code: def mixing_ratio(part_press, tot_press, molecular_weight_ratio=mpconsts.epsilon):
      r
      return (molecular_weight_ratio * part_press
              / (tot_press - part_press)).to('dimensionless')
docs: r"""Calculate the mixing ratio of a gas.
  
      This calculates mixing ratio given its partial pressure and the total pressure of
      the air. There are no required units for the input arrays, other than that
      they have the same units.
  
      Parameters
      ----------
      part_press : `pint.Quantity`
          Partial pressure of the constituent gas
      tot_press : `pint.Quantity`
          Total air pressure
      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 (mass) mixing ratio, dimensionless (e.g. Kg/Kg or g/g)
  
      Notes
      -----
      This function is a straightforward implementation of the equation given in many places,
      such as [Hobbs1977]_ pg.73:
  
      .. math:: r = \epsilon \frac{e}{p - e}
  
      See Also
      --------
      saturation_mixing_ratio, vapor_pressure