24
24
25
25
make_eddy_track_AVISO.py
26
26
27
- Version 1.2.0
27
+ Version 1.2.1
28
28
29
29
30
30
Scroll down to line ~640 to get started
@@ -61,8 +61,8 @@ def __init__(self):
61
61
'''
62
62
Set some constants
63
63
'''
64
- gravity = 9.81
65
- earth_radius = 6371315.0
64
+ self . gravity = 9.81
65
+ self . earth_radius = 6371315.0
66
66
67
67
68
68
def read_nc (self , varfile , varname , indices = "[:]" ):
@@ -241,7 +241,7 @@ def get_AVISO_f_pm_pn(self):
241
241
self ._gof *= 4.
242
242
self ._gof *= np .pi
243
243
self ._gof /= 86400.
244
- self ._gof = 9.81 / self ._gof
244
+ self ._gof = self . gravity / self ._gof
245
245
246
246
lonu = self .half_interp (self .lonpad ()[:,:- 1 ], self .lonpad ()[:,1 :])
247
247
latu = self .half_interp (self .latpad ()[:,:- 1 ], self .latpad ()[:,1 :])
@@ -375,6 +375,7 @@ def __init__(self, AVISO_file, lonmin, lonmax, latmin, latmax, with_pad=True, us
375
375
self .lonmax = lonmax
376
376
self .latmin = latmin
377
377
self .latmax = latmax
378
+ self .gravity = 9.81
378
379
379
380
try : # new AVISO (2014)
380
381
self ._lon = self .read_nc (AVISO_file , 'lon' )
@@ -438,7 +439,7 @@ def get_AVISO_data(self, AVISO_file):
438
439
#zeta = fillmask(zeta, 1 + (-1 * zeta.mask))
439
440
except Exception : # In case no landpoints
440
441
zeta = np .ma .masked_array (zeta )
441
- return zeta
442
+ return zeta . astype ( np . float64 )
442
443
443
444
444
445
@@ -470,7 +471,7 @@ def fillmask(self, x, mask):
470
471
# Points greater than one are then set to zero
471
472
weight = dist / (dist .min (axis = 1 )[:,np .newaxis ])
472
473
weight *= np .ones_like (dist )
473
- np .place (weight , weight > 1. , 0. )
474
+ np .place (weight , weight > 1. , 0. )
474
475
475
476
# Multiply the queried good points by the weight, selecting only the
476
477
# nearest points. Divide by the number of nearest points to get average
@@ -653,41 +654,51 @@ def pcol_2dxy(self, x, y):
653
654
# Specify use of new AVISO 2014 data
654
655
new_AVISO = True
655
656
657
+ # Specify subsampling new AVISO 2014 data; i.e. you may
658
+ # prefer to use every second day rather than every day
659
+ if new_AVISO :
660
+ new_AVISO_SUBSAMP = True
661
+ if new_AVISO_SUBSAMP :
662
+ days_btwn_recs = 7. # put sampling rate (days) here
663
+ else :
664
+ days_btwn_recs = 1.
665
+ else : # old seven day AVISO
666
+ days_btwn_recs = 7.
667
+
656
668
# Set path(s) to directory where SSH data are stored...
657
669
if 'Global' in the_domain :
658
670
if new_AVISO :
659
- directory = '/path/to/your/aviso_data/'
671
+ # directory = '/path/to/your/aviso_data/'
660
672
#directory = '/shared/Altimetry/global/delayed-time/grids/msla/all-sat-merged/h/'
661
- AVISO_files = 'dt_global_allsat_msla_h_????????_20140106.nc'
662
- days_btwn_recs = 1.
673
+ #AVISO_files = 'dt_global_allsat_msla_h_????????_20140106.nc'
674
+ directory = '/shared/Altimetry/global/delayed-time/grids/msla/two-sat-merged/h/'
675
+ AVISO_files = 'dt_global_twosat_msla_h_????????_20140106.nc'
663
676
else :
664
677
directory = '/path/to/your/aviso_data/'
665
678
#directory = '/marula/emason/data/altimetry/MSLA/GLOBAL/DT/REF/'
666
679
AVISO_files = 'dt_ref_global_merged_msla_h_qd_????????_*.nc'
667
- days_btwn_recs = 7.
668
680
669
681
elif 'MedSea' in the_domain :
670
682
if new_AVISO :
671
- directory = '/path/to/your/aviso_data/'
672
- # directory = '/shared/Altimetry/regional-mediterranean/delayed-time/grids/msla/all-sat-merged/h/'
683
+ # directory = '/path/to/your/aviso_data/'
684
+ directory = '/shared/Altimetry/regional-mediterranean/delayed-time/grids/msla/all-sat-merged/h/'
673
685
AVISO_files = 'dt_blacksea_allsat_msla_h_????????_*.nc'
674
686
else :
675
687
pass
676
688
677
689
elif 'BlackSea' in the_domain :
678
690
if new_AVISO :
679
- directory = '/path/to/your/aviso_data/'
680
- #irectory = '/shared/Altimetry/regional-blacksea/delayed-time/grids/msla/all-sat-merged/h/'
691
+ # directory = '/path/to/your/aviso_data/'
692
+ directory = '/shared/Altimetry/regional-blacksea/delayed-time/grids/msla/all-sat-merged/h/'
681
693
AVISO_files = 'dt_blacksea_allsat_msla_h_????????_*.nc'
682
- days_btwn_recs = 1.
683
694
else :
684
695
Exception #no_domain_specified
685
696
686
697
687
698
# Set date range (YYYYMMDD)
688
- date_str , date_end = 19980107 , 19991110 #
699
+ # date_str, date_end = 19980107, 19991110 #
689
700
#date_str, date_end = 20081107, 20100110 #
690
- # date_str, date_end = 19930101, 20121231 #
701
+ date_str , date_end = 19930101 , 20121231 #
691
702
692
703
# Choose type of diagnostic: either q-parameter ('Q') or sea level anomaly ('sla')
693
704
#diag_type = 'Q' <<< not implemented in 1.2.0
@@ -697,12 +708,13 @@ def pcol_2dxy(self, x, y):
697
708
# Path to directory where outputs are to be saved...
698
709
#savedir = directory
699
710
#savedir = '/marula/emason/aviso_eddy_tracking/pablo_exp/'
700
- # savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/'
711
+ savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/'
701
712
#savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test_0.35/'
702
713
#savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test_0.3/'
714
+ #savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO/CEC/'
703
715
#savedir = '/shared/emason/eddy_tracks/Barbara/2009/'
704
716
#savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/BlackSea/'
705
- savedir = '/path/to/save/your/outputs/'
717
+ # savedir = '/path/to/save/your/outputs/'
706
718
707
719
708
720
# True to save outputs in same style as Chelton
@@ -724,7 +736,7 @@ def pcol_2dxy(self, x, y):
724
736
ampmax = 100.
725
737
726
738
elif 'sla' in diag_type :
727
- radmin = 0.3 # degrees (Chelton recommends ~50 km minimum)
739
+ radmin = 0.35 # degrees (Chelton recommends ~50 km minimum)
728
740
radmax = 4.461 # degrees
729
741
ampmin = 1. # cm
730
742
ampmax = 150.
@@ -769,15 +781,16 @@ def pcol_2dxy(self, x, y):
769
781
770
782
subdomain = True
771
783
if the_domain in 'Global' :
772
- lonmin = - 36. # Canary
773
- lonmax = - 7.5
774
- latmin = 18.
775
- latmax = 33.2
784
+
785
+ #lonmin = -36. # Canary
786
+ #lonmax = -7.5
787
+ #latmin = 18.
788
+ #latmax = 33.2
776
789
777
- # lonmin = -65. # Corridor
778
- # lonmax = -5.5
779
- # latmin = 11.5
780
- # latmax = 38.5
790
+ lonmin = - 65. # Corridor
791
+ lonmax = - 5.5
792
+ latmin = 11.5
793
+ latmax = 38.5
781
794
782
795
#lonmin = -179. # SEP
783
796
#lonmax = -65
@@ -794,18 +807,22 @@ def pcol_2dxy(self, x, y):
794
807
#latmin = -47.
795
808
#latmax = -24.
796
809
810
+
797
811
elif the_domain in 'MedSea' :
812
+
798
813
lonmin = 354. # SEP
799
814
lonmax = 396
800
815
latmin = 30.
801
816
latmax = 46.
802
817
803
818
elif the_domain in 'BlackSea' :
804
- lonmin = 27. # SEP
819
+
820
+ lonmin = 27. # Black Sea
805
821
lonmax = 42.
806
822
latmin = 40.
807
823
latmax = 47.
808
824
825
+
809
826
# Typical parameters
810
827
dist0 = 25000. # m separation distance after ~7 days (see CSS11 fig 22)
811
828
if 'Q' in diag_type :
@@ -818,10 +835,10 @@ def pcol_2dxy(self, x, y):
818
835
819
836
# Parameters used by Chelton etal and Kurian etal (Sec. 3.2) to ensure the slow evolution
820
837
# of the eddies over time; they use min and max values of 0.25 and 2.5
821
- evolve_ammin = 0.05 # 0.25 # min change in amplitude
822
- evolve_ammax = 5 #2.5 # max change in amplitude
823
- evolve_armin = 0.05 # 0.25 # min change in area
824
- evolve_armax = 5 # max change in area
838
+ evolve_ammin = 0.01 # 0.25 # min change in amplitude
839
+ evolve_ammax = 10 #2.5 # max change in amplitude
840
+ evolve_armin = 0.01 # 0.25 # min change in area
841
+ evolve_armax = 10 # max change in area
825
842
826
843
827
844
separation_method = 'ellipse' # see CSS11
@@ -854,6 +871,9 @@ def pcol_2dxy(self, x, y):
854
871
# Get complete AVISO file list
855
872
AVISO_files = sorted (glob .glob (directory + AVISO_files ))
856
873
874
+ # Use this for subsampling to get identical list as old_AVISO
875
+ #AVISO_files = AVISO_files[5:-5:7]
876
+
857
877
# Set up a grid object using first AVISO file in the list
858
878
sla_grd = AVISO_grid (AVISO_files [0 ], lonmin , lonmax , latmin , latmax )
859
879
@@ -1020,20 +1040,25 @@ def pcol_2dxy(self, x, y):
1020
1040
# Loop through the AVISO files...
1021
1041
start = True
1022
1042
start_time = time .time ()
1043
+
1023
1044
print '\n Start tracking'
1045
+
1024
1046
for AVISO_file in AVISO_files :
1025
1047
1026
-
1027
1048
with netcdf .Dataset (AVISO_file ) as nc :
1028
-
1049
+
1029
1050
try :
1030
1051
thedate = nc .OriginalName
1031
- thedate = thedate .partition ('qd_' )[2 ].partition ('_' )[0 ]
1052
+ if 'qd_' in thedate :
1053
+ thedate = thedate .partition ('qd_' )[2 ].partition ('_' )[0 ]
1054
+ else :
1055
+ thedate = thedate .partition ('h_' )[2 ].partition ('_' )[0 ]
1032
1056
thedate = datestr2datetime (thedate )
1033
1057
thedate = dt .date2num (thedate )
1034
1058
except Exception :
1035
1059
thedate = nc .variables ['time' ][:]
1036
1060
thedate += sla_grd .base_date
1061
+
1037
1062
rtime = thedate
1038
1063
1039
1064
if np .logical_and (thedate >= thestartdate ,
@@ -1174,33 +1199,39 @@ def pcol_2dxy(self, x, y):
1174
1199
1175
1200
# Get contours of Q/sla parameter
1176
1201
if 'first_record' not in locals ():
1202
+
1177
1203
print '------ getting SLA contours'
1178
- plt .figure (99 )
1204
+ contfig = plt .figure (99 )
1205
+ ax = contfig .add_subplot (111 )
1206
+
1207
+ if anim_figs :
1208
+ animfig = plt .figure (999 )
1209
+ animax = animfig .add_subplot (111 )
1210
+
1179
1211
if 'Q' in diag_type :
1180
- CS = plt .contour (sla_grd .lon (),
1212
+ CS = ax .contour (sla_grd .lon (),
1181
1213
sla_grd .lat (), qparam , qparameter )
1182
1214
# Get xi contour field at zero
1183
- CSxi = plt .contour (sla_grd .lon (),
1215
+ CSxi = ax .contour (sla_grd .lon (),
1184
1216
sla_grd .lat (), xi , [0. ])
1185
1217
1186
1218
elif 'sla' in diag_type :
1187
- A_CS = plt .contour (sla_grd .lon (),
1219
+ A_CS = ax .contour (sla_grd .lon (),
1188
1220
sla_grd .lat (), A_eddy .sla , slaparameter )
1189
1221
# Note that CSc is for the cyclonics, slaparameter in reverse order
1190
- C_CS = plt .contour (sla_grd .lon (),
1222
+ C_CS = ax .contour (sla_grd .lon (),
1191
1223
sla_grd .lat (), C_eddy .sla , slaparameter [::- 1 ])
1192
1224
else : Exception
1193
1225
1194
- if True :
1195
- plt .close (99 )
1196
- else :
1197
- # Debug
1226
+ if True : # clear the current axis
1227
+ ax .cla ()
1228
+ else : # draw debug figure
1198
1229
if 'Q' in diag_type :
1199
- plt . title ('qparameter and xi' )
1200
- plt .clabel (CS , np .array ([qparameter .min (), qparameter .max ()]))
1230
+ ax . set_title ('qparameter and xi' )
1231
+ ax .clabel (CS , np .array ([qparameter .min (), qparameter .max ()]))
1201
1232
elif 'sla' in diag_type :
1202
- plt . title ('slaparameter' )
1203
- plt .clabel (A_CS , np .array ([slaparameter .min (), slaparameter .max ()]))
1233
+ ax . set_title ('slaparameter' )
1234
+ ax .clabel (A_CS , np .array ([slaparameter .min (), slaparameter .max ()]))
1204
1235
plt .axis ('image' )
1205
1236
plt .show ()
1206
1237
@@ -1227,7 +1258,7 @@ def pcol_2dxy(self, x, y):
1227
1258
if 'fig250' in locals ():
1228
1259
1229
1260
plt .figure (250 )
1230
- tit = 'Y' + str (yr ) + 'M' + str (mo ) + 'D' + str (da )
1261
+ tit = 'Y' + str (yr ) + 'M' + str (mo ). zfill ( 2 ) + 'D' + str (da ). zfill ( 2 )
1231
1262
1232
1263
if 'Q' in diag_type :
1233
1264
plt .title ('Q ' + tit )
@@ -1274,7 +1305,7 @@ def pcol_2dxy(self, x, y):
1274
1305
1275
1306
if anim_figs : # Make figures for animations
1276
1307
1277
- tit = 'Y' + str (yr ) + 'M' + str (mo ) + 'D' + str (da )
1308
+ tit = 'Y' + str (yr ) + 'M' + str (mo ). zfill ( 2 ) + 'D' + str (da ). zfill ( 2 )
1278
1309
1279
1310
#if 'anim_fig' in locals():
1280
1311
## Wait if there is a still-active anim_fig thread
@@ -1290,11 +1321,11 @@ def pcol_2dxy(self, x, y):
1290
1321
args=(33, M, pMx, pMy, slacopy, plt.cm.RdBu_r, rtime, diag_type, Mx, My,
1291
1322
slacopy, slacopy, slaparameter, A_eddy, C_eddy,
1292
1323
savedir, plt, 'SLA ' + tit))'''
1293
- fignum = 31
1324
+
1294
1325
#print 'figure saving'
1295
1326
#tt = time.time()
1296
1327
anim_figure (A_eddy , C_eddy , Mx , My , pMx , pMy , plt .cm .RdBu_r , rtime , diag_type ,
1297
- savedir , 'SLA ' + tit , fignum )
1328
+ savedir , 'SLA ' + tit , animax )
1298
1329
#print 'figure saving done in %s seconds\n' %(time.time() - tt)
1299
1330
#anim_fig.start()
1300
1331
0 commit comments