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

Function get_xy

src/wrf/interputils.py:266–323  ·  view source on GitHub ↗

Return the x,y points for the horizontal cross section line. Args: var (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A variable that contains a :attr:`shape` attribute. pivot_point (:obj:`tuple` or :obj:`list`, optional): A :obj:`tuple` or :obj

(var, pivot_point=None, angle=None,
           start_point=None, end_point=None)

Source from the content-addressed store, hash-verified

264
265
266def get_xy(var, pivot_point=None, angle=None,
267 start_point=None, end_point=None):
268 """Return the x,y points for the horizontal cross section line.
269
270 Args:
271
272 var (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A variable
273 that contains a :attr:`shape` attribute.
274
275 pivot_point (:obj:`tuple` or :obj:`list`, optional): A
276 :obj:`tuple` or :obj:`list` with two entries,
277 in the form of [x, y] (or [west_east, south_north]), which
278 indicates the x,y location through which the plane will pass.
279 Must also specify `angle`.
280
281 angle (:obj:`float`, optional): Only valid for cross sections where
282 a plane will be plotted through
283 a given point on the model domain. 0.0 represents a S-N cross
284 section. 90.0 is a W-E cross section.
285
286 start_point (:obj:`tuple` or :obj:`list`, optional): A
287 :obj:`tuple` or :obj:`list` with two entries, in the form of
288 [x, y] (or [west_east, south_north]), which indicates the start
289 x,y location through which the plane will pass.
290
291 end_point (:obj:`tuple` or :obj:`list`, optional): A
292 :obj:`tuple` or :obj:`list` with two entries, in the form of
293 [x, y] (or [west_east, south_north]), which indicates the end x,y
294 location through which the plane will pass.
295
296 Returns:
297
298 :class:`np.ndarray`: A two-dimensional array with the left index
299 representing each point along the line, and the rightmost dimension
300 having two values for the x and y coordinates [0=X, 1=Y].
301
302 """
303 if pivot_point is not None:
304 pos_pivot = to_positive_idxs(var.shape[-2:], pivot_point)
305 else:
306 pos_pivot = pivot_point
307
308 if start_point is not None:
309 pos_start = to_positive_idxs(var.shape[-2:], start_point)
310 else:
311 pos_start = start_point
312
313 if end_point is not None:
314 pos_end = to_positive_idxs(var.shape[-2:], end_point)
315 else:
316 pos_end = start_point
317
318 xdim = var.shape[-1]
319 ydim = var.shape[-2]
320
321 xy = _calc_xy(xdim, ydim, pos_pivot, angle, pos_start, pos_end)
322
323 return xy

Callers 4

get_xy_z_paramsFunction · 0.85
_set_line_metaFunction · 0.85
interplineFunction · 0.85
xyFunction · 0.85

Calls 2

to_positive_idxsFunction · 0.85
_calc_xyFunction · 0.85

Tested by

no test coverage detected