podi_definitions Module

This module contains a number of global constants required during reduction, as well as functions that are widely used throughout the other modules. Some general definitions useful in a number of podi scripts

podi_definitions.break_region_string(str_region)[source]

Break down a IRAF-like string (e.g. [0:100,0:200]) into its four components and return them separately.

podi_definitions.cell2ota__extract_data_from_cell(data_in=None)[source]

Don’t use anymore!

podi_definitions.cell2ota__get_target_region(x, y, binning=1)[source]

Get the location of a given cell in the monolithic OTA array, accounting for binning (only 1x1 and 2x2 supported).

podi_definitions.center_coords(hdr)[source]

Return the center coordinates of a given HDU, based on the WCS information (does not include distortion).

podi_definitions.clobberfile(filename)[source]

Delete a file if it already exists, otherwise do nothing.

podi_definitions.cmdline_arg_isset(arg)[source]

Check if the given argument was given on the command line

podi_definitions.cmdline_arg_set_or_default(name, defvalue)[source]

Return the value of a command line argument. If no argument was passed (for example -flag= ), assign the specified default value instead.

podi_definitions.create_qa_filename(outputfile, plotname, options)[source]

Return the filename for a given diagnostic plot, accounting for user-specified preferences.

podi_definitions.create_qa_otaplot_filename(plotname, ota, structure_qa_subdirs)[source]

Return the filename for a given OTA-level diagnostic plot, accounting for user-specified preferences.

podi_definitions.deg2sexa(deg, signed=False)[source]

Convert a float coordinate into the more user-friednly sexa-decimal format

podi_definitions.derive_ota_outlines(otalist)[source]

For each OTA (extension) in the pased list, derive the sky-position of all 4 corners.

podi_definitions.extract_biassec_from_cell(data, binning)[source]

Return the overscan region of a given cell, accounting for binning

podi_definitions.extract_datasec_from_cell(data, binning)[source]

Return the science region of a given cell, accounting for binning

podi_definitions.extract_region(data, str_region)[source]

Extract a region based on the a IRAF-like region definition.

See also

break_region_string

podi_definitions.get_binning(hdr)[source]

Get the binning factor of a given frame/cell based on its header.

podi_definitions.get_cellmode(primhdr, cellhdr)[source]

Check if the specified cell, identified by OTA and CELL-ID, is either broken or marked as a guide/video cell.

podi_definitions.get_clean_cmdline()[source]

Return all values entered on the command line with all command-line flags removed.

Example

The user called a program ./podi_something param1 -flag1 -flag2 param2

This function would then return a list containing [‘./podi_something’, ‘param1’, ‘param2’]

podi_definitions.get_cmdline_arg(arg)[source]

Retreive the value of a command-line argument

podi_definitions.get_collected_image_dimensions(binning)[source]

Return the dimension of the monolithic OTA frame, accounting for binning

podi_definitions.get_filter_level(header)[source]

Return the level of the installed filter, based on the information in the FLTARM header keywords. If more than one filter is active, this function returns the level of the lowest populated filter arm.

podi_definitions.get_svn_version()[source]

Return current SVN version as given by the svnversion command.

podi_definitions.get_valid_filter_name(hdr)[source]

Convert the header FILTERID entry into a valid filtername. This is necessary as some of the filter names change over time, but the filter-id should remain unchanged.

podi_definitions.inherit_headers(header, primary_header)[source]

Copy all headers from the primary header into the current header

podi_definitions.insert_into_array(data, from_region, target, target_region)[source]

Copy data from one array into another array, with source and target coordinates specified in the IRAF-style format.

podi_definitions.is_image_extension(hdu)[source]

Check if a given HDU is a Image extension

podi_definitions.log_svn_version(hdr)[source]

Add SVN version number to FITS header.

podi_definitions.mask_broken_regions(datablock, regionfile, verbose=False)[source]

Mask out broken regions in a data array. Regions are defined via a ds9 region file to allow for ay creation by the user.

podi_definitions.match_catalog_areas(src, to_match, radius)[source]

Match the area coverage of two catalogs, allowing for some extra coverage around the edges.

podi_definitions.rebin_image(data, binfac, operation=<function mean at 0x2d6cb18>)[source]

Apply a binning factor to a data array.

Parameters :
  • data (ndarray) –

    Input data array. Only tested to work on two-dimensional data.

  • binfac (int) –

    binning factor, e.g. 2 for 2xw binning. Only identical binning in both dimensions is supported at the present.

  • operation (function (default: numpy.mean)) –

    What operation to use when combining the pixels. All functions operating on ndarrays are supported, but typical cases are likely one of the following:

    • numpy.mean
    • numpy.average
    • numpy.sum
    • numpy.median

    Or from the bottleneck package:

    • bottleneck.nanmean
    • bottleneck.nanmedian
podi_definitions.rotate_around_center(data, angle, mask_limit=0.1, verbose=True, safety=1, mask_nans=True, spline_order=3)[source]

Rotate a given data array. Rotation center is the center of the data frame.

podi_definitions.sexa2deg(sexa)[source]

Convert a sexa-decimal coordinate string (e.g. 12:30:00.0”) into a float (12.5 in the example).

podi_definitions.shmem_as_ndarray(raw_array)[source]

Helper function needed to allocate shared memory numpy-arrays.

podi_definitions.stdout_write(str)[source]

Write a given text to stdout and flush the terminal. Pretty much what print does, but flushing the output afterwards.

podi_definitions.three_sigma_clip(input, ranges=[-1000000000.0, 1000000000.0], nrep=3, return_mask=False)[source]

Perfom an iterative 3-sigma clipping on the passed data array.