|
23 | 23 | from xarray import DataArray, Dataset
|
24 | 24 | from xarray.core.arithmetic import SupportsArithmetic
|
25 | 25 |
|
| 26 | +from .criteria import coordinate_criteria, regex |
26 | 27 | from .helpers import bounds_to_vertices
|
27 | 28 | from .utils import _is_datetime_like, invert_mappings, parse_cell_methods_attr
|
28 | 29 |
|
|
44 | 45 | #: Cell measures understood by cf_xarray.
|
45 | 46 | _CELL_MEASURES = ("area", "volume")
|
46 | 47 |
|
47 |
| -# Define the criteria for coordinate matches |
48 |
| -# Copied from metpy |
49 |
| -# Internally we only use X, Y, Z, T |
50 |
| -coordinate_criteria: MutableMapping[str, MutableMapping[str, Tuple]] = { |
51 |
| - "standard_name": { |
52 |
| - "X": ("projection_x_coordinate",), |
53 |
| - "Y": ("projection_y_coordinate",), |
54 |
| - "T": ("time",), |
55 |
| - "time": ("time",), |
56 |
| - "vertical": ( |
57 |
| - "air_pressure", |
58 |
| - "height", |
59 |
| - "depth", |
60 |
| - "geopotential_height", |
61 |
| - # computed dimensional coordinate name |
62 |
| - "altitude", |
63 |
| - "height_above_geopotential_datum", |
64 |
| - "height_above_reference_ellipsoid", |
65 |
| - "height_above_mean_sea_level", |
66 |
| - ), |
67 |
| - "Z": ( |
68 |
| - "model_level_number", |
69 |
| - "atmosphere_ln_pressure_coordinate", |
70 |
| - "atmosphere_sigma_coordinate", |
71 |
| - "atmosphere_hybrid_sigma_pressure_coordinate", |
72 |
| - "atmosphere_hybrid_height_coordinate", |
73 |
| - "atmosphere_sleve_coordinate", |
74 |
| - "ocean_sigma_coordinate", |
75 |
| - "ocean_s_coordinate", |
76 |
| - "ocean_s_coordinate_g1", |
77 |
| - "ocean_s_coordinate_g2", |
78 |
| - "ocean_sigma_z_coordinate", |
79 |
| - "ocean_double_sigma_coordinate", |
80 |
| - ), |
81 |
| - "latitude": ("latitude",), |
82 |
| - "longitude": ("longitude",), |
83 |
| - }, |
84 |
| - "_CoordinateAxisType": { |
85 |
| - "T": ("Time",), |
86 |
| - "Z": ("GeoZ", "Height", "Pressure"), |
87 |
| - "Y": ("GeoY",), |
88 |
| - "latitude": ("Lat",), |
89 |
| - "X": ("GeoX",), |
90 |
| - "longitude": ("Lon",), |
91 |
| - }, |
92 |
| - "axis": {"T": ("T",), "Z": ("Z",), "Y": ("Y",), "X": ("X",)}, |
93 |
| - "cartesian_axis": {"T": ("T",), "Z": ("Z",), "Y": ("Y",), "X": ("X",)}, |
94 |
| - "positive": {"vertical": ("up", "down")}, |
95 |
| - "units": { |
96 |
| - "latitude": ( |
97 |
| - "degree_north", |
98 |
| - "degree_N", |
99 |
| - "degreeN", |
100 |
| - "degrees_north", |
101 |
| - "degrees_N", |
102 |
| - "degreesN", |
103 |
| - ), |
104 |
| - "longitude": ( |
105 |
| - "degree_east", |
106 |
| - "degree_E", |
107 |
| - "degreeE", |
108 |
| - "degrees_east", |
109 |
| - "degrees_E", |
110 |
| - "degreesE", |
111 |
| - ), |
112 |
| - }, |
113 |
| -} |
114 |
| - |
115 |
| -# "long_name" and "standard_name" criteria are the same. For convenience. |
116 |
| -coordinate_criteria["long_name"] = coordinate_criteria["standard_name"] |
117 |
| - |
118 |
| -#: regular expressions for guess_coord_axis |
119 |
| -regex = { |
120 |
| - "time": "\\bt\\b|(time|min|hour|day|week|month|year)[0-9]*", |
121 |
| - "vertical": ( |
122 |
| - "(z|nav_lev|gdep|lv_|bottom_top|sigma|h(ei)?ght|altitude|depth|" |
123 |
| - "isobaric|pres|isotherm)[a-z_]*[0-9]*" |
124 |
| - ), |
125 |
| - "Y": "y", |
126 |
| - "latitude": "y?(nav_lat|lat|gphi)[a-z0-9]*", |
127 |
| - "X": "x", |
128 |
| - "longitude": "x?(nav_lon|lon|glam)[a-z0-9]*", |
129 |
| -} |
130 |
| -regex["Z"] = regex["vertical"] |
131 |
| -regex["T"] = regex["time"] |
132 |
| - |
133 |
| - |
134 | 48 | ATTRS = {
|
135 | 49 | "X": {"axis": "X"},
|
136 | 50 | "T": {"axis": "T", "standard_name": "time"},
|
|
0 commit comments