Skip to content

Commit e314212

Browse files
author
adelepoulle
committed
Draft of tracking
1 parent 621f26b commit e314212

11 files changed

+901
-230
lines changed

share/eddy_identification.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Two diagnostics, based on SLA (e.g., Chelton et al, 2011)
2+
DIAGNOSTIC_TYPE: 'SLA'
3+
4+
# Specify domain
5+
DOMAIN:
6+
#~ THE_DOMAIN: 'Global'
7+
THE_DOMAIN: 'Regional'
8+
LONMIN: -100
9+
LONMAX: -5
10+
LATMIN: 10
11+
LATMAX: 45
12+
DATE_STR: 2014-12-27
13+
DATE_END: 2014-12-31
14+
15+
DATASET:
16+
# Path to data
17+
#~ DATA_DIR: '/data/PVA/Externe/global/delayed-time/grids/msla/all-sat-merged/h/2014/'
18+
DATA_DIR: '/home/adelepoulle/2014/'
19+
# Model to select file
20+
FILES_MODEL: dt_global_allsat_msla_h_????????_????????.nc
21+
# Model to extract date (regular expression)
22+
DATE_REGEXP: dt_global_allsat_msla_h_([0-9]*)_[0-9]*.nc
23+
# Model to transfer date to python datetime
24+
DATE_MODEL: '%Y%m%d'
25+
# Grid Name to compute analysis
26+
VAR_NAME: Grid_0001
27+
# Longitude variable
28+
LON_NAME: NbLongitudes
29+
# Latitude variable
30+
LAT_NAME: NbLatitudes
31+
# Step to do SUBSAMPLING (1 no subsampling)
32+
SUBSAMPLING: 1
33+
34+
PATHS:
35+
# Obtain file from:
36+
# http://www-po.coas.oregonstate.edu/research/po/research/rossby_radius/
37+
RW_PATH: 'rossrad.dat'
38+
# Path for saving of outputs
39+
SAVE_DIR: 'test/'
40+
41+
# Reference Julian day (Julian date at Jan 1, 1992)
42+
JDAY_REFERENCE: 2448623.
43+
44+
# Define contouring parameters
45+
CONTOUR_PARAMETER:
46+
# Set SLA contour spacing (cm)
47+
CONTOUR_PARAMETER_SLA:
48+
MAX_SLA: 100.
49+
INTERVAL: 1
50+
#~ INTERVAL: 4
51+
52+
# Shape error (see Kurian et al 2011)
53+
SHAPE_ERROR: 65. # % (Mason et al 2014 use 55%)
54+
55+
# Filtering
56+
SMOOTHING: Yes
57+
SMOOTHING_SLA:
58+
TYPE: 'Gaussian'
59+
ZWL: 20. # degrees, zonal wavelength (see Chelton etal 2011)
60+
MWL: 10. # degrees, meridional wavelength
61+
62+
# Min and max permitted eddy radii [degrees] and amplitudes (cm)
63+
# 0.4 for DT10, 0.35 for DT14
64+
RADMIN: 0.35
65+
RADMAX: 4.461
66+
AMPMIN: 0.
67+
AMPMAX: 150.
68+
69+
# MPM14 use 1; CSS11 have no limit
70+
MAX_LOCAL_EXTREMA: 1
71+
72+
# Typical parameters
73+
RAD0: 60000. # m
74+
AMP0: 2. # cm
75+
TEMP0: 15.
76+
SALT0: 35.
77+
78+
# Parameters used by Chelton etal and Kurian etal (Sec. 3.2) to ensure
79+
# the slow evolution of the eddies over time;
80+
# they use min and max values of 0.25 and 2.5
81+
EVOLVE_AMP_MIN: 0.0005 # min change in amplitude
82+
EVOLVE_AMP_MAX: 500 # max change in amplitude
83+
EVOLVE_AREA_MIN: 0.0005 # min change in area
84+
EVOLVE_AREA_MAX: 500 # max change in area
85+
86+
# Define track_extra_variables to track and save:
87+
# - effective contour points
88+
# - speed-based contour points
89+
# - shape test values
90+
# - profiles of swirl velocity from effective contour inwards
91+
# Useful for working with ARGO data
92+
TRACK_EXTRA_VARIABLES: No
93+
94+
# 'RectBivariate' is faster
95+
INTERP_METHOD: 'RectBivariate'

share/tracking.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Two diagnostics, based on SLA (e.g., Chelton et al, 2011)
2+
# or the Q-parameter (e.g., Kurian et al, 2011) are available
3+
DIAGNOSTIC_TYPE: 'SLA'
4+
5+
PATHS:
6+
FILES_PATTERN: /homelocal/adelepoulle/20151110_eddy_track/Anticyclonic_2014*.nc
7+
#~ FILES_PATTERN: /homelocal/adelepoulle/20151110_eddy_track/Cyclonic_2014*.nc
8+
# Path and filename of Chelton et al (1998) Rossby radius data
9+
# Obtain file from:
10+
# http://www-po.coas.oregonstate.edu/research/po/research/rossby_radius/
11+
RW_PATH: 'rossrad.dat'
12+
# Path for saving of outputs
13+
SAVE_DIR: 'test/'
14+
15+
TRACK_DURATION_MIN: 28 # Number of observations
16+
17+
SEPARATION_METHOD: 'ellipse'
18+
#SEPARATION_METHOD: 'sum_radii'
19+
20+
21+
# Typical parameters
22+
DIST0: 25000. # m separation distance after ~7 days (see CSS11 fig 22)

src/py_eddy_tracker/__init__.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@ def parse_args(self, *args, **kwargs):
126126
'around the contour defining the eddy perimeter',
127127
)
128128
),
129-
radius=dict(
130-
attr_name=None,
131-
nc_name='L',
132-
nc_type='float32',
133-
nc_dims=('Nobs',),
134-
scale_factor=1e-3,
135-
nc_attr=dict(
136-
long_name='speed radius scale',
137-
units='km',
138-
description='radius of a circle whose area is equal to that '
139-
'enclosed by the contour of maximum circum-average'
140-
' speed',
141-
)
142-
),
129+
#~ radius=dict(
130+
#~ attr_name=None,
131+
#~ nc_name='L',
132+
#~ nc_type='float32',
133+
#~ nc_dims=('Nobs',),
134+
#~ scale_factor=1e-3,
135+
#~ nc_attr=dict(
136+
#~ long_name='speed radius scale',
137+
#~ units='km',
138+
#~ description='radius of a circle whose area is equal to that '
139+
#~ 'enclosed by the contour of maximum circum-average'
140+
#~ ' speed',
141+
#~ )
142+
#~ ),
143143
speed_radius=dict(
144144
attr_name='speed_radius',
145145
scale_factor=100,
@@ -192,7 +192,7 @@ def parse_args(self, *args, **kwargs):
192192
track=dict(
193193
attr_name=None,
194194
nc_name='track',
195-
nc_type='int32',
195+
nc_type='uint32',
196196
nc_dims=('Nobs',),
197197
nc_attr=dict(
198198
long_name='track number',
@@ -203,7 +203,7 @@ def parse_args(self, *args, **kwargs):
203203
n=dict(
204204
attr_name=None,
205205
nc_name='n',
206-
nc_type='int16',
206+
nc_type='uint16',
207207
nc_dims=('Nobs',),
208208
nc_attr=dict(
209209
long_name='observation number',
@@ -254,3 +254,5 @@ def parse_args(self, *args, **kwargs):
254254
)
255255
),
256256
)
257+
258+
VAR_DESCR_inv = {VAR_DESCR[key]['nc_name'] : key for key in VAR_DESCR.keys()}

src/py_eddy_tracker/global_tracking.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ def create_variable(self, handler_nc, kwargs_variable,
3535
except ValueError:
3636
logging.warn('Data is empty')
3737

38-
def write_netcdf(self):
38+
def write_netcdf(self, global_attr):
3939
"""Write a netcdf with eddy
4040
"""
4141
eddy_size = len(self.eddy.tmp_observations)
42-
print dir(self)
43-
exit()
4442
filename = '%s_%s.nc' % (self.sign_type, self.date.strftime('%Y%m%d'))
4543
with Dataset(filename, 'w', format='NETCDF4') as h_nc:
4644
logging.info('Create intermediary file %s', filename)
@@ -67,6 +65,10 @@ def write_netcdf(self):
6765
dimensions=VAR_DESCR['type_cyc']['nc_dims']),
6866
VAR_DESCR['type_cyc']['nc_attr'],
6967
-1 if self.sign_type == 'Cyclonic' else 1)
68+
# Global attr
69+
h_nc.title = self.sign_type + ' eddy tracks'
70+
for key, value in global_attr.iteritems():
71+
h_nc.setncattr(key, str(value))
7072

7173
def read_tracks(self):
7274
"""

src/py_eddy_tracker/grid/__init__.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,21 @@ def __init__(self):
6161
self._dy = None
6262
self._umask = None
6363
self._vmask = None
64+
self.grid_filename = None
65+
self.grid_date = None
6466

65-
@staticmethod
66-
def read_nc(varfile, varname, indices=slice(None)):
67+
def read_nc(self, varname, indices=slice(None)):
6768
"""
6869
Read data from nectdf file
6970
varname : variable ('temp', 'mask_rho', etc) to read
70-
indices : string of index ranges, eg. '[0,:,0]'
71+
indices : slice
7172
"""
72-
with Dataset(varfile) as h_nc:
73+
with Dataset(self.grid_filename) as h_nc:
7374
return h_nc.variables[varname][:][indices]
7475

75-
@staticmethod
76-
def nc_variables(varfile):
77-
with Dataset(varfile) as h_nc:
76+
@property
77+
def nc_variables(self):
78+
with Dataset(self.grid_filename) as h_nc:
7879
return h_nc.variables.keys()
7980

8081
@property
@@ -94,13 +95,13 @@ def view_unpad(self):
9495
return (self.slice_j_unpad,
9596
self.slice_i_unpad)
9697

97-
def read_nc_att(self, varfile, varname, att):
98+
def read_nc_att(self, varname, att):
9899
"""
99100
Read data attribute from nectdf file
100101
varname : variable ('temp', 'mask_rho', etc) to read
101102
att : string of attribute, eg. 'valid_range'
102103
"""
103-
with Dataset(varfile) as h_nc:
104+
with Dataset(self.grid_filename) as h_nc:
104105
return getattr(h_nc.variables[varname], att)
105106

106107
@property
@@ -422,17 +423,10 @@ def set_interp_coeffs(self, sla, uspd):
422423
"""
423424
Won't work for rotated grid
424425
"""
425-
if 'AVISO' in self.product:
426-
self.sla_coeffs = interpolate.RectBivariateSpline(
427-
self.lat[:, 0], self.lon[0], sla, kx=1, ky=1)
428-
self.uspd_coeffs = interpolate.RectBivariateSpline(
429-
self.lat[:, 0], self.lon[0], uspd, kx=1, ky=1)
430-
elif 'ROMS' in self.product:
431-
points = np.array([self.lon.ravel(), self.lat.ravel()]).T
432-
self.sla_coeffs = interpolate.CloughTocher2DInterpolator(
433-
points, sla.ravel())
434-
self.uspd_coeffs = interpolate.CloughTocher2DInterpolator(
435-
points, uspd.ravel())
426+
self.sla_coeffs = interpolate.RectBivariateSpline(
427+
self.lat[:, 0], self.lon[0], sla, kx=1, ky=1)
428+
self.uspd_coeffs = interpolate.RectBivariateSpline(
429+
self.lat[:, 0], self.lon[0], uspd, kx=1, ky=1)
436430
return self
437431

438432
@staticmethod

0 commit comments

Comments
 (0)