30
30
@njit (cache = True )
31
31
def count_consecutive (mask ):
32
32
"""
33
- Count consecutive event every False flag count restart
33
+ Count consecutive events every False flag count restart
34
34
35
35
:param array[bool] mask: event to count
36
36
:return: count when consecutive event
@@ -50,7 +50,7 @@ def count_consecutive(mask):
50
50
@njit (cache = True )
51
51
def reverse_index (index , nb ):
52
52
"""
53
- Compute a list of index , which are not in index.
53
+ Compute a list of indexes , which are not in index.
54
54
55
55
:param array index: index of group which will be set to False
56
56
:param array nb: Count for each group
@@ -65,25 +65,25 @@ def reverse_index(index, nb):
65
65
66
66
@njit (cache = True )
67
67
def build_index (groups ):
68
- """We expected that variable is monotonous, and return index for each step change.
68
+ """We expect that variable is monotonous, and return index for each step change.
69
69
70
- :param array groups: array which contain group to be separated
71
- :return: (first_index of each group, last_index of each group, value to shift group )
70
+ :param array groups: array that contains groups to be separated
71
+ :return: (first_index of each group, last_index of each group, value to shift groups )
72
72
:rtype: (array, array, int)
73
-
74
73
Examples
75
74
--------
76
75
>>> build_index(array((1, 1, 3, 4, 4)))
77
76
(array([0, 2, 2, 3]), array([2, 2, 3, 5]), 1)
78
77
"""
78
+
79
79
i0 , i1 = groups .min (), groups .max ()
80
80
amplitude = i1 - i0 + 1
81
81
# Index of first observation for each group
82
82
first_index = zeros (amplitude , dtype = numba_types .int_ )
83
83
for i , group in enumerate (groups [:- 1 ]):
84
84
# Get next value to compare
85
85
next_group = groups [i + 1 ]
86
- # if different we need to set index for all group between the 2 values
86
+ # if different we need to set index for all groups between the 2 values
87
87
if group != next_group :
88
88
first_index [group - i0 + 1 : next_group - i0 + 1 ] = i + 1
89
89
last_index = zeros (amplitude , dtype = numba_types .int_ )
@@ -95,21 +95,21 @@ def build_index(groups):
95
95
96
96
@njit (cache = True )
97
97
def hist_numba (x , bins ):
98
- """Call numba histogram to speed up."""
98
+ """Call numba histogram to speed up."""
99
99
return histogram (x , bins )
100
100
101
101
102
102
@njit (cache = True , fastmath = True , parallel = False )
103
103
def distance_grid (lon0 , lat0 , lon1 , lat1 ):
104
104
"""
105
- Get distance for every couple of point .
105
+ Get distance for every couple of points .
106
106
107
107
:param array lon0:
108
108
:param array lat0:
109
109
:param array lon1:
110
110
:param array lat1:
111
111
112
- :return: nan value for far away point , and km for other
112
+ :return: nan value for far away points , and km for other
113
113
:rtype: array
114
114
"""
115
115
nb_0 = lon0 .shape [0 ]
@@ -164,7 +164,7 @@ def cumsum_by_track(field, track):
164
164
Cumsum by track.
165
165
166
166
:param array field: data to sum
167
- :pram array(int) track: id of track to separate data
167
+ :pram array(int) track: id of trajectories to separate data
168
168
:return: cumsum with a reset at each start of track
169
169
:rtype: array
170
170
"""
@@ -192,7 +192,7 @@ def interp2d_geo(x_g, y_g, z_g, m_g, x, y, nearest=False):
192
192
:param array m_g: Boolean grid, True if value is masked
193
193
:param array x: coordinate where interpolate z
194
194
:param array y: coordinate where interpolate z
195
- :param bool nearest: if true we will take nearest pixel
195
+ :param bool nearest: if True we will take nearest pixel
196
196
:return: z interpolated
197
197
:rtype: array
198
198
"""
@@ -256,17 +256,17 @@ def interp2d_bilinear(x_g, y_g, z_g, m_g, x, y):
256
256
nb_x = x_g .shape [0 ]
257
257
nb_y = y_g .shape [0 ]
258
258
is_circular = abs (x_g [- 1 ] % 360 - (x_g [0 ] - x_step ) % 360 ) < 1e-5
259
- # Indices which should be never exist
259
+ # Indexes that should never exist
260
260
i0_old , j0_old , masked = - 100000000 , - 10000000 , False
261
261
z = empty (x .shape , dtype = z_g .dtype )
262
262
for i in prange (x .size ):
263
263
x_ = (x [i ] - x_ref ) / x_step
264
264
y_ = (y [i ] - y_ref ) / y_step
265
265
i0 = int (floor (x_ ))
266
- # To keep original value if wrapping apply to compute xd
266
+ # To keep original values if wrapping applied to compute xd
267
267
i0_ = i0
268
268
j0 = int (floor (y_ ))
269
- # corner are the same need only a new xd and yd
269
+ # corners are the same need only a new xd and yd
270
270
if i0 != i0_old or j0 != j0_old :
271
271
i1 = i0 + 1
272
272
j1 = j0 + 1
@@ -288,7 +288,7 @@ def interp2d_bilinear(x_g, y_g, z_g, m_g, x, y):
288
288
z_g [i1 , j1 ],
289
289
)
290
290
masked = False
291
- # Need to be store only on change
291
+ # Need to be stored only on change
292
292
i0_old , j0_old = i0 , j0
293
293
if masked :
294
294
z [i ] = nan
@@ -359,17 +359,17 @@ def flatten_line_matrix(l_matrix):
359
359
@njit (cache = True )
360
360
def simplify (x , y , precision = 0.1 ):
361
361
"""
362
- Will remove all middle/end point which are closer than precision.
362
+ Will remove all middle/end points closer than precision.
363
363
364
364
:param array x:
365
365
:param array y:
366
- :param float precision: if two points have distance inferior to precision with remove next point
366
+ :param float precision: if two points have distance inferior to precision we remove next point
367
367
:return: (x,y)
368
368
:rtype: (array,array)
369
369
"""
370
370
precision2 = precision ** 2
371
371
nb = x .shape [0 ]
372
- # will be True for value keep
372
+ # will be True for kept values
373
373
mask = ones (nb , dtype = bool_ )
374
374
for j in range (0 , nb ):
375
375
x_previous , y_previous = x [j ], y [j ]
@@ -423,7 +423,7 @@ def split_line(x, y, i):
423
423
:param y: array
424
424
:param i: array of int at each i change, we cut x, y
425
425
426
- :return: x and y separate by nan at each i jump
426
+ :return: x and y separated by nan at each i jump
427
427
"""
428
428
nb_jump = len (where (i [1 :] - i [:- 1 ] != 0 )[0 ])
429
429
nb_value = x .shape [0 ]
@@ -445,11 +445,11 @@ def split_line(x, y, i):
445
445
@njit (cache = True )
446
446
def wrap_longitude (x , y , ref , cut = False ):
447
447
"""
448
- Will wrap contiguous longitude with reference as west bound .
448
+ Will wrap contiguous longitude with reference as western boundary .
449
449
450
450
:param array x:
451
451
:param array y:
452
- :param float ref: longitude of reference, all the new value will be between ref and ref + 360
452
+ :param float ref: longitude of reference, all the new values will be between ref and ref + 360
453
453
:param bool cut: if True line will be cut at the bounds
454
454
:return: lon,lat
455
455
:rtype: (array,array)
@@ -557,7 +557,7 @@ def local_to_coordinates(x, y, lon0, lat0):
557
557
@njit (cache = True , fastmath = True )
558
558
def nearest_grd_indice (x , y , x0 , y0 , xstep , ystep ):
559
559
"""
560
- Get nearest grid indice from a position.
560
+ Get nearest grid index from a position.
561
561
562
562
:param x: longitude
563
563
:param y: latitude
@@ -575,7 +575,7 @@ def nearest_grd_indice(x, y, x0, y0, xstep, ystep):
575
575
@njit (cache = True )
576
576
def bbox_indice_regular (vertices , x0 , y0 , xstep , ystep , N , circular , x_size ):
577
577
"""
578
- Get bbox indice of a contour in a regular grid.
578
+ Get bbox index of a contour in a regular grid.
579
579
580
580
:param vertices: vertice of contour
581
581
:param float x0: first grid longitude
0 commit comments