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

Function cartopy_ylim

src/wrf/util.py:3770–3854  ·  view source on GitHub ↗

Return the y-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

3768
3769
3770def cartopy_ylim(var=None, geobounds=None, wrfin=None, varname=None, timeidx=0,
3771 method="cat", squeeze=True, cache=None):
3772 """Return the y-axis limits in the projected coordinates.
3773
3774 For some map projections, like :class`wrf.RotatedLatLon`, the
3775 :meth:`cartopy.GeoAxes.set_extent` method does not work correctly. This
3776 method is equivalent to:
3777
3778 .. code-block:: python
3779
3780 pc = crs.PlateCarree()
3781 xs, ys, _ = self._cartopy().transform_points(pc,
3782 np.array([geobounds.bottom_left.lon,
3783 geobounds.top_right.lon]),
3784 np.array([geobounds.bottom_left.lat,
3785 geobounds.top_right.lat])).T
3786
3787
3788 _xlimits = xs.tolist()
3789 _ylimits = ys.tolist()
3790
3791 return (_xlimits, _ylimits)[1]
3792
3793 Args:
3794
3795 var (:class:`xarray.DataArray`, optional): A :class:`xarray.DataArray`
3796 variable that includes latitude,longitude coordinate information.
3797 If not used, then *wrfin* must be provided.
3798
3799 geobounds (:class:`wrf.GeoBounds`, optional): The geobounds to
3800 get the extents. If set to None and using the *var* parameter,
3801 the geobounds will be taken from the variable. If using a
3802 file, then the geobounds will be taken from the native grid.
3803
3804 wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \
3805 iterable, optional): WRF-ARW NetCDF
3806 data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile`
3807 or an iterable sequence of the aforementioned types. If not used,
3808 then *var* must be provided.
3809
3810 varname (:obj:`str`, optional): If using *wrfin*, then this will be the
3811 variable name to use to determine the geobounds. The variable
3812 can be a coordinate variable, or a regular variable that contains
3813 coordinate attributes. If None,
3814 then the 'XLAT', 'XLAT_M', 'XLONG', 'XLONG_M' variables
3815 will be used.
3816
3817 timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`, optional): The
3818 desired time index. This value can be a positive integer,
3819 negative integer, or
3820 :data:`wrf.ALL_TIMES` (an alias for None) to return
3821 all times in the file or sequence. Default is 0.
3822
3823 method (:obj:`str`, optional): The aggregation method to use for
3824 sequences. Must be either 'cat' or 'join'.
3825 'cat' combines the data along the Time dimension.
3826 'join' creates a new dimension for the file index.
3827 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_ylimMethod · 0.80

Tested by

no test coverage detected