From fab96da709e63538a0333f6d25cd255a4131dd6c Mon Sep 17 00:00:00 2001 From: Brendan Sullivan <sullivanbt@ornl.gov> Date: Thu, 26 Jul 2018 12:34:31 -0400 Subject: [PATCH] Re #22811 move parameters from algorithms to param files --- .../IntegratePeaksProfileFitting.py | 36 +++++++------------ instrument/CORELLI_Parameters.xml | 30 ++++++++++++++++ instrument/MANDI_Parameters.xml | 28 +++++++++++++++ instrument/MANDI_Parameters_2015_08_01.xml | 30 ++++++++++++++++ instrument/MANDI_Parameters_2016_02_01.xml | 30 ++++++++++++++++ instrument/TOPAZ_Parameters.xml | 29 +++++++++++++++ scripts/SCD_Reduction/BVGFitTools.py | 8 +++-- scripts/SCD_Reduction/ICCFitTools.py | 10 +++--- 8 files changed, 169 insertions(+), 32 deletions(-) diff --git a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py index b2363518668..c38a7219d37 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 b560efec73c..a8167e41032 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 8833ec7f5d2..dcaa2ca55f3 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 656e899ba71..fef3a0458b8 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 c3471773d9f..9b8c188b408 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 0151036048a..ff52c5ebdd2 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 e09de245865..72d9972b0cf 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 d4a4f045639..9c378f849d4 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: -- GitLab