def _rename_magnetic_pars(pars):
    """
    Change from M0:par to par_M0, etc.
    """
    keys = list(pars.items())
    for k in keys:
        if k.startswith('M0:'):
            pars[k[3:] + '_M0'] = pars.pop(k)
        elif k.startswith('mtheta:'):
            pars[k[7:] + '_mtheta'] = pars.pop(k)
        elif k.startswith('mphi:'):
            pars[k[5:] + '_mphi'] = pars.pop(k)
        elif k.startswith('up:'):
            pars['up_' + k[3:]] = pars.pop(k)
    return pars
