3131===========================================================================
3232"""
3333
34+ """
35+ WARNINGS...?
36+
37+ --- AVISO_file: /marula/emason/data/altimetry/MSLA/GLOBAL/DT/REF/dt_ref_global_merged_msla_h_qd_19930915_19930915_20100503.nc
38+ /usr/lib64/python2.7/site-packages/numpy/lib/arraysetops.py:197: RuntimeWarning: invalid value encountered in not_equal
39+ flag = np.concatenate(([True], aux[1:] != aux[:-1]))
40+ --- AVISO_file: /marula/emason/data/altimetry/MSLA/GLOBAL/DT/REF/dt_ref_global_merged_msla_h_qd_19930922_19930922_20100503.nc
41+ """
42+
43+
44+
45+
46+
3447
3548import glob as glob
3649#import matplotlib.pyplot as plt
@@ -114,6 +127,7 @@ def kdt(lon, lat, limits, k=4):
114127 return iind , jind
115128
116129 if 'AvisoGrid' in self .__class__ .__name__ :
130+
117131 if self .zero_crossing is True :
118132 '''
119133 Used for a zero crossing, e.g., across Agulhas region
@@ -135,6 +149,7 @@ def half_limits(lon, lat):
135149 limits = half_limits (lon , lat )
136150 iind , jind = kdt (self ._lon , self ._lat , limits )
137151 self .i0 = iind .max ()
152+
138153 return self
139154
140155
@@ -395,10 +410,19 @@ def get_geostrophic_velocity(self, zeta):
395410 surface from variables f, zeta, pm, pn...
396411 Note: output at rho points
397412 '''
398- self .upad [:] = - self .gof () * self .v2rho_2d (self .vmask () * (zeta .data [1 :] - zeta .data [:- 1 ]) \
399- * 0.5 * (self .pn ()[1 :] + self .pn ()[:- 1 ]))
400- self .vpad [:] = self .gof () * self .u2rho_2d (self .umask () * (zeta .data [:, 1 :] - zeta .data [:, :- 1 ]) \
401- * 0.5 * (self .pm ()[:, 1 :] + self .pm ()[:, :- 1 ]))
413+ gof = self .gof ().view ()
414+ vmask = self .v2rho_2d (self .vmask ().view ()
415+ zeta1 , zeta2 = zeta .data [1 :].view (), zeta .data [:- 1 ].view ()
416+ pn1 , pn2 = self .pn ()[1 :].view (), self .pn ()[:- 1 ].view ()
417+ self .upad [:] = ne .evaluate ('-gof * vmask * (zeta1 - zeta2) * 0.5 * (pn1 + pn2)' )
418+ #self.upad[:] = -self.gof() * self.v2rho_2d(self.vmask() * (zeta.data[1:] - zeta.data[:-1]) \
419+ #* 0.5 * (self.pn()[1:] + self.pn()[:-1]))
420+ umask = self .u2rho_2d (self .umask ().view ()
421+ zeta1 , zeta2 = zeta .data [:,1 :].view (), zeta .data [:,:- 1 ].view ()
422+ pm1 , pm2 = self .pm ()[:,1 :].view (), self .pm ()[:,:- 1 ].view ()
423+ self .vpad [:] = ne .evaluate ('gof * umask * (zeta1 - zeta2) * 0.5 * (pm1 + pm2)' )
424+ #self.vpad[:] = self.gof() * self.u2rho_2d(self.umask() * (zeta.data[:, 1:] - zeta.data[:, :-1]) \
425+ #* 0.5 * (self.pm()[:, 1:] + self.pm()[:, :-1]))
402426 return self
403427
404428
@@ -424,15 +448,17 @@ def getEKE(self):
424448 '''
425449 self .u [:] = self .upad [self .jup0 :self .jup1 , self .iup0 :self .iup1 ]
426450 self .v [:] = self .vpad [self .jup0 :self .jup1 , self .iup0 :self .iup1 ]
427- np .add (self .u ** 2 , self .v ** 2 , out = self .eke )
428- self .eke *= 0.5
451+ u , v = self .u .view (), self .v .view ()
452+ self .eke [:] = ne .evaluate ('0.5 * (u**2 + v**2)' )
453+ #np.add(self.u**2, self.v**2, out=self.eke)
454+ #self.eke *= 0.5
429455 return self
430456
431457
432458
433459class AvisoGrid (PyEddyTracker ):
434460 '''
435- Class to satisfy the need of the ROMS eddy tracker
461+ Class to satisfy the need of the eddy tracker
436462 to have a grid class
437463 '''
438464 def __init__ (self , AVISO_file , lonmin , lonmax , latmin , latmax , with_pad = True , use_maskoceans = False ):
@@ -705,7 +731,7 @@ def pcol_2dxy(self, x, y):
705731 #the_domain = 'MedSea' # not yet implemented
706732
707733 # Specify use of new AVISO 2014 data
708- new_AVISO = True
734+ new_AVISO = False
709735
710736 # Specify subsampling new AVISO 2014 data; i.e. you may
711737 # prefer to use every second day rather than every day
@@ -730,8 +756,8 @@ def pcol_2dxy(self, x, y):
730756 directory = '/marula/emason/data/altimetry/global/delayed-time/grids/msla/two-sat-merged/h/'
731757 AVISO_files = 'dt_global_twosat_msla_h_????????_20140106.nc'
732758 else :
733- directory = '/path/to/your/aviso_data/'
734- # directory = '/marula/emason/data/altimetry/MSLA/GLOBAL/DT/REF/'
759+ # directory = '/path/to/your/aviso_data/'
760+ directory = '/marula/emason/data/altimetry/MSLA/GLOBAL/DT/REF/'
735761 AVISO_files = 'dt_ref_global_merged_msla_h_qd_????????_*.nc'
736762
737763 elif 'MedSea' in the_domain :
@@ -754,20 +780,21 @@ def pcol_2dxy(self, x, y):
754780 # Set date range (YYYYMMDD)
755781 #date_str, date_end = 19980107, 19991110 #
756782 #date_str, date_end = 20081107, 20100110 #
757- date_str , date_end = 19930101 , 20121231 #
783+ date_str , date_end = 19921014 , 20120718 #
758784
759785 # Choose type of diagnostic: either q-parameter ('Q') or sea level anomaly ('sla')
760- diag_type = 'Q' #<<< not implemented in 1.2.0
761- # diag_type = 'sla'
786+ # diag_type = 'Q' #<<< not implemented in 1.2.0
787+ diag_type = 'sla'
762788
763789
764790 # Path to directory where outputs are to be saved...
765791 #savedir = directory
766792 #savedir = '/marula/emason/aviso_eddy_tracking/pablo_exp/'
767793 #savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/'
768794 #savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_SUBSAMP-3days/'
769- savedir = '/marula/emason/aviso_eddy_tracking/junk/'
795+ # savedir = '/marula/emason/aviso_eddy_tracking/junk/'
770796 #savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/BlackSea/'
797+ savedir = '/marula/emason/aviso_eddy_tracking/Corridor_V3_Dec2014/'
771798 #savedir = '/path/to/save/your/outputs/'
772799
773800
@@ -810,8 +837,8 @@ def pcol_2dxy(self, x, y):
810837
811838 # Set SLA contour spacing
812839 elif 'sla' in diag_type :
813- # slaparameter = np.arange(-100., 101., 1.0) # cm
814- slaparameter = np .arange (- 100. , 100.25 , 0.25 ) # cm
840+ slaparameter = np .arange (- 100. , 101. , 1.0 ) # cm
841+ # slaparameter = np.arange(-100., 100.25, 0.25) # cm
815842
816843
817844
@@ -844,10 +871,10 @@ def pcol_2dxy(self, x, y):
844871 #latmin = -35.
845872 #latmax = -10.
846873
847- # lonmin = -65. # Corridor
848- # lonmax = -5.5
849- # latmin = 11.5
850- # latmax = 38.5
874+ lonmin = - 65. # Corridor
875+ lonmax = - 5.5
876+ latmin = 11.5
877+ latmax = 38.5
851878
852879 #lonmin = -179. # SEP
853880 #lonmax = -65
@@ -938,7 +965,7 @@ def pcol_2dxy(self, x, y):
938965
939966 # Use this for subsampling to get identical list as old_AVISO
940967 #AVISO_files = AVISO_files[5:-5:7]
941- if new_AVISO_SUBSAMP :
968+ if new_AVISO and new_AVISO_SUBSAMP :
942969 AVISO_files = AVISO_files [5 :- 5 :np .int (days_btwn_recs )]
943970
944971 # Set up a grid object using first AVISO file in the list
@@ -1341,7 +1368,8 @@ def pcol_2dxy(self, x, y):
13411368
13421369 if anim_figs : # Make figures for animations
13431370
1344- tit = 'Y' + str (yr ) + 'M' + str (mo ).zfill (2 ) + 'D' + str (da ).zfill (2 )
1371+ #tit = 'Y' + str(yr) + 'M' + str(mo).zfill(2) + 'D' + str(da).zfill(2)
1372+ tit = '' .join ((str (yr ), str (mo ).zfill (2 ), str (da ).zfill (2 )))
13451373 #tit = str(yr) + str(mo).zfill(2) + str(da).zfill(2)
13461374
13471375 #if 'anim_fig' in locals():
@@ -1380,12 +1408,12 @@ def pcol_2dxy(self, x, y):
13801408 print '--- saving to nc' , C_eddy .savedir
13811409 print '+++'
13821410 if chelton_style_nc : # Recommended
1383- A_eddy .write2chelton_nc (rtime )
1384- C_eddy .write2chelton_nc (rtime )
1411+ A_eddy .write2netcdf (rtime )
1412+ C_eddy .write2netcdf (rtime )
13851413 else :
13861414 A_eddy .write2nc (A_savefile , rtime )
13871415 C_eddy .write2nc (C_savefile , rtime )
1388-
1416+ raise Exception , 'not supported'
13891417 #print 'Saving the eddies', time.time() - saving_start_time, 'seconds'
13901418
13911419 # Running time for a single monthly file
0 commit comments