MetadataView#

class lsst.images.MetadataView(native, external)#

Bases: MutableMapping[str, MetadataValue | ExternalMetadataValue]

Combined view of an image’s native and external metadata.

Parameters:
  • native (_NativeMetadata) – Metadata that is part of the image’s data model.

  • external (ExternalMetadata) – Read-only metadata carried in from an external source.

Notes

Lookups check native first, matching case exactly, and then external, ignoring case. Writes and deletes go to native only, and adding a new key that case-insensitively matches an external key raises KeyError. Iteration yields the exact-case union of the keys of both.

When a key is repeated in the external source, which of its values [] returns is unspecified; use get_all to obtain every value.

Attributes Summary

external

Read-only metadata carried in from an external source, such as the primary header of a FITS file (serialization.ExternalMetadata).

native

Metadata that is part of the image's data model and is saved with it (MutableMapping).

Methods Summary

clear()

copy()

Return a plain dict copy of the native metadata.

get(k[,d])

get_all(key)

Return every value for a key.

items()

keys()

pop(k[,d])

value.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does:

values()

Attributes Documentation

external#

Read-only metadata carried in from an external source, such as the primary header of a FITS file (serialization.ExternalMetadata).

native#

Metadata that is part of the image’s data model and is saved with it (MutableMapping).

Keys are case-sensitive. Adding a key that case-insensitively matches a key of external raises KeyError; a key that is already present may always be updated.

Methods Documentation

clear()#
Return type:

None

copy()#

Return a plain dict copy of the native metadata.

Returns:

metadata – A copy of the native metadata.

Return type:

dict

get(k[, d]) → D[k] if k in D, else d.  d defaults to None.#
get_all(key)#

Return every value for a key.

Parameters:

key (str) – Key to look up.

Returns:

values – A single-element tuple holding the native value if key is a native key, and otherwise every external value for key, in source order.

Return type:

tuple

Raises:

KeyError – Raised if key is not present.

items() → a set-like object providing a view on D's items#
keys() → a set-like object providing a view on D's keys#
pop(k[, d]) → v, remove specified key and return the corresponding#

value. If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()#

as a 2-tuple; but raise KeyError if D is empty.

Return type:

tuple[str, TypeAliasType]

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D#
update([E, ]**F) → None.  Update D from mapping/iterable E and F.#
If E present and has a .keys() method, does:

for k in E.keys(): D[k] = E[k]

If E present and lacks .keys() method, does:

for (k, v) in E: D[k] = v

In either case, this is followed by:

for k, v in F.items(): D[k] = v

values() → an object providing a view on D's values#

This page was last modified on .