Simulation model repository#

The model repository API provides source-neutral, read-only access to simulation-model parameters, production tables, and referenced files.

reader#

Read simulation models through a source-neutral interface.

class model_repository.reader.SimulationModelReader(source)[source]#

Source-neutral read-only interface for simulation-model data.

export_model_file(parameter, site, array_element_name, model_version=None, parameter_version=None, export_file_as_table=False, dest=None)[source]#

Export one model file or return a file-backed value as a table.

export_model_files(parameters=None, file_names=None, dest=None)[source]#

Export model files through the selected source.

classmethod from_files(simulation_models_path)[source]#

Create a reader for a checked-out model repository.

classmethod from_git(repository_path, revision, object_store=None)[source]#

Create a reader for one immutable revision of a Git repository.

classmethod from_memory(files)[source]#

Create a reader from in-memory model files.

get_array_elements(model_version, collection='telescopes')[source]#

Return array elements in a model version.

get_array_elements_of_type(array_element_type, model_version, collection)[source]#

Return non-design elements of one type.

get_design_model(model_version, array_element_name, collection='telescopes')[source]#

Return the design model for an array element.

get_model_parameter(parameter, site, array_element_name, parameter_version=None, model_version=None)[source]#

Read one model parameter by parameter or model version.

get_model_parameters(site, array_element_name, collection, model_version, parameter_names=None, context=None)[source]#

Read resolved parameters for an array element and model version.

Parameters:
parameter_namesiterable of str, optional

If supplied, read only these parameters. This is useful for callers that need a small subset of a model, such as coordinate transforms.

get_model_parameters_for_all_model_versions(site, array_element_name, collection)[source]#

Read resolved parameters for an element across all model versions.

get_model_versions(collection_name='telescopes')[source]#

Return available model versions.

get_parameter_table(parameter_data)[source]#

Return the validated Astropy table referenced by a model parameter.

get_parameter_table_records(parameter_data)[source]#

Return cached scalar records for a validated model-parameter table.

get_production_descriptions()[source]#

Return model-version descriptions from the selected source.

get_simulation_configuration_parameters(simulation_software, site, array_element_name, model_version)[source]#

Read CORSIKA or sim_telarray configuration parameters.

is_configured()[source]#

Return whether the selected source is configured for reads.

read_production_table(collection_name, model_version)[source]#

Read a production table.

property source_config#

Return the serializable source selection for worker processes.

property source_name#

Return a user-facing description of the selected source.

storage#

Read-only storage implementations for simulation model files.

class model_repository.storage.DirectoryStorage(root)[source]#

Read model files from a directory tree.

exists(path)[source]#

Return whether a repository-relative file exists.

iter_files(prefix)[source]#

List repository-relative files below a directory prefix.

open(path)[source]#

Open a repository-relative file as a binary stream.

read_bytes(path)[source]#

Read a repository-relative file as bytes.

class model_repository.storage.GitStorage(repository, revision, object_store=None)[source]#

Read model files from a resolved commit in a local Git repository.

exists(path)[source]#

Return whether a repository-relative file exists (directories are not files).

iter_files(prefix)[source]#

List repository-relative files below a directory prefix.

open(path)[source]#

Open a repository-relative file as a binary stream.

read_bytes(path)[source]#

Read a repository-relative file as bytes.

class model_repository.storage.MemoryStorage(files)[source]#

Read model files from an in-memory mapping of paths to bytes.

exists(path)[source]#

Return whether a repository-relative file exists.

iter_files(prefix)[source]#

List repository-relative files below a directory prefix.

open(path)[source]#

Open a repository-relative file as a binary stream.

read_bytes(path)[source]#

Read a repository-relative file as bytes.

class model_repository.storage.ModelStorage(*args, **kwargs)[source]#

Common read-only interface for model repository storage.

exists(path)[source]#

Return whether a repository-relative file exists.

iter_files(prefix)[source]#

List repository-relative files below a directory prefix.

open(path)[source]#

Open a repository-relative file as a binary stream.

read_bytes(path)[source]#

Read a repository-relative file as bytes.

source#

Read simulation models through a storage-neutral source.

class model_repository.source.ModelSource(storage)[source]#

Read-only access to model data through a storage implementation.

export_model_files(parameters=None, file_names=None, dest=None)[source]#

Copy referenced model files to a destination directory.

get_model_versions(collection_name='telescopes')[source]#

Return semantically sorted production versions.

get_parameter_table(parameter_data)[source]#

Read and validate an ECSV table referenced by a parameter record.

get_production_descriptions()[source]#

Return model-version descriptions from production info files.

is_configured()[source]#

Return whether the source is ready for reads.

read_parameters(parameter_versions, collection_name, instrument=None, site=None)[source]#

Read and filter normalized parameter documents.

read_production_table(collection_name, model_version)[source]#

Return an aggregated production table for a collection and version.

static resolve_parameter_asset(parameter_data)[source]#

Resolve a file-valued parameter relative to its parameter directory.

property source_config#

Return the serializable storage configuration.

property source_name#

Return the storage’s user-facing identity.

files#

Read and combine production-table files from a model repository.

model_repository.files.collect_production_descriptions(info_files, read_info)[source]#

Collect sorted production descriptions using the supplied document reader.

model_repository.files.read_production_tables_from_documents(model_version, documents, collection_name=None)[source]#

Read and merge production tables from parsed repository documents.

documents contains (model_name, file_name, document) tuples. The representation is shared by filesystem and Git readers so that both sources apply patch history and production-table merging identically.

asset names#

Naming helpers for exported simulation-model assets.

model_repository.asset_names.get_export_file_name(parameter_data, fallback_instrument=None)[source]#

Return the deterministic exported name for a model asset.

ECSV assets are qualified with the instrument scope so that assets from different telescope designs can share one model directory safely. The original source value is kept separately when a parameter has already been qualified.

Parameters:
parameter_datadict

Model parameter metadata.

fallback_instrumentstr, optional

Instrument scope to use when the metadata does not contain one.

Returns:
str

Exported filename.

model_repository.asset_names.get_simtel_table_file_name(parameter_data)[source]#

Return the shared native sim_telarray filename for an ECSV parameter.

The model parameter identity is used instead of a telescope configuration filename. This allows identical tables used by several telescope models to share one generated native file.

Parameters:
parameter_datadict

Model parameter metadata.

Returns:
str or None

Shared native filename, or None when the parameter does not carry enough model identity metadata for safe sharing.

model_repository.asset_names.qualify_parameter_file_name(parameter_data, fallback_instrument=None)[source]#

Update ECSV parameter metadata with its deterministic exported name.

Git backend#

Small, replaceable Git object-store adapter for simulation models.

exception model_repository.git_backend.GitModelSourceDependencyError[source]#

Raised when the Git model source is selected without its runtime dependency.

class model_repository.git_backend.GitObjectStore[source]#

Library-neutral interface used by GitStorage.

abstractmethod iter_files(commit, prefix)[source]#

Return file paths below prefix for commit.

abstractmethod open_blob(commit, path)[source]#

Return a binary stream for one blob.

abstractmethod read_blob(commit, path)[source]#

Return one blob as bytes.

abstractmethod resolve_revision(revision)[source]#

Resolve a ref or commit to a full commit ID.

class model_repository.git_backend.Pygit2ObjectStore(repository_path)[source]#

Read objects from a local normal, bare, or mirror repository.

iter_files(commit, prefix)[source]#

Return sorted regular-file paths below a tree prefix.

open_blob(commit, path)[source]#

Open a blob as a binary stream without materializing it in memory.

read_blob(commit, path)[source]#

Read a blob into memory.

resolve_revision(revision)[source]#

Resolve a tag, ref, or SHA to a full commit SHA.

parsing#

Parsing helpers shared by simulation-model sources.

model_repository.parsing.normalize_model_parameter(data)[source]#

Normalize the value and unit fields of a model-parameter document.

application model-reader factory#

Construct the configured simulation-model reader.

application.model_reader.create_model_reader(simulation_models_path=None, simulation_models_git_path=None, simulation_models_git_revision=None)[source]#

Create a reader for a filesystem or Git model source.

Parameters:
simulation_models_pathstr or Path, optional

Root of a checked-out simulation-model repository. When supplied, this source is selected. If omitted, SIMTOOLS_SIMULATION_MODELS_PATH is used when set.

simulation_models_git_pathstr or Path, optional

Local normal, bare, or mirror Git repository.

simulation_models_git_revisionstr, optional

Git tag, ref, or commit. The model-repository catalog ref is used when the Git path is set and this value is omitted.

Returns:
SimulationModelReader

Reader backed by the selected source.

application.model_reader.create_model_reader_from_configuration(configuration)[source]#

Create a model reader from an application or test configuration.

Parameters:
configurationdict

Mapping that may contain filesystem or Git model-source options.

Returns:
SimulationModelReader

Reader selected by the supplied source options.

application.model_reader.create_model_reader_from_source_config(source_config)[source]#

Recreate a model reader from a worker-serializable source configuration.

Parameters:
source_configdict

Configuration returned by SimulationModelReader.source_config.

Returns:
SimulationModelReader

Reader backed by the configured source.

Raises:
ValueError

If the source configuration is missing or unsupported.

Compatibility#

Check model release versions against the simtools dependency catalog.

model_repository.compatibility.validate_release(path, catalog, revision=None, development=False)[source]#

Check an exact release tag without changing the selected model checkout.