Changeset 3833
- Timestamp:
- Jul 7, 2025, 1:39:13 PM (14 hours ago)
- Location:
- trunk/LMDZ.PLUTO/util/script_figures
- Files:
-
- 8 added
- 1 deleted
- 21 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.PLUTO/util/script_figures/FV3_utils.py
r3823 r3833 3 3 pi=math.pi 4 4 import matplotlib 5 matplotlib.use(' TKAgg')6 7 name="../Xhistins2015_short" 5 matplotlib.use('Agg') 6 from input import * 7 from display_netcdf import * 8 8 9 9 def fmtsci(x, pos): … … 1201 1201 1202 1202 def printvar(infile): 1203 # Get all variable names for a netCDF file ---1203 '''Get all variable names for a netCDF file ''' 1204 1204 print("Variables:") 1205 1205 variableNames = list(infile.variables.keys()); … … 1208 1208 1209 1209 def getind(myloc,field): 1210 # get a specific index in the lat, lon, time or pfull 1D field1210 '''get a specific index in the lat, lon, time or pfull 1D field''' 1211 1211 res=[] 1212 1212 for loc in np.atleast_1d(myloc): … … 1220 1220 # getinds=np.vectorize(getind, excluded="field") 1221 1221 1222 def getvar(nc1,var,times=None,tim=None,longitudes=None,lon=None,t_mean=False,l_mean=False): 1222 def getvar(nc1,var,times=None,longitudes=None,latitudes=None,altitudes=None,t_mean=False,l_mean=False): 1223 """Get variables from netcdf file and slice it up! 1224 1225 Args: 1226 nc1 : netcdf identifier 1227 var (str): variable name 1228 times (list, optional): times to select. Defaults to None. 1229 longitudes (list, optional): longitudes to select. Defaults to None. 1230 latitudes (list, optional): latitudes to select. Defaults to None. 1231 t_mean (bool, optional): Apply mean on time dimension. Defaults to False. 1232 l_mean (bool, optional): Apply mean on longitude dimension. Defaults to False. 1233 1234 Returns: 1235 array: variable data array 1236 """ 1237 1223 1238 if var == "latitude" and var not in nc1.variables: var="lat" 1224 1239 if var == "longitude" and var not in nc1.variables: var="lon" … … 1227 1242 if var == "phisinit" and var not in nc1.variables: var="phisfi" 1228 1243 1229 myvar = nc1.variables[var][:] 1230 try: 1231 t=getind(times,tim) 1232 if len(t)==2: 1233 myvar = myvar[t[0]:t[1]+1] 1234 else: 1235 myvar = myvar[t] 1236 except: 1237 # print("no time selected") 1238 pass 1239 try: 1240 l=getind(longitudes,lon) 1241 if len(l)==2: 1242 myvar = myvar[...,l[0]:l[1]+1] 1243 else: 1244 myvar = myvar[...,l] 1245 except: 1246 # print("no longitude selected") 1247 pass 1248 if t_mean: myvar=np.mean(myvar,axis=0) # temporal mean 1249 if l_mean: myvar=np.mean(myvar,axis=-1) # longitudinal mean 1244 var_data = nc1.variables[var] 1245 dims = var_data.dimensions 1246 myvar = var_data[:] 1247 1248 if times or longitudes or latitudes: 1249 slicer = [slice(None)] * len(dims) 1250 1251 time_it = (times,TIME_DIMS) 1252 alt_it = (altitudes,ALT_DIMS) 1253 lon_it = (longitudes,LON_DIMS) 1254 lat_it = (latitudes,LAT_DIMS) 1255 1256 # iterate over dimensions to pick indices to select 1257 for values, dim in (time_it, lon_it, lat_it, alt_it): 1258 try: 1259 dim_idx = find_dim_index(dims, dim) 1260 tmp_var = find_coord_var(nc1, dim) 1261 file_values = nc1.variables[tmp_var][:] 1262 i = getind(values, file_values) 1263 print(dim, i) 1264 if len(i)==2: # range of indices 1265 slicer[dim_idx] = slice(min(i),max(i)+1) 1266 else: # specific index 1267 slicer[dim_idx] = i 1268 except: 1269 continue 1270 1271 # slice the variable according to the indices 1272 myvar = myvar[tuple(slicer)] 1273 1274 if l_mean: # longitudinal mean 1275 myvar=np.mean(myvar,axis=find_dim_index(dims, LON_DIMS)) 1276 if t_mean: # temporal mean 1277 myvar=np.mean(myvar,axis=find_dim_index(dims, TIME_DIMS)) 1250 1278 print(np.shape(myvar)) 1251 1279 try: -
trunk/LMDZ.PLUTO/util/script_figures/ch4cloudsection.py
r3823 r3833 23 23 nc1=Dataset(filename1) 24 24 25 lat= nc1.variables["lat"][:]26 lon= nc1.variables["lon"][:]27 alt= nc1.variables["altitude"][:]25 lat=getvar(nc1,"latitude") 26 lon=getvar(nc1,"longitude") 27 alt=getvar(nc1,"altitude") 28 28 print(('alt=',alt)) 29 29 ############################ -
trunk/LMDZ.PLUTO/util/script_figures/ch4vmrsection.py
r3823 r3833 8 8 import matplotlib.colors as mcolors 9 9 from FV3_utils import * 10 from input import * 10 11 11 12 ############################ 12 folder="../"13 filename1=folder+"diagfi_mean_A.nc"14 13 var="ch4_gas" #variable 15 14 tint=[30,32] #Time must be as written in the input file 16 15 xarea="-180,179" 17 16 18 nc1=Dataset( filename1)17 nc1=Dataset(name+"_A.nc") 19 18 20 lat= nc1.variables["lat"][:]21 lon= nc1.variables["lon"][:]22 alt= nc1.variables["altitude"][:]23 tim= nc1.variables["time_counter"][:]19 lat=getvar(nc1,"latitude") 20 lon=getvar(nc1,"longitude") 21 alt=getvar(nc1,"altitude") 22 tim=getvar(nc1,"Time") 24 23 ############################ 25 24 26 # def getvar(filename,var,tint,xarea): 27 # myvar = pp(file=filename,var=var,t=tint,x=xarea,compute="mean").getf() 28 # print((shape(myvar))) 29 # return myvar 30 31 myvar=getvar(nc1,var,tint,tim) 25 myvar=getvar(nc1,var,tint, l_mean=True, t_mean=True) 32 26 myvar=myvar*28/16.*100. 33 27 … … 42 36 xticks=[-90,-60,-30,0,30,60,90] 43 37 #yticks=np.linspace(0,240,9) 44 alt=alt/1000.45 38 46 39 mymin=0.1 -
trunk/LMDZ.PLUTO/util/script_figures/map_alb_ini.py
r3823 r3833 1 1 #! /usr/bin/env python 2 from ppclass import pp3 2 from netCDF4 import Dataset 4 3 from numpy import * … … 10 9 import matplotlib.colors as mcolors 11 10 from mpl_toolkits.basemap import Basemap 11 from FV3_utils import * 12 12 13 13 ############################ 14 filename= "diagfi2015.nc"14 filename=name+".nc" 15 15 nb_dataset=1 #change vect as well 16 tint=[ "0,0.001"] #Time must be as written in the input file16 tint=[0,0.001] #Time must be as written in the input file 17 17 #zint=["0"] #alt in km 18 18 #xarea="-180,179" 19 19 #yarea="-90,90" 20 20 #step=5 #step between each bin 21 var=" albedo" #variable21 var="ALB" #variable 22 22 var2="phisinit" 23 23 ############################ 24 24 25 25 nc=Dataset(filename) 26 lat=nc.variables["lat"][:] 27 lon=nc.variables["lon"][:] 26 lat=getvar(nc,"latitude") 27 lon=getvar(nc,"longitude") 28 tim=getvar(nc,"Time") 28 29 29 myvar = pp(file=filename,var=var,t=tint,compute="mean").getf() # get data to be changed according to selected variable30 myvar2 = pp(file=filename,var=var2,t=tint,compute="mean").getf() # get data to be changed according to selected variable30 myvar = getvar(nc,var,tint,t_mean=True) 31 myvar2 = getvar(nc,var2) 31 32 print(('shape var1 =',shape(myvar))) 32 33 print(('shape lat = ',shape(lat))) … … 90 91 myvar2bis[i,j]=myvar2[i,j-int(vec[1]/2)] 91 92 92 lon=lon+180. 93 if lon[0]<0: 94 lon=lon+180. 93 95 94 96 -
trunk/LMDZ.PLUTO/util/script_figures/mapch4cloud.py
r3823 r3833 26 26 nc2=Dataset(filename2) 27 27 28 lat= nc1.variables["lat"][:]29 lon= nc1.variables["lon"][:]28 lat=getvar(nc1,"latitude") 29 lon=getvar(nc1,"longitude") 30 30 31 31 # altitdue file 2 -
trunk/LMDZ.PLUTO/util/script_figures/mapmeanwinds.py
r3823 r3833 8 8 from matplotlib import ticker 9 9 import matplotlib.colors as colors 10 import datetime11 10 from mpl_toolkits.basemap import Basemap, shiftgrid 12 11 from FV3_utils import * 12 from input import * 13 13 14 ############################15 14 fa='sans-serif' 16 15 hfont = {'fontname':'Arial'} … … 25 24 lvls=np.linspace(37,57,21) 26 25 26 altitude=1 # in km 27 27 28 ### Data 28 name2=name+'.nc'29 # name=name+' _A.nc'30 name=name+'.nc'31 print("Plot "+ name)32 nc1=Dataset( name)33 nc2=Dataset( name2)29 filename1=name+'_A.nc' 30 # name=name+'.nc' 31 filename2=name+'.nc' 32 print("Plot "+filename1) 33 nc1=Dataset(filename1) 34 nc2=Dataset(filename2) 34 35 ts=nc2.variables["temperature"][:,0,:,:] 35 36 # ts=nc2.variables["tsurf"][:,:,:] 36 37 u=nc1.variables["u"][:,:,:,:] 37 38 v=nc1.variables["v"][:,:,:,:] 38 lat= nc1.variables["lat"][:]39 alt= nc1.variables["altitude"][:]40 lon= nc1.variables["lon"][:]39 lat=getvar(nc1,"latitude") 40 alt=getvar(nc1,"altitude") 41 lon=getvar(nc1,"longitude") 41 42 ps=nc2.variables["ps"][:,:] 42 43 # ps=nc2.variables["phisinit"][:,:]/0.6169/1000. # altitude km 43 44 44 numalt=getind(1,alt) 45 # numalt=getind(1000,alt) 45 numalt=getind(altitude,alt) 46 46 print('numalt =',numalt,'altitude=',alt[numalt]) 47 47 u=u[:,numalt,:,:] … … 52 52 ps=np.mean(ps,axis=0) 53 53 54 ts=switchlon(ts) 55 u=switchlon(u) 56 v=switchlon(v) 57 # ps=switchlon(ps) 58 # topo=switchlon(topo) 59 # lon=lon+180. 54 if lon[0]<0: 55 ts=switchlon(ts) 56 u=switchlon(u) 57 v=switchlon(v) 58 ps=switchlon(ps) 59 # topo=switchlon(topo) 60 lon=lon+180. 60 61 61 62 ### Figure … … 96 97 mpl.show() 97 98 98 #######################99 -
trunk/LMDZ.PLUTO/util/script_figures/maptemp.py
r3823 r3833 1 1 #! /usr/bin/env python 2 import os 2 3 from netCDF4 import Dataset 3 4 from numpy import * … … 11 12 from mpl_toolkits.basemap import Basemap, shiftgrid 12 13 from matplotlib.cm import get_cmap 13 from FV3_utils import * # import name 14 from FV3_utils import * 15 from input import * # import name 16 print("Running "+os.path.basename(__file__)) 14 17 15 18 ############################ … … 26 29 27 30 ### Data 28 # name='../diagfi2015.nc' # read from FV3_util29 print(name)30 31 try: 32 print("Plotting "+name+"_A.nc") 31 33 nc1=Dataset(name+"_A.nc") 32 34 except: 35 print("Plotting "+name+".nc") 33 36 nc1=Dataset(name+".nc") 34 alt= nc1.variables["altitude"][:]35 lat= nc1.variables["lat"][:]36 lon= nc1.variables["lon"][:]37 alt=getvar(nc1,"altitude") 38 lat=getvar(nc1,"latitude") 39 lon=getvar(nc1,"longitude") 37 40 # temp=switchlon(temp) 38 lon=lon+180.39 41 40 def plot_alt(altitude = 1000): 42 if lon[0]<0: 43 lon=lon+180. 44 45 def plot_alt(altitude = 1): 41 46 temp=nc1.variables["temperature"][:,:,:,:] 42 47 numalt=getind(altitude,alt) … … 63 68 64 69 mpl.grid() 65 mpl.title(f"Temperatures @ z={altitude /1000}km",fontsize=font)70 mpl.title(f"Temperatures @ z={altitude}km",fontsize=font) 66 71 mpl.ylabel(r'Latitude',labelpad=10,fontsize=font) 67 72 mpl.xlabel('Longitude',labelpad=10, fontsize=font) … … 72 77 mpl.yticks(yticks,fontsize=font) 73 78 mpl.xticks(xticks,fontsize=font) 74 mpl.savefig(f"maptemp{altitude}",bbox_inches='tight',dpi=70) 79 output=f"maptemp{altitude}" 80 mpl.savefig(output,bbox_inches='tight',dpi=70) 81 print(f"Saved {output}") 75 82 #mpl.show() 76 83 77 84 78 plot_alt(1 000)79 plot_alt(5 000)80 plot_alt(20 000)81 plot_alt(50 000)82 plot_alt(100 000)85 plot_alt(1) 86 plot_alt(5) 87 plot_alt(20) 88 plot_alt(50) 89 plot_alt(100) -
trunk/LMDZ.PLUTO/util/script_figures/meanmeridwind.py
r3823 r3833 9 9 import colorsys 10 10 from FV3_utils import * 11 from input import * 11 12 12 13 ############################ … … 63 64 rvb1=diverge_map(h,l) 64 65 65 myvar=getvar(nc1,var,tint, tim,xarea,lon,t_mean=True,l_mean=True)66 myvar=getvar(nc1,var,tint,xarea,lon,t_mean=True,l_mean=True) 66 67 67 68 mpl.figure(figsize=(20, 10)) … … 76 77 xticks=[-90,-60,-30,0,30,60,90] 77 78 #yticks=np.linspace(0,240,9) 78 alt=alt/1000.79 79 80 80 CF=mpl.contourf(lat,alt,myvar,lev,cmap=pal,extend='both') … … 89 89 mpl.clabel(CS, inline=1, fontsize=20, fmt='%1.1f',inline_spacing=1) 90 90 91 #mpl.title('Latitude ='+str(tintstr[i]),fontsize=font)91 mpl.title('Meridional wind (m/s)',fontsize=font) 92 92 mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font) 93 93 mpl.xlabel('Latitude (deg)',labelpad=10, fontsize=font) -
trunk/LMDZ.PLUTO/util/script_figures/meanzonalwind.py
r3823 r3833 9 9 import colorsys 10 10 from FV3_utils import * 11 from input import * 11 12 12 13 ############################ … … 64 65 rvb1=diverge_map(h,l) 65 66 66 myvar=getvar(nc1,var,tint, tim,xarea,lon,t_mean=True,l_mean=True)67 myvar=getvar(nc1,var,tint,xarea,lon,t_mean=True,l_mean=True) 67 68 68 69 mpl.figure(figsize=(20, 10)) … … 77 78 xticks=[-90,-60,-30,0,30,60,90] 78 79 #yticks=np.linspace(0,240,9) 79 alt=alt/1000.80 80 81 81 CF=mpl.contourf(lat,alt,myvar,lev,cmap=pal,extend='both') … … 90 90 mpl.clabel(CS, inline=1, fontsize=20, fmt='%1.0f',inline_spacing=1) 91 91 92 #mpl.title('Latitude ='+str(tintstr[i]),fontsize=font)92 mpl.title('Zonal wind (m/s)',fontsize=font) 93 93 mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font) 94 94 mpl.xlabel('Latitude (deg)',labelpad=10, fontsize=font) -
trunk/LMDZ.PLUTO/util/script_figures/meanzonalwind_zoom.py
r3823 r3833 18 18 nc1=Dataset(filename1) 19 19 20 lat= nc1.variables["lat"][:]21 lon= nc1.variables["lon"][:]22 alt= nc1.variables["altitude"][:]20 lat=getvar(nc1,"latitude") 21 lon=getvar(nc1,"longitude") 22 alt=getvar(nc1,"altitude") 23 23 ############################ 24 24 -
trunk/LMDZ.PLUTO/util/script_figures/movie_vmr_ch4/FV3_utils.py
r3832 r3833 3 3 pi=math.pi 4 4 import matplotlib 5 matplotlib.use('TKAgg') 6 7 name="../Xhistins2015_short" 5 matplotlib.use('Agg') 8 6 9 7 def fmtsci(x, pos): -
trunk/LMDZ.PLUTO/util/script_figures/movie_vmr_ch4/vmr_ch4.py
r3832 r3833 10 10 import datetime 11 11 from mpl_toolkits.basemap import Basemap, shiftgrid 12 from FV3_utils import * 12 from FV3_utils import * # import name 13 from input import * # import 'name' 13 14 14 15 ############################ 15 # basename="../../Xhistins2072" 16 filename1="../"+name+"_A.nc" 16 filename1="../"+name+"_A.nc" # define name in input.py 17 17 filename2="../"+name+".nc" 18 filename3="../../phisinit.nc" 19 var="tsurf" #variable 20 phisinit="phisinit" #variable 18 var="vmr_ch4" 19 var2="phisinit" #variable 21 20 vari="u" 22 21 varj="v" 23 tint=[30,32] #Time must be as written in the input file 22 font=26 23 tint=[30,31] #Time must be as written in the input file 24 24 #tintstr=["03:00","09:00","15:00","21:00"] #Time must be as written in the input file 25 25 26 font=26 26 # altitude in km 27 altitude=1 27 28 28 29 nc1=Dataset(filename1) 29 30 nc2=Dataset(filename2) 30 nc3=Dataset(filename3)31 31 32 32 lat=getvar(nc1,"latitude") … … 35 35 tim=getvar(nc1,"Time") 36 36 ############################ 37 38 def swinglon(myvar): 39 # changer les longitudes pour mettre TR au centre 40 vec=shape(myvar) 41 myvarbis=np.zeros(vec,dtype='f') 42 # i lat : pas de changement 43 # j lon : 44 for i in range(vec[0]): 45 for j in range(vec[1]): 46 if j < int(vec[1]/2.) : 47 myvarbis[i,j]=myvar[i,j+int(vec[1]/2.)] 48 # myvar2bis[i,j]=myvar2[i,j+int(vec[1]/2)] 49 else: 50 myvarbis[i,j]=myvar[i,j-int(vec[1]/2.)] 51 # myvar2bis[i,j]=myvar2[i,j-int(vec[1]/2)] 52 return myvarbis 37 53 38 54 def getwinds(lon,lat,vecx,vecy): … … 44 60 color='black' # arrow color 45 61 pivot='mid' # arrow around middle of box. Alternative : tip 46 scale= 100 # scale arrow : plus grand = fleche plus petite62 scale=200 # scale arrow : plus grand = fleche plus petite 47 63 width=0.002 # width arrow 48 linewidths=0. 5# epaisseur contour arrow64 linewidths=0.1 # epaisseur contour arrow 49 65 edgecolors='k' # couleur contour arrow 50 66 … … 86 102 def getfigvar(i): 87 103 pal=get_cmap(name="jet") 88 lev=np.linspace(37,51,15) 89 # newlon=lon+180 90 newlon=lon 104 lev=np.linspace(0.2,0.8,50) 105 newlon=lon+180 91 106 CF=mpl.contourf(newlon, lat, myvarbis,lev,cmap=pal,extend='both') 92 107 yticks=[-90,-60,-30,0,30,60,90] 93 108 xticks=[0,60,120,180,240,300,360] 94 cbar=mpl.colorbar(CF,shrink=1, format="%1. 0f")95 cbar.ax.set_title(" Tsurf [K]",y=1.04,fontsize=font)109 cbar=mpl.colorbar(CF,shrink=1, format="%1.2f") 110 cbar.ax.set_title("VMR CH4 [%]",y=1.04,fontsize=font) 96 111 97 112 for t in cbar.ax.get_yticklabels(): 98 113 t.set_fontsize(font) 99 114 100 c=mpl.contour(newlon, lat, phisinit2bis, 10,levels=np.linspace(-4,4,8), colors = 'k', linewidths = 3.5)115 c=mpl.contour(newlon, lat, myvar2bis, 10,levels=np.linspace(-4,4,8), colors = 'k', linewidths = 3.5) 101 116 mpl.clabel(c, fmt='%2.1f',inline=1, colors='k', fontsize=23,inline_spacing=1) 102 117 #mpl.title('Local Time at Sputnik Planum='+str(i*3)+'H00',fontsize=font) … … 105 120 mpl.xticks(xticks,fontsize=font) 106 121 mpl.yticks(yticks,fontsize=font) 107 getwinds(newlon,lat,u,v)122 #getwinds(newlon,lat,u,v) 108 123 109 #def getnumalt(choicealt,alt):110 #numalt=np.where(abs(alt-choicealt)==min(abs(alt-choicealt)))111 #numalt=numalt[0][0]112 #return numalt124 def getnumalt(choicealt,alt): 125 numalt=np.where(abs(alt-choicealt)==min(abs(alt-choicealt))) 126 numalt=numalt[0][0] 127 return numalt 113 128 114 129 ####################### 115 # numalt=getnumalt(30,alt) 116 numalt=np.searchsorted(alt[...],30) 130 numalt=getnumalt(altitude,alt) 117 131 print(('numalt =',numalt,'altitude=',alt[numalt])) 118 132 uini=getvar(nc1,vari,tint,tim)[:,numalt] 119 133 vini=getvar(nc1,varj,tint,tim)[:,numalt] 120 134 myvar=getvar(nc2,var,tint,tim) 121 phisinit2=getvar(nc3,phisinit) # phisinitmyvar2=phisinit2/0.6169/1000. # altitude km 135 myvar2=getvar(nc2,var2) # phisinit 136 myvar2=myvar2/0.6169/1000. # altitude km 122 137 nbfig=uini.shape[0] 123 138 print(("nbfig=",nbfig)) 124 phisinit2bis=np.copy(phisinit2)139 myvar2bis=swinglon(myvar2) 125 140 126 141 for i in range(nbfig): … … 129 144 v2=vini[i,:,:] 130 145 myv=myvar[i,:,:] 131 u= np.copy(u2)132 v= np.copy(v2)133 myvarbis= np.copy(myv)134 print(i )146 u=swinglon(u2) 147 v=swinglon(v2) 148 myvarbis=swinglon(myv) 149 print(i,"/",nbfig) 135 150 getfigvar(i) 136 151 mpl.savefig('mapwinds'+str('{0:03}'.format(i))+'.eps',dpi=200) … … 146 161 #mpl.subplots_adjust(hspace = .1) 147 162 163 148 164 #mpl.show() 149 165 -
trunk/LMDZ.PLUTO/util/script_figures/movie_winds/tsurf_winds.py
r3823 r3833 16 16 filename1="../"+name+"_A.nc" 17 17 filename2="../"+name+".nc" 18 filename3="../../phisinit.nc" 18 filename3="../"+name+".nc" 19 # filename3="../../phisinit.nc" 19 20 var="tsurf" #variable 20 21 phisinit="phisinit" #variable … … 87 88 pal=get_cmap(name="jet") 88 89 lev=np.linspace(37,51,15) 89 # newlon=lon+180 90 newlon=lon 90 newlon=lon+180 91 91 CF=mpl.contourf(newlon, lat, myvarbis,lev,cmap=pal,extend='both') 92 92 yticks=[-90,-60,-30,0,30,60,90] … … 98 98 t.set_fontsize(font) 99 99 100 c=mpl.contour(newlon, lat, phisinit2bis, 10,levels=np.linspace(-4,4,8), colors = 'k', linewidths = 3.5)100 c=mpl.contour(newlon, lat, myvar2bis, 10,levels=np.linspace(-4,4,8), colors = 'k', linewidths = 3.5) 101 101 mpl.clabel(c, fmt='%2.1f',inline=1, colors='k', fontsize=23,inline_spacing=1) 102 102 #mpl.title('Local Time at Sputnik Planum='+str(i*3)+'H00',fontsize=font) … … 107 107 getwinds(newlon,lat,u,v) 108 108 109 #def getnumalt(choicealt,alt):110 #numalt=np.where(abs(alt-choicealt)==min(abs(alt-choicealt)))111 #numalt=numalt[0][0]112 #return numalt109 def getnumalt(choicealt,alt): 110 numalt=np.where(abs(alt-choicealt)==min(abs(alt-choicealt))) 111 numalt=numalt[0][0] 112 return numalt 113 113 114 114 ####################### 115 # numalt=getnumalt(30,alt) 116 numalt=np.searchsorted(alt[...],30) 115 numalt=getnumalt(30,alt) 117 116 print(('numalt =',numalt,'altitude=',alt[numalt])) 118 117 uini=getvar(nc1,vari,tint,tim)[:,numalt] 119 118 vini=getvar(nc1,varj,tint,tim)[:,numalt] 120 119 myvar=getvar(nc2,var,tint,tim) 121 phisinit2=getvar(nc3,phisinit) # phisinitmyvar2=phisinit2/0.6169/1000. # altitude km120 myvar2=getvar(nc3,phisinit) # phisinitmyvar2=myvar2/0.6169/1000. # altitude km 122 121 nbfig=uini.shape[0] 123 122 print(("nbfig=",nbfig)) 124 phisinit2bis=np.copy(phisinit2)123 myvar2bis=switchlon(myvar2) 125 124 126 125 for i in range(nbfig): … … 129 128 v2=vini[i,:,:] 130 129 myv=myvar[i,:,:] 131 u= np.copy(u2)132 v= np.copy(v2)133 myvarbis= np.copy(myv)134 print(i )130 u=switchlon(u2) 131 v=switchlon(v2) 132 myvarbis=switchlon(myv) 133 print(i,"/",nbfig) 135 134 getfigvar(i) 136 135 mpl.savefig('mapwinds'+str('{0:03}'.format(i))+'.eps',dpi=200) -
trunk/LMDZ.PLUTO/util/script_figures/proftempNH.py
r3823 r3833 1 1 #! /usr/bin/env python 2 from ppclass import pp3 2 from netCDF4 import Dataset 4 3 from numpy import * … … 11 10 import datetime 12 11 from mpl_toolkits.basemap import Basemap, shiftgrid 12 from FV3_utils import * 13 13 14 14 ############################ 15 zefile="diagfi2015_A.nc"16 d1="restart_ref/"17 18 f1=d1+zefile19 20 21 15 var="temperature" #variable 22 16 23 nc1=Dataset( f1)24 lat= nc1.variables["lat"][:]25 lon= nc1.variables["lon"][:]26 alt= nc1.variables["altitude"][:]27 tim= nc1.variables["time_counter"][:]17 nc1=Dataset(name+"_A.nc") 18 lat=getvar(nc1,"latitude") 19 lon=getvar(nc1,"longitude") 20 alt=getvar(nc1,"altitude") 21 tim=getvar(nc1,"Time") 28 22 29 23 print(('Time = ',tim)) … … 43 37 print(('Point =',p,' Time=',tim[indt1])) 44 38 return indt1 45 46 def getvar(filename,var):47 myvar = pp(file=filename,var=var,compute="nothing").getf()48 return myvar49 39 50 40 def getindex(lat,lon,mylat,mylon): … … 57 47 indt=findindextime(tini,lt0,ltchoice,p) 58 48 indlat,indlon=getindex(lat,lon,p[1],p[0]) 59 myvar=getvar( f1,var)[indt,:,indlat,indlon]49 myvar=getvar(nc1,var)[indt,:,indlat,indlon] 60 50 return myvar 61 51 ############################ … … 92 82 font=23 93 83 94 alt=alt/1000.95 96 84 mpl.plot(myvar1,alt,'r',label='Entry') 97 85 mpl.plot(myvar2,alt,'g',label='Entry-like on edge') -
trunk/LMDZ.PLUTO/util/script_figures/proftempNH_SP.py
r3823 r3833 17 17 18 18 nc1=Dataset(filename1) 19 lat= nc1.variables["lat"][:]20 lon= nc1.variables["lon"][:]21 alt= nc1.variables["altitude"][:]22 tim= nc1.variables["time_counter"][:]19 lat=getvar(nc1,"latitude") 20 lon=getvar(nc1,"longitude") 21 alt=getvar(nc1,"altitude") 22 tim=getvar(nc1,"Time") 23 23 24 24 print(('Time = ',tim)) -
trunk/LMDZ.PLUTO/util/script_figures/proftempNH_obs.py
r3823 r3833 22 22 23 23 nc1=Dataset(f1) 24 lat= nc1.variables["lat"][:]25 lon= nc1.variables["lon"][:]26 alt= nc1.variables["altitude"][:]27 tim= nc1.variables["time_counter"][:]24 lat=getvar(nc1,"latitude") 25 lon=getvar(nc1,"longitude") 26 alt=getvar(nc1,"altitude") 27 tim=getvar(nc1,"Time") 28 28 29 29 print(('Time = ',tim)) -
trunk/LMDZ.PLUTO/util/script_figures/temp_section.py
r3823 r3833 12 12 from mpl_toolkits.basemap import Basemap, shiftgrid 13 13 from FV3_utils import * 14 matplotlib.use('TKAgg') 14 from input import * 15 15 16 16 ############################ … … 33 33 mpl.figure(figsize=(20, 10)) 34 34 35 myvar=getvar(nc1,var,tint, tim,l_mean=True,t_mean=True)35 myvar=getvar(nc1,var,tint,l_mean=True,t_mean=True) 36 36 font=26 37 37 -
trunk/LMDZ.PLUTO/util/script_figures/temp_time_zoom.py
r3823 r3833 1 1 #! /usr/bin/env python 2 from ppclass import pp3 2 from netCDF4 import Dataset 4 3 from numpy import * … … 11 10 import datetime 12 11 from mpl_toolkits.basemap import Basemap, shiftgrid 12 from FV3_utils import * 13 13 14 14 ############################ 15 filename1= "diagfi2015_S.nc"15 filename1=name+"_S.nc" 16 16 var="temperature" #variable 17 xarea="-169,-165" 18 yarea="-19,-15" 17 longitude=[-169,-165] 18 # longitude=-165 19 latitude=[-19,-15] 20 # latitude=-19 19 21 20 22 # local time de la longitude consideree a t=0 21 23 loct=12 22 sol0= 3024 sol0=12 23 25 t0=1./24*loct 24 t1=t0+1 25 tint=[s tr(sol0+t0)+','+str(sol0+t1)] #Time must be as written in the input file26 t1=t0+12 27 tint=[sol0+t0,sol0+t1] #Time must be as written in the input file 26 28 print(tint) 27 29 nc1=Dataset(filename1) 28 30 29 lat=nc1.variables["lat"][:] 30 lon=nc1.variables["lon"][:] 31 alt=nc1.variables["altitude"][:] 31 lat=getvar(nc1,"latitude") 32 lon=getvar(nc1,"longitude") 33 alt=getvar(nc1,"altitude") 34 tim=getvar(nc1,"Time",times=tint) 32 35 ############################ 33 34 def getvar(filename,var,tint,xarea,yarea):35 myvar = pp(file=filename,var=var,t=tint,x=xarea,y=yarea,compute="nothing").getf()36 print(('shape myvar = ',shape(myvar)))37 return myvar38 39 36 40 37 mpl.figure(figsize=(18, 10)) 41 38 42 43 myvar=getvar(filename1,var,tint,xarea,yarea)[:,:,0,0] 39 myvar=getvar(nc1,var,times=tint,longitudes=longitude,latitudes=latitude)[:,:,0,0] 44 40 font=23 45 tim=np.linspace(0,24,9)41 # tim=np.linspace(0,24,9) 46 42 print(("tim=",tim)) 47 43 print(('on prend les premiers indice, shape (tmps, alt, var) =',shape(tim), shape(alt), shape(myvar))) … … 49 45 pal=get_cmap(name="Spectral_r") 50 46 lev=np.linspace(40,50,10) 51 xticks=[0,2,4,6,8,10,12,14,16,18,20,22,24]47 # xticks=[0,2,4,6,8,10,12,14,16,18,20,22,24] 52 48 print(('hello:',np.linspace(0,24,13))) 53 49 #yticks=np.linspace(0,240,9) 54 alt=alt/1000.55 50 56 51 … … 72 67 mpl.xlabel('Local Time (h)',labelpad=10,fontsize=font) 73 68 mpl.ylabel('Altitude (km)',labelpad=10, fontsize=font) 74 mpl.xticks(xticks,fontsize=font)75 #mpl.xticks(fontsize=font)69 # mpl.xticks(xticks,fontsize=font) 70 mpl.xticks(fontsize=font) 76 71 #mpl.yticks(yticks,fontsize=font) 77 72 mpl.yticks(fontsize=font) -
trunk/LMDZ.PLUTO/util/script_figures/temp_time_zoom_1.py
r3823 r3833 23 23 24 24 nc1=Dataset(f1) 25 lat= nc1.variables["lat"][:]26 lon= nc1.variables["lon"][:]27 alt= nc1.variables["altitude"][:]28 tim= nc1.variables["time_counter"][:]25 lat=getvar(nc1,"latitude") 26 lon=getvar(nc1,"longitude") 27 alt=getvar(nc1,"altitude") 28 tim=getvar(nc1,"Time") 29 29 30 30 def findindextime(tini,lt0,lt1,p): -
trunk/LMDZ.PLUTO/util/script_figures/temp_time_zoom_2.py
r3823 r3833 23 23 24 24 nc1=Dataset(f1) 25 lat= nc1.variables["lat"][:]26 lon= nc1.variables["lon"][:]27 alt= nc1.variables["altitude"][:]28 tim= nc1.variables["time_counter"][:]25 lat=getvar(nc1,"latitude") 26 lon=getvar(nc1,"longitude") 27 alt=getvar(nc1,"altitude") 28 tim=getvar(nc1,"Time") 29 29 30 30 def findindextime(tini,lt0,lt1,p): -
trunk/LMDZ.PLUTO/util/script_figures/temp_time_zoom_3.py
r3823 r3833 23 23 24 24 nc1=Dataset(f1) 25 lat= nc1.variables["lat"][:]26 lon= nc1.variables["lon"][:]27 alt= nc1.variables["altitude"][:]28 tim= nc1.variables["time_counter"][:]25 lat=getvar(nc1,"latitude") 26 lon=getvar(nc1,"longitude") 27 alt=getvar(nc1,"altitude") 28 tim=getvar(nc1,"Time") 29 29 30 30 def findindextime(tini,lt0,lt1,p): -
trunk/LMDZ.PLUTO/util/script_figures/temp_time_zoom_ref.py
r3823 r3833 23 23 24 24 nc1=Dataset(f1) 25 lat= nc1.variables["lat"][:]26 lon= nc1.variables["lon"][:]27 alt= nc1.variables["altitude"][:]28 tim= nc1.variables["time_counter"][:]25 lat=getvar(nc1,"latitude") 26 lon=getvar(nc1,"longitude") 27 alt=getvar(nc1,"altitude") 28 tim=getvar(nc1,"Time") 29 29 30 30 def findindextime(tini,lt0,lt1,p): -
trunk/LMDZ.PLUTO/util/script_figures/tempglobmean.py
r3823 r3833 11 11 from mpl_toolkits.basemap import Basemap, shiftgrid 12 12 from FV3_utils import * 13 from input import * 13 14 14 15 ############################ … … 52 53 mpl.figure(figsize=(8, 10)) 53 54 54 myvar=getvar(nc1,var,tint,t im,t_mean=True)55 #myvar2=getvar(nc1,var,tint ,tim)55 myvar=getvar(nc1,var,tint,t_mean=True) 56 #myvar2=getvar(nc1,var,tint) 56 57 aire = getvar(nc2,"aire") 57 58 totarea=zetotarea(aire) … … 70 71 #mpl.plot(meantemp2,alt2,'b--') 71 72 72 #mpl.title('Latitude ='+str(tintstr[i]),fontsize=font)73 mpl.title('Global mean temperature',fontsize=font) 73 74 mpl.ylabel('Altitude (km)',labelpad=10,fontsize=font) 74 75 mpl.xlabel('Temperature (K)',labelpad=10, fontsize=font) … … 78 79 mpl.yticks(fontsize=font) 79 80 mpl.grid() 80 mpl.legend(["Ref","Alt"],prop={'size':27},loc='upper left')81 # mpl.legend(["Ref","Alt"],prop={'size':27},loc='upper left') 81 82 82 83 left = 0.2 # the left side of the subplots of the figure
Note: See TracChangeset
for help on using the changeset viewer.