@@ -62,17 +62,27 @@ class GridMapping(abc.ABC):
6262 This class cannot be instantiated directly. Use one of its factory methods
6363 to create instances:
6464
65- * `regular`
66- * `regular_from_bbox`
67- * `from_dataset`
68- * `from_coords`
65+ - `regular`
66+ - `regular_from_bbox`
67+ - `from_dataset`
68+ - `from_coords`
6969
7070 Some instance methods can be used to derive new instances:
7171
72- * `derive`
73- * `scale`
74- * `transform`
75- * `to_regular`
72+ - `derive`
73+ - `scale`
74+ - `transform`
75+ - `to_regular`
76+
77+ Notes:
78+
79+ - `x` : eastward axis in CRS coordinates
80+ - `y` : northward axis in CRS coordinates
81+ - `i` : eastward axis in pixel space
82+ - `j` : northward axis in pixel space
83+
84+ References:
85+ [CF Conventions — Coordinate types](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.13/cf-conventions.html#coordinate-types)
7686 """
7787
7888 def __init__ (
@@ -277,8 +287,14 @@ def tile_height(self) -> int:
277287
278288 @property
279289 def x_coords (self ):
280- """The 1D or 2D x-coordinate array of
281- shape (width,) or (height, width).
290+ """Return the eastward (x) coordinate values.
291+
292+ The coordinates are provided as either a 1D or 2D array:
293+ - Shape (width,) for rectilinear grids
294+ - Shape (height, width) for curvilinear grids
295+
296+ See Also:
297+ [CF Conventions, Longitude Coordinate](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.13/cf-conventions.html#longitude-coordinate)
282298 """
283299 return self ._get_computed_attribute ("_x_coords" , self ._new_x_coords )
284300
@@ -290,8 +306,14 @@ def _new_x_coords(self) -> xr.DataArray:
290306
291307 @property
292308 def y_coords (self ):
293- """The 1D or 2D y-coordinate array of
294- shape (width,) or (height, width).
309+ """Return the northward (y) coordinate values.
310+
311+ The coordinates are provided as either a 1D or 2D array:
312+ - Shape (width,) for rectilinear grids
313+ - Shape (height, width) for curvilinear grids
314+
315+ See Also:
316+ [CF Conventions, Latitude Coordinate](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.13/cf-conventions.html#latitude-coordinate)
295317 """
296318 return self ._get_computed_attribute ("_y_coords" , self ._new_y_coords )
297319
@@ -303,16 +325,20 @@ def _new_y_coords(self) -> xr.DataArray:
303325
304326 @property
305327 def xy_coords (self ) -> xr .DataArray :
306- """The x,y coordinates as data array of shape (2, height, width).
307- Coordinates are given in units of the CRS.
328+ """Return the spatial coordinates as a single DataArray.
329+
330+ The coordinates are provided as a 3D array of shape `(2, height, width)`,
331+ where the first axis corresponds to the x and y coordinates stacked in order:
332+ `(x_coords, y_coords)`. All values are expressed in the units of the
333+ dataset's CRS (coordinate reference system).
308334 """
309335 xy_coords = self ._get_computed_attribute ("_xy_coords" , self ._new_xy_coords )
310336 _assert_valid_xy_coords (xy_coords )
311337 return xy_coords
312338
313339 @property
314340 def xy_coords_chunks (self ) -> tuple [int , int , int ]:
315- """Get the chunks for the * xy_coords* array."""
341+ """Return the chunks for the ` xy_coords` array."""
316342 return 2 , self .tile_height , self .tile_width
317343
318344 @abc .abstractmethod
@@ -337,15 +363,15 @@ def _get_computed_attribute(self, name: str, computer: Callable[[], Any]) -> Any
337363
338364 @property
339365 def xy_var_names (self ) -> tuple [str , str ]:
340- """The variable names of the x,y coordinates as
341- tuple (x_var_name, y_var_name).
366+ """The variable names of `x_coords` and `y_coords` as tuple
367+ ` (x_var_name, y_var_name)` .
342368 """
343369 return self ._xy_var_names
344370
345371 @property
346372 def xy_dim_names (self ) -> tuple [str , str ]:
347- """The dimension names of the x,y coordinates as
348- tuple (x_dim_name, y_dim_name).
373+ """The dimension names of `x_coords` and `y_coords` as
374+ tuple ` (x_dim_name, y_dim_name)` .
349375 """
350376 return self ._xy_dim_names
351377
@@ -356,37 +382,37 @@ def xy_bbox(self) -> tuple[float, float, float, float]:
356382
357383 @property
358384 def x_min (self ) -> FloatInt :
359- """Minimum x- coordinate in CRS units."""
385+ """Minimum eastward (x) coordinate value in CRS units."""
360386 return round (self ._xy_bbox [0 ] + self .x_res / 2 , ndigits = 7 )
361387
362388 @property
363389 def y_min (self ) -> FloatInt :
364- """Minimum y- coordinate in CRS units."""
390+ """Minimum northward (y) coordinate value in CRS units."""
365391 return round (self ._xy_bbox [1 ] + self .y_res / 2 , ndigits = 7 )
366392
367393 @property
368394 def x_max (self ) -> FloatInt :
369- """Maximum x- coordinate in CRS units."""
395+ """Maximum eastward (x) coordinate value in CRS units."""
370396 return round (self ._xy_bbox [2 ] - self .x_res / 2 , ndigits = 7 )
371397
372398 @property
373399 def y_max (self ) -> FloatInt :
374- """Maximum y- coordinate in CRS units."""
400+ """Maximum northward (y) coordinate value in CRS units."""
375401 return round (self ._xy_bbox [3 ] - self .y_res / 2 , ndigits = 7 )
376402
377403 @property
378404 def xy_res (self ) -> tuple [FloatInt , FloatInt ]:
379- """Pixel size in x and y direction."""
405+ """Pixel size in eastward (x) and northward (y) direction `(x_res, y_res)` ."""
380406 return self ._xy_res
381407
382408 @property
383409 def x_res (self ) -> FloatInt :
384- """Pixel size in CRS units per pixel in x- direction."""
410+ """Pixel size in CRS units per pixel in eastward (x) direction."""
385411 return self ._xy_res [0 ]
386412
387413 @property
388414 def y_res (self ) -> FloatInt :
389- """Pixel size in CRS units per pixel in y- direction."""
415+ """Pixel size in CRS units per pixel in northward (y) direction."""
390416 return self ._xy_res [1 ]
391417
392418 @property
@@ -400,38 +426,39 @@ def spatial_unit_name(self) -> str:
400426
401427 @property
402428 def is_lon_360 (self ) -> bool | None :
403- """Check whether * x_max* is greater than 180 degrees.
404- Effectively tests whether the range * x_min*, * x_max* crosses
429+ """Check whether ` x_max` is greater than 180 degrees.
430+ Effectively tests whether the range ` x_min`, ` x_max` crosses
405431 the anti-meridian at 180 degrees.
406432 Works only for geographical coordinate reference systems.
407433 """
408434 return self ._is_lon_360
409435
410436 @property
411437 def is_regular (self ) -> bool | None :
412- """Do the x,y coordinates for a regular grid?
413- A regular grid has a constant delta in both
414- x- and y-directions of the x- and y-coordinates.
438+ """Check whether the x (eastward) and y (northward) coordinates form a regular
439+ grid.
415440
416- Returns: None, if this property cannot be determined,
417- True or False otherwise .
441+ A regular grid is defined as having constant spacing (delta) along
442+ the x- and y-axes individually .
418443 """
444+
419445 return self ._is_regular
420446
421447 @property
422448 def is_j_axis_up (self ) -> bool | None :
423- """Does the positive image j-axis point up?
424- By default, the positive image j-axis points down.
449+ """Indicate whether the positive image j-axis points upward.
425450
426- Returns: None, if this property cannot be determined,
427- True or False otherwise.
451+ Here, the j-axis refers to the y-coordinate in pixel space. By convention,
452+ the positive j-axis usually points downward in image coordinates, so
453+ `True` indicates that the axis has been flipped to point upward.
428454 """
429455 return self ._is_j_axis_up
430456
431457 @property
432458 def ij_to_xy_transform (self ) -> AffineTransformMatrix :
433459 """The affine transformation matrix from image to CRS coordinates.
434- Defined only for grid mappings with rectified x,y coordinates.
460+ Defined only for grid mappings with regular x (eastward) and y (northward)
461+ coordinates.
435462 """
436463 self ._assert_regular ()
437464 if self .is_j_axis_up :
@@ -448,20 +475,22 @@ def ij_to_xy_transform(self) -> AffineTransformMatrix:
448475 @property
449476 def xy_to_ij_transform (self ) -> AffineTransformMatrix :
450477 """The affine transformation matrix from CRS to image coordinates.
451- Defined only for grid mappings with rectified x,y coordinates.
478+ Defined only for grid mappings with regular x (eastward) and y (northward)
479+ coordinates.
452480 """
453481 self ._assert_regular ()
454482 return _from_affine (~ _to_affine (self .ij_to_xy_transform ))
455483
456484 def ij_transform_to (self , other : "GridMapping" ) -> AffineTransformMatrix :
457485 """Get the affine transformation matrix that transforms
458- image coordinates of * other* into image coordinates
486+ image coordinates of ` other` grid-mapping into image coordinates
459487 of this image geometry.
460488
461- Defined only for grid mappings with rectified x,y coordinates.
489+ Defined only for grid mappings with regular x (eastward) and y (northward)
490+ coordinates.
462491
463492 Args:
464- other: The other image geometry
493+ other: The other grid-mapping
465494
466495 Returns:
467496 Affine transformation matrix
@@ -474,13 +503,14 @@ def ij_transform_to(self, other: "GridMapping") -> AffineTransformMatrix:
474503
475504 def ij_transform_from (self , other : "GridMapping" ) -> AffineTransformMatrix :
476505 """Get the affine transformation matrix that transforms
477- image coordinates of this image geometry to image
478- coordinates of *other*.
506+ image coordinates of this grid-mapping to image
507+ coordinates of *other* grid-mapping .
479508
480- Defined only for grid mappings with rectified x,y coordinates.
509+ Defined only for grid mappings with regular x (eastward) and y (northward)
510+ coordinates.
481511
482512 Args:
483- other: The other image geometry
513+ other: The other grid-mapping
484514
485515 Returns:
486516 Affine transformation matrix
0 commit comments