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

Re #18666 Rename van calib and remove abstract inst wrapping

parent 89838060
Branches equality_for_sample_run
No related tags found
No related merge requests found
from __future__ import (absolute_import, division, print_function)
import os
from abc import ABCMeta, abstractmethod
from six import add_metaclass
from isis_powder.routines import calibrate, focus
......@@ -17,7 +13,6 @@ from isis_powder.routines import calibrate, focus
# to denote internal methods to abstract_inst we will use '_abs_' to denote it as a
# private method for the scripts
@add_metaclass(ABCMeta)
class AbstractInst(object):
def __init__(self, user_name=None, calibration_dir=None, output_dir=None):
# ----- Properties common to ALL instruments -------- #
......@@ -31,10 +26,6 @@ class AbstractInst(object):
def calibration_dir(self):
return self._calibration_dir
@property
def raw_data_dir(self):
return self._raw_data_dir
@property
def output_dir(self):
return self._output_dir
......@@ -43,8 +34,8 @@ class AbstractInst(object):
def user_name(self):
return self._user_name
def _create_calibration_vanadium(self, vanadium_runs, empty_runs,
do_absorb_corrections=True, gen_absorb_correction=False):
def _create_vanadium(self, vanadium_runs, empty_runs,
do_absorb_corrections=True, gen_absorb_correction=False):
"""
Creates a vanadium calibration - should be called by the concrete instrument
:param vanadium_runs: The vanadium run or run in range (depending on instrument) to process
......@@ -69,26 +60,23 @@ class AbstractInst(object):
# Mandatory overrides
@abstractmethod
def _get_run_details(self, run_number_string):
"""
Returns a RunDetails object with various properties related to the current run set
:param run_number_string: The run number to look up the properties of
:return: A RunDetails object containing attributes relevant to that run_number_string
"""
pass
raise NotImplementedError("get_run_details must be implemented per instrument")
@staticmethod
@abstractmethod
def _generate_input_file_name(run_number):
"""
Generates a name which Mantid uses within Load to find the file.
:param run_number: The run number to convert into a valid format for Mantid
:return: A filename that will allow Mantid to find the correct run for that instrument.
"""
pass
raise NotImplementedError("generate_input_file_name must be implemented per instrument")
@abstractmethod
def _generate_output_file_name(self, run_number_string):
"""
Generates the filename which is used to uniquely identify and save the workspace. This should include any
......@@ -96,26 +84,26 @@ class AbstractInst(object):
:param run_number_string: The run string to uniquely identify the run
:return: The file name which identifies the run and appropriate parameter settings
"""
raise NotImplementedError("Output names not implemented")
raise NotImplementedError("generate_output_file_name must be implemented per instrument")
@abstractmethod
def _spline_vanadium_ws(self, focused_vanadium_banks):
"""
Takes a background spline of the list of processed vanadium banks
:param focused_vanadium_banks: The list processed (and cropped) vanadium banks to take a spline of
:return: The splined vanadium workspaces as a list
"""
return None
# XXX: Although this could be moved to common if enough instruments spline the same way and have
# the instrument override the optional behaviour
raise NotImplementedError("spline_vanadium_ws must be implemented per instrument")
# Optional overrides
@abstractmethod
def _apply_absorb_corrections(self, run_details, van_ws, gen_absorb=False):
"""
Generates vanadium absorption corrections to compensate for the container
:param van_ws: A reference vanadium workspace to match the binning of or correct
:return: A workspace containing the corrections
"""
raise NotImplementedError("Not implemented for this instrument yet")
raise NotImplementedError("apply_absorb_corrections Not implemented for this instrument yet")
def _attenuate_workspace(self, input_workspace):
"""
......@@ -205,7 +193,6 @@ class AbstractInst(object):
"""
Generates the various output paths and file names to be used during saving or as workspace names
:param run_details: The run details associated with this run
:param output_directory: The output directory to use as part of the output path
:return: A dictionary containing the various output paths and generated output name
"""
output_directory = os.path.join(self._output_dir, run_details.label, self._user_name)
......
......@@ -9,6 +9,7 @@ from isis_powder.pearl_routines import pearl_algs, pearl_output, pearl_advanced_
class Pearl(AbstractInst):
def __init__(self, **kwargs):
basic_config_dict = yaml_parser.open_yaml_file_as_dictionary(kwargs.get("config_file", None))
......@@ -29,7 +30,7 @@ class Pearl(AbstractInst):
return self._focus(run_number=run_number, input_batching=InputBatchingEnum.Summed,
do_van_normalisation=self._inst_settings.van_norm)
def create_calibration_vanadium(self, run_in_range, **kwargs):
def create_vanadium(self, run_in_range, **kwargs):
self._switch_long_mode_inst_settings(kwargs.get("long_mode"))
kwargs["perform_attenuation"] = False
self._inst_settings.update_attributes(kwargs=kwargs)
......@@ -37,9 +38,9 @@ class Pearl(AbstractInst):
run_details = self._get_run_details(run_number_string=run_in_range)
run_details.run_number = run_details.vanadium_run_numbers
return self._create_calibration_vanadium(vanadium_runs=run_details.vanadium_run_numbers,
empty_runs=run_details.empty_runs,
do_absorb_corrections=self._inst_settings.absorb_corrections)
return self._create_vanadium(vanadium_runs=run_details.vanadium_run_numbers,
empty_runs=run_details.empty_runs,
do_absorb_corrections=self._inst_settings.absorb_corrections)
# Params #
......
......@@ -32,12 +32,12 @@ class Polaris(AbstractInst):
return self._focus(run_number=self._inst_settings.run_number, input_batching=self._inst_settings.input_mode,
do_van_normalisation=self._inst_settings.do_van_normalisation)
def create_calibration_vanadium(self, **kwargs):
def create_vanadium(self, **kwargs):
self._inst_settings.update_attributes(kwargs=kwargs)
run_details = self._get_run_details(run_number_string=int(self._inst_settings.run_in_range))
run_details.run_number = run_details.vanadium_run_numbers
return self._create_calibration_vanadium(
return self._create_vanadium(
vanadium_runs=run_details.vanadium_run_numbers, empty_runs=run_details.empty_runs,
do_absorb_corrections=self._inst_settings.do_absorb_corrections,
gen_absorb_correction=None) # TODO POLARIS doesn't need this flag to gen abs. corrections does PEARL?
......
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