MCPcopy Create free account
hub / github.com/NCAR/wrf-python / cartopy_xlim

Function cartopy_xlim

src/wrf/util.py:3683–3767  ·  view source on GitHub ↗

Return the x-axis limits in the projected coordinates. For some map projections, like :class`wrf.RotatedLatLon`, the :meth:`cartopy.GeoAxes.set_extent` method does not work correctly. This method is equivalent to: .. code-block:: python pc = crs.PlateCarree() xs,

(var=None, geobounds=None, wrfin=None, varname=None, timeidx=0,
                 method="cat", squeeze=True, cache=None)

Source from the content-addressed store, hash-verified

3681
3682
3683def cartopy_xlim(var=None, geobounds=None, wrfin=None, varname=None, timeidx=0,
3684 method="cat", squeeze=True, cache=None):
3685 """Return the x-axis limits in the projected coordinates.
3686
3687 For some map projections, like :class`wrf.RotatedLatLon`, the
3688 :meth:`cartopy.GeoAxes.set_extent` method does not work correctly. This
3689 method is equivalent to:
3690
3691 .. code-block:: python
3692
3693 pc = crs.PlateCarree()
3694 xs, ys, _ = self._cartopy().transform_points(pc,
3695 np.array([geobounds.bottom_left.lon,
3696 geobounds.top_right.lon]),
3697 np.array([geobounds.bottom_left.lat,
3698 geobounds.top_right.lat])).T
3699
3700
3701 _xlimits = xs.tolist()
3702 _ylimits = ys.tolist()
3703
3704 return (_xlimits, _ylimits)[0]
3705
3706 Args:
3707
3708 var (:class:`xarray.DataArray`, optional): A :class:`xarray.DataArray`
3709 variable that includes latitude,longitude coordinate information.
3710 If not used, then *wrfin* must be provided.
3711
3712 geobounds (:class:`wrf.GeoBounds`, optional): The geobounds to
3713 get the extents. If set to None and using the *var* parameter,
3714 the geobounds will be taken from the variable. If using a
3715 file, then the geobounds will be taken from the native grid.
3716
3717 wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \
3718 iterable, optional): WRF-ARW NetCDF
3719 data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile`
3720 or an iterable sequence of the aforementioned types. If not used,
3721 then *var* must be provided.
3722
3723 varname (:obj:`str`, optional): If using *wrfin*, then this will be the
3724 variable name to use to determine the geobounds. The variable
3725 can be a coordinate variable, or a regular variable that contains
3726 coordinate attributes. If None,
3727 then the 'XLAT', 'XLAT_M', 'XLONG', 'XLONG_M' variables
3728 will be used.
3729
3730 timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The
3731 desired time index. This value can be a positive integer,
3732 negative integer, or
3733 :data:`wrf.ALL_TIMES` (an alias for None) to return
3734 all times in the file or sequence. Default is 0.
3735
3736 method (:obj:`str`, optional): The aggregation method to use for
3737 sequences. Must be either 'cat' or 'join'.
3738 'cat' combines the data along the Time dimension.
3739 'join' creates a new dimension for the file index.
3740 The default is 'cat'.

Callers 2

ctt_test.pyFile · 0.90
quiver_test.pyFile · 0.90

Calls 2

_get_wrf_proj_geobndsFunction · 0.85
cartopy_xlimMethod · 0.80

Tested by

no test coverage detected