(cls, lmax=None, mmax=None, new=False, verbose=True)
return np.array(alms_list)
Generate a set of alm given cl.
    The cl are given as a float array. Corresponding alm are generated.
    If lmax is None, it is assumed lmax=cl.size-1
    If mmax is None, it is assumed mmax=lmax.

    Parameters
    ----------
    cls : float, array or tuple of arrays
      Either one cl (1D array) or a tuple of either 4 cl
      or of n*(n+1)/2 cl.
      Some of the cl may be None, implying no
      cross-correlation. See *new* parameter.
    lmax : int, scalar, optional
      The lmax (if None or <0, the largest size-1 of cls)
    mmax : int, scalar, optional
      The mmax (if None or <0, =lmax)
    new : bool, optional
      If True, use the new ordering of cl's, ie by diagonal
      (e.g. TT, EE, BB, TE, EB, TB or TT, EE, BB, TE if 4 cl as input).
      If False, use the old ordering, ie by row
      (e.g. TT, TE, TB, EE, EB, BB or TT, TE, EE, BB if 4 cl as input).

    Returns
    -------
    alms : array or list of arrays
      the generated alm if one spectrum is given, or a list of n alms
      (with n(n+1)/2 the number of input cl, or n=3 if there are 4 input cl).

    Notes
    -----
    We don't plan to change the default order anymore, that would break old
    code in a way difficult to debug.
Generate a set of alm given cl.
    The cl are given as a float array. Corresponding alm are generated.
    If lmax is None, it is assumed lmax=cl.size-1
    If mmax is None, it is assumed mmax=lmax.
Generate a set of alm given cl . The cl are given as a float array . Corresponding alm are generated . If lmax is None it is assumed lmax = cl . size - 1 If mmax is None it is assumed mmax = lmax .
def synalm(cls, lmax=None, mmax=None, new=False, verbose=True):
    """Generate a set of alm given cl.
    The cl are given as a float array. Corresponding alm are generated.
    If lmax is None, it is assumed lmax=cl.size-1
    If mmax is None, it is assumed mmax=lmax.

    Parameters
    ----------
    cls : float, array or tuple of arrays
      Either one cl (1D array) or a tuple of either 4 cl
      or of n*(n+1)/2 cl.
      Some of the cl may be None, implying no
      cross-correlation. See *new* parameter.
    lmax : int, scalar, optional
      The lmax (if None or <0, the largest size-1 of cls)
    mmax : int, scalar, optional
      The mmax (if None or <0, =lmax)
    new : bool, optional
      If True, use the new ordering of cl's, ie by diagonal
      (e.g. TT, EE, BB, TE, EB, TB or TT, EE, BB, TE if 4 cl as input).
      If False, use the old ordering, ie by row
      (e.g. TT, TE, TB, EE, EB, BB or TT, TE, EE, BB if 4 cl as input).

    Returns
    -------
    alms : array or list of arrays
      the generated alm if one spectrum is given, or a list of n alms
      (with n(n+1)/2 the number of input cl, or n=3 if there are 4 input cl).

    Notes
    -----
    We don't plan to change the default order anymore, that would break old
    code in a way difficult to debug.
    """
    if not cb.is_seq(cls):
        raise TypeError("cls must be an array or a sequence of arrays")

    if not cb.is_seq_of_seq(cls, True):
        # Only one spectrum
        if lmax is None or lmax < 0:
            lmax = len(cls) - 1
        if mmax is None or mmax < 0:
            mmax = lmax
        cls_list = [np.asarray(cls, dtype=np.float64)]
        szalm = Alm.getsize(lmax, mmax)
        alm = np.zeros(szalm, "D")
        alm.real = np.random.standard_normal(szalm)
        alm.imag = np.random.standard_normal(szalm)
        alms_list = [alm]
        sphtlib._synalm(cls_list, alms_list, lmax, mmax)
        return alm

    # From here, we interpret cls as a list of spectra
    cls_list = list(cls)
    maxsize = max([len(c) for c in cls if c is not None])

    if lmax is None or lmax < 0:
        lmax = maxsize - 1
    if mmax is None or mmax < 0:
        mmax = lmax

    Nspec = sphtlib._getn(len(cls_list))

    if Nspec <= 0:
        if len(cls_list) == 4:
            if new:  ## new input order: TT EE BB TE -> TT EE BB TE 0 0
                cls_list = [cls[0], cls[1], cls[2], cls[3], None, None]
            else:  ## old input order: TT TE EE BB -> TT TE 0 EE 0 BB
                cls_list = [cls[0], cls[1], None, cls[2], None, cls[3]]
            Nspec = 3
        else:
            raise TypeError(
                "The sequence of arrays must have either 4 elements "
                "or n(n+1)/2 elements (some may be None)"
            )

    szalm = Alm.getsize(lmax, mmax)
    alms_list = []
    for i in range(Nspec):
        alm = np.zeros(szalm, "D")
        alm.real = np.random.standard_normal(szalm)
        alm.imag = np.random.standard_normal(szalm)
        alms_list.append(alm)
    if new:  # new input order: input given by diagonal, should be given by row
        cls_list = new_to_old_spectra_order(cls_list)
    # ensure cls are float64
    cls_list = [
        (np.asarray(cl, dtype=np.float64) if cl is not None else None)
        for cl in cls_list
    ]
    sphtlib._synalm(cls_list, alms_list, lmax, mmax)
    return np.array(alms_list)
def synalm ( cls , lmax = None , mmax = None , new = False , verbose = True ) : if not cb . is_seq ( cls ) : raise TypeError ( "cls must be an array or a sequence of arrays" ) if not cb . is_seq_of_seq ( cls , True ) : # Only one spectrum if lmax is None or lmax < 0 : lmax = len ( cls ) - 1 if mmax is None or mmax < 0 : mmax = lmax cls_list = [ np . asarray ( cls , dtype = np . float64 ) ] szalm = Alm . getsize ( lmax , mmax ) alm = np . zeros ( szalm , "D" ) alm . real = np . random . standard_normal ( szalm ) alm . imag = np . random . standard_normal ( szalm ) alms_list = [ alm ] sphtlib . _synalm ( cls_list , alms_list , lmax , mmax ) return alm # From here, we interpret cls as a list of spectra cls_list = list ( cls ) maxsize = max ( [ len ( c ) for c in cls if c is not None ] ) if lmax is None or lmax < 0 : lmax = maxsize - 1 if mmax is None or mmax < 0 : mmax = lmax Nspec = sphtlib . _getn ( len ( cls_list ) ) if Nspec <= 0 : if len ( cls_list ) == 4 : if new : ## new input order: TT EE BB TE -> TT EE BB TE 0 0 cls_list = [ cls [ 0 ] , cls [ 1 ] , cls [ 2 ] , cls [ 3 ] , None , None ] else : ## old input order: TT TE EE BB -> TT TE 0 EE 0 BB cls_list = [ cls [ 0 ] , cls [ 1 ] , None , cls [ 2 ] , None , cls [ 3 ] ] Nspec = 3 else : raise TypeError ( "The sequence of arrays must have either 4 elements " "or n(n+1)/2 elements (some may be None)" ) szalm = Alm . getsize ( lmax , mmax ) alms_list = [ ] for i in range ( Nspec ) : alm = np . zeros ( szalm , "D" ) alm . real = np . random . standard_normal ( szalm ) alm . imag = np . random . standard_normal ( szalm ) alms_list . append ( alm ) if new : # new input order: input given by diagonal, should be given by row cls_list = new_to_old_spectra_order ( cls_list ) # ensure cls are float64 cls_list = [ ( np . asarray ( cl , dtype = np . float64 ) if cl is not None else None ) for cl in cls_list ] sphtlib . _synalm ( cls_list , alms_list , lmax , mmax ) return np . array ( alms_list )