Compare commits

..

2 commits

2 changed files with 6 additions and 7 deletions

View file

@ -13,13 +13,17 @@ class Series(dict):
def __init__(self):
super().__init__()
def intersect(self, series: Self, intersection: SeriesIntersection) -> tuple[float]:
def intersect(self, series: Self, intersection: SeriesIntersection, start: float=None) -> tuple[float]:
pairs = nearest(sorted(self.keys(), reverse=True),
sorted(series.keys(), reverse=True))
for pair in pairs:
v1, v2 = self[pair[0]], series[pair[1]]
if start is not None:
if pair[0] > start:
continue
sign = cmp(v1, v2)
if sign == intersection.value:

View file

@ -185,11 +185,6 @@ class Sounding(DatabaseTable):
return series
def find_el(self, temp: float, pressure: float, temp_line: Series) -> tuple[float]:
moist_adiabat = follow_moist_adiabat(temp, pressure)
return moist_adiabat.intersect(temp_line, SeriesIntersection.LESSER)
def derive_parameters(self) -> SoundingParameters:
temp_line = self.follow_temp()
dry_adiabat = follow_dry_adiabat(self.samples[0].temp,
@ -203,7 +198,7 @@ class Sounding(DatabaseTable):
moist_adiabat = follow_moist_adiabat(*lcl)
lfc = moist_adiabat.intersect(temp_line, SeriesIntersection.GREATER)
el = self.find_el(lfc[0], lfc[1], temp_line)
el = moist_adiabat.intersect(temp_line, SeriesIntersection.LESSER, lfc[1])
params = SoundingParameters()
params.lcl = lcl