idstools.utils.idshelper¶
This module
Module Contents¶
-
idstools.utils.idshelper.compare_ids(x, y, field=
None, ignore_version=True, verb=True, name_x='first', name_y='second', output={})[source]¶ The function compares two ids objects and returns whether they are identical or not, along with a dictionary of differences.
- Parameters:¶
- x¶
The first input ids object to compare.
- y¶
The second input ids object to compare.
- field=
None¶ The name of the field being compared in the IDSes.
- ignore_version=
True¶ A boolean parameter that determines whether to ignore the “version_put” attribute when comparing the two objects. If set to True, the function will ignore this attribute. Defaults to True
- verb=
True¶ a boolean indicating whether to print log messages during the comparison process. Defaults to True
- output=
{}¶ A dictionary that stores the output of the function, which includes information about any differences found between the two input objects.
- Returns:¶
tuple containing a boolean value indicating whether the two input objects are identical, and a dictionary containing information about any differences found during the comparison.
- idstools.utils.idshelper.get_all_ids_get_time(db_entry_object)[source]¶
The function get_all_ids_get_time calculates the total time for all IDS in a given db_entry_object.
- idstools.utils.idshelper.get_all_ids_size(db_entry_object)[source]¶
The function get_all_ids_size calculates the total size in bytes of all IDS in a given db_entry_object.
-
idstools.utils.idshelper.get_available_ids_and_occurrences(db_entry_object, time_mode=
None, get_comment=False, get_version=False)[source]¶ This function returns a list of pairs of available IDS types and their occurrences in a given DBEntry object.
- Parameters:¶
- db_entry_object¶
An object of the class DBEntry, which represents an open DBEntry in which available IDSs will be looked for.
- time_mode=
None¶ The time mode of interest for the IDSs in the given DBEntry.
- get_comment=
False¶ Output ids_properties.comment field for each found occurrence
- get_version=
False¶ Whether to return version information
- Returns:¶
str,occurrence:int) with data in the given DBEntry.
- Return type:¶
a list of pairs (idstype
- idstools.utils.idshelper.get_available_ids_and_times(db_entry_object) list[source]¶
The function get_available_ids_and_times retrieves available IDS names and corresponding time arrays from a given db_entry_object.
- idstools.utils.idshelper.get_ids_attributes(idsobj: object) list[source]¶
This function returns a list of attribute names for a given IDS object.
-
idstools.utils.idshelper.get_ids_size(db_entry_object, ids_names=
None, dd_update=False, ignore_empty=False) dict[source]¶ The function get_ids_size retrieves the size of IDS objects from a database entry and returns a dictionary containing the size in bytes and the time taken to read each object.
- idstools.utils.idshelper.get_ids_types()[source]¶
This function returns list of strings corresponding to all ids types for each IDSName object in the imas module.
- Returns:¶
The function get_ids_types() is returning a list of values of all the value attributes of the IDSName objects in the imas module.
-
idstools.utils.idshelper.get_ids_values(uri: str, idspaths: str | list, dd_update=
False, verbose=False)[source]¶
-
idstools.utils.idshelper.get_quantities_from_pulses(idspath: list, pulses: tuple, list_count: int =
0, verbose: bool =False, query=None, dd_update: bool =False) pandas.DataFrame[source]¶ The get_quantities_from_pulses function retrieves values from specified IDS paths for a given set of pulses and returns a DataFrame containing the pulse, run, and corresponding values.
- Parameters:¶
- idspath: list¶
The idspath parameter is either a single string or a list of strings that represent the paths to the IDS nodes from which the quantities will be extracted.
- pulses: tuple¶
The pulses parameter is a tuple containing information about each pulse. Each element in the tuple is itself a tuple with the following elements: pulse, run, backend, database, user, version, and file path.
- list_count: int =
0¶ The list_count parameter is an optional parameter that specifies the number of pulses to retrieve values for. If list_count is set to 0 (default), values will be retrieved for all pulses in the pulses tuple. If list_count is set to a positive integer, values will be retrieved for first listCount pulses in the pulses tuple. Defaults to 0
- verbose: bool =
False¶ print debug information
- query=
None¶ Query string to filter results. Defaults to None.
- dd_update: bool =
False¶ Flag to indicate whether to update data dictionary. Defaults to False.
- Returns:¶
The function returns a pandas DataFrame containing the columns “URI”, “FILEPATH”, “FILETIME” and one column for each IDS path specified.
-
idstools.utils.idshelper.idsdiff(struct1: imaspy.ids_structure.IDSStructure, struct2: imaspy.ids_structure.IDSStructure, name1=
'', name2='', print_result=False, verbose=True, ignore_version=False)[source]¶
-
idstools.utils.idshelper.idsdiff_full(struct1: imaspy.ids_structure.IDSStructure, struct2: imaspy.ids_structure.IDSStructure, name1=
'', name2='', print_result=False, ignore_version=False)[source]¶
- idstools.utils.idshelper.is_ids_field(idstype: type) bool[source]¶
This function checks if a given type is a possible field of an IDS.
-
idstools.utils.idshelper.resample_indices(dbin: str, dbout: str, idsname: str, occurrence=
0, start: int =0, stop: int =None, step: int =1, interpolation_method=imas.ids_defs.PREVIOUS_INTERP)[source]¶ The function resample_indices takes in a database input, database output, and an idsname, and resamples the data based on the specified start, stop, and step values.
- Parameters:¶
- dbin: str¶
The parameter “dbin” is a string that represents the input database name. It is the database from which the data will be read.
- dbout: str¶
The parameter dbout is a string that represents the name of the output database. It is the database where the resampled data will be stored.
- idsname: str¶
The parameter “idsname” is a string that represents the ids that you want to resample.
- start: int =
0¶ The start parameter is the index of the first time value to be resampled.
- stop: int =
None¶ The stop parameter is used to specify the index at which the resampling should stop. If stop is not provided, the resampling will continue until the end of the times array.
- step: int =
1¶ The step parameter determines the interval between the indices that are selected from the times array. For example, if step is set to 2, every second index will be selected. If step is set to 3, every third index will be selected, and so. Defaults to 1
-
idstools.utils.idshelper.resample_times(dbin: object, dbout: object, idsname: str, occurrence=
0, start: float =None, stop: float =None, step: float =None, interpolation_method=imas.ids_defs.PREVIOUS_INTERP)[source]¶ Resamples time-dependent data from an input database and stores it in an output database.
- Parameters:¶
- dbin: object¶
The input database object from which data is retrieved.
- dbout: object¶
The output database object where resampled data is stored.
- idsname: str¶
The name of the IDS (Integrated Data Structure) to be resampled.
- occurrence=
0¶ The occurrence index of the IDS. Defaults to 0.
- start: float =
None¶ The start time for resampling. Defaults to None.
- stop: float =
None¶ The stop time for resampling. Defaults to None.
- step: float =
None¶ The time step for resampling. Defaults to None.
- interpolation_method=
imas.ids_defs.PREVIOUS_INTERP¶ The interpolation method to use for resampling. Defaults to imas.ids_defs.PREVIOUS_INTERP.
- Returns:¶
The function does not return a value. The resampled data is stored in the output database.
- Return type:¶
None
- Raises:¶
Exception – If an error occurs during data retrieval from the input database, it is caught and ignored.
-
idstools.utils.idshelper.ARRAY_EQUAL_KWARGS =
"'equal_nan=True'"¶
- idstools.utils.idshelper.logger¶