diff --git a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py index b236351866857910ad02204a1d7043733e135d5d..c38a7219d374715edcdcb12afc7f09ac69f36c5a 100644 --- a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py +++ b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py @@ -116,30 +116,18 @@ class IntegratePeaksProfileFitting(PythonAlgorithm): # statement. # If you change these values or add an instrument, documentation should also be changed. instrumentName = peaks_ws.getInstrument().getFullName() - mindtBinWidth = 15 - maxdtBinWidth = 50 - nTheta = 50 - nPhi = 50 - fracHKL = 0.4 - dQPixel = 0.003 - if instrumentName == 'MANDI': - pass - elif instrumentName == 'TOPAZ': - mindtBinWidth = 2 - maxdtBinWidth = 15 - nTheta=50 - nPhi = 50 - fracHKL = 0.4 - dQPixel = 0.01 - elif instrumentName == 'CORELLI': - mindtBinWidth = 2 - maxdtBinWidth = 60 - nTheta=50 - nPhi = 50 - fracHKL = 0.4 - dQPixel = 0.007 - else: - logger.warning("Instrument name {} not found! Falling back on default parameters!".format(instrumentName)) + try: + nTheta = peaks_ws.getInstrument().getIntParameter("numBinsTheta")[0] + nPhi = peaks_ws.getInstrument().getIntParameter("numBinsPhi")[0] + mindtBinWidth = peaks_ws.getInstrument().getNumberParameter("mindtBinWidth")[0] + maxdtBinWidth = peaks_ws.getInstrument().getNumberParameter("maxdtBinWidth")[0] + fracHKL = peaks_ws.getInstrument().getNumberParameter("fracHKL")[0] + dQPixel = peaks_ws.getInstrument().getNumberParameter("dQPixel")[0] + + except: + raise + logger.error("Cannot find all parameters in instrument parameters file.") + sys.exit(1) neigh_length_m=3 qMask = ICCFT.getHKLMask(UBMatrix, frac=fracHKL, dQPixel=dQPixel,dQ=dQ) diff --git a/instrument/CORELLI_Parameters.xml b/instrument/CORELLI_Parameters.xml index b560efec73c1cd93385ca7ed68564c689f3ad500..a8167e41032a155093b0974bd876569c1efb2afb 100644 --- a/instrument/CORELLI_Parameters.xml +++ b/instrument/CORELLI_Parameters.xml @@ -40,6 +40,36 @@ <value val="16" /> </parameter> + <!-- Number of polar bins for BVG histogramming when profile fitting --> + <parameter name="numBinsTheta" type="int"> + <value val="50" /> + </parameter> + + <!-- Number of azimuthal bins for BVG histogramming when profile fitting --> + <parameter name="numBinsPhi" type="int"> + <value val="50" /> + </parameter> + + <!-- Fraction along (h,k,l) to use for profile fitting. 0.5 is the next peak. --> + <parameter name="fracHKL"> + <value val="0.4" /> + </parameter> + + <!-- Side length of each voxel for fitting in units of angstrom^-1 --> + <parameter name="dQPixel"> + <value val="0.007" /> + </parameter> + + <!-- Minimum spacing for profile fitting the TOF profile. Units of microseconds --> + <parameter name="mindtBinWidth"> + <value val="2" /> + </parameter> + + <!-- Maximum spacing for profile fitting the TOF profile. Units of microseconds --> + <parameter name="maxdtBinWidth"> + <value val="60" /> + </parameter> + </component-link> </parameter-file> diff --git a/instrument/MANDI_Parameters.xml b/instrument/MANDI_Parameters.xml index 8833ec7f5d2683aab7531444d12c1d848f0ea291..dcaa2ca55f34d097f1ae10aa39203bc200936920 100644 --- a/instrument/MANDI_Parameters.xml +++ b/instrument/MANDI_Parameters.xml @@ -33,7 +33,35 @@ <value val="255" /> </parameter> +<!-- Number of polar bins for BVG histogramming when profile fitting --> +<parameter name="numBinsTheta" type="int"> + <value val="50" /> +</parameter> + +<!-- Number of azimuthal bins for BVG histogramming when profile fitting --> +<parameter name="numBinsPhi" type="int"> + <value val="50" /> +</parameter> + +<!-- Fraction along (h,k,l) to use for profile fitting. 0.5 is the next peak. --> +<parameter name="fracHKL"> + <value val="0.4" /> +</parameter> +<!-- Side length of each voxel for fitting in units of angstrom^-1 --> +<parameter name="dQPixel"> + <value val="0.003" /> +</parameter> + +<!-- Minimum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="mindtBinWidth"> + <value val="15" /> +</parameter> + +<!-- Maximum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="maxdtBinWidth"> + <value val="50" /> +</parameter> </component-link> diff --git a/instrument/MANDI_Parameters_2015_08_01.xml b/instrument/MANDI_Parameters_2015_08_01.xml index 656e899ba714c327f673a32cec910509ffe66c4e..fef3a0458b8cc5c3ac2c73e20efe0243479dba1e 100644 --- a/instrument/MANDI_Parameters_2015_08_01.xml +++ b/instrument/MANDI_Parameters_2015_08_01.xml @@ -33,6 +33,36 @@ <value val="255" /> </parameter> +<!-- Number of polar bins for BVG histogramming when profile fitting --> +<parameter name="numBinsTheta" type="int"> + <value val="50" /> +</parameter> + +<!-- Number of azimuthal bins for BVG histogramming when profile fitting --> +<parameter name="numBinsPhi" type="int"> + <value val="50" /> +</parameter> + +<!-- Fraction along (h,k,l) to use for profile fitting. 0.5 is the next peak. --> +<parameter name="fracHKL"> + <value val="0.4" /> +</parameter> + +<!-- Side length of each voxel for fitting in units of angstrom^-1 --> +<parameter name="dQPixel"> + <value val="0.003" /> +</parameter> + +<!-- Minimum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="mindtBinWidth"> + <value val="15" /> +</parameter> + +<!-- Maximum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="maxdtBinWidth"> + <value val="50" /> +</parameter> + </parameter-file> diff --git a/instrument/MANDI_Parameters_2016_02_01.xml b/instrument/MANDI_Parameters_2016_02_01.xml index c3471773d9fc8a338907a93c18d8017cce6b848b..9b8c188b40864e7dc1ee1d3a62e31b365eb94865 100644 --- a/instrument/MANDI_Parameters_2016_02_01.xml +++ b/instrument/MANDI_Parameters_2016_02_01.xml @@ -33,4 +33,34 @@ <value val="255" /> </parameter> +<!-- Number of polar bins for BVG histogramming when profile fitting --> +<parameter name="numBinsTheta" type="int"> + <value val="50" /> +</parameter> + +<!-- Number of azimuthal bins for BVG histogramming when profile fitting --> +<parameter name="numBinsPhi" type="int"> + <value val="50" /> +</parameter> + +<!-- Fraction along (h,k,l) to use for profile fitting. 0.5 is the next peak. --> +<parameter name="fracHKL"> + <value val="0.4" /> +</parameter> + +<!-- Side length of each voxel for fitting in units of angstrom^-1 --> +<parameter name="dQPixel"> + <value val="0.003" /> +</parameter> + +<!-- Minimum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="mindtBinWidth"> + <value val="15" /> +</parameter> + +<!-- Maximum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="maxdtBinWidth"> + <value val="50" /> +</parameter> + </parameter-file> diff --git a/instrument/TOPAZ_Parameters.xml b/instrument/TOPAZ_Parameters.xml index 0151036048a5a26c7aa4f368c81d67280df32d0b..ff52c5ebdd2cdd69984ebe66a7981c8dcd1dae07 100644 --- a/instrument/TOPAZ_Parameters.xml +++ b/instrument/TOPAZ_Parameters.xml @@ -109,6 +109,35 @@ detScale={13:1.046504,14:1.259293,16:1.02449,17:1.18898,18:0.88014,19:0.98665,\ <value val="255" /> </parameter> +<!-- Number of polar bins for BVG histogramming when profile fitting --> +<parameter name="numBinsTheta" type="int"> + <value val="50" /> +</parameter> + +<!-- Number of azimuthal bins for BVG histogramming when profile fitting --> +<parameter name="numBinsPhi" type="int"> + <value val="50" /> +</parameter> + +<!-- Fraction along (h,k,l) to use for profile fitting. 0.5 is the next peak. --> +<parameter name="fracHKL"> + <value val="0.4" /> +</parameter> + +<!-- Side length of each voxel for fitting in units of angstrom^-1 --> +<parameter name="dQPixel"> + <value val="0.01" /> +</parameter> + +<!-- Minimum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="mindtBinWidth"> + <value val="2" /> +</parameter> + +<!-- Maximum spacing for profile fitting the TOF profile. Units of microseconds --> +<parameter name="maxdtBinWidth"> + <value val="15" /> +</parameter> </component-link> diff --git a/scripts/SCD_Reduction/BVGFitTools.py b/scripts/SCD_Reduction/BVGFitTools.py index e09de245865b87b13a131d1f9235ca9875b6592d..72d9972b0cfc46c4b5b9172a5a9d46df515c5c82 100644 --- a/scripts/SCD_Reduction/BVGFitTools.py +++ b/scripts/SCD_Reduction/BVGFitTools.py @@ -15,7 +15,7 @@ def get3DPeak(peak, peaks_ws, box, padeCoefficients, qMask, nTheta=150, nPhi=150 plotResults=False, zBG=1.96, bgPolyOrder=1, fICCParams=None, oldICCFit=None, strongPeakParams=None, forceCutoff=250, edgeCutoff=15, neigh_length_m=3, q_frame='sample', dtSpread=0.03, pplmin_frac=0.8, pplmax_frac=1.5, mindtBinWidth=1, - maxdtBinWidth=50, figureNumber=2): + maxdtBinWidth=50, figureNumber=2, instrumentName=None): n_events = box.getNumEventsArray() if q_frame == 'lab': @@ -30,11 +30,13 @@ def get3DPeak(peak, peaks_ws, box, padeCoefficients, qMask, nTheta=150, nPhi=150 goodIDX, pp_lambda = ICCFT.getBGRemovedIndices( n_events, peak=peak, box=box, qMask=qMask, calc_pp_lambda=True, padeCoefficients=padeCoefficients, neigh_length_m=neigh_length_m, pp_lambda=None, pplmin_frac=pplmin_frac, - pplmax_frac=pplmax_frac, mindtBinWidth=mindtBinWidth, maxdtBinWidth=maxdtBinWidth) + pplmax_frac=pplmax_frac, mindtBinWidth=mindtBinWidth, maxdtBinWidth=maxdtBinWidth, + instrumentName=instrumentName) YTOF, fICC, x_lims = fitTOFCoordinate( box, peak, padeCoefficients, dtSpread=dtSpread, qMask=qMask, bgPolyOrder=bgPolyOrder, zBG=zBG, plotResults=plotResults, pp_lambda=pp_lambda, neigh_length_m=neigh_length_m, pplmin_frac=pplmin_frac, - pplmax_frac=pplmax_frac, mindtBinWidth=mindtBinWidth, maxdtBinWidth=maxdtBinWidth) + pplmax_frac=pplmax_frac, mindtBinWidth=mindtBinWidth, maxdtBinWidth=maxdtBinWidth, + instrumentName=instrumentName) chiSqTOF = mtd['fit_Parameters'].column(1)[-1] else: # we already did I-C profile, so we'll just read the parameters diff --git a/scripts/SCD_Reduction/ICCFitTools.py b/scripts/SCD_Reduction/ICCFitTools.py index d4a4f04563980fc2f6a0b28af2ed1931b56d3d5f..9c378f849d491c4bdbcb0743d6bfa6b1a3648fb5 100644 --- a/scripts/SCD_Reduction/ICCFitTools.py +++ b/scripts/SCD_Reduction/ICCFitTools.py @@ -197,7 +197,7 @@ def getPoissionGoodIDX(n_events, zBG=1.96, neigh_length_m=3): def getOptimizedGoodIDX(n_events, padeCoefficients, zBG=1.96, neigh_length_m=3, qMask=None, peak=None, box=None, pp_lambda=None, peakNumber=-1, minppl_frac=0.8, maxppl_frac=1.5, mindtBinWidth=1, maxdtBinWidth=50, - constraintScheme=1, instrumentName=None): + constraintScheme=1, instrumentName=None, peakMaskSize=5): """ getOptimizedGoodIDX - returns a numpy arrays which is true if the voxel contains events at the zBG z level (1.96=95%CI). Rather than using Poission statistics, this function @@ -245,12 +245,12 @@ def getOptimizedGoodIDX(n_events, padeCoefficients, zBG=1.96, neigh_length_m=3, cX = nX//2 cY = nY//2 cZ = nZ//2 - dP = 5 - + dP = peakMaskSize if instrumentName == 'TOPAZ': dP = 15 - if instrumentName == 'CORELLI': + elif instrumentName == 'CORELLI': dP = 10 + peakMask = qMask.copy() peakMask[cX-dP:cX+dP, cY-dP:cY+dP, cZ-dP:cZ+dP] = 0 neigh_length_m=3 @@ -318,7 +318,7 @@ def getOptimizedGoodIDX(n_events, padeCoefficients, zBG=1.96, neigh_length_m=3, def getBGRemovedIndices(n_events, zBG=1.96, calc_pp_lambda=False, neigh_length_m=3, qMask=None, peak=None, box=None, pp_lambda=None, peakNumber=-1, padeCoefficients=None, pplmin_frac=0.8, pplmax_frac=1.5, mindtBinWidth=1, maxdtBinWidth=50, - constraintScheme=1, instrumentName=None): + constraintScheme=1, instrumentName=None, peakMaskSize=5): """ getBGRemovedIndices - A wrapper for getOptimizedGoodIDX Input: