def load_existing_calibration_files(self, file_path): if not path.exists(file_path): msg = "Could not open GSAS calibration file: " + file_path logger.warning(msg) raise try: instrument, ceria_no, params_table = self.get_info_from_file( file_path) self.update_calibration_params_table(params_table) except RuntimeError: logger.error("Invalid file selected: " + file_path) raise try: bank = EnggUtils.load_relevant_calibration_files(file_path) except Exception as e: logger.error( "Unable to loading calibration files corresponding to " + file_path + ". Error: " + str(e)) raise try: grp_ws_name, roi_text = EnggUtils.load_custom_grouping_workspace( file_path) except Exception as e: logger.error( "Unable to load grouping workspace corresponding to " + file_path + ". Error: " + str(e)) raise return instrument, ceria_no, grp_ws_name, roi_text, bank
def run(ceria_run, do_cal, do_van, full_inst_calib, van_run, calibration_directory, calibration_general, cropped, crop_name, crop_on, focus_directory, focus_general, do_pre_process, params, time_period, focus_run, grouping_file): """ calls methods needed based off of inputs @param ceria_run :: the run number of the ceria to use @param do_cal :: whether or not to force running calibration @param do_van :: whether or not to force calculating the vanadium @param full_inst_calib :: workspace containing the full instrument calibration @param van_run :: run number to use for the vanadium @param calibration_directory :: the users calibration directory @param calibration_general :: the non-user specific calibration directory @param crop_on :: where to crop using the cropping method @param crop_name :: how to name cropped banks @param cropped :: the cropping method to use @param focus_directory :: the users focus directory @param focus_general :: the non-user specific focus directory @param do_pre_process:: whether or not to pre-process before focussing @param params :: list of parameters to use for rebinning @param time_period :: time period to old binning @param focus_run :: run number to focus @param grouping_file :: grouping file to use with texture mode """ # check whether creating a vanadium is required or requested if (not os.path.isfile(_get_van_names(van_run, calibration_directory)[0])) or do_van: create_vanadium_integration(van_run, calibration_directory) # find the file names of calibration files that would be created by this run cal_endings = {"banks": ["all_banks", f"bank_{crop_on}"], "spectra": ["all_banks", f"bank_{crop_name}"], None: ["all_banks", "bank_North", "bank_South"]} expected_cals = [f"ENGINX_{van_run}_{ceria_run}_{ending}.prm" for ending in cal_endings.get(cropped)] expected_cals_present = [os.path.isfile(os.path.join(calibration_directory, cal_file)) for cal_file in expected_cals] pdcal_table_endings = {"banks": [f"bank_{crop_on}"], "spectra": ["cropped"], None: ["bank_North", "bank_South"]} expected_pdcal_tables = [f"ENGINX_{van_run}_{ceria_run}_{ending}.nxs" for ending in pdcal_table_endings.get(cropped)] expected_tables_present = [os.path.isfile(os.path.join(calibration_directory, cal_file)) for cal_file in expected_pdcal_tables] # if the calibration files that this run would create are not present, or the user has requested it, create the # calibration files if not all(expected_cals_present) or not all(expected_tables_present) or do_cal: create_calibration(ceria_run, van_run, full_inst_calib, calibration_directory, calibration_general, cropped, crop_name, crop_on) else: ending_to_load = {"banks": f"bank_{crop_on}", "spectra": crop_name, None: "all_banks"} file_name = os.path.join(calibration_directory, f"ENGINX_{van_run}_{ceria_run}_{ending_to_load.get(cropped)}.prm") Utils.load_relevant_calibration_files(file_name, "engg") # if a focus is requested, run the focus if focus_run is not None: focus(focus_run, van_run, full_inst_calib, calibration_directory, focus_directory, focus_general, do_pre_process, params, time_period, grouping_file, cropped, crop_on)