hispecdrp.datamodels.meta_data
Functions
|
|
|
Get the metadata schema for a given instrument. |
|
Merge the meta information from multiple DataModel instances. |
|
Classes
|
Small helper class for handling metadata based on JSON schema. |
- class MetaModel(schema, meta=None, validate=True)[source]
Bases:
MutableMappingSmall helper class for handling metadata based on JSON schema.
- Parameters:
- boolean_columns()[source]
Return a set of columns that are logically booleans (for PostgreSQL)
- group_meta_by_section(flat=False)[source]
Group metadata properties by their FITS section.
- Parameters:
flat (bool, optional) – Whether to return a flat dictionary instead of grouped by section. Defaults to False.
- Returns:
dict – Dictionary of metadata grouped by FITS section. Keys are section names and values are dictionaries of metadata properties. Sections are ordered as they first appear in the metadata schema YAML file (
self._schema['properties']preserves that order).
- pprint(show_none=False, header_style=True)[source]
Pretty-print the metadata, grouped by FITS section.
- Parameters:
show_none (bool, optional) – Whether to show metadata fields with None values. Defaults to False.
- set_default(prop_name, value)[source]
Set a default value for a specific metadata field.
- Parameters:
prop_name (str) – The property name for which to set the default value.
value (Any) – The default value to set if the property is not already set.
- set_default_values()[source]
Set default values for metadata fields based on the schema.
- to_fits_header(extname='PRIMARY', include_missing_metadata=False)[source]
Convert the metadata to a FITS header.
- Parameters:
- Returns:
header (fits.Header) – The FITS header containing the metadata.
- to_record()[source]
Convert the metadata to a dictionary record.
- Returns:
record (dict) – The metadata as a dictionary.
- validate(prop_name, value)[source]
Validate a metadata field against the schema.
- Parameters:
prop_name (str) – The property name to validate.
value (Any) – The value to validate.
- Raises:
ValueError – If the value does not conform to the schema.
- _merge_fiber_state(values)[source]
- get_instrument_config(input=None, instrument_name=None)[source]
Get the instrument configuration class from either a FITS filename or an HDUList.
- Parameters:
input (str or fits.HDUList, optional) – Either a FITS filename path or an already-opened HDUList object. The INSTRUME keyword will be read from the primary header.
instrument_name (str, optional) – The instrument name. If provided, this will be used instead of reading the instrument name from the FITS header.
- Returns:
config_class (type) – The instrument config class if found.
- Raises:
TypeError – If input is neither a string nor an HDUList.
ValueError – If no INSTRUME keyword is found in the header, or if the instrument config is not found in INSTRUMENT_CONFIGS.
- get_meta_schema(instrument_name=None, config=None)[source]
Get the metadata schema for a given instrument.
- merge_meta(models)[source]
Merge the meta information from multiple DataModel instances.
- read_meta_schema(filepath)[source]