healpy.fitsfunc.write_cl#
- healpy.fitsfunc.write_cl(filename, cl, dtype=None, overwrite=False, column_names=None, column_units=None, extra_header=())#
Writes Cl into a HEALPix file, as IDL cl2fits.
- Parameters:
- filenamestr or pathlib.Path
the fits file name
- clarray
the cl array to write to file
- dtypenp.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.
- overwritebool, optional
If True, existing file is silently overwritten. Otherwise trying to write an existing file raises an OSError.
- column_namesstr or list, optional
Column name or list of column names. If None, uses default names: [“TEMPERATURE”, “GRADIENT”, “CURL”, “G-T”, “C-T”, “C-G”] for the first 6 columns, and “COLUMN_N” for columns beyond 6.
- column_unitsstr or list, optional
Units for each column, or same units for all columns. If None, no units are stored in the FITS header. A single string is applied to all columns; a list must have the same length as the number of columns (1 for a single Cl vector, or
len(cl)for multiple). Each element must be a string orNone;Nonemeans no unit for that column.- extra_headerlist, optional
Extra records to add to FITS header.
Examples
>>> import os >>> import tempfile >>> import numpy as np >>> cl = np.arange(1026, dtype=np.float64) >>> filename = os.path.join(tempfile.mkdtemp(), "cl.fits") >>> write_cl(filename, cl, column_units="K") >>> np.allclose(cl, read_cl(filename)) True >>> os.remove(filename)