code: def mean_pressure_weighted(pressure, *args, **kwargs):
      r
      heights = kwargs.pop('heights', None)
      bottom = kwargs.pop('bottom', None)
      depth = kwargs.pop('depth', None)
      ret = []  # Returned variable means in layer
      layer_arg = get_layer(pressure, *args, heights=heights,
                            bottom=bottom, depth=depth)
      layer_p = layer_arg[0]
      layer_arg = layer_arg[1:]
      # Taking the integral of the weights (pressure) to feed into the weighting
      # function. Said integral works out to this function:
      pres_int = 0.5 * (layer_p[-1].magnitude**2 - layer_p[0].magnitude**2)
      for i, datavar in enumerate(args):
          arg_mean = np.trapz(layer_arg[i] * layer_p, x=layer_p) / pres_int
          ret.append(arg_mean * datavar.units)
  
      return ret
docs: r"""Calculate pressure-weighted mean of an arbitrary variable through a layer.
  
      Layer top and bottom specified in height or pressure.
  
      Parameters
      ----------
      pressure : `pint.Quantity`
          Atmospheric pressure profile
      *args : `pint.Quantity`
          Parameters for which the pressure-weighted mean is to be calculated.
      heights : `pint.Quantity`, optional
          Heights from sounding. Standard atmosphere heights assumed (if needed)
          if no heights are given.
      bottom: `pint.Quantity`, optional
          The bottom of the layer in either the provided height coordinate
          or in pressure. Don't provide in meters AGL unless the provided
          height coordinate is meters AGL. Default is the first observation,
          assumed to be the surface.
      depth: `pint.Quantity`, optional
          The depth of the layer in meters or hPa.
  
      Returns
      -------
      `pint.Quantity`
          u_mean: u-component of layer mean wind.
      `pint.Quantity`
          v_mean: v-component of layer mean wind.