sandialabs / pyscan

Scientific Measurement Toolbox
https://pyscan.readthedocs.io/en/latest/
MIT License
4 stars 4 forks source link

Function (built in to load experiment) to interpret loaded experiment and output a summary. #76

Open rsbrost opened 6 months ago

rsbrost commented 2 months ago

For this I think we should try and have it output the code used to set up said experiment. For example, in demo nb 1 it would output something like:

devices = ps.ItemAttribute()

devices.v1 = ps.TestVoltage() # Device 1
devices.v2 = ps.TestVoltage() # Device 2
devices.v3 = ps.TestVoltage() # Device 3

def get_voltage_data(expt):
    runinfo = expt.runinfo
    devices = expt.devices

    d = ps.ItemAttribute()

    d.v1_readout = devices.v1.voltage
    d.v2_readout = devices.v2.voltage
    d.v3_readout = devices.v3.voltage

    d.vsum = d.v1_readout + d.v2_readout + d.v3_readout

    return d

runinfo = ps.RunInfo()
runinfo.scan0 = ps.PropertyScan({'v1': ps.drange(0, 0.1, 1)}, prop='voltage', dt=0.01)

runinfo.measure_function = get_voltage_data

expt = ps.Experiment(runinfo, devices, time=True)
expt.start_thread()  # or alternatively expt.run()

I think this could offer a quick overview of how the experiment was designed and be valuable to experimenters wanting to understand old experiments.