Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define dtype for station info lat-lon #3188

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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