Added Filippenko model, updated B&S refractivity

This commit is contained in:
yosata committed 2020-09-07 21:20:09 +02:00
1 parent cce60766fc
commit 8f9a0bbbea
5 files changed
+268 -91

No files matched your search

+113 -82
View File
@@ -3,12 +3,93 @@ from .ciddorModel import Observatory
from .refractionModels import refraction
from .dispersionModels import dispersion
from .neoslalib import sla_refro
from .observatories import observatories
from .refractivityModels import Edlen1953
import numpy as np
'''
@ Author: Joost van den Born
@ Contact: born@astron.nl
@ Description: Some functions for quick testing.
'''
def get_conditions(location):
'''
Returns the mean conditions at various site. Currently
supported locations:
- 'STANDARD'
- 'CERRO_ARMAZONES'
- 'CERRO_PARANAL'
- 'LA_PALMA'
- 'LA_SILLA'
- 'LAS_CAMPANAS'
- 'MAUNA_KEA'
Parameters
----------
location : string
String denoting the desired location
Returns
-------
observatory : dict
Dictionary containing the atmospheric parameters
'''
observatory = observatories[location]
return observatory
def Filippenko1982(l1, l2, zenith, conditions='STANDARD', T=288.15, p=101325,
RH=0.0, xc=450, lat=0, h=0, f=None):
'''
Calculates the refraction following the 1982 paper by
Alexei V. Filippenko.
The refraction is based on a flat atmosphere and the refractivity
values are calculated from a modified Edlen (1953) equation.
Parameters
----------
l1 : float
Shortest wavelength of interest in micron.
l2 : float
Longest wavelength of interest in micron.
zenith : float
Angle of observation in degrees.
zenith = 0 means the observation is directly overhead.
conditions : string
Refers to the standard conditions of the
observatory. See get_conditions() for more info.
If set to 'None', the conditions specified
after will be used.
T : float (optional)
Temperature in Kelvin
p : float (optional)
Atmospheric pressure in Pa
RH : float (optional)
Relative humidity
xc : float (optional)
CO2 density in parts per million
lat : float (optional)
Latitude of the observer in degrees
h : float (optional)
Altitude of the observer in meters
f : float
Water vapour pressure (default=None). If None, it is
calculated automatically.
Returns
-------
R : float
Atmospheric refraction in degrees
'''
if conditions is not None:
T, p, RH, xc, lat, h, _ = get_conditions(conditions).values()
n1 = Edlen1953(l1, T=T, p=p, RH=RH, f=f)
n2 = Edlen1953(l2, T=T, p=p, RH=RH, f=f)
dR = (n1 - n2) * np.tan(np.deg2rad(zenith))
return np.degrees(dR)
def quick_refractive_index(l, conditions='STANDARD', T=288.15, p=101325,
@@ -23,8 +104,10 @@ def quick_refractive_index(l, conditions='STANDARD', T=288.15, p=101325,
l : float
Wavelength in microns
conditions: string
'STANDARD' or 'CERRO_ARMAZONES', refers
to the standard atmospheric conditions.
Refers to the standard conditions of the
observatory. See get_conditions() for more info.
If set to 'None', the conditions specified
after will be used.
T : float (optional)
Temperature in Kelvin
p : float (optional)
@@ -43,23 +126,8 @@ def quick_refractive_index(l, conditions='STANDARD', T=288.15, p=101325,
n : float
Refractive index for the given conditions.
'''
if conditions == 'STANDARD':
# Parameters at Cerro Armazones
T = 288.15 # k
p = 101325 # Pa
RH = 0.0
xc = 450 # ppm
lat = 0 # degrees
h = 0 # m
elif conditions == 'CERRO_ARMAZONES':
# Parameters at Cerro Armazones
T = 279.65 # k
p = 71200 # Pa
RH = 0.22
xc = 450 # ppm
lat = -24.5983 # degrees
h = 3064 # m
if conditions is not None:
T, p, RH, xc, lat, h, _ = get_conditions(conditions).values()
# Initializing dispersion model
at = Observatory()
@@ -84,8 +152,10 @@ def quick_refraction(l, zenith, conditions='STANDARD', T=288.15, p=101325,
Angle of observation in degrees.
zenith = 0 means the observation is directly overhead.
conditions : string
'STANDARD' or 'CERRO_ARMAZONES', refers
to the standard atmospheric conditions.
Refers to the standard conditions of the
observatory. See get_conditions() for more info.
If set to 'None', the conditions specified
after will be used.
T : float (optional)
Temperature in Kelvin
p : float (optional)
@@ -104,23 +174,8 @@ def quick_refraction(l, zenith, conditions='STANDARD', T=288.15, p=101325,
R : float
Refraction in degrees
'''
if conditions == 'STANDARD':
# Parameters at Cerro Armazones
T = 288.15 # k
p = 101325 # Pa
RH = 0.0
xc = 450 # ppm
lat = 0 # degrees
h = 0 # m
elif conditions == 'CERRO_ARMAZONES':
# Parameters at Cerro Armazones
T = 279.65 # k
p = 71200 # Pa
RH = 0.22
xc = 450 # ppm
lat = -24.5983 # degrees
h = 3064 # m
if conditions is not None:
T, p, RH, xc, lat, h, _ = get_conditions(conditions).values()
# Initializing dispersion model
at = Observatory()
@@ -154,8 +209,10 @@ def quick_dispersion(l1, l2, zenith, conditions='STANDARD', T=288.15,
Angle of observation in degrees.
zenith = 0 means the observation is directly overhead.
conditions : string
'STANDARD' or 'CERRO_ARMAZONES', refers
to the standard atmospheric conditions.
Refers to the standard conditions of the
observatory. See get_conditions() for more info.
If set to 'None', the conditions specified
after will be used.
T : float (optional)
Temperature in Kelvin
p : float (optional)
@@ -174,23 +231,8 @@ def quick_dispersion(l1, l2, zenith, conditions='STANDARD', T=288.15,
dR : float
Atmospheric dispersion in degrees
'''
if conditions == 'STANDARD':
# Parameters at Cerro Armazones
T = 288.15 # k
p = 101325 # Pa
RH = 0.0
xc = 450 # ppm
lat = 0 # degrees
h = 0 # m
elif conditions == 'CERRO_ARMAZONES':
# Parameters at Cerro Armazones
T = 279.65 # k
p = 71200 # Pa
RH = 0.22
xc = 450 # ppm
lat = -24.5983 # degrees
h = 3064 # m
if conditions is not None:
T, p, RH, xc, lat, h, _ = get_conditions(conditions).values()
# Initializing dispersion model
at = Observatory()
@@ -228,8 +270,10 @@ def slalib_refraction(l, zenith, conditions='STANDARD', T=288.15, p=101325,
Angle of observation in degrees.
zenith = 0 means the observation is directly overhead.
conditions : string
'STANDARD' or 'CERRO_ARMAZONES', refers
to the standard atmospheric conditions.
Refers to the standard conditions of the
observatory. See get_conditions() for more info.
If set to 'None', the conditions specified
after will be used.
T : float (optional)
Temperature in Kelvin
p : float (optional)
@@ -245,11 +289,11 @@ def slalib_refraction(l, zenith, conditions='STANDARD', T=288.15, p=101325,
tlr : float
Temperature lapse rate (default=0.0065)
eps : float
Precision at which the calculation is aborted (default=1e-10)
Precision at which the calculation is aborted (default=1e-8)
use_pyslalib : bool
Flag that indicates that the user wants to use the pySlalib
package. If False, the internal python port of the original
FORTRAN code will be used. (Default=False).
FORTRAN code will be used. (default=False).
Returns
-------
@@ -257,23 +301,8 @@ def slalib_refraction(l, zenith, conditions='STANDARD', T=288.15, p=101325,
Refraction in degrees
'''
if conditions == 'STANDARD':
# Parameters at Cerro Armazones
T = 288.15 # k
p = 101325 # Pa
RH = 0.0
xc = 450 # ppm
lat = 0 # degrees
h = 0 # m
elif conditions == 'CERRO_ARMAZONES':
# Parameters at Cerro Armazones
T = 279.65 # k
p = 71200 # Pa
RH = 0.22
xc = 450 # ppm
lat = -24.5983 # degrees
h = 3064 # m
if conditions is not None:
T, p, RH, xc, lat, h, _ = get_conditions(conditions).values()
# Converting units to the units that sla_refro() requires.
_zenith = np.deg2rad(zenith) # From degrees to radians
@@ -326,8 +355,10 @@ def slalib_dispersion(l1, l2, zenith, conditions='STANDARD', T=288.15, p=101325,
Angle of observation in degrees.
zenith = 0 means the observation is directly overhead.
conditions : string
'STANDARD' or 'CERRO_ARMAZONES', refers
to the standard atmospheric conditions.
Refers to the standard conditions of the
observatory. See get_conditions() for more info.
If set to 'None', the conditions specified
after will be used.
T : float (optional)
Temperature in Kelvin
p : float (optional)
@@ -343,11 +374,11 @@ def slalib_dispersion(l1, l2, zenith, conditions='STANDARD', T=288.15, p=101325,
tlr : float
Temperature lapse rate (default=0.0065)
eps : float
Precision at which the calculation is aborted (default=1e-10)
Precision at which the calculation is aborted (default=1e-8)
use_pyslalib : bool
Flag that indicates that the user wants to use the pySlalib
package. If False, the internal python port of the original
FORTRAN code will be used. (Default=False).
FORTRAN code will be used. (default=False).
Returns
-------