71
71
@njit (cache = True , fastmath = True )
72
72
def shifted_ellipsoid_degrees_mask2 (lon0 , lat0 , lon1 , lat1 , minor = 1.5 , major = 1.5 ):
73
73
"""
74
- work only if major is an array but faster * 6
74
+ Work only if major is an array but faster * 6
75
75
"""
76
76
# c = (major ** 2 - minor ** 2) ** .5 + major
77
77
c = major
@@ -190,7 +190,8 @@ def _repr_html_(self):
190
190
return f"""<b>{ infos ['nb_obs' ]} observations from { infos ['t0' ]} to { infos ['t1' ]} </b>"""
191
191
192
192
def hist (self , varname , x , bins , percent = False , mean = False , nb = False ):
193
- """
193
+ """ Build histograms.
194
+
194
195
:param str varname: variable to use to compute stat
195
196
:param str x: variable to use to know in which bins
196
197
:param array bins:
@@ -217,7 +218,7 @@ def box_display(value):
217
218
218
219
def __repr__ (self ):
219
220
"""
220
- Return general informations on dataset as a string
221
+ Return general informations on dataset as strings.
221
222
222
223
:return: informations on datasets
223
224
:rtype: str
@@ -299,7 +300,7 @@ def obs_dimension(cls, handler):
299
300
300
301
def add_fields (self , fields = list (), array_fields = list ()):
301
302
"""
302
- Add a new field
303
+ Add a new field.
303
304
"""
304
305
nb_obs = self .obs .shape [0 ]
305
306
new = self .__class__ (
@@ -328,7 +329,7 @@ def add_rotation_type(self):
328
329
329
330
def circle_contour (self , only_virtual = False ):
330
331
"""
331
- Set contour as a circle with radius and center data
332
+ Set contours as a circles from radius and center data.
332
333
333
334
.. minigallery:: py_eddy_tracker.EddiesObservations.circle_contour
334
335
"""
@@ -353,7 +354,7 @@ def circle_contour(self, only_virtual=False):
353
354
354
355
@property
355
356
def dtype (self ):
356
- """Return dtype to build numpy array
357
+ """Return dtype to build numpy array.
357
358
"""
358
359
dtype = list ()
359
360
for elt in self .elements :
@@ -370,7 +371,7 @@ def dtype(self):
370
371
371
372
@property
372
373
def elements (self ):
373
- """Return all the names of the variables
374
+ """Return all the names of the variables.
374
375
"""
375
376
elements = [i for i in self .ELEMENTS ]
376
377
if self .track_array_variables > 0 :
@@ -383,7 +384,7 @@ def elements(self):
383
384
return list (set (elements ))
384
385
385
386
def coherence (self , other ):
386
- """Check coherence between two dataset
387
+ """Check coherence between two datasets.
387
388
"""
388
389
test = self .track_extra_variables == other .track_extra_variables
389
390
test *= self .track_array_variables == other .track_array_variables
@@ -409,7 +410,7 @@ def concatenate(cls, observations):
409
410
return eddies
410
411
411
412
def merge (self , other ):
412
- """Merge two dataset
413
+ """Merge two datasets.
413
414
"""
414
415
nb_obs_self = len (self )
415
416
nb_obs = nb_obs_self + len (other )
@@ -431,7 +432,7 @@ def reset(self):
431
432
432
433
@property
433
434
def obs (self ):
434
- """Return an array observations
435
+ """Return observations.
435
436
"""
436
437
return self .observations
437
438
@@ -444,7 +445,7 @@ def __iter__(self):
444
445
445
446
def iter_on (self , xname , bins = None ):
446
447
"""
447
- Yield observation group for each bin
448
+ Yield observation group for each bin.
448
449
449
450
:param str varname:
450
451
:param array bins: bounds of each bin ,
@@ -478,7 +479,7 @@ def iter_on(self, xname, bins=None):
478
479
479
480
def align_on (self , other , var_name = "time" , ** kwargs ):
480
481
"""
481
- Align the time indexes of two datasets
482
+ Align the time indexes of two datasets.
482
483
"""
483
484
iter_self , iter_other = (
484
485
self .iter_on (var_name , ** kwargs ),
@@ -497,7 +498,7 @@ def align_on(self, other, var_name="time", **kwargs):
497
498
yield indexs_self , indexs_other , b0_self , b1_self
498
499
499
500
def insert_observations (self , other , index ):
500
- """Insert other obs in self at the index
501
+ """Insert other obs in self at the index.
501
502
"""
502
503
if not self .coherence (other ):
503
504
raise Exception ("Observations with no coherence" )
@@ -519,7 +520,7 @@ def insert_observations(self, other, index):
519
520
return self
520
521
521
522
def append (self , other ):
522
- """Merge
523
+ """Merge.
523
524
"""
524
525
return self + other
525
526
@@ -528,7 +529,7 @@ def __add__(self, other):
528
529
529
530
def distance (self , other ):
530
531
""" Use haversine distance for distance matrix between every self and
531
- other eddies"""
532
+ other eddies. """
532
533
return distance_grid (
533
534
self .obs ["lon" ], self .obs ["lat" ], other .obs ["lon" ], other .obs ["lat" ]
534
535
)
@@ -545,7 +546,7 @@ def new_like(eddies, new_size):
545
546
)
546
547
547
548
def index (self , index , reverse = False ):
548
- """Return obs from self at the index
549
+ """Return obs from self at the index.
549
550
"""
550
551
if reverse :
551
552
index = reverse_index (index , len (self ))
@@ -570,7 +571,7 @@ def zarr_dimension(filename):
570
571
@classmethod
571
572
def load_file (cls , filename , ** kwargs ):
572
573
"""
573
- Load the netcdf or the zarr file
574
+ Load the netcdf or the zarr file.
574
575
575
576
Load only latitude and longitude on the first 300 obs :
576
577
@@ -584,6 +585,10 @@ def load_file(cls, filename, **kwargs):
584
585
indexs=dict(obs=slice(0, 300)),
585
586
)
586
587
small_dataset = TrackEddiesObservations.load_file(filename, **kwargs_latlon_300)
588
+
589
+ Default **kwargs to load zarr are : raw_data=False, remove_vars=None, include_vars=None
590
+
591
+ Default **kwargs to load netcdf are : raw_data=False, remove_vars=None, include_vars=None, indexs=None
587
592
"""
588
593
filename_ = (
589
594
filename .filename if isinstance (filename , ExFileObject ) else filename
@@ -855,7 +860,7 @@ def propagate(
855
860
self , previous_obs , current_obs , obs_to_extend , dead_track , nb_next , model
856
861
):
857
862
"""
858
- Filled virtual obs (C)
863
+ Filled virtual obs (C).
859
864
860
865
:param previous_obs: previous obs from current (A)
861
866
:param current_obs: previous obs from virtual (B)
@@ -914,16 +919,17 @@ def intern(flag, public_label=False):
914
919
return labels
915
920
916
921
def match (self , other , method = "overlap" , intern = False , cmin = 0 , ** kwargs ):
917
- """Return index and score computed with the chosen method on the effective contour
922
+ """Return index and score computed on the effective contour.
918
923
919
924
:param EddiesObservations other: Observations to compare
920
925
:param str method:
921
926
- "overlap": the score is computed with contours;
922
- - "circle": circles are computed and used for score
927
+ - "circle": circles are computed and used for score (TODO)
923
928
:param bool intern: if True, speed contour is used (default = effective contour)
924
929
:param float cmin: 0 < cmin < 1, return only couples with score >= cmin
925
- :param dict kwargs: look at :py:meth:`py_eddy_tracker.poly.vertice_overlap`
926
- :return: return the indexes of the eddies in self coupled with eddies in other and their associated score
930
+ :param dict kwargs: look at :py:meth:`vertice_overlap`
931
+ :return: return the indexes of the eddies in self coupled with eddies in
932
+ other and their associated score
927
933
:rtype: (array(int), array(int), array(float))
928
934
929
935
.. minigallery:: py_eddy_tracker.EddiesObservations.match
@@ -992,13 +998,14 @@ def mask_function(self, other, distance):
992
998
993
999
@staticmethod
994
1000
def cost_function (records_in , records_out , distance ):
995
- """Return cost function between obs to associate
1001
+ """Return the cost function between two obs.
996
1002
997
- .. code-block:: python
1003
+ .. math::
998
1004
999
- cost = sqrt(((amplitude_in - amplitude_out) / amplitude_in) ** 2 +
1000
- ((speed_radius_in - speed_radius_out) / speed_radius_in) ** 2 +
1001
- (distance / 125) ** 2)
1005
+ cost = \sqrt{({Amp_{_{in}} - Amp_{_{out}} \over Amp_{_{in}}}) ^2 +
1006
+ ({Rspeed_{_{in}} - Rspeed_{_{out}} \over Rspeed_{_{in}}}) ^2 +
1007
+ ({distance \over 125}) ^2
1008
+ }
1002
1009
1003
1010
:param records_in: starting observations
1004
1011
:param records_out: observations to associate
@@ -1110,7 +1117,7 @@ def solve_conflict(cost):
1110
1117
1111
1118
@staticmethod
1112
1119
def solve_simultaneous (cost ):
1113
- """Write something"""
1120
+ """Write something (TODO) """
1114
1121
mask = ~ cost .mask
1115
1122
# Count number of link by self obs and other obs
1116
1123
self_links = mask .sum (axis = 1 )
@@ -1482,7 +1489,7 @@ def set_global_attr_netcdf(self, h_nc):
1482
1489
1483
1490
def extract_with_area (self , area , ** kwargs ):
1484
1491
"""
1485
- Extract geographically with a bounding box
1492
+ Extract geographically with a bounding box.
1486
1493
1487
1494
:param dict area: 4 coordinates in a dictionary to specify bounding box (lower left corner and upper right corner)
1488
1495
:param dict kwargs: look at :py:meth:`extract_with_mask`
@@ -1503,7 +1510,7 @@ def extract_with_area(self, area, **kwargs):
1503
1510
1504
1511
def extract_with_mask (self , mask ):
1505
1512
"""
1506
- Extract a subset of observations
1513
+ Extract a subset of observations.
1507
1514
1508
1515
:param array(bool) mask: mask to select observations
1509
1516
:return: same object with selected observations
@@ -1529,6 +1536,8 @@ def extract_with_mask(self, mask):
1529
1536
1530
1537
def scatter (self , ax , name = None , ref = None , factor = 1 , ** kwargs ):
1531
1538
"""
1539
+ Scatter data.
1540
+
1532
1541
:param matplotlib.axes.Axes ax: matplotlib axe used to draw
1533
1542
:param str,array,None name:
1534
1543
variable used to fill the contour, if None all elements have the same color
0 commit comments