def __run_script__(fns): from Reduction import reduction,calibrations from os.path import join df.datasets.clear() # check input if not in_van_run.value: print 'specify vanadium run' return if not in_bkg_run.value: print 'specify background run' return # multiply to turn into floating point arrays van = Dataset(str(in_van_run.value)).get_reduced()*1.0 van.location = str(in_van_run.value) bkg = Dataset(str(in_bkg_run.value)).get_reduced()*1.0 bkg.location = str(in_bkg_run.value) # check if input is correct if van.ndim != 3: raise AttributeError('van.ndim != 3') if bkg.ndim != 3: raise AttributeError('van.ndim != 3') if van.axes[0].title != 'run_number': raise AttributeError('van.axes[0].title != run_number') if bkg.axes[0].title != 'run_number': raise AttributeError('bkg.axes[0].title != run_number') if van.shape != bkg.shape: # checks number of frames and detector pixel dimensions raise AttributeError('van.shape != bkg.shape') # check if input needs to be normalized if norm_apply.value: norm_ref = norm_table[str(norm_reference.value)] else: norm_ref = None low_lim = tool_frame_low.value high_lim = tool_frame_high.value if low_lim <=0: low_lim = 0 if eff_make.value: fl = None #holding value #eff = calibrations.calc_eff_mark2(van, bkg, norm_ref=norm_table[norm_ref], # esd_cutoff=eff_std_range.value) if str(eff_technique.value)=='No V peaks': eff, pix_ok,fudge_map,fl = calibrations.calc_eff_mark2(van,bkg,norm_ref=norm_ref, low_frame=low_lim, high_frame=high_lim) elif str(eff_technique.value)=='Naive': eff, pix_ok,fudge_map = calibrations.calc_eff_naive(van,bkg,norm_ref=norm_ref, low_frame=low_lim, high_frame=high_lim) else: raise ValueError, 'Efficiency calculation technique not recognised' var_check = Dataset(fudge_map) var_check.title = ('Variance against counts') Plot1.set_dataset(var_check) contrib_ds = Dataset(pix_ok) contrib_ds.title = 'Pixels contributing' Plot2.set_dataset(contrib_ds) if fl is not None: Plot3.set_dataset(Dataset(fl)) output_filename = join(str(out_folder.value), str(eff_name.value)) # write out new efficiency file import time print 'Writing efficiency file at %s' % time.asctime() eff.save_copy(output_filename) #calibrations.output_2d_efficiencies(eff, output_filename, comment='Created by Gumtree') print 'Finished writing at %s' % time.asctime()
def __run_script__(fns): from Reduction import reduction,calibrations from os.path import join df.datasets.clear() # check input if not in_van_run.value: print 'specify vanadium run' return if not in_bkg_run.value: print 'specify background run' return van = Dataset(str(in_van_run.value)).get_reduced() van.location = str(in_van_run.value) bkg = Dataset(str(in_bkg_run.value)).get_reduced() bkg.location = str(in_bkg_run.value) # check if input is correct if van.ndim != 3: raise AttributeError('van.ndim != 3') if bkg.ndim != 3: raise AttributeError('bkg.ndim != 3') if van.axes[0].title != 'azimuthal_angle': raise AttributeError('van.axes[0].title != azimuthal_angle') if bkg.axes[0].title != 'azimuthal_angle': raise AttributeError('bkg.axes[0].title != azimuthal_angle') if van.shape != bkg.shape: # checks number of frames and detector pixel dimensions raise AttributeError('van.shape != bkg.shape') # check if input needs to be normalized if norm_apply.value: norm_ref = str(norm_reference.value) # check if vertical tube correction list needs to be created vtc_filename = join(str(out_folder.value), str(vtc_name.value)) if vtc_make.value: if van.ndim > 2: summed = zeros(van.shape[1:]) for step in van: summed = summed + step input_ds = summed else: input_ds = van input_ds.location = van.location if str(vtc_algorithm.value) == 'Vertically Centered Average': calibrations.getVerticalCorrectionList(input_ds, output_filename=vtc_filename) elif str(vtc_algorithm.value) == 'Edges': calibrations.getVerticalEdges( input_ds,output_filename=vtc_filename) else: print 'Vertical offset algorithm not recognised' if eff_make.value: eff = calibrations.calc_eff_mark2(van, bkg,vtc_filename , norm_ref=norm_table[norm_ref]) output_filename = join(str(out_folder.value), str(eff_name.value)) # write out new efficiency file import time print 'Writing efficiency file at %s' % time.asctime() calibrations.output_2d_efficiencies(eff, output_filename, comment='Created by Gumtree') print 'Finished writing at %s' % time.asctime() if eff_transpose.value==True: output_filename = output_filename + '-transposed' calibrations.output_2d_efficiencies(eff,output_filename,comment='Created by Gumtree', transpose=True) print 'Finished writing transposed file at %s' % time.asctime()