Update scripts/experiment_remote.py
cleaning up of the code and commenting
This commit is contained in:
parent
49bc1ec08a
commit
d84103560e
@ -1,34 +1,46 @@
|
||||
#imports for runmanager - labscript
|
||||
from runmanager_remote import run_experiment
|
||||
from lyse import *
|
||||
|
||||
import pandas as pd
|
||||
|
||||
import TestDA
|
||||
import xarray as xr
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
routine_name = 'TestSetup'
|
||||
|
||||
TestVar = {'T_wlm': 1,
|
||||
'delta_freq': 0,
|
||||
'wait_AWG': 5,
|
||||
'buffer_time': 5,
|
||||
'carrier_amp': 2
|
||||
}
|
||||
|
||||
|
||||
hdf_output_file = run_experiment(routine_name, global_var = TestVar)
|
||||
|
||||
print('run finished')
|
||||
|
||||
#df = pd.DataFrame(lyse_run.get_result('wlm', 'wlm_df'), columns = ['timestamp [s]','wavelength [nm]', 'frequency [THz]'])
|
||||
#print(df)
|
||||
|
||||
#results = TestDA.analysis(hdf_output_file)
|
||||
|
||||
cost = TestDA.cost(hdf_output_file)
|
||||
#print('I am back')
|
||||
|
||||
#imports for runmanager - labscript
|
||||
from runmanager_remote import run_experiment
|
||||
|
||||
|
||||
import importlib
|
||||
_module_cache = {}
|
||||
|
||||
# use this script if you want to test a single iteration of NNDy with your sequence and DA,
|
||||
# if you get the cost dictionary printed at the end as expected, the test is passed
|
||||
|
||||
def cost_function(cost_model, hdf5_file):
|
||||
module_name = cost_model
|
||||
|
||||
#looks in the cache if the file was accessed already, otherwise imports the cost function
|
||||
if module_name not in _module_cache:
|
||||
try:
|
||||
module = importlib.import_module(module_name)
|
||||
cost_func = getattr(module, 'cost')
|
||||
_module_cache[module_name] = {
|
||||
"cost_func": cost_func ,
|
||||
}
|
||||
except (ModuleNotFoundError, AttributeError) as e:
|
||||
raise ImportError(f'Failed to load cost function from "{module_name}.py": {e}')
|
||||
|
||||
cost_model = _module_cache[module_name]["cost_func"]
|
||||
|
||||
return cost_model(hdf5_file)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
#provide routine_name and cost_model like in NNDy.py
|
||||
routine_name = ''
|
||||
cost_model = ''
|
||||
#set the input parameters with the values that you want to test in a dictionary
|
||||
TestVar = {
|
||||
}
|
||||
|
||||
hdf_output_file = run_experiment(routine_name, global_var = TestVar)
|
||||
|
||||
print('run finished')
|
||||
|
||||
|
||||
cost = cost_function(cost_model, hdf_output_file)
|
||||
#print('I am back')
|
||||
|
||||
print(cost)
|
Loading…
Reference in New Issue
Block a user