-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This function needs a second argument to specify the panel to calibration, because each calibration run deals with only one panel. Also the arguments are string rather than numbers. Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
- Loading branch information
1 parent
474f59a
commit b01b9bc
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
Code/Mantid/scripts/Calibration/Examples/TubeCalibDemoWish_Simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# | ||
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR WISH | ||
# | ||
# Here we run the calibration of WISH panel03 using a simple CalibrateWish function. | ||
# | ||
from mantid.api import WorkspaceFactory # For table worskspace of calibrations | ||
from ideal_tube import * # for ideal tube | ||
from tube_calib_fit_params import * # To handle fit parameters | ||
from tube_calib import * # For tube calibration functions | ||
from tube_spec import * # For tube specification class | ||
|
||
def CalibrateWish( RunNumber, PanelNumber ): | ||
''' | ||
RunNumber is the run number as a string and including any leading zeros that would occur in the raw file name. | ||
PanelNumber is the two-digit number of the panel being calibrated | ||
''' | ||
# == Set parameters for calibration == | ||
filename = 'WISH'+RunNumber+".raw" | ||
CalibratedComponent = 'WISH/panel'+PanelNumber | ||
|
||
|
||
# Get calibration raw file and integrate it | ||
print "Loading",filename | ||
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated. | ||
CalibInstWS = Integration( rawCalibInstWS, RangeLower=1, RangeUpper=20000 ) | ||
DeleteWorkspace(rawCalibInstWS) | ||
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate" | ||
|
||
#Create Calibration Table | ||
calibrationTable = CreateEmptyTableWorkspace(OutputWorkspace="CalibTable") | ||
calibrationTable.addColumn(type="int",name="Detector ID") # "Detector ID" column required by ApplyCalibration | ||
calibrationTable.addColumn(type="V3D",name="Detector Position") # "Detector Position" column required by ApplyCalibration | ||
|
||
# Specify panel of WISH instrument | ||
thisTubeSet = TubeSpec(CalibInstWS) | ||
print "Calibrating",CalibratedComponent | ||
thisTubeSet.setTubeSpecByString(CalibratedComponent) | ||
|
||
# Give y-positions of slit points (gotten for converting first tube's slit point to Y) | ||
iTube = IdealTube() | ||
iTube.setArray([-0.41,-0.31,-0.21,-0.11,-0.02, 0.09, 0.18, 0.28, 0.39 ]) | ||
|
||
# Set fitting parameters | ||
eP = [57.5, 107.0, 156.5, 206.0, 255.5, 305.0, 354.5, 404.0, 453.5] | ||
fitPar = TubeCalibFitParams( eP, 2000, 32 ) | ||
|
||
print "Created objects needed for calibration." | ||
|
||
# Get the calibration and put it into the calibration table | ||
getCalibration( CalibInstWS, thisTubeSet, calibrationTable, fitPar, iTube) | ||
print "Got calibration (new positions of detectors)" | ||
|
||
#Apply the calibration | ||
ApplyCalibration( Workspace=CalibInstWS, PositionTable=calibrationTable) | ||
print "Applied calibration" | ||
|
||
# == Save workspace == | ||
nexusName = "TubeCalibDemoWish"+PanelNumber+"Result.nxs" | ||
SaveNexusProcessed( CalibInstWS, 'TubeCalibDemoWishResult.nxs',"Result of Running TubeCalibWishMerlin_Simple.py") | ||
print "saved calibrated workspace (CalibInstWS) into Nexus file",nexusName | ||
|
||
# ==== End of CalibrateWish() ==== | ||
|
||
CalibrateWish( '00017701', '03' ) |