@exporter.export
@preprocess_xarray
@check_units('[pressure]')
def get_layer(pressure, *args, heights=None, bottom=None, depth=(100 * units.hPa), interpolate=True):
    'Return an atmospheric layer from upper air data with the requested bottom and depth.\n\n    This function will subset an upper air dataset to contain only the specified layer. The\n    bottom of the layer can be specified with a pressure or height above the surface\n    pressure. The bottom defaults to the surface pressure. The depth of the layer can be\n    specified in terms of pressure or height above the bottom of the layer. If the top and\n    bottom of the layer are not in the data, they are interpolated by default.\n\n    Parameters\n    ----------\n    pressure : array-like\n        Atmospheric pressure profile\n    args : array-like\n        Atmospheric variable(s) measured at the given pressures\n    heights: array-like, optional\n        Atmospheric heights corresponding to the given pressures. Defaults to using\n        heights calculated from ``p`` assuming a standard atmosphere [NOAA1976]_.\n    bottom : `pint.Quantity`, optional\n        The bottom of the layer as a pressure or height above the surface pressure. Defaults\n        to the highest pressure or lowest height given.\n    depth : `pint.Quantity`, optional\n        The thickness of the layer as a pressure or height above the bottom of the layer.\n        Defaults to 100 hPa.\n    interpolate : bool, optional\n        Interpolate the top and bottom points if they are not in the given data. Defaults\n        to True.\n\n    Returns\n    -------\n    `pint.Quantity, pint.Quantity`\n        The pressure and data variables of the layer\n\n    '
    if (depth is None):
        depth = (100 * units.hPa)
    for datavar in args:
        if (len(pressure) != len(datavar)):
            raise ValueError('Pressure and data variables must have the same length.')
    if (bottom is None):
        bottom = (np.nanmax(pressure.m) * pressure.units)
    (bottom_pressure, bottom_height) = _get_bound_pressure_height(pressure, bottom, heights=heights, interpolate=interpolate)
    if (depth.dimensionality == {'[length]': (- 1.0), '[mass]': 1.0, '[time]': (- 2.0)}):
        top = (bottom_pressure - depth)
    elif (depth.dimensionality == {'[length]': 1}):
        top = (bottom_height + depth)
    else:
        raise ValueError('Depth must be specified in units of length or pressure')
    (top_pressure, _) = _get_bound_pressure_height(pressure, top, heights=heights, interpolate=interpolate)
    ret = []
    sort_inds = np.argsort(pressure)
    pressure = pressure[sort_inds]
    inds = (_less_or_close(pressure, bottom_pressure) & _greater_or_close(pressure, top_pressure))
    p_interp = pressure[inds]
    if interpolate:
        if (not np.any(np.isclose(top_pressure, p_interp))):
            p_interp = (np.sort(np.append(p_interp.m, top_pressure.m)) * pressure.units)
        if (not np.any(np.isclose(bottom_pressure, p_interp))):
            p_interp = (np.sort(np.append(p_interp.m, bottom_pressure.m)) * pressure.units)
    ret.append(p_interp[::(- 1)])
    for datavar in args:
        datavar = datavar[sort_inds]
        if interpolate:
            datavar_interp = log_interpolate_1d(p_interp, pressure, datavar)
            datavar = datavar_interp
        else:
            datavar = datavar[inds]
        ret.append(datavar[::(- 1)])
    return ret
Return an atmospheric layer from upper air data with the requested bottom and depth.

This function will subset an upper air dataset to contain only the specified layer. The
bottom of the layer can be specified with a pressure or height above the surface
pressure. The bottom defaults to the surface pressure. The depth of the layer can be
specified in terms of pressure or height above the bottom of the layer. If the top and
bottom of the layer are not in the data, they are interpolated by default.

Parameters
----------
pressure : array-like
    Atmospheric pressure profile
args : array-like
    Atmospheric variable(s) measured at the given pressures
heights: array-like, optional
    Atmospheric heights corresponding to the given pressures. Defaults to using
    heights calculated from ``p`` assuming a standard atmosphere [NOAA1976]_.
bottom : `pint.Quantity`, optional
    The bottom of the layer as a pressure or height above the surface pressure. Defaults
    to the highest pressure or lowest height given.
depth : `pint.Quantity`, optional
    The thickness of the layer as a pressure or height above the bottom of the layer.
    Defaults to 100 hPa.
interpolate : bool, optional
    Interpolate the top and bottom points if they are not in the given data. Defaults
    to True.

Returns
-------
`pint.Quantity, pint.Quantity`
    The pressure and data variables of the layer
@exporter.export
@preprocess_xarray
@check_units('[pressure]')
def get_layer(pressure, *args, heights=None, bottom=None, depth=(100 * units.hPa), interpolate=True):
    'Return an atmospheric layer from upper air data with the requested bottom and depth.\n\n    This function will subset an upper air dataset to contain only the specified layer. The\n    bottom of the layer can be specified with a pressure or height above the surface\n    pressure. The bottom defaults to the surface pressure. The depth of the layer can be\n    specified in terms of pressure or height above the bottom of the layer. If the top and\n    bottom of the layer are not in the data, they are interpolated by default.\n\n    Parameters\n    ----------\n    pressure : array-like\n        Atmospheric pressure profile\n    args : array-like\n        Atmospheric variable(s) measured at the given pressures\n    heights: array-like, optional\n        Atmospheric heights corresponding to the given pressures. Defaults to using\n        heights calculated from ``p`` assuming a standard atmosphere [NOAA1976]_.\n    bottom : `pint.Quantity`, optional\n        The bottom of the layer as a pressure or height above the surface pressure. Defaults\n        to the highest pressure or lowest height given.\n    depth : `pint.Quantity`, optional\n        The thickness of the layer as a pressure or height above the bottom of the layer.\n        Defaults to 100 hPa.\n    interpolate : bool, optional\n        Interpolate the top and bottom points if they are not in the given data. Defaults\n        to True.\n\n    Returns\n    -------\n    `pint.Quantity, pint.Quantity`\n        The pressure and data variables of the layer\n\n    '
    if (depth is None):
        depth = (100 * units.hPa)
    for datavar in args:
        if (len(pressure) != len(datavar)):
            raise ValueError('Pressure and data variables must have the same length.')
    if (bottom is None):
        bottom = (np.nanmax(pressure.m) * pressure.units)
    (bottom_pressure, bottom_height) = _get_bound_pressure_height(pressure, bottom, heights=heights, interpolate=interpolate)
    if (depth.dimensionality == {'[length]': (- 1.0), '[mass]': 1.0, '[time]': (- 2.0)}):
        top = (bottom_pressure - depth)
    elif (depth.dimensionality == {'[length]': 1}):
        top = (bottom_height + depth)
    else:
        raise ValueError('Depth must be specified in units of length or pressure')
    (top_pressure, _) = _get_bound_pressure_height(pressure, top, heights=heights, interpolate=interpolate)
    ret = []
    sort_inds = np.argsort(pressure)
    pressure = pressure[sort_inds]
    inds = (_less_or_close(pressure, bottom_pressure) & _greater_or_close(pressure, top_pressure))
    p_interp = pressure[inds]
    if interpolate:
        if (not np.any(np.isclose(top_pressure, p_interp))):
            p_interp = (np.sort(np.append(p_interp.m, top_pressure.m)) * pressure.units)
        if (not np.any(np.isclose(bottom_pressure, p_interp))):
            p_interp = (np.sort(np.append(p_interp.m, bottom_pressure.m)) * pressure.units)
    ret.append(p_interp[::(- 1)])
    for datavar in args:
        datavar = datavar[sort_inds]
        if interpolate:
            datavar_interp = log_interpolate_1d(p_interp, pressure, datavar)
            datavar = datavar_interp
        else:
            datavar = datavar[inds]
        ret.append(datavar[::(- 1)])
    return ret