Example #1
0
def changeMarginAndExpectedValue(filename):
    """
    To fit correctly, it is important to have a good window around the peak. This windown is defined
    by the **margin** parameter.

    This examples shows how the results worsen if we change the margin from its default value **15**
    to **10**.

    It shows how to see the fitted values using the **plotTube** parameter.

    It will also output the peaks position and save them, through the **outputPeak** option and
    the :func:`tube.savePeak` method.

    An example of the fitted data compared to the acquired data to find the peaks positions:

    .. image:: /images/calibratePlotFittedData.png

    The result deteriorate, as you can see:

    .. image:: /images/calibrateChangeMarginAndExpectedValue.png

    """
    from tube_calib_fit_params import TubeCalibFitParams
    CalibInstWS = loadingStep(filename)
    # == Set parameters for calibration ==
    # Set what we want to calibrate (e.g whole instrument or one door )
    CalibratedComponent = 'MAPS'  # Calibrate all
    # define the known positions and function factor (edge, peak, peak, peak, edge)
    knownPos, funcFactor = [-0.50, -0.16, -0.00, 0.16, 0.50], [2, 1, 1, 1, 2]

    # the expected positions in pixels for the special points
    expectedPositions = [4.0, 85.0, 128.0, 161.0, 252.0]
    fitPar = TubeCalibFitParams(expectedPositions)
    fitPar.setAutomatic(True)

    # == Get the calibration and put results into calibration table ==
    calibrationTable, peakTable = tube.calibrate(CalibInstWS,
                                                 CalibratedComponent,
                                                 knownPos,
                                                 funcFactor,
                                                 fitPar=fitPar,
                                                 plotTube=[1, 10, 100],
                                                 outputPeak=True,
                                                 margin=10)
    # == Apply the Calibation ==
    mantid.ApplyCalibration(Workspace=CalibInstWS,
                            CalibrationTable=calibrationTable)

    tube.savePeak(peakTable, 'TubeDemoMaps01.txt')
Example #2
0
def changeMarginAndExpectedValue(filename):
    """
    To fit correcly, it is important to have a good window around the peak. This windown is defined
    by the **margin** parameter.

    This examples shows how the results worsen if we change the margin from its default value **15**
    to **10**.

    It shows how to see the fitted values using the **plotTube** parameter.

    It will also output the peaks position and save them, through the **outputPeak** option and
    the :func:`tube.savePeak` method.

    An example of the fitted data compared to the acquired data to find the peaks positions:

    .. image:: /images/calibratePlotFittedData.png

    The result deteriorate, as you can see:

    .. image:: /images/calibrateChangeMarginAndExpectedValue.png

    """
    from tube_calib_fit_params import TubeCalibFitParams
    CalibInstWS = loadingStep(filename)
    # == Set parameters for calibration ==
    # Set what we want to calibrate (e.g whole intrument or one door )
    CalibratedComponent = 'MAPS'  # Calibrate all
    # define the known positions and function factor (edge, peak, peak, peak, edge)
    knownPos, funcFactor = [-0.50,-0.16,-0.00, 0.16, 0.50 ],[2,1,1,1,2]

    # the expected positions in pixels for the special points
    expectedPositions = [4.0, 85.0, 128.0, 161.0, 252.0]
    fitPar = TubeCalibFitParams(expectedPositions)
    fitPar.setAutomatic(True)

    # == Get the calibration and put results into calibration table ==
    calibrationTable, peakTable= tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcFactor,
                                                fitPar=fitPar, plotTube=[1,10,100], outputPeak=True, margin=10)
    # == Apply the Calibation ==
    ApplyCalibration( Workspace=CalibInstWS, PositionTable=calibrationTable)

    tube.savePeak(peakTable, 'TubeDemoMaps01.txt')
Example #3
0
# Get fitting parameters
fitPar = TubeCalibFitParams(ExpectedPositions, ExpectedHeight, ExpectedWidth)
fitPar.setAutomatic(True)

print("Created objects needed for calibration.")

# == Get the calibration and put results into calibration table ==
# also put peaks into PeakFile
calibrationTable, peakTable = tube.calibrate(CalibInstWS,
                                             CalibratedComponent,
                                             knownPos,
                                             funcForm,
                                             fitPar=fitPar,
                                             outputPeak=True)
print("Got calibration (new positions of detectors) ")

# == Apply the Calibation ==
mantid.ApplyCalibration(Workspace=CalibInstWS, PositionTable=calibrationTable)
print("Applied calibration")

# == Save workspace ==
mantid.SaveNexusProcessed(CalibInstWS, 'TubeCalibDemoMapsResult.nxs',
                          "Result of Running TCDemoMaps_B1.py")
print(
    "saved calibrated workspace (CalibInstWS) into Nexus file TubeCalibDemoMapsResult.nxs"
)

# == Save Peak File ==
tube.savePeak(peakTable, 'TubeDemoMaps01.txt')
Example #4
0
# == Create Objects needed for calibration ==
# The positions of the shadows and ends here are an intelligent guess.
# First array gives positions in Metres and second array gives type 1=Gaussian peak 2=edge.
# See http://www.mantidproject.org/IdealTube for details.
knownPos = [-0.50, -0.165, -0.00, 0.165, 0.50]
funcForm = [2, 1, 1, 1, 2]

# Get fitting parameters
fitPar = TubeCalibFitParams(ExpectedPositions, ExpectedHeight, ExpectedWidth)
fitPar.setAutomatic(True)

print("Created objects needed for calibration.")

# == Get the calibration and put results into calibration table ==
# also put peaks into PeakFile
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcForm,
                                             fitPar=fitPar, outputPeak=True)
print("Got calibration (new positions of detectors) ")

# == Apply the Calibation ==
mantid.ApplyCalibration(Workspace=CalibInstWS, PositionTable=calibrationTable)
print("Applied calibration")

# == Save workspace ==
mantid.SaveNexusProcessed(CalibInstWS, 'TubeCalibDemoMapsResult.nxs', "Result of Running TCDemoMaps_B1.py")
print("saved calibrated workspace (CalibInstWS) into Nexus file TubeCalibDemoMapsResult.nxs")

# == Save Peak File ==
tube.savePeak(peakTable, 'TubeDemoMaps01.txt')