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

'MercatorWithLatTS' object has no attribute '_x_limits' #162

Closed
GautamKumarSaw opened this issue Feb 18, 2022 · 4 comments
Closed

'MercatorWithLatTS' object has no attribute '_x_limits' #162

GautamKumarSaw opened this issue Feb 18, 2022 · 4 comments
Assignees

Comments

@GautamKumarSaw
Copy link

Hi
I am new to wrf_python
I want to plot the slp (sea level Pressure) variable using wrf_python, for that, I have imported all the necessary libraries but I get this error
'MercatorWithLatTS' object has no attribute '_x_limits'
over the line (code)
cart_proj = get_cartopy(slp)

Any help would be really appreciated

from cartopy.crs import Mercator, Globe
slp = getvar(wrfin, 'slp', timeidx=0)
cart_proj = get_cartopy(slp)
lats, lons = latlon_coords(slp)
print(cart_proj, '\n', lats, '\n', lons)
fig = plt.figure(figsize=(10,10))
ax = plt.axes(projection=cart_proj)
ax.coastlines(linewidth=0.5)
lvl = np.arange(980, 1030, 2.5)
plt.contour(lons,
lats,
slp,
levels=lvl,
colors='k',
transform=crs.PlateCarree())

@sezick
Copy link

sezick commented Feb 23, 2022

I recently updated all my conda packages, and I am getting this same (and new to me) error when trying to extract cartography information, specifically when the output uses a Mercator projection:

AttributeError: 'MercatorWithLatTS' object has no attribute '_x_limits'

This error seems to be very similar to an older resolved issue: #77

I am using the following versions of wrf-python and cartopy:
Name Version Build Channel
cartopy 0.20.2 py39hb53ae2a_3 conda-forge
wrf-python 1.3.2.6 py39h5c3af23_0 conda-forge

I do not get this error when the output use another projection (e.g., Lambert conformal).

@michaelavs
Copy link
Contributor

Hi @GautamKumarSaw and @sezick,
I'm looking into this issue now and I have a couple of ideas as to what may be causing it and possibly a solution while we work to fix the issue. I went through the issue and linked PR you mentioned and then compared those updates to what has been done in Cartopy since 2018 (with respect to the Mercator projection and specifically "_x_limits/_y_limits" vs "_xlimits/_ylimits"). It looks like Cartopy completely dropped support for "_xlimits" and "_ylimits" which trickles down into the wrf-python work around from the PR you linked and then causes an attribute error. My thought process here is that because wrf-python is defining "_x_limits" based on a previously defined "_xlimits", when used with Cartopy, the "_xlimits" does not exists which then results in "_x_limits" not existing and raising the attribute error. If this is true/the correct understanding on my side, I believe it can be resolved with a fairly simple fix (if/else type statement so that cartopy < 0.17 doesn't lose support) and we can go on from there. I will bring this up with other members of my team and see what they think.

In the mean time, I think you may need to either define the mercator projection by hand (ax = plt.axes(projection=crs.Mercator()) or there may be some help in using the "geobounds" or "varname" args with the get_cartopy call (this option seems to be less likely to be successful given my above thoughts on what is causing the problem, but always worth a shot).

@GautamKumarSaw
Copy link
Author

Hi @michaelavs
Thanks for the reply
I have gone through the "geobounds" or "varname" as you mentioned above but they are not working and still giving the same error.

@michaelavs
Copy link
Contributor

Hi @GautamKumarSaw and @sezick,
We released a new version of wrf-python (v1.3.3) which contains the fix for the Mercator projection. This update can be done with conda or by building the software from source. When updating your package, please also ensure you are using the most up to date version of Cartopy (>=0.20) as this update will most likely have issues with versions below 0.19. I think you both will be at a correct version of Cartopy based on the error you received, but I wanted to ensure that was mentioned for anyone in the future who may have a similar issue.

Let me know if you have any issues with updating your wrf-python version!

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

3 participants