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

Suggestion: adding station as index to multi-station retrievals #49

Closed
ks905383 opened this issue Nov 13, 2024 · 2 comments
Closed

Suggestion: adding station as index to multi-station retrievals #49

ks905383 opened this issue Nov 13, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@ks905383
Copy link

When getting observations from multiple stations:

from ndbc_api import NdbcApi

api = NdbcApi()

# get all standard meterological measurements for stations tplm2 and apam2
stdmet_df = api.get_data(
    station_ids=['tplm2', 'apam2'],
    mode='stdmet',
    start_time='2021-01-01',
    end_time='2022-01-01',
)

stdmet_df
Bildschirmfoto 2024-11-13 um 1 48 42 PM

The index of the returned df is only the timestamp, resulting in a non-unique index (because timestamps can be duplicated between different stations). Perhaps it may be useful to make station_id an index as well.

In addition to better leveraging pandas's index-based functions, this would also make it easier to flip between pandas and xarray (since df.to_xarray() uses those indices), for example.

(it's easy enough to do 'manually' through stdmet_df.reset_index().set_index(['station_id','timestamp']), but it may be a neater way of showing this information)

This is related to JOSS review openjournals/joss-reviews#7406.

@CDJellen
Copy link
Owner

Thank you for this suggestion as well @ks905383, I will include it in the next release. You make an excellent point on index uniqueness. I will include this in the next release.

@CDJellen CDJellen self-assigned this Nov 15, 2024
@CDJellen CDJellen added the enhancement New feature or request label Nov 15, 2024
@CDJellen
Copy link
Owner

As for #51 , the suggestions are incorporated in #52 and the release in #53. I am scoping an appropriate change which allows for station metadata in the returned xarray Datasets. Thanks again for the suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants