π§ CRS with MetPy#
What if you need to manually attach coordinate reference system because metpy canβt detect it?
[1]:
from herbie import Herbie
import metpy
[2]:
H = Herbie("2021-01-25 06:00", model="hrrr")
β
Found β model=hrrr β product=sfc β 2021-Jan-25 06:00 UTC F00 β GRIB2 @ aws β IDX @ aws
[3]:
ds = H.xarray("TMP:2 m")
π¨π»βπ Created directory: [C:\Users\blaylock\data\hrrr\20210125]
C:\Users\blaylock\_GITHUB\Herbie\herbie\archive.py:1041: UserWarning: sorry, on windows I couldn't remove the file.
warnings.warn("sorry, on windows I couldn't remove the file.")
[4]:
ds
[4]:
<xarray.Dataset> Dimensions: (y: 1059, x: 1799) Coordinates: time datetime64[ns] 2021-01-25T06:00:00 step timedelta64[ns] 00:00:00 heightAboveGround float64 2.0 latitude (y, x) float64 21.14 21.15 21.15 ... 47.86 47.85 47.84 longitude (y, x) float64 237.3 237.3 237.3 ... 299.0 299.0 299.1 valid_time datetime64[ns] 2021-01-25T06:00:00 Dimensions without coordinates: y, x Data variables: t2m (y, x) float32 292.3 292.3 292.3 ... 272.9 272.9 273.0 gribfile_projection object None Attributes: GRIB_edition: 2 GRIB_centre: kwbc GRIB_centreDescription: US National Weather Service - NCEP GRIB_subCentre: 0 Conventions: CF-1.7 institution: US National Weather Service - NCEP model: hrrr product: sfc description: High-Resolution Rapid Refresh - CONUS remote_grib: https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr.... local_grib: C:\Users\blaylock\data\hrrr\20210125\subset_f7ef... searchString: TMP:2 m
[5]:
ds.metpy.assign_crs(
dict(
grid_mapping_name="lambert_conformal_conic",
standard_parallel=(38.5, 38.5),
latitude_of_projection_origin=38.5,
longitude_of_central_meridian=262.5,
)
)
[5]:
<xarray.Dataset> Dimensions: (y: 1059, x: 1799) Coordinates: time datetime64[ns] 2021-01-25T06:00:00 step timedelta64[ns] 00:00:00 heightAboveGround float64 2.0 latitude (y, x) float64 21.14 21.15 21.15 ... 47.86 47.85 47.84 longitude (y, x) float64 237.3 237.3 237.3 ... 299.0 299.0 299.1 valid_time datetime64[ns] 2021-01-25T06:00:00 metpy_crs object Projection: lambert_conformal_conic Dimensions without coordinates: y, x Data variables: t2m (y, x) float32 292.3 292.3 292.3 ... 272.9 272.9 273.0 gribfile_projection object None Attributes: GRIB_edition: 2 GRIB_centre: kwbc GRIB_centreDescription: US National Weather Service - NCEP GRIB_subCentre: 0 Conventions: CF-1.7 institution: US National Weather Service - NCEP model: hrrr product: sfc description: High-Resolution Rapid Refresh - CONUS remote_grib: https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr.... local_grib: C:\Users\blaylock\data\hrrr\20210125\subset_f7ef... searchString: TMP:2 m
[6]:
ds.gribfile_projection
[6]:
<xarray.DataArray 'gribfile_projection' ()> array(None, dtype=object) Coordinates: time datetime64[ns] 2021-01-25T06:00:00 step timedelta64[ns] 00:00:00 heightAboveGround float64 2.0 valid_time datetime64[ns] 2021-01-25T06:00:00 Attributes: (12/17) crs_wkt: PROJCRS["unknown",BASEGEOGCRS["unknown",D... semi_major_axis: 6371229.0 semi_minor_axis: 6371229.0 inverse_flattening: 0.0 reference_ellipsoid_name: unknown longitude_of_prime_meridian: 0.0 ... ... standard_parallel: (38.5, 38.5) latitude_of_projection_origin: 38.5 longitude_of_central_meridian: 262.5 false_easting: 0.0 false_northing: 0.0 long_name: HRRR model grid projection