Пример #1
0
    def _load_inst_parameters(self):
        """
            Loads an empty VESUVIO instrument and attaches the necessary
            parameters as attributes
        """
        isis = config.getFacility("ISIS")
        inst_name = "VESUVIO"
        inst_dir = config.getInstrumentDirectory()
        inst_file = os.path.join(inst_dir, inst_name + "_Definition.xml")
        __empty_vesuvio_ws = LoadEmptyInstrument(Filename=inst_file,
                                                 EnableLogging=_LOGGING_)
        empty_vesuvio = __empty_vesuvio_ws.getInstrument()

        def to_int_list(str_param):
            """Return the list of numbers described by the string range"""
            elements = str_param.split("-")
            return range(int(elements[0]),
                         int(elements[1]) + 1)  # range goes x_l,x_h-1

        # Attach parameters as attributes
        self._inst_prefix = isis.instrument(inst_name).shortName()
        parnames = empty_vesuvio.getParameterNames(False)
        for name in parnames:
            # Irritating parameter access doesn't let you query the type
            # so resort to trying
            try:
                parvalue = empty_vesuvio.getNumberParameter(name)
            except RuntimeError:
                parvalue = empty_vesuvio.getStringParameter(name)
            setattr(self, name, parvalue[0])

        self._mon_spectra = [int(self.monitor_spectrum)]
        self._mon_index = self._mon_spectra[0] - 1

        self._backward_spectra_list = to_int_list(
            self.backward_scatter_spectra)
        self._forward_spectra_list = to_int_list(self.forward_scatter_spectra)
        self._mon_scale = self.monitor_scale
        self._beta = self.double_diff_mixing
        self._tof_max = self.tof_max
        self._mon_tof_max = self.monitor_tof_max

        # Normalisation ranges
        def to_range_tuple(str_range):
            """Return a list of 2 floats giving the lower,upper range"""
            elements = str_range.split("-")
            return (float(elements[0]), float(elements[1]))

        self._back_mon_norm = to_range_tuple(self.backward_monitor_norm)
        self._back_period_sum1 = to_range_tuple(self.backward_period_sum1)
        self._back_period_sum2 = to_range_tuple(self.backward_period_sum2)
        self._back_foil_out_norm = to_range_tuple(self.backward_foil_out_norm)

        self._forw_mon_norm = to_range_tuple(self.forward_monitor_norm)
        self._forw_period_sum1 = to_range_tuple(self.forward_period_sum1)
        self._forw_period_sum2 = to_range_tuple(self.forward_period_sum2)
        self._forw_foil_out_norm = to_range_tuple(self.forward_foil_out_norm)

        DeleteWorkspace(__empty_vesuvio_ws, EnableLogging=_LOGGING_)
Пример #2
0
    def _load_inst_parameters(self):
        """
            Loads an empty VESUVIO instrument and attaches the necessary 
            parameters as attributes 
        """
        isis = config.getFacility("ISIS")
        inst_name = "VESUVIO"
        inst_dir = config.getInstrumentDirectory()
        inst_file = os.path.join(inst_dir, inst_name + "_Definition.xml")
        __empty_vesuvio_ws = LoadEmptyInstrument(Filename=inst_file, EnableLogging=_LOGGING_)
        empty_vesuvio = __empty_vesuvio_ws.getInstrument()
        
        def to_int_list(str_param):
            """Return the list of numbers described by the string range"""
            elements = str_param.split("-")
            return range(int(elements[0]),int(elements[1]) + 1) # range goes x_l,x_h-1
        
        # Attach parameters as attributes
        self._inst_prefix = isis.instrument(inst_name).shortName()
        parnames = empty_vesuvio.getParameterNames(False)
        for name in parnames:
            # Irritating parameter access doesn't let you query the type
            # so resort to trying
            try:
                parvalue = empty_vesuvio.getNumberParameter(name)
            except RuntimeError:
                parvalue = empty_vesuvio.getStringParameter(name)
            setattr(self, name, parvalue[0])

        self._mon_spectra = [int(self.monitor_spectrum)]
        self._mon_index = self._mon_spectra[0] - 1

        self._backward_spectra_list = to_int_list(self.backward_scatter_spectra)
        self._forward_spectra_list = to_int_list(self.forward_scatter_spectra)
        self._tau = self.dead_time_fraction
        self._mon_scale = self.monitor_scale
        self._beta =  self.double_diff_mixing
        self._tof_max = self.tof_max
        self._mon_tof_max = self.monitor_tof_max
        
        # Normalisation ranges
        def to_range_tuple(str_range):
            """Return a list of 2 floats giving the lower,upper range"""
            elements = str_range.split("-")
            return (float(elements[0]),float(elements[1]))
            
        self._back_mon_norm = to_range_tuple(self.backward_monitor_norm)
        self._back_period_sum1 = to_range_tuple(self.backward_period_sum1)
        self._back_period_sum2 = to_range_tuple(self.backward_period_sum2)
        self._back_foil_out_norm = to_range_tuple(self.backward_foil_out_norm)

        self._forw_mon_norm = to_range_tuple(self.forward_monitor_norm)
        self._forw_period_sum1 = to_range_tuple(self.forward_period_sum1)
        self._forw_period_sum2 = to_range_tuple(self.forward_period_sum2)
        self._forw_foil_out_norm = to_range_tuple(self.forward_foil_out_norm)

        DeleteWorkspace(__empty_vesuvio_ws,EnableLogging=_LOGGING_)
Пример #3
0
 def _load_param_file(self, inst_name):
     InstrumentParameters.instrument_name = inst_name
     if IS_IN_MANTIDPLOT:
         idf_loc = config.getInstrumentDirectory()
         idf_pattern = os.path.join(idf_loc, "%s_Definition*.xml") % inst_name
         import glob
         idf_files = glob.glob(idf_pattern)
         emptyInst = LoadEmptyInstrument(Filename=str(idf_files[0]))
         InstrumentParameters._instrument = emptyInst.getInstrument()
         AnalysisDataService.remove(str(emptyInst)) # Don't need to keep workspace
Пример #4
0
 def _load_param_file(self, inst_name):
     InstrumentParameters.instrument_name = inst_name
     if IS_IN_MANTIDPLOT:
         idf_loc = config.getInstrumentDirectory()
         idf_pattern = os.path.join(idf_loc, "%s_Definition*.xml") % inst_name
         import glob
         idf_files = glob.glob(idf_pattern)
         emptyInst = LoadEmptyInstrument(Filename=str(idf_files[0]))
         InstrumentParameters._instrument = emptyInst.getInstrument()
         AnalysisDataService.remove(str(emptyInst)) # Don't need to keep workspace
Пример #5
0
from mantid.simpleapi import LoadEmptyInstrument
import subprocess
import sys
import numpy as np

output = sys.argv[1]

corelli = LoadEmptyInstrument(InstrumentName='CORELLI')
inst = corelli.getInstrument()

def make_fityk_cmd(run, bank, tube):
    fityk_cmd = """@0 < 'COR_{0}_{1}_{2}.txt'
@0: A = a and not (-1 < x and x < 25.5)
@0: A = a and not (229.5 < x and x < 256)
$a = ~0.0
$b = ~282.0
$c = ~128.0
F += Lorentzian(height={3}, center=0.396*0.396*$a-0.396*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.3432*0.3432*$a-0.3432*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.2904*0.2904*$a-0.2904*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.2376*0.2376*$a-0.2376*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.1848*0.1848*$a-0.1848*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.132*0.132*$a-0.132*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.0792*0.0792*$a-0.0792*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.0264*0.0264*$a-0.0264*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.0264*0.0264*$a+0.0264*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.0792*0.0792*$a+0.0792*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.132*0.132*$a+0.132*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.1848*0.1848*$a+0.1848*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.2376*0.2376*$a+0.2376*$b+$c, hwhm=~1.28083)
F += Lorentzian(height={3}, center=0.2904*0.2904*$a+0.2904*$b+$c, hwhm=~1.28083)
Пример #6
0
from mantid.simpleapi import LoadEmptyInstrument, LoadIsawDetCal

cor = LoadEmptyInstrument(InstrumentName='CORELLI')
LoadIsawDetCal(cor, 'SCD_Grouped_calib.results')

i = cor.getInstrument()


def mapBankToABC(i):
    if i < 30:
        return "A" + str(i)
    elif i < 63:
        return "B" + str(i - 29)
    else:
        return "C" + str(i - 62)


print "Location Xsci Ysci Zsci Xrot_sci Yrot_sci Zrot_sci"

for bank in range(1, 92):
    b = i.getComponentByName("bank" + str(bank) + "/sixteenpack")
    x = b.getPos().getX() * 1000
    y = b.getPos().getY() * 1000
    z = b.getPos().getZ() * 1000
    [beta, alpha, gamma] = b.getRotation().getEulerAngles("YXZ")
    print mapBankToABC(bank), x, y, z, alpha, beta, gamma
            assert np.alltrue(x > 0.)
        # confirm which quadrants things are in - z-axis
        if name in ['bank3', 'bank4', 'bank5']:
            assert np.alltrue(z < 0.)
        if name in ["bank6"]:
            assert np.alltrue(z > 0.)

    # -- Verify center positions of 8-packs in each bank
    # bank_1: 20
    # bank_2: 20
    # bank_3: 18
    # bank_4: 18
    # bank_5: 9
    # bank_6: 11
    logging.info("Verify center positions of 8-packs in each bank.")
    instr = vulcan.getInstrument()
    offset = 2  # bank1 is the 4th item in the list
    for bank_id in df_survey[lb_bank].unique():
        # from survey measurements
        bank_survey = df_survey[df_survey[lb_bank] == bank_id]
        centers_survey = bank_survey.groupby(lb_8pack).mean()[lb_pos]
        logging.info(
            f"Bank {bank_id}'s 8-pack center positions from survey:\n{centers_survey}"
        )
        # from IDF
        bank_id_mantid = int(bank_id) + offset
        bank_mantid = instr[bank_id_mantid]
        centers_mantid = np.array([
            bank_mantid[pack_id].getPos()
            for pack_id in range(bank_mantid.nelements())
        ])