@exporter.export
@preprocess_xarray
@check_units('[length]')
def get_layer_heights(heights, depth, *args, bottom=None, interpolate=True, with_agl=False):
    '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 using\n    the heights only.\n\n    Parameters\n    ----------\n    heights : array-like\n        Atmospheric heights\n    depth : `pint.Quantity`\n        The thickness of the layer\n    args : array-like\n        Atmospheric variable(s) measured at the given pressures\n    bottom : `pint.Quantity`, optional\n        The bottom of the layer\n    interpolate : bool, optional\n        Interpolate the top and bottom points if they are not in the given data. Defaults\n        to True.\n    with_agl : bool, optional\n        Returns the heights as above ground level by subtracting the minimum height in the\n        provided heights. Defaults to False.\n\n    Returns\n    -------\n    `pint.Quantity, pint.Quantity`\n        The height and data variables of the layer\n\n    '
    for datavar in args:
        if (len(heights) != len(datavar)):
            raise ValueError('Height and data variables must have the same length.')
    if with_agl:
        sfc_height = np.min(heights)
        heights = (heights - sfc_height)
    if (bottom is None):
        bottom = heights[0]
    heights = heights.to_base_units()
    bottom = bottom.to_base_units()
    top = (bottom + depth)
    ret = []
    sort_inds = np.argsort(heights)
    heights = heights[sort_inds]
    inds = (_greater_or_close(heights, bottom) & _less_or_close(heights, top))
    heights_interp = heights[inds]
    if interpolate:
        if (top not in heights_interp):
            heights_interp = (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)
    ret.append(heights_interp)
    for datavar in args:
        datavar = datavar[sort_inds]
        if interpolate:
            datavar_interp = interpolate_1d(heights_interp, heights, datavar)
            datavar = datavar_interp
        else:
            datavar = datavar[inds]
        ret.append(datavar)
    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 using
the heights only.

Parameters
----------
heights : array-like
    Atmospheric heights
depth : `pint.Quantity`
    The thickness of the layer
args : array-like
    Atmospheric variable(s) measured at the given pressures
bottom : `pint.Quantity`, optional
    The bottom of the layer
interpolate : bool, optional
    Interpolate the top and bottom points if they are not in the given data. Defaults
    to True.
with_agl : bool, optional
    Returns the heights as above ground level by subtracting the minimum height in the
    provided heights. Defaults to False.

Returns
-------
`pint.Quantity, pint.Quantity`
    The height and data variables of the layer
@exporter.export
@preprocess_xarray
@check_units('[length]')
def get_layer_heights(heights, depth, *args, bottom=None, interpolate=True, with_agl=False):
    '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 using\n    the heights only.\n\n    Parameters\n    ----------\n    heights : array-like\n        Atmospheric heights\n    depth : `pint.Quantity`\n        The thickness of the layer\n    args : array-like\n        Atmospheric variable(s) measured at the given pressures\n    bottom : `pint.Quantity`, optional\n        The bottom of the layer\n    interpolate : bool, optional\n        Interpolate the top and bottom points if they are not in the given data. Defaults\n        to True.\n    with_agl : bool, optional\n        Returns the heights as above ground level by subtracting the minimum height in the\n        provided heights. Defaults to False.\n\n    Returns\n    -------\n    `pint.Quantity, pint.Quantity`\n        The height and data variables of the layer\n\n    '
    for datavar in args:
        if (len(heights) != len(datavar)):
            raise ValueError('Height and data variables must have the same length.')
    if with_agl:
        sfc_height = np.min(heights)
        heights = (heights - sfc_height)
    if (bottom is None):
        bottom = heights[0]
    heights = heights.to_base_units()
    bottom = bottom.to_base_units()
    top = (bottom + depth)
    ret = []
    sort_inds = np.argsort(heights)
    heights = heights[sort_inds]
    inds = (_greater_or_close(heights, bottom) & _less_or_close(heights, top))
    heights_interp = heights[inds]
    if interpolate:
        if (top not in heights_interp):
            heights_interp = (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)
    ret.append(heights_interp)
    for datavar in args:
        datavar = datavar[sort_inds]
        if interpolate:
            datavar_interp = interpolate_1d(heights_interp, heights, datavar)
            datavar = datavar_interp
        else:
            datavar = datavar[inds]
        ret.append(datavar)
    return ret