@@ -48,18 +48,15 @@ def add_metadata(self, metadata):
4848 def regulate_dims (self , space_label = None , time_label = None ):
4949 """Regulate the dimension of a Space-Time Matrix instance.
5050
51- An STM should have two dimensions: "space" and "time".
52-
53- If the inupt argument `space_label` or `time_label` is specified,
54- and that dimension exists, the function will rename that dimension to "space" or "time".
55-
56- If either `space_label` or `time_label` are None, a "space" or "time" dimension with
57- size 1 will be created.
58-
59- If both `space_label` or `time_label` are None. Data variables will also be regulated.
60-
61- For data variables with a name started with "pnt_", they are regared as
62- point-only attribute and will not be affected by "time" dimension expansion.
51+ An STM should have two dimensions: `"space"` and `"time"`. If the inupt
52+ argument `space_label` or `time_label` is specified, and that dimension
53+ exists, the function will rename that dimension to "space" or "time". If
54+ either `space_label` or `time_label` are None, a "space" or "time"
55+ dimension with size 1 will be created. If both `space_label` or
56+ `time_label` are None. Data variables will also be regulated. For data
57+ variables with a name started with "pnt_", they are regared as
58+ point-only attribute and will not be affected by "time" dimension
59+ expansion.
6360
6461 Parameters
6562 ----------
@@ -113,16 +110,23 @@ def subset(self, method: str, **kwargs):
113110 ----------
114111 method : str
115112 Method of subsetting. Choose from "threshold", "density" and "polygon".
113+
116114 - threshold: select all space entries with a threshold criterion, e.g.
115+ ```python
117116 data_xr.stm.subset(method="threshold", var="thres", threshold='>1')
117+ ```
118118 - density: select one point in every [dx, dy] cell, e.g.
119+ ```python
119120 data_xr.stm.subset(method="density", dx=0.1, dy=0.1)
121+ ```
120122 - polygon: select all space entries inside a given polygon, e.g.
123+ ```python
121124 data_xr.stm.subset(method='polygon', polygon=path_polygon_file)
122- or
125+ # or
123126 import geopandas as gpd
124127 polygon = gpd.read_file(path_polygon_file)
125128 data_xr.stm.subset(method='polygon', polygon=polygon)
129+ ```
126130 **kwargs:
127131 - when method="threshold": data variable "var" and threshold "threshold"
128132 - when method="density": x and y density size: "dx" and "dy"
@@ -187,11 +191,9 @@ def enrich_from_polygon(self, polygon, fields, xlabel="lon", ylabel="lat"):
187191 """Enrich the SpaceTimeMatrix from one or more attribute fields of a (multi-)polygon.
188192
189193 Each attribute in fields will be assigned as a data variable to the STM.
190-
191- If a point of the STM falls into the given polygon, the value of the specified field will
192- be added.
193-
194- For space entries outside the (multi-)polygon, the value will be None.
194+ If a point of the STM falls into the given polygon, the value of the
195+ specified field will be added. For space entries outside the
196+ (multi-)polygon, the value will be None.
195197
196198 Parameters
197199 ----------
@@ -200,9 +202,9 @@ def enrich_from_polygon(self, polygon, fields, xlabel="lon", ylabel="lat"):
200202 fields : str or list of str
201203 Field name(s) in the (multi-)polygon for enrichment
202204 xlabel : str, optional
203- Name of the x-coordinates of the STM, by default "lon"
205+ Name of the x-coordinates of the STM, by default ` "lon"`
204206 ylabel : str, optional
205- Name of the y-coordinates of the STM, by default "lat"
207+ Name of the y-coordinates of the STM, by default ` "lat"`
206208
207209 Returns
208210 -------
@@ -332,7 +334,7 @@ def register_datatype(self, keys: str | Iterable, datatype: DataVarTypes):
332334 keys : Union[str, Iterable]
333335 Keys of the data variables to register
334336 datatype : str in DataVarTypes
335- String of the datatype. Choose from ["obsData", "auxData", "pntAttrib", "epochAttrib"].
337+ String of the datatype. Choose from ` ["obsData", "auxData", "pntAttrib", "epochAttrib"]` .
336338
337339 Returns
338340 -------
@@ -353,12 +355,12 @@ def register_datatype(self, keys: str | Iterable, datatype: DataVarTypes):
353355 def get_order (self , xlabel = "azimuth" , ylabel = "range" , xscale = 1.0 , yscale = 1.0 ):
354356 """Compute an ordering on the points based on coordinates with xlabel and ylabel.
355357
356- This order is stored in a (new) point attribute "order".
357-
358- Note that this ordering is most intuitive for integer coordinates (e.g. pixel coordinates).
359- For float coordinates (e.g. lat-lon), the coordinates should be scaled to determine the
360- resolution of the ordering: only the whole-number part influences the order.
361- While coordinates could also be offset, this has limited effect on the relative order.
358+ This order is stored in a (new) point attribute "order". Note that this
359+ ordering is most intuitive for integer coordinates (e.g. pixel
360+ coordinates). For float coordinates (e.g. lat-lon), the coordinates
361+ should be scaled to determine the resolution of the ordering: only the
362+ whole-number part influences the order. While coordinates could also be
363+ offset, this has limited effect on the relative order.
362364
363365 Parameters
364366 ----------
@@ -388,13 +390,14 @@ def get_order(self, xlabel="azimuth", ylabel="range", xscale=1.0, yscale=1.0):
388390 def reorder (self , xlabel = "azimuth" , ylabel = "range" , xscale = 1.0 , yscale = 1.0 ):
389391 """Compute and apply an ordering on the points based on coordinates with xlabel and ylabel.
390392
391- Note that this ordering is most intuitive for integer coordinates (e.g. pixel coordinates).
392- For float coordinates (e.g. lat-lon), the coordinates should be scaled to determine the
393- resolution of the ordering: only the whole-number part influences the order.
394- While coordinates could also be offset, this has limited effect on the relative order.
395-
396- Also note that reordering a dataset may be an expensive operation. Because it is applied
397- lazily, this preformance cost will only manifest once the elements are evaluated.
393+ Note that this ordering is most intuitive for integer coordinates (e.g.
394+ pixel coordinates). For float coordinates (e.g. lat-lon), the
395+ coordinates should be scaled to determine the resolution of the
396+ ordering: only the whole-number part influences the order. While
397+ coordinates could also be offset, this has limited effect on the
398+ relative order. Also note that reordering a dataset may be an expensive
399+ operation. Because it is applied lazily, this preformance cost will only
400+ manifest once the elements are evaluated.
398401
399402 Parameters
400403 ----------
@@ -411,7 +414,7 @@ def reorder(self, xlabel="azimuth", ylabel="range", xscale=1.0, yscale=1.0):
411414
412415 """
413416 self ._obj = self .get_order (xlabel , ylabel , xscale , yscale )
414-
417+
415418 # Sorting may split up the chunks, which may interfere with later operations
416419 # so we immediately restore the chunk sizes.
417420 chunks = {"space" : self ._obj .chunksizes ["space" ][0 ]}
@@ -440,8 +443,8 @@ def enrich_from_dataset(self,
440443 """Enrich the SpaceTimeMatrix from one or more fields of a dataset.
441444
442445 scipy is required. if dataset is raster, it uses
443- _enrich_from_raster_block to do interpolation using method. if dataset
444- is point, it uses _enrich_from_points_block to find the nearest points
446+ ` _enrich_from_raster_block` to do interpolation using method. if dataset
447+ is point, it uses ` _enrich_from_points_block` to find the nearest points
445448 in space and time using Euclidean distance.
446449
447450 Parameters
@@ -451,8 +454,9 @@ def enrich_from_dataset(self,
451454 fields : str or list of str
452455 Field name(s) in the dataset for enrichment
453456 method : str, optional
454- Method of interpolation, by default "nearest", see
455- https://docs.xarray.dev/en/stable/generated/xarray.Dataset.interp.html
457+ Method of interpolation, by default `"nearest"`, see [xarray
458+ interpolation
459+ methods](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.interp.html)
456460
457461 Returns
458462 -------
0 commit comments