6. Miscellaneous (processor.utilities.misc)

processor.utilities.misc.EnergyDensity400(Diode, Diameter=600)[source]

Calculate the pulse energy density of 400nm laser in uJ/cm^2. The units are um for beam diameter, uJ/cm^2 for energy density.

Parameters:
Diode: numeric

Measured value from photodiode (arb. units)

Diameter: numeric | 600

Beam diameter.

processor.utilities.misc.EnergyDensity800(Diode, Diameter=600)[source]

Calculate the pulse energy density of 800nm laser in uJ/cm^2. The units are um for beam diameter, uJ/cm^2 for energy density.

Parameters:
Diode: numeric

Measured value from photodiode (arb. units)

Diameter: numeric | 600

Beam diameter.

processor.utilities.misc.PulseEnergy400(Diode)[source]

Calculate the pulse energy of 400nm laser in uJ. The unit is um for beam diameter.

Parameter:
Diode: numeric

Measured value from photodiode (arb. units)

processor.utilities.misc.PulseEnergy800(Diode)[source]

Calculate the pulse energy of 800nm laser in uJ. The unit is um for beam diameter.

Parameter:
Diode: numeric

Meausred value from photodiode (arb. units)

processor.utilities.misc.argnearest(array, val, rettype='vectorized')[source]

Find the coordinates of the nD array element nearest to a specified value.

Args:

array (np.array): Numeric data array val (int or float) : Look-up value rettype (str,optional): return type specification

‘vectorized’ (default) denotes vectorized coordinates (integer) ‘coordinates’ denotes multidimensional coordinates (tuple)

Returns:

argval (int): coordinate position

processor.utilities.misc.camelCaseIt(snake_case_string)[source]

Format a string in camel case

processor.utilities.misc.create_dataframes(runNumbers, *args)[source]

Creates a parquet dataframe for each run passed. Returns:

fails: dictionary of runs and error which broke the dataframe generation

processor.utilities.misc.get_available_runs(rootpath)[source]

Collects the filepaths to the available experimental run data.

Parameters:
rootpath: str

path where to look for data (recursive in subdirectories)

Return:
available_runs: dict

dict with run numbers as keys (e.g. ‘run12345’) and path where to load data from as str.

processor.utilities.misc.get_path_to_run(runNumber, rootpath)[source]

Returns the path to the data of a given run number

Parameters:
runNumber: str or int

run number as integer or string.

rootpath: str

path where to look for data (recursive in subdirectories)

Return:
path: str

path to where the raw data of the given run number is stored.

processor.utilities.misc.load_binned_h5(file_name, mode='r', ret_type='list')[source]

Load an HDF5 file saved with save_binned() method.

Args:

file_name (str): name of the file to load, including full path mode (str, optional): Read mode of h5 file (‘r’ = read). ret_type (str, optional): output format for axes and histograms:

‘list’ generates a list of arrays, ordered as the corresponding dimensions in data. ‘dict’ generates a dictionary with the names of each axis.

Returns:

data np.array: Multidimensional data read from h5 file. axes np.array: The axes values associated with the read data. hist np.array: Histogram values associated with the read data.

processor.utilities.misc.parse_category(category, settings_file='default')[source]

parse setting file and return desired value

Args:

category (str): title of the category setting_file (str): path to setting file. If set to ‘default’ it takes

a file called SETTINGS.ini in the main folder of the repo.

Returns:

dictionary containing name and value of all entries present in this category.

Notes:

Author: Steinn Ymir Agustsson <sagustss@uni-mainz.de>

processor.utilities.misc.parse_logbook(log_text)[source]

Parse a log book entry to read out metadata.

Args:

log_text (str or file): file or plain text of the log book, in the “correct” format TODO: add example of log entry

Returns:

logDict (dict): Dictionary with the relevant metadata

Notes:

Author: Steinn Ymir Agustsson <sagustss@uni-mainz.de>

processor.utilities.misc.parse_setting(category, name, settings_file='default')[source]

parse setting file and return desired value

Args:
category: str

title of the category

name: str

name of the parameter

setting_file: str | ‘default’

path to setting file. If set to ‘default’ it takes a file called SETTINGS.ini in the main folder of the repo.

Returns:

value of the parameter, None if parameter cannot be found.

Notes:

Author: Steinn Ymir Agustsson <sagustss@uni-mainz.de>

processor.utilities.misc.plot_lines(data, normalization='None', range=None, color_range=(0, 1), x_label='', y_label='', xlim=None, ylim=None, savefig=False, save_dir='E:/data/FLASH/', save_name='fig', static_curve=None)[source]

function to fit a series of curves with nice colorplot.

processor.utilities.misc.radius(df, center=(0, 0))[source]

Calculate the radius.

processor.utilities.misc.repr_byte_size(size_bytes)[source]

Represent in a string the size in Bytes in a compact format.

Adapted from https://stackoverflow.com/questions/5194057/better-way-to-convert-file-sizes-in-python Follows same notation as Windows does for files. See: https://en.wikipedia.org/wiki/Mebibyte

processor.utilities.misc.save_H5_hyperstack(data_array, filename, path=None, overwrite=True)[source]

Saves an hdf5 file with 4D (Kx,Ky,E,Time) images for import in FIJI

Parameters:
data_array: numpy array

4D data array, order must be Kx,Ky,Energy,Time.

filename: str

The name of the file to save

path: str

The path to where to save hdf5 file. If None, uses the “results” folder from SETTINGS.ini.

overwrite: str

If true, it overwrites existing file with the same name. Otherwise raises and error.

processor.utilities.misc.write_setting(value, category, name, settings_file='default')[source]

Write enrty in the settings file

Args:

category (str): title of the category name (str): name of the parameter setting_file (str): path to setting file. If set to ‘default’ it takes

a file called SETTINGS.ini in the main folder of the repo.

Returns:

value of the parameter, None if parameter cannot be found.

Notes:

Author: Steinn Ymir Agustsson <sagustss@uni-mainz.de>