From 4a687473ed864b397787330e7ab12f7ffdf36ebb Mon Sep 17 00:00:00 2001 From: Bill Ladwig Date: Fri, 30 Mar 2018 15:38:49 -0600 Subject: [PATCH] Documentation fixes --- doc/source/new.rst | 18 ++++++------- src/wrf/g_latlon.py | 61 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/doc/source/new.rst b/doc/source/new.rst index 6103c43..f32b1f6 100644 --- a/doc/source/new.rst +++ b/doc/source/new.rst @@ -9,15 +9,15 @@ v1.1.3 - Release 1.1.3 - Fixed/Enhanced the cloud top temperature diagnostic. - - Optical depth was not being calculated correctly when - cloud ice mixing ratio was not available. - - Fixed an indexing bug that caused crashes on Windows, but should have been - crashing on all platforms. - - Users can now specify if they want cloud free regions to use fill values, - rather than the default behavior of using the surface temperature. - - Users can now specify the optical depth required to trigger the cloud - top temperature calculation. However, the default value of 1.0 should be - sufficient for most users. + - Optical depth was not being calculated correctly when + cloud ice mixing ratio was not available. + - Fixed an indexing bug that caused crashes on Windows, but should have been + crashing on all platforms. + - Users can now specify if they want cloud free regions to use fill values, + rather than the default behavior of using the surface temperature. + - Users can now specify the optical depth required to trigger the cloud + top temperature calculation. However, the default value of 1.0 should be + sufficient for most users. - Added 'th' alias for the theta product. - Fixed a crash issue related to updraft helicity when a dictionary is used as the input. diff --git a/src/wrf/g_latlon.py b/src/wrf/g_latlon.py index 44363c9..a31ae8a 100755 --- a/src/wrf/g_latlon.py +++ b/src/wrf/g_latlon.py @@ -162,6 +162,67 @@ def get_lon(wrfin, timeidx=0, method="cat", squeeze=True, def _llxy_mapping(wrfin, x_or_lat, y_or_lon, func, timeidx, stagger, squeeze, meta, as_int=None): + """Return the x,y/lat,lon coordinates for a dictionary input. + + The leftmost dimension(s) for the result is: + + - return_val[key,...,0,...] will contain the x/lat values. + - return_val[key,...,1,...] will contain the y/lon values. + + Nested dictionaries are allowed. + + Args: + + wrfin (:obj:`dict`): A mapping of key name to a WRF NetCDF file object + or sequence of WRF NetCDF file objects. + + x_or_lat (:obj:`float` or sequence): A single latitude/x value or a + sequence of latitude/x values to be converted. + + y_or_lon (:obj:`float` or sequence): A single longitude/y value or a + sequence of longitude/y values to be converted. + + func (function): Either the xy_to_ll or ll_to_xy function. + + timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`): The + desired time index. This value can be a positive integer, + negative integer, or + :data:`wrf.ALL_TIMES` (an alias for None) to return + all times in the file or sequence. The default is 0. + + stagger (:obj:`str`): By default, the values are returned on the mass + grid, but a staggered grid can be chosen with the following + options: + + - 'm': Use the mass grid (default). + - 'u': Use the same staggered grid as the u wind component, + which has a staggered west_east (x) dimension. + - 'v': Use the same staggered grid as the v wind component, + which has a staggered south_north (y) dimension. + + squeeze (:obj:`bool`, optional): Set to False to prevent dimensions + with a size of 1 from being automatically removed from the shape + of the output. Default is True. + + meta (:obj:`bool`, optional): Set to False to disable metadata and + return :class:`numpy.ndarray` instead of + :class:`xarray.DataArray`. Default is True. + + as_int (:obj:`bool`, optional): Set to True to return the x,y values as + :obj:`int`, otherwise they will be returned as :obj:`float`. This + is only used when *func* is ll_to_xy. + + Returns: + :class:`xarray.DataArray` or :class:`numpy.ndarray`: The + lat,lon/x,y coordinate value(s) whose leftmost dimensions are the + dictionary keys, followed by a dimension of size + 2 (0=X, 1=Y)/(0=lat, 1=lon). + If xarray is enabled and the *meta* parameter is True, then the result + will be a :class:`xarray.DataArray` object. Otherwise, the result will + be a :class:`numpy.ndarray` object with no metadata. + + """ + keynames = [] # This might not work once mapping iterators are implemented numkeys = len(wrfin)