def runTest(self): loader = VesuvioLoadHelper('single', 'spectrum', 'Vesuvio_IP_file_test.par', load_log_files=False) self._tof_input = VesuvioTOFFitInput('15039-15045', None, 'forward', loader)
def fit_tof(runs, flags, iterations=1, convergence_threshold=None): # Retrieve vesuvio input data vesuvio_loader = VesuvioLoadHelper( flags['diff_mode'], flags['fit_mode'], flags['ip_file'], flags.get('bin_parameters', None), _extract_bool_from_flags('load_log_files', flags)) vesuvio_input = VesuvioTOFFitInput(runs, flags.get('container_runs', None), flags.get('spectra', None), vesuvio_loader) if flags.get('ms_enabled', True): hydrogen_constraints = flags['ms_flags'].pop("HydrogenConstraints", None) ms_helper = VesuvioMSHelper(**flags['ms_flags']) if hydrogen_constraints is not None: ms_helper.add_hydrogen_constraints(hydrogen_constraints) else: ms_helper = VesuvioMSHelper() intensity_string = _create_intensity_constraint_str( flags['intensity_constraints']) fit_helper = VesuvioTOFFitHelper( _create_background_str(flags.get('background', None)), intensity_string, _create_user_defined_ties_str(flags['masses']), flags.get('max_fit_iterations', 5000), flags['fit_minimizer']) corrections_helper = VesuvioCorrectionsHelper( _extract_bool_from_flags('gamma_correct', flags, False), _extract_bool_from_flags('ms_enabled', flags), flags.get('fixed_gamma_scaling', 0.0), flags.get('fixed_container_scaling', 0.0), intensity_string) create_mass_profile = _mass_profile_generator(MaterialBuilder()) profiles = [create_mass_profile(profile) for profile in flags['masses']] mass_profile_collection = MassProfileCollection2D.from_collection( MassProfileCollection(profiles), vesuvio_input.spectra_number) fit_namer = VesuvioFitNamer.from_vesuvio_input(vesuvio_input, flags['fit_mode']) vesuvio_fit_routine = VesuvioTOFFitRoutine(ms_helper, fit_helper, corrections_helper, mass_profile_collection, fit_namer) vesuvio_output, result, exit_iteration = vesuvio_fit_routine( vesuvio_input, iterations, convergence_threshold, _extract_bool_from_flags('output_verbose_corrections', flags, False), _extract_bool_from_flags('calculate_caad', flags, False)) result = result if len(result) > 1 else result[0] return result, vesuvio_output.fit_parameters_workspace, vesuvio_output.chi2_values, exit_iteration