asgardpy.io.io_dl4 module

Basic classes defining Input Config for DL4 files and some functions to retrieve information for the DL4 to DL5 processes.

pydantic model asgardpy.io.io_dl4.DL4BaseConfig[source]

Bases: BaseConfig

Config section for DL4 Dataset for a given instrument.

Fields:
field dl4_dataset: InputDL4Config = InputDL4Config(type='MapDataset', input_dir=PosixPath('.'), glob_pattern={}, dl4_format='gadf')
field spectral_energy_range: MapAxesConfig = MapAxesConfig(name='energy', axis=EnergyAxisConfig(min=<Quantity 1. GeV>, max=<Quantity 1. TeV>, nbins=5, per_decade=True), axis_custom=EnergyEdgesCustomConfig(edges=[], unit='TeV'))
class asgardpy.io.io_dl4.DL4Files(dl4_dataset_info, log=None)[source]

Bases: object

A general class to retrieve information from given DL4 files.

fetch_dl4_files_by_filenames(all_dl4_files, obs_ids)[source]

Assuming a simple nomenclature from gammapy on storing DL4 datasets names as pha_obs[OBS_ID].fits or obs_[OBS_ID].fits i.e. a single integer in the filename, being the OBS_ID or the DL4 dataset name.

get_dl4_dataset(observation_config=None)[source]

Read the corresponding DL4 dataset with the list of files provided, along with the dataset format and stack them in a Datasets object.

get_dl4_files(observation_config)[source]

Fetch the required DL4 files from the given directory path, file glob search and possible list of observation ids to select the dataset files from the full list in the directory.

If Model files are also given, fetch them as well

get_spectral_energies()[source]

Get the spectral energy information for each Instrument Dataset.

read_dl4_file(filename)[source]

Read a single file, which may be serialized in FITS or yaml format.

pydantic model asgardpy.io.io_dl4.InputDL4Config[source]

Bases: BaseConfig

Config section for main information on getting the relevant DL4 files.

Fields:
field dl4_format: DL4FormatEnum = DL4FormatEnum.gadf
field glob_pattern: dict = {}
field input_dir: Annotated[str | Path] = 'None'
Constraints:
  • func = <function <lambda> at 0x7f5167d96020>

  • json_schema_input_type = PydanticUndefined

  • return_type = <class ‘pathlib.Path’>

  • when_used = json-unless-none

field type: DatasetTypeEnum = DatasetTypeEnum.MapDataset
asgardpy.io.io_dl4.get_reco_energy_bins(dataset, en_bins)[source]

Calculate the total number of fit reco energy bins in the given dataset and add to the total value.