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

Add CFS model #199

Merged
merged 31 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c00e7e6
Add CFS model
blaylockbk May 29, 2023
efc5187
add 6-hourly product
blaylockbk May 29, 2023
a93fc54
work on CFS
blaylockbk Jun 22, 2023
d6e0ba0
Merge branch 'main' of https://github.com/blaylockbk/Herbie into blay…
blaylockbk Jan 3, 2025
40efc74
seeing if cfs still works
blaylockbk Jan 3, 2025
fd56af9
Add warnings for alpha status of CFS templates
blaylockbk Jan 3, 2025
21d7882
added more products for CFS time series
blaylockbk Jan 4, 2025
1d6eb2f
updated cfs template for 6_hourly and monthly means
blaylockbk Jan 4, 2025
2848653
updated cfs template
blaylockbk Jan 9, 2025
c4c9057
update
blaylockbk Jan 14, 2025
f40bd4b
debug test-pick-points
blaylockbk Jan 14, 2025
e48b169
tests
blaylockbk Jan 14, 2025
c9000c4
try this
blaylockbk Jan 14, 2025
3b8e9d7
try updating dependencies
blaylockbk Jan 14, 2025
149b3e4
drop python 3.9 (xarray only supports >3.10)
blaylockbk Jan 14, 2025
1634dba
simple charity test
blaylockbk Jan 14, 2025
73490b2
update
blaylockbk Jan 14, 2025
4782b57
update
blaylockbk Jan 14, 2025
246c2c1
try this
blaylockbk Jan 14, 2025
2df9fa9
put tests back
blaylockbk Jan 14, 2025
8efad4c
update
blaylockbk Jan 14, 2025
68b936b
update
blaylockbk Jan 14, 2025
eb35db5
update
blaylockbk Jan 14, 2025
f2dd848
readd more tests
blaylockbk Jan 14, 2025
f70bead
update
blaylockbk Jan 14, 2025
0f568de
try wit pygrib again
blaylockbk Jan 15, 2025
1d282db
turn pygrib off again
blaylockbk Jan 15, 2025
997e82e
fix numpy dependency
blaylockbk Jan 15, 2025
94c0c25
restore test
blaylockbk Jan 15, 2025
3aa742b
another attempt, (this is getting old)
blaylockbk Jan 15, 2025
707f878
added tests and updated notebook
blaylockbk Jan 16, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: true
matrix:
os: ["windows-latest"]
python-version: ["3.11"]
python-version: ["3.12"]

env:
OS: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: true
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
# In order to save resources, only run particular
# matrix slots on other OS than Linux.
include:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ herbie/_version.py

*.pkl
.coverage

.ruff_cache/
2 changes: 1 addition & 1 deletion ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- metpy
- numpy>=1.26.2
- pandas>=2.1.4
- pygrib
- pygrib>=2.1.6
- pytest
- requests>=2.31.0
- scikit-learn
Expand Down
9 changes: 5 additions & 4 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cfgrib>=0.9.9.1
cfgrib>=0.9.15
metpy>=1.3.0
numpy>=1.22.3
pandas>=1.4.1
requests>=2.27.1
pandas>=2.2.3
pygrib>=2.1.6
requests>=2.32.3
toml>=0.10.2
xarray>=2022.3.0
xarray>=2025.1.1
2,780 changes: 2,780 additions & 0 deletions docs/gallery/noaa_models/cfs.ipynb

Large diffs are not rendered by default.

60 changes: 22 additions & 38 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,73 @@ name: herbie-dev
channels:
- conda-forge
dependencies:
- python>=3.11
- pip
- git
- curl
- rclone # Not required, but is an awesome alternative (https://rclone.org/)
- wgrib2 # ONLY AVAILABLE ON LINUX. Comment if not using Linux.
- eccodes>=2.31
- git
- pip
- python>=3.13
- rclone
- uv
- wgrib2 # Linux only

# ===========
# Handy Tools
# ===========
# ============
# Dependencies
# ============
- cartopy>=0.22
- cfgrib>=0.9.10.4
- eccodes>=2.31
- geopandas
- h5py
- jupyter
- jupyterlab
- matplotlib>=3.4.3
- metpy
- netcdf4
- numpy>=1.25
- pandas>=2.0
- polars>=1.0
- polars>=1.17.1
- pygrib>=2.1.4
- pylint
- pyproj>=3.6
- requests>=2.31
- s3fs
- scipy
- scipy>=1.15.1
- scikit-learn
- toml
- xarray>=2023.7
- zarr

# ===================
# Formatter & Testing
# ===================
# ===========
# Development
# ===========
- ruff
- black
- black-jupyter
- isort
- pylint
- pytest
- pytest-cov
- line_profiler

# =============
# Documentation
# =============
- sphinx>=4.4.0
- nbsphinx
- nbconvert>=6.5
- pydata-sphinx-theme # PyData Sphinx Theme (i.e, Numpy, Pandas, MetPy)
- pydata-sphinx-theme
- sphinx-design
- recommonmark
- sphinx-markdown-tables
- sphinxcontrib-mermaid # For mermaid diagram support
- sphinxcontrib-mermaid
- autodocsumm
- sphinx-autosummary-accessors # pandas and xarray accessor docs
- sphinx-autosummary-accessors
- latexmk
- myst-parser
- linkify-it-py

#- pip:
#- cartopy>=0.22
# Herbie: Development version from GitHub
#- git+https://github.com/blaylockbk/Herbie.git

# Install a specific branch
#- git+https://github.com/blaylockbk/Herbie.git@blaylockbk/issue98

# Borrow some tools from my garage
#- git+https://github.com/blaylockbk/Carpenter_Workshop.git

# Create idx files on the fly!! -- Waiting for package maturity
#- git+https://github.com/joxtoby/beltzer.git
# =============================================================================
# Extra Setup Steps
# Setup Steps
# =============================================================================
# conda activate herbie-dev
# mamba activate herbie-dev
# git clone https://github.com/blaylockbk/Herbie.git
# cd Herbie
# pip install -e .
#
# cd ~
# git clone https://github.com/blaylockbk/Carpenter_Workshop.git
# cd Carpenter_Workshop
# pi install -e .
Expand Down
38 changes: 24 additions & 14 deletions herbie/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ def _validate(self) -> None:
_models = {m for m in dir(model_templates) if not m.startswith("__")}
_products = set(self.PRODUCTS)

assert self.date < pd.Timestamp.utcnow().tz_localize(
None
), "🔮 `date` cannot be in the future."
assert self.date < pd.Timestamp.utcnow().tz_localize(None), (
"🔮 `date` cannot be in the future."
)
assert self.model in _models, f"`model` must be one of {_models}"
assert self.product in _products, f"`product` must be one of {_products}"

Expand Down Expand Up @@ -910,7 +910,7 @@ def subset(search, outFile):
grib_source = f"file://{str(self.grib)}"
if verbose:
print(
f'📇 Download subset: {self.__repr__()}{" ":60s}\n cURL from {grib_source}'
f"📇 Download subset: {self.__repr__()}{' ':60s}\n cURL from {grib_source}"
)

# -----------------------------------------------------
Expand Down Expand Up @@ -1142,16 +1142,26 @@ def xarray(
# Get CF grid projection information with pygrib and pyproj because
# this is something cfgrib doesn't do (https://github.com/ecmwf/cfgrib/issues/251)
# NOTE: Assumes the projection is the same for all variables
with pygrib.open(str(local_file)) as grb:
msg = grb.message(1)
cf_params = CRS(msg.projparams).to_cf()

# Funny stuff with polar stereographic (https://github.com/pyproj4/pyproj/issues/856)
# TODO: Is there a better way to handle this? What about south pole?
if cf_params["grid_mapping_name"] == "polar_stereographic":
cf_params["latitude_of_projection_origin"] = cf_params.get(
"latitude_of_projection_origin", 90
)
# TODO: Issues with pygrib in tests. Segmentation Fault. Is it Numpy 2???
use_pygrib = False
if use_pygrib:
with pygrib.open(str(local_file)) as grb:
msg = grb.message(1)
cf_params = CRS(msg.projparams).to_cf()

#grb = pygrib.open(str(local_file))
#msg = grb.message(1)
#cf_params = CRS(msg.projparams).to_cf()
#grb.close()

# Funny stuff with polar stereographic (https://github.com/pyproj4/pyproj/issues/856)
# TODO: Is there a better way to handle this? What about south pole?
if cf_params["grid_mapping_name"] == "polar_stereographic":
cf_params["latitude_of_projection_origin"] = cf_params.get(
"latitude_of_projection_origin", 90
)
else:
cf_params = {}

# Here I'm looping over each dataset in the list returned by cfgrib
for ds in Hxr:
Expand Down
1 change: 1 addition & 0 deletions herbie/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from .rtma import *
from .usnavy import *
from .urma import *
from .cfs import *

# ======================================================================
# Import Private Model Templates
Expand Down
Loading
Loading