<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_units_to(source, target, context=None):
 """ Convert a mathematical expression into a value with the same units as a DataArray. Parameters source : str, pint.Quantity or xr.DataArray The value to be converted, e.g. '4C' or '1 mm/d'. target : str, pint.Unit or DataArray Target array of values to which units must conform. context : str Returns ------- out The source value converted to target's units. """

    # Target units
    if isinstance(target, units.Unit):
        tu = target
    elif isinstance(target, (str, xr.DataArray)):
        tu = units2pint(target)
    else:
        raise NotImplementedError

    if isinstance(source, str):
        q = units.parse_expression(source)

        # Return magnitude of converted quantity. This is going to fail if units are not compatible.
        return q.to(tu).m

    if isinstance(source, units.Quantity):
        return source.to(tu).m

    if isinstance(source, xr.DataArray):
        fu = units2pint(source)

        if fu == tu:
            return source

        tu_u = pint2cfunits(tu)
        with units.context(context or 'none'):
            out = units.convert(source, fu, tu)
            out.attrs['units'] = tu_u
            return out

    # TODO remove backwards compatibility of int/float thresholds after v1.0 release
    if isinstance(source, (float, int)):
        if context == 'hydro':
            fu = units.mm / units.day
        else:
            fu = units.degC
        warnings.warn("Future versions of XCLIM will require explicit unit specifications.", FutureWarning)
        return (source * fu).to(tu).m

    raise NotImplementedError("source of type {} is not supported.".format(type(source)))