4.2. Utilities

Besides the modules for data reduction, PAPI has a set of utilities than can be used as tools for preparing the data reduction execution; they are:

Utilities

Description

check_papi_modules

Check whether all python modules required by PAPI are installed

checkQuality

Computes some quality values from the image (FWHM, STD, RMS)

collapse

Collapse (sum) each cube of a list of files into a single 2D image

cropFITS

Crops a specified region of a FITS image and updates the header keywords (e.g., CRPIX, CRVAL) to maintain correct astrometric information.

mef

Utilities to convert FITS/MEF files.

eval_focus_serie

Finds out the best Focus value from a focus series

genLogsheet

Creates a log sheet from a set of FITS files

health

Compute the Gain and Noise from a set of flat images grouped in packets and with increased level of Integration Time

imtrim

Cut/crop edges of the input image

modFits

Modifies a keyword inside a FITS header

skyfilter

Subtracts sky background to a dither sequence of frames

spatial_noise

Compute the Spatial Noise from a set of dark images grouped in pairs with the same Integration Time

4.2.1. check_papi_modules

Check whether all Python modules required by PAPI are installed. The modules currently required are:

Module

Version

Numpy

1.6

PyRaf

1.1

PyFITS

3.0

Matplotlib

0.98.1

Scipy

0.10

PyQt4.QtCore

4.8

PyWCS

1.11

vo

0.7

Atpy

0.95

Example:

$ check_papi_modules.py

PAPI Python checking tool
=========================

Checking Python Version:
PAPI needs Python Version 2.Y with Y>=2.7
Your Python version 2.7.3 is fine!

Testing Python module installation for module 'atpy':
PAPI needs at least version 0.9.5
Your version 0.9.6 of 'atpy' is fine!

Testing Python module installation for module 'scipy':
PAPI needs at least version 0.10
Your version 0.10.1 of 'scipy' is fine!

Testing Python module installation for module 'pywcs':
PAPI needs at least version 1.11
Your version 1.11-4.10 of 'pywcs' is fine!

Testing Python module installation for module 'PyQt4.QtCore':
PAPI needs at least version 4.8
Your version 4.9.1 of 'PyQt4.QtCore' is fine!

Testing Python module installation for module 'vo':
PAPI needs at least version 0.7
Your version 0.8 of 'vo' is fine!

Testing Python module installation for module 'numpy':
PAPI needs at least version 1.6
Your version 1.6.2 of 'numpy' is fine!

Testing Python module installation for module 'pyraf':
PAPI needs at least version 1.1
Your version 2.0 of 'pyraf' is fine!

Testing Python module installation for module 'matplotlib':
PAPI needs at least version 0.98.1
Your version 1.1.0 of 'matplotlib' is fine!

Testing Python module installation for module 'pyfits':
PAPI needs at least version 3.0
Your version 3.1.0 of 'pyfits' is fine!

4.2.2. collapse

SYNOPSIS:

Usage: collapse.py [options] arg1 arg2 ...

Options:
-h, --help            show this help message and exit
-i INPUT_IMAGE, --input_image=INPUT_IMAGE
                        input cube image to collapse into a 2D image
-l INPUT_IMAGE_LIST, --input_image_list=INPUT_IMAGE_LIST
                        input image list to collapse into a single 2D image
-o OUTPUT_FILE, --output_file=OUTPUT_FILE
                        output filename (default = /tmp/out.fits)

DESCRIPTION:

Sum (add them up arithmetically) the planes of each cube of a list files into a single plane 2D-image. No image registration is done.

EXAMPLES:

$ collapse -i /data/mycube.fits -o /data/anymore_a_cube.fits

$ collapse -l /data/list.txt -o /data/anymore_a_cube.fits

4.2.3. cropFITS

SYNOPSIS:

Usage: cropFITS.py [-h] [-f FILE_LIST] [-od OUTPUT_DIR] [--suffix SUFFIX]
                   [-i INPUT_FITS_NAMED] [-o OUTPUT_FITS_NAMED]
                   [-xs X_START_NAMED] [-xe X_END_NAMED] [-ys Y_START_NAMED]
                   [-ye Y_END_NAMED] [--quiet]
                   [input_fits] [output_fits] [x_start] [x_end] [y_start]
                   [y_end]

Crop FITS image(s) and update header accordingly.

positional arguments:
  input_fits            Path to the input FITS file
  output_fits           Path to the output cropped FITS file
  x_start               Start x-coordinate (0-indexed, inclusive)
  x_end                 End x-coordinate (0-indexed, exclusive)
  y_start               Start y-coordinate (0-indexed, inclusive)
  y_end                 End y-coordinate (0-indexed, exclusive)

optional arguments:
  -h, --help            show this help message and exit
  -f FILE_LIST, --file_list FILE_LIST
                        Text file containing list of FITS files to process
                        (one per line)
  -od OUTPUT_DIR, --output_dir OUTPUT_DIR
                        Output directory for batch processing (default: same
                        as input)
  --suffix SUFFIX       Suffix to add to output filenames in batch mode
                        (default: '_cropped')
  -i INPUT_FITS_NAMED, --input_fits_flag INPUT_FITS_NAMED
                        Path to the input FITS file (named argument)
  -o OUTPUT_FITS_NAMED, --output_fits_flag OUTPUT_FITS_NAMED
                        Path to the output cropped FITS file (named argument)
  -xs X_START_NAMED, --x_start_flag X_START_NAMED
                        Start x-coordinate (named argument)
  -xe X_END_NAMED, --x_end_flag X_END_NAMED
                        End x-coordinate (named argument)
  -ys Y_START_NAMED, --y_start_flag Y_START_NAMED
                        Start y-coordinate (named argument)
  -ye Y_END_NAMED, --y_end_flag Y_END_NAMED
                        End y-coordinate (named argument)
  --quiet, -q           Suppress progress messages

Examples:
  Single file (positional):
    cropFITS.py input.fits output.fits 100 500 200 600

  Single file (named):
    cropFITS.py -i input.fits -o output.fits -xs 100 -xe 500 -ys 200 -ye 600

  Multiple files from list:
    cropFITS.py --file_list files.txt -xs 100 -xe 500 -ys 200 -ye 600
    cropFITS.py --file_list files.txt --output_dir cropped/ -xs 0 -xe 1024 -ys 0 -ye 1024
    cropFITS.py -f files.txt -od ./output -xs 100 -xe 500 -ys 200 -ye 600 --suffix _crop

DESCRIPTION:

Utility to extract a specified region of a FITS image and automatically updates the header keywords (e.g., CRPIX, CRVAL) to maintain correct astrometric information. Multiple files can be processed by supplying a text file containing the list of input FITS files.

4.2.4. mef

SYNOPSIS:

Usage: mef [options] arg1 arg2

Options:
-h, --help            show this help message and exit
-f FILE, --file=FILE  Input MEF file. It has to be a fullpath file name
-l INPUT_FILE_LIST, --input=INPUT_FILE_LIST
                      Source file list of data frames. It has to be a
                      fullpath file name.
-s OUT_SUFFIX, --suffix=OUT_SUFFIX
                      suffix to out files (default .Q%02d.fits)
-J, --join            make a join/stitch of the FITS extensions creating a
                      single FITS file
-S, --split           make a split of MEF files, adding a suffix for each
                      extension
-P, --slice           Slice a MEF-cube, adding a suffix for each plane
-G, --geirs-split     make a split of GEIRS SEF file, creating 4-single
                      files and adding a suffix for each extension
-C, --create          create a MEF (with N extensions) from a set N single
                      FITS files
-g, --geirs-convert   convert a GEIRS SEF file to a MEF FITS file with 4
                      extensions
-d OUTPUT_DIR, --output_dir=OUTPUT_DIR
                      Directory where output files will be saves.
-o OUTPUT_FILE, --output_file=OUTPUT_FILE
                      Filename of the output file created [default =
                      mef.fits].

DESCRIPTION:

Utility to convert MEF/FITS files generated by PANIC to different formats:

  • MEF -> SEF (–join)

  • SEF -> MEF (-g)

  • split a MEF/SEF (–split)

  • build MEF from N-SEFs (–create)

  • slice a MEF-cube (–slice)

EXAMPLES:

$ mef -f /tmp/myMEF_cube.fits -P -d /tmp/
$ mef -l /tmp/my_files.txt -C -d /tmp/ -o my_mef.fits

4.2.5. checkQuality

The checkQuality module computes some initial image quality estimations using SExtractor.

4.2.6. eval_focus_series

The eval_focus_series module computes the best focus estimation for a focus exposure series. It is done according to the FWHM value estimated for each frame, fitting a curve the the values pair values (FWHM,focus) and finding out the minimun.

  • Requirements

    • T-FOCUS (telescope focus) keyword value present in the header

    • (Raw) Images with enought number of stars

    • A series of images taken with covering a range of telescope focus values including the best focus value.

4.2.7. genLogsheet

4.2.8. health

4.2.9. imtrim

4.2.10. modFits

4.2.11. skyfilter

The skyfilter module uses the external package irdr_skyfilter to perform the sky background subtraction from a dither sequence of science frames. It works with almost all kind of dither sequences, even with sequences used for extended objects (T-S-T-S- …., T-T-S-T-T-S-T-T-….)

For more details on skyfilter see the Appendix section skyfilter.

4.2.12. spatial_noise