@@ -162,6 +162,67 @@ def get_lon(wrfin, timeidx=0, method="cat", squeeze=True,
162
162
def _llxy_mapping (wrfin , x_or_lat , y_or_lon , func , timeidx , stagger ,
163
163
squeeze , meta , as_int = None ):
164
164
165
+ """Return the x,y/lat,lon coordinates for a dictionary input.
166
+
167
+ The leftmost dimension(s) for the result is:
168
+
169
+ - return_val[key,...,0,...] will contain the x/lat values.
170
+ - return_val[key,...,1,...] will contain the y/lon values.
171
+
172
+ Nested dictionaries are allowed.
173
+
174
+ Args:
175
+
176
+ wrfin (:obj:`dict`): A mapping of key name to a WRF NetCDF file object
177
+ or sequence of WRF NetCDF file objects.
178
+
179
+ x_or_lat (:obj:`float` or sequence): A single latitude/x value or a
180
+ sequence of latitude/x values to be converted.
181
+
182
+ y_or_lon (:obj:`float` or sequence): A single longitude/y value or a
183
+ sequence of longitude/y values to be converted.
184
+
185
+ func (function): Either the xy_to_ll or ll_to_xy function.
186
+
187
+ timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`): The
188
+ desired time index. This value can be a positive integer,
189
+ negative integer, or
190
+ :data:`wrf.ALL_TIMES` (an alias for None) to return
191
+ all times in the file or sequence. The default is 0.
192
+
193
+ stagger (:obj:`str`): By default, the values are returned on the mass
194
+ grid, but a staggered grid can be chosen with the following
195
+ options:
196
+
197
+ - 'm': Use the mass grid (default).
198
+ - 'u': Use the same staggered grid as the u wind component,
199
+ which has a staggered west_east (x) dimension.
200
+ - 'v': Use the same staggered grid as the v wind component,
201
+ which has a staggered south_north (y) dimension.
202
+
203
+ squeeze (:obj:`bool`, optional): Set to False to prevent dimensions
204
+ with a size of 1 from being automatically removed from the shape
205
+ of the output. Default is True.
206
+
207
+ meta (:obj:`bool`, optional): Set to False to disable metadata and
208
+ return :class:`numpy.ndarray` instead of
209
+ :class:`xarray.DataArray`. Default is True.
210
+
211
+ as_int (:obj:`bool`, optional): Set to True to return the x,y values as
212
+ :obj:`int`, otherwise they will be returned as :obj:`float`. This
213
+ is only used when *func* is ll_to_xy.
214
+
215
+ Returns:
216
+ :class:`xarray.DataArray` or :class:`numpy.ndarray`: The
217
+ lat,lon/x,y coordinate value(s) whose leftmost dimensions are the
218
+ dictionary keys, followed by a dimension of size
219
+ 2 (0=X, 1=Y)/(0=lat, 1=lon).
220
+ If xarray is enabled and the *meta* parameter is True, then the result
221
+ will be a :class:`xarray.DataArray` object. Otherwise, the result will
222
+ be a :class:`numpy.ndarray` object with no metadata.
223
+
224
+ """
225
+
165
226
keynames = []
166
227
# This might not work once mapping iterators are implemented
167
228
numkeys = len (wrfin )
0 commit comments