class baseband.dada.base.DADAFileNameSequencer(template, header={})[source] [edit on github]

Bases: FileNameSequencer

List-like generator of DADA filenames using a template.

The template is formatted, filling in any items in curly brackets with values from the header, as well as possibly a file number equal to the indexing value, indicated with ‘{file_nr}’. The value ‘{obs_offset}’ is treated specially, in being calculated using header['OBS_OFFSET'] + file_nr * header['FILE_SIZE'], where header['FILE_SIZE'] is the file size in bytes.

The length of the instance will be the number of files that exist that match the template for increasing values of the file number (when writing, it is the number of files that have so far been generated).


Template to format to get specific filenames. Curly bracket item keywords are not case-sensitive.


Structure holding key’d values that are used to fill in the format. Keys must be in all caps (eg. DATE), as with DADA header keys.


>>> from baseband import dada
>>> dfs = dada.DADAFileNameSequencer(
...     '{date}_{file_nr:03d}.dada', {'DATE': "2018-01-01"})
>>> dfs[10]
>>> from import SAMPLE_DADA
>>> with open(SAMPLE_DADA, 'rb') as fh:
...     header = dada.DADAHeader.fromfile(fh)
>>> template = '{utc_start}.{obs_offset:016d}.000000.dada'
>>> dfs = dada.DADAFileNameSequencer(template, header)
>>> dfs[0]
>>> dfs[1]
>>> dfs[10]