Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engineering Diffraction Interface doesn't recalculate Van Norm Focus if one with the correct name is already in the ADS #38879

Open
andy-bridger opened this issue Feb 18, 2025 · 0 comments · May be fixed by #38870
Assignees
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Diffraction Issues and pull requests related to diffraction
Milestone

Comments

@andy-bridger
Copy link
Collaborator

andy-bridger commented Feb 18, 2025

Describe the bug
Bug found when changing the Custom Cal File implementation in Engineering Diffraction.
Currently, when you supply a Custom CalFile in Crop Calibration and then hit Calibrate the ADS is populated with files with the suffix _Custom.
When you then run focus, the Vanadium focussing checks to see if engggui_curves_Custom exists and if so, just loads it in, otherwise it calculates it.
This means if you run a calibration for a custom .cal file and focus it, then change your mind and rerun the calibration with a different custom .cal file, when you now focus again, it will use the original calibration.
This is also a problem (probably more so) for using the Crop to Spectra

Fortunately, for Custom CalFiles if there are different numbers of detector groups in the two custom files you get an error Error in execution of algorithm Divide: Number of histograms not identical., but if you happen to provide the same number of groups (like Crop To Spectra which always combines spectra into one group) you would likely not notice and it can make a big difference to the intensities:

Image

Image

To Reproduce
You can create some custom cal files using:

# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np

group_ws1 = CreateGroupingWorkspace(InstrumentName='ENGINX', 
                        ComponentName='ENGIN-X', 
                        CustomGroupingString='100001-100100,101001-101100, 102001-102100')
group_ws2 = CreateGroupingWorkspace(InstrumentName='ENGINX', 
                        ComponentName='ENGIN-X', 
                        CustomGroupingString='100001-100100,101001-101100')
group_ws3 = CreateGroupingWorkspace(InstrumentName='ENGINX', 
                        ComponentName='ENGIN-X', 
                        CustomGroupingString='114001-114100,111001-111100, 112001-112100')

tmp_dir = r"C:/Users/kcd17618/Documents/MantidScripts/CustomCalBug"

SaveCalFile(rf"{tmp_dir}/example_cal_file.cal", GroupingWorkspace = "group_ws1", )                   
SaveCalFile(rf"{tmp_dir}/another_cal_file.cal", GroupingWorkspace = "group_ws2", )   
SaveCalFile(rf"{tmp_dir}/third_cal_file.cal", GroupingWorkspace = "group_ws3", )   

Custom Cal Files:

  • Open Engineering Diffraction interface
  • Click Create New Calibration
  • Enter 305738
  • Click Crop Calibration
  • Set Region of Interest to Custom CalFile
  • Set Custom CalFile to (rf"{tmp_dir}/example_cal_file.cal"
  • Click Calibrate
  • Go to Focus tab
  • Set Sample Run to 305761
  • Set Vanadium to 307521
  • Click Focus
  • Should get first image spectra
  • Clear the ADS
  • Go back to Calibrate tab
  • Set Custom CalFile to (rf"{tmp_dir}/third_cal_file.cal"
  • Click Calibrate
  • Go to Focus tab
  • Set Sample Run to 305761
  • Set Vanadium to 307521
  • Click Focus
  • Without clearing ADS
  • Go back to Calibrate tab
  • Set Custom CalFile to (rf"{tmp_dir}/example_cal_file.cal"
  • Click Calibrate
  • Go to Focus tab
  • Set Sample Run to 305761
  • Set Vanadium to 307521
  • Click Focus
  • Should get second image spectra
  • Without clearing ADS
  • Go back to Calibrate tab
  • Set Custom CalFile to (rf"{tmp_dir}/another_cal_file.cal"
  • Click Calibrate
  • Go to Focus tab
  • Set Sample Run to 305761
  • Set Vanadium to 307521
  • Click Focus
  • Should get error

Custom Crop To Spectra:

  • Open Engineering Diffraction interface
  • Click Create New Calibration
  • Enter 305738
  • Click Crop Calibration
  • Set Region of Interest to Crop To Spectra
  • Set Custom Spectra to 2-102
  • Click Calibrate
  • Go to Focus tab
  • Set Sample Run to 305761
  • Set Vanadium to 307521
  • Click Focus
  • Should get first image spectra
  • Clear the ADS
  • Go back to Calibrate tab
  • Set Custom Spectra to 500-900
  • Click Calibrate
  • Go to Focus tab
  • Set Sample Run to 305761
  • Set Vanadium to 307521
  • Click Focus
  • Without clearing ADS
  • Go back to Calibrate tab
  • Set Custom Spectra back to 2-102
  • Click Calibrate
  • Go to Focus tab
  • Set Sample Run to 305761
  • Set Vanadium to 307521
  • Click Focus
  • Should get second image spectra

Expected behavior
Each time you run a calibration, you should expect to use that calibration for focussing, regardless of what junk is already in the ADS

Screenshots

Platform/Version (please complete the following information):

  • OS: [e.g. Windows, RHEL 7, Ubuntu, macOS]
  • OS Version:
  • Mantid Version [e.g. 6.0.0]

Additional context

@andy-bridger andy-bridger added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Diffraction Issues and pull requests related to diffraction labels Feb 18, 2025
@andy-bridger andy-bridger added this to the Release 6.13 milestone Feb 18, 2025
@andy-bridger andy-bridger self-assigned this Feb 18, 2025
@andy-bridger andy-bridger changed the title Focussing using Custom Cal Files breaks when changing the custom file Engineering Diffraction Interface doesn't recalculate Van Norm Focus if one with the correct name is already in the ADS Feb 18, 2025
@RichardWaiteSTFC RichardWaiteSTFC moved this from Todo to In Progress in ISIS Diffraction Feb 25, 2025
@RichardWaiteSTFC RichardWaiteSTFC moved this from In Progress to In Review in ISIS Diffraction Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) Diffraction Issues and pull requests related to diffraction
Projects
Status: In Review
1 participant