https://github.com/zmoon/uscrn
Easily load U.S. CRN data
https://github.com/zmoon/uscrn
climate-data ncei noaa-data
Last synced: about 1 year ago
JSON representation
Easily load U.S. CRN data
- Host: GitHub
- URL: https://github.com/zmoon/uscrn
- Owner: zmoon
- License: mit
- Created: 2023-07-25T14:59:52.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-03T20:51:14.000Z (about 1 year ago)
- Last Synced: 2025-04-04T19:06:02.739Z (about 1 year ago)
- Topics: climate-data, ncei, noaa-data
- Language: Python
- Homepage: https://uscrn.readthedocs.io
- Size: 1.98 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uscrn
Easily load [U.S. Climate Reference Network](https://www.ncei.noaa.gov/access/crn/) (USCRN) data.
[](https://pypi.org/project/uscrn/)
[](https://github.com/zmoon/uscrn/actions/workflows/ci.yml)
[](https://uscrn.readthedocs.io/en/latest/)
[](https://app.codecov.io/gh/zmoon/uscrn)
[](https://results.pre-commit.ci/latest/github/zmoon/uscrn/main)
[](https://www.repostatus.org/#wip)
With `uscrn`, fetching and loading years of [data](https://www.ncei.noaa.gov/access/crn/qcdatasets.html) for all USCRN sites[^a] takes just one line of code[^b].
Example:
```python
import uscrn
df = uscrn.get_data(2019, "hourly", n_jobs=6) # pandas.DataFrame
ds = uscrn.to_xarray(df) # xarray.Dataset, with soil depth dimension if applicable (hourly, daily)
```
Both `df` (pandas) and `ds` (xarray) include dataset and variable metadata.
For `df`, these are in `df.attrs` and can be preserved by
writing to Parquet with the PyArrow engine[^d] with
[pandas v2.1+](https://pandas.pydata.org/docs/whatsnew/v2.1.0.html#other-enhancements).
```python
df.to_parquet("uscrn_2019_hourly.parquet", engine="pyarrow")
```
Conda install example[^c]:
```sh
conda create -n crn -c conda-forge python=3.11 joblib numpy pandas pyyaml requests xarray pyarrow netcdf4
conda activate crn
pip install --no-deps uscrn
```
[^a]: Use `uscrn.load_meta()` to load the site metadata table.
[^b]: Not counting the `import` statement...
[^c]: `uscrn` is not yet on conda-forge.
[^d]: Or the fastparquet engine with [fastparquet v2024.2.0+](https://github.com/dask/fastparquet/commit/9d7ee90e38103fef3dd1bd2f5eb0654b8bd3fdff).