(filename, cl, dtype=None, overwrite=False)
Writes Cl into a healpix file, as IDL cl2fits.

    Parameters
    ----------
    filename : str
      the fits file name
    cl : array
      the cl array to write to file
    dtype : np.dtype (optional)
      The datatype in which the columns will be stored. If not supplied,
      the dtype of the input cl will be used. This changed in `healpy` 1.15.0,
      in previous versions, cl by default were saved in `float64`.
    overwrite : bool, optional
      If True, existing file is silently overwritten. Otherwise trying to write
      an existing file raises an OSError.
Writes Cl into a healpix file, as IDL cl2fits.
Writes Cl into a healpix file as IDL cl2fits .
def write_cl(filename, cl, dtype=None, overwrite=False):
    """Writes Cl into a healpix file, as IDL cl2fits.

    Parameters
    ----------
    filename : str
      the fits file name
    cl : array
      the cl array to write to file
    dtype : np.dtype (optional)
      The datatype in which the columns will be stored. If not supplied,
      the dtype of the input cl will be used. This changed in `healpy` 1.15.0,
      in previous versions, cl by default were saved in `float64`.
    overwrite : bool, optional
      If True, existing file is silently overwritten. Otherwise trying to write
      an existing file raises an OSError.
    """
    if dtype is None:
        dtype = cl.dtype if isinstance(cl, np.ndarray) else cl[0].dtype

    # check the dtype and convert it
    fitsformat = getformat(dtype)
    column_names = ["TEMPERATURE", "GRADIENT", "CURL", "G-T", "C-T", "C-G"]
    if len(np.shape(cl)) == 2:
        cols = [
            pf.Column(name=column_name, format="%s" % fitsformat, array=column_cl)
            for column_name, column_cl in zip(column_names[: len(cl)], cl)
        ]
    elif len(np.shape(cl)) == 1:
        # we write only TT
        cols = [pf.Column(name="TEMPERATURE", format="%s" % fitsformat, array=cl)]
    else:
        raise RuntimeError("write_cl: Expected one or more vectors of equal length")

    tbhdu = pf.BinTableHDU.from_columns(cols)
    # add needed keywords
    tbhdu.header["CREATOR"] = "healpy"
    # Add str to convert pathlib.Path into str
    # Due to https://github.com/astropy/astropy/issues/10594
    tbhdu.writeto(str(filename), overwrite=overwrite)
def write_cl ( filename , cl , dtype = None , overwrite = False ) : if dtype is None : dtype = cl . dtype if isinstance ( cl , np . ndarray ) else cl [ 0 ] . dtype # check the dtype and convert it fitsformat = getformat ( dtype ) column_names = [ "TEMPERATURE" , "GRADIENT" , "CURL" , "G-T" , "C-T" , "C-G" ] if len ( np . shape ( cl ) ) == 2 : cols = [ pf . Column ( name = column_name , format = "%s" % fitsformat , array = column_cl ) for column_name , column_cl in zip ( column_names [ : len ( cl ) ] , cl ) ] elif len ( np . shape ( cl ) ) == 1 : # we write only TT cols = [ pf . Column ( name = "TEMPERATURE" , format = "%s" % fitsformat , array = cl ) ] else : raise RuntimeError ( "write_cl: Expected one or more vectors of equal length" ) tbhdu = pf . BinTableHDU . from_columns ( cols ) # add needed keywords tbhdu . header [ "CREATOR" ] = "healpy" # Add str to convert pathlib.Path into str # Due to https://github.com/astropy/astropy/issues/10594 tbhdu . writeto ( str ( filename ) , overwrite = overwrite )