-
Notifications
You must be signed in to change notification settings - Fork 38
/
eddy_tracking.py
54 lines (30 loc) · 1.33 KB
/
eddy_tracking.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
Software for the tracking of eddies in
OFAM model output following Chelton et
al., Progress in Oceanography, 2011.
'''
# Load required modules
import numpy as np
import eddy_functions as eddy
# Load parameters
from params import *
# Automated eddy tracking
data = np.load(data_dir+'eddy_det_'+run+'.npz')
det_eddies = data['eddies'] # len(eddies) = number of time steps
# Initialize eddies discovered at first time step
eddies = eddy.eddies_init(det_eddies)
# Stitch eddy tracks together at future time steps
print 'eddy tracking started'
print "number of time steps to loop over: ",T
rossrad = eddy.load_rossrad() # Atlas of Rossby radius of deformation and first baroclinic wave speed (Chelton et al. 1998)
for tt in range(1, T):
print "timestep: " ,tt+1,". out of: ", T
# Track eddies from time step tt-1 to tt and update corresponding tracks and/or create new eddies
eddies = eddy.track_eddies(eddies, det_eddies, tt, dt, dt_aviso, dE_aviso, rossrad, eddy_scale_min, eddy_scale_max)
# Save data incrementally
if( np.mod(tt, dt_save)==0 ):
np.savez(data_dir+'eddy_track_'+run, eddies=eddies)
# Add keys for eddy age and flag if eddy was still in existence at end of run
for ed in range(len(eddies)):
eddies[ed]['age'] = len(eddies[ed]['lon'])
np.savez(data_dir+'eddy_track_'+run, eddies=eddies)