specdash.input.pfs.pfs.datamodel package

Submodules

specdash.input.pfs.pfs.datamodel.drp module

class specdash.input.pfs.pfs.datamodel.drp.PfsArm(identity, fiberId, wavelength, flux, mask, sky, covar, flags, metadata)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsFiberArraySet.PfsFiberArraySet

Spectra from reducing a single arm

Produced by reduceExposure.

filenameFormat = 'pfsArm-%(visit)06d-%(arm)1s%(spectrograph)1d.fits'
filenameKeys = [('visit', <class 'int'>), ('arm', <class 'str'>), ('spectrograph', <class 'int'>)]
filenameRegex = '^pfsArm-(\\d{6})-([brnm])(\\d)\\.fits.*$'
classmethod fromMerge(spectraList, metadata=None)

Construct from merging multiple spectra

Parameters
  • spectraList (iterable of PfsArm) – Spectra to combine.

  • metadata (dict (str: POD), optional) – Keyword-value pairs for the header.

Returns

self – Merged spectra.

Return type

PfsArm

classmethod read(identity, dirName='.')

Read file given an identity

This API is intended for use by science users, as it allows selection of the correct file by identity (e.g., visit, arm, spectrograph), without knowing the file naming convention.

Parameters
  • identity (pfs.datamodel.Identity) – Identification of the data of interest.

  • dirName (str, optional) – Directory from which to read.

Returns

self – Spectra read from file.

Return type

PfsArm

class specdash.input.pfs.pfs.datamodel.drp.PfsMerged(identity, fiberId, wavelength, flux, mask, sky, covar, flags, metadata)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsFiberArraySet.PfsFiberArraySet

Spectra from merging all arms within an exposure

Produced by mergeArms.

filenameFormat = 'pfsMerged-%(visit)06d.fits'
filenameKeys = [('visit', <class 'int'>)]
filenameRegex = '^pfsMerged-(\\d{6})\\.fits.*$'
classmethod fromMerge(spectraList, metadata=None)

Construct from merging multiple spectra

Parameters
  • spectraList (iterable of PfsMerged) – Spectra to combine.

  • metadata (dict (str: POD), optional) – Keyword-value pairs for the header.

Returns

self – Merged spectra.

Return type

PfsMerged

classmethod read(identity, dirName='.')

Read file given an identity

This API is intended for use by science users, as it allows selection of the correct file by identity (e.g., visit, arm, spectrograph), without knowing the file naming convention.

Parameters
  • identity (pfs.datamodel.Identity) – Identification of the data of interest.

  • dirName (str, optional) – Directory from which to read.

Returns

self – Spectra read from file.

Return type

PfsMerged

class specdash.input.pfs.pfs.datamodel.drp.PfsObject(target, observations, wavelength, flux, mask, sky, covar, covar2, flags, metadata=None, fluxTable=None)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsFiberArray.PfsFiberArray

Coadded spectrum

Produced by coaddSpectra.

filenameFormat = 'pfsObject-%(catId)05d-%(tract)05d-%(patch)s-%(objId)016x-%(nVisit)03d-0x%(pfsVisitHash)016x.fits'
filenameKeys = [('catId', <class 'int'>), ('tract', <class 'int'>), ('patch', <class 'str'>), ('objId', <class 'int'>), ('nVisit', <class 'int'>), ('pfsVisitHash', <class 'int'>)]
filenameRegex = '^pfsObject-(\\d{5})-(\\d{5})-(.*)-([0-9a-f]{16})-(\\d{3})-0x([0-9a-f]{16})\\.fits.*$'
class specdash.input.pfs.pfs.datamodel.drp.PfsReference(target, wavelength, flux, mask, flags, metadata=None)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsSimpleSpectrum.PfsSimpleSpectrum

Reference spectrum for flux calibration

Produced by calculateReferenceFlux.

filenameFormat = 'pfsReference-%(catId)05d-%(tract)05d-%(patch)s-%(objId)016x.fits'
filenameKeys = [('catId', <class 'int'>), ('tract', <class 'int'>), ('patch', <class 'str'>), ('objId', <class 'int'>)]
filenameRegex = '^pfsReference-(\\d{5})-(\\d{5})-(.*)-([0-9a-f]{16})\\.fits.*$'
class specdash.input.pfs.pfs.datamodel.drp.PfsSingle(target, observations, wavelength, flux, mask, sky, covar, covar2, flags, metadata=None, fluxTable=None)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsFiberArray.PfsFiberArray

Flux-calibrated, single epoch spectrum

Produced by fluxCalibrate.

filenameFormat = 'pfsSingle-%(catId)05d-%(tract)05d-%(patch)s-%(objId)016x-%(visit)06d.fits'
filenameKeys = [('catId', <class 'int'>), ('tract', <class 'int'>), ('patch', <class 'str'>), ('objId', <class 'int'>), ('visit', <class 'int'>)]
filenameRegex = '^pfsSingle-(\\d{5})-(\\d{5})-(.*)-([0-9a-f]{16})-(\\d{6})\\.fits.*$'

specdash.input.pfs.pfs.datamodel.fluxTable module

class specdash.input.pfs.pfs.datamodel.fluxTable.FluxTable(wavelength, flux, error, mask, flags)[source]

Bases: object

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.

classmethod fromFits(fits)[source]

Construct from a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

Returns

self – Constructed FluxTable.

Return type

FluxTable

toFits(fits)[source]

Write to a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

specdash.input.pfs.pfs.datamodel.identity module

class specdash.input.pfs.pfs.datamodel.identity.Identity(visit, arm=None, spectrograph=None, pfsDesignId=None)[source]

Bases: types.SimpleNamespace

Identification of an exposure

An exposure is identified by its visit, arm and spectrograph, for which a corresponding pfsDesignId was used.

Sometimes, exposures are combined, in which case the arm and spectrograph will be set to default values (defaultArm and defaultSpectrograph class attributes).

Since the pfsDesignId is uniquely specified from a visit, it may not be known at construction time, in which case it will be set to a default value defaultPfsDesignId class attribute).

Parameters
  • visit (int) – Visit identifier.

  • arm (str, optional) – Spectrograph arm identifier.

  • spectrograph (int, optional) – Spectrograph module identifier.

  • pfsDesignId (int, optional) – Top-end design identifier.

property arm
defaultArm = 'x'
defaultPfsDesignId = -1
defaultSpectrograph = 0
fitsExtension = 'CONFIG'
classmethod fromDict(identity)[source]

Construct from a dict

This is intended for use with a dataId such as used by the LSST butler.

Parameters

identity (dict (str: POD)) – Keyword-value pairs identifying the data. Must have visit and pfsDesignId keywords, and may have arm and spectrograph.

Returns

self – Constructed identity.

Return type

Identity

classmethod fromFits(fits)[source]

Construct from a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

Returns

self – Constructed identity.

Return type

Identity

classmethod fromMerge(identities)[source]

Construct by merging multiple identities

Parameters

identities (list of Identity) – Identities to merge.

Returns

merged – Merged identity.

Return type

Identity

Raises

RuntimeError – If the identities cannot be merged (because they do not have a common visit and pfsDesignId).

getDict()[source]

Generate a set of keyword-value pairs

Returns

identity – Keyword-value pairs for this identity.

Return type

dict (str: POD)

property pfsDesignId
property spectrograph
toFits(fits)[source]

Write to a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

specdash.input.pfs.pfs.datamodel.interpolate module

specdash.input.pfs.pfs.datamodel.masks module

class specdash.input.pfs.pfs.datamodel.masks.MaskHelper(**kwargs)[source]

Bases: object

Helper for dealing with symbolic names for mask values

For science, we care about the symbolic name (i.e., what the mask represents; e.g., NO_DATA), but this needs to be translated to the implementation (i.e., an integer) so pixels can be selected.

Parameters

**kwargs (dict mapping str to int) – The mask planes. The integers should all be positive in the range 0..63.

add(name)[source]

Add mask name

copy()[source]

Return a copy

count(mask)[source]

Return counts of each mask plane

Parameters

mask (numpy.ndarray) – Mask array.

Returns

counts – Counts for each mask plane. An additional result indexed by an empty string corresponds to the number of pixels with no mask plane set.

Return type

dict (str: int)

classmethod fromFitsHeader(header)[source]

Read from a FITS header

Parameters

header (dict) – FITS header keyword-value pairs.

Returns

self – Constructed mask helper.

Return type

MaskHelper

classmethod fromMerge(helpers)[source]

Construct from multiple `MaskHelper`s

There must be no discrepancies between the inputs.

Parameters

helpers (iterable of MaskHelper) – `MaskHelper`s to merge.

Returns

self – Merged MaskHelper.

Return type

MaskHelper

get(*args)[source]

Retrieve value for multiple masks

interpret(value)[source]

Interpret a value from the mask

Breaks down the provided value into the corresponding mask plane names.

Parameters
  • value (int) – Value to interpret.

  • names (list of str) – List of mask planes that are set in the provided value.

maskPlanePrefix = 'MP_'
toFitsHeader()[source]

Write to a FITS header

Returns

header – FITS header keyword-value pairs.

Return type

dict

specdash.input.pfs.pfs.datamodel.observations module

class specdash.input.pfs.pfs.datamodel.observations.Observations(visit, arm, spectrograph, pfsDesignId, fiberId, pfiNominal, pfiCenter)[source]

Bases: types.SimpleNamespace

A group of observations of a spectroscopic target

Parameters
  • visit (numpy.ndarray of int) – Visit identifiers for each observation.

  • arm (iterable of str) – Arm identifiers for each observation.

  • spectrograph (numpy.ndarray of int) – Spectrograph identifier for each observation.

  • pfsDesignId (numpy.ndarray of int) – Top-end design identifier for each observation.

  • fiberId (numpy.ndarray of int) – Array of fiber identifiers for this object in each observation.

  • pfiNominal (numpy.ndarray of float) – Array of nominal fiber positions (x,y) for this object in each observation.

  • pfiCenter (numpy.ndarray of float) – Array of actual fiber positions (x,y) for this object in each observation.

calculateVisitHash()[source]

Calculate hash of the exposure inputs

Returns

hash – Hash, truncated to 63 bits.

Return type

int

classmethod fromFits(fits)[source]

Construct from a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

Returns

self – Constructed observations.

Return type

Observations

getIdentity()[source]

Return the identity of these observations

Returns

identity – Keyword-value pairs identifying these observations.

Return type

dict

classmethod makeSingle(identity, pfsConfig, fiberId)[source]

Construct for a single observation

Parameters
  • identity (pfs.datamodel.Identity) – Identity of the exposure.

  • pfsConfig (pfs.datamodel.PfsConfig) – Top-end configuration.

  • fiberId (int) – Fiber identifier.

Returns

self – Observations, consisting of a single exposure.

Return type

Observations

toFits(fits)[source]

Write to a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

validate()[source]

Validate that all arrays are of the expected shape

specdash.input.pfs.pfs.datamodel.pfsConfig module

class specdash.input.pfs.pfs.datamodel.pfsConfig.FiberStatus(value)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsConfig.DocEnum

Enumerated options for the status of a fiber

BLACKSPOT = 4
BLOCKED = 3
BROKENFIBER = 2
GOOD = 1
UNILLUMINATED = 5
class specdash.input.pfs.pfs.datamodel.pfsConfig.PfsConfig(pfsDesignId, visit0, raBoresight, decBoresight, fiberId, tract, patch, ra, dec, catId, objId, targetType, fiberStatus, fiberMag, filterNames, pfiCenter, pfiNominal)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsConfig.PfsDesign

The configuration of the PFS top-end for one or more observations

The realised version of a PfsDesign.

Parameters
  • pfsDesignId (int) – PFI design identifier, specifies the intended top-end configuration.

  • visit0 (int) – Exposure identifier.

  • raBoresight (float, degrees) – Right Ascension of telescope boresight.

  • decBoresight (float, degrees) – Declination of telescope boresight.

  • fiberId (numpy.ndarary of int32) – Fiber identifier for each fiber.

  • tract (numpy.ndarray of int32) – Tract index for each fiber.

  • patch (numpy.ndarray of str) – Patch indices for each fiber, typically two integers separated by a comma, e.g,. “5,6”.

  • ra (numpy.ndarray of float64) – Right Ascension for each fiber, degrees.

  • dec (numpy.ndarray of float64) – Declination for each fiber, degrees.

  • catId (numpy.ndarray of int32) – Catalog identifier for each fiber.

  • objId (numpy.ndarray of int64) – Object identifier for each fiber. Specifies the object within the catalog.

  • targetType (numpy.ndarray of int) – Type of target for each fiber. Values must be convertible to TargetType (which limits the range of values).

  • fiberStatus (numpy.ndarray of int) – Status of each fiber. Values must be convertible to FiberStatus (which limits the range of values).

  • fiberMag (list of numpy.ndarray of float) – Array of fiber magnitudes for each fiber.

  • filterNames (list of list of str) – List of filters used to measure the fiber magnitudes for each filter.

  • pfiCenter (numpy.ndarray of float) – Actual position (2-vector) of each fiber on the PFI, microns.

  • pfiNominal (numpy.ndarray of float) – Intended target position (2-vector) of each fiber on the PFI, microns.

extractCenters(fiberId)[source]

Extract centers for fibers

Parameters

fiberId (iterable of int) – Fiber identifiers.

Returns

centers – Center of each fiber.

Return type

numpy.ndarray of shape (N, 2)

fileNameFormat = 'pfsConfig-0x%016x-%06d.fits'
property filename

Usual filename

classmethod fromPfsDesign(pfsDesign, visit0, pfiCenter)[source]

Construct from a PfsDesign

Parameters
  • pfsDesign (pfs.datamodel.PfsDesign) – PfsDesign to use as the base for this PfsConfig.

  • visit0 (int) – Exposure identifier.

  • pfiCenter (numpy.ndarray of float) – Actual position (2-vector) of each fiber on the PFI, microns.

Returns

self – Constructed ``PfsConfig`.

Return type

PfsConfig

classmethod read(pfsDesignId, visit0, dirName='.')[source]

Construct from file

Requires pyfits.

Parameters
  • pfsDesignId (int) – PFI design identifier, specifies the intended top-end configuration.

  • visit0 (int) – Exposure identifier.

  • dirName (str, optional) – Directory from which to read the file. Defaults to the current directory.

Returns

self – Constructed PfsConfig.

Return type

PfsConfig

class specdash.input.pfs.pfs.datamodel.pfsConfig.PfsDesign(pfsDesignId, raBoresight, decBoresight, fiberId, tract, patch, ra, dec, catId, objId, targetType, fiberStatus, fiberMag, filterNames, pfiNominal)[source]

Bases: object

The design of the PFS top-end configuration for one or more observations

Parameters
  • pfsDesignId (int) – PFI design identifier, specifies the intended top-end configuration.

  • raBoresight (float, degrees) – Right Ascension of telescope boresight.

  • decBoresight (float, degrees) – Declination of telescope boresight.

  • fiberId (numpy.ndarary of int32) – Fiber identifier for each fiber.

  • tract (numpy.ndarray of int32) – Tract index for each fiber.

  • patch (numpy.ndarray of str) – Patch indices for each fiber, typically two integers separated by a comma, e.g,. “5,6”.

  • ra (numpy.ndarray of float64) – Right Ascension for each fiber, degrees.

  • dec (numpy.ndarray of float64) – Declination for each fiber, degrees.

  • catId (numpy.ndarray of int32) – Catalog identifier for each fiber.

  • objId (numpy.ndarray of int64) – Object identifier for each fiber. Specifies the object within the catalog.

  • targetType (numpy.ndarray of int) – Type of target for each fiber. Values must be convertible to TargetType (which limits the range of values).

  • fiberStatus (numpy.ndarray of int) – Status of each fiber. Values must be convertible to FiberStatus (which limits the range of values).

  • fiberMag (list of numpy.ndarray of float) – Array of fiber magnitudes for each fiber.

  • filterNames (list of list of str) – List of filters used to measure the fiber magnitudes for each filter.

  • pfiNominal (numpy.ndarray of float) – Intended target position (2-vector) of each fiber on the PFI, microns.

extractNominal(fiberId)[source]

Extract nominal positions for fibers

Parameters

fiberId (iterable of int) – Fiber identifiers.

Returns

nominal – Nominal position for each fiber.

Return type

numpy.ndarray of shape (N, 2)

fileNameFormat = 'pfsDesign-0x%016x.fits'
property filename

Usual filename

getIdentity(fiberId)[source]

Return the identity of the target indicated by the fiber(s)

Parameters

fiberId (scalar or iterable of int) – Fiber identifier.

Returns

identity – Keyword-value pairs identifying the target.

Return type

single or list of dict

getIdentityFromIndex(index)[source]

Return the identity of the target indicated by the index

Parameters

index (scalar or iterable of int) – Index for self.

Returns

identity – Keword-value pairs identifying the target(s).

Return type

single or list of dict

classmethod read(pfsDesignId, dirName='.')[source]

Construct from file

Requires pyfits.

Parameters
  • pfsDesignId (int) – PFI design identifier, specifies the intended top-end configuration.

  • dirName (str, optional) – Directory from which to read the file. Defaults to the current directory.

Returns

self – Constructed PfsDesign.

Return type

PfsDesign

selectByFiberStatus(fiberStatus, fiberId=None)[source]

Select fibers by fiberStatus

If a fiberId array is provided, returns indices for array; otherwise, returns indices for self.

Parameters
  • fiberStatus (FiberStatus) – Fiber status to select.

  • fiberId (numpy.ndarray of int, optional) – Array of fiber identifiers to select.

Returns

indices – Indices of selected elements.

Return type

numpy.ndarray of int

selectByTargetType(targetType, fiberId=None)[source]

Select fibers by targetType

If a fiberId array is provided, returns indices for array; otherwise, returns indices for self.

Parameters
  • targetType (TargetType) – Target type to select.

  • fiberId (numpy.ndarray of int, optional) – Array of fiber identifiers to select.

Returns

indices – Indices of selected elements.

Return type

numpy.ndarray of int

selectFiber(fiberId)[source]

Select fiber(s) by fiber identifier

Returns the index for the provided fiber identifier.

Parameters

fiberId (iterable of int) – Fiber identifiers to select.

Returns

index – Indices for fiber.

Return type

array-like of int

selectTarget(catId, tract, patch, objId)[source]

Select fiber by target

Returns index for the fiber that matches the target identity.

Parameters
  • catId (int) – Catalog identifier.

  • tract (int) – Trace identifier.

  • patch (str) – Patch name.

  • objId (int) – Object identifier.

Returns

index – Index of selected target.

Return type

int

validate()[source]

Validate contents

Ensures the lengths are what is expected.

Raises
  • RuntimeError – If there are inconsistent lengths.

  • ValueError: – If the targetType is not recognised.

write(dirName='.', fileName=None)[source]

Write to file

Requires pyfits.

Parameters
  • dirName (str, optional) – Directory to which to write the file. Defaults to the current directory.

  • fileName (str, optional) – Filename to which to write. Defaults to using the filename template.

class specdash.input.pfs.pfs.datamodel.pfsConfig.TargetType(value)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsConfig.DocEnum

Enumerated options for what a fiber is targeting

ENGINEERING = 5
FLUXSTD = 3
SCIENCE = 1
SKY = 2
UNASSIGNED = 4

specdash.input.pfs.pfs.datamodel.pfsFiberArray module

class specdash.input.pfs.pfs.datamodel.pfsFiberArray.PfsFiberArray(target, observations, wavelength, flux, mask, sky, covar, covar2, flags, metadata=None, fluxTable=None)[source]

Bases: specdash.input.pfs.pfs.datamodel.pfsSimpleSpectrum.PfsSimpleSpectrum

Spectrum arrays for a single object

This base class is suitable for spectra which have been extracted from observations.

Parameters
  • target (pfs.datamodel.Target) – Target information.

  • observations (pfs.datamodel.Observations) – Observations of the target.

  • wavelength (numpy.ndarray of float) – Array of wavelengths.

  • flux (numpy.ndarray of float) – Array of fluxes.

  • mask (numpy.ndarray of int) – Array of mask pixels.

  • sky (numpy.ndarray of float) – Array of sky values.

  • covar (numpy.ndarray of float) – Near-diagonal (diagonal and either side) part of the covariance matrix.

  • covar2 (numpy.ndarray of float) – Low-resolution non-sparse covariance estimate.

  • flags (MaskHelper) – Helper for dealing with symbolic names for mask values.

  • metadata (dict (str: POD), optional) – Keyword-value pairs for the header.

  • fluxTable (pfs.datamodel.FluxTable, optional) – Table of fluxes from contributing observations.

filenameFormat = None
getIdentity()[source]

Return the identity of the spectrum

Returns

identity – Key-value pairs that identify this spectrum.

Return type

dict

validate()[source]

Validate that all the arrays are of the expected shape

property variance

Variance in the flux

specdash.input.pfs.pfs.datamodel.pfsFiberArraySet module

class specdash.input.pfs.pfs.datamodel.pfsFiberArraySet.PfsFiberArraySet(identity, fiberId, wavelength, flux, mask, sky, covar, flags, metadata)[source]

Bases: object

A collection of spectra from a common source

The collection may be from a single arm within a single spectrograph, or from the entire instrument. The only requirement is that the elements all have the same number of samples.

Parameters
  • identity (pfs.datamodel.Identity) – Identity of the data.

  • fiberId (numpy.ndarray of int) – Fiber identifiers for each spectrum.

  • wavelength (numpy.ndarray of float) – Array of wavelengths for each spectrum.

  • flux (numpy.ndarray of float) – Array of fluxes for each spectrum.

  • mask (numpy.ndarray of int) – Array of mask pixels for each spectrum.

  • sky (numpy.ndarray of float) – Array of sky values for each spectrum.

  • covar (numpy.ndarray of float) – Array of covariances for each spectrum.

  • flags (dict) – Mapping of symbolic mask names to mask planes.

  • metadata (dict) – Keyword-value pairs for the header.

extractFiber(FiberArrayClass, pfsConfig, fiberId)[source]

Extract a single fiber

Pulls a single fiber out into a subclass of pfs.datamodel.PfsFiberArray.

Parameters
  • FiberArrayClass (type) – Subclass of pfs.datamodel.PfsFiberArray to which to export.

  • pfsConfig (pfs.datamodel.PfsConfig) – PFS top-end configuration.

  • fiberId (int) – Fiber ID to export.

Returns

spectrum – Extracted spectrum.

Return type

SpectrumClass

property filename

Filename, without directory

filenameFormat = None

Format for filename (str)

Should include formatting directives for the identity dict.

filenameKeys = None

Key name and type (list of tuple of str and type)

Keys should be in the same order as for the regex.

filenameRegex = None

Regex for extracting dataId from filename (str)

Should capture the necessary values for the identity dict.

classmethod fromMerge(spectraList, metadata=None)[source]

Construct from merging multiple spectra

Parameters
  • spectraList (iterable of PfsFiberArraySet) – Spectra to combine.

  • metadata (dict (str: POD), optional) – Keyword-value pairs for the header.

Returns

self – Merged spectra.

Return type

PfsFiberArraySet

classmethod getFilename(identity)[source]

Calculate filename

Parameters

identity (pfs.datamodel.Identity) – Identity of the data.

Returns

filename – Filename, without directory.

Return type

str

classmethod read(identity, dirName='.')[source]

Read file given an identity

This API is intended for use by science users, as it allows selection of the correct file by identity (e.g., visit, arm, spectrograph), without knowing the file naming convention.

Parameters
  • identity (pfs.datamodel.Identity) – Identification of the data of interest.

  • dirName (str, optional) – Directory from which to read.

Returns

self – Spectra read from file.

Return type

PfsFiberArraySet

classmethod readFits(filename)[source]

Read from FITS file

This API is intended for use by the LSST data butler, which handles translating the desired identity into a filename.

Parameters

filename (str) – Filename of FITS file.

Returns

self – Constructed instance, from FITS file.

Return type

cls

validate()[source]

Validate that all the arrays are of the expected shape

property variance

Shortcut for variance

write(dirName='.')[source]

Write to file

This API is intended for use by science users, as it allows setting the correct filename from parameters that make sense, such as which exposure, spectrograph, etc.

Parameters

dirName (str, optional) – Directory to which to write.

writeFits(filename)[source]

Write to FITS file

This API is intended for use by the LSST data butler, which handles translating the desired identity into a filename.

Parameters

filename (str) – Filename of FITS file.

specdash.input.pfs.pfs.datamodel.pfsFiberTrace module

specdash.input.pfs.pfs.datamodel.pfsSimpleSpectrum module

class specdash.input.pfs.pfs.datamodel.pfsSimpleSpectrum.PfsSimpleSpectrum(target, wavelength, flux, mask, flags, metadata=None)[source]

Bases: object

Spectrum for a single object

This base class is suitable for model spectra which have not been extracted from observations.

Parameters
  • target (pfs.datamodel.Target) – Target information.

  • wavelength (numpy.ndarray of float) – Array of wavelengths.

  • flux (numpy.ndarray of float) – Array of fluxes.

  • mask (numpy.ndarray of int) – Array of mask pixels.

  • flags (pfs.datamodel.MaskHelper) – Helper for dealing with symbolic names for mask values.

  • metadata (dict (str: POD), optional) – Keyword-value pairs for the header.

filenameFormat = None
getIdentity()[source]

Return the identity of the spectrum

Returns

identity – Key-value pairs that identify this spectrum.

Return type

dict

classmethod read(identity, dirName='.')[source]

Read from file

This API is intended for use by science users, as it allows selection of the correct file from parameters that make sense, such as which catId, objId, etc.

Parameters
  • identity (dict) – Keyword-value pairs identifying the data of interest. Common keywords include catId, tract, patch, objId.

  • dirName (str, optional) – Directory from which to read.

Returns

self – Spectrum read from file.

Return type

cls

classmethod readFits(filename)[source]

Read from FITS file

This API is intended for use by the LSST data butler, which handles translating the desired identity into a filename.

Parameters

filename (str) – Filename of FITS file.

Returns

self – Constructed instance, from FITS file.

Return type

cls

validate()[source]

Validate that all the arrays are of the expected shape

write(dirName='.')[source]

Write to file

This API is intended for use by science users, as it allows setting the correct filename from parameters that make sense, such as which catId, objId, etc.

Parameters

dirName (str, optional) – Directory to which to write.

writeFits(filename)[source]

Write to FITS file

This API is intended for use by the LSST data butler, which handles translating the desired identity into a filename.

Parameters

filename (str) – Filename of FITS file.

specdash.input.pfs.pfs.datamodel.target module

class specdash.input.pfs.pfs.datamodel.target.Target(catId, tract, patch, objId, ra=nan, dec=nan, targetType=- 1, fiberMags=None)[source]

Bases: types.SimpleNamespace

A spectroscopic target

Parameters
  • catId (int) – Catalog identifier of the object.

  • tract (int) – Tract in which the object resides.

  • patch (str) – Patch in which the object resides.

  • objId (objId) – Object identifier of the object.

  • ra (float, optional) – Right Ascension of the object.

  • dec (float, optional) – Declination of the object.

  • targetType (TargetType, optional) – Type of target (typically SCIENCE).

  • fiberMags (dict mapping str to float, optional) – Filter names and corresponding fiber magnitudes.

classmethod fromFits(fits)[source]

Construct from a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

Returns

self – Constructed Target.

Return type

Target

classmethod fromPfsConfig(pfsConfig, index)[source]

Construct from a PfsConfig

Parameters
  • pfsConfig (pfs.datamodel.PfsConfig) – Top-end configuration.

  • index (int) – Index into the pfsConfig arrays for the target of interest.

Returns

self – Constructed Target.

Return type

cls

toFits(fits)[source]

Write to a FITS file

Parameters

fits (astropy.io.fits.HDUList) – Opened FITS file.

specdash.input.pfs.pfs.datamodel.utils module

specdash.input.pfs.pfs.datamodel.utils.astropyHeaderFromDict(metadata)[source]

Convert a dict to an astropy FITS header

Parameters

metadata (dict) – FITS header keywords and values.

Returns

header – FITS header.

Return type

astropy.io.fits.Header

specdash.input.pfs.pfs.datamodel.utils.astropyHeaderToDict(header)[source]

Convert an astropy FITS header to a dict

Comments are not preserved, nor are COMMENT or HISTORY cards.

Parameters

header (astropy.io.fits.Header) – FITS header.

Returns

metadata – FITS header keywords and values.

Return type

dict

specdash.input.pfs.pfs.datamodel.utils.calculatePfsVisitHash(visits)[source]

Calculate and return a hash from a list of visits

Parameters

visits (list of int) – List of visit numbers.

Returns

hash – Hash of the visits.

Return type

int

specdash.input.pfs.pfs.datamodel.utils.createHash(*args)[source]

Create a hash from the input strings truncated to 64 bits.

Parameters

*args (str) – input string values used to generate the hash.

Returns

truncatedHash – truncated hash value

Return type

int

specdash.input.pfs.pfs.datamodel.utils.inheritDocstrings(cls)[source]

Class decorator to inherit docstrings from base classes

Docstrings are copied, changing any instances of the base class name to the subclass name. The docstring is inserted into a new method that calls the parent class implementation.

specdash.input.pfs.pfs.datamodel.utils.wraparoundNVisit(nVisit)[source]

Wraparound number of visits to acceptable range (0-999)

Parameters

nVisit (int) – number of visits

Returns

nVisit_wrapped – wraparound number of visits

Return type

int

specdash.input.pfs.pfs.datamodel.wavelengthArray module

class specdash.input.pfs.pfs.datamodel.wavelengthArray.WavelengthArray(minWavelength, maxWavelength, length, dtype=<class 'numpy.float32'>)[source]

Bases: numpy.ndarray

An array of wavelengths

This subclass of numpy.ndarray keeps track of the construction parameters and uses them to create a FITS header with WCS. Specifying the wavelength in this way allows persisting the wavelength as a small handful of header keywords instead of thousands of values in a predictable series.

This is a functional numpy array, although it is read-only to prevent the construction parameters from getting out of sync with the array values. If you find the need to change the values, copy() this array first.

Parameters
  • minWavelength (float) – Minimum wavelength (nm).

  • maxWavelength (float) – Maximum wavelength (nm).

  • length (int) – Number of values.

  • dtype (numpy.dtype, optional) – Data type.

classmethod fromFitsHeader(header, length, dtype=<class 'numpy.float32'>)[source]

Construct from a FITS header

Parameters
  • header (astropy.io.fits.Header) – FITS header with WCS specifying wavelength array.

  • length (int) – Length of the array.

  • dtype (numpy.dtype) – Array data type.

Returns

self – Constructed wavelength array.

Return type

cls

toFitsHeader()[source]

Convert to a FITS header

Returns

header – FITS header with WCS specifying wavelength array.

Return type

astropy.io.fits.Header

Module contents