simdb.imas.utils module

exception simdb.imas.utils.ImasError[source]

Bases: Exception

class simdb.imas.utils.SimDBUrl(url: str | Url | _BaseUrl)[source]

Bases: AnyUrl

classmethod build(*, scheme: str, host: str | None = None, port: int | None = None, path: str | None = None, query: str | None = None, fragment: str | None = None, **kwargs) SimDBUrl[source]

Build a new Url instance from its component parts.

Args:

scheme: The scheme part of the URL. username: The username part of the URL, or omit for no username. password: The password part of the URL, or omit for no password. host: The host part of the URL. port: The port part of the URL, or omit for no port. path: The path part of the URL, or omit for no path. query: The query part of the URL, or omit for no query. fragment: The fragment part of the URL, or omit for no fragment.

Returns:

An instance of URL

simdb.imas.utils.check_time(entry: DBEntry, ids: str, occurrence) None[source]

Check the validity of the ids_properties/homogeneous_time field of the given IDS.

@param entry: the open IMAS data entry @param ids: the @return:

simdb.imas.utils.convert_uri(uri: SimDBUrl, path: Path, config: Config) SimDBUrl[source]

Converts a local IMAS URI to a remote access IMAS URI based on the server.imas_remote_host configuration option.

Translate locale IMAS URI (imas:<backend>?path=<path>) to remote access URI (imas://<imas_remote_host>:<imas_remote_port>/uda?path=<path>&backend=<backend>)

@param uri: The URI to convert @param config: Config to read the server.imas_remote_host and

server.imas_remote_port options from

simdb.imas.utils.extract_ids_occurrence(ids: str) tuple[str, int][source]

Extract IDS name and occurrence number. Returns tuple of (ids_name, occurrence)

simdb.imas.utils.get_path_for_legacy_uri(uri: SimDBUrl) Path[source]
simdb.imas.utils.imas_files(uri: SimDBUrl) list[Path][source]

Return all the files associated with the given IMAS URI.

@param uri: a valid IMAS URI @return: a list of files which contains the IDS data for the backend specified in

the URI

simdb.imas.utils.imas_timestamp(uri: SimDBUrl) datetime[source]

Extract the timestamp from the IDS data for the given IMAS URI.

@param uri: the IMAS URI @return: the timestamp as a datetime object

simdb.imas.utils.is_legacy_imas_uri(uri: SimDBUrl) bool[source]
simdb.imas.utils.is_missing(value: Any)[source]

Returns whether the given value is one of IMASs ‘missing’ values.

@param value: the value to check @return: whether this value is ‘missing’

simdb.imas.utils.list_idss(entry: DBEntry) list[str][source]

List all the IDSs found to be populated for the given IMAS data entry.

Each IDS is defined as being non-empty if the ids_properties/homogeneous_time field has been populated.

@param entry: the IMAS data entry @return: the list of found IDSs

simdb.imas.utils.open_imas(uri: SimDBUrl) DBEntry[source]

Open an IMAS URI and return the IMAS entry object.

@param uri: the IMAS URI to open @return: the IMAS data entry object