@@ -88,7 +88,7 @@ def animate(self):
88
88
@property
89
89
def tx (self ):
90
90
"""
91
- Trajectory x coordinates (usually longitude) - test .
91
+ Trajectory x coordinates (usually longitude).
92
92
93
93
See Also
94
94
--------
@@ -121,6 +121,10 @@ def ty(self):
121
121
def tlon (self ):
122
122
"""
123
123
Retrieve the trajectories in geographic coordinates (longitudes).
124
+
125
+ See Also
126
+ --------
127
+ tx, tlat
124
128
"""
125
129
if self .crs .is_geographic :
126
130
return self .tx
@@ -137,6 +141,10 @@ def tlon(self):
137
141
def tlat (self ) -> xr .DataArray :
138
142
"""
139
143
Retrieve the trajectories in geographic coordinates (latitudes).
144
+
145
+ See Also
146
+ --------
147
+ ty, tlon
140
148
"""
141
149
if self .crs .is_geographic :
142
150
return self .ty
@@ -155,14 +163,14 @@ def transform(self, to_crs, x, y):
155
163
156
164
Parameters
157
165
----------
158
- to_crs : pyproj.CRS
166
+ to_crs : pyproj.crs. CRS
159
167
160
- x, y : arrays
168
+ x, y : array-like
161
169
Coordinates in `self` CRS
162
170
163
171
Returns
164
172
-------
165
- xn, yn : arrays
173
+ xn, yn : array-like
166
174
Coordinates in `to_crs`
167
175
"""
168
176
t = pyproj .Transformer .from_crs (self .crs , to_crs , always_xy = True )
@@ -174,23 +182,27 @@ def itransform(self, from_crs, x, y):
174
182
175
183
Parameters
176
184
----------
177
- from_crs : ` pyproj.CRS`
185
+ from_crs : pyproj.crs. CRS
178
186
179
- x, y : arrays
180
- Coordinates in ` from_crs` CRS
187
+ x, y : array-like
188
+ Coordinates in from_crs CRS
181
189
182
190
Returns
183
191
-------
184
- xn, yn : arrays
192
+ xn, yn : array-like
185
193
Coordinates in this datasets CRS
186
194
"""
187
195
t = pyproj .Transformer .from_crs (from_crs , self .crs , always_xy = True )
188
196
return t .transform (x , y )
189
197
190
198
@property
191
- def crs (self ) -> pyproj .CRS :
199
+ def crs (self ) -> pyproj .crs . CRS :
192
200
"""
193
- Retrieve the pyproj.CRS object from the CF-defined grid-mapping in the dataset.
201
+ Retrieve the pyproj.crs.CRS object from the CF-defined grid-mapping in the dataset.
202
+
203
+ Returns
204
+ -------
205
+ pyproj.crs.CRS
194
206
"""
195
207
if len (self .ds .cf .grid_mapping_names ) == 0 :
196
208
logger .debug (
@@ -208,23 +220,24 @@ def crs(self) -> pyproj.CRS:
208
220
else :
209
221
gm = self .ds .cf ['grid_mapping' ]
210
222
logger .debug (f'Constructing CRS from grid_mapping: { gm } ' )
211
- return pyproj .CRS .from_cf (gm .attrs )
223
+ return pyproj .crs . CRS .from_cf (gm .attrs )
212
224
213
225
def set_crs (self , crs ) -> xr .Dataset :
214
226
"""
215
227
Returns a new dataset with the CF-supported grid-mapping / projection set to `crs`.
216
228
217
229
Parameters
218
230
----------
219
- crs: pyproj.CRS
231
+ crs : pyproj.crs .CRS
220
232
221
233
Returns
222
234
-------
223
- updated dataset
224
-
225
- .. warning::
235
+ Dataset
236
+ Updated dataset
226
237
227
- This does not transform the coordinates, make sure that `crs` is matching the data in the dataset.
238
+ Warning
239
+ -------
240
+ This does not transform the coordinates, make sure that `crs` is matching the data in the dataset.
228
241
"""
229
242
230
243
# TODO: Ideally this would be handled by cf-xarray or rio-xarray.
@@ -282,6 +295,19 @@ def assign_cf_attrs(self,
282
295
** kwargs ) -> xr .Dataset :
283
296
"""
284
297
Return a new dataset with CF-standard and common attributes set.
298
+
299
+ Parameters
300
+ ----------
301
+ *kwargs
302
+ Attribute names and values
303
+
304
+ Returns
305
+ -------
306
+ Dataset
307
+ Updated dataset with provided attributes, in addition to several CF standard attributes,
308
+ including Conventions, featureType, geospatial_lat_min etc.
309
+
310
+
285
311
"""
286
312
ds = self .ds .copy (deep = True )
287
313
@@ -332,7 +358,13 @@ def assign_cf_attrs(self,
332
358
return ds
333
359
334
360
def index_of_last (self ):
335
- """Find index of last valid position along each trajectory."""
361
+ """Find index of last valid position along each trajectory.
362
+
363
+ Returns
364
+ -------
365
+ array-like
366
+ Array of the index of the last valid position along each trajectory.
367
+ """
336
368
return np .ma .notmasked_edges (np .ma .masked_invalid (self .ds .lon .values ),
337
369
axis = 1 )[1 ][1 ]
338
370
@@ -612,7 +644,7 @@ def skill(self, other, method='liu-weissberg', **kwargs) -> xr.Dataset:
612
644
Returns
613
645
-------
614
646
615
- skill : :class:`xarray. Dataset`
647
+ skill : Dataset
616
648
The skill-score in the same dimensions as this dataset.
617
649
618
650
Notes
0 commit comments