pypeit.manual_extract module

Implements an object to handle manual object extraction.

class pypeit.manual_extract.ManualCubeExtractionObj(spatx=None, spaty=None, fwhm=None, boxcar_rad=None)[source]

Bases: DataContainer

A data container holding the arguments for how to perform the manual extraction of a spectrum from a datacube with pypeit_extract_datacube.

To perform a set of user-defined extractions on a datacube, a list of these objects is created in the .extract file which can be input to pypeit_extract_datacube with the -e option.

The datamodel attributes are:

Version: 1.1.0

Attribute

Type

Array Type

Description

boxcar_rad

numpy.ndarray

numpy.floating

Boxcar radius for manual extractions in arcseconds (optional, not yet used)

fwhm

numpy.ndarray

numpy.floating

FWHMs for manual extractions in arcseconds (optional, not yet used)

spatx

numpy.ndarray

numpy.floating

Cube spatial x positions to manually extract

spaty

numpy.ndarray

numpy.floating

Cube spatial y positions to manually extract

Parameters:
  • spatx (numpy.ndarray) – Array of spatial x positions to manually extract. These are image x coordinates as read from Ginga or DS9, corresponding to the second numpy image axis.

  • spaty (numpy.ndarray) – Array of spatial y positions to manually extract. These are image y coordinates as read from Ginga or DS9, corresponding to the first numpy image axis.

  • fwhm (numpy.ndarray, optional) – Array of FWHM for manual extraction in arcseconds. This must be aligned with spatx and spaty.

  • boxcar_rad (numpy.ndarray, optional) – Array of boxcar_radii in arcseconds for manual extraction. This must be aligned with spatx and spaty.

_validate()[source]

Validate

A couple of quick checks..

Raises:

ValueError – Raised if one of the arrays is not set or if they don’t have the same length

datamodel = {'boxcar_rad': {'atype': <class 'numpy.floating'>, 'descr': 'Boxcar radius for manual extractions in arcseconds (optional, not yet used)', 'otype': <class 'numpy.ndarray'>}, 'fwhm': {'atype': <class 'numpy.floating'>, 'descr': 'FWHMs for manual extractions in arcseconds (optional, not yet used)', 'otype': <class 'numpy.ndarray'>}, 'spatx': {'atype': <class 'numpy.floating'>, 'descr': 'Cube spatial x positions to manually extract', 'otype': <class 'numpy.ndarray'>}, 'spaty': {'atype': <class 'numpy.floating'>, 'descr': 'Cube spatial y positions to manually extract', 'otype': <class 'numpy.ndarray'>}}

Provides the class data model. This is undefined in the abstract class and should be overwritten in the derived classes.

The format of the datamodel needed for each implementation of a DataContainer derived class is as follows.

The datamodel itself is a class attribute (i.e., it is a member of the class, not just of an instance of the class). The datamodel is a dictionary of dictionaries: Each key of the datamodel dictionary provides the name of a given datamodel element, and the associated item (dictionary) for the datamodel element provides the type and description information for that datamodel element. For each datamodel element, the dictionary item must provide:

  • otype: This is the type of the object for this datamodel item. E.g., for a float or a numpy.ndarray, you would set otype=float and otype=np.ndarray, respectively.

  • descr: This provides a text description of the datamodel element. This is used to construct the datamodel tables in the pypeit documentation.

If the object type is a numpy.ndarray, you should also provide the atype keyword that sets the type of the data contained within the array. E.g., for a floating point array containing an image, your datamodel could be simply:

datamodel = {'image' : dict(otype=np.ndarray, atype=float, descr='My image')}

More advanced examples are given in the top-level module documentation.

Currently, datamodel components are restricted to have otype that are tuple, int, float, numpy.integer, numpy.floating, numpy.ndarray, or astropy.table.Table objects. E.g., datamodel values for otype cannot be dict.

classmethod parse(inp)[source]

Generate the object from a string input from the manual parameter in the parset.

Parameters:

inp (str) – String specifying the manual aperture, in x:y format. The x,y values are the image coordinates read from Ginga or DS9. In numpy terms, if the image has shape (ny, nx), a position (x, y) refers to image[y, x]. This method also parses the optional x:y:fwhm:boxcar_radius format and semi-colon-separated multiple positions, but neither is yet supported by the rest of the datacube extraction pipeline, which currently only uses a single x:y position.

Returns:

Object used to define the extraction.

Return type:

ManualCubeExtractionObj

to_dict()[source]

Repackage into a dict for the extraction code

Returns:

To be passed into datacube.extract_point_source

Return type:

dict or None

version = '1.1.0'

Provides the string representation of the class version.

This is currently put to minimal use so far, but will used for I/O verification in the future.

Each derived class should provide a version to guard against data model changes during development.

class pypeit.manual_extract.ManualExtractionObj(frame=None, spat=None, spec=None, detname=None, fwhm=None, neg=None, boxcar_rad=None)[source]

Bases: DataContainer

A data container holding the arguments for how to perform the manual extraction of a spectrum.

A list of these objects is generated in pypeit.py to perform a set of user-defined extractions.

For an example of how to define a series of manual extractions in the pypeit input file, see PypeIt Reduction File.

The datamodel attributes are:

Version: 1.1.0

Attribute

Type

Array Type

Description

boxcar_rad

numpy.ndarray

numpy.floating

Boxcar radius for manual extractions (optional)

detname

numpy.ndarray

str

detectors name for manual extraction.

frame

str

The name of the fits file for a manual extraction

fwhm

numpy.ndarray

numpy.floating

FWHMs for manual extractions

neg

numpy.ndarray

numpy.bool

Flags indicating which manual extraction is a negative trace

spat

numpy.ndarray

numpy.floating

spatial positions to manually extract

spec

numpy.ndarray

numpy.floating

spectral positions to manually extract

Parameters:
  • frame (str) – The name of the fits file for a manual extraction

  • spat (numpy.ndarray) – Array of spatial positions to manually extract

  • spec (numpy.ndarray) – Array of spectral positions to manually extract

  • det (numpy.ndarray) – Array of detectors for manual extraction. This must be a aligned with spec and spat . The values can be negative (for negative images)

  • fwhm (numpy.ndarray) – Array of FWHM for manual extraction. This must be aligned with spec and spat.

  • boxcar_rad (numpy.ndarray, optional) – Array of boxcar_radii for manual extraction. This must be aligned with spec and spat. It is to be in pixels, not arcsec. This is only intended for multi-slit reductions (not Echelle)

_validate()[source]

Validate

A couple of quick checks..

Raises:

ValueError – Raised if one of the arrays is not set or if they don’t have the same length

classmethod by_fitstbl_input(frame, inp, spectrograph)[source]

Generate the object from an entry in the fitstbl

Parameters:
  • frame (str) – filename

  • inp (str) – String specifying the manual aperture: det:spat:spec:fwhm; e.g., 1:1181.8:3820.6:3.

  • spectrograph (pypeit.spectrographs.spectrograph.Spectrograph) – The Spectrograph instance that sets the instrument used to take the observations. Used to set check that the input value of the mosaic detectors are allowed for this spectrograph

Return type:

ManualExtractionObj

datamodel = {'boxcar_rad': {'atype': <class 'numpy.floating'>, 'descr': 'Boxcar radius for manual extractions (optional)', 'otype': <class 'numpy.ndarray'>}, 'detname': {'atype': <class 'str'>, 'descr': 'detectors name for manual extraction.', 'otype': <class 'numpy.ndarray'>}, 'frame': {'descr': 'The name of the fits file for a manual extraction', 'otype': <class 'str'>}, 'fwhm': {'atype': <class 'numpy.floating'>, 'descr': 'FWHMs for manual extractions', 'otype': <class 'numpy.ndarray'>}, 'neg': {'atype': <class 'numpy.bool'>, 'descr': 'Flags indicating which manual extraction is a negative trace', 'otype': <class 'numpy.ndarray'>}, 'spat': {'atype': <class 'numpy.floating'>, 'descr': 'spatial positions to manually extract', 'otype': <class 'numpy.ndarray'>}, 'spec': {'atype': <class 'numpy.floating'>, 'descr': 'spectral positions to manually extract', 'otype': <class 'numpy.ndarray'>}}

Provides the class data model. This is undefined in the abstract class and should be overwritten in the derived classes.

The format of the datamodel needed for each implementation of a DataContainer derived class is as follows.

The datamodel itself is a class attribute (i.e., it is a member of the class, not just of an instance of the class). The datamodel is a dictionary of dictionaries: Each key of the datamodel dictionary provides the name of a given datamodel element, and the associated item (dictionary) for the datamodel element provides the type and description information for that datamodel element. For each datamodel element, the dictionary item must provide:

  • otype: This is the type of the object for this datamodel item. E.g., for a float or a numpy.ndarray, you would set otype=float and otype=np.ndarray, respectively.

  • descr: This provides a text description of the datamodel element. This is used to construct the datamodel tables in the pypeit documentation.

If the object type is a numpy.ndarray, you should also provide the atype keyword that sets the type of the data contained within the array. E.g., for a floating point array containing an image, your datamodel could be simply:

datamodel = {'image' : dict(otype=np.ndarray, atype=float, descr='My image')}

More advanced examples are given in the top-level module documentation.

Currently, datamodel components are restricted to have otype that are tuple, int, float, numpy.integer, numpy.floating, numpy.ndarray, or astropy.table.Table objects. E.g., datamodel values for otype cannot be dict.

dict_for_objfind(detname, neg=False)[source]

Repackage into a dict for the extraction code

Parameters:
  • det (str) – Detector name under consideration

  • neg (bool, optional) – If True, return the negative image requests

Returns:

To be passed into reduce.find_objects()

Return type:

dict or None

version = '1.1.0'

Provides the string representation of the class version.

This is currently put to minimal use so far, but will used for I/O verification in the future.

Each derived class should provide a version to guard against data model changes during development.