syncmoss 0.5.1__tar.gz → 0.7.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.
Files changed (280) hide show
  1. {syncmoss-0.5.1 → syncmoss-0.7.0}/.gitignore +3 -5
  2. {syncmoss-0.5.1 → syncmoss-0.7.0}/PKG-INFO +1 -1
  3. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/bundle.py +5 -0
  4. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/macos_bundle.py +5 -0
  5. {syncmoss-0.5.1 → syncmoss-0.7.0}/pyproject.toml +17 -12
  6. syncmoss-0.7.0/syncmoss/CMS_source_geometry_calibration.py +373 -0
  7. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Calibration.py +181 -54
  8. syncmoss-0.7.0/syncmoss/Expressions/Central shift vs temperature.mdl +11 -0
  9. syncmoss-0.7.0/syncmoss/Expressions/Hyperfine field in applied field, Langevin.mdl +8 -0
  10. syncmoss-0.7.0/syncmoss/Expressions/Hyperfine field vs temperature, Bloch.mdl +8 -0
  11. syncmoss-0.7.0/syncmoss/Expressions/Hyperfine field vs temperature, critical.mdl +8 -0
  12. syncmoss-0.7.0/syncmoss/Expressions/Hyperfine field vs temperature, empirical.mdl +8 -0
  13. syncmoss-0.7.0/syncmoss/Expressions/Lamb-Mossbauer factor vs temperature.mdl +9 -0
  14. syncmoss-0.7.0/syncmoss/Expressions/Lifetime from line width.mdl +7 -0
  15. syncmoss-0.7.0/syncmoss/Expressions/Neel relaxation time vs temperature.mdl +8 -0
  16. syncmoss-0.7.0/syncmoss/Expressions/Paramagnetic quadrupole shift from Hamiltonian.mdl +7 -0
  17. syncmoss-0.7.0/syncmoss/Expressions/Quadrupole splitting, doublet.mdl +7 -0
  18. syncmoss-0.7.0/syncmoss/Expressions/Quadrupole splitting, sextet.mdl +7 -0
  19. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library_io.py +1 -0
  20. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/constants.py +33 -6
  21. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/error_reporter.py +3 -8
  22. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/exclusion_bar.py +1 -2
  23. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/exclusion_regions.py +10 -2
  24. syncmoss-0.7.0/syncmoss/expression_eval.py +43 -0
  25. syncmoss-0.7.0/syncmoss/expressions_io.py +105 -0
  26. syncmoss-0.7.0/syncmoss/expressions_window.py +294 -0
  27. syncmoss-0.7.0/syncmoss/fit_quality.py +489 -0
  28. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/fitting_io.py +127 -73
  29. syncmoss-0.7.0/syncmoss/instrumental_dialogs.py +232 -0
  30. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/instrumental_io.py +525 -138
  31. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/license_window.py +5 -0
  32. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/main.py +12 -1
  33. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/minimi_lib.py +249 -137
  34. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/model_io.py +96 -16
  35. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/models.py +787 -157
  36. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/models_description_window.py +164 -6
  37. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/models_positions.py +18 -14
  38. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/one_model.py +22 -7
  39. syncmoss-0.7.0/syncmoss/parameters/Calibration.dat +514 -0
  40. syncmoss-0.7.0/syncmoss/parameters/GCMS.txt +1 -0
  41. syncmoss-0.7.0/syncmoss/parameters/INSexp.txt +1 -0
  42. syncmoss-0.7.0/syncmoss/parameters/INSint.txt +1 -0
  43. syncmoss-0.7.0/syncmoss/parameters/Standard_CMS.dat +514 -0
  44. syncmoss-0.7.0/syncmoss/parameters/Standard_SMS.dat +514 -0
  45. syncmoss-0.7.0/syncmoss/parameters/calibr.png +0 -0
  46. syncmoss-0.7.0/syncmoss/parameters/help.md +215 -0
  47. syncmoss-0.7.0/syncmoss/parameters/help_extended.md +1078 -0
  48. syncmoss-0.7.0/syncmoss/parameters/models_description.md +310 -0
  49. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/parameters_table.py +216 -116
  50. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/result_window.py +13 -2
  51. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/results_table.py +142 -22
  52. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/sms_theory.py +15 -7
  53. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/spectrum_io.py +57 -23
  54. syncmoss-0.7.0/syncmoss/spectrum_model.py +56 -0
  55. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/spectrum_plotter.py +68 -49
  56. syncmoss-0.7.0/syncmoss/spectrum_reference.py +562 -0
  57. syncmoss-0.7.0/syncmoss/spectrum_reference_window.py +318 -0
  58. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/supp_menu.py +243 -99
  59. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/syncmoss_main.py +659 -155
  60. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss.egg-info/PKG-INFO +1 -1
  61. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss.egg-info/SOURCES.txt +39 -0
  62. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss.egg-info/scm_file_list.json +40 -1
  63. syncmoss-0.7.0/tests/README.md +118 -0
  64. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/conftest.py +183 -27
  65. syncmoss-0.7.0/tests/profile_resources.py +258 -0
  66. syncmoss-0.7.0/tests/resource_profile.json +5785 -0
  67. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/syncmoss_test.py +110 -31
  68. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_baseline_polynomial.py +3 -10
  69. syncmoss-0.7.0/tests/test_calculation_time.py +30 -0
  70. syncmoss-0.7.0/tests/test_calibrate_menu.py +75 -0
  71. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_calibration.py +64 -10
  72. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_calibration_helpers.py +57 -2
  73. syncmoss-0.7.0/tests/test_channel_average.py +499 -0
  74. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_chi2_spread.py +19 -6
  75. syncmoss-0.7.0/tests/test_cms_source_geometry_calibration.py +138 -0
  76. syncmoss-0.7.0/tests/test_cosine_smearing.py +1081 -0
  77. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_create_spectrum_from_model.py +4 -1
  78. syncmoss-0.7.0/tests/test_default_settings.py +128 -0
  79. syncmoss-0.7.0/tests/test_distr_composition.py +92 -0
  80. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_distr_expansion.py +25 -3
  81. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_distr_mdl.py +5 -10
  82. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_distr_targets.py +83 -0
  83. syncmoss-0.7.0/tests/test_distr_text_references.py +308 -0
  84. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_exclusion_fit.py +29 -27
  85. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_exclusion_gui.py +37 -12
  86. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_expression_fit_start.py +6 -32
  87. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_expression_validation.py +43 -0
  88. syncmoss-0.7.0/tests/test_expressions.py +429 -0
  89. syncmoss-0.7.0/tests/test_find_bar.py +135 -0
  90. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_fit_core.py +9 -15
  91. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_fit_one_spectrum.py +4 -9
  92. syncmoss-0.7.0/tests/test_fit_quality.py +331 -0
  93. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_gui_smoke.py +38 -59
  94. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_instrumental_joint.py +7 -13
  95. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_instrumental_metadata.py +11 -14
  96. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_instrumental_method_choice.py +20 -8
  97. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_instrumental_recentre.py +42 -2
  98. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_interrupt.py +4 -7
  99. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_library_dir.py +13 -2
  100. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_link_chains.py +2 -2
  101. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_minimi_bounds.py +3 -3
  102. syncmoss-0.7.0/tests/test_minimi_covariance.py +292 -0
  103. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_model_only_mode.py +52 -20
  104. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_model_pointwise.py +2 -9
  105. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_nbaseline_multidistr.py +2 -7
  106. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_one_model_expand.py +20 -3
  107. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_one_model_gui.py +85 -19
  108. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_overwrite_dat_instrumental.py +59 -2
  109. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_parameter_links.py +42 -3
  110. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_polarization.py +1 -1
  111. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_recon_composition.py +8 -50
  112. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_recon_variants.py +3 -8
  113. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_replaced_component_skip.py +2 -7
  114. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_result_window.py +30 -3
  115. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_results_table_rows.py +13 -0
  116. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_sdw_grid.py +2 -2
  117. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_search_guards.py +17 -7
  118. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_sms_theory.py +11 -15
  119. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_source_norm.py +11 -18
  120. syncmoss-0.7.0/tests/test_spectrum_model.py +404 -0
  121. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_spectrum_parameters.py +3 -9
  122. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_thick_gui.py +20 -8
  123. syncmoss-0.7.0/tests/worker_plan.py +233 -0
  124. syncmoss-0.5.1/syncmoss/parameters/Calibration.dat +0 -513
  125. syncmoss-0.5.1/syncmoss/parameters/GCMS.txt +0 -1
  126. syncmoss-0.5.1/syncmoss/parameters/INSexp.txt +0 -1
  127. syncmoss-0.5.1/syncmoss/parameters/INSint.txt +0 -1
  128. syncmoss-0.5.1/syncmoss/parameters/calibr.png +0 -0
  129. syncmoss-0.5.1/syncmoss/parameters/help.md +0 -467
  130. syncmoss-0.5.1/syncmoss/parameters/models_description.md +0 -466
  131. syncmoss-0.5.1/tests/test_distr_composition.py +0 -163
  132. {syncmoss-0.5.1 → syncmoss-0.7.0}/.gitattributes +0 -0
  133. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/Tests.yml +0 -0
  134. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_MacOS.yml +0 -0
  135. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_PyPI.yml +0 -0
  136. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_TagRelease.yml +0 -0
  137. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_Tests.yml +0 -0
  138. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_UploadRelease.yml +0 -0
  139. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_Version.yml +0 -0
  140. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_Wheels.yml +0 -0
  141. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/_WindowsExe.yml +0 -0
  142. {syncmoss-0.5.1 → syncmoss-0.7.0}/.github/workflows/release.yml +0 -0
  143. {syncmoss-0.5.1 → syncmoss-0.7.0}/.vscode/settings.json +0 -0
  144. {syncmoss-0.5.1 → syncmoss-0.7.0}/COPYING.txt +0 -0
  145. {syncmoss-0.5.1 → syncmoss-0.7.0}/LICENSE +0 -0
  146. {syncmoss-0.5.1 → syncmoss-0.7.0}/Lib_test/test.mdl +0 -0
  147. {syncmoss-0.5.1 → syncmoss-0.7.0}/NOTICE.txt +0 -0
  148. {syncmoss-0.5.1 → syncmoss-0.7.0}/README.md +0 -0
  149. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/MacOS.spec +0 -0
  150. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/SYNCmoss.png +0 -0
  151. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/Windows.spec +0 -0
  152. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/dmg_background.pdf +0 -0
  153. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/licenses/GPL-3.0.txt +0 -0
  154. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/licenses/LGPL-3.0.txt +0 -0
  155. {syncmoss-0.5.1 → syncmoss-0.7.0}/bundle/third_party_licenses.py +0 -0
  156. {syncmoss-0.5.1 → syncmoss-0.7.0}/docs/thick_models.md +0 -0
  157. {syncmoss-0.5.1 → syncmoss-0.7.0}/docs/thick_vs_thin.md +0 -0
  158. {syncmoss-0.5.1 → syncmoss-0.7.0}/requirements.txt +0 -0
  159. {syncmoss-0.5.1 → syncmoss-0.7.0}/setup.cfg +0 -0
  160. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Hamiltonian_helper.py +0 -0
  161. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Aegirine.mdl +0 -0
  162. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Akaganeite.mdl +0 -0
  163. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Almandine.mdl +0 -0
  164. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Antitaenite.mdl +0 -0
  165. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Arsenopyrite.mdl +0 -0
  166. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Bornite.mdl +0 -0
  167. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Bridgmanite (Fe,Al-bearing) @100 GPa.mdl +0 -0
  168. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Bridgmanite (Fe,Al-bearing).mdl +0 -0
  169. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Celadonite.mdl +0 -0
  170. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Cementite.mdl +0 -0
  171. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Chalcopyrite.mdl +0 -0
  172. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Clinopyroxene (augite).mdl +0 -0
  173. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Copiapite.mdl +0 -0
  174. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Cubanite.mdl +0 -0
  175. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Epidote.mdl +0 -0
  176. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Fayalite (Fe-olivine).mdl +0 -0
  177. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Ferrihydrite (2-line).mdl +0 -0
  178. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Ferropericlase.mdl +0 -0
  179. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Goethite.mdl +0 -0
  180. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Green rust (fougerite, carbonate).mdl +0 -0
  181. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Haegg carbide.mdl +0 -0
  182. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Hedenbergite.mdl +0 -0
  183. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Hematite.mdl +0 -0
  184. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Heterosite (FePO4).mdl +0 -0
  185. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Ilmenite.mdl +0 -0
  186. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Iron phosphide.mdl +0 -0
  187. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Isocubanite.mdl +0 -0
  188. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Jarosite.mdl +0 -0
  189. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Kamacite.mdl +0 -0
  190. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Lepidocrocite.mdl +0 -0
  191. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Maghemite.mdl +0 -0
  192. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Magnetite.mdl +0 -0
  193. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Marcasite.mdl +0 -0
  194. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Melanterite.mdl +0 -0
  195. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Orthopyroxene (enstatite-ferrosilite).mdl +0 -0
  196. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Prussian blue (ferric ferrocyanide).mdl +0 -0
  197. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Pyrite.mdl +0 -0
  198. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Pyrrhotite.mdl +0 -0
  199. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Rhomboclase.mdl +0 -0
  200. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Roemerite.mdl +0 -0
  201. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Siderite.mdl +0 -0
  202. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Szomolnokite.mdl +0 -0
  203. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Taenite.mdl +0 -0
  204. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Talnakhite.mdl +0 -0
  205. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Tetrataenite.mdl +0 -0
  206. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Triphylite (LiFePO4).mdl +0 -0
  207. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Troilite.mdl +0 -0
  208. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Vivianite.mdl +0 -0
  209. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/Voltaite.mdl +0 -0
  210. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library/alpha-Fe (metallic iron, bcc).mdl +0 -0
  211. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/Library_window.py +0 -0
  212. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/bliss_channel.py +0 -0
  213. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/CheckBox.png +0 -0
  214. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/CheckBox_.png +0 -0
  215. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/CheckBox_L.png +0 -0
  216. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/CheckBox_L2.png +0 -0
  217. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/DU.png +0 -0
  218. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/Switch.png +0 -0
  219. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/UD.png +0 -0
  220. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/icons/icon_r.ico +0 -0
  221. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/instrumental_window.py +0 -0
  222. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/legacy.py +0 -0
  223. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/one_spectrum.py +0 -0
  224. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/parameters/ABSorber3.txt +0 -0
  225. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/parameters/Be.txt +0 -0
  226. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/parameters/INS_APS.txt +0 -0
  227. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/parameters/INSth.txt +0 -0
  228. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/parameters/KB.txt +0 -0
  229. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/parameters/NFS.txt +0 -0
  230. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/spectrum_parameters.py +0 -0
  231. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/support_math.py +0 -0
  232. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/test_graf.txt +0 -0
  233. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/test_param.txt +0 -0
  234. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/theme_dark.json +0 -0
  235. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss/theme_light.json +0 -0
  236. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss.egg-info/dependency_links.txt +0 -0
  237. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss.egg-info/entry_points.txt +0 -0
  238. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss.egg-info/requires.txt +0 -0
  239. {syncmoss-0.5.1 → syncmoss-0.7.0}/syncmoss.egg-info/top_level.txt +0 -0
  240. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/Distr_corr.mdl +0 -0
  241. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/Distr_distr.mdl +0 -0
  242. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/alpha_fe_sms_000.mca +0 -0
  243. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/calibration_000_golden.json +0 -0
  244. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/generate_cal_fixtures.py +0 -0
  245. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/parameters/Calibration.dat +0 -0
  246. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/parameters/GCMS.txt +0 -0
  247. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/parameters/INSexp.txt +0 -0
  248. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/parameters/INSint.txt +0 -0
  249. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/parameters/INSth.txt +0 -0
  250. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/synthetic_alpha_fe_cms_linear.mca +0 -0
  251. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/data/synthetic_alpha_fe_cms_sinus.mca +0 -0
  252. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/golden_models.json +0 -0
  253. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_bliss_channel.py +0 -0
  254. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_calibration_path.py +0 -0
  255. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_contact_author.py +0 -0
  256. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_error_reporter.py +0 -0
  257. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_exclusion_regions.py +0 -0
  258. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_golden_models.py +0 -0
  259. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_hamiltonian_texture.py +0 -0
  260. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_impurity_presets.py +0 -0
  261. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_instrumental_window.py +0 -0
  262. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_integral_points.py +0 -0
  263. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_legacy.py +0 -0
  264. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_library_io.py +0 -0
  265. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_license_window.py +0 -0
  266. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_minimi_batch_eval.py +0 -0
  267. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_model_append.py +0 -0
  268. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_model_io.py +0 -0
  269. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_nbaseline_results.py +0 -0
  270. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_node_sum_reuse.py +0 -0
  271. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_recon_mdl.py +0 -0
  272. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_recon_results.py +0 -0
  273. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_reference_shift.py +0 -0
  274. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_results_table_image.py +0 -0
  275. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_save_result_model.py +0 -0
  276. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_support_math.py +0 -0
  277. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_table_marks.py +0 -0
  278. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_take_result.py +0 -0
  279. {syncmoss-0.5.1 → syncmoss-0.7.0}/tests/test_texture_s1.py +0 -0
  280. {syncmoss-0.5.1 → syncmoss-0.7.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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syncmoss
3
- Version: 0.5.1
3
+ Version: 0.7.0
4
4
  Summary: SYNCmoss — Mössbauer spectroscopy analysis application
5
5
  Author: Sergey Yaroslavtsev
6
6
  License: MIT
@@ -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
- # -n 6: almost every test here spends its time in ONE process doing physics
77
- # (a fit, a calibration, an instrumental-function search), so a serial run
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
- # A FIXED 6, not "auto". Each worker builds its own QApplication, PhysicsApp
82
- # and numba-compiled model, so the suite is limited by MEMORY, not by cores:
83
- # "auto" resolves to one worker per core (22 here) and dies during start-up
84
- # with an execnet EOFError once the machine runs out. The same ceiling bit the
85
- # 83-spectrum study, where 10 parallel fits OOM'd and 6 did not.
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, where even 6 oversubscribes. Use -n 0 locally too when debugging,
89
- # since xdist swallows live output.
90
- addopts = "-q --basetemp=./.pytest_tmp -n 6"
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
+ }