Using atmosphericModel.py is made as simple as importing the python package and calling its functions. Several parameters are needed, such as location, temperature, pressure and relative humidity. Then the dispersion model object is initiated, allowing us to calculate the index of refraction for any set of TPH and CO2 content values.
We install the package using the setup.py
file and running the following command:
python setup.py install
Now the package can be imported using import AstroAtmosphere
in Python.
#!/usr/bin/env Python
import numpy as np
import matplotlib.pyplot as plt
from AstroAtmosphere import *
# Parameters at Cerro Armazones
T = 279.65 # k
P = 71200 # Pa
H = 0.22
xc = 450 # ppm
lat = -24.5983 # degrees
h = 3064 # m
l1 = 1.49 # micron
l2 = 1.78 # micron
# Initializing dispersion model
at = Observatory()
# Calculating indices of refraction for l1 and l2
n1 = at.n_tph(l=l1, T=T, p=P, RH=H, xc=xc)
n2 = at.n_tph(l=l2, T=T, p=P, RH=H, xc=xc)
We can also calculate the density of the air, which will be useful when calculating the scale height of the atmosphere, necessary for the refraction calculations.
# Density of the atmosphere (following CIPM-81/91 equations)
rho = at.rho(p=P, T=T, RH=H, xc=xc)
# Initializing refraction model and setting the reduced height
ref = refraction(lat, h)
ref.setReducedHeight(P, rho)
The refraction for 1.49 um light at a zenith angle of 45 degrees, as calculated by the Cassini model, is found to be:
zenith_obs = 45
refraction_obs = ref.cassini(n1, zenith_obs) * 3.6e3
print ('The refraction is %.03f arc seconds' %(refraction_obs))
Some error propagation is included in the module as well. It takes is able to calculate the uncertainty in the refractive index and uses that to propagate it into the refraction formule for the cassini model. Note: The Cassini model is the only refraction model for which error propagation is possible, in this module.
In this example we assume the following uncertainties:
# Calculating the uncertainty in the refractive index
n1 = at.n_tph(l=l1, T=T, p=P, RH=H, xc=xc)
dn1 = at.dn_tph(l1, T, P, H, xc, dl=0.001, dT=0.2, dP=30, dRH=0.03, dCO2=25)
# Calculating the uncertainty in the atmospheric refraction
refError = ref.cassiniError(n1, dn1, zenith_obs, dz=1/3600)*3.6e3
print ('The refraction is: %.3f +/- %.3f arc seconds' %(refraction_obs, refError))
Dispersion is simply the refraction differential between two wavelengths. This is calculated with a dispersion object. Again, we can also calculate the uncertainty in the dispersion based on the measurement uncertainties. We take the same values as above.
Note that, since the unertainties in the refractive index at two wavelengths observated at the same time are correlated, we cannot simply use n1, n2, dn1 and dn2 as an input but require the whole set of conditions and uncertainties.
# Initializing dispersion object
disp = dispersion(lat, h)
disp.setReducedHeight(P, rho)
dispersion_obs = disp.cassini(n1, n2, zenith_obs)*3.6e6
# Calculating the uncertainty in the atmospheric dispersion
dispersion_unc = disp.cassiniError(zenith_obs, l1, l2, T, P, H, xc,
dl1=0.001, dl2=0.001, dT=0.2, dP=30, dRH=0.03, dCO2=25, dz=1/3600) * 3.6e6
print ('The dispersion is %.03f +/- %.03f milli arc seconds' %(dispersion_obs, dispersion_unc))
There are also some quick calculation functions defined in the examples.py
file, if you just want to know the refractive index, the refraction or the dispersion at standard atmospheric conditions (conditions='STANDARD'
) or at Cerro Armazones (conditions='CERRO_ARMAZONES'
).
# Quick refractive index
nq = quick_refractive_index(l=1.49, conditions='STANDARD')
print('Quick refractive index: {}'.format(nq))
# Quick refraction
rq = quick_refraction(l1, zenith_obs, conditions='CERRO_ARMAZONES') * 3.6e3
print('Quick refraction: {:.3f} arcsec'.format(rq))
# Quick dispersion
dq = quick_dispersion(l1, l2, zenith_obs, conditions='CERRO_ARMAZONES') * 3.6e6
print('Quick dispersion: {:.3f} mas'.format(dq))