Database (sunpy.database)#

sunpy.database can be used to provide a local cache of the files and records retrieved from various remote services.

Warning

sunpy.database module is no longer actively maintained and has a number of outstanding issues. It is deprecated and will be removed in sunpy 6.0.

sunpy.database Package#

Functions#

disable_undo(database)

A context manager to disable saving the used commands in the undo history.

split_database(source_database, ...)

Queries the source database with the query string, and moves the matched entries to the destination database.

Classes#

Database(url[, CacheClass[, cache_size[, ...)

Parameters:
  • url (str) -- A URL describing the database. This value is simply passed to

EntryAlreadyAddedError(database_entry)

This exception is raised if a database entry is attempted to be added to the database although it was already saved in it.

NoSuchEntryError(database_entry)

This exception is raised if it is attempted to remove an entry even though it does not exist in the database.

NoSuchTagError(tag_name)

This exception is raised if a tag cannot be found in a database by its name.

NonRemovableTagError(database_entry, tag)

This exception is raised if it is attempted to remove a tag from a database entry even though it is not saved in this entry.

EntryAlreadyStarredError(database_entry)

This exception is raised if a database entry is marked as starred using Database.star() although it was already starred before this operation.

EntryAlreadyUnstarredError(database_entry)

This exception is raised if the star mark from a database entry is attempted to be removed although the entry is not starred.

EntryNotFoundError(entry_id)

This exception is raised if a database entry cannot be found by its unique ID.

TagAlreadyAssignedError(database_entry, tag_name)

This exception is raised if it is attempted to assign a tag to a database entry but the database entry already has this tag assigned.

PartialFetchError(paths, n_expected)

This exception is raised if the number of files returned by the downloader does not match the number expected.

Submodules#

sunpy.database.tables Module#

Functions#

entries_from_query_result(qr[, default_waveunit])

Use a query response returned from sunpy.net.vso.VSOClient.search() to generate instances of DatabaseEntry.

entries_from_file(file[, default_waveunit, ...])

Use the headers of a FITS file to generate an iterator of sunpy.database.tables.DatabaseEntry instances.

entries_from_dir(fitsdir[, recursive, ...])

Search the given directory for FITS files and use the corresponding FITS headers to generate instances of DatabaseEntry.

display_entries(database_entries[, columns, ...])

Print a table to display the database entries.

Classes#

WaveunitNotFoundError(obj)

This exception is raised if a wavelength unit cannot be found in a FITS header or in a VSO query result block.

WaveunitNotConvertibleError(waveunit)

This exception is raised if a wavelength cannot be converted to an astropy.units.Unit instance.

JSONDump(dump)

FitsHeaderEntry(key, value)

FitsKeyComment(key, value)

Tag(name)

DatabaseEntry(**kwargs)

This represents the main table of the database and each instance represents one record that can be saved in the database.

sunpy.database.caching Module#

Classes#

BaseCache([maxsize])

BaseCache is a class that saves and operates on an OrderedDict.

LRUCache([maxsize])

LFUCache([maxsize])

sunpy.database.commands Module#

Classes#

EmptyCommandStackError

This exception is raised if it is attempted to pop from a command stack even though it is empty.

NoSuchEntryError(database_entry)

This exception is raised if it is attempted to remove an entry even though it does not exist in the database.

NonRemovableTagError(database_entry, tag)

This exception is raised if it is attempted to remove a tag from a database entry even though it is not saved in this entry.

DatabaseOperation()

This is the abstract main class for all database operations.

AddEntry(session, database_entry)

Add a new database entry to this session.

RemoveEntry(session, entry)

Remove the given database entry from the session.

EditEntry(database_entry, **kwargs)

Change the properties of the database entry.

CommandManager()

The CommandManager saves all executed and reverted commands to act as an undo-redo-manager.

sunpy.database.attrs Module#

Classes#

Starred()

Tag(tagname)

Path(value[, inverted])

DownloadTime(start, end)

FitsHeaderEntry(key, value[, inverted])