Commit 0291aa26 authored by Vasilisa Usova's avatar Vasilisa Usova
Browse files

Removing unnecessary printing, changes in couple_parameters and progress bars

parent 544f389d
......@@ -39,9 +39,7 @@ class DA(Instrument):
def __init__(self, id_string, channel=0, driver=None, database=True, **kwargs):
# Device parameters ####################################################
print('start init')
super().__init__(id_string, kwargs, driver, database)
print('continue init')
self.ch = int(channel)
self.devtype = 'DA'
......
import numpy as np
import h5py
from tqdm import tqdm
from tqdm.auto import tqdm
import time
import shutil
......@@ -75,7 +75,6 @@ class BondedOnOffParameter(BondedParameter):
self.instrument_func(instruments[self._instrument_name].instrument_instance, self.off_value)
self.last_value = self.off_value
## To be finished to be implemented
class CoupledBondedParameters():
def __init__(self, name, bonded_parameters):
## bonded_parameters must be a list of bonded parametters
......@@ -246,9 +245,10 @@ class Experiment():
def add_bonded_parameter(self, bonded_parameter):
self.parameters[bonded_parameter.name] = bonded_parameter
def couple_parameters(self, coupled_parameters):
parameter_name = ''.join([coupled_parameters[i].name + '+' for i in range(len(coupled_parameters))])
parameter_name = parameter_name[:-1]
def couple_parameters(self, coupled_parameters, parameter_name = ''):
if not parameter_name:
parameter_name = ''.join([coupled_parameters[i].name + '+' for i in range(len(coupled_parameters))])
parameter_name = parameter_name[:-1]
self.parameters[parameter_name] = CoupledBondedParameters(parameter_name, coupled_parameters)
def add_measurement(self, instrument_name, measurement_name, instrument_func, options = {}, suffix = ''):
......@@ -388,7 +388,6 @@ class Experiment():
string_sweep_parameters = 'Parameters which will be swept by python code: \n'
for parameter in sweep_parameters:
print(self.instruments, self.parameters[parameter].data[0])
self.parameters[parameter](self.instruments, self.parameters[parameter].data[0])
string_sweep_parameters += '\t '+parameter+': '
string_sweep_parameters += 'start %.3g %s'%(self.parameters[parameter].data[0],
......@@ -424,7 +423,6 @@ class Experiment():
## Close all opened instruments
for instrument in initialized_instruments:
self.instruments[instrument].stop()
return
def measure(self, sweep_parameters, list_measurements, mode='sequential'):
......@@ -512,15 +510,16 @@ class Experiment():
#print(number_iteration)
with tqdm(generator_indexes, total=number_iteration,
bar_format="{l_bar}{bar}|{n:.1f}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}] ") as progress_bar_line1:
with tqdm(total=number_iteration, bar_format="{postfix}") as progress_bar_line2:
bar_format="{l_bar}{bar}|{n:.0f}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]{postfix}") as progress_bar_line1:
#with tqdm(total=number_iteration, bar_format="{postfix}") as progress_bar_line2:
for indexes in progress_bar_line1:
#Add settles
for i, parameter in enumerate(sweep_parameters):
self.parameters[parameter](self.instruments, self.parameters[parameter].data[indexes[i]])
progress_bar_line2.set_postfix_str(self.format_parameter(sweep_parameters), refresh=True)
#progress_bar_line2.set_postfix_str(self.format_parameter(sweep_parameters), refresh=True)
progress_bar_line1.set_postfix_str(self.format_parameter(sweep_parameters), refresh=True)
if len(on_off_sweep_parameter) == 0:
if mode == 'sequential':
......@@ -530,8 +529,6 @@ class Experiment():
dataset_measurements = \
DataSet().fuse_another_dataset(dataset_measurements,
suffix=self.measurements[measurement].suffix)
#print(self.parameters)
print("Measurement ended successfully")
except KeyboardInterrupt:
print("Measurement terminated")
print('Current parameters: ')
......@@ -541,13 +538,11 @@ class Experiment():
if self.local_folder is not None:
shutil.copyfile(self.local_folder+fname, self.storage_folder+fname)
#rm.visalib.sessions[fg.session].interface.lastxid -= 1?
#print current parameters
return
except:
print("Measurement cannot be finished successfully, restarting instruments")
print('Current parameters: ')
print(parameter, self.parameters[parameter].data[indexes[i]])
#print current parameters
self.close_all_instruments(initialized_instruments)
_ = self.initialize_instruments(sweep_parameters, list_measurements)
self.start_all_instruments(initialized_instruments)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment