def analyze_and_report_from_data(name, out_dir, profiles, ifts, raw_settings=None): if raw_settings is None: raw_settings = raw.__default_settings profiles, ifts, all_dammif_data, all_denss_data = analyze.analyze_data( out_dir, profiles, ifts, raw_settings) series = [] pdf.make_report_from_data(name, out_dir, profiles, ifts, series, dammif_data=all_dammif_data, denss_data=all_denss_data) for profile in profiles: raw.save_profile(profile, datadir=out_dir, settings=raw_settings) for ift in ifts: raw.save_ift(ift, datadir=out_dir)
def run_efa_for_report(secm, efa_ranges, prof_type, efa_start, efa_end, efa_method, efa_iter_limit, efa_tolerance): efa_results = raw.efa(secm, efa_ranges, prof_type, int(efa_start), int(efa_end), efa_method, int(efa_iter_limit), float(efa_tolerance)) return efa_results
def run_regals_for_report(secm, regals_component_settings, prof_type, regals_start, regals_end, regals_x_cal, min_iter, max_iter, tol, conv_type): regals_results = raw.regals(secm, regals_component_settings, prof_type, int(regals_start), int(regals_end), regals_x_cal, min_iter, max_iter, tol, conv_type) return regals_results
def _load_raw_settings(self, raw_settings_file): logger.debug('Loading RAW settings from %s', raw_settings_file) self.raw_settings_file = raw_settings_file self.raw_settings = raw.load_settings(raw_settings_file) try: self.s_cmd_q.append(['set_raw_settings', [self.raw_settings]]) except Exception: # On startup loading settings happens before creating the cmd q. pass self._ret_lock.acquire() for proc in self.reduction_processes: proc.load_settings(raw_settings_file) for proc in self.analysis_processes: proc.load_settings(raw_settings_file) self._ret_lock.release()
# gen_config_results = saxs_raver.init_integration(os.path.join(base_config_dir, 'SAXS_cytc_basic.cfg')) # for fnum in fnum_list: # if os.path.exists(os.path.join(base_config_dir, 'SAXS_cytc_{:03d}.cfg'.format(fnum))): # config_results = saxs_raver.init_integration(os.path.join(base_config_dir, 'SAXS_cytc_{:03d}.cfg'.format(fnum))) # else: # config_results = gen_config_results # config_dict[fnum] = config_results # December 2019 if 'martin' in source_dir.lower(): for fnum in fnum_list: print fnum # gen_config_results = saxs_raver.init_integration(os.path.join(base_config_dir, 'em_basic_{:04d}.cfg'.format(fnum))) gen_config_results = raw.load_settings( os.path.join(base_config_dir, 'em_basic_{:04d}.cfg'.format(fnum))) for step in step_list: print step if os.path.exists( os.path.join(base_config_dir, 'em_{}_{:04d}.cfg'.format(step, fnum))): # print os.path.join(base_config_dir, 'em_{}_{:04d}.cfg'.format(step, fnum)) # config_results = saxs_raver.init_integration(os.path.join(base_config_dir, 'em_{}_{:04d}.cfg'.format(step, fnum))) config_results = raw.load_settings( os.path.join(base_config_dir, 'em_{}_{:04d}.cfg'.format(step, fnum))) else: # print 'basic'
def init_integration(cfg_file): #Load a RAW.cfg file raw_settings = raw.load_settings(cfg_file) #Get parameters detector = pyFAI.detector_factory("pilatus1m") masks = raw_settings.get('Masks') mask = masks['BeamStopMask'][0] mask = np.logical_not(mask) sd_distance = raw_settings.get('SampleDistance') pixel_size = raw_settings.get('DetectorPixelSize') wavelength = raw_settings.get('WaveLength') bin_size = raw_settings.get('Binsize') normlist = raw_settings.get('NormalizationList') do_normalization = raw_settings.get('EnableNormalization') #Put everything in appropriate units pixel_size = pixel_size *1e-6 #convert pixel size to m wavelength = wavelength*1e-10 #convert wl to m #Set up q calibration xlen, ylen = detector.shape x_cin = raw_settings.get('Xcenter') y_cin = detector.shape[0]-raw_settings.get('Ycenter') maxlen1 = int(max(xlen - x_cin, ylen - y_cin, xlen - (xlen - x_cin), ylen - (ylen - y_cin))) diag1 = int(np.sqrt((xlen-x_cin)**2 + y_cin**2)) diag2 = int(np.sqrt((x_cin**2 + y_cin**2))) diag3 = int(np.sqrt((x_cin**2 + (ylen-y_cin)**2))) diag4 = int(np.sqrt((xlen-x_cin)**2 + (ylen-y_cin)**2)) maxlen = int(max(diag1, diag2, diag3, diag4, maxlen1)/bin_size) x_c = float(x_cin) y_c = float(y_cin) qmin_theta = calcTheta(sd_distance*1e-3, pixel_size, 0) qmin = ((4*math.pi*math.sin(qmin_theta))/(wavelength*1e10)) qmax_theta = calcTheta(sd_distance*1e-3, pixel_size, maxlen) qmax = ((4*math.pi*math.sin(qmax_theta))/(wavelength*1e10)) q_range = (qmin, qmax) #Set up the pyfai Aziumuthal integrator ai = pyFAI.AzimuthalIntegrator(detector=detector) ai.wavelength = wavelength ai.pixel1 = pixel_size ai.pixel2 = pixel_size ai.setFit2D(sd_distance, x_c, y_c) calibrate_dict = {'Sample_Detector_Distance' : sd_distance, 'Detector_Pixel_Size' : pixel_size, 'Wavelength' : wavelength, 'Beam_Center_X' : x_c, 'Beam_Center_Y' : y_c, 'Radial_Average_Method' : 'pyFAI', } fliplr = raw_settings.get('DetectorFlipLR') flipud = raw_settings.get('DetectorFlipUD') ai.setup_CSR((xlen, ylen), npt=maxlen, mask=mask, pos0_range=q_range, unit='q_A^-1', split='no', mask_checksum=mask.sum()) ai.setup_LUT((xlen, ylen), npt=maxlen, mask=mask, pos0_range=q_range, unit='q_A^-1', mask_checksum=mask.sum()) return ai, mask, q_range, maxlen, normlist, do_normalization, raw_settings, calibrate_dict, fliplr, flipud