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

need accessor to transform wind to earth relative #368

Open
blaylockbk opened this issue Aug 30, 2024 · 0 comments
Open

need accessor to transform wind to earth relative #368

blaylockbk opened this issue Aug 30, 2024 · 0 comments

Comments

@blaylockbk
Copy link
Owner

blaylockbk commented Aug 30, 2024

This is needed for models like the HRRR, RTMA, URMA, etc. if ds['v10'].attrs["GRIB_uvRelativeToGrid"] = 1 if you want to plot vectors (barbs or quivers) on a PlatteCarree projection)

# Transform Latitude and Longitude coordinate points (PlateCarree)
# to the source projection coordinates. We need the lat/lon in the
# projection coordinate space before we do the vector transform.
srcProj = ds.herbie.crs
srcProj_coords = srcProj.transform_points(
    pc, srcData.longitude.data, srcData.latitude.data
)

# Extract the X and Y coordinate arrays for the src projection.
X = srcProj_coords[:, :, 0]
Y = srcProj_coords[:, :, 1]

# Transform the U and V vectors to the earth-relative orientation
U_t, V_t = pc.transform_vectors(srcProj, X, Y, srcData[u].data, srcData[v].data)

ds["u10"].values = U_t
ds["v10"].values = V_t
ds['u10'].attrs["GRIB_uvRelativeToGrid"] = 0
ds['v10'].attrs["GRIB_uvRelativeToGrid"] = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant