(
    m, nest=False, bad=UNSEEN, gal_cut=0, fitval=False, copy=True, verbose=True
)
Fit and subtract the monopole from the given map m.

    Parameters
    ----------
    m : float, array-like
      the map to which a monopole is fitted and subtracted
    nest : bool
      if ``False`` m is assumed in RING scheme, otherwise map is NESTED
    bad : float
      bad values of pixel, default to :const:`UNSEEN`.
    gal_cut : float [degrees]
      pixels at latitude in [-gal_cut;+gal_cut] are not taken into account
    fitval : bool
      whether to return or not the fitted value of monopole
    copy : bool
      whether to modify input map or not (by default, make a copy)
    verbose: bool
      deprecated, no effect

    Returns
    -------
    res : array or tuple of length 3
      if fitval is False, returns map with monopole subtracted,
      otherwise, returns map (array, in res[0]) and monopole (float, in res[1])

    See Also
    --------
    fit_dipole, fit_monopole, remove_dipole
Fit and subtract the monopole from the given map m.
Fit and subtract the monopole from the given map m .
def remove_monopole(
    m, nest=False, bad=UNSEEN, gal_cut=0, fitval=False, copy=True, verbose=True
):
    """Fit and subtract the monopole from the given map m.

    Parameters
    ----------
    m : float, array-like
      the map to which a monopole is fitted and subtracted
    nest : bool
      if ``False`` m is assumed in RING scheme, otherwise map is NESTED
    bad : float
      bad values of pixel, default to :const:`UNSEEN`.
    gal_cut : float [degrees]
      pixels at latitude in [-gal_cut;+gal_cut] are not taken into account
    fitval : bool
      whether to return or not the fitted value of monopole
    copy : bool
      whether to modify input map or not (by default, make a copy)
    verbose: bool
      deprecated, no effect

    Returns
    -------
    res : array or tuple of length 3
      if fitval is False, returns map with monopole subtracted,
      otherwise, returns map (array, in res[0]) and monopole (float, in res[1])

    See Also
    --------
    fit_dipole, fit_monopole, remove_dipole
    """
    input_ma = is_ma(m)
    m = ma_to_array(m)
    m = np.array(m, copy=copy)
    npix = m.size
    nside = npix2nside(npix)
    if nside > 128:
        bunchsize = npix // 24
    else:
        bunchsize = npix
    mono = fit_monopole(m, nest=nest, bad=bad, gal_cut=gal_cut)
    for ibunch in range(npix // bunchsize):
        ipix = np.arange(ibunch * bunchsize, (ibunch + 1) * bunchsize)
        ipix = ipix[(m.flat[ipix] != bad) & (np.isfinite(m.flat[ipix]))]
        x, y, z = pix2vec(nside, ipix, nest)
        m.flat[ipix] -= mono
    log.info("monopole: %.3g", mono)
    if input_ma:
        m = ma(m)
    if fitval:
        return m, mono
    else:
        return m
def remove_monopole ( m , nest = False , bad = UNSEEN , gal_cut = 0 , fitval = False , copy = True , verbose = True ) : input_ma = is_ma ( m ) m = ma_to_array ( m ) m = np . array ( m , copy = copy ) npix = m . size nside = npix2nside ( npix ) if nside > 128 : bunchsize = npix // 24 else : bunchsize = npix mono = fit_monopole ( m , nest = nest , bad = bad , gal_cut = gal_cut ) for ibunch in range ( npix // bunchsize ) : ipix = np . arange ( ibunch * bunchsize , ( ibunch + 1 ) * bunchsize ) ipix = ipix [ ( m . flat [ ipix ] != bad ) & ( np . isfinite ( m . flat [ ipix ] ) ) ] x , y , z = pix2vec ( nside , ipix , nest ) m . flat [ ipix ] -= mono log . info ( "monopole: %.3g" , mono ) if input_ma : m = ma ( m ) if fitval : return m , mono else : return m