3 Commits
Author SHA1 Message Date
yosata 03d583a9cd Improved quick functions 2022-03-23 08:42:45 +01:00
yosata 3cdf4ccd39 Added TPH dependence to BirchDowns() 2021-03-10 12:27:07 +01:00
yosata 2652d75eec Update README 2021-03-10 12:04:27 +01:00
4 changed files with 63 additions and 20 deletions

No files matched your search

+31 -5
View File
@@ -4,8 +4,9 @@ from .refractionModels import refraction
from .dispersionModels import dispersion
from .neoslalib import sla_refro
from .observatories import observatories
from .refractivityModels import Edlen1953
from .refractivityModels import Edlen1953, Mathar
import numpy as np
import warnings
'''
@ Author: Joost van den Born
@@ -102,7 +103,9 @@ def quick_refractive_index(l, conditions='STANDARD', T=288.15, p=101325,
Parameters
----------
l : float
Wavelength in microns
Wavelength in microns. If the wavelength is above
2.5 microns, then the Mathar refractivity model
is used.
conditions: string
Refers to the standard conditions of the
observatory. See get_conditions() for more info.
@@ -129,11 +132,15 @@ def quick_refractive_index(l, conditions='STANDARD', T=288.15, p=101325,
if conditions is not None:
T, p, RH, xc, lat, h, _ = get_conditions(conditions).values()
if l <= 2.5:
# Initializing dispersion model
at = Observatory()
# Calculating indices of refraction for l
n = at.n_tph(l=l, T=T, p=p, RH=RH, xc=xc)
else:
# Using the Mathar description for infrared wavelengths
n = Mathar(l=l, T=T, p=p, RH=RH)
return n
@@ -147,7 +154,8 @@ def quick_refraction(l, zenith, conditions='STANDARD', T=288.15, p=101325,
Parameters
----------
l : float
Wavelength in microns
Wavelength in microns. If the wavelength is above 2.5 micron
then the Mathar refractivity model is used.
zenith : float
Angle of observation in degrees.
zenith = 0 means the observation is directly overhead.
@@ -180,8 +188,12 @@ def quick_refraction(l, zenith, conditions='STANDARD', T=288.15, p=101325,
# Initializing dispersion model
at = Observatory()
if l <= 2.5:
# Calculating indices of refraction for l
n = at.n_tph(l=l, T=T, p=p, RH=RH, xc=xc)
else:
# Using the Mathar description for infrared wavelengths
n = Mathar(l=l, T=T, p=p, RH=RH)
# Density of the atmosphere (following CIPM-81/91 equations)
rho = at.rho(p=p, T=T, RH=RH, xc=xc)
@@ -202,9 +214,11 @@ def quick_dispersion(l1, l2, zenith, conditions='STANDARD', T=288.15,
Parameters
----------
l1 : float
Shortest wavelength of interest in micron.
Shortest wavelength of interest in micron. If the wavelength
is above 2.5 microns, then the Mathar model is used.
l2 : float
Longest wavelength of interest in micron.
Longest wavelength of interest in micron. If the wavelength
is above 2.5 microns, then the Mathar model is used.
zenith : float
Angle of observation in degrees.
zenith = 0 means the observation is directly overhead.
@@ -237,9 +251,21 @@ def quick_dispersion(l1, l2, zenith, conditions='STANDARD', T=288.15,
# Initializing dispersion model
at = Observatory()
if l1 <= 2.5 and l2 <= 2.5:
# Calculating indices of refraction for l1 and l2
n1 = at.n_tph(l=l1, T=T, p=p, RH=RH, xc=xc)
n2 = at.n_tph(l=l2, T=T, p=p, RH=RH, xc=xc)
elif l1 > 1.4 and l2 > 1.4:
# Using the Mathar description for infrared wavelengths
n1 = Mathar(l=l1, T=T, p=p, RH=RH)
n2 = Mathar(l=l2, T=T, p=p, RH=RH)
else:
warnings.warn('Using two refractivity models (Ciddor and Mathar). \
Make sure you trust the results!')
l1n = np.min([l1, l2])
l2n = np.max([l1, l2])
n1 = at.n_tph(l=l1n, T=T, p=p, RH=RH, xc=xc)
n2 = Mathar(l=l2n, T=T, p=p, RH=RH)
# Density of the atmosphere (following CIPM-81/91 equations)
rho = at.rho(p=p, T=T, RH=RH, xc=xc)
+26 -9
View File
@@ -244,10 +244,10 @@ def BonschPotulski(l, T=288.15, p=101325, RH=0, CO2=400, f=None):
return n
def BirchDowns(l):
def BirchDowns(l, T=288.15, p=101325, RH=0, f=None):
'''
From Birch & Downs, 1993 and 1994 (correction)
Equations 1 and 2
Equations 1, 2 and 3
Only at standard conditions
@@ -255,15 +255,32 @@ def BirchDowns(l):
----------
l : float
wavelength in micron
T : float
Temperature in Kelvin
p : float
Atmospheric pressure in Pa
RH : float
Relative humidity (0<=H<=1)
f : float
Water vapor pressure in Pascal
Returns
-------
n : float
Refractive index of atmospheric air at the given conditions
'''
Tc = K2C(T)
s = 1 / l
R = 8342.54 + 2406147 / (130 - s**2) + 15998 / (38.9-s**2)
n = R/1e8 + 1
Rs = 8342.54 + 2406147 / (130 - s**2) + 15998 / (38.9-s**2)
n = Rs/1e8 + 1
R_tp = (p * Rs/1e8) / 96095.43 * (1 + 1e-8 * (0.601 - 0.00972 * Tc) * p) / (1 + 0.0036610 * Tc)
n_tp = R_tp + 1
if f is None:
f = RH * svp(T)
n = n_tp - f * (3.7345 - 0.0401 * s**2) * 1e-10
return n
@@ -438,7 +455,7 @@ def Mathar(l, T=288.15, p=101325, RH=0):
if l < 1.3 or l > 24:
print('Using the Mathar model at this wavelength (l={:.3f}) is not recommended!'.format(l))
if l <= 2.65:
elif l <= 2.65:
########################################################################
# model parameters for wavelengths between 1.3 and 2.5 microns
cref = [ 0.200192e-3, 0.113474e-9, -0.424595e-14, 0.100957e-16, -0.293315e-20, 0.307228e-24] # cm^j
@@ -458,7 +475,7 @@ def Mathar(l, T=288.15, p=101325, RH=0):
Href = 10 #%, reference humdity in percent
########################################################################
if l > 2.65 and l <= 4.275:
elif l > 2.65 and l <= 4.275:
########################################################################
# model parameters for wavelengths between 2.8 and 4.2 microns
cref = [ 0.200049e-3, 0.145221e-9, 0.250951e-12, -0.745834e-15, -0.161432e-17, 0.352780e-20] # cm^j
@@ -478,7 +495,7 @@ def Mathar(l, T=288.15, p=101325, RH=0):
Href = 10 #%, reference humdity in percent
########################################################################
if l > 4.275 and l <= 6.35:
elif l > 4.275 and l <= 6.35:
########################################################################
# model parameters for wavelengths between 4.35 and 5.2 microns
cref = [ 0.200020e-3, 0.275346e-9, 0.325702e-12, -0.693603e-14, 0.285610e-17, 0.338758e-18] # cm^j
@@ -497,7 +514,7 @@ def Mathar(l, T=288.15, p=101325, RH=0):
Href = 10 #%, reference humdity in percent
########################################################################
if l > 6.35 and l <= 15.05:
elif l > 6.35 and l <= 15.05:
########################################################################
# model parameters for wavelengths between 7.5 and 14.1 microns
cref = [ 0.199885e-3, 0.344739e-9, -0.273714e-12, 0.393383e-15, -0.569488e-17, 0.164556e-19] # cm^j
@@ -517,7 +534,7 @@ def Mathar(l, T=288.15, p=101325, RH=0):
########################################################################
if l > 15.05:
elif l > 15.05:
########################################################################
# model parameters for wavelengths between 16 and 24 microns
cref = [ 0.199436e-3, 0.299123e-8, -0.214862e-10, 0.143338e-12, 0.122398e-14, -0.114628e-16] # cm^j
+4 -4
View File
@@ -190,9 +190,9 @@ Included are
| Barrell & Sears (1939) | `BarrellAndSears()` | Outdated model, especially poor for short wavelengths. |
| Ciddor (1996) | `Ciddor()` | Only at standard atmosphere. CO2 density can be changed. |
| Edlen (1953) | `Edlen1953()` | The equation by Edlèn, 1953, combined with modification from Barrel (1951), to include temperature, pressure and humidity dependence. |
| Edlen (1966) | `Edlen1966()` | Only at standard atmosphere. Function requires wavelength only. |
| Owens (1967) | `Owens()` | - |
| Bonsch & Potulski (1998) | `BonschPotulski()` | Function does not include humidity |
| Edlen (1966) | `Edlen1966()` | Allows for any temperature, pressure, humidity and CO2 density.|
| Owens (1967) | `Owens()` | Allows for any temperature, pressure, humidity. |
| Bonsch & Potulski (1998) | `BonschPotulski()` | Allows for any temperature, pressure, humidity and CO2 density. |
| Birch & Downs (1994) | `BirchDowns()` | Only at standard atmosphere. Function requires wavelength only. |
| Peck & Reeder (1972) | `PeckReeder()` | Only at standard atmosphere. Function requires wavelength only. |
| Hohenkerk & Sinclair (1985) | `HohenkerkAndSinclair()` | Based on Barrell & Sears equation. Generally, gives slightly larger values.|
@@ -229,6 +229,6 @@ Presently, several observatories are known. These can all be found in the `obser
## Other
This package also contains a python native port of the `SLA_REFRO()` routine of the pyslalib package, which was originally written in FORTRAN by P.T. Wallace. It can be called directly using `sla_refro()`. When using the same units as the other refraction functions, you might prefer using `slalib_refraction()` or `slalib_dispersion()`.
This package also contains a python native port of the `SLA_REFRO()` routine of the pyslalib package, which was originally written in FORTRAN by P.T. Wallace. It can be called directly using `sla_refro()`. When using the same units as the other refraction functions, you might prefer using `slalib_refraction()` or `slalib_dispersion()`. Do note that this implementation is slower than the (compiled) FORTRAN implementation.
Finally, the dispersion model used by Alexei Filippenko in 1982 is also included. This model is a combination of the (modified) Edlèn equation and a plane-parallel atmospheric geometry. This calculation can be accessed by calling the `Filippenko1982()` function.
+2 -2
View File
@@ -21,14 +21,14 @@ def setup_package():
# write_version_py()
setup(name='AstroAtmosphere',
version='1.4',
version='1.4.1',
description='Collection of equations for refractive index, refraction and dispersion calculations of atmospheric air.',
long_description=__readme__,
long_description_content_type='text/markdown',
author='Joost van den Born',
author_email='born@astron.nl',
url='https://gitlab.astro-wise.org/micado/atmosphericmodel',
download_url='https://gitlab.astro-wise.org/micado/atmosphericmodel/-/archive/v1.4/atmosphericmodel-v1.4.tar.gz',
download_url='https://gitlab.astro-wise.org/micado/atmosphericmodel/-/archive/v1.4.1/atmosphericmodel-v1.4.1.tar.gz',
license='GNU General Public License v3',
data_files = [('',['LICENSE.txt'])],
package_dir={'AstroAtmosphere': 'AstroAtmosphere'},