idstools.database¶
Module Contents¶
- class idstools.database.DBMaster[source]¶
-
ALL_BACKENDS =
"('mdsplus', 'hdf5')"¶
-
static get_database_dir(database: str, user: str =
None)[source]¶ The function get_database_dir returns the directory path for a given database, and raises an error if the path does not exist.
-
static get_database_files(user=
None, database=None, version=None, backends=None)[source]¶ The function get_database_files retrieves a list of database files based on the specified user, database, version, and backends.
- Parameters:¶
- user=
None¶ The
userparameter is used to specify the user for whom the database files are being retrieved. If no user is specified, it defaults toNone.- database=
None¶ The
databaseparameter is used to specify the name of the database.- version=
None¶ The
versionparameter is used to specify a specific version of the database.- backends=
None¶ The
backendsparameter is a list of strings that specifies the database backends to retrieve files from. The possible values forbackendsarehdf5andmdsplus. Ifbackendsis not provided, it defaults toDBMaster.ALL_BACKENDS
- user=
- Returns:¶
The function
get_database_filesreturns a list of tuples. Each tuple contains the name of a database, followed by a list of tuples. Each inner tuple contains a version number, followed by a list of tuples. Each innermost tuple contains the name of a backend (eitherhdf5ormdsplus), followed by a dictionary of database files.
-
static get_database_files_from_folder(folder=
None, backends=None)[source]¶ Retrieve database files from a folder based on specified backends.
-
static get_databases(user: str =
None) list[source]¶ The function get_databases returns a sorted list of databases in a user’s directory.
-
static get_databases_with_versions(user: str =
None) list[source]¶ The function get_databases_with_versions returns a list of tuples, where each tuple contains the name of a database and a list of its versions, for a given user.
- static get_db_Path(user, database, version)[source]¶
Function that returns a pathlib Path to desired database, depending on the user, database and version names.
- static get_hdf5_physical_file(user, database, version, pulse, run)[source]¶
The function get_hdf5_physical_file returns the path to an HDF5 file based on the user, database, version, pulse, and run.
- Parameters:¶
- user¶
The “user” parameter represents the name of the user who is accessing the HDF5 physical file.
- database¶
The “database” parameter refers to the name of the database where the HDF5 files are stored.
- version¶
The “version” parameter represents the version of the database.
- pulse¶
The “pulse” parameter represents the pulse number. It is a numerical value that identifies a specific pulse in a dataset.
- run¶
The “run” parameter represents the run number.
- Returns:¶
the path to an HDF5 physical file.
-
static get_hdf5_pulses(user: str =
None, database: str =None, version: str =None, status=None, as_dictionary=False) list[source]¶ The function get_hdf5_pulses retrieves a list of pulses from HDF5 master files. It needs to specify full path till version.
- Parameters:¶
- user: str =
None¶ The user parameter is a string that represents the user for whom the MDSPlus pulses are being retrieved.
- database: str =
None¶ The database parameter is a string that represents the name of the database. It is used to specify the directory where the MDSplus pulses are stored.
- version: str =
None¶ The version parameter is used to specify the version of the MDSplus database. It is a string that represents the version number.
- as_dictionary=
False¶ The as_dictionary parameter is a boolean flag that determines the format of the returned pulses. If as_dictionary is set to True, the pulses will be returned as a dictionary where the keys are the pulse numbers and the values are lists of runs associated with each pulse.Defaults to False
- user: str =
- Returns:¶
a list of tuples. Each tuple contains the following elements, The tuple includes the pulse number, run number, HDF5_BACKEND backend, database, user, version, and data file path.
-
static get_mds_plus_pulses(user: str =
None, database: str =None, version: str =None, status: str =None, as_dictionary=False) list[source]¶ The function get_mds_plus_pulses retrieves a list of MDSPlus pulses based on the provided user, database, version, and status parameters.
- Parameters:¶
- user: str =
None¶ The user parameter is a string that represents the user for whom the MDSPlus pulses are being retrieved.
- database: str =
None¶ The database parameter is a string that represents the name of the database. It is used to specify the directory where the MDSplus pulses are stored.
- version: str =
None¶ The version parameter is used to specify the version of the MDSplus database. It is a string that represents the version number.
- status: str =
None¶ The “status” parameter is used to filter the pulses based on their status. If a status is provided, only pulses with that status will be included in the result. If no status is provided, all pulses will be included.
- as_dictionary=
False¶ The as_dictionary parameter is a boolean flag that determines the format of the returned pulses. If as_dictionary is set to True, the pulses will be returned as a dictionary where the keys are the pulse numbers and the values are lists of runs associated with each pulse.Defaults to False
- user: str =
- Returns:¶
a list of pulses.
- static get_mdsplus_physical_files(user, database, version, pulse, run)[source]¶
The function get_mdsplus_physical_files returns the MDS+ database filenames for a given IMAS database.
- Parameters:¶
- user¶
The “user” parameter is the username of the user accessing the IMAS database.
- database¶
The database parameter refers to the name of the IMAS database.
- version¶
The “version” parameter represents the version of the IMAS database.
- pulse¶
The parameter “pulse” represents the pulse number in the IMAS database.
- run¶
The “run” parameter is the run number.
- Returns:¶
The function get_mdsplus_physical_files returns a tuple of three strings. The first string is the filename with the extension “.characteristics”, the second string is the filename with the extension “.datafile”, and the third string is the filename with the extension “.tree”.
- static get_physical_files(user, database, version, pulse, run, backend)[source]¶
The function get_physical_files returns the physical files storing a database based on the specified backend.
- Parameters:¶
- user¶
The user parameter represents the user who is requesting the physical files.
- database¶
The “database” parameter refers to the name or identifier of the database for which you want to retrieve the physical files.
- version¶
The version parameter represents the version of the database. It is used to retrieve the physical files associated with a specific version of the database.
- pulse¶
The “pulse” parameter refers to a specific pulse or shot number in a database. It is used to identify a particular data acquisition event or experiment.
- run¶
The “run” parameter is used to specify the run number or identifier for the database. It is likely used to retrieve the physical files associated with a specific run of the database.
- backend¶
The “backend” parameter refers to the type of database backend being used. It can have two possible values: “mdsplus” or “hdf5”.
- Returns:¶
The function get_physical_files returns the physical file path storing the specified database.
- static get_pulse_status(yaml_file_path) str[source]¶
The function get_pulse_status reads a YAML file from a given path and returns the value of the “status” key in the file’s metadata.
-
static get_user_dir(user: str =
None)[source]¶ The function get_user_dir returns the database directory path for a given user or the current user’s directory path if no user is specified.
-
static get_version_dir(version: str, database: str, user: str =
None)[source]¶ The function get_version_dir returns the directory path for a specific version of a database, given the version, database name, and optional user.
-
static get_versions(database: str, user: str =
None) list[source]¶ The function get_versions returns a sorted list of versions in a given database directory.
-
static get_versions_with_databases(user: str =
None) list[source]¶ The function get_versions_with_databases returns a list of tuples, where each tuple contains a version number and a list of databases associated with that version.
- Parameters:¶
- Returns:¶
a list of tuples. Each tuple contains a version number and a list of databases that have that version.
The list is sorted in ascending order based on the version numbers.
- static hdf5_list_pulse_run(locpath)[source]¶
Function that lists Pulse and Run numbers from a given database, in HDF5
Parameter¶
- locpath: str or Path
Path in which the database files are stored
- rtype:
listoftuple (pulse,run)
-
static mds_list_pulse_run(locpath, with_status=
None, as_dict=False)[source]¶ Function that lists Pulse and Run numbers from a given database, in MDSPLUS
-
ALL_BACKENDS =
-
idstools.database.read_scenario(scenario_file_path: str, in_ids_list: list =
None, out_ids_list: list =None, test_mode: bool =False, **test_args)[source]¶ This function reads a scenario file and takes in optional input and output IDs lists, as well as a test mode flag and additional test arguments.
- Parameters:¶
- scenario_file_path: str¶
The file path of the scenario file that contains the test cases.
- in_ids_list: list =
None¶ A list of input IDS names that should be read from the scenario file.
- out_ids_list: list =
None¶ A list of output IDS names It is used to specify the list of output IDs that the function should read from the scenario file. If this parameter is not provided, the function will read all output IDs from the scenario file.
- test_mode: bool =
False¶ A boolean flag indicating whether the function is being called in test mode or not. If test_mode is True, the function will execute in a way that is suitable for testing purposes. Defaults to False
-
idstools.database.read_scenario_with_args(imasargs, in_ids_list: list =
None, out_ids_list: list =None, test_mode: bool =False, **test_args)[source]¶ This function reads a scenario file and takes in optional input and output IDs lists, as well as a test mode flag and additional test arguments.
- Parameters:¶
- imasargs¶
The file path of the scenario file that contains the test cases.
- in_ids_list: list =
None¶ A list of input IDS names that should be read from the scenario file.
- out_ids_list: list =
None¶ A list of output IDS names It is used to specify the list of output IDs that the function should read from the scenario file. If this parameter is not provided, the function will read all output IDs from the scenario file.
- test_mode: bool =
False¶ A boolean flag indicating whether the function is being called in test mode or not. If test_mode is True, the function will execute in a way that is suitable for testing purposes. Defaults to False
- idstools.database.logger¶