[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[python #AEC-201933]: Help with MetPy plotting?
- Subject: [python #AEC-201933]: Help with MetPy plotting?
- Date: Wed, 08 Dec 2021 14:53:47 -0700
Greetings!
No worries, I just wanted to make sure we didn't get the pieces of the question
spread out over a whole bunch of places. The call to `expand_dims` doesn't look
correct to me. The problem you're running into with the original code is an
issue with MetPy's simplified plotting code trying to handle wrapping the image
plot around the earth:
https://github.com/Unidata/MetPy/issues/1915
This is an issue I'm planning on fixing for the next (1.2) release. In the
meantime, you can fix your plot by doing this before plotting:
ds.assign_coords(longitude=ds.longitude - 360)
This essentially changes the longitude coordinates from being in the range (0,
360) to (-360, 0) (and disabling MetPy's own wrapping).
I also wanted to give you a head up that your original code said "GFS temp
forecast", but you were plotting CAPE (convective available potential
temperature), which is vastly different than temperature.
Hope this helps!
Ryan
> Hey there, thanks for responding. Apologies for not seeing this sooner (and
> reaching out over Twitter)!
>
> I believe I solved the time issue by just adding a time dimension: "ds =
> ds.expand_dims(dim = 'time', axis = 0)". However, now, the plot appears to
> simply be plotting the data for one longitude along the prime meridian.
> However, the data is sound (colder near the poles, so the data isn't
> totally wonky).
>
> Here's the code that I'm using to read 'ds' into an xarray from a grib
> file:
>
> url = '
> https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20211206/00/atmos/gfs.t00z.pgrb2.0p50.f000
> '
> r = requests.get(url, allow_redirects=True)
> open('gfs.grib2', 'wb').write(r.content)
> ds = xr.load_dataset("gfs.grib2", engine="cfgrib",
> filter_by_keys={'stepType': 'instant', 'typeOfLevel': 'surface'})
>
> Attached below is a screenshot of the plotting of temperature along the one
> longitude coordinate; any ideas?
>
Ticket Details
===================
Ticket ID: AEC-201933
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.