Skip to content

Commit

Permalink
put tests back
Browse files Browse the repository at this point in the history
  • Loading branch information
blaylockbk committed Jan 14, 2025
1 parent 246c2c1 commit 2df9fa9
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions herbie/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,16 +1142,21 @@ 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
# )

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()

# 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 All @@ -1171,7 +1176,7 @@ def xarray(
# ----------------------
# http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#appendix-grid-mappings
ds.coords["gribfile_projection"] = None
# ds.coords["gribfile_projection"].attrs = cf_params
ds.coords["gribfile_projection"].attrs = cf_params
ds.coords["gribfile_projection"].attrs["long_name"] = (
f"{self.model.upper()} model grid projection"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2df9fa9

Please sign in to comment.