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

Function xy

src/wrf/computation.py:20–103  ·  view source on GitHub ↗

Return the x,y points for a line within a two-dimensional grid. This function is primarily used to obtain the x,y points when making a cross section. Args: field (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A field with at least two dimensions. p

(field, pivot_point=None, angle=None, start_point=None, end_point=None,
       meta=True)

Source from the content-addressed store, hash-verified

18
19@set_interp_metadata("xy")
20def xy(field, pivot_point=None, angle=None, start_point=None, end_point=None,
21 meta=True):
22 """Return the x,y points for a line within a two-dimensional grid.
23
24 This function is primarily used to obtain the x,y points when making a
25 cross section.
26
27 Args:
28
29 field (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A
30 field with at least two dimensions.
31
32 pivot_point (:obj:`tuple` or :obj:`list`, optional): A
33 :obj:`tuple` or :obj:`list` with two entries,
34 in the form of [x, y] (or [west_east, south_north]), which
35 indicates the x,y location through which the plane will pass.
36 Must also specify `angle`.
37
38 angle (:obj:`float`, optional): Only valid for cross sections where
39 a plane will be plotted through
40 a given point on the model domain. 0.0 represents a S-N cross
41 section. 90.0 is a W-E cross section.
42
43 start_point (:obj:`tuple` or :obj:`list`, optional): A
44 :obj:`tuple` or :obj:`list` with two entries, in the form of
45 [x, y] (or [west_east, south_north]), which indicates the start
46 x,y location through which the plane will pass.
47
48 end_point (:obj:`tuple` or :obj:`list`, optional): A
49 :obj:`tuple` or :obj:`list` with two entries, in the form of
50 [x, y] (or [west_east, south_north]), which indicates the end x,y
51 location through which the plane will pass.
52
53 meta (:obj:`bool`, optional): Set to False to disable metadata and
54 return :class:`numpy.ndarray` instead of
55 :class:`xarray.DataArray`. Default is True.
56
57 Returns:
58
59 :class:`xarray.DataArray` or :class:`numpy.ndarray`: An array of
60 x,y points, which has shape num_points x 2.
61 If xarray is enabled and the *meta* parameter is True, then the result
62 will be a :class:`xarray.DataArray` object. Otherwise, the result will
63 be a :class:`numpy.ndarray` object with no metadata.
64
65 Examples:
66
67 Example 1: Using Pivot Point and Angle
68
69 .. code-block:: python
70
71 from wrf import getvar, xy
72 from netCDF4 import Dataset
73
74 wrfnc = Dataset("wrfout_d02_2010-06-13_21:00:00")
75 field = wrf.getvar(wrfnc, "slp")
76
77 # Use the center of the grid

Callers

nothing calls this directly

Calls 1

get_xyFunction · 0.85

Tested by

no test coverage detected