entries_from_file#

sunpy.database.tables.entries_from_file(file, default_waveunit=None, time_string_parse_format='')[source]#

Use the headers of a FITS file to generate an iterator of sunpy.database.tables.DatabaseEntry instances. Gathered information will be saved in the attribute fits_header_entries. If the key INSTRUME, WAVELNTH or DATE-OBS / DATE_OBS is available, the attribute instrument, wavemin and wavemax or observation_time_start is set, respectively. If the wavelength unit can be read, the values of wavemin and wavemax are converted to nm (nanometres). The value of the file parameter is used to set the attribute path of each generated database entry.

Parameters:
  • file (str, file object) – Either a path pointing to a FITS file or a an opened file-like object. If an opened file object, its mode must be one of the following rb, rb+, or ab+.

  • default_waveunit (str, optional) – The wavelength unit that is used for a header if it cannot be found.

  • time_string_parse_format (str, optional) – Fallback timestamp format which will be passed to strptime if sunpy.time.parse_time is unable to automatically read the date-obs metadata.

Raises:

Examples

>>> from sunpy.database.tables import entries_from_file
>>> import sunpy.data.sample  
>>> entries = list(entries_from_file(sunpy.data.sample.SWAP_LEVEL1_IMAGE))  
>>> len(entries)  
1
>>> entry = entries.pop()  
>>> entry.instrument  
'SWAP'
>>> entry.observation_time_start, entry.observation_time_end  
(datetime.datetime(2011, 6, 7, 6, 33, 29, 759000), None)
>>> entry.wavemin, entry.wavemax  
(17.400000000000002, 17.400000000000002)
>>> len(entry.fits_header_entries)  
110