Skip to content

Commit 6a15b43

Browse files
committed
add function to create subset
1 parent 0fba6c6 commit 6a15b43

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/py_eddy_tracker/observations/observation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"""
3030
from numpy import zeros, where, unique, \
3131
ma, cos, radians, isnan, ones, ndarray, \
32-
floor, array, empty
32+
floor, array, empty, absolute
3333
from netCDF4 import Dataset
3434
from ..generic import distance_grid, distance
3535
from .. import VAR_DESCR, VAR_DESCR_inv
@@ -100,8 +100,6 @@ def shifted_ellipsoid_degrees_mask2(lon0, lat0, lon1, lat1, minor=1.5, major=1.5
100100

101101
@njit(cache=True, fastmath=True)
102102
def custom_concat(x, y):
103-
'''
104-
'''
105103
nb = x.shape[0]
106104
a = empty((nb,2))
107105
for i in range(nb):

src/py_eddy_tracker/observations/tracking.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ def set_global_attr_netcdf(self, h_nc):
116116
h_nc.time_coverage_start = d_start.strftime('%Y-%m-%dT00:00:00Z')
117117
h_nc.time_coverage_end = d_end.strftime('%Y-%m-%dT00:00:00Z')
118118

119+
def extract_with_period(self, period, **kwargs):
120+
"""
121+
Extract with a period
122+
Args:
123+
period: two date to define period, must be specify from 1/1/1950
124+
**kwargs: directly give to __extract_with_mask
125+
126+
Returns:
127+
same object with selected data
128+
"""
129+
mask = (self.time > period[0]) * (self.time < period[1])
130+
return self.__extract_with_mask(mask, **kwargs)
131+
132+
119133
def __extract_with_mask(self, mask, full_path=False, remove_incomplete=False):
120134
"""
121135
Extract a subset of observations

0 commit comments

Comments
 (0)