Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removals of all deprecated stuff #1286

Merged
merged 9 commits into from
Jan 11, 2020
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ build: off

test_script:
- cmd: set TEST_DATA_DIR=%APPVEYOR_BUILD_FOLDER%\\staticdata
- cmd: pytest -s --junitxml=tests.xml --flake8 --mpl --cov=metpy -W error::metpy.deprecation.MetpyDeprecationWarning
- cmd: pytest -s --junitxml=tests.xml --flake8 --mpl --cov=metpy --cov=tests -W error::metpy.deprecation.MetpyDeprecationWarning
- cmd: cd docs
- cmd: make overridecheck html
- cmd: cd ..
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ before_install:
export EXTRA_PACKAGES="$EXTRA_PACKAGES flake8-bugbear";
fi;
if [[ $TASK == "coverage" ]]; then
export TEST_OPTS="$TEST_OPTS --cov=metpy";
export TEST_OPTS="$TEST_OPTS --cov=metpy --cov=tests";
export EXTRA_PACKAGES="$EXTRA_PACKAGES pytest-cov";
fi;
fi;
Expand Down
11 changes: 0 additions & 11 deletions docs/_templates/overrides/metpy.calc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,3 @@ Other
resample_nn_1d
smooth_gaussian
smooth_n_point


Deprecated
----------

Do not use these functions in new code, please see their documentation for their replacements.

.. autosummary::
:toctree: ./

dewpoint_rh
2 changes: 1 addition & 1 deletion docs/startingguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ To demonstrate some of the calculations MetPy can do, let's show a simple exampl

temperature = [20] * units.degC
rel_humidity = [50] * units.percent
print(dewpoint_rh(temperature, rel_humidity))
print(mpcalc.dewpoint_from_relative_humidity(temperature, rel_humidity))

.. parsed-literal::

Expand Down
18 changes: 9 additions & 9 deletions examples/isentropic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@
# levels, and temperature be input. Any additional inputs (in this case relative humidity, u,
# and v wind components) will be linearly interpolated to isentropic space.

isent_anal = mpcalc.isentropic_interpolation(isentlevs,
lev,
tmp,
spech,
uwnd,
vwnd,
hgt,
tmpk_out=True)
isent_ana = mpcalc.isentropic_interpolation(isentlevs,
lev,
tmp,
spech,
uwnd,
vwnd,
hgt,
temperature_out=True)

#####################################
# The output is a list, so now we will separate the variables to different names before
# plotting.

isentprs, isenttmp, isentspech, isentu, isentv, isenthgt = isent_anal
isentprs, isenttmp, isentspech, isentu, isentv, isenthgt = isent_ana
isentu.ito('kt')
isentv.ito('kt')

Expand Down
6 changes: 3 additions & 3 deletions examples/meteogram_metpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import matplotlib.pyplot as plt
import numpy as np

from metpy.calc import dewpoint_rh
from metpy.calc import dewpoint_from_relative_humidity
from metpy.cbook import get_test_data
from metpy.plots import add_metpy_logo
from metpy.units import units
Expand Down Expand Up @@ -201,8 +201,8 @@ def parse_date(date):
data = {'wind_speed': (np.array(ws) * units('m/s')).to(units('knots')),
'wind_speed_max': (np.array(wsmax) * units('m/s')).to(units('knots')),
'wind_direction': np.array(wd) * units('degrees'),
'dewpoint': dewpoint_rh((np.array(temp) * units('degC')).to(units('K')),
np.array(rh) / 100.).to(units('degF')),
'dewpoint': dewpoint_from_relative_humidity((np.array(temp) * units.degC).to(units.K),
np.array(rh) / 100.).to(units('degF')),
'air_temperature': (np.array(temp) * units('degC')).to(units('degF')),
'mean_slp': calc_mslp(np.array(temp), np.array(pres), hgt_example) * units('hPa'),
'relative_humidity': np.array(rh), 'times': np.array(date)}
Expand Down
42 changes: 29 additions & 13 deletions src/metpy/calc/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
"""Contains calculation of various derived indices."""
import warnings

import numpy as np

from .tools import get_layer
from .thermo import mixing_ratio, saturation_vapor_pressure
from .tools import _remove_nans, get_layer
from .. import constants as mpconsts
from ..package_tools import Exporter
from ..units import atleast_1d, check_units, concatenate, units
from ..xarray import preprocess_xarray
Expand All @@ -16,8 +16,8 @@

@exporter.export
@preprocess_xarray
@check_units('[temperature]', '[pressure]', '[pressure]')
def precipitable_water(dewpt, pressure, bottom=None, top=None):
@check_units('[pressure]', '[temperature]', bottom='[pressure]', top='[pressure]')
def precipitable_water(pressure, dewpt, *, bottom=None, top=None):
r"""Calculate precipitable water through the depth of a sounding.

Formula used is:
Expand All @@ -28,10 +28,10 @@ def precipitable_water(dewpt, pressure, bottom=None, top=None):

Parameters
----------
dewpt : `pint.Quantity`
Atmospheric dewpoint profile
pressure : `pint.Quantity`
Atmospheric pressure profile
dewpt : `pint.Quantity`
Atmospheric dewpoint profile
bottom: `pint.Quantity`, optional
Bottom of the layer, specified in pressure. Defaults to None (highest pressure).
top: `pint.Quantity`, optional
Expand All @@ -46,14 +46,30 @@ def precipitable_water(dewpt, pressure, bottom=None, top=None):
--------
>>> pressure = np.array([1000, 950, 900]) * units.hPa
>>> dewpoint = np.array([20, 15, 10]) * units.degC
>>> pw = precipitable_water(dewpoint, pressure)
>>> pw = precipitable_water(pressure, dewpoint)

"""
warnings.warn('Input variables will be reordered in 1.0 to be (pressure, dewpt, bottom,'
'top). To update to new input format before 1.0 is released, use'
'`from metpy.future import precipitable_water`.', FutureWarning)
from ..future import precipitable_water as _precipitable_water
return _precipitable_water(pressure, dewpt, bottom=bottom, top=top)
# Sort pressure and dewpoint to be in decreasing pressure order (increasing height)
sort_inds = np.argsort(pressure)[::-1]
pressure = pressure[sort_inds]
dewpt = dewpt[sort_inds]

pressure, dewpt = _remove_nans(pressure, dewpt)

if top is None:
top = np.nanmin(pressure.magnitude) * pressure.units

if bottom is None:
bottom = np.nanmax(pressure.magnitude) * pressure.units

pres_layer, dewpt_layer = get_layer(pressure, dewpt, bottom=bottom, depth=bottom - top)

w = mixing_ratio(saturation_vapor_pressure(dewpt_layer), pres_layer)

# Since pressure is in decreasing order, pw will be the opposite sign of that expected.
pw = -1. * (np.trapz(w.magnitude, pres_layer.magnitude) * (w.units * pres_layer.units)
/ (mpconsts.g * mpconsts.rho_l))
return pw.to('millimeters')


@exporter.export
Expand Down
64 changes: 38 additions & 26 deletions src/metpy/calc/kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
# SPDX-License-Identifier: BSD-3-Clause
"""Contains calculation of kinematic parameters (e.g. divergence or vorticity)."""
import functools
import warnings

import numpy as np

from . import coriolis_parameter
from .tools import first_derivative, gradient
from .tools import first_derivative, get_layer_heights, gradient
from .. import constants as mpconsts
from ..cbook import iterable
from ..package_tools import Exporter
Expand Down Expand Up @@ -447,14 +446,20 @@ def geostrophic_wind(heights, f, dx, dy):


@exporter.export
@check_units(f='[frequency]', dx='[length]', dy='[length]', u='[speed]', v='[speed]')
def ageostrophic_wind(heights, f, dx, dy, u, v, dim_order='yx'):
@preprocess_xarray
@ensure_yx_order
@check_units(f='[frequency]', u='[speed]', v='[speed]', dx='[length]', dy='[length]')
def ageostrophic_wind(heights, u, v, f, dx, dy, dim_order='yx'):
r"""Calculate the ageostrophic wind given from the heights or geopotential.

Parameters
----------
heights : (M, N) ndarray
The height or geopotential field.
u : (M, N) `pint.Quantity`
The u wind field.
v : (M, N) `pint.Quantity`
The u wind field.
f : array_like
The coriolis parameter. This can be a scalar to be applied
everywhere or an array of values.
Expand All @@ -464,30 +469,24 @@ def ageostrophic_wind(heights, f, dx, dy, u, v, dim_order='yx'):
dy : `pint.Quantity`
The grid spacing(s) in the y-direction. If an array, there should be one item less than
the size of `heights` along the applicable axis.
u : (M, N) `pint.Quantity`
The u wind field.
v : (M, N) `pint.Quantity`
The u wind field.

Returns
-------
A 2-item tuple of arrays, `pint.Quantity`
A 2-item tuple of arrays
A tuple of the u-component and v-component of the ageostrophic wind.

Notes
-----
If inputs have more than two dimensions, they are assumed to have either leading dimensions
of (x, y) or trailing dimensions of (y, x), depending on the value of ``dim_order``.

The order of the inputs will be changed in 1.0 to be (heights, u, v, f, dx, dy).
To updated to the new format, use `from metpy.future import ageostrophic_wind`.
This function contains an updated input variable order from the same function in the
kinematics module. This version will be fully implemented in 1.0 and moved from the
`future` module back to the `kinematics` module.

"""
warnings.warn('Input variables will be reordered in 1.0 to be (heights, u, v, f, dx, dy).'
'To update to new input format before 1.0 is released, use'
'`from metpy.future import ageostrophic_wind`.', FutureWarning)
from ..future import ageostrophic_wind as _ageostrophic_wind
return _ageostrophic_wind(heights, u, v, f, dx, dy, dim_order=dim_order)
u_geostrophic, v_geostrophic = geostrophic_wind(heights, f, dx, dy, dim_order=dim_order)
return u - u_geostrophic, v - v_geostrophic


@exporter.export
Expand Down Expand Up @@ -534,9 +533,9 @@ def montgomery_streamfunction(height, temperature):

@exporter.export
@preprocess_xarray
@check_units('[speed]', '[speed]', '[length]', '[length]', '[length]',
'[speed]', '[speed]')
def storm_relative_helicity(u, v, heights, depth, bottom=0 * units.m,
@check_units('[length]', '[speed]', '[speed]', '[length]',
bottom='[length]', storm_u='[speed]', storm_v='[speed]')
def storm_relative_helicity(heights, u, v, depth, *, bottom=0 * units.m,
storm_u=0 * units('m/s'), storm_v=0 * units('m/s')):
# Partially adapted from similar SharpPy code
r"""Calculate storm relative helicity.
Expand Down Expand Up @@ -577,13 +576,26 @@ def storm_relative_helicity(u, v, heights, depth, bottom=0 * units.m,
total storm-relative helicity

"""
warnings.warn('Input variables will be reordered in 1.0 to be (heights, u, v, depth, '
'bottom, storm_u, storm_v). To update to new input format before 1.0 is '
'released, use `from metpy.future import storm_relative_helicity`.',
FutureWarning)
from ..future import storm_relative_helicity as _storm_relative_helicity
return _storm_relative_helicity(heights, u, v, depth,
bottom=bottom, storm_u=storm_u, storm_v=storm_v)
_, u, v = get_layer_heights(heights, depth, u, v, with_agl=True, bottom=bottom)

storm_relative_u = u - storm_u
storm_relative_v = v - storm_v

int_layers = (storm_relative_u[1:] * storm_relative_v[:-1]
- storm_relative_u[:-1] * storm_relative_v[1:])

# Need to manually check for masked value because sum() on masked array with non-default
# mask will return a masked value rather than 0. See numpy/numpy#11736
positive_srh = int_layers[int_layers.magnitude > 0.].sum()
if np.ma.is_masked(positive_srh):
positive_srh = 0.0 * units('meter**2 / second**2')
negative_srh = int_layers[int_layers.magnitude < 0.].sum()
if np.ma.is_masked(negative_srh):
negative_srh = 0.0 * units('meter**2 / second**2')

return (positive_srh.to('meter ** 2 / second ** 2'),
negative_srh.to('meter ** 2 / second ** 2'),
(positive_srh + negative_srh).to('meter ** 2 / second ** 2'))


@exporter.export
Expand Down
26 changes: 0 additions & 26 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
find_intersections, first_derivative, get_layer)
from .. import constants as mpconsts
from ..cbook import broadcast_indices
from ..deprecation import deprecated, metpyDeprecation
from ..interpolate.one_dimension import interpolate_1d
from ..package_tools import Exporter
from ..units import atleast_1d, check_units, concatenate, units
Expand Down Expand Up @@ -829,22 +828,6 @@ def dewpoint_from_relative_humidity(temperature, rh):
return dewpoint(rh * saturation_vapor_pressure(temperature))


@exporter.export
@preprocess_xarray
@deprecated('0.12', addendum=(' This function has been renamed '
'dewpoint_from_relative_humidity.'),
pending=False)
def dewpoint_rh(temperature, rh):
"""Wrap dewpoint_from_relative_humidity for deprecated dewpoint_rh function."""
return dewpoint_from_relative_humidity(temperature, rh)


dewpoint_rh.__doc__ = (dewpoint_from_relative_humidity.__doc__
+ '\n .. deprecated:: 0.12.0\n Function has been renamed to'
' `dewpoint_from_relative_humidity` and will be removed from MetPy '
'in 1.0.0.')


@exporter.export
@preprocess_xarray
@check_units('[pressure]')
Expand Down Expand Up @@ -1702,9 +1685,6 @@ def isentropic_interpolation(theta_levels, pressure, temperature, *args, axis=0,
[Ziv1994]_. Any additional arguments are assumed to vary linearly with temperature and will
be linearly interpolated to the new isentropic levels.

`isentropic_interpolation` previously accepted `tmpk_out` as an argument. That has been
deprecated in 0.11 in favor of `temperature_out` and support will end in 1.0.

See Also
--------
potential_temperature
Expand All @@ -1720,12 +1700,6 @@ def _isen_iter(iter_log_p, isentlevs_nd, ka, a, b, pok):
fp = exner * (ka * t - a)
return iter_log_p - (f / fp)

# Remove block when tmpk_out is removed in 1.0
if 'tmpk_out' in kwargs:
temperature_out = kwargs.get('tmpk_out')
warnings.warn('The use of "tmpk_out" has been deprecated in favor of'
'"temperature_out",', metpyDeprecation)

# Get dimensions in temperature
ndim = temperature.ndim

Expand Down