DataFileList

class ndmapper.data.DataFileList(filenames=None, data=None, meta=None, mode=None, strip=False, prefix=None, suffix=None, dirname=None)[source] [edit on github]

Bases: list

A class that holds a list of DataFile objects, tracking filenames and/or NDData collections with ancillary information. This implementation is pretty much a normal Python list but provides a more convenient interface for instantiating multiple DataFile objects from a list of filenames or nddata instances/lists.

Parameters:

filenames : str or list of str, optional

The filename(s) on disk of the dataset(s) to be represented. There should either be as many filenames as data or None (but lists of NDData can be nested to associate subsets with fewer filenames).

data : DataFile or DataFileList or (nested list of) NDData, optional

NDData/DataFile instance(s) for the dataset(s) to be represented (or an existing DataFileList instance). Any member DataFile instances will become new copies if any of the filename-modifying parameters are set, otherwise the DataFileList will simply hold references to the original instances (allowing manipulation of existing DataFiles via new lists).

meta : dict-like or list of dict-like or None, optional

The header/meta-data associated with each file as a whole (eg. the primary FITS header) rather than with individual nddata instances. There should be one instance per file or None (which preserves any information from an existing file).

mode : str, optional

‘read’ (default), ‘new’, ‘update’ or ‘overwrite’ Specifies whether the file should exist on disk already and be used to initialize this DataFile (if a filename is provided) and whether it can later be written to disk (also see DataFile). With ‘read’ and ‘update’, the specified file must already exist, with ‘new’, it must not exist and with ‘overwrite’, any existing file is ignored and will be replaced when writing to disk. The ‘data’ and ‘filename’ parameters always override whatever would otherwise be read from disk. If mode is None, it will be taken from any DataFile instances given as data, as long as they are all the same (raising an exception if not), defaulting to ‘read’ if no DataFile instances are provided.

strip : bool

Remove any existing prefix and suffixes from the supplied filename (prior to adding any specified prefix & suffix)?

prefix : str, None

Prefix string to add before the base filename.

suffix : str, None

Suffix string to add after the base filename (including any initial separator).

dirname : str, None

Directory name to add to the filename (replacing any existing dir).

Methods Summary

append([data, meta, filename, strip, ...])
extend([data, meta, filenames, strip, ...])
reload() Reload each constituent DataFile (eg.
save() Save each constituent DataFile to its pre-defined filename.

Methods Documentation

append(data=None, meta=None, filename=None, strip=False, prefix=None, suffix=None, dirname=None)[source] [edit on github]
extend(data=None, meta=None, filenames=None, strip=False, prefix=None, suffix=None, dirname=None)[source] [edit on github]
reload()[source] [edit on github]

Reload each constituent DataFile (eg. after the file is modified by an IRAF task).

save()[source] [edit on github]

Save each constituent DataFile to its pre-defined filename.