def fsizewind(namefile): # load data data = np.loadtxt(namefile+"_1.txt",delimiter=";") s = data[:,1] ; v = data[:,5] # plot drop = f(size) restrict = (s > 0) dropl = ppplot.plot1d() ; dropl.f = v[restrict] ; dropl.x = s[restrict] dropl.linestyle,dropl.marker,dropl.color,dropl.fmt = '','.','r',"%.1f" dropl.xlabel = "Vortex size (m)" ; dropl.ylabel = r"Friction velocity (m s$^{-1}$)" #dropl.logx= True ; dropl.logy = True dropl.makeshow()
def fdropsize(namefile): # load data data = np.loadtxt(namefile+"_1.txt",delimiter=";") s = data[:,1] ; d = data[:,2] # plot drop = f(size) restrict = (s > 0) dropl = ppplot.plot1d() ; dropl.f = d[restrict] ; dropl.x = s[restrict] dropl.linestyle,dropl.marker,dropl.color,dropl.fmt = '','.','r',"%.1f" dropl.xlabel = "Vortex size (m)" ; dropl.ylabel = "Pressure drop (Pa)" #dropl.logx= True ; dropl.logy = True dropl.makeshow()
url = "https://raw.githubusercontent.com/aymeric-spiga/planetoplot/master/examples/ppplot/sounding.txt" sounding = urllib.urlopen(url).read() soundingfile = open('sounding.txt', 'w').write(sounding) # and loaded using `numpy.loadtxt()` # In[23]: press, z_alt, temp, dew, hum, mix, wdir, wknot, thta, thte, thtv = np.loadtxt( "sounding.txt", skiprows=8, unpack=True) # before the variables can be easily displayed using `ppplot` through a one-line instruction # In[24]: ppplot.plot1d(f=temp).makeshow() # A more elaborate plot can be obtained as well by setting more attributes for the `plot1d` class object # In[25]: sd = ppplot.plot1d() sd.f = z_alt sd.x = temp sd.linestyle = '-' sd.marker = '.' sd.color = 'r' sd.ycoeff = 1.e-3 sd.title = "A random terrestrial sounding" sd.legend = "Fort Smith 00Z 26 Sep 2013" sd.xlabel = "Temperature ($^{\circ}$C)"
lat = data[:, 0] lon = data[:, 1] ls = data[:, 2] u = data[:, 3:15] data = np.loadtxt("v.txt") v = data[:, 3:15] # computations wind = u**2 + v**2 wind = np.sqrt(wind) # get evolution over season ind = np.where(lon == dalon) # make a simple plot pl = ppplot.plot1d() pl.x = range(0, 360, 30) pl.xlabel = "L$_s$ ($^{\circ}$)" pl.ylabel = "Wind speed (m s$^{-1}$)" pl.out = "png" pl.filename = "lsdune" pl.f = u[ind][:, dalt] pl.legend = "WE component" pl.make() pl.f = v[ind][:, dalt] pl.legend = "SN component" pl.make() pl.f = wind[ind][:, dalt]
#! /usr/bin/env python from ppclass import pp import planets import ppplot fi = "DRAG90days_DISSIP10000_year7_912791376_512_z5" u,lon,lat,p,t = pp(file=fi+".nc",var="u",t=0,z=0,x="-180,180").getfd() # index = acosphi*((omega*acosphi)+u) / (omega*a*a) sindex = planets.Saturn.superrot(u=u,lat=lat) pl = ppplot.plot1d() pl.f = sindex*1000. pl.x = lat pl.ylabel = r'Local superrotation index $s = \mathcal{M}_u / \Omega a^2$ ($\times 10^{-3}$)' pl.xmin = -10. pl.xmax = 10. pl.fmt = '%.0f' pl.ymin = -30. pl.ymax = 10. pl.marker = '' pl.xlabel = "Latitude (deg)" pl.make() ppplot.save(mode="png",filename=fi+"_superrot")
req.changetime = "mars_dayini" #prof,xx,yy,zz,tt = req.getfd() ### MCD z,tpot,q,u,v = np.loadtxt("input_sounding",skiprows=1,unpack=True) r,cp,p,rho,t = np.loadtxt("input_therm",unpack=True) hgt,tsurf = np.loadtxt("input_more",unpack=True) q = 0.001*q ### PLOT nnn=60 dd=10 ppplot.rainbow(cb="jet",num=1+(nnn/dd)) sdg = ppplot.plot1d() sdg.f = z-hgt sdg.x = q sdg.x = t sdg.legend = 'mcd' sdg.marker = 's' sdg.color = 'w' sdg.make() nnn=60 dd=10 ppplot.rainbow(cb="jet",num=nnn/dd) ppp = ppplot.plot1d() ppp.marker = '.'
r.xmin = -90. r.xmax = 90. r.colorbar = "spectral" r.fmt = "%.0f" r.swaplab = False r.xlabel = "Latitude ($^{\circ}$N)" r.ylabel = "Pressure (Pa)" r.units = "m s$^{-1}$" r.make() ppplot.save(mode="png",filename="section",includedate=False) ppplot.close() ################################### ppplot.figuref(x=12,y=8) ## r = ppplot.plot1d() r.f = gmcbwind r.x = gmcblat r.marker = '.' r.linestyle = '' r.color = 'p' r.legend = "Cassini ISS CB (GM11)" r.make() ## r = ppplot.plot1d() r.f = gmmtwind r.x = gmmtlat r.marker = '.' r.linestyle = '' r.color = 'm' r.legend = "Cassini ISS MT (GM11)"
dtlwr = pp(file=zefile,t=ttt,x=lon,y=lat,var="dtlwr").getf() dtswr = pp(file=zefile,t=ttt,x=lon,y=lat,var="dtswr").getf() geop = pp(file=zefile,t=ttt,x=lon,y=lat,var="geop").getf() ### COMPUTATIONS refpres = pres[0] ; surftpot = temp[0] ; surfh = 0. ### -- tpot tpot = temp*(refpres/pres)**(Venus.R()/Venus.cp) ### -- alt #alt = Venus.H(T0=temp)*np.log(refpres/pres) alt = geop / Venus.g ### -- rho rho = pres / Venus.R() / temp ### CHECK WITH A PLOT pl = ppplot.plot1d(f=alt,x=tpot).makeshow() pl = ppplot.plot1d(f=alt,x=rho).makeshow() pl = ppplot.plot1d(f=alt,x=temp).makeshow() ### OPEN FILES TO BE WRITTEN sounding = open("input_sounding", "w") additional = open("input_therm", "w") more = open("input_more", "w") hr = open("input_hr", "w") ### GET and WRITE SURFACE VALUES sounding.write( "%10.2f%12.2f%12.2f\n" % (refpres/100.,surftpot,0.) ) more.write( "%10.2f%10.2f" % (surfh,surftpot) ) ### GET and WRITE VERTICAL PROFILE nz = len(pres)
wheremin = np.argmin(diff) + 8 pblh3[indt] = np.mean(geop[tt,wheremin,:,:]) / grav ## sometimes spurious values caused by GW diff = 100.*np.abs(pblh3[indt]-pblh1[indt])/pblh1[indt] if diff > 33.: pblh3[indt] = pblh1[indt] pblh[indt] = np.mean([pblh1[indt],pblh2[indt],pblh3[indt]]) ## remove small or negative values pblh = pblh[pblh > 100.] ## compute mean height altitude = np.mean(np.mean(np.mean(geop,axis=3),axis=2),axis=0)/grav altitude = altitude[0:nz] file1=open('pbl.txt','w') for val in pblh: file1.write("%8.3f\n"%(val)) file1.close() pl = ppplot.plot1d() # plot of the boundary layer height time evolution pl.f = pblh pl.makeshow() pl = ppplot.plot2d() # shade of the vertical eddy heat flux time evolution pl.f = vehfmean pl.y = altitude pl.makeshow()
sounding = urllib.urlopen(url).read() soundingfile = open('sounding.txt','w').write(sounding) # and loaded using `numpy.loadtxt()` # In[23]: press,z_alt,temp,dew,hum,mix,wdir,wknot,thta,thte,thtv = np.loadtxt("sounding.txt",skiprows=8,unpack=True) # before the variables can be easily displayed using `ppplot` through a one-line instruction # In[24]: ppplot.plot1d(f=temp).makeshow() # A more elaborate plot can be obtained as well by setting more attributes for the `plot1d` class object # In[25]: sd = ppplot.plot1d() sd.f = z_alt sd.x = temp sd.linestyle = '-' sd.marker = '.' sd.color = 'r' sd.ycoeff = 1.e-3 sd.title = "A random terrestrial sounding" sd.legend = "Fort Smith 00Z 26 Sep 2013"
#! /usr/bin/env python import numpy as np import ppplot as ppp phalf = 2.e5 transi = 3. transi = 2. press = np.logspace(6,0) pl=ppp.plot1d() pl.f = press pl.x = 0.5*(1+np.tanh(transi*np.log(press/phalf))) pl.fmt = "%2.e" pl.logy = True #pl.logx = True pl.invert = True pl.makeshow()
#! /usr/bin/env python import ppplot import numpy as np # load data # http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html p,z,t,dew,hum,mix,wdir,wknot,thta,thte,thtv \ = np.loadtxt("sounding.txt",skiprows=8,unpack=True) # make a simple plot sdg = ppplot.plot1d() sdg.f = z sdg.x = t sdg.makeshow() # Tweaking a little bit the plot sdg.linestyle = '-' sdg.marker = '.' sdg.color = 'r' sdg.ycoeff = 1.e-3 sdg.title = "A random terrestrial sounding" sdg.legend = "Fort Smith 00Z 26 Sep 2013" sdg.xlabel = "Temperature ($^{\circ}$C)" sdg.ylabel = "Altitude (km)" sdg.makeshow() sdg.make() ppplot.save(mode="png", filename="plot", res=50, includedate=False)
## method 3: convective motions diff = np.abs(wmax[indt, 8:] - np.max(wmax[indt, :] / 3.)) wheremin = np.argmin(diff) + 8 pblh3[indt] = np.mean(geop[tt, wheremin, :, :]) / grav ## sometimes spurious values caused by GW diff = 100. * np.abs(pblh3[indt] - pblh1[indt]) / pblh1[indt] if diff > 33.: pblh3[indt] = pblh1[indt] pblh[indt] = np.mean([pblh1[indt], pblh2[indt], pblh3[indt]]) ## remove small or negative values pblh = pblh[pblh > 100.] ## compute mean height altitude = np.mean(np.mean(np.mean(geop, axis=3), axis=2), axis=0) / grav altitude = altitude[0:nz] file1 = open('pbl.txt', 'w') for val in pblh: file1.write("%8.3f\n" % (val)) file1.close() pl = ppplot.plot1d() # plot of the boundary layer height time evolution pl.f = pblh pl.makeshow() pl = ppplot.plot2d() # shade of the vertical eddy heat flux time evolution pl.f = vehfmean pl.y = altitude pl.makeshow()
#! /usr/bin/env python import ppplot import numpy as np # load data # http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html p,z,t,dew,hum,mix,wdir,wknot,thta,thte,thtv \ = np.loadtxt("sounding.txt",skiprows=8,unpack=True) # make a simple plot sdg = ppplot.plot1d() sdg.f = z sdg.x = t sdg.makeshow() # Tweaking a little bit the plot sdg.linestyle = '-' sdg.marker = '.' sdg.color = 'r' sdg.ycoeff = 1.e-3 sdg.title = "A random terrestrial sounding" sdg.legend = "Fort Smith 00Z 26 Sep 2013" sdg.xlabel = "Temperature ($^{\circ}$C)" sdg.ylabel = "Altitude (km)" sdg.makeshow() sdg.make() ppplot.save(mode="png",filename="plot",res=50,includedate=False)