24
24
25
25
make_eddy_track_AVISO.py
26
26
27
- Version 1.0.1
27
+ Version 1.1.0
28
28
29
29
30
30
Scroll down to line ~630 to get started
33
33
34
34
35
35
import glob as glob
36
+ #import matplotlib.pyplot as plt
36
37
from py_eddy_tracker_classes import *
38
+ from make_eddy_tracker_list_obj import *
37
39
38
40
39
41
class py_eddy_tracker (object ):
@@ -634,7 +636,6 @@ def pcol_2dxy(self, x, y):
634
636
#diag_type = 'Q' <<< not implemented in 1.0.1
635
637
diag_type = 'sla'
636
638
637
- days_btwn_recs = 7.
638
639
639
640
# Path to directory where outputs are to be saved...
640
641
#savedir = directory
@@ -646,20 +647,16 @@ def pcol_2dxy(self, x, y):
646
647
647
648
print '\n Outputs saved to' , savedir
648
649
650
+ days_btwn_recs = 7.
649
651
650
-
651
-
652
-
653
-
654
-
655
-
656
652
657
653
658
654
# Reference Julian day (Julian date at Jan 1, 1992)
659
655
jday_ref = 2448623
660
656
661
657
# Min and max permitted eddy radii [m]
662
658
if 'Q' in diag_type :
659
+ Exception # Not implemented
663
660
radmin = 15000.
664
661
radmax = 250000.
665
662
ampmin = 0.02
@@ -673,25 +670,22 @@ def pcol_2dxy(self, x, y):
673
670
674
671
675
672
# Obtain this file from:
676
- # http://www-po.coas.oregonstate.edu/research/po/research/rossby_radius/
673
+ # http://www-po.coas.oregonstate.edu/research/po/research/rossby_radius/
677
674
rw_path = '/home/emason/data_tmp/chelton_eddies/rossrad.dat'
678
-
679
- # Option to track using speed-based radius or effective radius
680
- #track_with_speed = True
675
+
681
676
682
677
# Make figures for animations
683
678
anim_figs = True
684
679
685
680
686
681
# Define contours
687
682
if 'Q' in diag_type :
688
- # Set Q contours
683
+ # Set Q contour spacing
689
684
qparameter = np .linspace (0 , 5 * 10 ** - 11 , 25 )
690
685
elif 'sla' in diag_type :
691
- # Units, cm; for anticyclones use -50 to 50
692
- #slaparameter = np.arange(-100., 100.5, 0.5)
693
- slaparameter = np .arange (- 100. , 101. , 1.0 )
694
- #slaparameter = np.arange(-50., 51., 1.)
686
+ # Set SLA contour spacing
687
+ slaparameter = np .arange (- 100. , 101. , 1.0 ) # cm
688
+
695
689
696
690
697
691
# Apply a filter to the Q parameter
@@ -737,7 +731,7 @@ def pcol_2dxy(self, x, y):
737
731
738
732
739
733
# Typical parameters
740
- dist0 = 25000. # m separation distance after ~7 days (see Chelton2011 fig 22)
734
+ dist0 = 25000. # m separation distance after ~7 days (see CSS11 fig 22)
741
735
if 'Q' in diag_type :
742
736
amp0 = 0.02 # vort/f
743
737
elif 'sla' in diag_type :
@@ -754,22 +748,20 @@ def pcol_2dxy(self, x, y):
754
748
evolve_armax = 5 # max change in area
755
749
756
750
757
- separation_method = 'ellipse' # see Chelton etal (2011)
751
+ separation_method = 'ellipse' # see CSS11
758
752
#separation_method = 'sum_radii' # see Kurian etal (2011)
759
753
760
- if 'sum_radii' in separation_method :
761
- # Separation distance factor. Adjust according to number of days between records
762
- # For 7 days, Chelton uses 150 km search ellipse
763
- # So, given typical eddy radius of r=50 km, 1.5 * (r1 + r2) = 150 km.
764
- #sep_dist_fac = 1.0
765
- sep_dist_fac = 1.15 # Seems ok for AVISO 7-day
766
- #sep_dist_fac = 1.5 # Causes tracks to jump for AVISO 7-day
754
+ # if 'sum_radii' in separation_method:
755
+ ## Separation distance factor. Adjust according to number of days between records
756
+ ## For 7 days, Chelton uses 150 km search ellipse
757
+ ## So, given typical eddy radius of r=50 km, 1.5 * (r1 + r2) = 150 km.
758
+ ## sep_dist_fac = 1.0
759
+ # sep_dist_fac = 1.15 # Seems ok for AVISO 7-day
760
+ ## sep_dist_fac = 1.5 # Causes tracks to jump for AVISO 7-day
767
761
768
762
769
- #cmap = plt.cm.Spectral_r
770
- #cmap = plt.cm.jet
771
- cmap = plt .cm .RdBu
772
763
764
+ cmap = plt .cm .RdBu
773
765
774
766
verbose = False
775
767
@@ -780,6 +772,9 @@ def pcol_2dxy(self, x, y):
780
772
assert date_str < date_end , 'date_end must be larger than date_str'
781
773
assert diag_type in ('Q' ,'sla' ), 'diag_type not properly defined'
782
774
775
+ thestartdate = dt .date2num (datestr2datetime (str (date_str )))
776
+ theenddate = dt .date2num (datestr2datetime (str (date_end )))
777
+
783
778
# Get complete AVISO file list
784
779
AVISO_files = sorted (glob .glob (directory + AVISO_files ))
785
780
@@ -793,10 +788,8 @@ def pcol_2dxy(self, x, y):
793
788
qparameter .size ), 2 )[::- 1 ]
794
789
795
790
# The shape error can maybe be played with...
796
- #shape_err = np.power(np.linspace(200., 40, qparameter.size), 2) / 100.
797
791
shape_err = np .power (np .linspace (85. , 40 , qparameter .size ), 2 ) / 100.
798
792
shape_err [shape_err < 35. ] = 35.
799
- #shape_err = 35. * np.ones(qparameter.size)
800
793
801
794
elif 'sla' in diag_type :
802
795
shape_err = 55. * np .ones (slaparameter .size )
@@ -808,7 +801,7 @@ def pcol_2dxy(self, x, y):
808
801
809
802
Mx , My = sla_grd .Mx [sla_grd .jup0 :sla_grd .jup1 , sla_grd .iup0 :sla_grd .iup1 ], \
810
803
sla_grd .My [sla_grd .jup0 :sla_grd .jup1 , sla_grd .iup0 :sla_grd .iup1 ]
811
- pMx , pMy = sla_grd .pcol_2dxy (Mx , My )
804
+ # pMx, pMy = sla_grd.pcol_2dxy(Mx, My)
812
805
813
806
814
807
# Get Rossby wave speed data
@@ -932,8 +925,6 @@ def pcol_2dxy(self, x, y):
932
925
A_eddy .dist0 = np .float (dist0 )
933
926
C_eddy .dist0 = np .float (dist0 )
934
927
935
- start = 0
936
- start_time = time .time ()
937
928
A_eddy .days_btwn_recs = days_btwn_recs
938
929
C_eddy .days_btwn_recs = days_btwn_recs
939
930
@@ -943,15 +934,32 @@ def pcol_2dxy(self, x, y):
943
934
944
935
945
936
# Loop through the AVISO files...
946
- active = False
937
+ #active = False
938
+ start = True
939
+ start_time = time .time ()
947
940
print '\n Start tracking'
948
941
for AVISO_file in AVISO_files :
949
-
950
- if str (date_str ) in AVISO_file :
942
+
943
+
944
+ with netcdf .Dataset (AVISO_file ) as nc :
945
+
946
+ try :
947
+ thedate = nc .OriginalName
948
+ thedate = thedate .partition ('qd_' )[2 ].partition ('_' )[0 ]
949
+ thedate = datestr2datetime (thedate )
950
+ thedate = dt .date2num (thedate )
951
+ except Exception :
952
+ thedate = nc .variables ['time' ]
953
+ raise Exception # 2014 AVISO not yet implemented
954
+
955
+
956
+ if np .logical_and (thedate >= thestartdate ,
957
+ thedate <= theenddate ):
951
958
active = True
952
- file_time = time .time ()
953
-
954
-
959
+ else :
960
+ active = False
961
+
962
+
955
963
if active :
956
964
957
965
#rec_start_time = time.time()
@@ -1161,13 +1169,14 @@ def pcol_2dxy(self, x, y):
1161
1169
plt .close (250 )
1162
1170
1163
1171
1164
- if str (date_str ) not in AVISO_file :
1165
- first_record = False
1166
- else :
1172
+ if start :
1167
1173
first_record = True
1168
1174
# Set old variables equal to new variables
1169
1175
A_eddy .set_old_variables ()
1170
1176
C_eddy .set_old_variables ()
1177
+ start = False
1178
+ else :
1179
+ first_record = False
1171
1180
1172
1181
1173
1182
# Track the eddies
0 commit comments