def airDensity_from_theta(data, units, notation=None, inplace_units=True,
    use_means=False, theta=None, theta_unit=None):
    """
    Calculates moist air density using theta measurements

    Parameters
    -----------
    data: pandas.DataFrame
        dataset to add rho_air
    units: dict
        units dictionary
    notation: pymicra.notation
        notation to be used
    inplace_units: bool
        whether or not to treat units inplace
    use_means: bool
        use the mean of theta or not when calculating
    theta: pandas.Series
        auxiliar theta measurement
    theta_unit: pint.quantity
        auxiliar theta's unit
    """
    from . import algs
    from . import constants
    defs = algs.get_notation(notation)
    data = data.copy()
    outunits = {}
    R_dry = constants.R_spec['dry']
    R_h2o = constants.R_spec['h2o']
    R_spec_unit = constants.units['R_spec']
    if not theta:
        theta = data[defs.thermodyn_temp]
        theta_unit = units[defs.thermodyn_temp]
    if use_means:
        theta = theta.mean()
    p_h2o = data[defs.h2o_mass_density] * R_h2o * theta
    p_h2o_unit = units[defs.h2o_mass_density] * R_spec_unit * theta_unit
    p_dry, p_dry_unit = algs.add([data[defs.pressure], -p_h2o], [units[defs
        .pressure], p_h2o_unit], inplace_units=False)
    data[defs.dry_air_mass_density] = p_dry / (R_dry * theta)
    outunits[defs.dry_air_mass_density] = p_dry_unit / (R_spec_unit *
        theta_unit)
    data = data.convert_cols({defs.dry_air_mass_density: 'kg/m**3'},
        outunits, inplace_units=True)
    data.loc[:, (defs.moist_air_mass_density)] = algs.add([data[defs.
        dry_air_mass_density], data[defs.h2o_mass_density]], [outunits[defs
        .dry_air_mass_density], units[defs.h2o_mass_density]],
        inplace_units=True, unitdict=outunits, key=defs.moist_air_mass_density)
    conversions = {defs.moist_air_mass_density: 'kg/m**3', defs.
        dry_air_mass_density: 'kg/m**3'}
    data = data.convert_cols(conversions, outunits, inplace_units=True)
    if inplace_units:
        units.update(outunits)
        return data
    else:
        return data, outunits
