Skip to content

Commit a775661

Browse files
author
adelepoulle
committed
Manage of empty pixel with gaussian filter
1 parent f448412 commit a775661

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/scripts/EddyIdentification

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ from matplotlib.dates import date2num, num2julian
3131
from matplotlib.figure import Figure
3232
from os.path import exists
3333
from os import mkdir
34-
from numpy import array, arange, atleast_1d, unique, round, int, interp, pi
34+
from numpy import array, arange, atleast_1d, unique, round, int, interp, pi, \
35+
float_, errstate, ma
3536

3637
from py_eddy_tracker import EddyParser
3738
from py_eddy_tracker.property_functions import \
@@ -173,13 +174,20 @@ if __name__ == '__main__':
173174
if 'Gaussian' in CONFIG['SMOOTHING_SLA']['TYPE']:
174175
logging.info('applying Gaussian high-pass filter')
175176
# Set landpoints to zero
177+
m = SLA_GRD.mask
176178
sla[SLA_GRD.mask] = 0.
177179
if hasattr(sla, 'data'):
180+
m += sla.data == SLA_GRD.fillval
178181
sla[sla.data == SLA_GRD.fillval] = 0.
179182
# High pass filter, see
180183
# http://stackoverflow.com/questions/6094957/high-pass-filter-
181184
# for-image-processing-in-python-by-using-scipy-numpy
182-
sla -= gaussian_filter(sla, [MRES, ZRES])
185+
v = gaussian_filter(sla, sigma=[MRES, ZRES])
186+
w = gaussian_filter(float_(-m), sigma=[MRES, ZRES])
187+
188+
with errstate(invalid='ignore'):
189+
sla -= ma.array(v / w, mask= (w==0) + m)
190+
183191
logging.info('applying Gaussian high-pass filter -- OK')
184192

185193
elif 'Hanning' in SMOOTHING_TYPE:

0 commit comments

Comments
 (0)