Utilizing AstroData descriptors on GMOS Long Slit datasets

Home Forums Gemini Data Reduction Utilizing AstroData descriptors on GMOS Long Slit datasets

This topic contains 0 replies, has 1 voice, and was last updated by Kenneth Anderson Kenneth Anderson 4 years, 8 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #759
    Kenneth Anderson
    Kenneth Anderson
    Moderator

    Recently, the subject was raised about how one can use AstroData to provide wavelength start and end values on calibrated GMOS Long Slit data. The short answer is that AstroData does not provide that directly (although it could if it were so desired by the user community).

    What one can do, however, is still employ the AstroData Descriptors available to derive those values. A function was born that will (mostly) use AstroData descriptors to return a tuple of floats, the start and end values of the wavelength band of the long slit image. But the function uses the AstroData interface exclusively to retrieve all required metadata to do the calculation.

    Note: The function type checks on the passed dataset to ensure that a calibrated GMOS_LS image is passed. Returns a tuple of values: wavelength start and end. The function can accept either a filename as as string or an AstroData instance.

    Eg., example of usage:

    $python
    [ ... ]
    >>> from astrodata import AstroData
    >>> from wave_range import wave_range
    >>> ls_file = "../tgsS20140405S0084.fits"
    >>> wave_range(ls_file)
    (3656.8373557925224, 5117.759352326394)

    Or work from an AstroData instance:

    >>> ls_ad = AstroData(ls_file)
    >>> wave_range(ls_ad)
    (3656.8373557925224, 5117.759352326394)

    The latter function call will be noticeably quicker, since it doesn't have to open the file and build an AstroData instance.

    Here's the function:

    def wave_range(dataset):
        """
        Passed dataset should be a filename of a calibrated GMOS LONG SLIT
        observation or an AstroData instance of same. The dataset should
        have only one (1) pixel data extension ("SCI").
    
        :param dataset: File name or AstroData instance
        :type dataset:  <str> or <AstroData>
        :returns: A tuple of strings: wavelength start, end
        :rtype: <tuple>
        :raises: TypeError
    
        """
        from astrodata import AstroData
        if isinstance(dataset, AstroData):
            ad = dataset
        elif isinstance(dataset, str):
            ad = AstroData(dataset)
        else:
            raise TypeError("Unrecognized argument type")
    
        # # ensure a calibrated GMOS_LS type was passed.
        if "GMOS_LS" not in ad.types and "PREPARED" not in ad.types:
            raise TypeError("Not a PREPARED Long slit")
    
        rad  = ad["SCI"]
        disp = rad.dispersion().get_value()
        refpix = rad.wavelength_reference_pixel().get_value()
        lenaxis = len(rad.data[refpix])
        ref_value = rad.header["CRVAL1"]
        wave_start= ref_value - refpix * disp
        wave_end =  ref_value + lenaxis * disp
        return wave_start, wave_end
    

    The one value needed but not provided by a descriptor call is ‘CRVAL1′ which holds the calibrated wavelength value of the reference pixel in calibrated GMOS long slit data. (I think this may be a bit of an oversight in the descriptor set, but is readily corrected should users express interest in seeing a descriptor for this.)

    The function could be extended on other types, such as F2_LS, if those calibrated data provide the metadata needed, i.e dispersion (in GMOS_LS’ this is ‘CD1_1’) and the value of the reference pixel in wavelength space (in GMOS_LS this is ‘CRVAL1’). Indeed, if calibrated F2 long slit provided the expected information in ‘CRVAL1’, this function would work on those data as well (minus the GMOS_LS type checking).

    For convenience, users can find a module with the above function and may use this instead of writing out their own module. The module moves the import outside of the function.

    If the forum community expressed interest, future posts could address how users/developers can extend the AstroData class to bind their own functions as methods on an AstroData instance.

    • This topic was modified 4 years, 8 months ago by Kenneth Anderson Kenneth Anderson.
    • This topic was modified 4 years, 8 months ago by Kenneth Anderson Kenneth Anderson. Reason: code block fix
    • This topic was modified 4 years, 8 months ago by Kenneth Anderson Kenneth Anderson. Reason: more code block fixes
    • This topic was modified 4 years, 8 months ago by Kenneth Anderson Kenneth Anderson.
    Attachments:
    1. wave_range.py
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.