Updated documentation, descriptions for v1.0 release.

This commit is contained in:
yosata committed 2020-06-24 16:47:25 +02:00
1 parent 56051bb6a5
commit 8d50899db6
31 files changed
+17833 -192

No files matched your search

+208 -19
View File
@@ -16,6 +16,53 @@ from scipy import integrate
'''
class Observatory:
'''
Class used for all function to calculate the refractive index
and the corresponding uncertainties.
...
Attributes
----------
dT : float (optional)
Uncertainty in the atmospheric temperature in Kelvin
dP : float (optional)
Uncertainty in the atmospheric pressure in Pascal
dH : float (optional)
Uncertainty in the atmospheric relative humidity
dCO2: float (optional)
Uncertianty in the atmospheric CO2 density in parts
per million.
dl : float (optional)
Uncertainty in the wavelengths in micron
Methods
-------
n_as(l)
Returns the refractive index for standard atmospheric conditions.
n_axs(l, xc)
Same as n_as(l), but with a different CO2 density given by xc
n_ws(l)
Returns the refractive index of air for standard moist contions.
f(p,T)
Returns the enchancement factor of water vapour in air.
svp(T)
Returns the saturation vapour pressure in Pa.
svp2(T)
Returns the saturation vapour pressure in Pa.
From IAPWS formula, based on documentation by NIST toolbox.
xw(p, T, RH)
Returns the molar fraction of water vapour in moist air.
Z(p, T, RH, xw='')
Returns the compressibility of moist air
rho(p, T, RH, xc, xw='')
Returns the density of atmospheric air at the given parameters.
n_tph(l, T, p, RH, xc)
Returns the refractive index for any atmospheric conditions.
dn_tph(l, T, p, RH, xc, dl=None, dT=None, dP=None, dRH=None, dCO2=None)
Returns the uncertainty in the refractive index for any atmospheric
conditions, given the parameters.
'''
def __init__(self, dT=0.2, dP=20, dH=0.02, dCO2=20, dl=0.001):
self.dT = dT # in K
self.dP = dP # in Pa
@@ -28,6 +75,17 @@ class Observatory:
Formula that calculate the refractive index for standard atmospheric
conditions, i.e. 15 C, 101,325 Pa, 0% RH, 450 ppm CO2.
It returns n_as, not (n_as - 1) * 1e8!
Parameters
----------
l : float
Wavelength of light in microns
Returns
-------
n : float
Refractive index of air at standard atmospheric conditions.
'''
_s = 1 / l
_k0 = 238.0185 # um^-2
@@ -42,6 +100,18 @@ class Observatory:
Formula that calculate the refractive index for standard atmospheric
conditions, i.e. 15 C, 101,325 Pa, 0% RH, but with xc ppm of CO2.
It returns n_axs, not (n_axs - 1)
Parameters
----------
l : float
Wavelength of light in microns
xc : float
CO2 density in parts per million
Returns
-------
n : float
Refractive index of air
'''
_n_as = self.n_as(l)
return ( (_n_as - 1) * (1 + 0.534e-6 * (xc - 450) ) ) + 1
@@ -52,6 +122,16 @@ class Observatory:
Formula that calculates the refractivity of air for standard moist conditions
as defined by B&S (1939), i.e. 20 C, 1333 Pa
Returns n_ws, not (n_ws - 1) * 1e8
Parameters
----------
l : float
Wavelength of light in microns
Returns
-------
n : float
Refractive index of standard moist air.
'''
_s = 1 / l
_cf = 1.022
@@ -65,8 +145,18 @@ class Observatory:
def f(self, p, T):
'''
Enhancement factor of water vapour in air
t in degrees celsius
p in Pascal (Pa)
Parameters
----------
p : float
Atmospheric pressure in Pascal
T : float
Atmospheric temperature in Kelvin
Returns
-------
f : float
Enhancement factor of water vapour in air
'''
_t = T - 273.15
_a = 1.00062
@@ -78,6 +168,16 @@ class Observatory:
def svp(self, T):
'''
Saturation vapour pressure in Pa.
Parameters
----------
T : float
Atmospheric temperature in Kelvin
Returns
-------
svp : float
Saturation vapour pressure
'''
_A = 1.2378847e-5 # K^-2
_B = -1.9121316e-2 # K^-2
@@ -88,7 +188,18 @@ class Observatory:
def svp2(self, T):
'''
Calculation of svp from IAPWS formula, based on documentation by NIST toolbox.
Calculation of svp from IAPWS formula, based on documentation
by NIST toolbox.
Parameters
----------
T : float
Atmospheric temperature in Kelvin
Returns
-------
svp : float
Saturation vapour pressure
'''
K1 = 1.16705214528e+03
K2 = -7.24213167032e+05
@@ -111,6 +222,20 @@ class Observatory:
def xw(self, p, T, RH):
'''
Molar fraction of water vapour in moist air.
Parameters
----------
p : float
Atmospheric pressure in Pascal
T : float
Atmospheric temperature in Kelvin
RH : float
Atmospheric relative humidity (0<=RH<=1)
Returns
-------
xw : float
Molar fraction of water vapour in moist air
'''
_f = self.f(p, T)
_svp = self.svp(T)
@@ -120,6 +245,20 @@ class Observatory:
def Z(self, p, T, RH, xw=''):
'''
Compressibility of moist air
Parameters
----------
p : float
Atmospheric pressure in Pascal
T : float
Atmospheric temperature in Kelvin
RH : float
Atmospheric relative humidity (0<=RH<=1)
Returns
-------
Z : float
Compressibility of moist air
'''
_a0 = 1.58123e-6 # K Pa^-1
_a1 = -2.9331e-8 # Pa^-1
@@ -142,10 +281,25 @@ class Observatory:
def rho(self, p, T, RH, xc, xw=''):
'''
Calculates the density of air for the given parameters.
T in Kelvin
p in Pascal
RH between 0 and 1
xc in ppm
Parameters
----------
p : float
Atmospheric pressure in Pascal
T : float
Atmospheric temperature in Kelvin
RH : float
Atmospheric relative humidity (0<=RH<=1)
xc : float
CO2 density in parts per million
xw : str or float
Placeholder for molar fraction of water vapour in moist air.
Used to pass the function along where it should go.
Returns
-------
rho : float
Density of air
'''
_Ma = 1e-3 * (28.9635 + 12.011e-6 * (xc - 400) ) # Molar mass in kg/mol of dry air containing xc ppm of CO2
_Mw = 0.018015 # kg/mol
@@ -161,6 +315,25 @@ class Observatory:
def n_tph(self, l, T, p, RH, xc):
'''
Calculates the refraction of the atmosphere for any conditions.
Follows the equations by Ciddor (1996).
Parameters
----------
l : float
Wavelength of light in microns
p : float
Atmospheric pressure in Pascal
T : float
Atmospheric temperature in Kelvin
RH : float
Atmospheric relative humidity (0<=RH<=1)
xc : float
CO2 density in parts per million
Returns
-------
n : float
Refractive index of air
'''
_n_a = self.n_axs(l, xc)
_n_w = self.n_ws(l)
@@ -193,18 +366,34 @@ class Observatory:
by using fully propagated error analysis.
This involves almost endless use of the chain rule and evaluation of both the moist
air and dry air components. Note: dry air does not contain any water, i.e. H=0, x_w=0, etc.
Parameters:
l - Wavelength in micron (0.4 - 2.5 micron)
T - Temperature in Kelvin
p - Pressure in Pascals
RH - Relative humidity (no units, don't use percentage but value 0<x<1)
xc - CO2 density in ppm
dl - Uncertainty in the blue wavelength
dT - Uncertainty in the temperature, default: 0.2 K
dP - Uncertainty in the pressure, default: 20 Pa
dRH - Uncertainty in the relative humidity, default: 0.02
dCO2- Uncertainty in the CO2 density, default: 20
Parameters
----------
l : float
Wavelength of light in microns
p : float
Atmospheric pressure in Pascal
T : float
Atmospheric temperature in Kelvin
RH : float
Atmospheric relative humidity (0<=RH<=1)
xc : float
CO2 density in parts per million
dl : float
Uncertainty in the wavelength in microns
dT : float (default: 0.2)
Uncertainty in the atmospheric temperature in Kelvin
dP : float (default: 20)
Uncertainty in the atmospheric pressure in Pascal
dRH : float (default: 0.02)
Uncertainty in the atmospheric relative humidity
dCO2: float (default: 20)
Uncertainty in the atmospheric CO2 density in parts per million
Returns
-------
dn : float
Uncertainty in the refractive index of air
'''
if dP == None: