2424
2525make_eddy_track_AVISO.py
2626
27- Version 1.0.1
27+ Version 1.1.0
2828
2929
3030Scroll down to line ~630 to get started
3333
3434
3535import glob as glob
36+ #import matplotlib.pyplot as plt
3637from py_eddy_tracker_classes import *
38+ from make_eddy_tracker_list_obj import *
3739
3840
3941class py_eddy_tracker (object ):
@@ -634,7 +636,6 @@ def pcol_2dxy(self, x, y):
634636 #diag_type = 'Q' <<< not implemented in 1.0.1
635637 diag_type = 'sla'
636638
637- days_btwn_recs = 7.
638639
639640 # Path to directory where outputs are to be saved...
640641 #savedir = directory
@@ -646,20 +647,16 @@ def pcol_2dxy(self, x, y):
646647
647648 print '\n Outputs saved to' , savedir
648649
650+ days_btwn_recs = 7.
649651
650-
651-
652-
653-
654-
655-
656652
657653
658654 # Reference Julian day (Julian date at Jan 1, 1992)
659655 jday_ref = 2448623
660656
661657 # Min and max permitted eddy radii [m]
662658 if 'Q' in diag_type :
659+ Exception # Not implemented
663660 radmin = 15000.
664661 radmax = 250000.
665662 ampmin = 0.02
@@ -673,25 +670,22 @@ def pcol_2dxy(self, x, y):
673670
674671
675672 # 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/
677674 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+
681676
682677 # Make figures for animations
683678 anim_figs = True
684679
685680
686681 # Define contours
687682 if 'Q' in diag_type :
688- # Set Q contours
683+ # Set Q contour spacing
689684 qparameter = np .linspace (0 , 5 * 10 ** - 11 , 25 )
690685 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+
695689
696690
697691 # Apply a filter to the Q parameter
@@ -737,7 +731,7 @@ def pcol_2dxy(self, x, y):
737731
738732
739733 # 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)
741735 if 'Q' in diag_type :
742736 amp0 = 0.02 # vort/f
743737 elif 'sla' in diag_type :
@@ -754,22 +748,20 @@ def pcol_2dxy(self, x, y):
754748 evolve_armax = 5 # max change in area
755749
756750
757- separation_method = 'ellipse' # see Chelton etal (2011)
751+ separation_method = 'ellipse' # see CSS11
758752 #separation_method = 'sum_radii' # see Kurian etal (2011)
759753
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
767761
768762
769- #cmap = plt.cm.Spectral_r
770- #cmap = plt.cm.jet
771- cmap = plt .cm .RdBu
772763
764+ cmap = plt .cm .RdBu
773765
774766 verbose = False
775767
@@ -780,6 +772,9 @@ def pcol_2dxy(self, x, y):
780772 assert date_str < date_end , 'date_end must be larger than date_str'
781773 assert diag_type in ('Q' ,'sla' ), 'diag_type not properly defined'
782774
775+ thestartdate = dt .date2num (datestr2datetime (str (date_str )))
776+ theenddate = dt .date2num (datestr2datetime (str (date_end )))
777+
783778 # Get complete AVISO file list
784779 AVISO_files = sorted (glob .glob (directory + AVISO_files ))
785780
@@ -793,10 +788,8 @@ def pcol_2dxy(self, x, y):
793788 qparameter .size ), 2 )[::- 1 ]
794789
795790 # The shape error can maybe be played with...
796- #shape_err = np.power(np.linspace(200., 40, qparameter.size), 2) / 100.
797791 shape_err = np .power (np .linspace (85. , 40 , qparameter .size ), 2 ) / 100.
798792 shape_err [shape_err < 35. ] = 35.
799- #shape_err = 35. * np.ones(qparameter.size)
800793
801794 elif 'sla' in diag_type :
802795 shape_err = 55. * np .ones (slaparameter .size )
@@ -808,7 +801,7 @@ def pcol_2dxy(self, x, y):
808801
809802 Mx , My = sla_grd .Mx [sla_grd .jup0 :sla_grd .jup1 , sla_grd .iup0 :sla_grd .iup1 ], \
810803 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)
812805
813806
814807 # Get Rossby wave speed data
@@ -932,8 +925,6 @@ def pcol_2dxy(self, x, y):
932925 A_eddy .dist0 = np .float (dist0 )
933926 C_eddy .dist0 = np .float (dist0 )
934927
935- start = 0
936- start_time = time .time ()
937928 A_eddy .days_btwn_recs = days_btwn_recs
938929 C_eddy .days_btwn_recs = days_btwn_recs
939930
@@ -943,15 +934,32 @@ def pcol_2dxy(self, x, y):
943934
944935
945936 # Loop through the AVISO files...
946- active = False
937+ #active = False
938+ start = True
939+ start_time = time .time ()
947940 print '\n Start tracking'
948941 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 ):
951958 active = True
952- file_time = time .time ()
953-
954-
959+ else :
960+ active = False
961+
962+
955963 if active :
956964
957965 #rec_start_time = time.time()
@@ -1161,13 +1169,14 @@ def pcol_2dxy(self, x, y):
11611169 plt .close (250 )
11621170
11631171
1164- if str (date_str ) not in AVISO_file :
1165- first_record = False
1166- else :
1172+ if start :
11671173 first_record = True
11681174 # Set old variables equal to new variables
11691175 A_eddy .set_old_variables ()
11701176 C_eddy .set_old_variables ()
1177+ start = False
1178+ else :
1179+ first_record = False
11711180
11721181
11731182 # Track the eddies
0 commit comments