scopesim.effects.data_container.DataContainer#

class scopesim.effects.data_container.DataContainer(filename: Path | str | None = None, table: Table | None = None, array_dict: Mapping | None = None, cmds: UserCommands | None = None, **kwargs)#

Bases: object

A class to hold data (file(s)) needed by some Effects objects.

Parameters:
  • filename (str, optional) – Path to file containing data. Accepted formats: ASCII table, FITS table, FITS image

  • table (astropy.Table, optional) – An astropy Table containing data

  • array_dict (dict, optional) – A dictionary out of which an astropy.Table object can be constructed.

  • kwargs – addition meta data

Notes

If a table is to be generated from an array_dict parameter, column units can be passed as keyword arguments (kwargs) using the following format:

Datacontainer(... , <column name>_unit="<unit string>")

where unit string is a string recognised by astropy.units. Any additional table meta-data can also be passed using this format.

data#

A generic property method which returns the data from the file. Any function calling this should be prepared to handle both data formats

Type:

astropy.Table, fits.HDUList

meta#

Contains all meta data read in from the file’s header, and/or passed via kwargs.

Type:

dict

table#

If the file has a table format (ASCII of FITS) it is read in immediately and stored in .table

Type:

astropy.Table

_file#

If the file is a FITS image or cube, the data is only read in when needed in order to save on memory usage. ._file contains a pointer to the data open FITS file.

Type:

HDUList pointer

__init__(filename: Path | str | None = None, table: Table | None = None, array_dict: Mapping | None = None, cmds: UserCommands | None = None, **kwargs)#

Methods

__init__([filename, table, array_dict, cmds])

get_data([ext, layer])

Return either a table or a ImageHDU object.

validate(etype)

Attributes

get_data(ext: int = 0, layer: int | None = None)#

Return either a table or a ImageHDU object.

Note

Use this call for reading in individual FITS extensions.

The .data handle will read in all extensions and return an HDUList object

Parameters:
  • ext (int)

  • layer (int) – If the FITS extension is a data cube, layer corresponds to a slice from this cube of <ImageHDU>.data[layer, :, :]

Returns:

data

Return type:

astropy.Table, fits.ImageHDU