Improved quick functions

This commit is contained in:
yosata committed 2022-03-23 08:42:45 +01:00
1 parent 3cdf4ccd39
commit 03d583a9cd
3 files changed
+47 -21

No files matched your search

+40 -14
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()
# Initializing dispersion model
at = Observatory()
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)
# 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()
# Calculating indices of refraction for l
n = at.n_tph(l=l, T=T, p=p, RH=RH, xc=xc)
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()
# 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)
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)