Skip to content

Commit

Permalink
MNT: Use more Quantity() for creation
Browse files Browse the repository at this point in the history
This is more robust for masked arrays, etc. with pint master than using
multiplication.
  • Loading branch information
dopplershift committed Jan 5, 2020
1 parent af91744 commit 8b2fec1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ def _parcel_profile_helper(pressure, temperature, dewpt):

# If the pressure profile doesn't make it to the lcl, we can stop here
if _greater_or_close(np.nanmin(pressure.m), press_lcl.m):
return (press_lower[:-1], press_lcl, np.array([]) * press_lower.units,
temp_lower[:-1], temp_lcl, np.array([]) * temp_lower.units)
return (press_lower[:-1], press_lcl, units.Quantity(np.array([]), press_lower.units),
temp_lower[:-1], temp_lcl, units.Quantity(np.array([]), temp_lower.units))

# Find moist pseudo-adiabatic profile starting at the LCL
press_upper = concatenate((press_lcl, pressure[pressure < press_lcl]))
Expand Down
6 changes: 4 additions & 2 deletions src/metpy/calc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,11 @@ def get_layer_heights(heights, depth, *args, bottom=None, interpolate=True, with
if interpolate:
# If we don't have the bottom or top requested, append them
if top not in heights_interp:
heights_interp = np.sort(np.append(heights_interp.m, top.m)) * heights.units
heights_interp = units.Quantity(np.sort(np.append(heights_interp.m, top.m)),
heights.units)
if bottom not in heights_interp:
heights_interp = np.sort(np.append(heights_interp.m, bottom.m)) * heights.units
heights_interp = units.Quantity(np.sort(np.append(heights_interp.m, bottom.m)),
heights.units)

ret.append(heights_interp)

Expand Down

0 comments on commit 8b2fec1

Please sign in to comment.