Compare commits
No commits in common. "57ce901c01e823e80adb6bafe1ca3cda20944d88" and "d9761de7b409ce43c17dfa270b6a17720ad2f9aa" have entirely different histories.
57ce901c01
...
d9761de7b4
2 changed files with 17 additions and 24 deletions
|
@ -13,7 +13,8 @@ from xmet.thermo import follow_dry_adiabat, \
|
|||
pressure_height, \
|
||||
virtual_temp, \
|
||||
kelvin, \
|
||||
wind_uv
|
||||
wind_u, \
|
||||
wind_v
|
||||
|
||||
from xmet.units import deg
|
||||
|
||||
|
@ -212,17 +213,11 @@ class Sounding(DatabaseTable):
|
|||
s1 = self.samples[level]
|
||||
s2 = self.samples[level+1]
|
||||
|
||||
u1, v1 = wind_uv(s1.wind_speed, s1.wind_dir)
|
||||
u2, v2 = wind_uv(s2.wind_speed, s2.wind_dir)
|
||||
u1 = wind_u(s1.wind_speed, s1.wind_dir)
|
||||
u2 = wind_u(s2.wind_speed, s2.wind_dir)
|
||||
|
||||
return abs(u2 - u1), abs(v2 - v1)
|
||||
|
||||
def shear_magnitude(self, level: int):
|
||||
s1 = self.samples[level]
|
||||
s2 = self.samples[level+1]
|
||||
|
||||
u1, v1 = wind_uv(s1.wind_speed, s1.wind_dir)
|
||||
u2, v2 = wind_uv(s2.wind_speed, s2.wind_dir)
|
||||
v1 = wind_v(s1.wind_speed, s1.wind_dir)
|
||||
v2 = wind_v(s2.wind_speed, s2.wind_dir)
|
||||
|
||||
zd = s2.height - s1.height
|
||||
|
||||
|
@ -237,18 +232,18 @@ class Sounding(DatabaseTable):
|
|||
def bulk_shear(self):
|
||||
levels = len(self.samples) - 1
|
||||
|
||||
shear_u = 0.0
|
||||
shear_v = 0.0
|
||||
shear_speed = 0.0
|
||||
shear_dir = 0.0
|
||||
|
||||
for level in range(0, levels):
|
||||
shear = self.shear(level)
|
||||
|
||||
shear_u += shear[0]
|
||||
shear_v += shear[1]
|
||||
shear_speed += shear[0]
|
||||
shear_dir += shear[1]
|
||||
|
||||
return (
|
||||
shear_u / levels,
|
||||
shear_v / levels
|
||||
shear_speed / levels,
|
||||
shear_dir / levels
|
||||
)
|
||||
|
||||
def between(n, a, b):
|
||||
|
|
|
@ -5,8 +5,7 @@ from typing import Callable
|
|||
from xmet.series import Series
|
||||
from xmet.units import rad, deg, kelvin, celsius
|
||||
|
||||
LAPSE_RATE_DRY = 9.8 / 1000 # degrees C per km
|
||||
LAPSE_RATE_MAGIC_FACTOR = 1.09 # adjustment for accuracy
|
||||
LAPSE_RATE_DRY = 9.8 / 1000 # degrees C per km
|
||||
|
||||
PRESSURE_MAX = 1050 # millibar
|
||||
PRESSURE_MSL = 1013.25
|
||||
|
@ -131,8 +130,7 @@ def loft_parcel(start_temp: float,
|
|||
except OverflowError:
|
||||
break
|
||||
|
||||
temp = lapse(temp, height - last_height,
|
||||
LAPSE_RATE_MAGIC_FACTOR*rate)
|
||||
temp = lapse(temp, height - last_height, 1.09*rate)
|
||||
|
||||
yield temp, pressure
|
||||
|
||||
|
@ -194,10 +192,10 @@ def follow_saturated_mixing_ratio(temp: float, pressure: float, step: float=1.0)
|
|||
return series
|
||||
|
||||
def wind_u(speed: float, direction: float) -> float:
|
||||
return math.cos(rad(direction)) * speed
|
||||
return speed * math.cos(rad(direction))
|
||||
|
||||
def wind_v(speed: float, direction: float) -> float:
|
||||
return math.sin(rad(direction)) * -speed
|
||||
return -speed * math.sin(rad(direction))
|
||||
|
||||
def wind_uv(speed: float, direction: float) -> float:
|
||||
return (
|
||||
|
@ -208,5 +206,5 @@ def wind_uv(speed: float, direction: float) -> float:
|
|||
def wind_speed_dir(u: float, v: float) -> float:
|
||||
return (
|
||||
math.sqrt(u**2 + v**2),
|
||||
(deg(math.atan2(v, u)) - 180) % 360
|
||||
(180 - deg(math.atan2(v, u))) % 360
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue