Skip to content

Commit

Permalink
conform code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Osamu Miyawaki committed Nov 7, 2023
1 parent e857cc0 commit cefd5e5
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,19 @@ def dt_standard(p, t, params):
def dt_pseudoadiabatic(p, t, params):
rs = saturation_mixing_ratio._nounit(p, t)
frac = ((1 + rs) * (mpconsts.nounit.Rd * t + mpconsts.nounit.Lv * rs)
/ (mpconsts.nounit.Cp_d + rs * mpconsts.nounit.Cv_d
+ (mpconsts.nounit.Lv**2 * rs * (mpconsts.nounit.epsilon + rs)
/ (mpconsts.nounit.Rd * t**2))))
/ (mpconsts.nounit.Cp_d + rs * mpconsts.nounit.Cv_d
+ (mpconsts.nounit.Lv**2 * rs * (mpconsts.nounit.epsilon + rs)
/ (mpconsts.nounit.Rd * t**2))))
return frac / p

def dt_reversible(p, t, params):
rs = saturation_mixing_ratio._nounit(p, t)
rl = params['rt'] - rs # assuming no ice content
frac = ((1 + params['rt']) * (mpconsts.nounit.Rd * t + mpconsts.nounit.Lv * rs)
/ (mpconsts.nounit.Cp_d + rs * mpconsts.nounit.Cv_d
/ (mpconsts.nounit.Cp_d + rs * mpconsts.nounit.Cv_d
+ rl * mpconsts.nounit.Cp_l + (mpconsts.nounit.Lv**2 * rs
* (mpconsts.nounit.epsilon + rs)
/ (mpconsts.nounit.Rd * t**2))))
/ (mpconsts.nounit.Rd * t**2))))
return frac / p

def dt_so13(p, t, params):
Expand All @@ -382,11 +382,11 @@ def dt_so13(p, t, params):
rs = saturation_mixing_ratio._nounit(p, t)
qs = specific_humidity_from_mixing_ratio(rs)
frac = ((mpconsts.nounit.Rd * t + mpconsts.nounit.Lv * qs
+ ep * qs * mpconsts.nounit.Lv * (1 - params['rh0'])
* mpconsts.nounit.Rd * t / mpconsts.nounit.g)
/ (mpconsts.nounit.Cp_d
+ (mpconsts.nounit.Lv**2 * qs * mpconsts.nounit.epsilon
/ (mpconsts.nounit.Rd * t**2))))
+ ep * qs * mpconsts.nounit.Lv * (1 - params['rh0'])
* mpconsts.nounit.Rd * t / mpconsts.nounit.g)
/ (mpconsts.nounit.Cp_d
+ (mpconsts.nounit.Lv**2 * qs * mpconsts.nounit.epsilon
/ (mpconsts.nounit.Rd * t**2))))
# cap lapse rate at dry adiabat (can be steeper with large entrainment rate)
frac = np.min([frac, mpconsts.nounit.Rd * t / mpconsts.nounit.Cp_d])
return frac / p
Expand All @@ -403,12 +403,12 @@ def dt_r14(p, t, params):
rs = saturation_mixing_ratio._nounit(p, t)
qs = specific_humidity_from_mixing_ratio(rs)
a1 = (mpconsts.nounit.Rv * mpconsts.nounit.Cp_d * t**2 / mpconsts.nounit.Lv
+ qs * mpconsts.nounit.Lv )
+ qs * mpconsts.nounit.Lv)
a2 = (mpconsts.nounit.Rv * mpconsts.nounit.Cp_d * t**2 / mpconsts.nounit.Lv
* (de + mpconsts.nounit.g / (mpconsts.nounit.Rd * t))
+ qs * mpconsts.nounit.Lv * (de - ep) - mpconsts.nounit.g)
* (de + mpconsts.nounit.g / (mpconsts.nounit.Rd * t))
+ qs * mpconsts.nounit.Lv * (de - ep) - mpconsts.nounit.g)
a3 = ((mpconsts.nounit.Rv * mpconsts.nounit.Cp_d * t
/ (mpconsts.nounit.Rd * mpconsts.nounit.Lv) - 1) * mpconsts.nounit.g * de)
/ (mpconsts.nounit.Rd * mpconsts.nounit.Lv) - 1) * mpconsts.nounit.g * de)
frac = (mpconsts.nounit.Rd * t / (mpconsts.nounit.g)
* mpconsts.nounit.Rv * t**2 / mpconsts.nounit.Lv
* ((-a2 + np.sqrt(a2**2 - 4 * a1 * a3)) / (2 * a1)
Expand All @@ -427,11 +427,11 @@ def dt_r14(p, t, params):
elif lapse_type == 'reversible':
dt = dt_reversible
# total water at LCL = rs
params = {'rt':saturation_mixing_ratio._nounit(reference_pressure, temperature)}
params = {'rt': saturation_mixing_ratio._nounit(reference_pressure, temperature)}
elif lapse_type == 'so13':
dt = dt_so13
params.update({'h0':mpconsts.nounit.Rd * temperature[0] / mpconsts.nounit.g,
'p0':pressure[0]})
params.update({'h0': mpconsts.nounit.Rd * temperature[0] / mpconsts.nounit.g,
'p0': pressure[0]})
elif lapse_type == 'r14':
dt = dt_r14
else:
Expand All @@ -449,7 +449,7 @@ def dt_r14(p, t, params):

# It would be preferable to use a regular solver like RK45, but as of scipy 1.8.0
# anything other than LSODA goes into an infinite loop when given NaNs for y0.
solver_args = {'fun':lambda p,t:dt(p,t,params), 'y0': temperature,
solver_args = {'fun': lambda p, t: dt(p, t, params), 'y0': temperature,
'method': 'LSODA', 'atol': 1e-7, 'rtol': 1.5e-8}

# Need to handle close points to avoid an error in the solver
Expand Down

0 comments on commit cefd5e5

Please sign in to comment.