healpy.fitsfunc.write_map(filename, m, nest=False, dtype=None, fits_IDL=True, coord=None, partial=False, column_names=None, column_units=None, extra_header=(), overwrite=False)

Writes a healpix map into a healpix file.


the fits file name

marray or sequence of 3 arrays

the map to write. Possibly a sequence of 3 maps of same size. They will be considered as I, Q, U maps. Supports masked maps, see the ma function.

nestbool, optional

If True, ordering scheme is assumed to be NESTED, otherwise, RING. Default: RING. The map ordering is not modified by this function, the input map array should already be in the desired ordering (run ud_grade beforehand).

fits_IDLbool, optional

If True, reshapes columns in rows of 1024, otherwise all the data will go in one column. Default: True


The coordinate system, typically ‘E’ for Ecliptic, ‘G’ for Galactic or ‘C’ for Celestial (equatorial)

partialbool, optional

If True, fits file is written as a partial-sky file with explicit indexing. Otherwise, implicit indexing is used. Default: False.

column_namesstr or list

Column name or list of column names, if None here the default column names based on the number of columns: 1 : “TEMPERATURE”, 2 : [“Q_POLARISATION”, “U_POLARISATION”], 3 : [“TEMPERATURE”, “Q_POLARISATION”, “U_POLARISATION”], 6 : [“II”, “IQ”, “IU”, “QQ”, “QU”, “UU”] COLUMN_1, COLUMN_2… otherwise (FITS is 1-based)

column_unitsstr or list

Units for each column, or same units for all columns.


Extra records to add to FITS header.

dtype: np.dtype or list of np.dtypes, optional

The datatype in which the columns will be stored. Will be converted internally from the numpy datatype to the fits convention. If a list, the length must correspond to the number of map arrays. Default: use np.float32 (WARNING: in a future version this will change to “use the data type of the input array(s)”.)

overwritebool, optional

If True, existing file is silently overwritten. Otherwise trying to write an existing file raises an OSError (IOError for Python 2).