Skip to content

Commit

Permalink
define dtype for station info lat-lon
Browse files Browse the repository at this point in the history
  • Loading branch information
kgoebber committed Sep 13, 2023
1 parent c0826bc commit f102c3b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/metpy/io/station_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ def key_finder(df):
raise KeyError('Second argument not provided to add_station_lat_lon, but none of '
f'{names_to_try} were found.')

df['latitude'] = None
df['longitude'] = None
df['latitude'] = np.nan
df['longitude'] = np.nan

if stn_var is None:
stn_var = key_finder(df)
for stn in df[stn_var].unique():
Expand Down
1 change: 1 addition & 0 deletions tests/io/test_station_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_add_lat_lon_station_data():
assert_almost_equal(df.loc[df.station == 'KDEN'].longitude.values[0], -104.65)
assert_almost_equal(df.loc[df.station == 'PAAA'].latitude.values[0], np.nan)
assert_almost_equal(df.loc[df.station == 'PAAA'].longitude.values[0], np.nan)
assert df['longitude'].dtype == np.float64


def test_add_lat_lon_station_data_optional():
Expand Down

0 comments on commit f102c3b

Please sign in to comment.