look_up_cals

ndmapper.services.look_up_cals(filenames, dependencies, server, cache=None, obs_type='target')[source] [edit on github]

Look up specified filenames on a specified server and return a dictionary of best-matching calibration files and their calibrations in turn.

WARNING: According to the Python docs, the minidom library used in back-ends for this should not be used to parse input from untrusted URLs.

Parameters:

filenames : list of (convertible to str) or convertible to str

The filename(s) for which calibration files are to be looked up.

dependencies : dict of str

Dictionary defining which types of observations (potentially) require which other types as calibrations. Both the keys and list values are strings such as ‘bias’ or ‘flat’, as recognized by the calibration server. The first key has the special name ‘target’. This dictionary is normally imported with the name CAL_DEPS from the instrument mode sub-package used, eg. modes.gmos.spec.ifu.

server : str, function

Name of the service to be used for the look-up (which determines the back-end function selected from this library). The currently-available options are: ‘gemini’ (default). Alternatively, the user may supply a look-up function/object, which must accept a filename and calibration type name (such as ‘flat’) and return a list of (filename, checksum) tuples, where the checksum may be None.

cache : str, optional

Filename of a JSON cache file to load and save, if any. This is essentially an editable Python dictionary. Any existing entries in this file take precedence over new look-up results, ensuring reproducibility and allowing the user to override matches iteratively. If the file does not already exist, it will be created from a new look-up, while the default of None produces a new look-up every time.

obs_type : str

The type of observation, corresponding to filenames, for which calibrations are to be looked up (default ‘target’). This parameter exists to allow explicitly looking up a subset of calibrations for calibrations if needed, but normally it should be left at its default value and all those dependencies will be found recursively anyway, starting from the ‘target’.

Returns:

dict

A dictionary of calibration files & associations, in the format produced by calibrations.init_cal_dict().