Skip to content

Commit

Permalink
Fixed N2 absorption part, added docstrings for the new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MDS-007-52 committed Jul 24, 2024
1 parent 6c513dc commit 8a9a8d6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
42 changes: 36 additions & 6 deletions pyrtlib/absorption_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,24 @@ def liquid_water_absorption(water: np.ndarray, freq: np.ndarray, temp: np.ndarra
class N2AbsModel(AbsModel):
"""This class contains the absorption model used in pyrtlib.
"""

def n2_absor_mwl24(self, f, p, t):
"""
Calculation of the collision-induced absorption by N2-N2 molecular pairs
Based on the Classic Trajectory Calcs by Vigasin/Chistikov/Finenko
Args:
f (float): frequency (Ghz)
p (float): dry air pressure (mbar) (recalculations to Torr are used inside)
t (float): air temperature (K)
Returns:
float: N2-N2 absorption coefficient in 1/cm
@staticmethod
Convert to Np/km by multiplying by 1.E5
Convert to dry air absorption by multiplying by 0.84 (see [Meshkov, DeLucia 2007 10.1016/j.jqsrt.2007.04.001])
def n2_absor_mwl24(self, f, p, t):
References:
[Serov et al, JQSRT 2024]
"""
t0 = 300.
ti = t0 / t
p_torr = p * 0.7500616827
Expand Down Expand Up @@ -230,7 +244,7 @@ def n2_absor_mwl24(self, f, p, t):
t_dep = ti ** (m0 + aa * np.log(ti))

return spec_fun * t_dep * potential * p_torr**2 * f**2

def n2_absorption(self, t: np.ndarray, p: np.ndarray, f: np.ndarray) -> np.ndarray:
"""Collision-Induced Power Absorption Coefficient (Neper/km) in air
with modification of 1.34 to account for O2-O2 and O2-N2 collisions, as calculated by [Boissoles-2003]_.
Expand Down Expand Up @@ -269,8 +283,9 @@ def n2_absorption(self, t: np.ndarray, p: np.ndarray, f: np.ndarray) -> np.ndarr
else:
raise ValueError(
'[AbsN2] No model available with this name: {} . Sorry...'.format(N2AbsModel.model))

if N2AbsModel.model == 'MWL24':
bf = self.n2_absor_mwl24(self, f=f, p=p, t=t) * 1.E5
bf = self.n2_absor_mwl24(f, p, t) * 1.E5
else:
bf = l * fdepen * p * p * f * f * th ** m

Expand Down Expand Up @@ -331,11 +346,26 @@ def h2o_continuum(self, frq: np.ndarray, vx: np.ndarray, nfreq: int):
b = 0.5*p*(1.-p)
b1 = b*(1.-p)
b2 = b*p
cs[i] = -a[j]*b1+a[j+1]*(1.-c+b2)+a[j+2]*(c+b1)-a[j+3]*b2
# print('h2o_continuum called')
cs[i] = -a[j]*b1+a[j+1]*(1.-c+b2)+a[j+2]*(c+b1)-a[j+3]*b2
return cs

def h2o_continuum_mwl24(self, frq: np.ndarray, vx: np.ndarray):
"""
H2O self-continuum absorption normalized to the squared water vapor pressure (1/cm)/mbar**2
Based on the known measurements meta-analysis and theoretical calculations
Args:
frq (float): Frequency (GHz)
vx (float): Theta (adim) - (normalised temperature 300/t(K))
Returns:
float: self-continuum term ((1/cm)/mbar**2), multiply by pvap**2 * 1.E5 to get Np/km
Reference:
[Tretyakov, Galanina, Koroleva et al 2024] (not published currently)
[Odintsova 2022 10.1016/j.jms.2022.111603]
[Galanina 2022 10.1016/j.jms.2022.111691]
"""

atm2mbar = 1013.25
t = 300.0 / vx
Expand Down
2 changes: 1 addition & 1 deletion pyrtlib/rt_equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def clearsky_absorption(p: np.ndarray, t: np.ndarray, e: np.ndarray, frq: np.nda
aO2[i] = factor * (npp + ncpp) * db2np
# add N2 term
if N2AbsModel.model not in ['R03', 'R16', 'R17', 'R18', 'R98']:
aN2[i] = N2AbsModel.n2_absorption(
aN2[i] = N2AbsModel().n2_absorption(
t[i], np.dot(pdrykpa, 10), frq)

if not N2AbsModel.model:
Expand Down

0 comments on commit 8a9a8d6

Please sign in to comment.