From 5adb4481372e975bfbf654b4f793fcfddb1c21f9 Mon Sep 17 00:00:00 2001 From: Andrew Sazonov Date: Wed, 26 Jun 2024 15:18:47 +0200 Subject: [PATCH] Bump from 0.9.3 to 0.9.4 (#42) * Fix summary (#34) * Modify summary page * Add measured and processed data for TOF * Move report.cif from Analysis main view to sidebar text mode * Show html-based analysis summary in the Analysis main view * Allow saving analysis summary as html * Update images for GUI tests * Fix signing macos (#35) * Temporarily remove the CI script for snapcraft * Simplify build script to try code signing * MACOS_CERTIFICATE_ENCODED (.p12 content base64 encoded) updated on github * MACOS_CERTIFICATE_PASSWORD (.p12 password) updated on github * Rename fpath to fname * Migrate from altool to notarytool * altool is depricated * Migration instruction https://developer.apple.com/documentation/technotes/tn3147-migrating-to-the-latest-notarization-tool * Fix spctl verbose output option * Try using lando/code-sign-action instead of custom script * Fix file path in the code signing script * Update certificate identity * Debug * Fix identity * more debug * more debug * more debug * more debug * debug: return after verify * debug: return after sign * debug: return before verify * debug 2: return after sign * more debug * Another try with lando/code-sign-action * More debug terminal * more debug * fix * More fixes * More fixes * continue after signing * Remove sleep before staple (moved to notarisation) * clean up * Rename variables and clean up * More clean up * Fix team-id * Restore other steps in the build script * Force to use numpy<2 * Use full os name in uploaded artifacts * Windows signing (#33) * initial test, mostly to get the filenames first * attempt to locate the signed binary * play with filename * try again * another attempt at properly delimit the string * go back to the whole matrix before PR * remove debug printouts * Get path to setup_exe from Config.py --------- Co-authored-by: Andrew Sazonov * Prepare for releasing 0.9.2 * Fix release info * Return snapcraft build script back (#37) * Update release info * Add a point background model to TOF (#41) * Bump from 0.9.2 to 0.9.3 (#38) * Fix summary (#34) * Modify summary page * Add measured and processed data for TOF * Move report.cif from Analysis main view to sidebar text mode * Show html-based analysis summary in the Analysis main view * Allow saving analysis summary as html * Update images for GUI tests * Fix signing macos (#35) * Temporarily remove the CI script for snapcraft * Simplify build script to try code signing * MACOS_CERTIFICATE_ENCODED (.p12 content base64 encoded) updated on github * MACOS_CERTIFICATE_PASSWORD (.p12 password) updated on github * Rename fpath to fname * Migrate from altool to notarytool * altool is depricated * Migration instruction https://developer.apple.com/documentation/technotes/tn3147-migrating-to-the-latest-notarization-tool * Fix spctl verbose output option * Try using lando/code-sign-action instead of custom script * Fix file path in the code signing script * Update certificate identity * Debug * Fix identity * more debug * more debug * more debug * more debug * debug: return after verify * debug: return after sign * debug: return before verify * debug 2: return after sign * more debug * Another try with lando/code-sign-action * More debug terminal * more debug * fix * More fixes * More fixes * continue after signing * Remove sleep before staple (moved to notarisation) * clean up * Rename variables and clean up * More clean up * Fix team-id * Restore other steps in the build script * Force to use numpy<2 * Use full os name in uploaded artifacts * Windows signing (#33) * initial test, mostly to get the filenames first * attempt to locate the signed binary * play with filename * try again * another attempt at properly delimit the string * go back to the whole matrix before PR * remove debug printouts * Get path to setup_exe from Config.py --------- Co-authored-by: Andrew Sazonov * Prepare for releasing 0.9.2 * Fix release info * Return snapcraft build script back (#37) * Update release info --------- Co-authored-by: Piotr Rozyczko * Bump from v0.9.2 to v0.9.3 (#39) * Fix summary (#34) * Modify summary page * Add measured and processed data for TOF * Move report.cif from Analysis main view to sidebar text mode * Show html-based analysis summary in the Analysis main view * Allow saving analysis summary as html * Update images for GUI tests * Fix signing macos (#35) * Temporarily remove the CI script for snapcraft * Simplify build script to try code signing * MACOS_CERTIFICATE_ENCODED (.p12 content base64 encoded) updated on github * MACOS_CERTIFICATE_PASSWORD (.p12 password) updated on github * Rename fpath to fname * Migrate from altool to notarytool * altool is depricated * Migration instruction https://developer.apple.com/documentation/technotes/tn3147-migrating-to-the-latest-notarization-tool * Fix spctl verbose output option * Try using lando/code-sign-action instead of custom script * Fix file path in the code signing script * Update certificate identity * Debug * Fix identity * more debug * more debug * more debug * more debug * debug: return after verify * debug: return after sign * debug: return before verify * debug 2: return after sign * more debug * Another try with lando/code-sign-action * More debug terminal * more debug * fix * More fixes * More fixes * continue after signing * Remove sleep before staple (moved to notarisation) * clean up * Rename variables and clean up * More clean up * Fix team-id * Restore other steps in the build script * Force to use numpy<2 * Use full os name in uploaded artifacts * Windows signing (#33) * initial test, mostly to get the filenames first * attempt to locate the signed binary * play with filename * try again * another attempt at properly delimit the string * go back to the whole matrix before PR * remove debug printouts * Get path to setup_exe from Config.py --------- Co-authored-by: Andrew Sazonov * Prepare for releasing 0.9.2 * Fix release info * Return snapcraft build script back (#37) * Update release info --------- Co-authored-by: Piotr Rozyczko * Bump from v0.9.2 to v0.9.3 (#40) * Fix summary (#34) * Modify summary page * Add measured and processed data for TOF * Move report.cif from Analysis main view to sidebar text mode * Show html-based analysis summary in the Analysis main view * Allow saving analysis summary as html * Update images for GUI tests * Fix signing macos (#35) * Temporarily remove the CI script for snapcraft * Simplify build script to try code signing * MACOS_CERTIFICATE_ENCODED (.p12 content base64 encoded) updated on github * MACOS_CERTIFICATE_PASSWORD (.p12 password) updated on github * Rename fpath to fname * Migrate from altool to notarytool * altool is depricated * Migration instruction https://developer.apple.com/documentation/technotes/tn3147-migrating-to-the-latest-notarization-tool * Fix spctl verbose output option * Try using lando/code-sign-action instead of custom script * Fix file path in the code signing script * Update certificate identity * Debug * Fix identity * more debug * more debug * more debug * more debug * debug: return after verify * debug: return after sign * debug: return before verify * debug 2: return after sign * more debug * Another try with lando/code-sign-action * More debug terminal * more debug * fix * More fixes * More fixes * continue after signing * Remove sleep before staple (moved to notarisation) * clean up * Rename variables and clean up * More clean up * Fix team-id * Restore other steps in the build script * Force to use numpy<2 * Use full os name in uploaded artifacts * Windows signing (#33) * initial test, mostly to get the filenames first * attempt to locate the signed binary * play with filename * try again * another attempt at properly delimit the string * go back to the whole matrix before PR * remove debug printouts * Get path to setup_exe from Config.py --------- Co-authored-by: Andrew Sazonov * Prepare for releasing 0.9.2 * Fix release info * Return snapcraft build script back (#37) * Update release info --------- Co-authored-by: Piotr Rozyczko * Initial implementation of point background for TOF * Clean up debugging * Force scipy<1.14 --------- Co-authored-by: Piotr Rozyczko * Update release info --------- Co-authored-by: Piotr Rozyczko --- CHANGELOG.md | 8 +++ RELEASE.md | 4 +- .../experiments/polaris.cif | 39 +++++----- .../experiments/osiris.cif | 43 +++++------ .../experiments/wish.cif | 66 ++++++++++------- .../Si_SEPD@Argonne/experiments/sepd.cif | 44 ++++++------ .../Pages/Experiment/SideBarBasic.qml | 15 ++-- easyDiffractionApp/Gui/Globals/Configs.qml | 4 +- easyDiffractionApp/Logic/Calculators.py | 33 +++++---- easyDiffractionApp/Logic/Data.py | 2 +- easyDiffractionApp/Logic/Experiment.py | 72 +++++++++++++++---- easyDiffractionApp/Logic/Fitting.py | 2 +- easyDiffractionApp/Logic/Helpers.py | 10 ++- easyDiffractionApp/Logic/Model.py | 2 +- easyDiffractionApp/Logic/Summary.py | 4 +- pyproject.toml | 3 +- 16 files changed, 213 insertions(+), 138 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd4980b..04addfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Version 0.9.4 (26 Jun 2024) + +This is a test version of EasyDiffraction with improved GUI and overall performance. This version temporarily does not use the EasyScience framework, contains only CrysPy as calculation engine and uses only Lmfit for minimization. + +### New Features + +- Point background is now implemented for time-of-flight (TOF) type of experiments + # Version 0.9.3 (21 Jun 2024) This is a test version of EasyDiffraction with improved GUI and overall performance. This version temporarily does not use the EasyScience framework, contains only CrysPy as calculation engine and uses only Lmfit for minimization. diff --git a/RELEASE.md b/RELEASE.md index eac0678..dea2603 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,5 @@ This is a test version of EasyDiffraction with improved GUI and overall performance. This version temporarily does not use the EasyScience framework, contains only CrysPy as calculation engine and uses only Lmfit for minimization. -### Bug Fixes +### New Features -- The package for Snap Store (Linux) has been added back +- Point background is now implemented for time-of-flight (TOF) type of experiments diff --git a/easyDiffractionApp/Examples/CeCuAl3_Polaris@ISIS/experiments/polaris.cif b/easyDiffractionApp/Examples/CeCuAl3_Polaris@ISIS/experiments/polaris.cif index b431af7..1ae2231 100644 --- a/easyDiffractionApp/Examples/CeCuAl3_Polaris@ISIS/experiments/polaris.cif +++ b/easyDiffractionApp/Examples/CeCuAl3_Polaris@ISIS/experiments/polaris.cif @@ -11,27 +11,26 @@ _pd_instr.beta1 0.00224 _pd_instr.sigma0 0.409 _pd_instr.sigma1 8.118 -_tof_background.coeff1 25101(108) -_tof_background.coeff2 6940(199) -_tof_background.coeff3 8460(189) -_tof_background.coeff4 3452(162) -_tof_background.coeff5 2812(157) -_tof_background.coeff6 545(122) -_tof_background.coeff7 1000(128) -_tof_background.coeff8 9(77) -_tof_background.coeff9 116(78) -_tof_background.coeff10 0.0 -_tof_background.coeff11 0.0 -_tof_background.coeff12 0.0 -_tof_background.coeff13 0.0 -_tof_background.coeff14 0.0 -_tof_background.coeff15 0.0 -_tof_background.coeff16 0.0 -_tof_background.coeff17 0.0 -_tof_background.coeff18 0.0 - _diffrn_radiation.probe neutron +loop_ +_pd_background.line_segment_X +_pd_background.line_segment_intensity +_pd_background.X_coordinate +3000.0 33469(55) time-of-flight +4000.0 27344(46) time-of-flight +5000.0 23749(54) time-of-flight +6000.0 20995(65) time-of-flight +7000.0 19795(71) time-of-flight +9000.0 18381(91) time-of-flight +11000.0 18983(136) time-of-flight +13000.0 20745(237) time-of-flight +15000.0 19626(352) time-of-flight +16000.0 22778(634) time-of-flight +17000.0 23899(837) time-of-flight +18000.0 25356(985) time-of-flight +19000.0 25188(1649) time-of-flight + loop_ _pd_phase_block.id _pd_phase_block.scale @@ -3733,4 +3732,4 @@ _pd_meas.intensity_total_su 18976.191 26208.0 5806.0 18985.67 19929.0 5494.0 18995.164 26780.0 5848.0 -19004.658 22232.0 5634.0 +19004.658 22232.0 5634.0 \ No newline at end of file diff --git a/easyDiffractionApp/Examples/Na2Ca3Al2F14_Osiris@ISIS/experiments/osiris.cif b/easyDiffractionApp/Examples/Na2Ca3Al2F14_Osiris@ISIS/experiments/osiris.cif index a27def6..02b904e 100644 --- a/easyDiffractionApp/Examples/Na2Ca3Al2F14_Osiris@ISIS/experiments/osiris.cif +++ b/easyDiffractionApp/Examples/Na2Ca3Al2F14_Osiris@ISIS/experiments/osiris.cif @@ -5,33 +5,34 @@ _pd_instr.dtt1 17591.139 _pd_instr.dtt2 -0.56(5) _pd_instr.zero 2.4(2) _pd_instr.alpha0 0.0 -_pd_instr.alpha1 0.0773(9) -_pd_instr.beta0 0.01079(7) +_pd_instr.alpha1 0.0772(9) +_pd_instr.beta0 0.01078(7) _pd_instr.beta1 0.0555(9) _pd_instr.sigma0 0.0 _pd_instr.sigma1 13.2(1) -_tof_background.coeff1 819(43) -_tof_background.coeff2 737(85) -_tof_background.coeff3 717(83) -_tof_background.coeff4 567(79) -_tof_background.coeff5 441(74) -_tof_background.coeff6 316(68) -_tof_background.coeff7 230(61) -_tof_background.coeff8 157(54) -_tof_background.coeff9 102(46) -_tof_background.coeff10 58(39) -_tof_background.coeff11 20(32) -_tof_background.coeff12 -3(25) -_tof_background.coeff13 -19(19) -_tof_background.coeff14 -19(14) -_tof_background.coeff15 -20(10) -_tof_background.coeff16 -8(7) -_tof_background.coeff17 -9(4) -_tof_background.coeff18 -5(3) - _diffrn_radiation.probe neutron +loop_ +_pd_background.line_segment_X +_pd_background.line_segment_intensity +_pd_background.X_coordinate +14918.0 1915(55) time-of-flight +16000.0 1661(28) time-of-flight +18000.0 1511(17) time-of-flight +20000.0 1059(12) time-of-flight +22000.0 885(8) time-of-flight +25000.0 758(6) time-of-flight +30000.0 607(5) time-of-flight +35000.0 523(4) time-of-flight +40000.0 416(3) time-of-flight +50000.0 363(3) time-of-flight +70000.0 394(3) time-of-flight +90000.0 425(6) time-of-flight +110000.0 445(10) time-of-flight +120000.0 484(14) time-of-flight +135002.0 487(10) time-of-flight + loop_ _pd_phase_block.id _pd_phase_block.scale diff --git a/easyDiffractionApp/Examples/Na2Ca3Al2F14_WISH@ISIS/experiments/wish.cif b/easyDiffractionApp/Examples/Na2Ca3Al2F14_WISH@ISIS/experiments/wish.cif index 3090071..128e4a8 100644 --- a/easyDiffractionApp/Examples/Na2Ca3Al2F14_WISH@ISIS/experiments/wish.cif +++ b/easyDiffractionApp/Examples/Na2Ca3Al2F14_WISH@ISIS/experiments/wish.cif @@ -1,41 +1,55 @@ data_wish _pd_instr.2theta_bank 152.827 -_pd_instr.dtt1 20773.9(3) +_pd_instr.dtt1 20773.5(3) _pd_instr.dtt2 -1.08308 -_pd_instr.zero -15.0(5) -_pd_instr.alpha0 -0.0160(8) -_pd_instr.alpha1 0.121(3) -_pd_instr.beta0 0.00663(3) -_pd_instr.beta1 0.0100(3) +_pd_instr.zero -14.4(5) +_pd_instr.alpha0 -0.0162(8) +_pd_instr.alpha1 0.122(3) +_pd_instr.beta0 0.00658(3) +_pd_instr.beta1 0.0108(3) _pd_instr.sigma0 0.0 _pd_instr.sigma1 7.5(2) -_tof_background.coeff1 307(16) -_tof_background.coeff2 63(32) -_tof_background.coeff3 18(31) -_tof_background.coeff4 -27(30) -_tof_background.coeff5 -45(29) -_tof_background.coeff6 -45(27) -_tof_background.coeff7 -46(25) -_tof_background.coeff8 -45(23) -_tof_background.coeff9 -40(20) -_tof_background.coeff10 -31(17) -_tof_background.coeff11 -23(15) -_tof_background.coeff12 -21(12) -_tof_background.coeff13 -16(10) -_tof_background.coeff14 -11(8) -_tof_background.coeff15 -5(6) -_tof_background.coeff16 -3(4) -_tof_background.coeff17 1(2) -_tof_background.coeff18 -2(2) - _diffrn_radiation.probe neutron +loop_ +_pd_background.line_segment_X +_pd_background.line_segment_intensity +_pd_background.X_coordinate +9162.304 466(39) time-of-flight +11136.874 593(30) time-of-flight +13313.388 497(22) time-of-flight +14906.508 546(19) time-of-flight +16454.75 533(17) time-of-flight +17352.281 497(14) time-of-flight +18743.455 429(10) time-of-flight +20179.508 453(10) time-of-flight +21368.736 397(9) time-of-flight +22176.04 473(12) time-of-flight +22827.227 478(9) time-of-flight +24644.729 380(6) time-of-flight +26439.791 381(5) time-of-flight +28257.293 378(5) time-of-flight +31196.71 343(4) time-of-flight +34034.406 328(4) time-of-flight +37265.52 309(4) time-of-flight +41214.66 322(3) time-of-flight +44827.227 282(3) time-of-flight +49830.965 272(4) time-of-flight +52905.01 257(4) time-of-flight +58204.938 260(4) time-of-flight +62916.98 261(4) time-of-flight +70186.984 262(5) time-of-flight +74204.94 262(6) time-of-flight +82103.22 268(6) time-of-flight +91958.87 268(7) time-of-flight +102712.04 262(15) time-of-flight + loop_ _pd_phase_block.id _pd_phase_block.scale -ncaf 1.087(5) +ncaf 1.095(5) loop_ _pd_meas.time_of_flight diff --git a/easyDiffractionApp/Examples/Si_SEPD@Argonne/experiments/sepd.cif b/easyDiffractionApp/Examples/Si_SEPD@Argonne/experiments/sepd.cif index e67766a..a8dd6a9 100644 --- a/easyDiffractionApp/Examples/Si_SEPD@Argonne/experiments/sepd.cif +++ b/easyDiffractionApp/Examples/Si_SEPD@Argonne/experiments/sepd.cif @@ -1,41 +1,37 @@ data_sepd +_diffrn_radiation.probe neutron + _pd_instr.2theta_bank 144.845 _pd_instr.dtt1 7476.91 _pd_instr.dtt2 -1.54 -_pd_instr.zero -9.26(5) +_pd_instr.zero -9.24(5) _pd_instr.alpha0 0.0 _pd_instr.alpha1 0.5971 _pd_instr.beta0 0.04221 _pd_instr.beta1 0.00946 -_pd_instr.sigma0 0.21(6) -_pd_instr.sigma1 7.08(6) - -_tof_background.coeff1 154.8(6) -_tof_background.coeff2 1(1) -_tof_background.coeff3 36.8(9) -_tof_background.coeff4 12.1(8) -_tof_background.coeff5 17.7(8) -_tof_background.coeff6 5.0(7) -_tof_background.coeff7 6.8(5) -_tof_background.coeff8 0.0 -_tof_background.coeff9 0.0 -_tof_background.coeff10 0.0 -_tof_background.coeff11 0.0 -_tof_background.coeff12 0.0 -_tof_background.coeff13 0.0 -_tof_background.coeff14 0.0 -_tof_background.coeff15 0.0 -_tof_background.coeff16 0.0 -_tof_background.coeff17 0.0 -_tof_background.coeff18 0.0 +_pd_instr.sigma0 0.30(6) +_pd_instr.sigma1 7.01(6) -_diffrn_radiation.probe neutron +loop_ +_pd_background.line_segment_X +_pd_background.line_segment_intensity +_pd_background.X_coordinate +2000.0 221.1 time-of-flight +4000.0 169.5 time-of-flight +6000.0 135.4 time-of-flight +10000.0 121.4 time-of-flight +14000.0 132.2 time-of-flight +18000.0 134 time-of-flight +22000.0 143 time-of-flight +25000.0 183 time-of-flight +28000.0 165 time-of-flight +29995.0 204 time-of-flight loop_ _pd_phase_block.id _pd_phase_block.scale -si 15.01(4) +si 14.97(4) loop_ _pd_meas.time_of_flight diff --git a/easyDiffractionApp/Gui/Components/Pages/Experiment/SideBarBasic.qml b/easyDiffractionApp/Gui/Components/Pages/Experiment/SideBarBasic.qml index 19bd619..96f0d0c 100644 --- a/easyDiffractionApp/Gui/Components/Pages/Experiment/SideBarBasic.qml +++ b/easyDiffractionApp/Gui/Components/Pages/Experiment/SideBarBasic.qml @@ -135,13 +135,14 @@ EaComponents.SideBarColumn { if (JSON.stringify(Globals.Proxies.experimentMainParam('_diffrn_radiation', 'type')) === '{}') { return '' } - if (Globals.Proxies.experimentMainParam('_diffrn_radiation', 'type').value === 'cwl') { - return 'SideBarBasic/PdBackground.qml' - } else if (Globals.Proxies.experimentMainParam('_diffrn_radiation', 'type').value === 'tof') { - return 'SideBarBasic/PdBackground_TOF.qml' - } else { - return '' - } + //if (Globals.Proxies.experimentMainParam('_diffrn_radiation', 'type').value === 'cwl') { + // return 'SideBarBasic/PdBackground.qml' + //} else if (Globals.Proxies.experimentMainParam('_diffrn_radiation', 'type').value === 'tof') { + // return 'SideBarBasic/PdBackground_TOF.qml' + //} else { + // return '' + //} + return 'SideBarBasic/PdBackground.qml' } } } diff --git a/easyDiffractionApp/Gui/Globals/Configs.qml b/easyDiffractionApp/Gui/Globals/Configs.qml index 3a88961..27eebf1 100644 --- a/easyDiffractionApp/Gui/Globals/Configs.qml +++ b/easyDiffractionApp/Gui/Globals/Configs.qml @@ -12,7 +12,7 @@ QtObject { // If "Unknown component. (M300) in QtCreator", try: "Tools > QML/JS readonly property var projectConfig: QtObject { readonly property var release: QtObject { // NEED FIX readonly property string appName: 'EasyDiffraction' - readonly property string version: '0.9.3' + readonly property string version: '0.9.4' readonly property string appIssuesUrl: 'https://github.com/easyscience/easydiffractionapp/issues' readonly property string homePageUrl: 'https://easydiffraction.org' readonly property string docsUrl: 'https://docs.easydiffraction.org/app/' @@ -25,7 +25,7 @@ QtObject { // If "Unknown component. (M300) in QtCreator", try: "Tools > QML/JS readonly property string branch_url: '' readonly property string commit_sha_short: '' readonly property string commit_url: '' - readonly property string build_date: '29 May 2024' + readonly property string build_date: '26 Jun 2024' } } } diff --git a/easyDiffractionApp/Logic/Calculators.py b/easyDiffractionApp/Logic/Calculators.py index bacfd4e..9b80996 100644 --- a/easyDiffractionApp/Logic/Calculators.py +++ b/easyDiffractionApp/Logic/Calculators.py @@ -14,7 +14,7 @@ str_to_globaln from cryspy.A_functions_base.function_2_space_group import \ get_it_coordinate_system_codes_by_it_number - console.debug('CrysPy module imported') + #console.debug('CrysPy module imported') except ImportError: console.error('No CrysPy module found') @@ -237,6 +237,8 @@ def edCifToCryspyCif(edCif, diffrn_radiation_type='cwl'): # NEED to remove this and use our handling of a background as for TOF case '_pd_background.line_segment_X': '_pd_background_2theta', '_pd_background.line_segment_intensity': '_pd_background_intensity', + '_pd_background.X_coordinate': '_pd_background_X_coordinate', + } edToCryspyNamesMap['tof'] = { '_pd_instr.zero': '_tof_parameters_Zero', @@ -256,8 +258,12 @@ def edCifToCryspyCif(edCif, diffrn_radiation_type='cwl'): '_pd_instr.sigma1': '_tof_profile_sigma1', '_pd_instr.sigma2': '_tof_profile_sigma2', - '_tof_background.time_max': '_tof_background_time_max', - '_tof_background.coeff': '_tof_background_coeff', + ###'_tof_background.time_max': '_tof_background_time_max', + ###'_tof_background.coeff': '_tof_background_coeff', + + '_pd_background.line_segment_X': '_tof_backgroundpoint_time', + '_pd_background.line_segment_intensity': '_tof_backgroundpoint_intensity', + '_pd_background.X_coordinate': '_tof_backgroundpoint.X_coordinate', '_pd_meas.time_of_flight': '_tof_meas_time', '_pd_meas.intensity_total_su': '_tof_meas_intensity_sigma', # before _pd_meas.intensity_total! @@ -1251,14 +1257,14 @@ def cryspyObjAndDictToEdExperiments(cryspy_obj, cryspy_dict): # NEED to be modi # fit = item.gamma2_refinement #)) - # Ed (pycifstar processed) background section - elif type(item) is cryspy.B_parent_classes.cl_2_loop.LoopN and item.items[0].PREFIX == 'pd_background': - pycifstar_bkg_points = item.items + # Cryspy background section (TOF, points) + elif type(item) is cryspy.C_item_loop_classes.cl_1_tof_background_by_points.TOFBackgroundPointL: + cryspy_bkg_points = item.items ed_bkg_points = [] - for idx, pycifstar_bkg_point in enumerate(pycifstar_bkg_points): + for idx, cryspy_bkg_point in enumerate(cryspy_bkg_points): ed_bkg_point = {} ed_bkg_point['line_segment_X'] = dict(Parameter( - pycifstar_bkg_point.line_segment_x, + cryspy_bkg_point.time, idx = idx, category = '_pd_background', name = 'line_segment_X', @@ -1268,13 +1274,12 @@ def cryspyObjAndDictToEdExperiments(cryspy_obj, cryspy_dict): # NEED to be modi cifDict = 'pd' )) ed_bkg_point['line_segment_intensity'] = dict(Parameter( - pycifstar_bkg_point.line_segment_intensity, - #error = pycifstar_bkg_point.line_segment_intensity_sigma, - error = 1.0, + cryspy_bkg_point.intensity, + error = cryspy_bkg_point.intensity_sigma, idx = idx, category = '_pd_background', prettyCategory = 'bkg', - rowName = f'{pycifstar_bkg_point.line_segment_x:g}µs', # formatting float to str without trailing zeros + rowName = f'{cryspy_bkg_point.time:g}µs', # formatting float to str without trailing zeros name = 'line_segment_intensity', prettyName = 'intensity', shortPrettyName = 'Ibkg', @@ -1284,7 +1289,7 @@ def cryspyObjAndDictToEdExperiments(cryspy_obj, cryspy_dict): # NEED to be modi cifDict = 'pd', pctDelta = 25, fittable = True, - fit = pycifstar_bkg_point.line_segment_intensity_refinement + fit = cryspy_bkg_point.intensity_refinement )) ed_bkg_point['X_coordinate'] = dict(Parameter( 'time-of-flight', @@ -1299,7 +1304,7 @@ def cryspyObjAndDictToEdExperiments(cryspy_obj, cryspy_dict): # NEED to be modi ed_bkg_points.append(ed_bkg_point) ed_experiment_no_meas['loops']['_pd_background'] = ed_bkg_points - # Cryspy background section (TOF, polinom coeffs?) + # Cryspy background section (TOF, polinom coeffs) elif type(item) is cryspy.C_item_loop_classes.cl_1_tof_background.TOFBackground: if hasattr(item, 'time_max'): if not '_tof_background' in ed_experiment_no_meas['params']: diff --git a/easyDiffractionApp/Logic/Data.py b/easyDiffractionApp/Logic/Data.py index 236bfd4..54545e2 100644 --- a/easyDiffractionApp/Logic/Data.py +++ b/easyDiffractionApp/Logic/Data.py @@ -10,7 +10,7 @@ try: from cryspy.H_functions_global.function_1_cryspy_objects import \ str_to_globaln - console.debug('CrysPy module imported') + #console.debug('CrysPy module imported') except ImportError: console.error('No CrysPy module found') diff --git a/easyDiffractionApp/Logic/Experiment.py b/easyDiffractionApp/Logic/Experiment.py index 11f6f8d..ace9fa1 100644 --- a/easyDiffractionApp/Logic/Experiment.py +++ b/easyDiffractionApp/Logic/Experiment.py @@ -23,12 +23,44 @@ str_to_globaln from cryspy.procedure_rhochi.rhochi_by_dictionary import \ rhochi_calc_chi_sq_by_dictionary - console.debug('CrysPy module imported') + #console.debug('CrysPy module imported') except ImportError: - console.debug('No CrysPy module found') + console.error('No CrysPy module found') -_DEFAULT_DATA_BLOCK_NO_MEAS = """data_pnd +_DEFAULT_DATA_BLOCK_NO_MEAS_TOF = """data_pnd + +_diffrn_radiation.probe neutron + +_pd_instr.2theta_bank 144.845 +_pd_instr.dtt1 7476.91 +_pd_instr.dtt2 -1.54 +_pd_instr.zero -9.24 +_pd_instr.alpha0 0.0 +_pd_instr.alpha1 0.5971 +_pd_instr.beta0 0.04221 +_pd_instr.beta1 0.00946 +_pd_instr.sigma0 0.30 +_pd_instr.sigma1 7.01 + +loop_ +_pd_phase_block.id +_pd_phase_block.scale +ph 1.0 + +loop_ +_pd_background.line_segment_X +_pd_background.line_segment_intensity +0 100 +150000 100 + +loop_ +_pd_meas.time_of_flight +_pd_meas.intensity_total +_pd_meas.intensity_total_su +""" + +_DEFAULT_DATA_BLOCK_NO_MEAS_CWL = """data_pnd _diffrn_radiation.probe neutron _diffrn_radiation_wavelength.wavelength 1.9 @@ -63,7 +95,7 @@ _pd_meas.intensity_total_su """ -_DEFAULT_DATA_BLOCK = _DEFAULT_DATA_BLOCK_NO_MEAS + """36.5 1 1 +_DEFAULT_DATA_BLOCK_CWL = _DEFAULT_DATA_BLOCK_NO_MEAS_CWL + """36.5 1 1 37.0 10 3 37.5 700 25 38.0 1100 30 @@ -169,7 +201,7 @@ def dataBlocksCifMeasOnly(self): @Slot() def addDefaultExperiment(self): console.debug('Adding default experiment') - self.loadExperimentsFromEdCif(_DEFAULT_DATA_BLOCK) + self.loadExperimentsFromEdCif(_DEFAULT_DATA_BLOCK_CWL) @Slot('QVariant') def loadExperimentsFromResources(self, fpaths): @@ -213,9 +245,9 @@ def loadExperimentsFromFiles(self, fpaths): # Extract measured data and calculate standard uncertainty if needed if data.shape[0] == 3: - ttheta, intensity, intensity_su = data + x, intensity, intensity_su = data elif data.shape[0] == 2: - ttheta, intensity = data + x, intensity = data intensity_su = np.sqrt(intensity) else: console.error(f"Failed to load data from file {fpath}. Supported number of columns: 2 or 3") @@ -223,11 +255,14 @@ def loadExperimentsFromFiles(self, fpaths): # Convert data from numpy arrays to string sio = StringIO() - np.savetxt(sio, np.c_[ttheta, intensity, intensity_su], fmt='%10.6f') + np.savetxt(sio, np.c_[x, intensity, intensity_su], fmt='%10.6f') procData = sio.getvalue() # Add default CIF instrumental block and measured data header - procData = _DEFAULT_DATA_BLOCK_NO_MEAS + procData + if x.max() < 180: + procData = _DEFAULT_DATA_BLOCK_NO_MEAS_CWL + procData + else: + procData = _DEFAULT_DATA_BLOCK_NO_MEAS_TOF + procData # Other formats not supported else: @@ -250,7 +285,7 @@ def loadExperimentsFromEdCif(self, edCif): elif 'time_of_flight' in edCif: edCif += '\n_pd_instr.peak_shape Gauss' # 'pseudo-Voigt' is default #edCif += '\n_pd_instr.peak_shape pseudo-Voigt' - edCif += '\n_tof_background_time_max 1000.0' + ###edCif += '\n_tof_background_time_max 1000.0' cryspyCif = CryspyParser.edCifToCryspyCif(edCif, 'tof') cryspyExperimentsObj = str_to_globaln(cryspyCif) @@ -357,11 +392,11 @@ def replaceExperiment(self, edCifNoMeas=''): # NEED modifications for CWL/TOF range_max = currentDataBlock['params']['_pd_meas']['2theta_range_max']['value'] edRangeCif = f'_pd_meas.2theta_range_min {range_min}\n_pd_meas.2theta_range_max {range_max}' elif 'time_of_flight' in edCif: + edCif += '\n\n_pd_instr.peak_shape Gauss' diffrn_radiation_type = 'tof' experiment_prefix = 'tof' - time_max = currentDataBlock['params']['_tof_background']['time_max']['value'] - edCif += '\n\n_pd_instr.peak_shape Gauss' - edCif += f'\n_tof_background.time_max {time_max}' + ###time_max = currentDataBlock['params']['_tof_background']['time_max']['value'] + ###edCif += f'\n_tof_background.time_max {time_max}' range_min = currentDataBlock['params']['_pd_meas']['tof_range_min']['value'] range_max = currentDataBlock['params']['_pd_meas']['tof_range_max']['value'] edRangeCif = f'_pd_meas.tof_range_min {range_min}\n_pd_meas.tof_range_max {range_max}' @@ -691,7 +726,7 @@ def cryspyDictPathByLoopParam(self, blockIdx, category, name, rowIndex, value): # _pd_background if category == '_pd_background': if diffrn_radiation_type == 'cwl': - console.debug('Background is handeled by CrysPy') # NEED FIX: do as in TOF + console.debug('Background is handeled by CrysPy') if name == 'line_segment_X': path[1] = 'background_ttheta' path[2] = rowIndex @@ -700,7 +735,14 @@ def cryspyDictPathByLoopParam(self, blockIdx, category, name, rowIndex, value): path[1] = 'background_intensity' path[2] = rowIndex elif diffrn_radiation_type == 'tof': - console.debug('Background is handeled by ED, not CrysPy') + console.debug('Background is handeled by CrysPy') + if name == 'line_segment_X': + path[1] = 'background_time' + path[2] = rowIndex + value = np.deg2rad(value) + if name == 'line_segment_intensity': + path[1] = 'background_intensity' + path[2] = rowIndex # _pd_phase_block if category == '_pd_phase_block': diff --git a/easyDiffractionApp/Logic/Fitting.py b/easyDiffractionApp/Logic/Fitting.py index 489ad53..37d1fa1 100644 --- a/easyDiffractionApp/Logic/Fitting.py +++ b/easyDiffractionApp/Logic/Fitting.py @@ -16,7 +16,7 @@ import cryspy from cryspy.procedure_rhochi.rhochi_by_dictionary import \ rhochi_calc_chi_sq_by_dictionary - console.debug('CrysPy module imported') + #console.debug('CrysPy module imported') except ImportError: console.error('No CrysPy module found') diff --git a/easyDiffractionApp/Logic/Helpers.py b/easyDiffractionApp/Logic/Helpers.py index de977b3..4438b2b 100644 --- a/easyDiffractionApp/Logic/Helpers.py +++ b/easyDiffractionApp/Logic/Helpers.py @@ -59,11 +59,19 @@ def setPaths(self): self.mainQml = f'qrc:/{self.mainQml}' self.splashScreenQml = f'qrc:/{self.splashScreenQml}' self.imports.append('qrc:/') - console.info(f'Resources: {resources}') + resourcesPath = resources.__file__ + console.info(f'Resources: {resourcesPath}') except ImportError: self.imports.append('.') console.debug('No python resources (rc) file found') + try: + import cryspy + cryspyPath = os.path.abspath(cryspy.__path__[0]) + console.info(f'CrysPy module: {cryspyPath}') + except ImportError: + console.error('No CrysPy module found') + import EasyApp easyAppPath = os.path.abspath(EasyApp.__path__[0]) self.imports.append(os.path.join(easyAppPath, '..')) diff --git a/easyDiffractionApp/Logic/Model.py b/easyDiffractionApp/Logic/Model.py index bdeb40a..d5f3a23 100644 --- a/easyDiffractionApp/Logic/Model.py +++ b/easyDiffractionApp/Logic/Model.py @@ -25,7 +25,7 @@ ACCESIBLE_NAME_HM_SHORT from cryspy.procedure_rhochi.rhochi_by_dictionary import \ rhochi_calc_chi_sq_by_dictionary - console.debug('CrysPy module imported') + #console.debug('CrysPy module imported') except ImportError: console.error('No CrysPy module found') diff --git a/easyDiffractionApp/Logic/Summary.py b/easyDiffractionApp/Logic/Summary.py index 15458c3..0a18bc9 100644 --- a/easyDiffractionApp/Logic/Summary.py +++ b/easyDiffractionApp/Logic/Summary.py @@ -11,7 +11,7 @@ try: import cryspy - console.debug('CrysPy module imported') + #console.debug('CrysPy module imported') except ImportError: console.error('No CrysPy module found') @@ -277,7 +277,7 @@ def setDataBlocksCif(self): def setAsHtml(self): proxy = self._proxy - if proxy.model.dataBlocks == []: + if proxy.model.dataBlocks == [] or proxy.experiment.dataBlocksNoMeas == [] or proxy.experiment._yMeasArrays == []: return html = _HTML_TEMPLATE diff --git a/pyproject.toml b/pyproject.toml index a0bb967..984c12e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "hatchling.build" # Note that while the project is called EasyDiffractionApp # the application itself is EasyDiffraction. name = 'easyDiffractionApp' -version = '0.9.2' +version = '0.9.4' description = 'Making diffraction data analysis and modelling easy.' authors = [ {name = "Andrew Sazonov", email = "andrew.sazonov@ess.eu"} @@ -27,6 +27,7 @@ classifiers = [ requires-python = ">=3.8,<3.13" dependencies = [ 'numpy<2', + 'scipy<1.14', 'lmfit', 'orjson', 'cryspy @ git+https://github.com/ikibalin/cryspy.git@beta',