Skip to content

Commit f807631

Browse files
committed
Add information on filter
1 parent 48b50f9 commit f807631

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/py_eddy_tracker/dataset/grid.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from numpy import concatenate, int32, empty, where, array, \
66
sin, deg2rad, pi, ones, cos, ma, int8, histogram2d, arange, float_, \
77
linspace, errstate, int_, interp, meshgrid, nan, ceil, sinc, isnan, \
8-
percentile, zeros, arctan2, arcsin, round_, nanmean, exp
8+
percentile, zeros, arctan2, arcsin, round_, nanmean, exp, mean as np_mean
99
from datetime import datetime
1010
from scipy.special import j1
1111
from netCDF4 import Dataset
@@ -1013,6 +1013,11 @@ def convolve_filter_with_dynamic_kernel(self, grid, kernel_func, lat_max=85, ext
10131013
# Matrix for result
10141014
data_out = ma.empty(data.shape)
10151015
data_out.mask = ones(data_out.shape, dtype=bool)
1016+
nb_lines = self.y_c.shape[0]
1017+
dt = list()
1018+
1019+
debug_active = logging.getLogger().getEffectiveLevel() == logging.DEBUG
1020+
10161021
for i, lat in enumerate(self.y_c):
10171022
if abs(lat) > lat_max or data[:, i].mask.all():
10181023
data_out.mask[:, i] = True
@@ -1021,6 +1026,12 @@ def convolve_filter_with_dynamic_kernel(self, grid, kernel_func, lat_max=85, ext
10211026
kernel = kernel_func(lat, **kwargs_func)
10221027
# Kernel shape
10231028
k_shape = kernel.shape
1029+
t0 = datetime.now()
1030+
if debug_active and len(dt) > 0:
1031+
dt_mean = np_mean(dt) * (nb_lines - i)
1032+
print('Remain ', dt_mean, 'ETA ', t0 + dt_mean, 'current kernel size :', k_shape, 'Step : %d/%d' % (i, nb_lines), end="\r")
1033+
1034+
10241035
# Half size, k_shape must be always impair
10251036
d_lat = int((k_shape[1] - 1) / 2)
10261037
d_lon = int((k_shape[0] - 1) / 2)
@@ -1049,6 +1060,9 @@ def convolve_filter_with_dynamic_kernel(self, grid, kernel_func, lat_max=85, ext
10491060
data_out[:, i] = ma.array(values_sum / kernel_sum, mask=kernel_sum < (extend * kernel.sum()))
10501061
else:
10511062
data_out[:, i] = values_sum / kernel_sum
1063+
dt.append(datetime.now() - t0)
1064+
if len(dt) == 100:
1065+
dt.pop(0)
10521066
if extend:
10531067
return ma.array(data_out, mask=data_out.mask)
10541068
else:

0 commit comments

Comments
 (0)