Implement finding equilibrium level
Other changes: * Rework Series.intersect() to return a tuple containing temperature, pressure * Rework other methods returning Series to return a tuple containing temperature, pressure
This commit is contained in:
parent
30a8e15bf6
commit
ebae24b38e
2 changed files with 20 additions and 5 deletions
|
@ -7,7 +7,7 @@ class Series(dict):
|
|||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def intersect(self, series: Self):
|
||||
def intersect(self, series: Self) -> tuple[float]:
|
||||
pairs = nearest(sorted(self.keys(), reverse=True),
|
||||
sorted(series.keys(), reverse=True))
|
||||
|
||||
|
@ -19,6 +19,6 @@ class Series(dict):
|
|||
sign = cmp(v1, v2)
|
||||
|
||||
if sign == 0 or (sign_last is not None and sign_last != sign):
|
||||
return pair[0]
|
||||
return v1, pair[0]
|
||||
|
||||
sign_last = sign
|
||||
|
|
|
@ -185,7 +185,7 @@ class Sounding(DatabaseTable):
|
|||
|
||||
return series
|
||||
|
||||
def find_lfc(self, temp: float, pressure: float) -> float:
|
||||
def find_lfc(self, temp: float, pressure: float) -> tuple[float]:
|
||||
moist_adiabat = follow_moist_adiabat(temp, pressure)
|
||||
temp_line = self.follow_temp()
|
||||
|
||||
|
@ -196,7 +196,20 @@ class Sounding(DatabaseTable):
|
|||
v1, v2 = moist_adiabat[pair[0]], temp_line[pair[1]]
|
||||
|
||||
if v1 > v2:
|
||||
return pair[0]
|
||||
return v1, pair[0]
|
||||
|
||||
def find_el(self, temp: float, pressure: float) -> tuple[float]:
|
||||
moist_adiabat = follow_moist_adiabat(temp, pressure)
|
||||
temp_line = self.follow_temp()
|
||||
|
||||
pairs = nearest(sorted(moist_adiabat.keys(), reverse=True),
|
||||
sorted(temp_line.keys(), reverse=True))
|
||||
|
||||
for pair in pairs:
|
||||
v1, v2 = moist_adiabat[pair[0]], temp_line[pair[1]]
|
||||
|
||||
if v1 < v2:
|
||||
return v1, pair[0]
|
||||
|
||||
def derive_parameters(self) -> SoundingParameters:
|
||||
dry_adiabat = follow_dry_adiabat(self.samples[0].temp,
|
||||
|
@ -206,10 +219,12 @@ class Sounding(DatabaseTable):
|
|||
self.samples[0].pressure)
|
||||
|
||||
lcl = dry_adiabat.intersect(saturated_mr_line)
|
||||
lfc = self.find_lfc(dry_adiabat[lcl], lcl)
|
||||
lfc = self.find_lfc(lcl[0], lcl[1])
|
||||
el = self.find_el(lfc[0], lfc[1])
|
||||
|
||||
params = SoundingParameters()
|
||||
params.lcl = lcl
|
||||
params.lfc = lfc
|
||||
params.el = el
|
||||
|
||||
return params
|
||||
|
|
Loading…
Add table
Reference in a new issue