Coverage for python/pfs/datamodel/fluxTable.py : 33%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Table of coadded fluxes at near-original sampling
Merged and coadded spectra have been resampled to a standard wavelength sampling. This representation provides coadded fluxes at approximately the native wavelength sampling, for those that want the data with a minimum of resampling. This is mostly of use for single exposures and coadds made from back-to-back exposures with the same top-end configuration. For coadds made from exposures with different top-end configurations, the different wavelength samplings obtained from the different fibers means there's no single native wavelength sampling, and so this is less useful.
This is like a `pfs.datamodel.PfsSimpleSpectrum`, except that it includes a variance array, and is written to a FITS HDU rather than a file (so it can be incorporated within a `pfs.datamodel.PfsSpectrum`).
Parameters ---------- wavelength : `numpy.ndarray` of `float` Array of wavelengths. flux : `numpy.ndarray` of `float` Array of fluxes. error : `numpy.ndarray` of `float` Array of flux errors. mask : `numpy.ndarray` of `int` Array of mask pixels. flags : `pfs.datamodel.MaskHelper` Helper for dealing with symbolic names for mask values. """
dims = np.array([len(wavelength.shape), len(flux.shape), len(error.shape), len(mask.shape)]) lengths = set([wavelength.shape, flux.shape, error.shape, mask.shape]) if np.any(dims != 1) or len(lengths) > 1: raise RuntimeError("Bad shapes for wavelength,flux,error,mask: %s,%s,%s,%s" % (wavelength.shape, flux.shape, error.shape, mask.shape)) self.wavelength = wavelength self.flux = flux self.error = error self.mask = mask self.flags = flags
"""Return number of elements""" return len(self.wavelength)
"""Write to a FITS file
Parameters ---------- fits : `astropy.io.fits.HDUList` Opened FITS file. """ from astropy.io.fits import BinTableHDU, Column header = self.flags.toFitsHeader() hdu = BinTableHDU.from_columns([ Column("wavelength", "E", array=self.wavelength), Column("flux", "E", array=self.flux), Column("error", "E", array=self.error), Column("mask", "K", array=self.mask), ], header=astropyHeaderFromDict(header), name=self._hduName) fits.append(hdu)
def fromFits(cls, fits): """Construct from a FITS file
Parameters ---------- fits : `astropy.io.fits.HDUList` Opened FITS file.
Returns ------- self : `FluxTable` Constructed `FluxTable`. """ hdu = fits[cls._hduName] header = astropyHeaderToDict(hdu.header) flags = MaskHelper.fromFitsHeader(header) return cls(hdu.data["wavelength"], hdu.data["flux"], hdu.data["error"], hdu.data["mask"], flags) |