diff --git a/script/Diagnostics/BlmGainScan.py b/script/Diagnostics/BlmGainScan.py index 291f0b5..0f5d2a9 100644 --- a/script/Diagnostics/BlmGainScan.py +++ b/script/Diagnostics/BlmGainScan.py @@ -4,16 +4,26 @@ import ch.psi.pshell.epics.DiscretePositioner as DiscretePositioner #Arguments -SAMPLES = 5 -BLMS = ["SINDI02-DBLM025"] +SAMPLES = 10 +GAINS = ["SINDI02-DBLM084:M06-1-CH03-V-MM","SINDI02-DBLM084:M06-1-CH03-V-MM2",] +BLMS = ["SINDI02-DBLM025", "SINDI02-DBLM085", "S10DI01-DBLM045"] +ATTENUATORS = ["SINDI02-DBLM084:M06-1-ATT2-VAL", "SINDI02-DBLM084:M06-2-ATT2-VAL", "S10DI01-DBLM113:M06-1-ATT2-VAL"] RANGE = [0.5, 1.1] -STEP_SIZE = 0.10 -SETTLING_TIME = 0.1 +STEP_SIZE = 0.01 +SETTLING_TIME = 0.5 SIMULATION = True do_elog = True -pos = DummyPositioner("gain") +gain_positioners = [] +for i in range(len(GAINS)): + gain_positioners.append( DummyPositioner("gain " + str(i+1)) if SIMULATION else Channel(GAINS[i], alias = "gain " + str(i+1))) + +attenuators = [] +for i in range(len(ATTENUATORS)): + att = DiscretePositioner("Att"+str(i+1), ATTENUATORS[i]) + att.initialize() + attenuators.append(att) #Channel-based @@ -37,13 +47,51 @@ st.initialize() st.start() st.waitCacheChange(10000) #Wait stream be running before starting scan -#Metadata -set_exec_pars(persist = False) -try: - r=lscan(pos, sensors, RANGE[0], RANGE[1],STEP_SIZE, latency = SETTLING_TIME) - r=bscan(st, 10) - mscan(st, sensors, 10, -1) - -finally: - st.close() +""" +#Averaging +ablm1 = create_averager(blm1, SAMPLES, interval = -1) +ablm2 = create_averager(blm2, SAMPLES, interval = -1) +ablm2.setMonitored(True) +""" + +#Plot setup +setup_plotting( line_plots = line_plots) + + +#Metadata +set_attribute("/", "Samples" , SAMPLES) +set_attribute("/", "BLM" , BLMS) +set_attribute("/", "Gain" , GAINS) +set_attribute("/", "Range" , RANGE) +set_attribute("/", "Attenuators" , ATTENUATORS) +set_attribute("/", "StepSize" , STEP_SIZE) +set_attribute("/", "SamplingTime" , SETTLING_TIME) + +for att in attenuators: + set_attribute("/", att.setpoint.channelName, att.read()) + +try: + r=lscan(gain_positioners, sensors, [RANGE[0],] * len(gain_positioners), [RANGE[1],] * len(gain_positioners), [STEP_SIZE,] * len(gain_positioners), latency = SETTLING_TIME) +finally: + st.close() + + +# save the entry in the logbook +if do_elog: + if get_option("Generated data file:\n" + get_exec_pars().path + "\n\n" + "Save to ELOG?", "YesNo") == "Yes": + gsa_log_msg = "Data file: " + get_exec_pars().path + gsa_log_msg = gsa_log_msg + "\nSamples = " + str(SAMPLES) + gsa_log_msg = gsa_log_msg + "\nBLM = " + str(BLMS) + gsa_log_msg = gsa_log_msg + "\nGain = " + str(GAINS) + gsa_log_msg = gsa_log_msg + "\nRange = " + str(RANGE) + gsa_log_msg = gsa_log_msg + "\nAttenuators = " + str(ATTENUATORS) + gsa_log_msg = gsa_log_msg + "\nStepSize = " + str(STEP_SIZE) + gsa_log_msg = gsa_log_msg + "\nSamplingTime = " + str(SETTLING_TIME) + + plots = get_plot_snapshots() + save=[] + for i in range(len(BLMS)): + save.append(plots[3*i]) + elog("Wire Scan", gsa_log_msg, save) +