mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
210 stars 121 forks source link

Running focus twice in POLARIS powder diffraction scripts causes error #34749

Closed DannyHindson closed 1 year ago

DannyHindson commented 1 year ago

If you run the following script you get an error on the second call to focus:

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

from isis_powder import polaris, SampleDetails

config_file_path = r"C:\Total Scattering\demo Helen\polaris_config_example.yaml"
# mode PDF means normalisation method defaults to absolute
polaris = polaris.Polaris(config_file=config_file_path, user_name="test", mode="PDF")

sample_details = SampleDetails(height=4.0, radius=0.2985, center=[0, 0, 0], shape='cylinder')
# for a compound, need to supply two of number_density, number_density_effective and packing_fraction
sample_details.set_material(chemical_formula='Si', packing_fraction=0.6)
polaris.set_sample_details(sample=sample_details)

polaris.create_vanadium(first_cycle_run_no="98532", multiple_scattering=False)

polaris.focus(run_number="98533", input_mode='Summed')

polaris.focus(run_number="98533", input_mode='Summed')

image

I wonder if the second call goes down a different code path that reuses the loaded workspace in the ADS. Perhaps that's already been "normalised by current" and we need to check if that's happened already.

DannyHindson commented 1 year ago

Problem only happens if run with absorption corrections enabled. So this focus call can be repeated without an error:

polaris.focus(run_number="98533", input_mode='Summed', do_absorb_corrections=False)