diff --git a/script/Alignment/Gun_solenoid_alignment.py b/script/Alignment/Gun_solenoid_alignment.py index ffdb1a2..c9f60ff 100755 --- a/script/Alignment/Gun_solenoid_alignment.py +++ b/script/Alignment/Gun_solenoid_alignment.py @@ -29,6 +29,7 @@ if get_context().source == CommandSource.ui: else: centroid_excursion_plot = False +multiple_background = multiple_background and use_background print "Parameters: ", I1, I2, dI, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S') @@ -37,11 +38,10 @@ plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S') add_device(CamTool("camtool") , True) camtool.setNumberOfImages(max(number_images,1)) camtool.enableBackground (use_background) -if use_background and not multiple_background: +if use_background: laser_off() - camtool.captureBackground(number_backgrounds) -multiple_background = multiple_background and use_background - + if not multiple_background: + camtool.captureBackground(number_backgrounds) # Switch off magnets mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", @@ -59,13 +59,13 @@ if zero_solenoids: # add here gun phase setting see wiki page -def br(): +def before_sample(): if multiple_background: camtool.captureBackground(number_backgrounds) laser_on() camtool.update() -def ar(): +def after_sample(): if multiple_background: laser_off() @@ -78,7 +78,7 @@ try: sensors = [camtool.com_x_mean, camtool.com_y_mean, camtool.com_x_stdev, camtool.com_y_stdev] if plot_image: sensors.append(camtool.image) - r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = br, after_read = ar) + r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = before_sample, after_read = after_sample) finally: laser_off() @@ -90,13 +90,13 @@ else: hx.append(hx[0]); hy.append(hy[0]) # save the entry in the logbook +gsa_log_msg = "Data file: " + get_context().path +gsa_log_msg = gsa_log_msg + "\n\n" + r.print() + if do_elog: - msg = str(r) - msg = msg + "\nFile: " + get_context().path - msg = msg + "\n\n" + r.print() - elog("Gun solenoid current scan", msg , get_plot_snapshots()) + elog("Gun solenoid current scan", gsa_log_msg , get_plot_snapshots()) -set_return([r, hx,hy]) +set_return([r, hx, hy])