pypeit.core.collate module

This module contains code for collating multiple 1d spectra source object.

class pypeit.core.collate.SourceObject(spec1d_obj, spec1d_header, spec1d_file, spectrograph, match_type)[source]

Bases: object

A group of reduced spectra from the same source object. This contains the information needed to coadd the spectra and archive the metadata.

An instance is initiated with the first spectra of the group. Additional spectra can be compared with this object to see if it matches using the match method, and are added to it if they do.

Parameters:
  • spec1d_obj (pypeit.specobj.SpecObj) – The initial spectra of the group as a SpecObj.

  • spec1d_header (astropy.io.fits.Header) – The header for the first spec1d file in the group.

  • spec1d_file (str) – Filename of the first spec1d file in the group.

  • spectrograph (pypeit.spectrographs.spectrograph.Spectrograph) – The spectrograph that was used to take the data.

  • match_type (str) – How spectra should be compared. ‘ra/dec’ means the spectra should be compared using the sky coordinates in RA and DEC. ‘pixel’ means the spectra should be compared by the spatial pixel coordinates in the image.

spec_obj_list

The list of spectra in the group as SpecObj objects.

Type:

list of pypeit.spectrographs.spectrograph.Spectrograph

spec1d_file_list

The pathnames of the spec1d files in the group.

Type:

list of str

spec1d_header_list

(list of astropy.io.fits.Header): The headers of the spec1d files in the group

_config_key_match(header)[source]

Check to see if the configuration keys from a spec1d file match the ones for this SourceObject.

Parameters:

header (astropy.io.fits.Header) – Header from a spec1d file.

Returns:

True if the configuration keys match,

false if they do not.

Return type:

bool

classmethod build_source_objects(specobjs_list, spec1d_files, match_type)[source]

Build a list of SourceObjects from a list of spec1d files. There will be one SourceObject per SpecObj in the resulting list (i.e. no combining or collating is done by this method).

Parameters:
  • specobjs_list (list of pypeit.specobjs.SpecObjs) – List of SpecObjs objects to build from.

  • spec1d_files (list of str) – List of spec1d filenames corresponding to each SpecObjs object.

  • match_type (str) – What type of matching the SourceObjects will be configured for. Must be either ‘ra/dec’ or ‘pixel’

Returns:

A list of uncollated SourceObjects with one SpecObj per SourceObject.

Return type:

list of SourceObject

combine(other_source_object)[source]

Combine this SourceObject with another. The two objects must be from the same spectrograph and use the same match type.

Parameters:

other_source_object (SourceObject) – The other object to combine with.

Returns:

This SourceObject, now combined with other_source_object.

Return type:

(SourceObject)

match(spec_obj, spec1d_header, tolerance, unit=Unit('arcsec'))[source]

Determine if a SpecObj matches this group within the given tolerance. This will also compare the configuration keys to make sure the SpecObj is compatible with the ones in this SourceObject.

Parameters:
  • spec_obj (pypeit.specobj.SpecObj) – The SpecObj to compare with this SourceObject.

  • spec1d_header (astropy.io.fits.Header) – The header from the spec1d that dontains the SpecObj.

  • tolerance (float) – Maximum distance that two spectra can be from each other to be considered to be from the same source. Measured in floating point pixels or as an angular distance (see unit1 argument).

  • unit (astropy.units.Unit) – Units of tolerance argument if match_type is ‘ra/dec’. Defaults to arcseconds. Igored if match_type is ‘pixel’.

Returns:

True if the SpecObj matches this group, False otherwise.

Return type:

bool

pypeit.core.collate.collate_spectra_by_source(source_list, tolerance, unit=Unit('arcsec'))[source]

Given a list of spec1d files from PypeIt, group the spectra within the files by their source object. The grouping is done by comparing the position of each spectra (using either pixel or RA/DEC) using a given tolerance.

Parameters:
  • source_list (list of SourceObject) – A list of source objects, one SpecObj per object, ready for collation.

  • tolerance (float) – Maximum distance that two spectra can be from each other to be considered to be from the same source. Measured in floating point pixels or as an angular distance (see unit argument).

  • unit (astropy.units.Unit) – Units of tolerance argument if match_type is ‘ra/dec’. Defaults to arcseconds. Ignored if match_type is ‘pixel’.

Returns:

The collated spectra as SourceObjects.

Return type:

list