31
31
===========================================================================
32
32
"""
33
33
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
+
34
47
35
48
import glob as glob
36
49
#import matplotlib.pyplot as plt
@@ -114,6 +127,7 @@ def kdt(lon, lat, limits, k=4):
114
127
return iind , jind
115
128
116
129
if 'AvisoGrid' in self .__class__ .__name__ :
130
+
117
131
if self .zero_crossing is True :
118
132
'''
119
133
Used for a zero crossing, e.g., across Agulhas region
@@ -135,6 +149,7 @@ def half_limits(lon, lat):
135
149
limits = half_limits (lon , lat )
136
150
iind , jind = kdt (self ._lon , self ._lat , limits )
137
151
self .i0 = iind .max ()
152
+
138
153
return self
139
154
140
155
@@ -395,10 +410,19 @@ def get_geostrophic_velocity(self, zeta):
395
410
surface from variables f, zeta, pm, pn...
396
411
Note: output at rho points
397
412
'''
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]))
402
426
return self
403
427
404
428
@@ -424,15 +448,17 @@ def getEKE(self):
424
448
'''
425
449
self .u [:] = self .upad [self .jup0 :self .jup1 , self .iup0 :self .iup1 ]
426
450
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
429
455
return self
430
456
431
457
432
458
433
459
class AvisoGrid (PyEddyTracker ):
434
460
'''
435
- Class to satisfy the need of the ROMS eddy tracker
461
+ Class to satisfy the need of the eddy tracker
436
462
to have a grid class
437
463
'''
438
464
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):
705
731
#the_domain = 'MedSea' # not yet implemented
706
732
707
733
# Specify use of new AVISO 2014 data
708
- new_AVISO = True
734
+ new_AVISO = False
709
735
710
736
# Specify subsampling new AVISO 2014 data; i.e. you may
711
737
# prefer to use every second day rather than every day
@@ -730,8 +756,8 @@ def pcol_2dxy(self, x, y):
730
756
directory = '/marula/emason/data/altimetry/global/delayed-time/grids/msla/two-sat-merged/h/'
731
757
AVISO_files = 'dt_global_twosat_msla_h_????????_20140106.nc'
732
758
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/'
735
761
AVISO_files = 'dt_ref_global_merged_msla_h_qd_????????_*.nc'
736
762
737
763
elif 'MedSea' in the_domain :
@@ -754,20 +780,21 @@ def pcol_2dxy(self, x, y):
754
780
# Set date range (YYYYMMDD)
755
781
#date_str, date_end = 19980107, 19991110 #
756
782
#date_str, date_end = 20081107, 20100110 #
757
- date_str , date_end = 19930101 , 20121231 #
783
+ date_str , date_end = 19921014 , 20120718 #
758
784
759
785
# 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'
762
788
763
789
764
790
# Path to directory where outputs are to be saved...
765
791
#savedir = directory
766
792
#savedir = '/marula/emason/aviso_eddy_tracking/pablo_exp/'
767
793
#savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/'
768
794
#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/'
770
796
#savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/BlackSea/'
797
+ savedir = '/marula/emason/aviso_eddy_tracking/Corridor_V3_Dec2014/'
771
798
#savedir = '/path/to/save/your/outputs/'
772
799
773
800
@@ -810,8 +837,8 @@ def pcol_2dxy(self, x, y):
810
837
811
838
# Set SLA contour spacing
812
839
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
815
842
816
843
817
844
@@ -844,10 +871,10 @@ def pcol_2dxy(self, x, y):
844
871
#latmin = -35.
845
872
#latmax = -10.
846
873
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
851
878
852
879
#lonmin = -179. # SEP
853
880
#lonmax = -65
@@ -938,7 +965,7 @@ def pcol_2dxy(self, x, y):
938
965
939
966
# Use this for subsampling to get identical list as old_AVISO
940
967
#AVISO_files = AVISO_files[5:-5:7]
941
- if new_AVISO_SUBSAMP :
968
+ if new_AVISO and new_AVISO_SUBSAMP :
942
969
AVISO_files = AVISO_files [5 :- 5 :np .int (days_btwn_recs )]
943
970
944
971
# Set up a grid object using first AVISO file in the list
@@ -1341,7 +1368,8 @@ def pcol_2dxy(self, x, y):
1341
1368
1342
1369
if anim_figs : # Make figures for animations
1343
1370
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 )))
1345
1373
#tit = str(yr) + str(mo).zfill(2) + str(da).zfill(2)
1346
1374
1347
1375
#if 'anim_fig' in locals():
@@ -1380,12 +1408,12 @@ def pcol_2dxy(self, x, y):
1380
1408
print '--- saving to nc' , C_eddy .savedir
1381
1409
print '+++'
1382
1410
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 )
1385
1413
else :
1386
1414
A_eddy .write2nc (A_savefile , rtime )
1387
1415
C_eddy .write2nc (C_savefile , rtime )
1388
-
1416
+ raise Exception , 'not supported'
1389
1417
#print 'Saving the eddies', time.time() - saving_start_time, 'seconds'
1390
1418
1391
1419
# Running time for a single monthly file
0 commit comments