In [0]:
#
#start by importing the necessary routines from the lib folder
#
from __future__ import print_function
from matplotlib import pyplot as plt
try:
import seaborn
except:
pass
import os,site
currdir=os.getcwd()
head,tail=os.path.split(currdir)
libdir=os.path.join(head,'lib')
site.addsitedir(libdir)
from radiances import hydrostat,find_tau,radiances
In [0]:
%matplotlib inline
In [0]:
#atmospheric properties
r_gas=0.01 #kg/kg
k_lambda=0.01 #m^2/kg
T_surf=300 #K
p_surf=100.e3 #Pa
dT_dz = -7.e-3 #K/km
delta_z=10
num_levels=1500
In [0]:
Temp,press,rho,height=hydrostat(T_surf,p_surf,dT_dz,delta_z,num_levels)
tau=find_tau(r_gas,k_lambda,rho,height)
up,down=radiances(tau,Temp,height,T_surf)
In [0]:
up
In [0]:
fig1,axis1=plt.subplots(1,1)
axis1.plot(up,height*0.001,'b-',lw=5,label='upward radiance')
axis1.plot(down,height*0.001,'g-',lw=5,label='downward radiance')
axis1.set_title('upward and downward radiances')
axis1.set_xlabel('radiance $(W\,m^{-2}\,sr^{-1})$')
axis1.set_ylabel('height (km)')
axis1.legend(numpoints=1,loc='best')
In [0]:
fig2,axis2=plt.subplots(1,1)
axis2.plot(up-down,height*0.001,'b-',lw=5)
axis2.set_title('net upward radiance')
axis2.set_xlabel('net upward radiance $(W\,m^{-2}\,sr^{-1})$')
axis2.set_ylabel('height (km)')
In [0]:
from fluxes import fluxes
up,down=fluxes(tau,Temp,height,T_surf)
In [0]:
fig1,axis1=plt.subplots(1,1)
axis1.plot(up,height*0.001,'b-',lw=5,label='upward flux')
axis1.plot(down,height*0.001,'g-',lw=5,label='downward lux')
axis1.set_title('upward and downward fluxes')
axis1.set_xlabel('flux $(W\,m^{-2})$')
axis1.set_ylabel('height (km)')
axis1.legend(numpoints=1,loc='best')
In [0]:
fig2,axis2=plt.subplots(1,1)
axis2.plot(up-down,height*0.001,'b-',lw=5)
axis2.set_title('net upward flux')
axis2.set_xlabel('net upward flux $(W\,m^{-2})$')
axis2.set_ylabel('height (km)')
In [0]:
from fluxes import heating_rate
dT_dt=heating_rate(up - down,height,rho)
fig3,axis3=plt.subplots(1,1)
#
#find the height at mid-layer
#
layer_height=(height[1:] + height[:-1])/2.
axis3.plot(dT_dt*3600.*24.,layer_height*0.001,'b-',lw=5)
axis3.set_title('heating rate in K/day')
axis3.set_xlabel('heating rate (K/day)')
axis3.set_ylabel('height (km)')
In [0]: