code: def precipitable_water(dewpt, pressure, bottom=None, top=None):
      r
      # 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]
  
      if top is None:
          top = np.nanmin(pressure) * pressure.units
  
      if bottom is None:
          bottom = np.nanmax(pressure) * 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')
docs: r"""Calculate precipitable water through the depth of a sounding.
  
      Formula used is:
  
      .. math::  -\frac{1}{\rho_l g} \int\limits_{p_\text{bottom}}^{p_\text{top}} r dp
  
      from [Salby1996]_, p. 28.
  
      Parameters
      ----------
      dewpt : `pint.Quantity`
          Atmospheric dewpoint profile
      pressure : `pint.Quantity`
          Atmospheric pressure profile
      bottom: `pint.Quantity`, optional
          Bottom of the layer, specified in pressure. Defaults to None (highest pressure).
      top: `pint.Quantity`, optional
          The top of the layer, specified in pressure. Defaults to None (lowest pressure).
  
      Returns
      -------
      `pint.Quantity`
          The precipitable water in the layer