write_fits_spec

synphot.specio.write_fits_spec(filename, wavelengths, fluxes, pri_header={}, ext_header={}, overwrite=False, trim_zero=True, pad_zero_ends=True, precision=None, epsilon=0.00032, wave_col='WAVELENGTH', flux_col='FLUX', wave_unit=Unit("Angstrom"), flux_unit=Unit("FLAM"))[source]

Write FITS spectrum.

Warning

If data is being written out as single-precision but wavelengths are in double-precision, some rows may be omitted.

Parameters:
filename : str

Output spectrum filename.

wavelengths, fluxes : array-like or Quantity

Wavelength and flux of the spectrum.

pri_header, ext_header : dict

Metadata to be added to primary and given extension FITS header, respectively. Do not use this to define column names and units.

overwrite : bool

Overwrite existing file. Defaults to False.

trim_zero : bool

Remove rows with zero-flux. Default is True.

pad_zero_ends : bool

Pad each end of the spectrum with a row of zero flux like synphot.spectrum.BaseSpectrum.taper(). This is unnecessary if input is already tapered.

precision : {None, ‘single’, ‘double’}

Precision of values in output file. Use native flux precision by default.

epsilon : float

Single-precision \(\epsilon\) value, taken from IRAF SYNPHOT FAQ. This is the minimum separation in wavelengths necessary for SYNPHOT to read the entries as distinct single-precision numbers. This is only used if precision='single' but data are in double-precision. Default from the FAQ is 0.00032.

wave_col, flux_col : str

Wavelength and flux column names (case-insensitive).

wave_unit, flux_unit : str or Unit

Wavelength and flux units, which default to Angstrom and FLAM, respectively. These are only used if wavelengths and fluxes are not in astropy quantities.

Raises:
synphot.exceptions.SynphotError

Wavelengths and fluxes have difference shapes or value precision is not supported.