Tools for use in data processing steps & user scripts

Reference/API for direct use in processing steps

ndmapper.iraf_task Module

A module to help execute IRAF tasks conveniently as part of an NDMapper data reduction sequence, with DataFileList objects as inputs and outputs.

Functions

run_task(taskname, inputs[, outputs, ...]) Wrapper to run an IRAF task on one or more DataFile objects and collect the results.
get_extname_labels(datafiles) Ensure that all DataFile instances in datafiles use the same convention for labelling NDData component arrays (eg.

ndmapper.calibrations Module

A module for management of calibration exposure dependencies & associations via a Python dictionary (in conjuction with the “services” module).

Functions

init_cal_dict([filename]) Load a calibration dictionary from a JSON file if one is specified, otherwise initialize a new dictionary in the same format.
save_cal_dict(cal_dict, filename) Save the provided calibration dictionary as a user-editable JSON file.
add_cal_entry(filename, cal_type, matches, ...) Populate each component of the calibration dictionary with the specified list of calibration files matching a given filename.
cal_entries(cal_dict, cal_type[, reference]) Extract entries of a specified type from the ‘calibrations’ section of a calibration dictionary (typically for iterating over and processing calibrations of a given type).
associate_cals(cals, inputs, cal_type[, ...]) Associate a given type of processed calibrations with the data they will subsequently be used to calibrate (both as DataFile instances).

ndmapper.services Module

A module for executing Web queries on specific data archive services, for file downloads, calibration file matching etc.

Functions

look_up_cals(filenames, dependencies, server) Look up specified filenames on a specified server and return a dictionary of best-matching calibration files and their calibrations in turn.
look_up_single_cal_gemini(filename, cal_type) Query the Gemini science archive for the named input file and return a list of (filename, checksum) tuples corresponding to the requested type of calibration files.
download_files(filenames, server[, dirname]) Download a list of files from the specified server, skipping any that already exist in the target directory.
download_files_gemini(filenames[, dirname]) Query the Gemini science archive for the named input files and download them to the specified directory, skipping any that already exist there.
download_query_gemini(query[, dirname]) Perform a user-specified Gemini science archive query and save the files returned to a specified directory.

ndmapper.utils Module

Some high-level utilities for direct use in scripts & processing functions (or which depend on the high-level data representations used in NDMapper).

Functions

convert_region(region, convention) Convert a NumPy- or FITS-style region string into a tuple of integers and Python slice objects that is suitable for subscripting arrays.
to_datafilelist(arg[, mode]) Derive a DataFileList object from one or a sequence of objects than can be converted to filename strings (eg.
to_filename_strings(objects[, strip_names, ...]) Extract a list of filename strings from one or more str, FileName or DataFile objects (or a DataFileList), by default removing any path and processing suffix/prefixes.

Lower-level reference/API

ndmapper.io Package

I/O routines used internally by NDMapper. These have a public API for the convenience of anyone who wants to use their file format abstraction directly but users should nearly always work with the higher-level DataFile interface instead (which is also a bit less liable to change).

Functions

get_backend_fn(funcname, filename) Given a filename string and the name of a loader function defined in ndmapper.io, return the implementation of the latter function from the sub-module appropriate for the file format.
load_array(*args, **kwargs) Load a data array from the specified index within a file.
load_array_meta(*args, **kwargs) Load the meta-data data associated with an array from the specified index within a file.
load_common_meta(*args, **kwargs) Open an existing file and return any meta-data common to all data groups (eg.
load_table(*args, **kwargs) Load a table from the specified index within a file as an array-like object.
load_table_meta(*args, **kwargs) Load the meta-data data associated with a table from the specified index within a file.
map_file(*args, **kwargs) Open an existing file and return a list of NDMapIO instances corresponding to data/uncertainty/flags image array groups and a second list of TabMapIO instances corresponding to any additional data tables.
save_array(*args, **kwargs) Save a data array to the specified index (array number) within an existing file.
save_list(*args, **kwargs) Save a list of data arrays and associated meta-data to a file (overwriting any existing data).

Classes

NDMapIO(filename[, ident, data_idx, ...]) Propagate additional information needed for NDLater instances to support lazy loading, allow saving only arrays/header attributes that have changed & report which FITS extensions they came from for IRAF etc.
TabMapIO(filename, idx[, label, ident]) A proxy object for lazily loading/saving AstroPy Table instances.

ndmapper.libutils Module

Some lower-level utility functions (with minimal dependencies) that are used internally and are also made available as part of the public API.

Functions

addext(path, ext) Reconstruct a filename from a (root, extension) tuple of the type produced by splitext().
map_API_enum(name, value, map_dict) Convert an enumerable parameter value from the Python API to its equivalent IRAF value in the supplied dictionary (where such a mapping exists), raising an appropriate exception if it’s not recognized.
new_filename([purpose, base, ext, full_path]) Generate a new filename string that is not already used in the current directory (beginning with ‘tmp’ by default, for use as a temporary file).
splitext(path) A version of splitext that splits at the first separator rather than the last one (so ‘file.fits.gz’ gives ‘file’ & ‘fits.gz’).