-
Notifications
You must be signed in to change notification settings - Fork 416
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
Identify 'lv_' variables as vertical coordinates. #1225
Conversation
ncl_convert2nc starts its vertical coordinate variables with the string "lv_". Added this to the set of regular expressions to match in metpy.xarray.coordinate_criteria. For example, when NARR grib files are converted from grib to netCDF the 10-m zonal wind is stored in a variable called U_GRD_221_HTGL with a vertical coordinate lv_HTGL5. long_name: fixed height above ground units: m Let metpy.parse_cf() recognize this. Otherwise you get an Attribute error AttributeError: vertical attribute is not available.
Good catch! Would you be able to add a test for this by adding an entry like Lines 372 to 410 in 82e5258
|
Yes, I will add a test for this in the test_xarray.py file, as suggested! |
Restored whitespace to match master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference would also be to fix NCL to be CF-compliant, but alas. I think this is a reasonable way to make things more useful. Thanks for the PR!
ncl_convert2nc starts its vertical coordinate variables with the
string "lv_". Added this to the set of regular expressions to match
in metpy.xarray.coordinate_criteria.
For example, when you download NARR grib files from https://nomads.ncdc.noaa.gov/data/narr/
and convert them from grib to netCDF, the 10-m zonal wind is stored in a variable called U_GRD_221_HTGL with a vertical coordinate lv_HTGL5.
Here are its attributes:
int lv_HTGL5(lv_HTGL5) ;
lv_HTGL5:long_name = "fixed height above ground" ;
lv_HTGL5:units = "m" ;
Unfortunately, because lv_HTGL5 doesn't have units of pressure, nor the "positive" attribute indicating positive is "up". metpy.parse_cf() doesn't recognize this as a vertical coordinate. It would be nice if ncl_convert2nc did this for you, but I think its development is over.
Could we have metpy.parse_cf() recognize this prefix? i.e. "lv_"
Otherwise you get an Attribute error
AttributeError: vertical attribute is not available.
p.s. sorry about empty line in line 194. not needed. Couldn't figure out an easy way to remove.
Description Of Changes
Checklist