<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def liquid_precip_ratio(pr, prsn=None, tas=None, freq='QS-DEC'):
 r"""Ratio of rainfall to total precipitation The ratio of total liquid precipitation over the total precipitation. If solid precipitation is not provided, then precipitation is assumed solid if the temperature is below 0°C. Parameters pr : xarray.DataArray Mean daily precipitation flux [Kg m-2 s-1] or [mm]. prsn : xarray.DataArray Mean daily solid precipitation flux [Kg m-2 s-1] or [mm]. tas : xarray.DataArray Mean daily temperature [℃] or [K] freq : str Resampling frequency Returns ------- xarray.DataArray Ratio of rainfall to total precipitation Notes ----- Let :math:`PR_i` be the mean daily precipitation of day :math:`i`, then for a period :math:`j` starting at day :math:`a` and finishing on day :math:`b`: .. math:: PR_{ij} = \sum_{i=a}^{b} PR_i PRwet_{ij} See also -------- winter_rain_ratio """


    if prsn is None:
        tu = units.parse_units(tas.attrs['units'].replace('-', '**-'))
        fu = 'degC'
        frz = 0
        if fu != tu:
            frz = units.convert(frz, fu, tu)
        prsn = pr.where(tas < frz, 0)

    tot = pr.resample(time=freq).sum(dim='time')
    rain = tot - prsn.resample(time=freq).sum(dim='time')
    ratio = rain / tot
    return ratio