lib.frontend package¶
Subpackages¶
- lib.frontend.process_widgets package
- Submodules
- lib.frontend.process_widgets.warea_detector module
- lib.frontend.process_widgets.wdata_1d module
- lib.frontend.process_widgets.wgixd module
- lib.frontend.process_widgets.wgixs module
- lib.frontend.process_widgets.wisotherm module
- lib.frontend.process_widgets.wxrf module
- lib.frontend.process_widgets.wxrr module
- Module contents
Submodules¶
lib.frontend.action module¶
Module for action widgets.
- lib.frontend.action.display_widgets_action(expt)¶
Set and display the widgets for choosing an action.
- Parameters:
expt (object) – Object of the class Experiment.
lib.frontend.experiment module¶
Module defining the class Experiment.
- class lib.frontend.experiment.Experiment¶
Bases:
objectClass defining an Experiment.
- paths¶
Dictionary of paths to files and folders.
- Type:
dict
- params¶
Dictionary of parameters.
- Type:
dict
- default¶
Dictionary of default values.
- Type:
dict
- is_paths_ok¶
True if all the paths are correct.
- Type:
bool
- list_nxs¶
List of nexus filenames in the nxs folder.
- Type:
list of str
- list_logs¶
List of log filenames in the logs folder.
- Type:
list of str
- list_scripts¶
List of script filenames in the scripts folder.
- Type:
list of str
- list_scans¶
List of scans selected in the interactive widget.
- Type:
list of objects Scan
- list_params_files¶
List of json files in the params folder.
- Type:
list of str
- default_log¶
List of commands from a log file.
- Type:
str
- check_and_set_paths(paths)¶
Check if the paths exist and set the attribute paths.
- Parameters:
paths (dict) – Dictionary of paths to files and folders.
- get_default_param_value(key, alt)¶
Return the value associated to the key if it already exists, else return the alternative value.
- Parameters:
key (str) – Key in the dictionnary params.
alt – Alternative value to return if the key is not present in params.
- Returns:
Value associated to the key or alternative value if not present in params.
- Return type:
value
- load_params_from_json(path_to_params)¶
Import a json file of params and set the attribute params.
- Parameters:
path_to_params (str) – Path to the json file.
- save_params_in_json(path_to_params)¶
Save the attribute params in a json file.
- Parameters:
path_to_params (str) – Path to the json file.
- set_list_images()¶
Refresh the list of files in the images folder and set the attribute list_images.
- set_list_logs()¶
Refresh the list of log files and set the attribute list_logs.
- set_list_nxs()¶
Refresh the list of nxs files and set the attribute list_nxs.
- set_list_params_files()¶
Refresh the list of params files and set the attribute list_params_files.
- set_list_scripts()¶
Refresh the list of script files and set the attribute list_scripts.
- set_scans(list_nxs)¶
Create a list of object Scans.
- Parameters:
list_nxs (list of str) – List of nexus filenames in the nxs folder.
- update_param_from_widget(dict_widgets, list_keys)¶
Update the default value of the keys in params with the value of the corresponding widget.
- Parameters:
dict_widgets (dict) – Dictionnary with the widgets.
list_keys (list of str) – List of keys in params to update.
lib.frontend.form module¶
Module for inserting a form (description of the experiment) in the notebook.
- lib.frontend.form.display_widgets_form()¶
Set and display the widgets for filling and inserting a form in the notebook.
lib.frontend.jlb_io module¶
Module dealing with the various imports and exports (pdf, logs, state …) and insertions in the notebook.
- lib.frontend.jlb_io.display_widgets_insert_from_log(expt)¶
Set and display the widgets for inserting commands or positions from a log file.
- Parameters:
expt (object) – Object of the class Experiment.
- lib.frontend.jlb_io.display_widgets_insert_image(path_to_images_dir, list_images)¶
Set and display the widgets for inserting an image.
- Parameters:
path_to_images_dir (str) – Path to the directory with the images.
list_images (list of str) – List of images filenames in the images folder.
- lib.frontend.jlb_io.display_widgets_insert_script(path_to_scripts_dir, list_scripts)¶
Set and display the widgets for inserting a script.
- Parameters:
path_to_scripts_dir (str) – Path to the directory with the scripts.
list_scripts (list of str) – List of script filenames in the scripts folder.
- lib.frontend.jlb_io.display_widgets_insert_text()¶
Set and display the widgets for inserting text.
- lib.frontend.jlb_io.display_widgets_load_params_from_json(expt)¶
Set and display the widgets for loading params from a json file.
- Parameters:
expt (object) – Object of the class Experiment.
- lib.frontend.jlb_io.display_widgets_save_params_in_json(expt)¶
Set and display the widgets for saving params in a json file.
- Parameters:
expt (object) – Object of the class Experiment.
- lib.frontend.jlb_io.export_logs_to_rlogs(path_to_logs_dir, list_logs, verbose=True, output_dir='readable_logs/')¶
Export all the logs to a human-readable version with date and commands only.
- Parameters:
path_to_logs_dir (str) – Path to the logs files directory, e.g. user/logs/.
list_logs (list of str) – List of log filenames in the logs folder.
verbose (bool, optional) – Verbose mode.
output_dir (str, optional) – Output directory.
- lib.frontend.jlb_io.export_nb_to_pdf(path_to_nb, timeout=100.0, verbose=True, output_dir='.')¶
Export the notebook to pdf.
- Parameters:
path_to_nb (str) – Path to the notebook. PDF is saved in the same folder.
timeout (float, optional) – Time in s before timeout.
verbose (bool, optional) – Verbose mode.
output_dir (str, optional) – Output directory.
- lib.frontend.jlb_io.extract_absorbers_from_log(path_to_logs_dir, list_logs, scan_name)¶
Extract from a log file the absorbers used for a specific scan.
- Parameters:
path_to_logs_dir (str) – Path to the logs files directory, e.g. user/logs/.
list_logs (list of str) – List of log filenames in the logs folder.
scan_name (str) – Name of the scan, e.g. ‘SIRIUS_2020_03_12_0756’.
- Returns:
absorbers – Absorbers used for the scan.
- Return type:
str
- lib.frontend.jlb_io.extract_commands_from_log(path_to_log_file)¶
Extract all commands from a log file.
- Parameters:
path_to_log_file (str) – Path to the log file.
- Returns:
arr_all_commands – Extracted commands.
- Return type:
array of str
- lib.frontend.jlb_io.extract_dead_pixels(file_dead_pixels)¶
Extract the dead pixels file.
- Parameters:
file_dead_pixels (str) – Path to the dead pixels file, e.g. ‘lib/params/dead_pixels/dead_pixels_pilatus.dat’
- Returns:
arr_dead_pixels – (y,x) positions of the dead pixels.
- Return type:
array
- lib.frontend.jlb_io.extract_positions_from_log(path_to_log_file)¶
Extract all positions from a log file.
- Parameters:
path_to_log_file (str) – Path to the log file.
- Returns:
list_positions – Extracted positions.
- Return type:
array of str
lib.frontend.notebook module¶
Module dealing with actions on the notebook itself (create cell, save nb, …). The code requires use of Javascript to modify the structure of the notebook and is therefore not usable in Jupyter Lab, which forbids Javascript.
- lib.frontend.notebook.create_cell(code, position='below', celltype='markdown', is_print=True, is_execute=True)¶
Create a cell in the Jupyter Notebook.
- Parameters:
code (str) – Code to display in the cell
position (str, optional) – Where to put the cell: ‘below’ or ‘at_bottom’
celltype (str, optional) – Type of cell: ‘code’ or ‘markdown’
is_print (bool, optional) – Print the cell in the pdf report
is_execute (bool, optional) – Execute the cell after its creation
- lib.frontend.notebook.create_cell_action_widgets(is_delete_current_cell)¶
Delete the current cell if asked, and create a cell to call the action widgets.
- Parameters:
is_delete_current_cell (bool) – Delete the current cell if True.
- lib.frontend.notebook.delete_cell()¶
Delete the cell in which this function was called in the Jupyter Notebook.
- lib.frontend.notebook.refresh_cell()¶
Refresh the current cell.
- lib.frontend.notebook.save_nb()¶
Save the current state of the notebook (including the widgets).
lib.frontend.process module¶
Module for process widgets.
- lib.frontend.process.display_widgets_process(expt)¶
Set and display the widgets for choosing a process on a selected scan.
- Parameters:
expt (object) – Object of the class Experiment.
lib.frontend.scan module¶
Module defining the class Scan.
- class lib.frontend.scan.Scan¶
Bases:
objectClass defining a Scan.
- path_to_nxs¶
Path to the nexus file, e.g. user/SIRIUS_2020_03_12_0756.nxs.
- Type:
str
- nxs_name¶
Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
- Type:
str
- name¶
Name of the scan, as is in the logs, e.g. SIRIUS_2020_03_12_0756.
- Type:
str
- command¶
Command corresponding to the scan, if found in the logs.
- Type:
str or None
- set_command(path_to_logs_dir, list_logs)¶
Find the command corresponding to the scan in the logs, and set it to the attribute command.
- Parameters:
path_to_logs_dir (str) – Path to the logs files directory, e.g. user/logs/.
list_logs (list of str) – List of log filenames in the logs folder.
- set_identifiers(path_to_nxs_dir, nxs_name)¶
Set identifiers to the scan (path, name …).
- Parameters:
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.