70
70
@njit (cache = True , fastmath = True )
71
71
def shifted_ellipsoid_degrees_mask2 (lon0 , lat0 , lon1 , lat1 , minor = 1.5 , major = 1.5 ):
72
72
"""
73
- work only if major is an array but faster * 6
73
+ Work only if major is an array but faster * 6
74
74
"""
75
75
# c = (major ** 2 - minor ** 2) ** .5 + major
76
76
c = major
@@ -189,7 +189,8 @@ def _repr_html_(self):
189
189
return f"""<b>{ infos ['nb_obs' ]} observations from { infos ['t0' ]} to { infos ['t1' ]} </b>"""
190
190
191
191
def hist (self , varname , x , bins , percent = False , mean = False , nb = False ):
192
- """
192
+ """ Build histograms.
193
+
193
194
:param str varname: variable to use to compute stat
194
195
:param str x: variable to use to know in which bins
195
196
:param array bins:
@@ -216,7 +217,7 @@ def box_display(value):
216
217
217
218
def __repr__ (self ):
218
219
"""
219
- Return general informations on dataset as a string
220
+ Return general informations on dataset as strings.
220
221
221
222
:return: informations on datasets
222
223
:rtype: str
@@ -292,7 +293,7 @@ def obs_dimension(cls, handler):
292
293
293
294
def add_fields (self , fields = list (), array_fields = list ()):
294
295
"""
295
- Add a new field
296
+ Add a new field.
296
297
"""
297
298
nb_obs = self .obs .shape [0 ]
298
299
new = self .__class__ (
@@ -321,7 +322,7 @@ def add_rotation_type(self):
321
322
322
323
def circle_contour (self , only_virtual = False ):
323
324
"""
324
- Set contour as a circle with radius and center data
325
+ Set contours as a circles from radius and center data.
325
326
326
327
.. minigallery:: py_eddy_tracker.EddiesObservations.circle_contour
327
328
"""
@@ -346,7 +347,7 @@ def circle_contour(self, only_virtual=False):
346
347
347
348
@property
348
349
def dtype (self ):
349
- """Return dtype to build numpy array
350
+ """Return dtype to build numpy array.
350
351
"""
351
352
dtype = list ()
352
353
for elt in self .elements :
@@ -363,7 +364,7 @@ def dtype(self):
363
364
364
365
@property
365
366
def elements (self ):
366
- """Return all the names of the variables
367
+ """Return all the names of the variables.
367
368
"""
368
369
elements = [i for i in self .ELEMENTS ]
369
370
if self .track_array_variables > 0 :
@@ -376,7 +377,7 @@ def elements(self):
376
377
return list (set (elements ))
377
378
378
379
def coherence (self , other ):
379
- """Check coherence between two dataset
380
+ """Check coherence between two datasets.
380
381
"""
381
382
test = self .track_extra_variables == other .track_extra_variables
382
383
test *= self .track_array_variables == other .track_array_variables
@@ -402,7 +403,7 @@ def concatenate(cls, observations):
402
403
return eddies
403
404
404
405
def merge (self , other ):
405
- """Merge two dataset
406
+ """Merge two datasets.
406
407
"""
407
408
nb_obs_self = len (self )
408
409
nb_obs = nb_obs_self + len (other )
@@ -424,7 +425,7 @@ def reset(self):
424
425
425
426
@property
426
427
def obs (self ):
427
- """Return an array observations
428
+ """Return observations.
428
429
"""
429
430
return self .observations
430
431
@@ -437,7 +438,7 @@ def __iter__(self):
437
438
438
439
def iter_on (self , xname , bins = None ):
439
440
"""
440
- Yield observation group for each bin
441
+ Yield observation group for each bin.
441
442
442
443
:param str varname:
443
444
:param array bins: bounds of each bin ,
@@ -467,7 +468,7 @@ def iter_on(self, xname, bins=None):
467
468
468
469
def align_on (self , other , var_name = "time" , ** kwargs ):
469
470
"""
470
- Align the time indexes of two datasets
471
+ Align the time indexes of two datasets.
471
472
"""
472
473
iter_self , iter_other = (
473
474
self .iter_on (var_name , ** kwargs ),
@@ -486,7 +487,7 @@ def align_on(self, other, var_name="time", **kwargs):
486
487
yield indexs_self , indexs_other , b0_self , b1_self
487
488
488
489
def insert_observations (self , other , index ):
489
- """Insert other obs in self at the index
490
+ """Insert other obs in self at the index.
490
491
"""
491
492
if not self .coherence (other ):
492
493
raise Exception ("Observations with no coherence" )
@@ -508,7 +509,7 @@ def insert_observations(self, other, index):
508
509
return self
509
510
510
511
def append (self , other ):
511
- """Merge
512
+ """Merge.
512
513
"""
513
514
return self + other
514
515
@@ -517,7 +518,7 @@ def __add__(self, other):
517
518
518
519
def distance (self , other ):
519
520
""" Use haversine distance for distance matrix between every self and
520
- other eddies"""
521
+ other eddies. """
521
522
return distance_grid (
522
523
self .obs ["lon" ], self .obs ["lat" ], other .obs ["lon" ], other .obs ["lat" ]
523
524
)
@@ -534,7 +535,7 @@ def new_like(eddies, new_size):
534
535
)
535
536
536
537
def index (self , index , reverse = False ):
537
- """Return obs from self at the index
538
+ """Return obs from self at the index.
538
539
"""
539
540
if reverse :
540
541
index = reverse_index (index , len (self ))
@@ -559,7 +560,7 @@ def zarr_dimension(filename):
559
560
@classmethod
560
561
def load_file (cls , filename , ** kwargs ):
561
562
"""
562
- Load the netcdf or the zarr file
563
+ Load the netcdf or the zarr file.
563
564
564
565
Load only latitude and longitude on the first 300 obs :
565
566
@@ -573,6 +574,10 @@ def load_file(cls, filename, **kwargs):
573
574
indexs=dict(obs=slice(0, 300)),
574
575
)
575
576
small_dataset = TrackEddiesObservations.load_file(filename, **kwargs_latlon_300)
577
+
578
+ Default **kwargs to load zarr are : raw_data=False, remove_vars=None, include_vars=None
579
+
580
+ Default **kwargs to load netcdf are : raw_data=False, remove_vars=None, include_vars=None, indexs=None
576
581
"""
577
582
filename_ = (
578
583
filename .filename if isinstance (filename , ExFileObject ) else filename
@@ -843,7 +848,7 @@ def propagate(
843
848
self , previous_obs , current_obs , obs_to_extend , dead_track , nb_next , model
844
849
):
845
850
"""
846
- Filled virtual obs (C)
851
+ Filled virtual obs (C).
847
852
848
853
:param previous_obs: previous obs from current (A)
849
854
:param current_obs: previous obs from virtual (B)
@@ -902,16 +907,17 @@ def intern(flag, public_label=False):
902
907
return labels
903
908
904
909
def match (self , other , method = "overlap" , intern = False , cmin = 0 , ** kwargs ):
905
- """Return index and score computed with the chosen method on the effective contour
910
+ """Return index and score computed on the effective contour.
906
911
907
912
:param EddiesObservations other: Observations to compare
908
913
:param str method:
909
914
- "overlap": the score is computed with contours;
910
- - "circle": circles are computed and used for score
915
+ - "circle": circles are computed and used for score (TODO)
911
916
:param bool intern: if True, speed contour is used (default = effective contour)
912
917
:param float cmin: 0 < cmin < 1, return only couples with score >= cmin
913
- :param dict kwargs: look at :py:meth:`py_eddy_tracker.poly.vertice_overlap`
914
- :return: return the indexes of the eddies in self coupled with eddies in other and their associated score
918
+ :param dict kwargs: look at :py:meth:`vertice_overlap`
919
+ :return: return the indexes of the eddies in self coupled with eddies in
920
+ other and their associated score
915
921
:rtype: (array(int), array(int), array(float))
916
922
917
923
.. minigallery:: py_eddy_tracker.EddiesObservations.match
@@ -980,13 +986,14 @@ def mask_function(self, other, distance):
980
986
981
987
@staticmethod
982
988
def cost_function (records_in , records_out , distance ):
983
- """Return cost function between obs to associate
989
+ """Return the cost function between two obs.
984
990
985
- .. code-block:: python
991
+ .. math::
986
992
987
- cost = sqrt(((amplitude_in - amplitude_out) / amplitude_in) ** 2 +
988
- ((speed_radius_in - speed_radius_out) / speed_radius_in) ** 2 +
989
- (distance / 125) ** 2)
993
+ cost = \sqrt{({Amp_{_{in}} - Amp_{_{out}} \over Amp_{_{in}}}) ^2 +
994
+ ({Rspeed_{_{in}} - Rspeed_{_{out}} \over Rspeed_{_{in}}}) ^2 +
995
+ ({distance \over 125}) ^2
996
+ }
990
997
991
998
:param records_in: starting observations
992
999
:param records_out: observations to associate
@@ -1098,7 +1105,7 @@ def solve_conflict(cost):
1098
1105
1099
1106
@staticmethod
1100
1107
def solve_simultaneous (cost ):
1101
- """Write something"""
1108
+ """Write something (TODO) """
1102
1109
mask = ~ cost .mask
1103
1110
# Count number of link by self obs and other obs
1104
1111
self_links = mask .sum (axis = 1 )
@@ -1470,7 +1477,7 @@ def set_global_attr_netcdf(self, h_nc):
1470
1477
1471
1478
def extract_with_area (self , area , ** kwargs ):
1472
1479
"""
1473
- Extract geographically with a bounding box
1480
+ Extract geographically with a bounding box.
1474
1481
1475
1482
:param dict area: 4 coordinates in a dictionary to specify bounding box (lower left corner and upper right corner)
1476
1483
:param dict kwargs: look at :py:meth:`extract_with_mask`
@@ -1491,7 +1498,7 @@ def extract_with_area(self, area, **kwargs):
1491
1498
1492
1499
def extract_with_mask (self , mask ):
1493
1500
"""
1494
- Extract a subset of observations
1501
+ Extract a subset of observations.
1495
1502
1496
1503
:param array(bool) mask: mask to select observations
1497
1504
:return: same object with selected observations
@@ -1517,6 +1524,8 @@ def extract_with_mask(self, mask):
1517
1524
1518
1525
def scatter (self , ax , name = None , ref = None , factor = 1 , ** kwargs ):
1519
1526
"""
1527
+ Scatter data.
1528
+
1520
1529
:param matplotlib.axes.Axes ax: matplotlib axe used to draw
1521
1530
:param str, None name:
1522
1531
variable used to fill the contour, if None all elements have the same color
0 commit comments