code: def density(pressure, temperature, mixing, molecular_weight_ratio=mpconsts.epsilon):
      r
      virttemp = virtual_temperature(temperature, mixing, molecular_weight_ratio)
      return (pressure / (mpconsts.Rd * virttemp)).to(units.kilogram / units.meter ** 3)
docs: r"""Calculate density.
  
      This calculation must be given an air parcel's pressure, temperature, and mixing ratio.
      The implementation uses the formula outlined in [Hobbs2006]_ pg.67.
  
      Parameters
      ----------
      temperature: `pint.Quantity`
          The temperature
      pressure: `pint.Quantity`
          Total atmospheric pressure
      mixing : `pint.Quantity`
          dimensionless mass mixing ratio
      molecular_weight_ratio : `pint.Quantity` or float, optional
          The ratio of the molecular weight of the constituent gas to that assumed
          for air. Defaults to the ratio for water vapor to dry air.
          (:math:`\epsilon\approx0.622`).
  
      Returns
      -------
      `pint.Quantity`
          The corresponding density of the parcel
  
      Notes
      -----
      .. math:: \rho = \frac{p}{R_dT_v}