entries_from_dir(fitsdir, recursive=False, pattern='*', default_waveunit=None, time_string_parse_format=None)¶
Search the given directory for FITS files and use the corresponding FITS headers to generate instances of
DatabaseEntry. FITS files are detected by reading the content of each file, the
patternargument may be used to avoid reading entire directories if one knows that all FITS files have the same filename extension.
fitsdir (str) – The directory where to look for FITS files.
recursive (bool, optional) – If True, the given directory will be searched recursively. Otherwise, only the given directory and no subdirectories are searched. The default is
False, i.e. the given directory is not searched recursively.
pattern (string, optional) – The pattern can be used to filter the list of filenames before the files are attempted to be read. The default is to collect all files. This value is passed to the function
fnmatch.filter(), see its documentation for more information on the supported syntax.
default_waveunit (str, optional) – See
generator of (DatabaseEntry, str) pairs – A generator where each item is a tuple consisting of a
DatabaseEntryinstance and the absolute path to the filename which was used to make the database entry.
>>> import os >>> from sunpy.data.test import rootdir as fitsdir >>> from sunpy.database.tables import entries_from_dir
>>> eitdir = os.path.join(fitsdir, 'EIT') >>> entries = list(entries_from_dir(eitdir, default_waveunit='angstrom')) >>> len(entries) 13