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

Bases: baseband.helpers.sequentialfile.FileNameSequencer

List-like generator of GUPPI 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 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 GUPPI header keys.


>>> from baseband import guppi
>>> gfs = guppi.GUPPIFileNameSequencer(
...     '{date}_{file_nr:03d}.raw', {'DATE': "2018-01-01"})
>>> gfs[10]
>>> from import SAMPLE_PUPPI
>>> with open(SAMPLE_PUPPI, 'rb') as fh:
...     header = guppi.GUPPIHeader.fromfile(fh)
>>> template = 'puppi_{stt_imjd}_{src_name}_{scannum}.{file_nr:04d}.raw'
>>> gfs = guppi.GUPPIFileNameSequencer(template, header)
>>> gfs[0]
>>> gfs[10]