[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #AEC-201933]: Help with MetPy plotting?



Hi,

Apologies this got dropped. Did you get this issue solved?

Ryan

> Hi Ryan,
> 
> This did the trick for the GFS! Thank you! Unfortunately, when testing with
> HRRR and NAM data, I get "AttributeError: crs attribute is not available."
> I've pasted the full error down below.
> 
> Thank you for your help!
> 
> Full error message:
> 
> ---------------------------------------------------------------------------AttributeError
> Traceback (most recent call
> last)/tmp/ipykernel_1431666/884204437.py in <module>     13 pc.size =
> (10, 8)     14 pc.panels = [panel]---> 15 pc.show()
> ~/Projects/modap/env/lib/python3.9/site-packages/metpy/plots/declarative.py
> in show(self)    587     def show(self):    588         """Show the
> constructed graphic on the screen."""--> 589         self.draw()
> 590         plt.show()    591
> ~/Projects/modap/env/lib/python3.9/site-packages/metpy/plots/declarative.py
> in draw(self)    574         for panel in self.panels:    575
> with panel.hold_trait_notifications():--> 576
> panel.draw()    577     578     def save(self, *args, **kwargs):
> ~/Projects/modap/env/lib/python3.9/site-packages/metpy/plots/declarative.py
> in draw(self)    839                 self.ax.set_global()    840
> elif self.area is not None:--> 841
> self.ax.set_extent(self.area, ccrs.PlateCarree())    842     843
> # Draw all of the plots.
> ~/Projects/modap/env/lib/python3.9/site-packages/metpy/plots/declarative.py
> in ax(self)    802         # map projection.    803         if
> getattr(self, '_ax', None) is None:--> 804             self._ax =
> self.parent.figure.add_subplot(*self.layout,
> projection=self._proj_obj)    805     806         return self._ax
> ~/Projects/modap/env/lib/python3.9/site-packages/metpy/plots/declarative.py
> in _proj_obj(self)    740                     return
> self.plots[0].griddata[0].metpy.cartopy_crs    741
> else:--> 742                     return
> self.plots[0].griddata.metpy.cartopy_crs    743             else:
> 744                 return lookup_projection(self.projection)
> ~/Projects/modap/env/lib/python3.9/site-packages/metpy/xarray.py in
> cartopy_crs(self)    236     def cartopy_crs(self):    237
> """Return the coordinate reference system (CRS) as a cartopy
> object."""--> 238         return self.crs.to_cartopy()    239     240
> @property
> ~/Projects/modap/env/lib/python3.9/site-packages/metpy/xarray.py in
> crs(self)    231         if 'metpy_crs' in self._data_array.coords:
> 232             return self._data_array.coords['metpy_crs'].item()-->
> 233         raise AttributeError('crs attribute is not available.')
> 234     235     @property
> AttributeError: crs attribute is not available.
> 
> 
> address@hidden> wrote:
> 
> > Greetings!
> >
> > Apologies, there was a glitch in the code I sent you that I didn't catch
> > while testing. `assign_coords` doesn't work in-place, but returns a new
> > Dataset that you need to hold onto and use. There's also an issue where
> > Metpy's plotting expects longitude to have some units, so you need to
> > assign those units after assigning the coordinate. Try this:
> >
> >     ds = ds.assign_coords(longitude=ds.longitude - 360)
> >
> >     # Set units on longitude
> >     ds.longitude.attrs['units'] = 'degree'
> >
> > Cheers!
> >
> > Ryan
> >
> >
> > 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.
> >
> >
> >
> 
> 


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.



pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy