def precip_to_mm(ds):
    """Convert precip to mm"""
    if ds.pr.attrs['units']=='kg m-2 s-1':
        ds['pr'] = ds.pr * 24*60**2
        ds.pr.attrs['units']='mm day-1'
    elif ds.pr.attrs['units']=='mm day-1':
        pass
    else:
        raise ValueError('Unrecognised units')
    return ds