catalight.equipment.experiment_control.Experiment
- class catalight.equipment.experiment_control.Experiment(eqpt_list=False)
Bases:
object
Object containing all information necessary to run a particular experiment.
The experiment class is the center piece of catalight. This class contains several type checked properties that should be updated with relevant experimental parameters by the user. The user sets a desired experimental procedure from the list provided in
expt_list
Most importantly, equipment object can be passed to each instance of Experiment and used to run the
run_experiment()
method to control the hardware components.- Parameters:
eqpt_list (list of objects, optional) – List of equipment objects. Calls
update_eqpt_list()
, if provided. Order of list should be: (GC_Connector
,Diode_Laser
,Gas_System
,Heater
)
- __init__(eqpt_list=False)
Init experiment object.
Methods
__init__
([eqpt_list])Init experiment object.
create_dirs
(sample_path)Create directory for storing experiment data and analysis.
plot_sweep
([fig])Plot the sweep parameter vs time.
read_expt_log
(log_path)Read data from an existing log file and update object parameters.
Directs connected equipment to run experiment based on attributes.
Set initial conditions for experiment.
Set
date
based on current date.update_eqpt_list
(eqpt_list)Assign equipment objects as attributes of Experiment object.
update_expt_log
(expt_path)Update the experiment log based on current object parameters.
update_save_paths
(expt_path[, should_exist])Update data/results paths for the object.
Attributes
Save location for raw data, defined relative to expt_log.
Update w/
update_date()
method.This class attr defines the possible experiments.
Creates name using the fixed variables for expt
Define the desired experimental procedure selected from _expt_list.
List of gas composition lists to sweep through.
List of gas types for the MFCs to use to measure flow rates.
Describes the variable being modified.
List of power (mW) values to step through during experiment.
Save location for analysis, defined relative to expt_log.
Name of sample for building save paths
Sample rate in minutes (time it takes to collect a sample).
Updates when
set_initial_conditions()
method is called.List of temperature values to step through during experiment.
List of flow rates (sccm) to step through during experiment.
Number of GC samples to collect
(min) Time between last GC sample of a step and going to next condition
(min) Time between going to next condition and collecting first sample of a step
(deg C/min) Ramp rate to use when heating reactor.
- create_dirs(sample_path)
Create directory for storing experiment data and analysis.
This function creates a set of directories to store experimental data for a given experiment and the results of the analysis. Updates the experiment name based on current expt settings and creates/updates the experiment log file in the sample path
- Parameters:
sample_path (str) – Input the path where the data should be stored (sample folder)
- Raises:
AttributeError – Throws error if
expt_type
is undefined:- Return type:
None.
- property data_path
Save location for raw data, defined relative to expt_log. Update using
update_save_paths()
- Type:
str, read-only
- property date
Update w/
update_date()
method. For logging- Type:
str, read-only
- property expt_list
This class attr defines the possible experiments. This is an important part of the class and should be altered with caution. Changing the units within this DF should allow different unit inputs for the rest of the codebase, but this feature is untested!!!
- Type:
pandas.DataFrame, read-only
- property expt_type
Define the desired experimental procedure selected from _expt_list.
A key property directing much of the behavior of the class.For example, the run_experiment() method is guided by the expt_type provided. New values must be entered into the _expt_list attribute and the appropriate class methods must be edited to account for new experimental capabilities. Updates
ind_var
when called. Converts ‘Active Status’ inexpt_list
to True.
- property gas_comp
List of gas composition lists to sweep through. (ex. [[gas1, gas2, gas3],[…]]) Can be len=1 if not comp sweep. Each inner list must sum to 1 or 100. Initial value of [[0.0, 50.0, 0.0, 0.0]].
- property gas_type
List of gas types for the MFCs to use to measure flow rates. (ex. [gasA, gasB, gasC, …]) All values must be found in the gas library of the MFC system used. Initial value of [‘C2H2’, ‘Ar’, ‘H2’, ‘Ar’].
- property ind_var
Describes the variable being modified. This gets updated when expt_type is updated based on what defined by
expt_list
.- Type:
str, read-only
- plot_sweep(fig=None)
Plot the sweep parameter vs time.
- Parameters:
fig (matplotlib.pyplot.figure, optional) – Can supply figure object to write plot to it. The default is None.
- Returns:
matplotlib.pyplot.figure – figure object for experimental sweep. Two subplots for full and zoomed in versions. There is a hidden single subplot in background used for making shared axis titles
matplotlib.pyplot.axis – ax1 - top plot showing full experimental sweep
matplotlib.pyplot.axis – ax2 - bottom plot showing zoomed in version of experimental sweep
float – run_time - Calculate total time to run experiment
- property power
List of power (mW) values to step through during experiment. One element if constant or multiple for sweep. Initial value of [0.0].
- read_expt_log(log_path)
Read data from an existing log file and update object parameters.
Grows gas_type list if more gasses are found in the expt_log than contained in current gas_type list.
- Parameters:
log_path (str) – string to the full file path of the log file (‘./expt_log.txt’).
- Return type:
None.
- property results_path
Save location for analysis, defined relative to expt_log. Update using
update_save_paths()
- Type:
str, read-only
- run_experiment()
Directs connected equipment to run experiment based on attributes.
Most critical method of the class/package. This method directs the equipment to actually carry out the experiment based on the assigned attribute values for the object instance. This method currently works by using a series of if-statements to determine the experiment type and take the corresponding actions.
- property sample_rate
Sample rate in minutes (time it takes to collect a sample).
Set sample rate based on whether GC is connected. If GC is connected, try to set sample rate to that defined by expt. If that failed, _gc_control.sample_rate will be set to min defined by ctrl file.
- set_initial_conditions()
Set initial conditions for experiment.
Uses the first element of each attributes list to define initial conditions. Will also check that the temperature is not more than 10 degrees C above the first setpoint. The order is: 1. Set temperature 2. Give 1 minute time warning for laser 3. Set initial laser power 4. Set gas type 5. Set gas flows 6. Wait 2 minutes 7. Print gas flows 8. Update gc sample set size 9. Update date, time, and update log
- property start_time
Updates when
set_initial_conditions()
method is called. For logging. Used to calculate time_passed during analysis. Given by time.time() at the end of initial conditions steps.- Type:
str, read-only
- t_buffer
(min) Time between last GC sample of a step and going to next condition
- t_steady_state
(min) Time between going to next condition and collecting first sample of a step
- property temp
List of temperature values to step through during experiment. One element if constant or multiple for sweep. Initial value of [273.0].
- property tot_flow
List of flow rates (sccm) to step through during experiment. One element if constant or multiple for sweep. Initial value of [0.0].
- update_eqpt_list(eqpt_list)
Assign equipment objects as attributes of Experiment object.
Takes eqpt_list as tuple in format (gc controller, laser controller, gas controller, heater) and assigns each component to experiment object updates sample rate by given value in gc_control and updates heater ramp rate by the rate specified in experiment object
- Parameters:
eqpt_list (list[object]) – (
GC_Connector
,Diode_Laser
,Gas_System
,Heater
)
- update_expt_log(expt_path)
Update the experiment log based on current object parameters.
- Parameters:
expt_path (str) – path to the experiment folder
- update_save_paths(expt_path, should_exist=True)
Update data/results paths for the object.
Used when reading expt from log file or creating new expt data set
- Parameters:
- Raises:
ValueError – Gives error if should_exist=True and no results/data directories exists,
- Return type:
None.