Exemple #1
0
        statv, axis=zeaxis)
else:
    stat_trans = None
# 3. multiply by mass/metric term (computed above)
tot_trans = tot_trans * massmetric
mmc_trans = mmc_trans * massmetric
eddy_trans = eddy_trans * massmetric
if stat_trans is not None:
    stat_trans = stat_trans * massmetric
# 4. compute meridional divergence of eddy momentum flux
what_is_derived = eddy_trans / planet.a  # to get d/dy while performing d/dphi
#what_is_derived = np.cos(lat*np.pi/180.) * what_is_derived # Hoskins as followed by Remke Kaspi
if not vertaxis:
    dETdy = ppcompute.deriv1d(what_is_derived, coord=lat * np.pi / 180.)
else:
    dETdy, dETdp = ppcompute.deriv2d(what_is_derived, lat * np.pi / 180., pniv)
# spherical coordinates (needed because this is in factor to du/dt)
dETdy = dETdy / np.cos(lat * np.pi / 180.)
#dETdy = dETdy / np.cos(lat*np.pi/180.) # Hoskins as followed by Remke Kaspi

### PLOTS
### -- \langle q \rangle = \left[ \overline{q} \right]
print "plots"

### 1D plots
if not vertaxis:

    #####################################################################
    #####################################################################
    ## PLOT : check d <u>/dt = -d <u'v'> /dy
    pl = ppplot.plot1d()
Exemple #2
0
####################################################
nz,nlat = ubc.shape
nlon = 1
lat2d = np.tile(ydim,(nz,1))
acosphi2d = myp.acosphi(lat=lat2d)
cosphi2d = acosphi2d / myp.a
latrad,lat2drad = ydim*np.pi/180.,lat2d*np.pi/180.
beta = myp.beta(lat=lat2d)
f = myp.fcoriolis(lat=lat2d)
print f
tanphia = myp.tanphia(lat=lat2d)
etape("coordinates",time0)

####################################################
dubc_dy,dummy = ppcompute.deriv2d(ubc*cosphi2d,latrad,targetp1d) / acosphi2d
dummy,dubc_dp = ppcompute.deriv2d(ubc,latrad,targetp1d)
dupvpbc_dy,dummy = ppcompute.deriv2d(upvpbc*cosphi2d,latrad,targetp1d) / acosphi2d
#dusvsbc_dy,dummy = ppcompute.deriv2d(usvsbc*cosphi2d,latrad,targetp1d) / acosphi2d

#dubc_dy,dubc_dp = ppcompute.deriv2d(ubc,myp.a*latrad,targetp1d) 
#dupvpbc_dy,dummy = ppcompute.deriv2d(upvpbc,myp.a*latrad,targetp1d) 
##dusvsbc_dy,dummy = ppcompute.deriv2d(usvsbc,myp.a*latrad,targetp1d) 


vdubc_dy = -vbc*dubc_dy
fvbc = f*vbc
trans = - dupvpbc_dy
#stat = - dusvsbc_dy

summ = trans + vdubc_dy + fvbc #+ stat
Exemple #3
0
rq.xzs,rq.xze = 40000.,180000. 

# request zonal mean
#rq.zonalmean()
rq.lon = 0. ; rq.secalt()

# coordinates
z = rq.ycoord
lat = rq.xcoord
# zonal wind
u = np.transpose(rq.zonwindtab)
# density
rho = np.transpose(rq.denstab)
# static stability
temp = np.transpose(rq.temptab)
dummy,dTdz = ppcompute.deriv2d(temp,lat,z)
bv = planets.Mars.N2(T0=temp,dTdz=dTdz)

# compute saturation ratio
s = np.sqrt(alpha*bv/(rho*np.abs(u)*u*u))
w = np.where(s>1) ; s[w] = 1. # S ratio is <= 1

# plot bounds -- same as Spiga et al. 2012
lb,ub = -2.,-0.5
w = np.where(np.log10(s)<lb) ; s[w] = 10.**(lb)
w = np.where(np.log10(s)>ub) ; s[w] = 10.**(ub)

# plot
pl = ppplot.plot2d()
pl.f = np.log10(s)
pl.x = lat ; pl.xlabel = "Latitude"
Exemple #4
0
# get coordinates and zonal mean temperature + zonal mean zonal wind
temp, lon, lat, p, t = pp(file=fff, var="temp", t=ttt, x="-180,180").getfd()
u = pp(file=fff, var="u", t=ttt, x="-180,180").getf()
press = pp(file=fff, var="p", t=ttt, x="-180,180").getf()

# convert deg to rad
phi = lat * np.pi / 180.
sinphi = np.sin(phi)
cosphi = np.cos(phi)

# convert pressure to pseudo-altitude
p0 = 1.e5
z = myplanet.H() * np.log(p0 / p)

# vertical derivatives
dTdphi, dTdz = ppcompute.deriv2d(temp, phi, z)
dudphi, dudz = ppcompute.deriv2d(u, phi, z)

# convert horizontal derivatives
dTdy = dTdphi / a
dudy = dudphi / a

# compute Brunt-Vaisala frequency
bv0 = myplanet.N2()
bv = myplanet.N2(T0=temp, dTdz=dTdz)

# double horizontal derivative for u
dudydy, dummy = ppcompute.deriv2d(dudy, phi, z, fac=a)

# beta term
betaterm = 2. * omega * a * cosphi
from ppclass import pp
import ppplot
import ppcompute
import numpy as np

fff = "../temporaire.nc"
teta, lon, lat, z, t = pp(file=fff,
                          var="teta",
                          t=500,
                          x="-180,180",
                          verbose=True,
                          useindex="1000").getfd()
phi = lat * np.pi / 180.
sinphi = np.sin(phi)
cosphi = np.cos(phi)
dtetadphi, dtetadz = ppcompute.deriv2d(teta, phi, z)
pl = ppplot.plot2d()
pl.verbose = True
pl.logy = 1
pl.f = dtetadphi
pl.c = teta
pl.x = lat
pl.y = z
pl.ylabel = 'altitude (km)'
pl.xlabel = 'latitude ($^{\circ}$N)'
pl.title = '$dteta/d\phi$'
pl.makeshow()
sinphi = np.sin(phi)
cosphi = np.cos(phi)


# Convert altitudes from km to m

# In[93]:

z = z*1000.


# Compute latitudinal & vertical derivatives using `ppcompute`

# In[94]:

dTdphi,dTdz = ppcompute.deriv2d(temp,phi,z)


# Plot with ppplot the meridional gradient of temperature as shaded field and temperature as contoured field 

# In[95]:

pl = ppplot.plot2d()
pl.f = dTdphi
pl.c = temp 
pl.x = lat
pl.y = z
pl.ylabel = 'altitude (m)'
pl.xlabel = 'latitude ($^{\circ}$N)'
pl.title = '$dT/d\phi$'
pl.makeshow()
  stat_trans = ppcompute.mean(statu,axis=zeaxis)*ppcompute.mean(statv,axis=zeaxis)
else:
  stat_trans = None
# 3. multiply by mass/metric term (computed above)
tot_trans = tot_trans*massmetric
mmc_trans = mmc_trans*massmetric
eddy_trans = eddy_trans*massmetric
if stat_trans is not None:
  stat_trans = stat_trans*massmetric
# 4. compute meridional divergence of eddy momentum flux
what_is_derived = eddy_trans / planet.a # to get d/dy while performing d/dphi
#what_is_derived = np.cos(lat*np.pi/180.) * what_is_derived # Hoskins as followed by Remke Kaspi
if not vertaxis:
  dETdy = ppcompute.deriv1d(what_is_derived,coord=lat*np.pi/180.)
else:
  dETdy,dETdp = ppcompute.deriv2d(what_is_derived,lat*np.pi/180.,pniv)
# spherical coordinates (needed because this is in factor to du/dt)
dETdy = dETdy / np.cos(lat*np.pi/180.)
#dETdy = dETdy / np.cos(lat*np.pi/180.) # Hoskins as followed by Remke Kaspi

### PLOTS
### -- \langle q \rangle = \left[ \overline{q} \right]
print "plots"

### 1D plots
if not vertaxis:

 #####################################################################
 #####################################################################
 ## PLOT : check d <u>/dt = -d <u'v'> /dy
 pl = ppplot.plot1d()
# get coordinates and zonal mean temperature + zonal mean zonal wind
temp,lon,lat,p,t = pp(file=fff,var="temp",t=ttt,x="-180,180").getfd()
u = pp(file=fff,var="u",t=ttt,x="-180,180").getf()
press = pp(file=fff,var="p",t=ttt,x="-180,180").getf()

# convert deg to rad
phi = lat*np.pi/180.
sinphi = np.sin(phi)
cosphi = np.cos(phi)

# convert pressure to pseudo-altitude
p0 = 1.e5
z = myplanet.H()*np.log(p0/p)

# vertical derivatives
dTdphi,dTdz = ppcompute.deriv2d(temp,phi,z)
dudphi,dudz = ppcompute.deriv2d(u,phi,z)

# convert horizontal derivatives
dTdy = dTdphi/a
dudy = dudphi/a

# compute Brunt-Vaisala frequency
bv0 = myplanet.N2() 
bv = myplanet.N2(T0=temp,dTdz=dTdz)

# double horizontal derivative for u
dudydy,dummy = ppcompute.deriv2d(dudy,phi,z,fac=a)

# beta term
betaterm = 2.*omega*a*cosphi