artof_utils#
The artof_utils module provide static utility functions to be used in the artof package.
- artof.artof_utils.edges_to_values(edges)#
Convert edges to values, by calculating the center of each edge bin.
- Parameters:
edges (ndarray) – A numpy array of edges.
- Returns:
A numpy array of values.
- Raises:
ValueError – If the edges are not increasing.
- Return type:
ndarray
- artof.artof_utils.format_value(value)#
Format value and return as string. Floats are formatted in engineering notation (SI prefixes).
- Parameters:
value (str | int | float) – Value to format.
- Returns:
Formatted value as string.
- Return type:
formatted_value
- artof.artof_utils.get_axes_permutations(axes)#
Get all permutations needed for transposing projected data.
- Parameters:
axes (list) – List of axes to project onto.
- Returns:
List of permutations for transposing the projected data.
- Return type:
permutations
- artof.artof_utils.get_datetime_string(time)#
Convert a datetime object to an ISO 8601 formatted string in the Europe/Berlin timezone.
- Parameters:
time (datetime) – A datetime object.
- Returns:
An ISO 8601 formatted string representing the datetime in the Europe/Berlin timezone.
- Return type:
str
- artof.artof_utils.get_incident_energy(metadata)#
Extract the incident energy from the metadata, if available. If not available, return -1.
- Parameters:
metadata (Metadata) – Metadata object containing experimental information.
- Returns:
The incident energy as a float.
- Return type:
float
- artof.artof_utils.get_incident_energy_for_binding(metadata, incident_energy)#
Get the incident energy for binding energy plotting/exporting. If the incident energy is not provided, use the value from the metadata.
- Parameters:
metadata (Metadata) – Metadata object containing experimental information.
incident_energy (float) – Incident energy value. If -1, the value from metadata will be used.
- Returns:
The incident energy as a float, or None if not available.
- Raises:
ValueError – If the incident energy is not provided and cannot be found in the metadata.
- Return type:
None
- artof.artof_utils.get_next_step(it, step, lens_steps)#
Get the next step of a run
- Parameters:
it (int) – Current iteration.
step (int) – Current step.
lens_steps (int) – Total number of steps per iteration.
- Returns:
Next iteration and step
- artof.artof_utils.get_previous_step(it, step, lens_steps)#
Get the previous step of a run
- Parameters:
it (int) – Current iteration.
step (int) – Current step.
lens_steps (int) – Total number of steps per iteration.
- Returns:
Previous iteration and step
- artof.artof_utils.is_last_step(it, step, stop_iter, lens_steps)#
Check if the current file is the last file of a run
- Parameters:
it (int) – Current iteration.
step (int) – Current step in iteration.
lens_steps (int) – Total number of steps.
stop_iter (int) – Maximum number of iterations.
- Returns:
Boolean value if the current file is the last file
- artof.artof_utils.load_data_from_csv(path)#
Load data from a CSV file.
- Parameters:
path (str) – Path to the CSV file.
- Returns:
Tuple containing a list of axes values and the data as a numpy array.
- Return type:
tuple[list[ndarray], ndarray]
- artof.artof_utils.next_file_exists(path, it, step, lens_steps)#
Check if the next file of a run exists
- Parameters:
path (str) – Path where data files are located.
it (int) – Current iteration.
step (int) – Current step.
lens_steps (int) – Total number of steps.
- Returns:
Boolean value if the next file exists
- artof.artof_utils.previous_file_exists(path, it, step, lens_steps)#
Check if the previous file of a run exists
- Parameters:
path (str) – Path where data files are located.
it (int) – Current iteration.
step (int) – Current step.
lens_steps (int) – Total number of steps.
- Returns:
Boolean value if the next file exists
- artof.artof_utils.print_progress(progress_info)#
Print the progress of the current run
- Parameters:
progress_info (dict) – Dictionary containing progress information.
- artof.artof_utils.values_to_edges(values)#
Convert values to edges. The first edge is extrapolated from the first two values, and the rest of the edges are calculated.
Warning: In case of variations in step size of the given values, the calculated edges are not guaranteed to be monotonically increasing and the physical relevance is not guranteed.
- Parameters:
values (ndarray) – A numpy array of values.
- Returns:
A numpy array of edges.
- Raises:
ValueError – If the values are not increasing.
- Return type:
ndarray