User Tools


teaching:pangea4calval:exercises_ch2

Exercises_Ch2

In [1]:
%matplotlib notebook

Calculation of thermal irradiance spectrum

libRadtran input file to calculate thermal spectrum (reptran.inp)

In [ ]:
atmosphere_file midlatitude_summer  # Define atmosphere file

rte_solver schwarzschild   # Radiative transfer equation solver

# use REPTRAN absorption parameterization
mol_abs_param reptran fine


                           # calculate brightness temperature
#output_quantity brightness

albedo 0                   # set albedo to 0, emissivity to 1
source thermal             # thermal
wavelength 5000 100000

zout TOA                   # TOA

output_process per_nm
output_user lambda eup edn 

quiet

Run various REPTRAN spectral resolutions and plot the results

In [2]:
from pylab import *
import os

# Calculate transmittance with REPTRAN at different spectral resolutions

spectral_resolutions=['fine', 'medium', 'coarse']

for i in range(len(spectral_resolutions)):

    tmp=open('./reptran.inp').read()
    inp=open('uvspec.inp','w')
    inp.write(tmp)

    inp.write('mol_abs_param reptran %s'%spectral_resolutions[i])

    inp.close()

    os.system('uvspec < uvspec.inp > uvspec_%s.out'%spectral_resolutions[i])



# plot results

figure(1, figsize=(10,5))

for i in range(len(spectral_resolutions)):
    
    data=loadtxt('uvspec_%s.out'%spectral_resolutions[i])

    semilogx(data[:,0], data[:,1], label=spectral_resolutions[i])

    xlabel('wavelength [nm]')
    ylabel('E$_{up}$ [W/m$^2$/nm]')
    legend()
    

Impact of various trace gases

In [3]:
from pylab import *
import os

# Calculate transmittance including only single species

all_species=['O3','O2','H2O','CO2','NO2','BRO','OCLO','HCHO','O4','SO2','CH4','N2O','CO','N2'] 

species=['H2O', 'CO2', 'CH4', 'N2O', 'O3'] 

for i in range(len(species)):

    tmp=open('./reptran.inp').read()
    inp=open('uvspec.inp','w')
    inp.write(tmp)

    # set concentrations of all species except species[i] to 0
    for j in range(len(all_species)):
        if all_species[j] != species[i]:
            inp.write('mol_modify %s 0 CM_2 \n'%all_species[j])
    
    inp.close()

    os.system('uvspec < uvspec.inp > uvspec_%s.out'%species[i])



# plot results

figure(2, figsize=(10,5))

for i in range(len(species)):
    
    data=loadtxt('uvspec_%s.out'%species[i])

    semilogx(data[:,0], data[:,1], label=species[i])

    xlabel('wavelength [nm]')
    ylabel('E$_{up}$ [W/m$^2$/nm]')
    legend()
    

Spectrum for various surface emissivities

In [4]:
from pylab import *
import os

# Calculate irradiance with different emissivities

emissivities=arange(0,1.1,0.25)

for i in range(len(emissivities)):

    tmp=open('./reptran.inp').read()
    inp=open('uvspec.inp','w')
    inp.write(tmp)

    inp.write('albedo %.2f \n'%(1.-emissivities[i]))
    inp.write('zout 0 TOA\n')
    inp.write('rte_solver twostrebe \n')
    
    inp.close()

    os.system('uvspec < uvspec.inp > uvspec_%s.out'%emissivities[i])



# plot results

figure(3, figsize=(10,10))

for i in range(len(emissivities)):
    
    data=loadtxt('uvspec_%s.out'%emissivities[i])

    subplot(221)
    semilogx(data[1::2,0], data[1::2,1], label='%.2f'%emissivities[i])
    xlabel('wavelength [nm]')
    ylabel('TOA E$_{up}$ [W/m$^2$/nm]')
    legend()
    
    subplot(222)
    semilogx(data[1::2,0], data[1::2,2], label='%.2f'%emissivities[i])
    xlabel('wavelength [nm]')
    ylabel('TOA E$_{dn}$ [W/m$^2$/nm]')
    legend()
    
    subplot(223)
    semilogx(data[::2,0], data[::2,1], label='%.2f'%emissivities[i])
    xlabel('wavelength [nm]')
    ylabel('surface E$_{up}$ [W/m$^2$/nm]')
    legend()
    
    subplot(224)
    semilogx(data[::2,0], data[::2,2], label='%.2f'%emissivities[i])
    xlabel('wavelength [nm]')
    ylabel('surface E$_{dn}$ [W/m$^2$/nm]')
    legend()

    suptitle('Impact of surface emissivity on thermal irradiance')
    
    

Include clouds

In [5]:
from pylab import *
import os

# Calculate irradiance with different emissivities

cloud_heights=arange(1,15,4)

for i in range(len(cloud_heights)):

    tmp=open('./reptran.inp').read()
    inp=open('uvspec.inp','w')
    inp.write(tmp)

    # write cloud input file
    wc=open('wc.dat','w')
    wc.write('%f 0 0 \n'%(cloud_heights[i]+1.))
    wc.write('%f 0.1 10 \n'%cloud_heights[i])
    wc.close()

    inp.write('wc_file 1D wc.dat \n')
    inp.write('wc_properties mie interpolate \n')
    inp.write('wc_modify tau set 20 \n')
    
    inp.write('zout 0 TOA\n')

    inp.write('mol_abs_param reptran coarse \n')
    inp.write('rte_solver twostrebe \n')
    
    inp.close()

    os.system('uvspec < uvspec.inp > uvspec_%s.out'%cloud_heights[i])



# plot results

figure(4, figsize=(8,8))

for i in range(len(cloud_heights)):
    
    data=loadtxt('uvspec_%s.out'%cloud_heights[i])

    subplot(211)
    semilogx(data[1::2,0], data[1::2,1], label='%.2f'%cloud_heights[i])
    xlabel('wavelength [nm]')
    ylabel('TOA E$_{up}$ [W/m$^2$/nm]')
    legend()
    
   
    subplot(212)
    semilogx(data[::2,0], data[::2,2], label='%.2f'%cloud_heights[i])
    xlabel('wavelength [nm]')
    ylabel('surface E$_{dn}$ [W/m$^2$/nm]')
    legend()

    suptitle('Impact of cloud height on thermal irradiance')
    
    

Include aerosols

In [6]:
from pylab import *
import os

# Calculate irradiance with different aerosols
aerosol_species=['continental_clean', 'continental_average', 'continental_polluted', 'urban', 'maritime_clean', 'maritime_polluted', 'maritime_tropical', 'desert', 'antarctic'] 


tmp=open('./reptran.inp').read()
inp=open('uvspec.inp','w')
inp.write(tmp)
inp.write('wavelength 5000 40000 \n')
inp.write('zout 0 TOA\n')
inp.write('mol_abs_param reptran coarse \n')
inp.write('rte_solver twostrebe \n')
inp.close()

os.system('uvspec < uvspec.inp > uvspec_clear.out')



for i in range(len(aerosol_species)):

    tmp=open('./reptran.inp').read()
    inp=open('uvspec.inp','w')
    inp.write(tmp)

    inp.write('aerosol_default \n')
    inp.write('aerosol_species_file %s \n'%aerosol_species[i])
    inp.write('wavelength 5000 40000 \n')
    
    inp.write('zout 0 TOA\n')

    inp.write('mol_abs_param reptran coarse \n')
    inp.write('rte_solver twostrebe \n')
    
    inp.close()

    os.system('uvspec < uvspec.inp > uvspec_%s.out'%aerosol_species[i])



# plot results

figure(5, figsize=(8,10))

clear=loadtxt('uvspec_clear.out')
subplot(121)
semilogx(clear[1::2,0], clear[1::2,1], 'k',label='clear')
subplot(122)
semilogx(clear[::2,0], clear[::2,2], 'k',label='clear')

for i in range(len(aerosol_species)):
    
    data=loadtxt('uvspec_%s.out'%aerosol_species[i])

    subplot(211)
    semilogx(data[1::2,0], data[1::2,1], label='%s'%aerosol_species[i])
    xlabel('wavelength [nm]')
    ylabel('TOA E$_{up}$ [W/m$^2$/nm]')
    legend()
    
   
    subplot(212)
    semilogx(data[::2,0], data[::2,2], label='%s'%aerosol_species[i])
    xlabel('wavelength [nm]')
    ylabel('surface E$_{dn}$ [W/m$^2$/nm]')
    legend()

    suptitle('Impact of aerosols on thermal irradiance')

#subplots_adjust(wspace=0.3)

Thermal heating rate

In [ ]:
atmosphere_file midlatitude_summer  # Define atmosphere file

rte_solver twostrebe     # Radiative transfer equation solver

# use Fu absorption parameterization
mol_abs_param fu

albedo 0                   # set albedo to 0, emissivity to 1
source thermal             # thermal


zout 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 4.0 4.2 4.4 4.6 4.8 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 6.6 6.8 7.0 7.2 7.4 7.6 7.8 8.0 8.2 8.4 8.6 8.8 9.0 9.2 9.4 9.6 9.8 10.0 10.2 10.4 10.6 10.8 11.0 11.2 11.4 11.6 11.8 12.0 12.2 12.4 12.6 12.8 13.0 13.2 13.4 13.6 13.8 14.0 14.2 14.4 14.6 14.8 15.0

output_process sum
output_user zout edn eup heat 

quiet
In [7]:
from pylab import *
import os

# Calculate integrated irradiances and heating rates

# Clear atmosphere
os.system('uvspec < ./fu_heating_rates.inp > uvspec_clear.out')

# Increase water vapor concentration
tmp=open('./fu_heating_rates.inp').read()
inp=open('uvspec.inp','w')
inp.write(tmp)
inp.write('mol_modify H2O 50 MM \n') # MM corresponds approx. to kg/m^2
inp.close()
os.system('uvspec < uvspec.inp > uvspec_humid.out')

# Include a water cloud
tmp=open('./fu_heating_rates.inp').read()
inp=open('uvspec.inp','w')
inp.write(tmp)
# write cloud input file
wc=open('wc.dat','w')
wc.write('3 0 0 \n')
wc.write('2 0.1 10 \n')
wc.close()
inp.write('wc_file 1D wc.dat \n')
inp.write('wc_properties hu \n')
inp.write('wc_modify tau set 10 \n')
inp.close()
os.system('uvspec < uvspec.inp > uvspec_wc.out')

# Include an ice cloud
tmp=open('./fu_heating_rates.inp').read()
inp=open('uvspec.inp','w')
inp.write(tmp)
wc=open('wc.dat','w')
wc.write('12 0 0 \n')
wc.write('10 0.1 30 \n')
wc.close()
inp.write('ic_file 1D wc.dat \n')
inp.write('ic_properties fu \n')
inp.write('ic_modify tau set 1 \n')
inp.close()
os.system('uvspec < uvspec.inp > uvspec_ic.out')



# plot results
cases=['clear', 'humid', 'wc', 'ic']

figure(6, figsize=(10,7))

for i in range(len(cases)):
    
    data=loadtxt('uvspec_%s.out'%cases[i])

    subplot(131)
    plot(data[:,1], data[:,0], label='%s'%cases[i])
    ylabel('z [km]')
    xlabel('E$_{dn}$ [W/m$^2$]')
    legend()
    
    subplot(132)
    plot(data[:,2], data[:,0], label='%s'%cases[i])
    #ylabel('z [km]')
    xlabel('E$_{up}$ [W/m$^2$]')
    legend()
   
    subplot(133)
    plot(data[:,3], data[:,0], label='%s'%cases[i])
    #ylabel('z [km]')
    xlabel('heating rate [K/d]')
    legend()

    suptitle('Thermal heating rates')
    

Line-by-line simulations

libRadtran input file (uvspec_lbl.ir.disort.inp):

In [ ]:
# data_files_path /home/data/daten/public/rt-data/libRadtran_data/

# Standard atmospheres in ARTS defined up to 95km, the atmosphere
# file here has to correspond to the atmosphere used to generate the 
# molecular_tau_file  
atmosphere_file  afglms.dat
source thermal

wavelength 10000 10010

# Read ARTS generated molecular_tau_file
mol_tau_file abs moltau_example.nc

# Use disort2 solver
rte_solver  disort        # Radiative transfer equation solver

# Calculate upwelling nadir radiance at TOA
zout toa
umu 1.0
phi 0

output_process per_nm
output_user lambda uu
In [8]:
from pylab import *
import os

os.system('uvspec < ex7_line_by_line/uvspec_lbl.ir.disort.inp > ex7_line_by_line/disort_lbl.out')
result=loadtxt('ex7_line_by_line/disort_lbl.out') 

figure(7, figsize=(10,6))
plot(result[:,0], result[:,1])
xlabel('wavelength [nm]')
ylabel('nadir radiance TOA [W/m$^2$/nm/sr]');

teaching/pangea4calval/exercises_ch2.txt · Last modified: 2023/03/23 16:39 (external edit)