Skip to content

Commit 8e19c5c

Browse files
committed
Added new file make_eddy_track_CLS.py
1 parent 491baa6 commit 8e19c5c

File tree

4 files changed

+149
-4
lines changed

4 files changed

+149
-4
lines changed

make_eddy_track_AVISO.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ def __getstate__(self):
545545
"""
546546
print '--- removing unwanted attributes'
547547
pops = ('Mx', 'My', '_f', '_angle', '_dx', '_dy', '_gof', '_lon',
548-
'_lat', '_pm', '_pn', '_umask', '_vmask', 'eke', 'sla',
549-
'mask', 'slacopy', 'sla_coeffs', 'uspd_coeffs')
548+
'_lat', '_pm', '_pn', '_umask', '_vmask', 'eke', 'u', 'v',
549+
'mask')
550550
result = self.__dict__.copy()
551551
for pop in pops:
552552
result.pop(pop)

make_eddy_track_CLS.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# -*- coding: utf-8 -*-
2+
# %run make_eddy_track_CLS.py
3+
4+
"""
5+
===============================================================================
6+
This file is part of py-eddy-tracker.
7+
8+
py-eddy-tracker is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU General Public License as published by
10+
the Free Software Foundation, either version 3 of the License, or
11+
(at your option) any later version.
12+
13+
py-eddy-tracker is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License
19+
along with py-eddy-tracker. If not, see <http://www.gnu.org/licenses/>.
20+
21+
Copyright (c) 2014 by Evan Mason
22+
23+
===============================================================================
24+
25+
make_eddy_track_CLS.py
26+
27+
Version 1.4.2
28+
29+
30+
===============================================================================
31+
"""
32+
import glob as glob
33+
#import pickle
34+
import cPickle as pickle
35+
#import dill
36+
import numpy as np
37+
from make_eddy_track_AVISO import track_eddies, AvisoGrid
38+
39+
40+
41+
42+
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43+
44+
if __name__ == '__main__':
45+
46+
DATA_DIR = '/data/OCE_ETU/MSA/emason/Global_DT10/'
47+
48+
A_PKL_FILES = 'A_eddy_????????.pkl'
49+
C_PKL_FILES = 'C_eddy_????????.pkl'
50+
51+
A_PKL_FILES = sorted(glob.glob(DATA_DIR + A_PKL_FILES))
52+
C_PKL_FILES = sorted(glob.glob(DATA_DIR + C_PKL_FILES))
53+
54+
55+
for PKL_FILES in (A_PKL_FILES, C_PKL_FILES):
56+
57+
for active, PKL_FILE in enumerate(PKL_FILES):
58+
59+
print PKL_FILE
60+
61+
# Unpickle
62+
with open(PKL_FILE, 'rb') as the_pickle:
63+
eddy = pickle.load(the_pickle)
64+
print '--- loaded %s' % PKL_FILE
65+
66+
print 'eddy.index', eddy.index
67+
eddy.savedir = DATA_DIR + eddy.savedir.rpartition('/')[-1]
68+
69+
eddy.TRACK_DURATION_MIN = 10
70+
71+
72+
73+
74+
if active:
75+
76+
first_record = False
77+
78+
eddy.new_list = False
79+
eddy.tracklist = tracklist.tolist()
80+
81+
eddy.index = index
82+
83+
eddy.old_lon = old_lon
84+
eddy.old_lat = old_lat
85+
eddy.old_amp = old_amp
86+
eddy.old_uavg = old_uavg
87+
eddy.old_radii_s = old_radii_s
88+
eddy.old_radii_e = old_radii_e
89+
eddy.old_teke = old_teke
90+
#eddy.old_temp = old_temp
91+
#eddy.old_salt = old_salt
92+
93+
eddy = track_eddies(eddy, first_record)
94+
tracklist = np.copy(eddy.tracklist)
95+
96+
else:
97+
98+
first_record = True
99+
100+
eddy.create_netcdf(DATA_DIR, eddy.savedir)
101+
eddy.set_old_variables()
102+
103+
eddy = track_eddies(eddy, first_record)
104+
tracklist = np.copy(eddy.tracklist)
105+
106+
index = eddy.index
107+
108+
print 'eddy.index', eddy.index
109+
print len(eddy.tracklist)
110+
111+
112+
if not first_record:
113+
print eddy.new_time_tmp[0]
114+
eddy.write2netcdf(eddy.new_time_tmp[0])
115+
116+
old_lon = eddy.old_lon
117+
old_lat = eddy.old_lat
118+
old_amp = eddy.old_amp
119+
old_uavg = eddy.old_uavg
120+
old_radii_s = eddy.old_radii_s
121+
old_radii_e = eddy.old_radii_e
122+
old_teke = eddy.old_teke
123+
#old_temp = eddy.old_temp
124+
#old_salt = eddy.old_salt
125+
126+
127+
#eddy.reset_holding_variables()
128+
129+
130+
131+

make_eddy_tracker_list_obj.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ def __init__(self, DATATYPE, SIGN_TYPE, SAVE_DIR, grd, search_ellipse,
344344
self.FILLVAL = grd.FILLVAL
345345
self.PRODUCT = grd.PRODUCT
346346

347+
self.sla = None
348+
self.slacopy = None
349+
347350
self.new_lon = [] #np.array([])
348351
self.new_lat = []
349352
self.new_radii_s = []
@@ -387,7 +390,17 @@ def __init__(self, DATATYPE, SIGN_TYPE, SAVE_DIR, grd, search_ellipse,
387390
'in *DATATYPE* parameter'))
388391

389392

390-
393+
def __getstate__(self):
394+
"""
395+
Needed for Pickle
396+
"""
397+
print '--- removing unwanted attributes'
398+
pops = ('uspd', 'uspd_coeffs', 'sla_coeffs', 'points',
399+
'circlon', 'circlat', 'sla', 'slacopy')
400+
result = self.__dict__.copy()
401+
for pop in pops:
402+
result.pop(pop)
403+
return result
391404

392405
def add_new_track(self, lon, lat, time, uavg, teke,
393406
radius_s, radius_e, amplitude, temp=None, salt=None,

py_eddy_tracker_classes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,7 @@ def track_eddies(Eddy, first_record):
10371037
Eddy.new_lon_tmp[new_ind])] = False
10381038
#print 'aa', new_eddy_inds
10391039
dist_mat[:, new_ind] = far_away # km
1040+
print '*********************************************'
10401041

10411042

10421043
if Eddy.TRACK_EXTRA_VARIABLES:
@@ -1170,7 +1171,7 @@ def track_eddies(Eddy, first_record):
11701171
# Now we need to add new eddies defined by new_eddy_inds
11711172
if np.any(new_eddy_inds):
11721173

1173-
if False:
1174+
if True:
11741175
print '------adding %s new eddies' %new_eddy_inds.sum()
11751176

11761177
for neind, a_new_eddy in enumerate(new_eddy_inds):

0 commit comments

Comments
 (0)