podi_matchpupilghost Module

podi_matchpupilghost

This module contains all routines and functionality related to removing the pupilghost signature from either the flat-field or a science frame.

Standalone functions:

Most routines are made to be called from other routines, but the following stand-alone modi exist:

  • Create a radial profile from a full 2-d template

    Run as : ./podi_matchpupilghost -makeradial 2d-template.fits 1d-output.fits

  • Compute the best-fitting scaling factor for the template

    Run as: ./podi_matchpupilghost -getscaling science_input.fits template.fits

  • Subtract the pupilghost from a given frame, with automatic scaling

    Run as: ./podi_matchpupilghost -cleanpupilghost inputframe.fits template.fits output.fits

    In this case, the scaling factor is automatically derived in the same manner as with the -getscaling flag described above.

  • Subtract the pupilghost from a given frame

    Run as: ./podi_matchpupilghost -cleanpupilghost inputframe.fits template.fits output.fits (scaling)

    (scaling is optional, and a value of 1.0 is assumed if no value is given.

Modules

podi_matchpupilghost.create_azimuthal_template(filename, outputfilename)[source]

This routine will read the full pupilghost template and create a radial profile by averaging out the azimuthal variations. This radial pupil template will then be used in collectcells to remove the pupil ghost from science frames.

podi_matchpupilghost.get_pupilghost_scaling(science_frame, pupilghost_frame, n_samples=750, boxwidth=20, verbose=True)[source]

Find the optimum scaling for the pupil ghost. This is done by sampling the image frame and the pupil ghost template at a range of identical positions. The median ratio between these measurements then yields the scaling ratio.

Parameters :
  • science_frame (string or HDUList) –

    If science frame is a string, it is interpreted as the filename of the science frame for which we are to obtain the scaling. Alternatively you can also pass the HDUList of the science frame.

  • pupilghost_template (string of HDUList) –

    same as above, just for the pupil-ghost template

  • n_samples (int) –

    Number of intensity samples to take from each OTA when deriving the optimum scaling factor.

  • boxwidth (int) –

    Size of the sample box, in pixels

Returns:

  • median_scaling_factor
  • standard deviation of scaling factor

podi_matchpupilghost.subtract_pupilghost(input_hdu, pupil_hdu, scaling, rotate=True, verbose=True, source_center_coords='data')[source]

This is a wrapper around the subtract_pupilghost_extension routine, going through all the extensions that might have a pupil ghost.

podi_matchpupilghost.subtract_pupilghost_extension(input_hdu, rotator_angle, filtername, pupil_hdu, scaling, rotate=True, verbose=True, non_negative=True, source_center_coords='data')[source]

Contains all functionality to execute the actual pupil ghost removal. The pupil ghost is roatted to match the rotation angle of the science frame, then scaled with the specified scaling factor and lastly the scaled template is removed from the science frame. The results stay in the input_hdu variable that is also returned.

Parameters :
  • input_hdu (pyfits.HDU) – Has to be a valid ImageHDU. This HDU is the source of the image data that contains the pupilghost, as well as the EXTNAME keyword to select the correct template.
  • rotator_angle (float) – Rotator angle from the primary HDU
  • filtername (string) – This parameter is only important if source_center_coords is not set to ‘header’ or ‘data’. In that case, it defines the filter for the set of set of pre-canned pupilghost center coordinates
  • pupil_hdu (pyfits.HDUList) – HDUlist containing the pupilghost template
  • scaling (float) – scaling factor for the pupilghost amplutide
  • rotate (Bool) – Apply rotation (see rotator_angle) to the pupilghost template before removing it from the input data
  • verbose (Bool) – Output some progress updates during runtime
  • non_negative (Bool) – if set, all negative values in the pupilghost templates (that are very likely unphysical) are clipped to 0.
  • source_center_coords ((‘data’, ‘header’, ‘xxx’).) – if set to ‘data’, the center of the pupilghost is determined auto- matically during execution. If set to ‘header’, it is assumed that the input-hdu already contains header keywords with information about the location of the pupilghost. This is likely not the case for flat- field data, but important for science frames. All other values use the pre-canned coordinates given in podi_definitions.
Returns:

No return value per se, changes are reflected in input_hdu

See also

dev_pgcenter.find_pupilghost_center

Table Of Contents