syncmoss 0.5.1__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.gitignore +3 -5
- {syncmoss-0.5.1 → syncmoss-0.6.0}/PKG-INFO +1 -1
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/bundle.py +5 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/macos_bundle.py +5 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/pyproject.toml +17 -12
- syncmoss-0.6.0/syncmoss/CMS_source_geometry_calibration.py +373 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Calibration.py +69 -7
- syncmoss-0.6.0/syncmoss/Expressions/Central shift vs temperature.mdl +11 -0
- syncmoss-0.6.0/syncmoss/Expressions/Hyperfine field in applied field, Langevin.mdl +8 -0
- syncmoss-0.6.0/syncmoss/Expressions/Hyperfine field vs temperature, Bloch.mdl +8 -0
- syncmoss-0.6.0/syncmoss/Expressions/Hyperfine field vs temperature, critical.mdl +8 -0
- syncmoss-0.6.0/syncmoss/Expressions/Hyperfine field vs temperature, empirical.mdl +8 -0
- syncmoss-0.6.0/syncmoss/Expressions/Lamb-Mossbauer factor vs temperature.mdl +9 -0
- syncmoss-0.6.0/syncmoss/Expressions/Lifetime from line width.mdl +7 -0
- syncmoss-0.6.0/syncmoss/Expressions/Neel relaxation time vs temperature.mdl +8 -0
- syncmoss-0.6.0/syncmoss/Expressions/Paramagnetic quadrupole shift from Hamiltonian.mdl +7 -0
- syncmoss-0.6.0/syncmoss/Expressions/Quadrupole splitting, doublet.mdl +7 -0
- syncmoss-0.6.0/syncmoss/Expressions/Quadrupole splitting, sextet.mdl +7 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/constants.py +28 -6
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/error_reporter.py +3 -8
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/exclusion_bar.py +1 -2
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/exclusion_regions.py +10 -2
- syncmoss-0.6.0/syncmoss/expression_eval.py +43 -0
- syncmoss-0.6.0/syncmoss/expressions_io.py +105 -0
- syncmoss-0.6.0/syncmoss/expressions_window.py +294 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/fitting_io.py +91 -65
- syncmoss-0.6.0/syncmoss/instrumental_dialogs.py +232 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/instrumental_io.py +506 -125
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/license_window.py +5 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/main.py +12 -1
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/minimi_lib.py +243 -137
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/model_io.py +70 -11
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/models.py +705 -142
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/models_description_window.py +164 -6
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/models_positions.py +12 -13
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/one_model.py +4 -0
- syncmoss-0.6.0/syncmoss/parameters/Calibration.dat +514 -0
- syncmoss-0.6.0/syncmoss/parameters/GCMS.txt +1 -0
- syncmoss-0.6.0/syncmoss/parameters/INSexp.txt +1 -0
- syncmoss-0.6.0/syncmoss/parameters/INSint.txt +1 -0
- syncmoss-0.6.0/syncmoss/parameters/Standard_CMS.dat +514 -0
- syncmoss-0.6.0/syncmoss/parameters/Standard_SMS.dat +514 -0
- syncmoss-0.6.0/syncmoss/parameters/calibr.png +0 -0
- syncmoss-0.6.0/syncmoss/parameters/help.md +187 -0
- syncmoss-0.6.0/syncmoss/parameters/help_extended.md +920 -0
- syncmoss-0.6.0/syncmoss/parameters/models_description.md +297 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/parameters_table.py +106 -50
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/result_window.py +7 -1
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/results_table.py +7 -17
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/sms_theory.py +15 -7
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/spectrum_io.py +35 -22
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/spectrum_plotter.py +72 -50
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/supp_menu.py +243 -99
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/syncmoss_main.py +570 -152
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss.egg-info/PKG-INFO +1 -1
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss.egg-info/SOURCES.txt +32 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss.egg-info/scm_file_list.json +33 -1
- syncmoss-0.6.0/tests/README.md +118 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/conftest.py +183 -27
- syncmoss-0.6.0/tests/profile_resources.py +258 -0
- syncmoss-0.6.0/tests/resource_profile.json +5557 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/syncmoss_test.py +110 -31
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_baseline_polynomial.py +3 -10
- syncmoss-0.6.0/tests/test_calculation_time.py +30 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_calibration.py +27 -4
- syncmoss-0.6.0/tests/test_channel_average.py +499 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_chi2_spread.py +24 -6
- syncmoss-0.6.0/tests/test_cms_source_geometry_calibration.py +138 -0
- syncmoss-0.6.0/tests/test_cosine_smearing.py +1081 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_create_spectrum_from_model.py +4 -1
- syncmoss-0.6.0/tests/test_default_settings.py +123 -0
- syncmoss-0.6.0/tests/test_distr_composition.py +92 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_distr_expansion.py +25 -3
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_distr_mdl.py +5 -10
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_distr_targets.py +83 -0
- syncmoss-0.6.0/tests/test_distr_text_references.py +308 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_exclusion_fit.py +29 -27
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_exclusion_gui.py +28 -12
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_expression_fit_start.py +6 -32
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_expression_validation.py +43 -0
- syncmoss-0.6.0/tests/test_expressions.py +429 -0
- syncmoss-0.6.0/tests/test_find_bar.py +135 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_fit_core.py +9 -15
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_fit_one_spectrum.py +4 -9
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_gui_smoke.py +38 -59
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_instrumental_joint.py +7 -13
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_instrumental_metadata.py +11 -14
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_instrumental_method_choice.py +20 -8
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_interrupt.py +4 -7
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_library_dir.py +13 -2
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_link_chains.py +2 -2
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_minimi_bounds.py +3 -3
- syncmoss-0.6.0/tests/test_minimi_covariance.py +273 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_model_only_mode.py +52 -20
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_model_pointwise.py +2 -9
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_nbaseline_multidistr.py +2 -7
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_one_model_gui.py +8 -14
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_overwrite_dat_instrumental.py +59 -2
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_parameter_links.py +42 -3
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_polarization.py +1 -1
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_recon_composition.py +8 -50
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_recon_variants.py +3 -8
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_replaced_component_skip.py +2 -7
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_result_window.py +2 -2
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_results_table_rows.py +13 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_sdw_grid.py +2 -2
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_search_guards.py +17 -7
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_sms_theory.py +11 -15
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_source_norm.py +11 -18
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_spectrum_parameters.py +3 -9
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_thick_gui.py +0 -7
- syncmoss-0.6.0/tests/worker_plan.py +233 -0
- syncmoss-0.5.1/syncmoss/parameters/Calibration.dat +0 -513
- syncmoss-0.5.1/syncmoss/parameters/GCMS.txt +0 -1
- syncmoss-0.5.1/syncmoss/parameters/INSexp.txt +0 -1
- syncmoss-0.5.1/syncmoss/parameters/INSint.txt +0 -1
- syncmoss-0.5.1/syncmoss/parameters/calibr.png +0 -0
- syncmoss-0.5.1/syncmoss/parameters/help.md +0 -467
- syncmoss-0.5.1/syncmoss/parameters/models_description.md +0 -466
- syncmoss-0.5.1/tests/test_distr_composition.py +0 -163
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.gitattributes +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/Tests.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_MacOS.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_PyPI.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_TagRelease.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_Tests.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_UploadRelease.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_Version.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_Wheels.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/_WindowsExe.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.github/workflows/release.yml +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/.vscode/settings.json +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/COPYING.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/LICENSE +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/Lib_test/test.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/NOTICE.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/README.md +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/MacOS.spec +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/SYNCmoss.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/Windows.spec +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/dmg_background.pdf +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/licenses/GPL-3.0.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/licenses/LGPL-3.0.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/bundle/third_party_licenses.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/docs/thick_models.md +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/docs/thick_vs_thin.md +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/requirements.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/setup.cfg +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Hamiltonian_helper.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Aegirine.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Akaganeite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Almandine.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Antitaenite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Arsenopyrite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Bornite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Bridgmanite (Fe,Al-bearing) @100 GPa.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Bridgmanite (Fe,Al-bearing).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Celadonite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Cementite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Chalcopyrite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Clinopyroxene (augite).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Copiapite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Cubanite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Epidote.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Fayalite (Fe-olivine).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Ferrihydrite (2-line).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Ferropericlase.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Goethite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Green rust (fougerite, carbonate).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Haegg carbide.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Hedenbergite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Hematite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Heterosite (FePO4).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Ilmenite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Iron phosphide.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Isocubanite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Jarosite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Kamacite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Lepidocrocite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Maghemite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Magnetite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Marcasite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Melanterite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Orthopyroxene (enstatite-ferrosilite).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Prussian blue (ferric ferrocyanide).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Pyrite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Pyrrhotite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Rhomboclase.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Roemerite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Siderite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Szomolnokite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Taenite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Talnakhite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Tetrataenite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Triphylite (LiFePO4).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Troilite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Vivianite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/Voltaite.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library/alpha-Fe (metallic iron, bcc).mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library_io.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/Library_window.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/bliss_channel.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/CheckBox.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/CheckBox_.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/CheckBox_L.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/CheckBox_L2.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/DU.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/Switch.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/UD.png +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/icons/icon_r.ico +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/instrumental_window.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/legacy.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/one_spectrum.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/parameters/ABSorber3.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/parameters/Be.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/parameters/INS_APS.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/parameters/INSth.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/parameters/KB.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/parameters/NFS.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/spectrum_parameters.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/support_math.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/test_graf.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/test_param.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/theme_dark.json +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss/theme_light.json +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss.egg-info/dependency_links.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss.egg-info/entry_points.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss.egg-info/requires.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/syncmoss.egg-info/top_level.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/Distr_corr.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/Distr_distr.mdl +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/alpha_fe_sms_000.mca +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/calibration_000_golden.json +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/generate_cal_fixtures.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/parameters/Calibration.dat +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/parameters/GCMS.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/parameters/INSexp.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/parameters/INSint.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/parameters/INSth.txt +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/synthetic_alpha_fe_cms_linear.mca +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/data/synthetic_alpha_fe_cms_sinus.mca +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/golden_models.json +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_bliss_channel.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_calibration_helpers.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_calibration_path.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_contact_author.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_error_reporter.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_exclusion_regions.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_golden_models.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_hamiltonian_texture.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_impurity_presets.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_instrumental_recentre.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_instrumental_window.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_integral_points.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_legacy.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_library_io.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_license_window.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_minimi_batch_eval.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_model_append.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_model_io.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_nbaseline_results.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_node_sum_reuse.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_one_model_expand.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_recon_mdl.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_recon_results.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_reference_shift.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_results_table_image.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_save_result_model.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_support_math.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_table_marks.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_take_result.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_texture_s1.py +0 -0
- {syncmoss-0.5.1 → syncmoss-0.6.0}/tests/test_theory_search.py +0 -0
|
@@ -138,6 +138,9 @@ source_code/
|
|
|
138
138
|
bundle/build/
|
|
139
139
|
bundle/Windows/
|
|
140
140
|
|
|
141
|
+
# The user's saved settings (Supp -> Save settings as default): never shipped
|
|
142
|
+
syncmoss/parameters/config.json
|
|
143
|
+
|
|
141
144
|
# fitting results
|
|
142
145
|
|
|
143
146
|
syncmoss/*.mdl
|
|
@@ -158,11 +161,6 @@ verify_minimi.py
|
|
|
158
161
|
bench_coldstart.py
|
|
159
162
|
minimi_optimization_notes.txt
|
|
160
163
|
|
|
161
|
-
# SCDW grid-vs-direct / physics-invariant checks: kept local-only. The tracked
|
|
162
|
-
# suite still covers the model end-to-end via the SCDW golden case, plus its
|
|
163
|
-
# param-count and locked-angle checks (test_model_io / test_thick_gui).
|
|
164
|
-
tests/test_sdw_grid.py
|
|
165
|
-
|
|
166
164
|
# SMS instrumental-function study against the ESRF (temperature, angle) dataset
|
|
167
165
|
# on N:\SL_studies: analysis scripts, cached intermediate fits and the figures
|
|
168
166
|
# they produce. Local-only -- it needs a network share that is not part of the
|
|
@@ -54,6 +54,7 @@ def copy_resources():
|
|
|
54
54
|
(os.path.join(syncmoss_DIR, "icons"), os.path.join(OUTPUT_DIR, "icons")),
|
|
55
55
|
(os.path.join(syncmoss_DIR, "parameters"), os.path.join(OUTPUT_DIR, "parameters")),
|
|
56
56
|
(os.path.join(syncmoss_DIR, "Library"), os.path.join(OUTPUT_DIR, "Library")),
|
|
57
|
+
(os.path.join(syncmoss_DIR, "Expressions"), os.path.join(OUTPUT_DIR, "Expressions")),
|
|
57
58
|
]
|
|
58
59
|
for src, dst in folder_pairs:
|
|
59
60
|
if os.path.isdir(dst):
|
|
@@ -116,9 +117,13 @@ def verify():
|
|
|
116
117
|
"parameters/INSint.txt",
|
|
117
118
|
"parameters/models_description.md",
|
|
118
119
|
"parameters/help.md",
|
|
120
|
+
"parameters/help_extended.md",
|
|
119
121
|
"theme_dark.json",
|
|
120
122
|
"theme_light.json",
|
|
121
123
|
"parameters/Calibration.dat",
|
|
124
|
+
# the standard spectra the "--test" smoke run fits
|
|
125
|
+
"parameters/Standard_SMS.dat",
|
|
126
|
+
"parameters/Standard_CMS.dat",
|
|
122
127
|
"COPYING.txt",
|
|
123
128
|
"NOTICE.txt",
|
|
124
129
|
"LICENSE",
|
|
@@ -59,6 +59,7 @@ def copy_resources(app_dir: str):
|
|
|
59
59
|
(os.path.join(SYNCMOSS_DIR, "icons"), os.path.join(app_macos_dir, "icons")),
|
|
60
60
|
(os.path.join(SYNCMOSS_DIR, "parameters"), os.path.join(app_macos_dir, "parameters")),
|
|
61
61
|
(os.path.join(SYNCMOSS_DIR, "Library"), os.path.join(app_macos_dir, "Library")),
|
|
62
|
+
(os.path.join(SYNCMOSS_DIR, "Expressions"), os.path.join(app_macos_dir, "Expressions")),
|
|
62
63
|
]
|
|
63
64
|
for src, dst in folder_pairs:
|
|
64
65
|
if os.path.isdir(dst):
|
|
@@ -114,7 +115,11 @@ def verify(app_dir: str):
|
|
|
114
115
|
"Contents/MacOS/parameters/KB.txt",
|
|
115
116
|
"Contents/MacOS/parameters/models_description.md",
|
|
116
117
|
"Contents/MacOS/parameters/help.md",
|
|
118
|
+
"Contents/MacOS/parameters/help_extended.md",
|
|
117
119
|
"Contents/MacOS/parameters/Calibration.dat",
|
|
120
|
+
# the standard spectra the "--test" smoke run fits
|
|
121
|
+
"Contents/MacOS/parameters/Standard_SMS.dat",
|
|
122
|
+
"Contents/MacOS/parameters/Standard_CMS.dat",
|
|
118
123
|
"Contents/MacOS/theme_dark.json",
|
|
119
124
|
"Contents/MacOS/theme_light.json",
|
|
120
125
|
# third-party license texts (MacOS.spec -> third_party_licenses.py);
|
|
@@ -73,21 +73,26 @@ local_scheme = "no-local-version"
|
|
|
73
73
|
|
|
74
74
|
[tool.pytest.ini_options]
|
|
75
75
|
testpaths = ["tests"]
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
# leaves most of the machine idle -- measured 351 s serial against 116 s on 8
|
|
79
|
-
# workers for the calibration + instrumental set.
|
|
76
|
+
# Parallel by default: almost every test spends its time in ONE process doing
|
|
77
|
+
# physics or building a window, so a serial run leaves most of the machine idle.
|
|
80
78
|
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
#
|
|
79
|
+
# -n auto does NOT mean one worker per core here: tests/conftest.py answers it
|
|
80
|
+
# with tests/worker_plan.py, which takes as many workers as the memory
|
|
81
|
+
# available NOW (minus what stays free for the rest of the machine), the idle
|
|
82
|
+
# processors and the amount of selected work allow, using the time and memory
|
|
83
|
+
# per test measured in tests/resource_profile.json. The first output line says
|
|
84
|
+
# what it chose and why; the last one the peak memory the run really took.
|
|
85
|
+
# -n N still forces N; PYTEST_XDIST_AUTO_NUM_WORKERS=N does the same for auto.
|
|
86
|
+
#
|
|
87
|
+
# --dist loadgroup --no-loadscope-reorder: the workers hand the tests out in
|
|
88
|
+
# the order conftest gives them, longest first, so the long tests start at once
|
|
89
|
+
# and the short ones fill in at the end; tests sharing an xdist_group mark (one
|
|
90
|
+
# expensive module fixture) run on one worker instead of each worker redoing it.
|
|
86
91
|
#
|
|
87
92
|
# CI overrides this with -n 0 (see .github/workflows/_Tests.yml): the runners
|
|
88
|
-
# are small
|
|
89
|
-
#
|
|
90
|
-
addopts = "-q --
|
|
93
|
+
# are small. Use -n 0 locally too when debugging, since xdist swallows live
|
|
94
|
+
# output.
|
|
95
|
+
addopts = "-q -n auto --dist loadgroup --no-loadscope-reorder"
|
|
91
96
|
markers = [
|
|
92
97
|
"gui: builds the PySide6 GUI; runs head-less via QT_QPA_PLATFORM=offscreen (set in tests/conftest.py)",
|
|
93
98
|
"slow: slow tests (numba compilation / fitting)",
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"""Calibrate the drive and find the CMS source's G, Δθ and f_LM in ONE fit, of
|
|
2
|
+
two raw spectra measured with one source, geometry and drive: pure alpha-Fe and
|
|
3
|
+
a single line (docs/cosine_smearing.md, §7: parts H3, H4 and J).
|
|
4
|
+
|
|
5
|
+
Δθ moves the alpha-Fe lines out, so an axis is the transducer's only when it is
|
|
6
|
+
calibrated with the right Δθ, and Δθ and G are found on a calibrated axis. Done
|
|
7
|
+
one after the other the two need rounds (part H3). Here they are fitted
|
|
8
|
+
together, on both raw spectra at once: the drive curve, its count distortion,
|
|
9
|
+
G, Δθ, f_LM and both absorbers. The drive's scale then takes the line positions
|
|
10
|
+
and Δθ the widths, as an axis scale does in part H4; the saturated single line
|
|
11
|
+
fixes f_LM, which takes Δθ off the alpha-Fe's saturation (part J).
|
|
12
|
+
|
|
13
|
+
1. Start: Calibration.Calibration on the alpha-Fe with the start G and Δθ
|
|
14
|
+
(the dialog's; START_G, START_DTHETA when the fields hold none). It decides
|
|
15
|
+
the drive's waveform, sine or triangle -- kept from here on -- and gives
|
|
16
|
+
the start of everything else: the drive curve (with the phase of the
|
|
17
|
+
recording), its count distortion, the alpha-Fe's T, texture and count rate.
|
|
18
|
+
2. The single line on its own, on that drive, with G, Δθ and f_LM held: its
|
|
19
|
+
thickness from a coarse scan, then its T, shift and count rate fitted.
|
|
20
|
+
3. Everything together, all free at once: the drive curve (3), its count
|
|
21
|
+
distortion (5, one for both spectra: one source, one geometry), G, Δθ,
|
|
22
|
+
f_LM, and each spectrum's own T and count rate, the alpha-Fe's texture and
|
|
23
|
+
the single line's shift.
|
|
24
|
+
4. Both spectra folded with the drive found (the fold window from it);
|
|
25
|
+
Calibration.dat written from the alpha-Fe as Calibration writes it, and G,
|
|
26
|
+
Δθ, d and D into GCMS.txt.
|
|
27
|
+
|
|
28
|
+
The references: alpha-Fe, a polarized Sextet at the alpha-Fe field with δ 0
|
|
29
|
+
(the axis' zero), the natural width and no Gaussian of its own; a single line,
|
|
30
|
+
a Singlet at the natural width with no Gaussian of its own. Each spectrum's
|
|
31
|
+
non-resonant counts are the source's (as dtheta_alpha_fe_reference has them):
|
|
32
|
+
|
|
33
|
+
Nnr = Ns (1 - f_LM) / f_LM + C_high,
|
|
34
|
+
|
|
35
|
+
C_high the 122/136 keV quanta counted per channel; they follow the source's
|
|
36
|
+
distance, so the count distortion multiplies them too, while the detector's
|
|
37
|
+
static noise is added flat. C_high and the static noise are measured, one pair
|
|
38
|
+
per spectrum (the counting times differ); with both 0, f_LM would take them up.
|
|
39
|
+
The fit takes 1 - cos Δθ, not Δθ: every spectrum is flat in Δθ at 0 (the
|
|
40
|
+
smearing grows as Δθ^2), and a fit that reached it could not come back.
|
|
41
|
+
"""
|
|
42
|
+
import os
|
|
43
|
+
|
|
44
|
+
import numpy as np
|
|
45
|
+
|
|
46
|
+
import syncmoss.minimi_lib as mi
|
|
47
|
+
import syncmoss.models as m5
|
|
48
|
+
from syncmoss.Calibration import (Calibration, MulCoCMS, _fold_sinusoidal, _fold_triangular, _load_raw_counts,
|
|
49
|
+
_raw_drive, _write_calibration_dat)
|
|
50
|
+
from syncmoss.constants import ALPHA_FE_FIELD, NAT_WIDTH, number_of_baseline_parameters as NB
|
|
51
|
+
from syncmoss.instrumental_io import compute_norm, drive_rest_velocity, r_ratio_of, write_gcms_file
|
|
52
|
+
from syncmoss.spectrum_io import estimate_edge_background, load_spectrum
|
|
53
|
+
|
|
54
|
+
# Where G and Δθ start when their fields hold no usable value (not a number, 0
|
|
55
|
+
# or less, Δθ from π/2): a usual source and geometry
|
|
56
|
+
START_G = 0.09 # mm/s
|
|
57
|
+
START_DTHETA = 0.1 # rad
|
|
58
|
+
|
|
59
|
+
# The raw formats Calibration reads (Calibration._load_raw_counts)
|
|
60
|
+
RAW_SUFFIXES = ('.mca', '.cmca', '.ws5', '.w98', '.moe', '.m1', '.mcs')
|
|
61
|
+
|
|
62
|
+
# The single line's thicknesses tried before its own fit: decades, not steps,
|
|
63
|
+
# since a dip saturates
|
|
64
|
+
THICKNESS_SCAN = (0.3, 1.0, 3.0, 10.0, 30.0)
|
|
65
|
+
|
|
66
|
+
# f_LM is kept off 0 and 1, where Nnr = Ns (1 - f_LM)/f_LM is infinite or 0
|
|
67
|
+
F_LM_MARGIN = 1e-3
|
|
68
|
+
|
|
69
|
+
# The fitted vector: the drive curve (Calibration's sin_cal / lin_cal
|
|
70
|
+
# parameters); the count distortion, the counts times
|
|
71
|
+
# 1 + a1 (ch - c1)^2 + o1 in the first half-sweep, 1 + a2 (ch - c2)^2 in the second
|
|
72
|
+
# (a1, c1, o1, a2, c2), the solid angle changing with the source's position;
|
|
73
|
+
# G, 1 - cos Δθ and f_LM; alpha-Fe's T, texture A and count rate Ns; the single
|
|
74
|
+
# line's T, shift and Ns
|
|
75
|
+
DRIVE = slice(0, 3)
|
|
76
|
+
DISTORTION = slice(3, 8)
|
|
77
|
+
G_I, U_I, F_I = 8, 9, 10
|
|
78
|
+
ALPHA_T, ALPHA_A, ALPHA_NS = 11, 12, 13
|
|
79
|
+
LINE_T, LINE_SHIFT, LINE_NS = 14, 15, 16
|
|
80
|
+
N_FIT = 17
|
|
81
|
+
LINE_ONLY = [LINE_T, LINE_SHIFT, LINE_NS]
|
|
82
|
+
|
|
83
|
+
# The joint model: alpha-Fe's baseline and Sextet, then the single line's
|
|
84
|
+
# baseline (Nbaseline) and Singlet
|
|
85
|
+
MODEL = ['Sextet', 'Nbaseline', 'Singlet']
|
|
86
|
+
LINE_START = NB + 14
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def start_values(G, dtheta):
|
|
90
|
+
"""G and Δθ as the procedure starts from them: the fields' values, or
|
|
91
|
+
START_G / START_DTHETA for one that is not usable."""
|
|
92
|
+
try:
|
|
93
|
+
G = float(G)
|
|
94
|
+
except (TypeError, ValueError):
|
|
95
|
+
G = START_G
|
|
96
|
+
try:
|
|
97
|
+
dtheta = float(dtheta)
|
|
98
|
+
except (TypeError, ValueError):
|
|
99
|
+
dtheta = START_DTHETA
|
|
100
|
+
if not 0 < G < 1:
|
|
101
|
+
G = START_G
|
|
102
|
+
if not 0 < dtheta < np.pi / 2:
|
|
103
|
+
dtheta = START_DTHETA
|
|
104
|
+
return G, dtheta
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def refusal(files):
|
|
108
|
+
"""Why the procedure cannot start on *files* (alpha-Fe first, then the
|
|
109
|
+
single line), or None."""
|
|
110
|
+
if len(files) < 2:
|
|
111
|
+
return "needs two raw spectra in the path box: alpha-Fe first, then the single line"
|
|
112
|
+
for f in files[:2]:
|
|
113
|
+
if not os.path.exists(f):
|
|
114
|
+
return f"{os.path.basename(f)} does not exist"
|
|
115
|
+
if not f.lower().endswith(RAW_SUFFIXES):
|
|
116
|
+
return f"{os.path.basename(f)} is not a raw spectrum ({', '.join(RAW_SUFFIXES)})"
|
|
117
|
+
channels = [len(_load_raw_counts(f)) for f in files[:2]]
|
|
118
|
+
if channels[0] != channels[1]:
|
|
119
|
+
return (f"the two spectra have {channels[0]} and {channels[1]} channels: "
|
|
120
|
+
"they must come from the same drive")
|
|
121
|
+
return None
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def source_refusal(source):
|
|
125
|
+
"""Why the source's numbers cannot be used, or None: f_LM in (0, 1), C_high
|
|
126
|
+
and the static noise not negative, one of each per spectrum."""
|
|
127
|
+
if not 0 < source['f_LM'] < 1:
|
|
128
|
+
return "f_LM must be between 0 and 1"
|
|
129
|
+
if len(source['C_high']) != 2 or len(source['C_static']) != 2:
|
|
130
|
+
return "C_high and the static noise are needed for both spectra"
|
|
131
|
+
if min(source['C_high']) < 0 or min(source['C_static']) < 0:
|
|
132
|
+
return "C_high and the static noise must not be negative"
|
|
133
|
+
return None
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def counts(x, p, model, lengths, G, dtheta, r_ratio, JN, pool, channel_average=False):
|
|
137
|
+
"""The counts of *model* (parameters p) at the velocities x, with the CMS
|
|
138
|
+
source of Gaussian width G and smearing Δθ: the smearing and its Norm
|
|
139
|
+
prepared for these velocities, each spectrum from where its drive is at
|
|
140
|
+
rest, as every CMS search prepares them (instrumental_io.instrumental);
|
|
141
|
+
with *channel_average*, every point averaged over its channel (the widths
|
|
142
|
+
of the drive of each spectrum's raw channels, Calibration._raw_drive)."""
|
|
143
|
+
x = np.asarray(x, dtype=float)
|
|
144
|
+
pieces = [x] if lengths is None else np.split(x, np.cumsum(lengths)[:-1])
|
|
145
|
+
v_center = [drive_rest_velocity(piece) for piece in pieces]
|
|
146
|
+
widths = (np.concatenate([m5.channel_widths(piece, _raw_drive(piece)) for piece in pieces])
|
|
147
|
+
if channel_average else None)
|
|
148
|
+
smearing = m5.source_smearing(x, JN, MulCoCMS, G, 1, dtheta, v_center if lengths else v_center[0], r_ratio,
|
|
149
|
+
lengths, widths)
|
|
150
|
+
source = {'x0': 0, 'MulCo': MulCoCMS, 'INS': G, 'Met': 1}
|
|
151
|
+
if lengths is None:
|
|
152
|
+
norm = compute_norm(pool, JN, source, x, smearing)
|
|
153
|
+
else:
|
|
154
|
+
norm = [compute_norm(pool, JN, source, piece, s)
|
|
155
|
+
for piece, s in zip(pieces, smearing or [None] * len(pieces))]
|
|
156
|
+
return np.asarray(m5.TI(x, np.asarray(p, dtype=float), model, JN, pool, 0, MulCoCMS, G, [0], [0], Met=1,
|
|
157
|
+
Norm=norm, lengths=lengths, smearing=smearing), dtype=float)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def distortion(n_ch, d):
|
|
161
|
+
"""The count distortion's factor at every channel (see DISTORTION)."""
|
|
162
|
+
ch = np.arange(n_ch, dtype=float)
|
|
163
|
+
first = ch < n_ch // 2
|
|
164
|
+
return np.where(first, 1 + d[0] * (ch - d[1]) ** 2 + d[2], 1 + d[3] * (ch - d[4]) ** 2)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _baseline(ns, f_lm, c_high):
|
|
168
|
+
"""A spectrum's baseline: Ns, and Nnr the source's (see the module docstring)."""
|
|
169
|
+
return [ns, 0, 0, 0, ns * (1 - f_lm) / f_lm + c_high, 0, 0, 0]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def alpha_fe_parameters(q, c_high):
|
|
173
|
+
"""alpha-Fe's baseline and polarized Sextet (T, δ 0, ε 0, the alpha-Fe
|
|
174
|
+
field, the natural width, no Gaussian, θk 90, φh 0, texture A, ..., I1/I3 3)."""
|
|
175
|
+
return (_baseline(q[ALPHA_NS], q[F_I], c_high)
|
|
176
|
+
+ [q[ALPHA_T], 0, 0, ALPHA_FE_FIELD, NAT_WIDTH, 0, 90, 0, q[ALPHA_A], 0, 0, 0, 0, 3])
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def single_line_parameters(q, c_high):
|
|
180
|
+
"""The single line's baseline and Singlet (T, shift, the natural width, no
|
|
181
|
+
Gaussian)."""
|
|
182
|
+
return _baseline(q[LINE_NS], q[F_I], c_high) + [q[LINE_T], q[LINE_SHIFT], NAT_WIDTH, 0]
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def raw_counts(q, velocity, n_ch, source, r_ratio, JN, pool, line_only=False, channel_average=False):
|
|
186
|
+
"""Both raw spectra (alpha-Fe's channels, then the single line's) for the
|
|
187
|
+
fitted vector q, or the single line's alone: the absorbers on the drive's
|
|
188
|
+
velocities, times the count distortion, plus each spectrum's static
|
|
189
|
+
noise; with *channel_average*, every channel averaged over its
|
|
190
|
+
velocities."""
|
|
191
|
+
c_high, c_static = source['C_high'], source['C_static']
|
|
192
|
+
v = velocity(np.arange(n_ch, dtype=float), q[DRIVE])
|
|
193
|
+
w = distortion(n_ch, q[DISTORTION])
|
|
194
|
+
G, dtheta = q[G_I], float(np.arccos(1 - q[U_I]))
|
|
195
|
+
if line_only:
|
|
196
|
+
return (counts(v, single_line_parameters(q, c_high[1]), ['Singlet'], None, G, dtheta, r_ratio, JN, pool,
|
|
197
|
+
channel_average) * w
|
|
198
|
+
+ c_static[1])
|
|
199
|
+
joint = counts(np.concatenate((v, v)), alpha_fe_parameters(q, c_high[0]) + single_line_parameters(q, c_high[1]),
|
|
200
|
+
MODEL, [n_ch, n_ch], G, dtheta, r_ratio, JN, pool, channel_average)
|
|
201
|
+
return joint * np.concatenate((w, w)) + np.repeat(np.asarray(c_static, dtype=float), n_ch)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _resonant_start(level, f_lm, c_high, c_static, name):
|
|
205
|
+
"""Ns to start from: the counts off resonance less C_high and the static
|
|
206
|
+
noise, times f_LM (as dtheta_alpha_fe_reference starts)."""
|
|
207
|
+
ns = (level - c_high - c_static) * f_lm
|
|
208
|
+
if ns <= 0:
|
|
209
|
+
raise ValueError(f"{name}: C_high + static noise is not below its counts off resonance ({level:g})")
|
|
210
|
+
return ns
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def start_vector(details, line_counts, line_folded, source, G, dtheta, r_ratio, JN, pool, channel_average=False):
|
|
214
|
+
"""The fitted vector to start from: the drive, its distortion and alpha-Fe
|
|
215
|
+
from the start calibration (*details*, Calibration's), the single line
|
|
216
|
+
fitted on its own on that drive (G, Δθ and f_LM held)."""
|
|
217
|
+
pS, n_ch, f_lm = details['pS'], len(line_counts), source['f_LM']
|
|
218
|
+
(ca, cl), (sa, sl) = source['C_high'], source['C_static']
|
|
219
|
+
level = pS[11] + pS[12] # alpha-Fe's counts off resonance
|
|
220
|
+
q = np.zeros(N_FIT)
|
|
221
|
+
q[DRIVE] = pS[0:3]
|
|
222
|
+
# Calibration's distortion is added counts, p5 (c1 - ch)^2 + p6 and p8 (c2 - ch)^2
|
|
223
|
+
q[DISTORTION] = [pS[5] / level, pS[4], pS[6] / level, pS[8] / level, pS[7]]
|
|
224
|
+
q[G_I], q[U_I], q[F_I] = G, 1 - np.cos(dtheta), f_lm
|
|
225
|
+
q[[ALPHA_T, ALPHA_A]] = [pS[9], pS[10]]
|
|
226
|
+
q[ALPHA_NS] = _resonant_start(level, f_lm, ca, sa, "alpha-Fe")
|
|
227
|
+
# the single line: the edges' counts, the shift where its folded dip is
|
|
228
|
+
# deepest (a 5-point average), the best thickness of THICKNESS_SCAN
|
|
229
|
+
q[LINE_NS] = _resonant_start(estimate_edge_background(line_counts), f_lm, cl, sl, "single line")
|
|
230
|
+
x_f, B_f = line_folded
|
|
231
|
+
smooth = np.convolve(B_f, np.ones(5) / 5, mode='same')
|
|
232
|
+
q[LINE_SHIFT] = float(x_f[2:-2][np.argmin(smooth[2:-2])])
|
|
233
|
+
|
|
234
|
+
def line_alone(trial):
|
|
235
|
+
return raw_counts(trial, details['velocity'], n_ch, source, r_ratio, JN, pool, line_only=True,
|
|
236
|
+
channel_average=channel_average)
|
|
237
|
+
|
|
238
|
+
def deviance_at(t):
|
|
239
|
+
# the Poisson deviance: what the fits here minimise (weights='P')
|
|
240
|
+
trial = np.copy(q)
|
|
241
|
+
trial[LINE_T] = t
|
|
242
|
+
return float(mi.poisson_deviance(line_counts, line_alone(trial)))
|
|
243
|
+
q[LINE_T] = min(THICKNESS_SCAN, key=deviance_at)
|
|
244
|
+
fix = np.setdiff1d(np.arange(N_FIT), LINE_ONLY)
|
|
245
|
+
q = mi.minimi_hi(lambda _x, trial: line_alone(trial), np.arange(n_ch), line_counts, q, fix=fix,
|
|
246
|
+
bounds=_bounds(x_f), MI=20, MI2=10, tau0=1e-4, eps=1e-6, weights='P')[0]
|
|
247
|
+
return np.array(q, dtype=float)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _bounds(line_axis):
|
|
251
|
+
bounds = np.array([[-np.inf] * N_FIT, [np.inf] * N_FIT], dtype=float)
|
|
252
|
+
bounds[0][G_I], bounds[1][G_I] = 0.001, 1.0
|
|
253
|
+
bounds[0][U_I], bounds[1][U_I] = 0.0, 1.0
|
|
254
|
+
bounds[0][F_I], bounds[1][F_I] = F_LM_MARGIN, 1 - F_LM_MARGIN
|
|
255
|
+
for i in (ALPHA_T, LINE_T):
|
|
256
|
+
bounds[0][i] = 0.001
|
|
257
|
+
for i in (ALPHA_NS, LINE_NS):
|
|
258
|
+
bounds[0][i] = 0.0
|
|
259
|
+
bounds[0][LINE_SHIFT], bounds[1][LINE_SHIFT] = float(np.min(line_axis)), float(np.max(line_axis))
|
|
260
|
+
return bounds
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def fit_together(q, data, velocity, n_ch, line_axis, source, r_ratio, JN, pool, chi2_correction=True,
|
|
264
|
+
channel_average=False):
|
|
265
|
+
"""Everything fitted together on both raw spectra (*data*: alpha-Fe's
|
|
266
|
+
counts, then the single line's), by the Poisson likelihood; the errors
|
|
267
|
+
carry sqrt(chi2) unless *chi2_correction* is False. Returns (q, errors,
|
|
268
|
+
deviance, chi2): the reduced deviance it minimised and Pearson's chi2."""
|
|
269
|
+
def f(_x, trial):
|
|
270
|
+
return raw_counts(trial, velocity, n_ch, source, r_ratio, JN, pool, channel_average=channel_average)
|
|
271
|
+
x, bounds = np.arange(2 * n_ch), _bounds(line_axis)
|
|
272
|
+
q, errors, deviance, chi2 = np.array(q, dtype=float), None, np.inf, np.nan
|
|
273
|
+
# until a pass no longer lowers the deviance, as the instrumental-function searches refine
|
|
274
|
+
for _ in range(3):
|
|
275
|
+
p, er, d, _cov, c2 = mi.minimi_hi(f, x, data, q, bounds=bounds, MI=20, MI2=20, tau0=1e-4, eps=1e-6,
|
|
276
|
+
weights='P', chi2_correction=chi2_correction)
|
|
277
|
+
if errors is not None and not d < deviance:
|
|
278
|
+
break
|
|
279
|
+
q, errors, deviance, chi2 = np.array(p, dtype=float), np.array(er, dtype=float), float(d), float(c2)
|
|
280
|
+
return q, errors, deviance, chi2
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def _fold(method, v_axis, raw, fit, drive):
|
|
284
|
+
"""A raw spectrum and its fit folded as Calibration folds them."""
|
|
285
|
+
if method == 0:
|
|
286
|
+
return _fold_sinusoidal(v_axis, raw, fit, drive[2])
|
|
287
|
+
return _fold_triangular(v_axis, raw, fit, drive)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def calibrate_source(params_dir, files, pool, JN, vel_start, G, dtheta, diameters, source, report=None,
|
|
291
|
+
cancelled=None, chi2_correction=True, channel_average=False):
|
|
292
|
+
"""Calibrate the drive on the alpha-Fe and find G, Δθ and f_LM, in one fit
|
|
293
|
+
with the single line (see the module docstring). *files*: the alpha-Fe and
|
|
294
|
+
the single-line raw spectra; *diameters*: the source's and the aperture's
|
|
295
|
+
(d, D), held; *source*: 'f_LM' to start from, and 'C_high' and 'C_static'
|
|
296
|
+
per channel, one for each spectrum (alpha-Fe, single line). Writes
|
|
297
|
+
Calibration.dat and GCMS.txt (G, Δθ, d, D) into *params_dir*.
|
|
298
|
+
|
|
299
|
+
*report*, when given, takes a progress line; *cancelled* (a callable, the
|
|
300
|
+
window's Interrupt) stops it between steps -- TI stops it inside them.
|
|
301
|
+
*chi2_correction*: the errors carry sqrt(chi2) (Supp). *channel_average*:
|
|
302
|
+
every channel averaged over its velocities (Supp), in each step.
|
|
303
|
+
|
|
304
|
+
Returns 'G', 'dtheta' and 'f_LM' with their 'errors', the 'start' G and Δθ,
|
|
305
|
+
the 'drive' found, and the fit folded for the plot: 'A' (the folded axis,
|
|
306
|
+
once per spectrum), 'B', 'F' (the model), 'F2' (the model at 4 JN, the cyan
|
|
307
|
+
line), 'p' (each spectrum's model, its baseline as folded), 'hi2'
|
|
308
|
+
(Pearson's chi2), 'deviance' (the reduced deviance the fit minimised),
|
|
309
|
+
'chi2_spread', 'lengths', 'starts', 'files', 'calibration_path'.
|
|
310
|
+
"""
|
|
311
|
+
def check():
|
|
312
|
+
if cancelled is not None and cancelled():
|
|
313
|
+
raise m5.FitInterrupted()
|
|
314
|
+
|
|
315
|
+
if report is None:
|
|
316
|
+
def report(_line):
|
|
317
|
+
pass
|
|
318
|
+
|
|
319
|
+
refused = refusal(files) or source_refusal(source)
|
|
320
|
+
if refused:
|
|
321
|
+
raise ValueError(refused)
|
|
322
|
+
files = list(files[:2])
|
|
323
|
+
r_ratio = r_ratio_of(*diameters)
|
|
324
|
+
G, dtheta = start = start_values(G, dtheta)
|
|
325
|
+
calibration_path = os.path.join(params_dir, 'Calibration.dat')
|
|
326
|
+
|
|
327
|
+
report(f"Start: calibrating with G {G:.4f} mm/s, Δθ {dtheta:.4f} rad...")
|
|
328
|
+
details = {}
|
|
329
|
+
Calibration(params_dir, files[0], pool, 1, np.array([G]), JN, 0.0, MulCoCMS, Vel_start=vel_start, GCMS=G,
|
|
330
|
+
dtheta=dtheta, r_ratio=r_ratio, details=details, channel_average=channel_average)
|
|
331
|
+
check()
|
|
332
|
+
report("Start: the single line on its own...")
|
|
333
|
+
line_raw = np.asarray(_load_raw_counts(files[1]), dtype=float)
|
|
334
|
+
alpha_raw = np.asarray(details['counts'], dtype=float)
|
|
335
|
+
A_f, B_f = load_spectrum(None, [files[1]], calibration_path=calibration_path)
|
|
336
|
+
q = start_vector(details, line_raw, (A_f[0], B_f[0]), source, G, dtheta, r_ratio, JN, pool, channel_average)
|
|
337
|
+
check()
|
|
338
|
+
report("Calibration, G, Δθ and f_LM together...")
|
|
339
|
+
n_ch, velocity = len(alpha_raw), details['velocity']
|
|
340
|
+
q, errors, deviance, chi2 = fit_together(q, np.concatenate((alpha_raw, line_raw)), velocity, n_ch, A_f[0],
|
|
341
|
+
source, r_ratio, JN, pool, chi2_correction, channel_average)
|
|
342
|
+
check()
|
|
343
|
+
|
|
344
|
+
G, dtheta, f_lm = float(q[G_I]), float(np.arccos(1 - q[U_I])), float(q[F_I])
|
|
345
|
+
# σ(Δθ) from σ(1 - cos Δθ): d(1 - cos Δθ) = sin Δθ dΔθ
|
|
346
|
+
dtheta_error = float(errors[U_I] / np.sin(dtheta)) if dtheta > 0 else float('nan')
|
|
347
|
+
v_axis = velocity(np.arange(n_ch, dtype=float), q[DRIVE])
|
|
348
|
+
|
|
349
|
+
def folded(jn):
|
|
350
|
+
model = raw_counts(q, velocity, n_ch, source, r_ratio, jn, pool, channel_average=channel_average)
|
|
351
|
+
return [_fold(details['method'], v_axis, raw, fit, q[DRIVE])
|
|
352
|
+
for raw, fit in ((alpha_raw, model[:n_ch]), (line_raw, model[n_ch:]))]
|
|
353
|
+
alpha, line = folded(JN)
|
|
354
|
+
v_f, n1, n2 = alpha[0], alpha[4], alpha[5]
|
|
355
|
+
_write_calibration_dat(params_dir, details['method'], n1, n2, v_f, alpha[1])
|
|
356
|
+
write_gcms_file(params_dir, G, dtheta, *diameters)
|
|
357
|
+
fine = folded(4 * JN)
|
|
358
|
+
# each spectrum's model with its baseline as folded (two channels to a
|
|
359
|
+
# point), the static noise in its Nnr: the plot fills down to the baseline
|
|
360
|
+
shown = np.array(alpha_fe_parameters(q, source['C_high'][0]) + single_line_parameters(q, source['C_high'][1]),
|
|
361
|
+
dtype=float)
|
|
362
|
+
for section, static in zip((0, LINE_START), source['C_static']):
|
|
363
|
+
shown[section] *= 2
|
|
364
|
+
shown[section + 4] = 2 * (shown[section + 4] + static)
|
|
365
|
+
return {
|
|
366
|
+
'G': G, 'dtheta': dtheta, 'f_LM': f_lm,
|
|
367
|
+
'errors': (float(errors[G_I]), dtheta_error, float(errors[F_I])), 'start': start,
|
|
368
|
+
'drive': np.array(q[DRIVE]), 'method': details['method'], 'A': np.concatenate((v_f, line[0])),
|
|
369
|
+
'B': np.concatenate((alpha[1], line[1])), 'F': np.concatenate((alpha[2], line[2])),
|
|
370
|
+
'F2': np.concatenate((fine[0][2], fine[1][2])), 'p': shown, 'hi2': chi2, 'deviance': deviance,
|
|
371
|
+
'chi2_spread': mi.chi2_spread(2 * n_ch, N_FIT), 'lengths': [len(v_f), len(line[0])],
|
|
372
|
+
'starts': [0, LINE_START], 'files': files, 'calibration_path': calibration_path,
|
|
373
|
+
}
|
|
@@ -459,11 +459,36 @@ def _save_sms_diagnostic_plot(dir_path, channels, counts, final_curve, flat_coun
|
|
|
459
459
|
plt.close()
|
|
460
460
|
|
|
461
461
|
|
|
462
|
+
def _raw_drive(x):
|
|
463
|
+
"""The drive of a raw sweep -- a velocity per channel, in recorded order, as
|
|
464
|
+
sin_cal or lin_cal make them -- as models.channel_widths takes it: a cosine
|
|
465
|
+
of one period over the channels (sin_cal: exact), else two ramps of one
|
|
466
|
+
step (lin_cal: the slope of the first). Fitted with minimi_hi."""
|
|
467
|
+
n = len(x)
|
|
468
|
+
channels = np.arange(n, dtype=float)
|
|
469
|
+
w = 2 * np.pi / n
|
|
470
|
+
|
|
471
|
+
def one_period(k, p): # sin_cal's cosine, phase at the channel's middle
|
|
472
|
+
return p[0] + p[1] * np.cos(w * (k + 0.5)) + p[2] * np.sin(w * (k + 0.5))
|
|
473
|
+
|
|
474
|
+
p = mi.minimi_hi(one_period, channels, x, np.array([0.5 * (np.min(x) + np.max(x)),
|
|
475
|
+
0.5 * (np.max(x) - np.min(x)), 0.0]))[0]
|
|
476
|
+
if np.median(np.abs(x - one_period(channels, p))) <= m5.DRIVE_AXIS_TOLERANCE * np.median(np.abs(np.diff(x))):
|
|
477
|
+
return ('sine', float(p[0]), float(np.hypot(p[1], p[2])), w)
|
|
478
|
+
ramp = np.arange(int(n / 2) + 1, dtype=float) # lin_cal's first ramp
|
|
479
|
+
|
|
480
|
+
def line(k, q):
|
|
481
|
+
return q[0] + q[1] * k
|
|
482
|
+
slope = mi.minimi_hi(line, ramp, x[:ramp.size], np.array([x[0], x[1] - x[0]]))[0][1]
|
|
483
|
+
return ('triangular', float(abs(slope)))
|
|
484
|
+
|
|
485
|
+
|
|
462
486
|
# ========================================================================= #
|
|
463
487
|
# Main entry point #
|
|
464
488
|
# ========================================================================= #
|
|
465
489
|
|
|
466
|
-
def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1, GCMS=0.1
|
|
490
|
+
def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1, GCMS=0.1, dtheta=0.0,
|
|
491
|
+
r_ratio=0.0, details=None, channel_average=False):
|
|
467
492
|
"""Fit the velocity calibration of a standard alpha-Fe absorber spectrum.
|
|
468
493
|
|
|
469
494
|
Loads the calibration spectrum ``Cal_file``, auto-detects everything about
|
|
@@ -489,6 +514,22 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
489
514
|
Vel_start: Sweep orientation: ``1`` velocity starts at its maximum
|
|
490
515
|
(down-up), ``0`` at its minimum (up-down).
|
|
491
516
|
GCMS: Gaussian instrumental linewidth for CMS (the GUI GCMS box).
|
|
517
|
+
dtheta: cosine smearing for CMS in rad (the GUI Δθ box,
|
|
518
|
+
models.source_smearing's ``dtheta``); 0 = none. With it the model's
|
|
519
|
+
lines sit out by ~<1/cos theta> and broaden, so the calibration
|
|
520
|
+
gives the transducer velocity -- the axis the fits with the same
|
|
521
|
+
dtheta take.
|
|
522
|
+
r_ratio: d/D of the CMS source and aperture diameters (the Supp
|
|
523
|
+
setting, models.source_smearing's ``r_ratio``), above 0 when dtheta is.
|
|
524
|
+
details: a dict to receive what the fit found, for a procedure that
|
|
525
|
+
starts from it (CMS_source_geometry_calibration): 'method' (0 sinusoidal, 1
|
|
526
|
+
triangular), 'velocity' (channel -> velocity, ``velocity(x, drive)``),
|
|
527
|
+
'pS' (the final-fit vector, layout above), 'model' (the absorber's
|
|
528
|
+
parameters, pCAL) and 'counts' (the raw counts). None: nothing.
|
|
529
|
+
channel_average: every channel the model averaged over the
|
|
530
|
+
velocities the drive runs through in it (the Supp setting,
|
|
531
|
+
models "Channel average"), the widths from the drive curve being
|
|
532
|
+
fitted (_raw_drive).
|
|
492
533
|
|
|
493
534
|
Returns:
|
|
494
535
|
tuple ``(v_folded, data_folded, fit_folded)`` -- the folded velocity
|
|
@@ -522,8 +563,19 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
522
563
|
MulCoCMS, INS, [0], [0], Met=1)[0]
|
|
523
564
|
|
|
524
565
|
def fit_func(x, p):
|
|
566
|
+
# x is always the whole drive axis: its middle is the drive at rest,
|
|
567
|
+
# where the cosine smearing starts, and its channels' widths those
|
|
568
|
+
# of the channel average. The axis is what the calibration fits, so
|
|
569
|
+
# the smearing -- and with it the smeared source's own Norm, an
|
|
570
|
+
# array over x (the same empty-model sum as Norm above) -- is
|
|
571
|
+
# prepared for every call.
|
|
572
|
+
smearing = m5.source_smearing(x, JN, MulCoCMS, INS, 1, dtheta, 0.5 * (np.min(x) + np.max(x)), r_ratio,
|
|
573
|
+
channel_widths=m5.channel_widths(x, _raw_drive(x)) if channel_average
|
|
574
|
+
else None)
|
|
575
|
+
norm = Norm if smearing is None else np.asarray(
|
|
576
|
+
m5.TI(x, pNorm, [], JN, pool, 0.0, MulCoCMS, INS, [0], [0], Met=1, smearing=smearing), dtype=float)
|
|
525
577
|
return m5.TI(x, p, model, JN, pool, 0.0, MulCoCMS, INS, [], [],
|
|
526
|
-
Met=1, Norm=
|
|
578
|
+
Met=1, Norm=norm, smearing=smearing)
|
|
527
579
|
|
|
528
580
|
INS_shift = 0
|
|
529
581
|
elif VVV == 3:
|
|
@@ -531,7 +583,14 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
531
583
|
MulCo, INS, [0], [0])[0]
|
|
532
584
|
|
|
533
585
|
def fit_func(x, p):
|
|
534
|
-
|
|
586
|
+
if not channel_average:
|
|
587
|
+
return m5.TI(x, p, model, JN, pool, x0, MulCo, INS, [], [], Norm=Norm)
|
|
588
|
+
# the channel average of the axis being fitted, and the averaged
|
|
589
|
+
# source's own Norm, one per channel, prepared for every call
|
|
590
|
+
smearing = m5.source_smearing(x, JN, MulCo, INS, 0, 0.0, 0.0, 0.0,
|
|
591
|
+
channel_widths=m5.channel_widths(x, _raw_drive(x)), x0=x0)
|
|
592
|
+
norm = np.asarray(m5.TI(x, pNorm, [], JN, pool, x0, MulCo, INS, [0], [0], smearing=smearing), dtype=float)
|
|
593
|
+
return m5.TI(x, p, model, JN, pool, x0, MulCo, INS, [], [], Norm=norm, smearing=smearing)
|
|
535
594
|
|
|
536
595
|
# The multi-line instrumental function displaces the apparent line
|
|
537
596
|
# positions by its first moment (for the legacy sum of unit-area
|
|
@@ -687,8 +746,9 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
687
746
|
* np.cos(np.pi / n_ch * (2 * ch_min1 + 1)
|
|
688
747
|
+ (np.pi / n_ch * phase0)))
|
|
689
748
|
x_try = sin_cal(channels, [Vel_max_m, (np.pi / n_ch * phase0), shift_m])
|
|
749
|
+
# counts: the Poisson fit, res[2] its reduced deviance
|
|
690
750
|
res = mi.minimi_hi(fit_func, x_try, counts, p00, fix=fix_coarse,
|
|
691
|
-
bounds=bounds, MI=3, MI2=5)
|
|
751
|
+
bounds=bounds, MI=3, MI2=5, weights='P')
|
|
692
752
|
if res[2] <= chi2_sin:
|
|
693
753
|
chi2_sin = res[2]
|
|
694
754
|
Vel_max_sin = Vel_max_m
|
|
@@ -721,7 +781,7 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
721
781
|
Vel_max_m - velocity_step_m * lin_phase,
|
|
722
782
|
velocity_step_m])
|
|
723
783
|
res = mi.minimi_hi(fit_func, x_try, counts, p00, fix=fix_coarse,
|
|
724
|
-
bounds=bounds, MI=3, MI2=5)
|
|
784
|
+
bounds=bounds, MI=3, MI2=5, weights='P')
|
|
725
785
|
if res[2] <= chi2_lin:
|
|
726
786
|
chi2_lin = res[2]
|
|
727
787
|
Vel_max_lin = Vel_max_m
|
|
@@ -756,7 +816,7 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
756
816
|
print(p0)
|
|
757
817
|
start_time = time.time()
|
|
758
818
|
for it in range(0, 4):
|
|
759
|
-
p = mi.minimi_hi(fit_func, x, counts, p0, fix=fix_refine, MI=3, MI2=5)[0]
|
|
819
|
+
p = mi.minimi_hi(fit_func, x, counts, p0, fix=fix_refine, MI=3, MI2=5, weights='P')[0]
|
|
760
820
|
# 12 reference velocities: the 6 lines, seen once per half-sweep.
|
|
761
821
|
# No reversal is needed here even for Vel_start == 1: the velocity
|
|
762
822
|
# direction is already encoded in the calibrated axis `x` (built from
|
|
@@ -901,7 +961,7 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
901
961
|
# STEP 10: final global fit -- drive curve + distortion + intensities. #
|
|
902
962
|
# --------------------------------------------------------------------- #
|
|
903
963
|
start_time = time.time()
|
|
904
|
-
res = mi.minimi_hi(cal_fin2, channels, counts, p0=ps1, MI=20, MI2=20, eps=10 ** -6)
|
|
964
|
+
res = mi.minimi_hi(cal_fin2, channels, counts, p0=ps1, MI=20, MI2=20, eps=10 ** -6, weights='P')
|
|
905
965
|
if abs(res[0][0]) < 2.95:
|
|
906
966
|
print('very small velocity range - texture could not be defined')
|
|
907
967
|
print('model parameters ', pCAL)
|
|
@@ -960,4 +1020,6 @@ def Calibration(dir_path, Cal_file, pool, VVV, INS, JN, x0, MulCo, Vel_start=1,
|
|
|
960
1020
|
|
|
961
1021
|
_write_calibration_dat(dir_path, method, n1, n2, v_folded, data_folded)
|
|
962
1022
|
|
|
1023
|
+
if details is not None:
|
|
1024
|
+
details.update(method=method, velocity=cal, pS=np.copy(pS), model=np.copy(pCAL), counts=np.copy(counts))
|
|
963
1025
|
return (v_folded, data_folded, fit_folded)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#@Comment Describes the dependence of the central shift on temperature: the isomer shift plus the second-order Doppler shift of the Debye model. The integral is substituted with a high-accuracy approximation.
|
|
2
|
+
#@Comment $\delta(T)=-\frac{c}{E_\gamma}\,\frac{3E_\gamma}{2Mc^2}\left[\frac{3}{8}k_B\Theta_D+3k_BT\left(\frac{T}{\Theta_D}\right)^3\int_0^{\Theta_D/T}\frac{x^3}{e^x-1}\,dx\right]+\delta_{IS}$
|
|
3
|
+
#@Comment δ(T) - the central shift, mm/s.
|
|
4
|
+
#@Comment The integral: $\int_0^{y}\frac{x^3}{e^x-1}\,dx\approx\frac{\pi^4}{15}\left(1-e^{-g}\right)$, $g=\frac{y^3(1+0.2903896y)}{\pi^4/5+12.963y+3.895y^2+0.2869y^3}$ with $y=\Theta_D/T$: exact for $T\to0$ and $T\gg\Theta_D$, δ within $10^{-4}$ of its zero-point part ($1.1\cdot10^{-5}$ mm/s at $\Theta_D=400$ K) up to $T=100\,\Theta_D$.
|
|
5
|
+
#@Comment N1 - temperature of the measurement, K: the first number given with each spectrum in the path box.
|
|
6
|
+
#@Comment {T_D} - Debye temperature, K: a parameter, free or fixed (e.g. a value of a Variables row) - substitute its p[i].
|
|
7
|
+
#@Comment {IS} - isomer shift (temperature-independent), mm/s: a parameter or a number.
|
|
8
|
+
baseline Expression
|
|
9
|
+
red red
|
|
10
|
+
10000 1 False 0 True 0 True 0 True 0 True =[1,1] True =[2,1] True =[3,1] True False False False False False False False False False False False False False False False False False False False
|
|
11
|
+
-0.0007306719237962155*(3/8*{T_D} + 3*N1*(N1/{T_D})**3*(pi**4/15)*(1-exp(-({T_D}/N1)**3*(1+0.2903896*{T_D}/N1)/(pi**4/5+12.963*{T_D}/N1+3.895*({T_D}/N1)**2+0.2869*({T_D}/N1)**3)))) + {IS} True False False False False False False False False False False False False False False False False False False False False False False False False False False
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#@Comment Hyperfine field of fast-relaxing superparamagnetic particles in an applied field: it follows their Langevin magnetisation, T.
|
|
2
|
+
#@Comment $H_{hf}=H_0\left(\coth x-\frac{1}{x}\right)$ with $x=\frac{\mu\,\mu_B H_{ext}}{k_BT}$
|
|
3
|
+
#@Comment N1 - temperature of the measurement, K: the first number given with each spectrum in the path box.
|
|
4
|
+
#@Comment {H_0} - saturation hyperfine field, T; {mu} - particle moment, in Bohr magnetons; {H_ext} - applied field, T (e.g. N2 for a field sequence).
|
|
5
|
+
baseline Expression
|
|
6
|
+
red red
|
|
7
|
+
10000 1 False 0 True 0 True 0 True 0 True =[1,1] True =[2,1] True =[3,1] True False False False False False False False False False False False False False False False False False False False
|
|
8
|
+
{H_0}*(lambda x: (x != 0)*(1/tanh(x + (x == 0)) - 1/(x + (x == 0))))(0.6717138156258398*{mu}*{H_ext}/N1) True False False False False False False False False False False False False False False False False False False False False False False False False False False
|