import cdms2 from vacumm.config import data_sample from vacumm.diag.thermdyn import mixed_layer_depth from vacumm.misc.plot import map2 from vacumm.data.misc.sigma import NcSigma from vacumm.misc.grid import curv2rect # Read temperature print 'Read' ncfile = data_sample(ncfile) f = cdms2.open(ncfile) temp = curv2rect(f('TEMP'))(lon=lon, lat=lat, squeeze=1) # Compute depth print 'depth' s = NcSigma.factory(f) depth = curv2rect(s())(lon=lon, lat=lat, squeeze=1) f.close() # Compute MLD print 'mld' print temp.shape, depth.shape mld = mixed_layer_depth(temp, depth, mode='deltatemp', deltatemp=0.1) # Plot print 'plot' map2(mld, proj='merc', figsize=(6, 4), autoresize=0, fill='pcolormesh', contour=False, show=False, colorbar_shrink=0.7, right=1, savefigs=__file__)
import cdms2 from vacumm.config import data_sample from vacumm.diag.thermdyn import mixed_layer_depth from vacumm.misc.plot import map2 from vacumm.data.misc.sigma import NcSigma from vacumm.misc.grid import curv2rect # Read temperature print 'Read' ncfile = data_sample(ncfile) f = cdms2.open(ncfile) temp = curv2rect(f('TEMP'))(lon=lon, lat=lat, squeeze=1) # Compute depth print 'depth' s = NcSigma.factory(f) depth = curv2rect(s())(lon=lon, lat=lat, squeeze=1) f.close() # Compute MLD print 'mld' print temp.shape, depth.shape mld = mixed_layer_depth(temp, depth, mode='deltatemp', deltatemp=0.1) # Plot print 'plot' map2(mld, proj='merc', figsize=(6, 4), autoresize=0, fill='pcolormesh', contour=False, show=False, colorbar_shrink=0.7, right=1, savefigs=__file__, close=True)
time_format = "%Y%m%d" date = strftime(time_format) print "Begin : " + strftime(print_time_format) # Profondeurs sur lesquelles nous souhaitons interpoler (en m) depths = np.array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 22,24,26,28,30,32,34,36,38,40,45,50,55,60,65,70,75,80,85,90,95,100,120,140,160]) depths = -depths[::-1] # croissantes et négatives # Lecture de la température f = cdms2.open(data_sample('mars3d.tsigyx.nc')) data_in = f('TEMP') # T-YX (- = level) # Détermination des profondeurs d'après les sigma # - détection auto de la classe de sigma d'après fichier sigma_class = NcSigma.factory(f) # - initialisation du convertisseur sigma_converter = sigma_class(copyaxes=True) # - lecture de eta (sans sélection de domaine) et calcul des profondeurs depths_in = sigma_converter().filled() f.close() # Creation de l'axe des profondeurs cibles depth_out = create_depth(depths) # Interpolation xmap = (0, 2, 3) # la profondeur varie en T/Y/X xmapper = np.rollaxis(depths_in, 1, 4) # profondeur = dernier axe data_out = regrid1d(data_in, depth_out, axi=depths_in, axis=1, method='linear', extrap=1) # Plot