(m, nest=False, bad=UNSEEN, gal_cut=0)
return mono
Fit a monopole to the map, excluding unseen pixels.

    Parameters
    ----------
    m : float, array-like
      the map to which a dipole is fitted and subtracted, accepts masked arrays
    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] degrees are not taken into account

    Returns
    -------
    res: float
      fitted monopole value

    See Also
    --------
    fit_dipole, remove_monopole, remove_monopole
Fit a monopole to the map, excluding unseen pixels.
Fit a monopole to the map excluding unseen pixels .
def fit_monopole(m, nest=False, bad=UNSEEN, gal_cut=0):
    """Fit a monopole to the map, excluding unseen pixels.

    Parameters
    ----------
    m : float, array-like
      the map to which a dipole is fitted and subtracted, accepts masked arrays
    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] degrees are not taken into account

    Returns
    -------
    res: float
      fitted monopole value

    See Also
    --------
    fit_dipole, remove_monopole, remove_monopole
    """
    m = ma_to_array(m)
    m = np.asarray(m)
    npix = m.size
    nside = npix2nside(npix)
    if nside > 128:
        bunchsize = npix // 24
    else:
        bunchsize = npix
    aa = v = 0.0
    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)
        if gal_cut > 0:
            w = np.abs(z) >= np.sin(gal_cut * np.pi / 180)
            ipix = ipix[w]
            x = x[w]
            y = y[w]
            z = z[w]
            del w
        aa += ipix.size
        v += m.flat[ipix].sum()
    mono = v / aa
    return mono
def fit_monopole ( m , nest = False , bad = UNSEEN , gal_cut = 0 ) : m = ma_to_array ( m ) m = np . asarray ( m ) npix = m . size nside = npix2nside ( npix ) if nside > 128 : bunchsize = npix // 24 else : bunchsize = npix aa = v = 0.0 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 ) if gal_cut > 0 : w = np . abs ( z ) >= np . sin ( gal_cut * np . pi / 180 ) ipix = ipix [ w ] x = x [ w ] y = y [ w ] z = z [ w ] del w aa += ipix . size v += m . flat [ ipix ] . sum ( ) mono = v / aa return mono