-
Notifications
You must be signed in to change notification settings - Fork 53
HRRR Async Refactor #301
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
Merged
Merged
HRRR Async Refactor #301
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/blossom-ci |
Grid validation: import numpy as np
from herbie import Herbie
import pyproj
def hrrr_grid() -> tuple[np.array, np.array]:
"""Generates the HRRR lambert conformal projection grid coordinates. Creates the
HRRR grid using single parallel lambert conformal mapping
Note
----
For more information about the HRRR grid see:
- https://ntrs.nasa.gov/api/citations/20160009371/downloads/20160009371.pdf
Returns
-------
Returns:
tuple: (lat, lon) in degrees
"""
# a, b is radius of globe 6371229
p1 = pyproj.CRS("proj=lcc lon_0=262.5 lat_0=38.5 lat_1=38.5 lat_2=38.5 a=6371229 b=6371229")
p2 = pyproj.CRS("latlon")
transformer = pyproj.Transformer.from_proj(p2, p1)
itransformer = pyproj.Transformer.from_proj(p1, p2)
# Start with getting grid bounds based on lat / lon box (SW-NW-NE-SE)
# Reference seems a bit incorrect from the actual data, grabbed from S3 HRRR gribs
# Perhaps cell points? IDK
lat = np.array([21.138123, 47.83862349881542, 47.84219502248866, 21.140546625419148])
lon = np.array([237.280472, 225.90452026573686, 299.0828072281622, 287.71028150897075])
easting, northing = transformer.transform(lat, lon)
E, N = np.meshgrid(np.linspace(easting[0], easting[2], 1799), np.linspace(northing[0] , northing[1] , 1059))
lat, lon = itransformer.transform(E, N)
lon = np.where(lon < 0, lon + 360, lon)
return lat, lon
def main():
H = Herbie('2021-01-01 12:00', model='hrrr', product='sfc', fxx=6)
H.download(':500 mb')
x = H.xarray('TMP:2 m')
lat, lon = hrrr_grid()
print(np.mean(x.coords['latitude'].values - lat))
print(np.mean(x.coords['longitude'].values - lon))
if __name__ == "__main__":
main()
``` |
/blossom-ci |
/blossom-ci |
/blossom-ci |
/blossom-ci |
/blossom-ci |
/blossom-ci |
/blossom-ci |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Earth2Studio Pull Request
Description
round two, this time with HRRR. Similar overhaul as GFS focuses on complete async and interfacing directly with the grib files to get significant speed ups
Sanity check:
Checked with:
that gives:
New version Time taken: 93.54 seconds
Main branch version Time taken: 2760.56 seconds
Also plotted a few for visual comparison:
A similar process was done with the forecast source but with a set of two lead times at (timedelta(hours=1), timedelta(hours=3), timedelta(hours=18)) and making sure tp (APCP is included and is the 1 hour accumulated)
Checklist
Dependencies