soxspipe.commonutils.horne_extraction

perform optimal source extraction using the Horne method (Horne 1986)

Author

Marco Landoni & David Young

Date Created

May 17, 2023

Module Contents

Classes

horne_extraction

perform optimal source extraction using the Horne method (Horne 1986)

Functions

create_cross_dispersion_slices

This function is used to create a single, 1-pixel wide cross-dispersion slices of object data. When applied to the dataframe, a single slice is created for each discrete pixel position in the dispersion direction

extract_single_order

extract the object spectrum for a single order

API

soxspipe.commonutils.horne_extraction.create_cross_dispersion_slices(crossDispersionSlices)[source][source]

This function is used to create a single, 1-pixel wide cross-dispersion slices of object data. When applied to the dataframe, a single slice is created for each discrete pixel position in the dispersion direction

Key Arguments:

  • crossDispersionSlices – the seed dataframe

Return:

  • crossDispersionSlices – dataframe containing metadata for each cross-dispersion slice (single data-points in extracted spectrum)

soxspipe.commonutils.horne_extraction.extract_single_order(crossDispersionSlices, funclog, ron, slitHalfLength, clippingSigma, clippingIterationLimit, globalClippingSigma, axisA, axisB, gain=1.0, hornePolyOrder=3, debug=False)[source][source]

extract the object spectrum for a single order

Return:

  • crossDispersionSlices – dataframe containing metadata for each cross-dispersion slice (single data-points in extracted spectrum)

class soxspipe.commonutils.horne_extraction.horne_extraction(log, settings, recipeSettings, skyModelFrame, skySubtractedFrame, unflattenedFrame, twoDMapPath, recipeName=False, qcTable=False, productsTable=False, dispersionMap=False, sofName=False, locationSetIndex=False, startNightDate='', notFlattened=False, debug=False, turnOffMP=False)[source][source]

Bases: object

perform optimal source extraction using the Horne method (Horne 1986)

Key Arguments:

  • log – logger

  • settings – the settings dictionary

  • recipeSettings – the recipe specific settings

  • skyModelFrame – path to sky model frame

  • skySubtractedFrame – path to sky subtracted frame

  • unflattenedFrame – path to unflattened frame

  • twoDMapPath – path to 2D dispersion map image path

  • recipeName – name of the recipe as it appears in the settings dictionary

  • qcTable – the data frame to collect measured QC metrics

  • productsTable – the data frame to collect output products (if False no products are saved to file)

  • dispersionMap – the FITS binary table containing dispersion map polynomial

  • sofName – the set-of-files filename

  • locationSetIndex – the index of the AB cycle locations (nodding mode only). Default False

  • startNightDate – YYYY-MM-DD date of the observation night. Default “”

  • notFlattened – flag to indicate if the frame is flattened or not. Default False

  • debug – flag to indicate if debug mode is on (shows plots). Default False

  • turnOffMP – turn off multiprocessing. True or False. Default False. If True, multiprocessing will be turned off and the recipe will run in serial. This is useful for debugging.

Usage:

To setup your logger, settings and database connections, please use the fundamentals package (see tutorial here https://fundamentals.readthedocs.io/en/master/initialisation.html).

To initiate a horne_extraction object, use the following:

from soxspipe.commonutils import horne_extraction
optimalExtractor = horne_extraction(
    log=log,
    skyModelFrame=skyModelFrame,
    skySubtractedFrame=skySubtractedFrame,
    unflattenedFrame=unflattenedFrame,
    twoDMapPath=twoDMap,
    settings=settings,
    recipeName="soxs-stare",
    qcTable=qc,
    productsTable=products,
    dispersionMap=dispMap,
    sofName=sofName,
    locationSetIndex=locationSetIndex,
    startNightDate=startNightDate,
    debug=debug,
    turnOffMP=turnOffMP

)
qc, products = optimalExtractor.extract()

Initialization

extract()[source][source]

extract the full spectrum order-by-order and return FITS Binary table containing order-merged spectrum

Return:

  • qcTable – the data frame to collect measured QC metrics

  • productsTable – the data frame to collect output products

  • mergedSpectumDF – path to the FITS binary table containing the merged spectrum

merge_extracted_orders(extractedOrdersDF)[source][source]

merge the extracted order spectra in one continuous spectrum

Key Arguments:

  • extractedOrdersDF – a data-frame containing the extracted orders

Return:

  • None

plot_extracted_spectrum_qc(extractions)[source][source]

plot extracted spectrum QC plot

Key Arguments:

  • extractions – dataframes hosting order extractions

Usage:

optimalExtractor.plot_extracted_spectrum_qc(extractions)
residual_merge(group)[source][source]
weighted_average(group)[source][source]