コード例 #1
0
def create_calibration_cropped_file(ceria_run, van_run, curve_van, int_van, calibration_directory, calibration_general,
                                    use_spectrum_number, crop_name, spec_nos):
    """
    create and save a cropped calibration file

    @param ceria_run :: run number for the ceria used
    @param van_run :: the run number of the vanadium to use
    @param curve_van :: name of the vanadium curves workspace
    @param int_van :: name of the integrated vanadium workspace
    @param calibration_directory :: the user specific calibration directory to save to
    @param calibration_general :: the general calibration dirrecory
    @param use_spectrum_number :: whether or not to crop using spectrum numbers  or banks
    @param crop_name :: name of the output workspace
    @param spec_nos :: the value to crop on, either a spectra number, or a bank

    """
    van_curves_ws, van_integrated_ws = load_van_files(curve_van, int_van)
    ceria_ws = simple.Load(Filename="ENGINX" + ceria_run, OutputWorkspace="eng_calib")
    # check which cropping method to use
    if use_spectrum_number:
        param_tbl_name = crop_name if crop_name is not None else "cropped"
        # run the calibration cropping on spectrum number
        output = simple.EnggCalibrate(InputWorkspace=ceria_ws, VanIntegrationWorkspace=van_integrated_ws,
                                      VanCurvesWorkspace=van_curves_ws, SpectrumNumbers=str(spec_nos),
                                      FittedPeaks=param_tbl_name,
                                      OutputParametersTableName=param_tbl_name)
        # get the values needed for saving out the .prm files
        difc = [output.DIFC]
        tzero = [output.TZERO]
        difa = [output.DIFA]
        save_calibration(ceria_run, van_run, calibration_directory, calibration_general, "all_banks", [param_tbl_name],
                         tzero, difc, difa)
        save_calibration(ceria_run, van_run, calibration_directory, calibration_general,
                         "bank_{}".format(param_tbl_name), [param_tbl_name], tzero, difc, difa)
    else:
        # work out which bank number to crop on, then calibrate
        if spec_nos.lower() == "north":
            param_tbl_name = "engg_calibration_bank_1"
            bank = 1
        else:
            param_tbl_name = "engg_calibration_bank_2"
            bank = 2
        output = simple.EnggCalibrate(InputWorkspace=ceria_ws, VanIntegrationWorkspace=van_integrated_ws,
                                      VanCurvesWorkspace=van_curves_ws, Bank=str(bank), FittedPeaks=param_tbl_name,
                                      OutputParametersTableName=param_tbl_name)
        # get the values needed for saving out the .prm files
        difc = [output.DIFC]
        tzero = [output.TZERO]
        difa = [output.DIFA]
        save_calibration(ceria_run, van_run, calibration_directory, calibration_general, "all_banks", [spec_nos], tzero,
                         difc, difa)
        save_calibration(ceria_run, van_run, calibration_directory, calibration_general, "bank_{}".format(spec_nos),
                         [spec_nos], tzero, difc, difa)
    # create the table workspace containing the parameters
    create_params_table(difc, tzero, difa)
    create_difc_zero_workspace(difc, tzero, spec_nos, param_tbl_name)
コード例 #2
0
    def test_runs_ok(self):
        """
        Checks normal operation.
        """

        difc, zero, peaks = sapi.EnggCalibrate(
            InputWorkspace=self.__class__._data_ws,
            VanIntegrationWorkspace=self.__class__._van_integ_tbl,
            VanCurvesWorkspace=self.__class__._van_curves_ws,
            ExpectedPeaks=[1.6, 1.1, 1.8],
            Bank='2')

        self.check_3peaks_values(difc, zero)
コード例 #3
0
    def test_runs_ok_with_peaks_file(self):
        """
        Normal operation with a csv input file with expected peaks
        """
        # This file has: 1.6, 1.1, 1.8 (as the test above)
        filename = 'EnginX_3_expected_peaks_unittest.csv'
        difc, zero, peaks = sapi.EnggCalibrate(
            InputWorkspace=self.__class__._data_ws,
            VanIntegrationWorkspace=self.__class__._van_integ_tbl,
            VanCurvesWorkspace=self.__class__._van_curves_ws,
            ExpectedPeaks=[-4, 40,
                           323],  # nonsense, but FromFile should prevail
            ExpectedPeaksFromFile=filename,
            Bank='2')

        self.check_3peaks_values(difc, zero)
コード例 #4
0
ファイル: EnggCalibrateTest.py プロジェクト: mcvine/mantid
    def test_runs_ok_without_reliable_peaks(self):
        """
        Checks normal operation.
        """
        try:
            difa, difc, zero, peaks = sapi.EnggCalibrate(InputWorkspace=self.__class__._data_ws,
                                                         VanIntegrationWorkspace=self.__class__._van_integ_tbl,
                                                         VanCurvesWorkspace=self.__class__._van_curves_ws,
                                                         ExpectedPeaks=[1.6, 1.1, 1.8], Bank='2')
            self.assertEquals(difa, 0)
            self.assertGreater(difc, 0)
            self.assertLess(abs(zero), 1000)
            self.assertEquals(peaks.rowCount(), 3)

        except RuntimeError:
            pass
コード例 #5
0
def create_calibration_files(ceria_run, van_run, curve_van, int_van,
                             calibration_directory, calibration_general):
    """
    create the calibration files for an uncropped run

    @param ceria_run :: the run number of the ceria
    @param van_run :: the run number of the vanadium
    @param curve_van :: the vanadium curves workspace
    @param int_van :: the integrated vanadium workspace
    @param calibration_directory :: the user specific calibration directory to save to
    @param calibration_general :: the general calibration directory

    """
    van_curves_ws, van_integrated_ws = load_van_files(curve_van, int_van)
    ceria_ws = simple.Load(Filename="ENGINX" + ceria_run,
                           OutputWorkspace="eng_calib")
    difcs = []
    tzeros = []
    difa = []
    banks = 3
    bank_names = ["North", "South"]
    # loop through the banks, calibrating both
    for i in range(1, banks):
        param_tbl_name = "engg_calibration_bank_{}".format(i)
        output = simple.EnggCalibrate(
            InputWorkspace=ceria_ws,
            VanIntegrationWorkspace=van_integrated_ws,
            VanCurvesWorkspace=van_curves_ws,
            Bank=str(i),
            FittedPeaks=param_tbl_name,
            OutputParametersTableName=param_tbl_name)
        # add the needed outputs to a list
        difcs.append(output.DIFC)
        tzeros.append(output.TZERO)
        difa.append(output.DIFA)
        # save out the ones needed for this loop
        save_calibration(ceria_run, van_run, calibration_directory,
                         calibration_general,
                         "bank_{}".format(bank_names[i - 1]),
                         [bank_names[i - 1]], [tzeros[i - 1]], [difcs[i - 1]])
    # save out the total version, then create the table of params
    save_calibration(ceria_run, van_run, calibration_directory,
                     calibration_general, "all_banks", bank_names, tzeros,
                     difcs)
    create_params_table(difcs, tzeros, difa)
    create_difc_zero_workspace(difcs, tzeros, "", None)
コード例 #6
0
ファイル: EnggCalibrateTest.py プロジェクト: mcvine/mantid
    def test_runs_ok_with_bad_peaks_file(self):
        """
        Normal operation with a csv input file with (poor / impossible) expected peaks
        """
        # This file has: 1.6, 1.1, 1.8 (as the test above)
        filename = 'EnginX_3_expected_peaks_unittest.csv'
        try:
            difa, difc, zero, peaks = sapi.EnggCalibrate(InputWorkspace=self.__class__._data_ws,
                                                         VanIntegrationWorkspace=self.__class__._van_integ_tbl,
                                                         VanCurvesWorkspace=self.__class__._van_curves_ws,
                                                         # nonsense, but FromFile should prevail
                                                         ExpectedPeaks=[-4, 40, 323],
                                                         ExpectedPeaksFromFile=filename,
                                                         Bank='2')
            self.assertEquals(difa, 0)
            self.assertGreater(difc, 0)
            self.assertLess(abs(zero), 1000)
            self.assertEquals(peaks.rowCount(), 3)

        except RuntimeError:
            pass