-
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
Cross-Section from HRRR output #1004
Comments
@dopplershift and @jrleeman: The general problem at play here seems to be that the dimensions of the data are not present as coordinates, and having x and y dimension coordinates is required for the current implementation of cross section interpolation to work. This isn't the first time I've seen this problem come up with dimensions lacking coordinates in relation to cross sections (WRF has been notorious for it), so I'd think MetPy should probably have something to handle this. I had two ideas on how to resolve this (but neither seems ideal, so other suggestions would be great):
|
Also, @atmosmattbrewer, to directly answer your last question, I don't believe there is any extra xarray manipulation that you are missing; it is simply a problem with MetPy's |
@jthielen : Since WRF output is a common analysis target, could you post the code you use to fill in the missing x and y coordinates? Perhaps this (or a suitably generalized variant) should be a MetPy helper function users can call when they know they have an Xarray Dataset that originated from WRF output. |
As requested, here is the code I used: https://gist.github.com/jthielen/8881d32d08d625c75c906a7e8ad7583f This issue with WRF, however, relates to something I've been wondering about for a little while now. I have some of these scripts built (and more I'd like to create) to make working with WRF files easier (a more pythonic API than what wrf-python currently has and having CF-compliance so it can play nice with MetPy). Salem came close to this already, but it looks like they are deprecating their WRF support soon in favor of wrf-python. And so, what would be the best place to contribute these efforts?
|
Also, tagging @tjwixtrom, since we talked at AMS about this and he has done some similar work. |
Has anyone had any success in using the metpy cross_section for HRRR or GFS grib data yet? I am now coming back to this problem and still have not had any success in making a cross section. Still pretty much running into the same issues as mentioned above and haven't found any examples any where online. |
@atmosmattbrewer Now with MetPy's Would you have a sample grib2 dataset that you'd be willing to share, along with its grid projection parameters? I can take a look and put together a quick demo based off of that. |
@jthielen Right now just for testing purposes I have been using the daily native level HRRR grib2 output (https://nomads.ncep.noaa.gov/pub/data/nccf/com/hrrr/prod/hrrr.20200805/conus/) The projection code I use is: |
I'd be interesting in including something like this in the docs if it takes care of it (unless the data file is unreasonable which case maybe python-training.) We should also look at whatever we can to improve the docs to |
This particular example with HRRR is a 519 MB grib2 file, so probably not best to include in the docs or maybe even python-training. I have some post-processed FV3-LAM output on a coarser (25km) version of the same grid that could probably function the same way for such a demo, and it is only 13 MB. I'll also be sure to keep |
Probably should be some combination of at least:
|
I just discovered this issue - thanks for tagging the salem issue @jthielen . Yes, I do believe that something better than wrf-python and separate from MetPy should exist, I personally don't have the bandwith for this. I still believe that wrf-python's API was not well designed because they seem to just have translated their NCL code to python. Now they have a lot of legacy to deal with, and on top of that the library's development does not look very active. I seems that a strong political decision at NCAR or Unidata is needed here to put more effort into python for WRF tools. (sorry for the out-of-topic rant) |
Thanks for the reply! After I gave a presentation at the AMS annual meeting back in January, there was some informal support from the NCAR GeoCAT team for an overhaul of wrf-python to be more pythonic and integrate with the pangeo ecosystem, but effort would have to come from the community in the immediate future, since the GeoCAT team's limited resources were prioritized elsewhere. I had hoped to spearhead that effort, but other research priorities (and the pandemic) got in the way since then. It is still something I'd like to see happen, but I unfortunately can't prioritize it myself either right now. Though, I'd be glad to discuss ideas with anyone else who wants to move it forward! |
I have an initial stab at this which can be found here. The basic idea is to wrap xarray's open_dataset by opening the input file, fixing metadata, and providing some basic diagnostic computations. Arrays are held in Dask, allowing for out-of-memory and delayed operations, so the code seems to be relatively efficient. Computations are currently mainly either vectorized adaptation of RIP/wrf-python or a modification of MetPy. I'm currently waiting for a few PRs to be merged in MetPy but the idea is to depend on MetPy for general computations and handle the model specific routines within the wrf-ens-tools code. We are currently very early in the development for this so input is definitely welcomed. |
Great talk! salem is still attracting some users disappointed with wrf-python btw. I would much rather have them go to a better supported package... @tjwixtrom great! There are some ideas about that in salem as well: https://github.com/fmaussion/salem/blob/697762b3b8daf195119889959535220726b12248/salem/sio.py#L951 - one of the fundamental ideas was to unstagger and add diagnostic variables on the go by mimicking netcdf variables for xarray. Maybe this is also what you are doing? In all cases I wish your efforts to take off, it would be great to help the community to converge. |
I've tried to follow this thread, but I'm stuck. I asked Unidata support for help and they said they were able to create a cross section with my data, which perhaps that tells you about my coding skills. Anyway, as university faculty, I would like to use this great tool in my mesoscale meteorology course if anyone can point me in the right direction. I'm trying to plot a hrrr model cross section. I can use the sample metpy code My code Since this is the HRRR model and my data set is the entire domain, it's clear the data lat/lon is shifted north and east, so it seems like the assign crs is not working as intended. Any advice would be appreciated. |
Just want to update here in case it helps out anyone else! Thanks @mvoss-wx for reaching out via eSupport as well. The main issue was in making sure the projection definition lined up with the provided coordinates. In this case, using the operational HRRR namelist to define the appropriate |
@dcamron , Thanks so much for checking this out. I tested and this works perfectly for the hrrr isobaric files. |
@meihan33 You can still use the approach taken in the example notebook that @jthielen posted above. I think this will work: cf_attrs = {
'grid_mapping_name': 'lambert_conformal_conic',
'standard_parallel': 38.5,
'longitude_of_central_meridian': -97.5,
'latitude_of_projection_origin': 38.5
}
ds = ds.metpy.assign_crs(cf_attrs).metpy.assign_y_x() |
@dopplershift Thank you very much for your suggestion. I added one more key and value pair in the dictionary: There are only some warnings left for each variable, it shows: I could probably find a way to drop these extra coordinate or axis. But the information may be useful actually, so I would just keep them by ignoring a page of warning messages. Thank you for any further suggestions you may have. |
Hello,
I have been trying to use MetPy's Cross-section functionality on HRRR model output and have run into problems with handling the coordinates and dimensions. I asked a stack overflow question, Metpy HRRR Cross Section, and was directed here. I have looked into one of the other issues related to this topic, #949, but the I still haven't been able to get fix my issue.
The data file I am using is HRRR model output transformed from grib2 to netcdf using xarray and pynio.
Here is what my dataset looks like after I parse it with metpy.parse_cf()
When try to do the cross-section this is the errors I get:
So I tried parsing one variable as suggested,
RH = data.metpy.parse_cf('RH_P0_L100_GLC0')
x, y = RH.metpy.coordinates('x', 'y')
and got this error code instead:
Is there extra xarray manipulation that I am missing to get the dimensions and coordinates to be correct?
The text was updated successfully, but these errors were encountered: