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

Small README changes #56

Merged
merged 7 commits into from
Nov 23, 2024
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
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#### Contributing

The `ndbc-api` is actively maintained, please feel free to open a pull request if you have any suggested improvements, test coverage is strongly preferred.

##### Testing

Tests are prepared and executed using the `pytest` framework, and designed to use cached responses rather than making new HTTP requests to the NDBC Data Service. In order to run tests, you will need to install the additional packages in `requirements_dev.txt` (also encoded in the `dev` group in `pyproject.toml`)

For pip installation, please create a clean virtual environment and run:

```bash
pip install -r requirements.txt
pip install -r requirements_dev.txt
```

For poetry-managed installations, please run:

```bash
poetry install
```

##### Running Tests

All tests can be run from the root directory using `python3 -m pytest --run-slow --run-private`.

The two flags in the command above are optional, but can be useful for running all tests, including those marked as slow or private. The `--run-slow` flag will run tests marked with the `@pytest.mark.slow` decorator, and the `--run-private` flag will run tests marked with the `@pytest.mark.private` decorator. Tests which take more than 30 seconds are typically marked as slow, while test for internals are marked as private.

##### Pull Requests

In order for a pull request to merge to `main`, all tests must pass, and the code must be reviewed by at least one other contributor.

Breaking changes will be considered, especially in the current `alpha` state of the package on `PyPi`. As the API further matures, breaking changes will only be considered with new major versions (e.g. `N.0.0`).

Alternatively, if you have an idea for a new capability or improvement, feel free to open a feature request issue outlining your suggestion and the ways in which it will empower the atmospheric research community.
40 changes: 23 additions & 17 deletions README.md
Copy link
Contributor Author

@rwegener2 rwegener2 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 83 is really interesting, but I worry it is a bit dense for someone with less programming background. I would consider adding some higher level text before the denser paragraph, for example maybe
"NdbcApi provides a singular access point for NDBC data. All the methods for finding data, metadata, and locating stations are available using the api object."

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this suggestion; I agree and have included this change in the PR you opened.

While I enjoyed building these features when initially designing the API, they are all but irrelevant to end users.

Additionally, I've split off the test instructions into a new CONTRIBUTING.md guide.

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ The API uses synchronous HTTP requests to compile data matching the user-supplie
* pandas
* bs4
* html5lib>=1.1
* xarray
* scipy

##### Development
If you would like to contribute to the growth and maintenance of the `ndbc-api`, please feel free to open a PR with tests covering your changes. The tests leverage `pytest` and depend on the above requirements, as well as:
Expand All @@ -80,14 +82,14 @@ from ndbc_api import NdbcApi
api = NdbcApi()
```

The `api` is a singleton, such that the underlying `RequestHandler` and NDBC station-level `RequestCache`s are shared between instances. Both the singleton metaclass and `RequestHandler` are implemented to reduce the likelihood of repeat requests to the NDBC's data service, and to converse NDBC resources. This is balanced by a station-level `cache_limit`, implemented as an LRU cache, which seeks to respect user resources.
The `NdbcApi` provides a unified access point for NDBC data. All methods for obtaining data, metadata, and locating stations are available using the `api` object. The `get_data` method is the primary method for accessing NDBC data, and is used to retrieve measurements from a given station over a specified time range. This method can request data from the NDBC HTTP Data Service or the THREDDS data service, and return the data as a `pandas.DataFrame`, `xarray.Dataset` or python `dict` object.

Data made available by the NDBC falls into two broad catagories.
Data made available by the NDBC falls into two broad categories.

1. Station metadata
2. Station measurements

The `api` supports a range of public methods for accessing data from the above catagories.
The `api` supports a range of public methods for accessing data from the above categories.

##### Station metadata

Expand Down Expand Up @@ -144,7 +146,7 @@ nearby_stations_df = api.radial_search(lat=lat, lon=lon, radius=radius, units=un
###### `station`

```python3
# get staion metadata
# get station metadata
tplm2_meta = api.station(station_id='tplm2')
# parse the response as a Pandas DataFrame
tplm2_df = api.station(station_id='tplm2', as_df=True)
Expand All @@ -170,9 +172,9 @@ tplm2_historical_df = api.available_historical(station_id='tplm2', as_df=True)

##### Station measurements

The `api` has two public method which support accessing supported NDBC station measurements.
The `api` has two public methods which support accessing supported NDBC station measurements.

1. The `get_modes` method, which returns a list of supported `mode`s, coresponding to the data formats provided by the NDBC data service.
1. The `get_modes` method, which returns a list of supported `mode`s, corresponding to the data formats provided by the NDBC data service. For example, the `adcp` mode represents "Acoustic Doppler Current Profiler" measurements, providing information about ocean currents at different depths, while `cwind` represents "Continuous winds" data, offering high-frequency wind speed and direction measurements.

Note that not all stations provide the same set of measurements. The `available_realtime` and `available_historical` methods can be called on a station-by station basis to ensure a station has the desired data available, before building and executing requests with `get_data`.

Expand Down Expand Up @@ -202,10 +204,23 @@ print(modes)
]
```

The mode values above map directly to the identifiers used buy the NDBC. Desriptions for each mode are presented below:
* `adcp`: Acoustic Doppler Current Profiler measurements, providing information about ocean currents at different depths.
* `cwind`: Continuous winds data, offering high-frequency wind speed and direction measurements.
* `ocean`: Oceanographic data, including water temperature, salinity, and wave measurements.
* `spec`: Spectral wave data, providing detailed information about wave energy and direction.
* `stdmet`: Standard meteorological data, including air temperature, pressure, wind speed, and visibility.
* `supl`: Supplemental measurements, which can vary depending on the specific buoy and its sensors.
* `swden`: Spectral wave density data, providing information about the distribution of wave energy across different frequencies.
* `swdir`: Spectral wave direction data, indicating the primary direction of wave energy.
* `swdir2`: Secondary spectral wave direction data, capturing additional wave direction information.
* `swr1`: First-order spectral wave data, providing basic wave height and period information.
* `swr2`: Second-order spectral wave data, offering more detailed wave measurements.

###### `get_data`

```python3
# get all continuous wind measurements for station tplm2
# get all continuous wind (`cwind`) measurements for station tplm2
cwind_df = api.get_data(
station_id='tplm2',
mode='cwind',
Expand All @@ -229,7 +244,7 @@ wspd_df = api.get_data(
as_df=True,
cols=['WSPD']
)
# get all standard meterological measurements for stations tplm2 and apam2
# get all standard meterological (`stdmet`) measurements for stations tplm2 and apam2
stdmet_df = api.get_data(
station_ids=['tplm2', 'apam2'],
mode='stdmet',
Expand All @@ -249,15 +264,6 @@ stdmet_df = api.get_data(
#### More Information
Please see [the included example notebook](/notebooks/overview.ipynb) for a more detailed walkthrough of the API's capabilities.


#### Questions
If you have questions regarding the library please post them into
the [GitHub discussion forum](https://github.com/cdjellen/ndbc-api/discussions).


#### Contributing
The `ndbc-api` is actively maintained, please feel free to open a pull request if you have any suggested improvements, test coverage is strongly preferred.

As a reminder, breaking changes will be considered, especially in the current `alpha` state of the package on `PyPi`. As the API further matures, breaking changes will only be considered with new major versions (e.g. `N.0.0`).

Alternatively, if you have an idea for a new capability or improvement, feel free to open a feature request issue outlining your suggestion and the ways in which it will empower the atmospheric research community.
Loading