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

Mercator fix #174

Merged
merged 9 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wrf/g_slp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_slp(wrfin, timeidx=0, method="cat", squeeze=True,

units (:obj:`str`): The desired units. Refer to the :meth:`getvar`
product table for a list of available units for 'slp'. Default
is 'Pa'.
is 'hPa'.

Returns:

Expand Down
17 changes: 10 additions & 7 deletions src/wrf/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from Ngl import Resources



if cartopy_enabled():
class MercatorWithLatTS(crs.Mercator):
"""A :class:`cartopy.crs.Mercator` subclass that adds support for
Expand Down Expand Up @@ -60,6 +61,10 @@ def __init__(self, central_longitude=0.0,
("units", "m")]
super(crs.Mercator, self).__init__(proj4_params, globe=globe)

# Need to have x/y limits defined for the initial hash which
# gets used within transform_points for caching
self._x_limits = self._y_limits = None

# Calculate limits.
limits = self.transform_points(
crs.Geodetic(),
Expand All @@ -76,14 +81,12 @@ def __init__(self, central_longitude=0.0,
else:
xlimits[0] = -xlimits[0]

self._xlimits = tuple(xlimits)
self._ylimits = tuple(limits[..., 1])

# Compatibility with cartopy >= 0.17
self._x_limits = self._xlimits
self._y_limits = self._ylimits
self._x_limits = tuple(xlimits)
self._y_limits = tuple(limits[..., 1])

self._threshold = np.diff(self.x_limits)[0] / 720
self._threshold = min(np.diff(self.x_limits)[0] / 720,
np.diff(self.y_limits)[0] / 360)


def _ismissing(val, islat=True):
Expand Down Expand Up @@ -824,7 +827,7 @@ def _cartopy(self):

def _proj4(self):
_proj4 = ("+proj=stere +units=m +a={} +b={} "
"+lat0={} +lon_0={} +lat_ts={} +nadgrids=@null".format(
"+lat_0={} +lon_0={} +lat_ts={} +nadgrids=@null".format(
Constants.WRF_EARTH_RADIUS,
Constants.WRF_EARTH_RADIUS,
self._hemi,
Expand Down