cal_entries

ndmapper.calibrations.cal_entries(cal_dict, cal_type, reference=None)[source] [edit on github]

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).

This could also be done by the user in 1-2 lines of code, but involves some nested loops or (in)comprehensions that are less user-readable than a function call (to avoid duplication of type information in calibration dictionary, which would then have to be kept synchronized).

Parameters:

cal_dict : dict

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

cal_type : str

Type of calibration to be looked up (matching a type name in the ‘associations’ sub-dict).

reference : str or tuple of str, optional

One or more filenames with which matching calibrations must be associated, to limit the selection. By default, all available calibrations of type cal_type are selected.

Returns:

tuple of (str, list of str)

A tuple of (key, value) tuple pairs from the dictionary, where each first element is a calibration name label and each second element a list of constituent filenames. These are the items() of the input ‘calibrations’ sub-dict that match cal_type (and, if specified, reference). The result can be iterated over directly, for processing each entry in turn, or converted with dict() to reproduce the appropriate subset of cal_dict['calibrations'].