Skip to content
Snippets Groups Projects
Commit 2fd58444 authored by David Fairbrother's avatar David Fairbrother
Browse files

Revert "Re #18643 Add optional chemical properties for abs. corrections"

Re #18643 Let Mantid handle chemical properties

This reverts commit 60512423.
parent 60512423
No related merge requests found
...@@ -14,6 +14,7 @@ absorption_correction_params = { ...@@ -14,6 +14,7 @@ absorption_correction_params = {
gem_adv_config_params = { gem_adv_config_params = {
"raw_tof_cropping_values": (500, 20000), "raw_tof_cropping_values": (500, 20000),
"spline_coefficient": 30 "spline_coefficient": 30
} }
focused_cropping_values = [(550, 19900), # Bank 1 focused_cropping_values = [(550, 19900), # Bank 1
......
...@@ -27,7 +27,6 @@ def get_run_details(run_number_string, inst_settings): ...@@ -27,7 +27,6 @@ def get_run_details(run_number_string, inst_settings):
label = common.cal_map_dictionary_key_helper(cycle_map, "label") label = common.cal_map_dictionary_key_helper(cycle_map, "label")
offset_file_name = common.cal_map_dictionary_key_helper(cycle_map, "offset_file_name") offset_file_name = common.cal_map_dictionary_key_helper(cycle_map, "offset_file_name")
empty_runs = common.cal_map_dictionary_key_helper(cycle_map, "empty_run_numbers") empty_runs = common.cal_map_dictionary_key_helper(cycle_map, "empty_run_numbers")
empty_containers_runs = common.cal_map_dictionary_key_helper(cycle_map, "empty_container_run_numbers")
vanadium_runs = common.cal_map_dictionary_key_helper(cycle_map, "vanadium_run_numbers") vanadium_runs = common.cal_map_dictionary_key_helper(cycle_map, "vanadium_run_numbers")
# For GEM the grouping and offset file are identical # For GEM the grouping and offset file are identical
...@@ -39,6 +38,8 @@ def get_run_details(run_number_string, inst_settings): ...@@ -39,6 +38,8 @@ def get_run_details(run_number_string, inst_settings):
offset_file_path = os.path.join(label_calibration_folder, offset_file_name) offset_file_path = os.path.join(label_calibration_folder, offset_file_name)
splined_file_path = os.path.join(label_calibration_folder, splined_vanadium_name) splined_file_path = os.path.join(label_calibration_folder, splined_vanadium_name)
# TODO generate splined vanadium name from common
run_details = RunDetails.RunDetails(run_number=run_number) run_details = RunDetails.RunDetails(run_number=run_number)
run_details.empty_runs = empty_runs run_details.empty_runs = empty_runs
run_details.user_input_run_number = run_number_string run_details.user_input_run_number = run_number_string
......
...@@ -11,7 +11,6 @@ class RunDetails(object): ...@@ -11,7 +11,6 @@ class RunDetails(object):
self.run_number = run_number self.run_number = run_number
self.user_input_run_number = None self.user_input_run_number = None
self.empty_container_runs = None
self.empty_runs = None self.empty_runs = None
self.label = None self.label = None
......
...@@ -23,7 +23,6 @@ def run_cylinder_absorb_corrections(ws_to_correct, multiple_scattering, config_d ...@@ -23,7 +23,6 @@ def run_cylinder_absorb_corrections(ws_to_correct, multiple_scattering, config_d
radius_key = "cylinder_sample_radius" radius_key = "cylinder_sample_radius"
pos_key = "cylinder_position" pos_key = "cylinder_position"
formula_key = "chemical_formula" formula_key = "chemical_formula"
chemical_key = "chemical_properties"
e_msg = "The following key was not found in the advanced configuration for sample correction:\n" e_msg = "The following key was not found in the advanced configuration for sample correction:\n"
...@@ -32,23 +31,16 @@ def run_cylinder_absorb_corrections(ws_to_correct, multiple_scattering, config_d ...@@ -32,23 +31,16 @@ def run_cylinder_absorb_corrections(ws_to_correct, multiple_scattering, config_d
pos = common.dictionary_key_helper(dictionary=config_dict, key=pos_key, exception_msg=e_msg + pos_key) pos = common.dictionary_key_helper(dictionary=config_dict, key=pos_key, exception_msg=e_msg + pos_key)
formula = common.dictionary_key_helper(dictionary=config_dict, key=formula_key, exception_msg=e_msg + formula_key) formula = common.dictionary_key_helper(dictionary=config_dict, key=formula_key, exception_msg=e_msg + formula_key)
chemical_properties = common.dictionary_key_helper(dictionary=config_dict, key=chemical_key, throws=False)
position_dict = {
"cylinder_height": height,
"cylinder_radius": radius,
"cylinder_pos": pos
}
ws_to_correct = _calculate__cylinder_absorb_corrections( ws_to_correct = _calculate__cylinder_absorb_corrections(
ws_to_correct=ws_to_correct, multiple_scattering=multiple_scattering, ws_to_correct=ws_to_correct, multiple_scattering=multiple_scattering,
position_dict=position_dict, chemical_formula=formula, material_properties=chemical_properties) c_height=height, c_radius=radius, c_pos=pos, chemical_formula=formula)
return ws_to_correct return ws_to_correct
def _calculate__cylinder_absorb_corrections(ws_to_correct, multiple_scattering, def _calculate__cylinder_absorb_corrections(ws_to_correct, multiple_scattering,
position_dict, chemical_formula, material_properties): c_height, c_radius, c_pos, chemical_formula):
""" """
Calculates vanadium absorption corrections for the specified workspace. The workspace Calculates vanadium absorption corrections for the specified workspace. The workspace
should have any monitor spectra masked before being passed into this method. Additionally should have any monitor spectra masked before being passed into this method. Additionally
...@@ -62,9 +54,9 @@ def _calculate__cylinder_absorb_corrections(ws_to_correct, multiple_scattering, ...@@ -62,9 +54,9 @@ def _calculate__cylinder_absorb_corrections(ws_to_correct, multiple_scattering,
:param chemical_formula: The chemical formula of the container - usually set to 'V' for Vanadium :param chemical_formula: The chemical formula of the container - usually set to 'V' for Vanadium
:return: The workspace with corrections applied :return: The workspace with corrections applied
""" """
geometry_json = {'Shape': 'Cylinder', 'Height': position_dict["cylinder_height"], geometry_json = {'Shape': 'Cylinder', 'Height': c_height,
'Radius': position_dict["cylinder_radius"], 'Center': position_dict["cylinder_pos"]} 'Radius': c_radius, 'Center': c_pos}
material_json = _get_material_json(chemical_formula=chemical_formula, material_properties=material_properties) material_json = {'ChemicalFormula': chemical_formula}
mantid.SetSample(InputWorkspace=ws_to_correct, Geometry=geometry_json, Material=material_json) mantid.SetSample(InputWorkspace=ws_to_correct, Geometry=geometry_json, Material=material_json)
...@@ -74,45 +66,3 @@ def _calculate__cylinder_absorb_corrections(ws_to_correct, multiple_scattering, ...@@ -74,45 +66,3 @@ def _calculate__cylinder_absorb_corrections(ws_to_correct, multiple_scattering,
ws_to_correct = mantid.ConvertUnits(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct, Target="dSpacing") ws_to_correct = mantid.ConvertUnits(InputWorkspace=ws_to_correct, OutputWorkspace=ws_to_correct, Target="dSpacing")
return ws_to_correct return ws_to_correct
def _get_material_json(chemical_formula, material_properties):
"""
Returns a material JSON with either a chemical formula when using elemental chemicals
or uses user set chemical properties when required or the user has set them to generate
the required input for SetMaterial
:param chemical_formula: The formula of the chemical to use
:param material_properties: The materials properties dictionary as set by the user
:return: The material JSON for setSample with appropriate settings.
"""
material_json = {'ChemicalFormula': chemical_formula}
is_elemental_vanadium = True if chemical_formula.lower() == 'v' else False
# Test if we can just use built in Mantid properties
if is_elemental_vanadium and not material_properties:
return material_json
# Else we have to parse the chemical formula specified below
err_message = "Custom properties was detected for the material but the required key was not set:\n"
attenuation_key = "attenuation_cross_section"
scattering_key = "scattering_cross_section"
sample_density_key = "sample_number_density"
attenuation_x_section = common.dictionary_key_helper(material_properties, attenuation_key,
exception_msg=err_message + attenuation_key)
scattering_x_section = common.dictionary_key_helper(material_properties, scattering_key,
exception_msg=err_message + scattering_key)
sample_density = common.dictionary_key_helper(material_properties, sample_density_key,
exception_msg=err_message + sample_density_key)
material_json = {"SampleNumberDensity": sample_density,
"AttenuationXSection": attenuation_x_section,
"ScatteringXSection": scattering_x_section}
print ("Using custom chemical properties:")
for k, v in material_json.viewitems():
print (k, v)
return material_json
...@@ -21,6 +21,8 @@ def create_van(instrument, run_details, absorb): ...@@ -21,6 +21,8 @@ def create_van(instrument, run_details, absorb):
aligned_ws = mantid.AlignDetectors(InputWorkspace=corrected_van_ws, aligned_ws = mantid.AlignDetectors(InputWorkspace=corrected_van_ws,
CalibrationFile=run_details.offset_file_path) CalibrationFile=run_details.offset_file_path)
import pydevd
pydevd.settrace('localhost', port=51205, stdoutToServer=True, stderrToServer=True)
if absorb: if absorb:
aligned_ws = _apply_absorb_corrections(instrument=instrument, run_details=run_details, aligned_ws = _apply_absorb_corrections(instrument=instrument, run_details=run_details,
van_ws=aligned_ws) van_ws=aligned_ws)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment