diff --git a/Code/Mantid/Framework/API/src/FileFinder.cpp b/Code/Mantid/Framework/API/src/FileFinder.cpp index 966672dd74a96570741b33d647f89a9d7edfa9a3..433438157b99d7ee2c4a2335cb8b75179cfe0851 100644 --- a/Code/Mantid/Framework/API/src/FileFinder.cpp +++ b/Code/Mantid/Framework/API/src/FileFinder.cpp @@ -14,6 +14,7 @@ #include <Poco/Path.h> #include <Poco/File.h> #include <Poco/StringTokenizer.h> +#include <Poco/RegularExpression.h> #include <boost/lexical_cast.hpp> #include <cctype> @@ -566,6 +567,12 @@ namespace Mantid int runNumber = boost::lexical_cast<int>(run); std::string runEnd = run; runEnd.replace(runEnd.end() - range[1].size(), runEnd.end(), range[1]); + + // Throw if runEnd contains something else other than a digit. + Poco::RegularExpression digits("[0-9]+"); + if (!digits.match(runEnd)) + throw std::invalid_argument("Malformed range of runs: Part of the run has a non-digit character in it."); + int runEndNumber = boost::lexical_cast<int>(runEnd); if (runEndNumber < runNumber) { diff --git a/Code/Mantid/Framework/API/test/FileFinderTest.h b/Code/Mantid/Framework/API/test/FileFinderTest.h index 0d3cb26e7f31c18690440a3155f0ec18ea0aaa87..c64f5e54f10935cedbc0fc6ebfb5942105a6b480 100644 --- a/Code/Mantid/Framework/API/test/FileFinderTest.h +++ b/Code/Mantid/Framework/API/test/FileFinderTest.h @@ -4,6 +4,7 @@ #include <cxxtest/TestSuite.h> #include "MantidAPI/FileFinder.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/Exception.h" #include <Poco/Path.h> #include <Poco/File.h> @@ -186,9 +187,16 @@ public: void testFindFiles() { ConfigService::Instance().setString("default.facility","ISIS"); - std::vector<std::string> files = FileFinder::Instance().findRuns("MUSR15189-15199"); + std::vector<std::string> files; + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189-n15199"), std::invalid_argument); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189n-15199"), std::invalid_argument); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189-15199n"), std::invalid_argument); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189-151n99"), std::invalid_argument); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15n189-151n99"), Exception::NotFoundError); + TS_ASSERT_THROWS_NOTHING(files = FileFinder::Instance().findRuns("MUSR15189-15199")); TS_ASSERT_EQUALS(files.size(), 11); std::vector<std::string>::iterator it = files.begin(); + for (; it != files.end(); ++it) { if (it != files.begin()) diff --git a/Code/Mantid/Framework/Algorithms/src/ExtractMasking.cpp b/Code/Mantid/Framework/Algorithms/src/ExtractMasking.cpp index 318a7b0801ceca2d6c7a7b9920a9a256e0abffcf..9d7c0ab2881d82bbb1c33b0aae052ff095f29d4a 100644 --- a/Code/Mantid/Framework/Algorithms/src/ExtractMasking.cpp +++ b/Code/Mantid/Framework/Algorithms/src/ExtractMasking.cpp @@ -13,6 +13,7 @@ The spectra containing 0 are also marked as masked and the instrument link is pr //------------------------------------------------------------------------------ #include "MantidAlgorithms/ExtractMasking.h" #include "MantidAPI/SpectraDetectorMap.h" +#include "MantidDataObjects/SpecialWorkspace2D.h" #include "MantidKernel/MultiThreaded.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/NullValidator.h" @@ -70,7 +71,8 @@ namespace Mantid const int nHist = static_cast<int>(inputWS->getNumberHistograms()); const int xLength(1), yLength(1); // Create a new workspace for the results, copy from the input to ensure that we copy over the instrument and current masking - MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create(inputWS, nHist, xLength, yLength); + MatrixWorkspace_sptr outputWS = MatrixWorkspace_sptr(new DataObjects::SpecialWorkspace2D(inputWS->getInstrument())); + outputWS->setTitle(inputWS->getTitle()); Progress prog(this,0.0,1.0,nHist); MantidVecPtr xValues; diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/UnitCell.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/UnitCell.h index fdce801da030683d89444913d3a3d1f39ac7175a..67762dbdc57b375c66ed0be0288cdb2f1ba2d8d8 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/UnitCell.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/UnitCell.h @@ -73,6 +73,7 @@ namespace Geometry double alpha2() const; double alpha3() const; // Direct lattice parameters, angle in degrees. + double a(int nd)const; // get lattice parameter as function of index (0-2) double a() const; double b() const; double c() const; diff --git a/Code/Mantid/Framework/Geometry/src/Crystal/UnitCell.cpp b/Code/Mantid/Framework/Geometry/src/Crystal/UnitCell.cpp index 8ba0950e836e5d04dee27d0c23ef61a539daa23d..329a2480a1cb7ecba3c319e50c1a3676cfac6231 100644 --- a/Code/Mantid/Framework/Geometry/src/Crystal/UnitCell.cpp +++ b/Code/Mantid/Framework/Geometry/src/Crystal/UnitCell.cpp @@ -90,6 +90,14 @@ namespace Geometry { return da[2]; } +/** Get lattice parameter a1-a3 as function of index (0-2) + @return a_n :: lattice parameter \f$ a,b or c \f$ (in \f$ \mbox{\AA} \f$ ) + */ + double UnitCell::a(int nd)const + { + if(nd<0||nd>2)throw(std::invalid_argument("lattice parameter index can change from 0 to 2 ")); + return da[nd]; + } /** Get lattice parameter @return alpha1 :: lattice parameter \f$ \alpha \f$ (in radians) diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h index 74561e9b5961f67b41000d14f78c0862c89b69af..711d83a016820068fd9a6c96030e2e1f14ed68da 100644 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h +++ b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h @@ -123,7 +123,7 @@ namespace MDAlgorithms //<---< Parts of the identifyMatrixAlg; /** identifies the ID of the conversion subalgorithm to run on a workspace */ std::string identifyTheAlg(API::MatrixWorkspace_const_sptr inMatrixWS,const std::string &Q_mode_req, const std::string &dE_mode_req, - const Strings &other_dim_names,MDEvents::MDWSDescription &TargWSDescription); + const Strings &other_dim_names,bool convert_to_hkl,MDEvents::MDWSDescription &TargWSDescription); //<---< Parts of the identifyTheAlg; diff --git a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp index c07b83d193083c1470c5d03d3d2dd3452d5f321c..50ab7935ebea547ef9cf7b29e23441470b86262e 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp @@ -64,7 +64,22 @@ ConvertToMDEvents::getLogger(){return convert_log;} // // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(ConvertToMDEvents) - + +/** describes default dimensions ID currently used by multidimensional workspace + * + * DimensionID is the short name which used to retrieve this dimesnion from MD workspace. + * The names themself are defined by constructor + */ +enum defaultDimID +{ + modQ_ID, //< the defauld |Q| id for mod Q or powder mode + Q1_ID, //< 1 of 3 dimID in Q3D mode + Q2_ID, //< 2 of 3 dimID in Q3D mode + Q3_ID, //< 3 of 3 dimID in Q3D mode + dE_ID, //< energy transfer ID + nDefaultID //< ID conunter +}; + // Sets documentation strings for this algorithm void ConvertToMDEvents::initDocs() @@ -181,7 +196,10 @@ ConvertToMDEvents::init() /// this variable describes default possible ID-s for Q-dimensions declareProperty("QDimensions",Q_modes[modQ],new ListValidator(Q_modes), "You can to transfer source workspace dimensions into target workspace directly """" (NoQ), transform into mod(Q) (1 dimension) or QhQkQl (3 dimensions) in Q space",Direction::InOut); - + // this switch allows to make units expressed in HKL, hkl is currently not supported by units conversion so the resulting workspace can not be subject to unit conversion + declareProperty(new PropertyWithValue<bool>("QinHKL", false, Direction::Input), + " Setting this property to true will normalize three momentums obtained in QhQkQl mode by reciprocal lattice vectors 2pi/a,2pi/b and 2pi/c\n" + " ignored in mod|Q| and NoQ modes and if reciprocal lattice is not defined"); /// this variable describes implemented modes for energy transfer analysis declareProperty("dEAnalysisMode",dE_modes[Direct],new ListValidator(dE_modes), "You can analyse neutron energy transfer in direct, indirect or elastic mode. The analysis mode has to correspond to experimental set up." @@ -219,9 +237,14 @@ ConvertToMDEvents::init() //TODO: "If a maximal target workspace range is lower, then one of specified here, the target workspace range will be used instead" ); declareProperty(new ArrayProperty<double>("u"), - "Optional: first base vector (in hkl) defining fractional coordinate system for neutron diffraction; default value is [1,0,0] or powder mode"); + "Optional: First base vector (in hkl) defining fractional coordinate system for neutron diffraction;\n" + "If nothing is specified as input, it will try to recover this vector from the input workspace's oriented lattice,\n" + " where it should define the initial orientation of the crystal wrt the beam. \n" + " If no oriented lattice is not found, the workspace is processed with unit coordinate transformation matrix or in powder mode.\n"); declareProperty(new ArrayProperty<double>("v"), - "Optional: second base vector (in hkl) defining fractional coordinate system for neutron diffraction; default value is [0,1,0] or powder mode"); + "Optional: Second base vector (in hkl) defining fractional coordinate system for neutron diffraction; \n" + "If nothing is specified as input, it will try to recover this vector from the input workspace's oriented lattice\n" + "and if this fails, proceed as for property u above."); // Box controller properties. These are the defaults this->initBoxControllerProps("5" /*SplitInto*/, 1500 /*SplitThreshold*/, 20 /*MaxRecursionDepth*/); @@ -284,20 +307,20 @@ void ConvertToMDEvents::exec() std::string dE_mod_req = getProperty("dEAnalysisMode"); //c) other dim property; std::vector<std::string> other_dim_names = getProperty("OtherDimensions"); + //d) part of the procedure, specifying the target dimensions units. Currently only Q3D target units can be converted to hkl + bool convert_to_hkl = getProperty("QinHKL"); // Identify the algorithm to deploy and identify/set the (multi)dimension names to use - algo_id = identifyTheAlg(inWS2D,Q_mod_req,dE_mod_req,other_dim_names,TWS); + algo_id = identifyTheAlg(inWS2D,Q_mod_req,dE_mod_req,other_dim_names,convert_to_hkl,TWS); // set the min and max values for the dimensions from the input porperties TWS.dim_min = getProperty("MinValues"); TWS.dim_max = getProperty("MaxValues"); // verify that the number min/max values is equivalent to the number of dimensions defined by properties and min is less the - TWS.checkMinMaxNdimConsistent(convert_log); - // the output dimensions and almost everything else will be determined by the dimensions of the target workspace - // user input is mainly ignored - } - else - { + TWS.checkMinMaxNdimConsistent(convert_log); + } + else // the output dimensions and almost everything else is determined by the dimensions of the target workspace + { // user input is mainly ignored TWS.n_dims = spws->getNumDims(); TWS.dim_min.assign(TWS.n_dims,-1); TWS.dim_max.assign(TWS.n_dims,1); @@ -482,6 +505,7 @@ ConvertToMDEvents::parseDEMode(const std::string &Q_MODE_ID,const std::string &d convert_log.error()<<" dE-mode: "<<dE_mode_req<<" not recognized\n"; throw(std::invalid_argument(" Non-existing dE-mode")); } + // set default number of additional dimensions, neded for anargy analysis mode to 0 (no needed) ndE_dims = 0; std::string DE_MODE_ID= dE_mode_req; @@ -490,11 +514,15 @@ ConvertToMDEvents::parseDEMode(const std::string &Q_MODE_ID,const std::string &d DE_MODE_ID = dE_modes[ANY_Mode]; // no-Q mode -- no conversion, so natural units are the one, already used by the workspace natural_units=ws_dim_units[0]; + if(DE_MODE_ID.compare(dE_mode_req)!=0){ + convert_log.warning()<<" No Q mode selected together with dEAnalysisMode: "<<dE_mode_req<<std::endl; + convert_log.warning()<<" No Q mode not comparible with any energy analyzsis mode, so the energy analysis mode ignored\n"; + } } // inelastic modes have one additional dimension and need special units on X-axis if((DE_MODE_ID.compare(dE_modes[Direct])==0)||(DE_MODE_ID.compare(dE_modes[Indir])==0)){ ndE_dims = 1; - out_dim_IDs.push_back(default_dim_ID[4]); + out_dim_IDs.push_back(default_dim_ID[dE_ID]); out_dim_units.push_back("DeltaE"); // natural units defined in subalgorithm doing the conversion and their ID has to be defined correctly in class constructor natural_units = native_inelastic_unitID; @@ -536,7 +564,7 @@ ConvertToMDEvents::parseQMode(const std::string &Q_mode_req,const Strings &ws_di nQ_dims=1; out_dim_ID.resize(1); out_dim_units.resize(1); - out_dim_ID[0] = default_dim_ID[0]; + out_dim_ID[0] = default_dim_ID[modQ_ID]; out_dim_units[0] = native_elastic_unitID; Q_MODE_ID = Q_modes[modQ]; @@ -545,9 +573,9 @@ ConvertToMDEvents::parseQMode(const std::string &Q_mode_req,const Strings &ws_di { nQ_dims=3; out_dim_ID.resize(3); - out_dim_ID[0]= default_dim_ID[1]; - out_dim_ID[1]= default_dim_ID[2]; - out_dim_ID[2]= default_dim_ID[3]; + out_dim_ID[0]= default_dim_ID[Q1_ID]; + out_dim_ID[1]= default_dim_ID[Q2_ID]; + out_dim_ID[2]= default_dim_ID[Q3_ID]; Q_MODE_ID = Q_modes[Q3D]; out_dim_units.assign(3,native_elastic_unitID); @@ -589,12 +617,14 @@ ConvertToMDEvents::parseWSType(API::MatrixWorkspace_const_sptr inMatrixWS)const * @param Q_mode_req -- what to do with Q-dimensions e.g. calculate either mod|Q| or Q3D; * @param dE_mode_req -- desirable dE analysis mode (elastic, direct/indirect) * @param other_dim_names -- vector of other dimension names requested by the algorithm - * @param dim_names_requested [out] -- dimension names for the target workspace + * @param convert_to_hkl -- part of the procedure to convert to any uints. Currently in Q3D mode Q dimensions can be converted to hkl + * @param dim_names_requested [out] -- dimension names for the target workspace * @param dim_units_requested [out] -- dimension units for the target workspace */ std::string ConvertToMDEvents::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,const std::string &Q_mode_req, const std::string &dE_mode_req,const std::vector<std::string> &other_dim_names, + bool convert_to_hkl, MDEvents::MDWSDescription &TargWSDescription) { @@ -666,12 +696,14 @@ ConvertToMDEvents::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,const std // set up the target workspace description; TargWSDescription.n_dims = nDims; TargWSDescription.emode = emode; + TargWSDescription.convert_to_hkl = convert_to_hkl; TargWSDescription.dim_names = dim_IDs_requested; TargWSDescription.dim_IDs = dim_IDs_requested; TargWSDescription.dim_units = dim_units_requested; TargWSDescription.AlgID = the_algID; - // build meaningfull dimension names for Q-transformation if it is Q-transformation indeed + // build meaningfull dimension names for Q-transformation if it is Q-transformation indeed + // also (temporary) redefines transformation matrix in convert to hkl mode this->buildDimNames(TargWSDescription); return the_algID; @@ -760,6 +792,10 @@ ConvertToMDEvents::getTransfMatrix(API::MatrixWorkspace_sptr inWS,MDEvents::MDWS return rotMat; } +/** Build meaningful dimension namse for different conversion modes + * Currently modifies Q3D mode + * Currently modifies the coordinate transformation matrix, if it is Q3D mode converted in hkl + */ void ConvertToMDEvents::buildDimNames(MDEvents::MDWSDescription &TargWSDescription) { // non-energy transformation modes currently do not change any units and dimension names @@ -771,8 +807,16 @@ void ConvertToMDEvents::buildDimNames(MDEvents::MDWSDescription &TargWSDescripti dim_directions[0]=TargWSDescription.u; dim_directions[1]=TargWSDescription.v; dim_directions[2]=dim_directions[0].cross_prod(dim_directions[1]); - for(size_t i=0;i<3;i++){ + for(int i=0;i<3;i++){ TargWSDescription.dim_names[i]=MDEvents::makeAxisName(dim_directions[i],TWS.defailt_qNames); + if(TargWSDescription.convert_to_hkl){ + // lattice wave vector + double cr=TargWSDescription.Latt.a(i)/(2*M_PI); + for(int j=0;j<3;j++){ + TargWSDescription.rotMatrix[3*i+j]*=cr; + } + TargWSDescription.dim_units[i] = "in "+MDEvents::sprintfd(1/cr,1.e-3)+" A^-1"; + } } } @@ -904,8 +948,9 @@ SupportedWS(NInWSTypes), native_elastic_unitID("Momentum"),// currently it is Q /// the ID of the unit, which is used in the expression to converty to QND. All other related inelastic units should be converted to this one. native_inelastic_unitID("DeltaE"), // currently it is energy transfer (DeltaE) -default_dim_ID(5), -// initiate target ws description to be not empty and have 4 dimensions (It will be redefined later, but defailt_qNames are defined only when it is not empty) +default_dim_ID(nDefaultID), +// initiate target ws description to be not empty and have 4 dimensions (It will be redefined later, but defailt_qNames are defined only +// when N-dim constructor wass called TWS(4) { // strings to indentify possible momentum analysis modes @@ -928,12 +973,12 @@ TWS(4) // this defines default dimension ID-s which are used to indentify dimensions when using the target MD workspace later // for modQ transformation: - default_dim_ID[0]="|Q|"; + default_dim_ID[modQ_ID]="|Q|"; // for Q3D transformation - default_dim_ID[1]="Q1"; - default_dim_ID[2]="Q2"; - default_dim_ID[3]="Q3"; - default_dim_ID[4]="DeltaE"; + default_dim_ID[Q1_ID]="Q1"; + default_dim_ID[Q2_ID]="Q2"; + default_dim_ID[Q3_ID]="Q3"; + default_dim_ID[dE_ID]="DeltaE"; // Subalgorithm factories: // NoQ --> any Analysis mode will do as it does not depend on it; we may want to convert unuts diff --git a/Code/Mantid/Framework/MDAlgorithms/test/ConvertToMDEventsTest.h b/Code/Mantid/Framework/MDAlgorithms/test/ConvertToMDEventsTest.h index 205599acf40e41751c664f3faca47edff85ca54d..68fc823876028dfbf8b422752660a08fdce0dd99 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/ConvertToMDEventsTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/ConvertToMDEventsTest.h @@ -33,7 +33,7 @@ public: const std::vector<std::string> &other_dim_names,MDEvents::MDWSDescription &TWSD) { - return ConvertToMDEvents::identifyTheAlg(inMatrixWS,Q_mode_req, dE_mode_req,other_dim_names,TWSD); + return ConvertToMDEvents::identifyTheAlg(inMatrixWS,Q_mode_req, dE_mode_req,other_dim_names,false,TWSD); } std::string identifyMatrixAlg(API::MatrixWorkspace_const_sptr inMatrixWS,const std::string &Q_mode_req, const std::string &dE_mode_req, std::vector<std::string> &outws_dim_names,std::vector<std::string> &outws_dim_units){ @@ -129,7 +129,7 @@ void testInit(){ TS_ASSERT_THROWS_NOTHING( pAlg->initialize() ) TS_ASSERT( pAlg->isInitialized() ) - TSM_ASSERT_EQUALS("algortithm should have 14 propeties",14,(size_t)(pAlg->getProperties().size())); + TSM_ASSERT_EQUALS("algortithm should have 15 propeties",15,(size_t)(pAlg->getProperties().size())); } // TEST QMode void testParseQMode_WrongThrows() diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDWSDescription.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDWSDescription.h index 15ec47691fea2532d05c35a425048f9f8415b179..9fc5c0642ae7d022889a5b75c2b93c10b351b40d 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDWSDescription.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDWSDescription.h @@ -60,6 +60,8 @@ namespace MDEvents std::vector<std::string> dim_IDs; /// the units of target workspace dimensions and properties of input MD workspace dimensions std::vector<std::string> dim_units; + /// the swich, specifying if the target Q3D -dimensions should be converted to hkl. Ignored in ModQ and NoQ mode and if no oriented lattice is found in input ws. + bool convert_to_hkl; /** vectors, which describe the projection plain the target ws is based on (notional coordinate system). The transformation matrix below * should bring the momentums from lab coordinate system into notional coordinate system */ Kernel::V3D u,v; @@ -79,6 +81,8 @@ namespace MDEvents }; /** function to build mslice-like axis name from the vector, which describes crystallographic direction along this axis*/ std::string DLLExport makeAxisName(const Kernel::V3D &vector,const std::vector<std::string> &Q1Names); +/**creates string representation of the number with accuracy, cpecified by eps*/ +std::string DLLExport sprintfd(const double data, const double eps); } } diff --git a/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp b/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp index e7ab0953b090cf82c1642d5b5f860463866043ae..801870d674a1e555f7febd13560482be257d5dad 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp @@ -38,6 +38,7 @@ dim_max(nDimesnions,1), dim_names(nDimesnions,"mdn"), dim_IDs(nDimesnions,"mdn_"), dim_units(nDimesnions,"Momentum"), +convert_to_hkl(false), u(1,0,0), v(0,1,0), is_uv_default(true), @@ -50,6 +51,13 @@ defailt_qNames(3) defailt_qNames[1]="Qk"; defailt_qNames[2]="Ql"; +} +std::string DLLExport sprintfd(const double data, const double eps) +{ + // truncate to eps decimal points + float dist = float((int(data/eps+0.5))*eps); + return boost::str(boost::format("%d")%dist); + } std::string makeAxisName(const Kernel::V3D &Dir,const std::vector<std::string> &QNames) @@ -70,9 +78,7 @@ std::string makeAxisName(const Kernel::V3D &Dir,const std::vector<std::string> & name+=QNames[i]+separator; continue; } - // truncate to eps decimal points - dist = float(int(dist/eps+0.5))*eps; - name+= boost::str(boost::format("%d")%dist)+QNames[i]+separator; + name+= sprintfd(dist,eps)+QNames[i]+separator; } return name; diff --git a/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py b/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py index fb05d76c6fd1f24b71275ac1082ebb4a26a3a0e3..6ac002bdf39c36ad2e0e68eb5135a2e9768cc894 100644 --- a/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py +++ b/Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py @@ -19,8 +19,10 @@ class RefLReduction(PythonAlgorithm): self.declareListProperty("RunNumbers", [0], Validator=ArrayBoundedValidator(Lower=0)) self.declareProperty("NormalizationRunNumber", 0, Description="") self.declareListProperty("SignalPeakPixelRange", [126, 134], Validator=ArrayBoundedValidator(Lower=0)) + self.declareProperty("SubtractSignalBackground", True) self.declareListProperty("SignalBackgroundPixelRange", [123, 137], Validator=ArrayBoundedValidator(Lower=0)) self.declareListProperty("NormPeakPixelRange", [127, 133], Validator=ArrayBoundedValidator(Lower=0)) + self.declareProperty("SubtractNormBackground", True) self.declareListProperty("NormBackgroundPixelRange", [123, 137], Validator=ArrayBoundedValidator(Lower=0)) self.declareListProperty("LowResAxisPixelRange", [115, 210], Validator=ArrayBoundedValidator(Lower=0)) self.declareListProperty("TOFRange", [9000., 23600.], Validator=ArrayBoundedValidator(Lower=0)) @@ -69,6 +71,9 @@ class RefLReduction(PythonAlgorithm): from_peak = norm_peak[0] to_peak = norm_peak[1] + subtract_data_bck = self.getProperty("SubtractSignalBackground") + subtract_norm_bck = self.getProperty("SubtractNormBackground") + ######################################################################## # Find full path to event NeXus data file f = FileFinder.findRuns("REF_L%d" %run_numbers[0]) @@ -174,12 +179,14 @@ class RefLReduction(PythonAlgorithm): OutputWorkspace='TransposedID') ConvertToHistogram(InputWorkspace='TransposedID', OutputWorkspace='TransposedID') - FlatBackground(InputWorkspace='TransposedID', - OutputWorkspace='TransposedFlatID', - StartX=BackfromYpixel, - Mode='Mean', - EndX=data_peak[0]) - Transpose(InputWorkspace='TransposedFlatID', + + if subtract_data_bck: + FlatBackground(InputWorkspace='TransposedID', + OutputWorkspace='TransposedID', + StartX=BackfromYpixel, + Mode='Mean', + EndX=data_peak[0]) + Transpose(InputWorkspace='TransposedID', OutputWorkspace='DataWks') @@ -235,13 +242,14 @@ class RefLReduction(PythonAlgorithm): ConvertToHistogram(InputWorkspace='TransposedID', OutputWorkspace='TransposedID') - FlatBackground(InputWorkspace='TransposedID', - OutputWorkspace='TransposedFlatID', - StartX=BackfromYpixel, - Mode='Mean', - EndX=norm_peak[0]) - - Transpose(InputWorkspace='TransposedFlatID', + if subtract_norm_bck: + FlatBackground(InputWorkspace='TransposedID', + OutputWorkspace='TransposedID', + StartX=BackfromYpixel, + Mode='Mean', + EndX=norm_peak[0]) + + Transpose(InputWorkspace='TransposedID', OutputWorkspace='NormWks') #perform the integration myself diff --git a/Code/Mantid/Installers/WinInstaller/generateWxs.py b/Code/Mantid/Installers/WinInstaller/generateWxs.py index 9364224f0433468bd67c68b1dd7ac8c0764011ad..3f12c5867ed0799c2e2cb142003ed2286df19c4d 100644 --- a/Code/Mantid/Installers/WinInstaller/generateWxs.py +++ b/Code/Mantid/Installers/WinInstaller/generateWxs.py @@ -505,7 +505,22 @@ control.appendChild(publish) publish.setAttribute('Property','ALLUSERS') publish.setAttribute('Value','{}') addText(r'ASSISTANCE_USERS = "current"',publish) +################################################################################################################### +# Set the default install dir, it sets the default value for [INSTALLDIR] to use +# [WindowsVolume] rather than [ROOTDRIVE]. ROOTDRIVE can end up being a USB drive if it +# has more space than an internal drive +# We want to write this to the XML file, as usal this is more complicated than it needs be +# +# <CustomAction Id="SetInstallDirDefault" Property="INSTALLDIR" +# Value="[WindowsVolume]MantidInstall" /> +# <InstallUISequence> +# <Custom Action="SetInstallDirDefault" After="CostInitialize" /> +# </InstallUISequence> +# +addTo(Product,'CustomAction',{'Id':'SetInstallDirDefault','Property':'INSTALLDIR','Value':'[WindowsVolume]%s' % MantidInstallDir}) +installDefaultUISeq = addTo(Product, 'InstallUISequence', {}) +addTo(installDefaultUISeq, 'Custom', {'Action':'SetInstallDirDefault','After':'CostInitialize'}) TargetDir = addDirectory('TARGETDIR','SourceDir','SourceDir',Product) InstallDir = addDirectory('INSTALLDIR','MInstall',MantidInstallDir,TargetDir) binDir = addDirectory('MantidBin','bin','bin',InstallDir) @@ -751,6 +766,7 @@ DesktopFolder = addDirectory('DesktopFolder','Desktop','Desktop',TargetDir) #----------------------------------------------------------------------- + Complete = addRootFeature('Complete','Mantid','The complete package','1',Product) MantidExec = addFeature('MantidExecAndDlls','Mantid binaries','The main executable.','1',Complete) addCRef('MantidDLLs',MantidExec) @@ -776,7 +792,7 @@ addCRef('QtImagePlugins', MantidExec) addCRef('MantidQtPlugins', MantidExec) # Header files -Includes = addFeature('Includes','Includes','Mantid and third party header files.','2',Complete) +Includes = addFeature('Includes','Includes','Mantid and third party header files.','1',Complete) addCRef('IncludeFiles', Includes) addCRef('IncludeMantidAPI',Includes) addCRefs(includeMantidGeometryDirList,Includes) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/ConvertToEnergy.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/ConvertToEnergy.cpp index a64fc5f997973753adf5f6810cd825194c2e8cb5..dad479dedd8e7be7743551ae4a9e0c9270f6fb91 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/ConvertToEnergy.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/ConvertToEnergy.cpp @@ -195,15 +195,8 @@ void ConvertToEnergy::instrumentSelectChanged(const QString& name) return; } - //QString defFile = getIDFPath(name); QString defFile = (Mantid::API::ExperimentInfo::getInstrumentFilename(name.toStdString())).c_str(); - - // m_filename = ExperimentInfo::getInstrumentFilename(m_instName,date); - - std::cout << "ConvertToEnergy::instrumentSelectChanged(): name = " << name.toStdString() << std::endl; - std::cout << "ConvertToEnergy::instrumentSelectChanged(): defFile = " << defFile.toStdString() << std::endl; - if ( defFile == "" ) { m_curEmodeType = Undefined; @@ -242,39 +235,8 @@ void ConvertToEnergy::instrumentSelectChanged(const QString& name) m_curEmodeType = desired; m_uiForm.pbRun->setEnabled(true); - std::cout << "ConvertToEnergy::instrumentSelectChanged() - leaving" << std::endl; } -//QString ConvertToEnergy::getIDFPath(const QString& prefix) -//{ -// QString paramfile_dir = QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("parameterDefinition.directory")); -// QDir paramdir(paramfile_dir); -// paramdir.setFilter(QDir::Files); -// QStringList filters; -// filters << prefix + "*_Parameters.xml"; -// paramdir.setNameFilters(filters); - -// QStringList entries = paramdir.entryList(); -// QString defFilePrefix; - -// if( entries.isEmpty() ) -// { -// QMessageBox::warning(this, "MantidPlot", "Selected instrument (" + prefix + ") does not have a parameter file.\nCannot run analysis"); -// m_uiForm.cbInst->blockSignals(true); -// m_uiForm.cbInst->setCurrentIndex(m_uiForm.cbInst->findText(m_curInterfaceSetup)); -// m_uiForm.cbInst->blockSignals(false); -// return ""; -// } -// else -// { -// defFilePrefix = entries[(entries.count()-1)]; -// defFilePrefix.chop(15); // cut "_Parameters.xml" off the string -// } - -// QString defFile = paramdir.filePath(defFilePrefix + "_Definition.xml"); -// return defFile; -//} - /** * Runs a Python script to discover whether the selected instrument is direct or indirect. * @param defFile :: path to instrument definition file. diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/CreateMDWorkspace.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/CreateMDWorkspace.cpp index 61a7bc9460dfe68f127fec94c431b11a7c0e6fa7..2c0dbb234c85d4d9bfe6a13ddb23abbc56ece453 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/CreateMDWorkspace.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/CreateMDWorkspace.cpp @@ -380,7 +380,7 @@ Add a nexus files on disk */ void CreateMDWorkspace::addNexusFileClicked() { - QStringList fileNames = findFiles("Raw Files (*.nxs)"); + QStringList fileNames = findFiles("Nexus files (*.nxs)"); QStringList::iterator it = fileNames.begin(); QStringList::const_iterator end = fileNames.end(); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/EventNexusFileMemento.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/EventNexusFileMemento.cpp index 7337aa2edc30ba1bbb06ac80232c800a99a5557c..bf94179ee999867327b3eb67815056cd7bdd8f4f 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/EventNexusFileMemento.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/EventNexusFileMemento.cpp @@ -1,4 +1,5 @@ #include "MantidQtCustomInterfaces/EventNexusFileMemento.h" +#include "MantidAPI/LoadAlgorithmFactory.h" #include "MantidKernel/Matrix.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/IEventWorkspace.h" @@ -21,15 +22,24 @@ namespace MantidQt { boost::regex pattern("(NXS)$", boost::regex_constants::icase); + //Fail if wrong extension if(!boost::regex_search(fileName, pattern)) { std::string msg = "EventNexusFileMemento:: Unknown File extension on: " + fileName; throw std::invalid_argument(msg); } - + + //Check file exists at given location if(!checkStillThere()) { - throw std::runtime_error("EventNexusFileMemento:: File doesn't exist"); + throw std::invalid_argument("EventNexusFileMemento:: File doesn't exist"); + } + + //Detailed check of file structure. + IDataFileChecker_sptr alg = LoadAlgorithmFactory::Instance().create("LoadEventNexus"); + if(!alg->fileCheck(m_fileName)) + { + throw std::invalid_argument("Expecting Event Nexus files. This file type is not recognised"); } std::vector<std::string> strs; @@ -86,7 +96,7 @@ namespace MantidQt { checkStillThere(); - IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("LoadEventNexus"); + IDataFileChecker_sptr alg = LoadAlgorithmFactory::Instance().create("LoadEventNexus"); alg->initialize(); alg->setRethrows(true); alg->setProperty("Filename", m_fileName); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp index aba7714686caf39241fc72eea28141dc9b211706..d38837fc2947046c502611a2dfbf56cc480d47b7 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp @@ -912,71 +912,105 @@ void MuonAnalysis::inputFileChanged_MWRunFiles() m_previousFilename = m_uiForm.mwRunFiles->getFirstFilename(); - int appendSeparator(-1); - appendSeparator = m_previousFilename.find("-"); - - if (appendSeparator != -1) + //int appendSeparator(-1); + ////appendSeparator = m_previousFilename.find("-"); + + //if (appendSeparator != -1) + //{ + // int difference(0); + + // //if a range has been selected then open them all + // //first split into files + // QString currentFile = m_uiForm.mwRunFiles->getText();//m_previousFilename; // m_uiForm.mwRunFiles->getFirstFilename(); + // + // int lowSize(-1); + // int lowLimit(-1); + // QString fileExtension(""); + // QString lowString(""); + + // if (currentFile.contains(".")) + // { + // //Get the file extension and then remove it from the current file + // int temp(currentFile.size()-currentFile.find(".")); + // fileExtension = currentFile.right(temp); + // currentFile.chop(temp); + // + // //Get the max value and then chop this off + // QString maxString = currentFile.right(currentFile.size() - appendSeparator - 1); + // int maxSize = maxString.size(); + // int maxLimit = maxString.toInt(); + // //include chopping off the "-" symbol + // currentFile.chop(maxSize + 1); + + // separateMuonFile(currentFile, lowSize, lowLimit); + // difference = maxLimit - lowLimit; + + // for(int i = 0; i<=difference; ++i) + // { + // lowString = lowString.setNum(lowLimit + i); + // getFullCode(lowSize, lowString); + // m_previousFilename = currentFile + lowString + fileExtension; + // // in case file is selected from browser button check that it actually exist + // Poco::File l_path( m_previousFilename.toStdString() ); + // if ( !l_path.exists() ) + // { + // QMessageBox::warning(this,"Mantid - MuonAnalysis", m_previousFilename + "Specified data file does not exist."); + // return; + // } + // + // // save selected browse file directory to be reused next time interface is started up + // m_uiForm.mwRunFiles->saveSettings(m_settingsGroup + "mwRunFilesBrowse"); + + // inputFileChanged(m_previousFilename); + // } + // } + //} + //else + //{ + // in case file is selected from browser button check that it actually exist + try { - int difference(0); - - //if a range has been selected then open them all - //first split into files - QString currentFile = m_uiForm.mwRunFiles->getText();//m_previousFilename; // m_uiForm.mwRunFiles->getFirstFilename(); - - int lowSize(-1); - int lowLimit(-1); - QString fileExtension(""); - QString lowString(""); - - //Get the file extension and then remove it from the current file - int temp(currentFile.size()-currentFile.find(".")); - fileExtension = currentFile.right(temp); - currentFile.chop(temp); - - //Get the max value and then chop this off - QString maxString = currentFile.right(currentFile.size() - appendSeparator - 1); - int maxSize = maxString.size(); - int maxLimit = maxString.toInt(); - //include chopping off the "-" symbol - currentFile.chop(maxSize + 1); - - separateMuonFile(currentFile, lowSize, lowLimit); - difference = maxLimit - lowLimit; - - for(int i = 0; i<=difference; ++i) - { - lowString = lowString.setNum(lowLimit + i); - getFullCode(lowSize, lowString); - m_previousFilename = currentFile + lowString + fileExtension; - // in case file is selected from browser button check that it actually exist - Poco::File l_path( m_previousFilename.toStdString() ); - if ( !l_path.exists() ) + Poco::File l_path( m_previousFilename.toStdString() ); + if ( !l_path.exists() ) + { + QString tempFilename; + if (m_previousFilename.contains('.')) { - QMessageBox::warning(this,"Mantid - MuonAnalysis", m_previousFilename + "Specified data file does not exist."); - return; + tempFilename = m_previousFilename.left(m_previousFilename.find('.')); } - - // save selected browse file directory to be reused next time interface is started up - m_uiForm.mwRunFiles->saveSettings(m_settingsGroup + "mwRunFilesBrowse"); - - inputFileChanged(m_previousFilename); + Poco::File l_path( tempFilename.toStdString() ); + if ( !l_path.exists() ) + { + QMessageBox::warning(this,"Mantid - MuonAnalysis", m_previousFilename + " Specified data file does not exist."); + } + return; } } - else + catch(std::exception &e) { - // in case file is selected from browser button check that it actually exist - Poco::File l_path( m_previousFilename.toStdString() ); - if ( !l_path.exists() ) + //Specified a network drive. + QString tempFilename; + if (m_previousFilename.contains('.')) { - QMessageBox::warning(this,"Mantid - MuonAnalysis", m_previousFilename + "Specified data file does not exist."); - return; + tempFilename = m_previousFilename.left(m_previousFilename.find('.')); } - - // save selected browse file directory to be reused next time interface is started up - m_uiForm.mwRunFiles->saveSettings(m_settingsGroup + "mwRunFilesBrowse"); - - inputFileChanged(m_previousFilename); + Poco::File l_path( tempFilename.toStdString() ); + try + { + if ( !l_path.exists() ) + QMessageBox::warning(this,"Mantid - MuonAnalysis", m_previousFilename + " Specified data file does not exist."); + } + catch (std::exception &e) + { + QMessageBox::warning(this,"Mantid - MuonAnalysis", tempFilename + " Specified directory does not exist."); + } + return; } + // save selected browse file directory to be reused next time interface is started up + m_uiForm.mwRunFiles->saveSettings(m_settingsGroup + "mwRunFilesBrowse"); + + inputFileChanged(m_previousFilename); + //} } /** @@ -2750,7 +2784,7 @@ void MuonAnalysis::changeRun(int amountToChange) //Find where the file begins for (int i = 0; i<currentFile.size(); i++) { - if(currentFile[i] == '/') //.isDigit()) + if(currentFile[i] == '/' || currentFile[i] == '\\') //.isDigit()) { fileStart = i+1; } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/RawFileMemento.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/RawFileMemento.cpp index abfcfd19f2f6ede5f71ba96bd6f048943d223a52..48f5a48a45ff04042693c4919e701b56cd51033f 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/RawFileMemento.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/RawFileMemento.cpp @@ -2,6 +2,7 @@ #include "MantidKernel/Matrix.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/LoadAlgorithmFactory.h" #include "MantidGeometry/Crystal/OrientedLattice.h" #include <iostream> #include <fstream> @@ -21,15 +22,17 @@ namespace MantidQt { boost::regex pattern("(NXS)$", boost::regex_constants::icase); + //Fail if the file extension is wrong. if(!boost::regex_search(fileName, pattern)) { std::string msg = "NexusFileMemento:: Unknown File extension on: " + fileName; throw std::invalid_argument(msg); } + //Fail if there is no file at the given location if(!checkStillThere()) { - throw std::runtime_error("NexusFileMemento:: File doesn't exist"); + throw std::invalid_argument("NexusFileMemento:: File doesn't exist"); } std::vector<std::string> strs; @@ -93,7 +96,7 @@ namespace MantidQt alg->setPropertyValue("OutputWorkspace", m_adsID); if(protocol == MinimalData) { - alg->setProperty("SpectrumMin", 1); + alg->setProperty("SpectrumMin", 0); alg->setProperty("SpectrumMax", 1); } alg->execute(); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/test/EventNexusFileMementoTest.h b/Code/Mantid/MantidQt/CustomInterfaces/test/EventNexusFileMementoTest.h index 0e235506b11de82bb58f4bf74287a44d7aad1275..2e9f0b821648b4d95e8ece69849c92905938b188 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/test/EventNexusFileMementoTest.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/test/EventNexusFileMementoTest.h @@ -20,6 +20,11 @@ private: return Mantid::API::FileFinder::Instance().getFullPath("CNCS_7860_event.nxs"); } + static std::string getUnSuitableFileNamePath() + { + return Mantid::API::FileFinder::Instance().getFullPath("MDEW_4D.nxs"); + } + public: void testConstructorThrowsWithWrongExtension() @@ -36,7 +41,12 @@ public: void testConstructThrowsWhenFileDoesntExist() { - TSM_ASSERT_THROWS("Unknown file, should throw.", new EventNexusFileMemento("MadeUp.nxs"), std::runtime_error); + TSM_ASSERT_THROWS("Unknown file, should throw.", new EventNexusFileMemento("MadeUp.nxs"), std::invalid_argument); + } + + void testConstructThrowsOnInvalidFile() + { + TSM_ASSERT_THROWS("Unknown file structure, should throw.", new EventNexusFileMemento(getUnSuitableFileNamePath()), std::invalid_argument); } void testFetchItSucceedsWhenFileExists() diff --git a/Code/Mantid/MantidQt/CustomInterfaces/test/RawFileMementoTest.h b/Code/Mantid/MantidQt/CustomInterfaces/test/RawFileMementoTest.h index 808d7b1b957a063c1221d31564c122b8fbad07a8..841bc648a5d52099b422c14ccf45506aa4484717 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/test/RawFileMementoTest.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/test/RawFileMementoTest.h @@ -37,7 +37,7 @@ public: void testConstructThrowsWhenFileDoesntExist() { - TSM_ASSERT_THROWS("Unknown file, should throw.", new RawFileMemento("MadeUp.nxs"), std::runtime_error); + TSM_ASSERT_THROWS("Unknown file, should throw.", new RawFileMemento("MadeUp.nxs"), std::invalid_argument); } void testFetchItSucceedsWhenFileExists() diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/DiagResults.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/DiagResults.cpp index 8a28e005549f7c38026aa8905b2e224fe8a74a9f..5a76e1032a54b59516188cfedd52496c3b1f0cc9 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/DiagResults.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/DiagResults.cpp @@ -22,10 +22,10 @@ using namespace MantidQt::MantidWidgets; namespace { /// the total number of tests that results are reported for here - const int NUMTESTS = 4; + const int NUMTESTS = 5; /// the list of tests that we display results for const QString TESTS[NUMTESTS] = - { "First detector vanadium test", "Second detector vanadium test", "Background test", "PSD Bleed test"}; + { "Hard mask", "First detector vanadium test", "Second detector vanadium test", "Background test", "PSD Bleed test"}; } //---------------------- diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp index e5b6e703f9a6b16c7e9b754d657c61296d2fb7f1..b6b23f8d099b3656950967ea3d74d89c8b401c70 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/MWRunFiles.cpp @@ -28,7 +28,7 @@ MWRunFiles::MWRunFiles(QWidget *parent) connect(m_uiForm.browseBtn, SIGNAL(clicked()), this, SLOT(browseClicked())); connect(m_uiForm.browseIco, SIGNAL(clicked()), this, SLOT(browseClicked())); - connect(m_uiForm.fileEditor, SIGNAL(editingFinished()), this, SIGNAL(fileEditingFinished())); + connect(m_uiForm.fileEditor, SIGNAL(returnPressed ()), this, SIGNAL(fileEditingFinished())); connect(this, SIGNAL(fileEditingFinished()), this, SLOT(findFiles())); connect(m_uiForm.entryNum, SIGNAL(textChanged(const QString &)), this, SLOT(checkEntry())); connect(m_uiForm.entryNum, SIGNAL(editingFinished()), this, SLOT(checkEntry())); diff --git a/Code/Mantid/instrument/ARCS_Parameters.xml b/Code/Mantid/instrument/ARCS_Parameters.xml index 5697452ec5809b7e424f742fc85122c4c2905407..2808f21f930b447aff3b01d88465d101925283b8 100644 --- a/Code/Mantid/instrument/ARCS_Parameters.xml +++ b/Code/Mantid/instrument/ARCS_Parameters.xml @@ -115,47 +115,11 @@ <value val="0.0"/> </parameter> - - <!-- TO BE REMOVED Diagnostic test defaults --> - - <parameter name="remove_zero"> - <value val="1.0" /> - </parameter> - - <parameter name="tiny"> - <value val="1e-10" /> - </parameter> - - <parameter name="large"> - <value val="1e10" /> - </parameter> - - <parameter name="median_lo"> - <value val="0.1" /> - </parameter> - - <parameter name="median_hi"> - <value val="3.0" /> + <!-- Variation for ratio test with second white beam --> + <parameter name="diag_variation"> + <value val="1.1"/> </parameter> - <parameter name="signif"> - <value val="3.3" /> - </parameter> - - <parameter name="check_background"> - <value val="1.0" /> - </parameter> - - <parameter name="bkgd_threshold"> - <value val="5.0" /> - </parameter> - - <parameter name="variation"> - <value val="1.1" /> - </parameter> - - <!-- --> - <!-- Absolute units conversion average --> <parameter name="monovan_lo_bound"> diff --git a/Code/Mantid/instrument/CNCS_Parameters.xml b/Code/Mantid/instrument/CNCS_Parameters.xml index af3a868ea1c24cf398e90aa053533dcf2592b34b..7b76b3d20ceb8ae7e1de60d392bc641c716b3ceb 100644 --- a/Code/Mantid/instrument/CNCS_Parameters.xml +++ b/Code/Mantid/instrument/CNCS_Parameters.xml @@ -115,42 +115,9 @@ <value val="0.0"/> </parameter> - <!-- TO BE REMOVED Diagnostic test defaults --> - - <parameter name="remove_zero"> - <value val="1.0" /> - </parameter> - - <parameter name="tiny"> - <value val="1e-10" /> - </parameter> - - <parameter name="large"> - <value val="1e10" /> - </parameter> - - <parameter name="median_lo"> - <value val="0.1" /> - </parameter> - - <parameter name="median_hi"> - <value val="3.0" /> - </parameter> - - <parameter name="signif"> - <value val="3.3" /> - </parameter> - - <parameter name="check_background"> - <value val="1.0" /> - </parameter> - - <parameter name="bkgd_threshold"> - <value val="5.0" /> - </parameter> - - <parameter name="variation"> - <value val="1.1" /> + <!-- Variation for ratio test with second white beam --> + <parameter name="diag_variation"> + <value val="1.1"/> </parameter> <!-- Absolute units conversion average --> diff --git a/Code/Mantid/instrument/HYSPEC_Parameters.xml b/Code/Mantid/instrument/HYSPEC_Parameters.xml index 5bf54fe1c1c68c2758496f08e0eef04f2af7d724..2632a7e47f5f1c37e2892a982245783bb42e19a3 100644 --- a/Code/Mantid/instrument/HYSPEC_Parameters.xml +++ b/Code/Mantid/instrument/HYSPEC_Parameters.xml @@ -115,42 +115,9 @@ <value val="0.0"/> </parameter> - <!-- TO BE REMOVED Diagnostic test defaults --> - - <parameter name="remove_zero"> - <value val="1.0" /> - </parameter> - - <parameter name="tiny"> - <value val="1e-10" /> - </parameter> - - <parameter name="large"> - <value val="1e10" /> - </parameter> - - <parameter name="median_lo"> - <value val="0.1" /> - </parameter> - - <parameter name="median_hi"> - <value val="3.0" /> - </parameter> - - <parameter name="signif"> - <value val="3.3" /> - </parameter> - - <parameter name="check_background"> - <value val="1.0" /> - </parameter> - - <parameter name="bkgd_threshold"> - <value val="5.0" /> - </parameter> - - <parameter name="variation"> - <value val="1.1" /> + <!-- Variation for ratio test with second white beam --> + <parameter name="diag_variation"> + <value val="1.1"/> </parameter> <!-- Absolute units conversion average --> diff --git a/Code/Mantid/instrument/LET_Parameters.xml b/Code/Mantid/instrument/LET_Parameters.xml index bbc34e406a06939ce539ab71a3570d689472a90e..f1d13006c9eacadbde8a032cc5b9e2d7e36c68e4 100644 --- a/Code/Mantid/instrument/LET_Parameters.xml +++ b/Code/Mantid/instrument/LET_Parameters.xml @@ -149,6 +149,11 @@ <value val="80"/> </parameter> +<!-- Variation for ratio test with second white beam --> +<parameter name="diag_variation"> + <value val="1.1"/> +</parameter> + <!-- --> <!-- Absolute units conversion average --> @@ -170,45 +175,6 @@ <!-- --> -<!-- To be removed --> -<!-- Diagnostic test defaults --> - -<parameter name="remove_zero"> - <value val="1.0"/> -</parameter> - -<parameter name="tiny"> - <value val="1e-10"/> -</parameter> - -<parameter name="large"> - <value val="1e10"/> -</parameter> - -<parameter name="median_lo"> - <value val="0.1"/> -</parameter> - -<parameter name="median_hi"> - <value val="3.0"/> -</parameter> - -<parameter name="signif"> - <value val="3.3"/> -</parameter> - -<parameter name="check_background"> - <value val="1.0"/> -</parameter> - -<parameter name="bkgd_threshold"> - <value val="5.0"/> -</parameter> - -<parameter name="variation"> - <value val="1.1"/> -</parameter> - </component-link> </parameter-file> diff --git a/Code/Mantid/instrument/MAPS_Parameters.xml b/Code/Mantid/instrument/MAPS_Parameters.xml index 513843b00fe640563e3871444cab40e9ffaf6e0a..50dec74a9f436b86144c6a6bde3b4d792c596304 100644 --- a/Code/Mantid/instrument/MAPS_Parameters.xml +++ b/Code/Mantid/instrument/MAPS_Parameters.xml @@ -145,6 +145,11 @@ <value val="0.0"/> </parameter> +<!-- Variation for ratio test with second white beam --> +<parameter name="diag_variation"> + <value val="1.1"/> +</parameter> + <!-- --> <!-- Absolute units conversion average --> @@ -166,41 +171,6 @@ </parameter> <!-- --> - -<!-- To be removed --> - -<parameter name="remove_zero"> - <value val="1.0"/> -</parameter> - -<parameter name="tiny"> - <value val="1e-10"/> -</parameter> - -<parameter name="large"> - <value val="1e10"/> -</parameter> - -<parameter name="median_lo"> - <value val="0.1"/> -</parameter> - -<parameter name="median_hi"> - <value val="3.0"/> -</parameter> - -<parameter name="signif"> - <value val="3.3"/> -</parameter> - -<parameter name="bkgd_threshold"> - <value val="5.0"/> -</parameter> - -<parameter name="variation"> - <value val="1.1"/> -</parameter> - </component-link> </parameter-file> diff --git a/Code/Mantid/instrument/MARI_Parameters.xml b/Code/Mantid/instrument/MARI_Parameters.xml index c325342fc206d9822f0bf9cf576205a456363c80..279b2414430eff50e15e84a74adaf78af939e557 100644 --- a/Code/Mantid/instrument/MARI_Parameters.xml +++ b/Code/Mantid/instrument/MARI_Parameters.xml @@ -139,6 +139,11 @@ <value val="0.0"/> </parameter> +<!-- Variation for ratio test with second white beam --> +<parameter name="diag_variation"> + <value val="1.1"/> +</parameter> + <!-- --> <!-- Absolute units conversion average --> @@ -159,41 +164,6 @@ </parameter> <!-- --> - -<!-- To be removed --> - -<parameter name="remove_zero"> - <value val="1.0"/> -</parameter> - -<parameter name="large"> - <value val="1e10"/> -</parameter> - -<parameter name="median_lo"> - <value val="0.1"/> -</parameter> - -<parameter name="median_hi"> - <value val="3.0"/> -</parameter> - -<parameter name="signif"> - <value val="3.3"/> -</parameter> - -<parameter name="check_background"> - <value val="1.0"/> -</parameter> - -<parameter name="bkgd_threshold"> - <value val="5.0"/> -</parameter> - -<parameter name="variation"> - <value val="1.1"/> -</parameter> - </component-link> </parameter-file> diff --git a/Code/Mantid/instrument/MERLIN_Parameters.xml b/Code/Mantid/instrument/MERLIN_Parameters.xml index 4cbb1d8bee3d119e25519994a02128d523988b17..ff7aebb022021410dc39e3f71af68cf5d3b8ae8e 100644 --- a/Code/Mantid/instrument/MERLIN_Parameters.xml +++ b/Code/Mantid/instrument/MERLIN_Parameters.xml @@ -150,6 +150,11 @@ <value val="80"/> </parameter> +<!-- Variation for ratio test with second white beam --> +<parameter name="diag_variation"> + <value val="1.1"/> +</parameter> + <!-- --> <!-- Absolute units conversion average --> @@ -171,47 +176,6 @@ <!-- --> -<!-- To be removed --> -<!-- Diagnostic test defaults --> - -<parameter name="remove_zero"> - <value val="1.0"/> -</parameter> - -<parameter name="tiny"> - <value val="1e-10"/> -</parameter> - -<parameter name="large"> - <value val="1e10"/> -</parameter> - -<parameter name="median_lo"> - <value val="0.1"/> -</parameter> - -<parameter name="median_hi"> - <value val="3.0"/> -</parameter> - -<parameter name="signif"> - <value val="3.3"/> -</parameter> - -<parameter name="check_background"> - <value val="1.0"/> -</parameter> - -<parameter name="bkgd_threshold"> - <value val="5.0"/> -</parameter> - -<parameter name="variation"> - <value val="1.1"/> -</parameter> - - - </component-link> </parameter-file> diff --git a/Code/Mantid/instrument/SEQUOIA_Parameters.xml b/Code/Mantid/instrument/SEQUOIA_Parameters.xml index 1dc31bdde0d57c16e1226e540a9dd32c7b00a508..45f188458a3618e8bee12603330018a28d7d13e3 100644 --- a/Code/Mantid/instrument/SEQUOIA_Parameters.xml +++ b/Code/Mantid/instrument/SEQUOIA_Parameters.xml @@ -104,44 +104,10 @@ <value val="0.0"/> </parameter> - <!-- TO BE REMOVED Diagnostic test defaults --> - - <parameter name="remove_zero"> - <value val="1.0" /> - </parameter> - - <parameter name="tiny"> - <value val="1e-10" /> - </parameter> - - <parameter name="large"> - <value val="1e10" /> - </parameter> - - <parameter name="median_lo"> - <value val="0.1" /> - </parameter> - - <parameter name="median_hi"> - <value val="3.0" /> + <!-- Variation for ratio test with second white beam --> + <parameter name="diag_variation"> + <value val="1.1"/> </parameter> - - <parameter name="signif"> - <value val="3.3" /> - </parameter> - - <parameter name="check_background"> - <value val="1.0" /> - </parameter> - - <parameter name="bkgd_threshold"> - <value val="5.0" /> - </parameter> - - <parameter name="variation"> - <value val="1.1" /> - </parameter> - <!-- --> <!-- Absolute units conversion average --> diff --git a/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py b/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py index d80c8d86433643936129c605eb02f463021277d1..753931bd80c1b00575ae26c23a10f35fc6ceba30 100755 --- a/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py +++ b/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py @@ -96,9 +96,6 @@ class DirectEnergyConversion(object): bleed test diagnostic print_results - If True then the results are printed to the screen """ - if kwargs.get('second_white', None) is not None: - raise RuntimeError("Diagnostic does not support second white beam run yet") - lhs_names = lhs_info('names') if len(lhs_names) > 0: var_name = lhs_names[0] @@ -113,6 +110,11 @@ class DirectEnergyConversion(object): # Get the white beam vanadium integrals whiteintegrals = self.do_white(white, None, None) # No grouping yet + if 'second_white' in kwargs: + second_white = kwargs['second_white'] + other_whiteintegrals = self.do_white(second_white, None, None) # No grouping yet + kwargs['second_white'] = other_whiteintegrals + # Get the background/total counts from the sample if present if 'sample' in kwargs: sample = kwargs['sample'] @@ -135,7 +137,7 @@ class DirectEnergyConversion(object): total_counts = Integration(result_ws, OutputWorkspace='total_counts', IncludePartialBins=True).workspace() background_int = ConvertUnits(background_int, background_int, "Energy", AlignBins=0).workspace() background_int *= 1.7016e8 - background_int /= whiteintegrals + diagnostics.normalise_background(background_int, whiteintegrals, kwargs.get('second_white',None)) kwargs['background_int'] = background_int kwargs['sample_counts'] = total_counts @@ -162,6 +164,8 @@ class DirectEnergyConversion(object): if 'sample_counts' in kwargs: DeleteWorkspace('background_int') DeleteWorkspace('total_counts') + if 'second_white' in kwargs: + DeleteWorkspace(kwargs['second_white']) # Return a mask workspace diag_mask = ExtractMasking(whiteintegrals, OutputWorkspace='diag_mask').workspace() DeleteWorkspace(whiteintegrals) @@ -178,9 +182,8 @@ class DirectEnergyConversion(object): Normalise to a specified white-beam run """ whitews_name = common.create_resultname(white_run, suffix='-white') - if mtd.workspaceExists(whitews_name): - return mtd[whitews_name] - + if whitews_name in mtd: + DeleteWorkspace(whitews_name) # Load white_data = self.load_data(white_run) # Normalise @@ -792,7 +795,7 @@ class DirectEnergyConversion(object): # Diag self.diag_params = ['diag_tiny', 'diag_huge', 'diag_samp_zero', 'diag_samp_lo', 'diag_samp_hi','diag_samp_sig',\ - 'diag_van_out_lo', 'diag_van_out_hi', 'diag_van_lo', 'diag_van_hi', 'diag_van_sig'] + 'diag_van_out_lo', 'diag_van_out_hi', 'diag_van_lo', 'diag_van_hi', 'diag_van_sig', 'diag_variation'] # Add an attribute for each of them for par in self.diag_params: setattr(self, par, self.get_default_parameter(par)) diff --git a/Code/Mantid/scripts/Inelastic/diagnostics.py b/Code/Mantid/scripts/Inelastic/diagnostics.py index cfd87c66a33a77397774fdd3d2c6d5984ab6caa6..ad2f6e7a6d1198664f0e483dbbe13df57a723328 100644 --- a/Code/Mantid/scripts/Inelastic/diagnostics.py +++ b/Code/Mantid/scripts/Inelastic/diagnostics.py @@ -59,62 +59,71 @@ def diagnose(white_int, **kwargs): bleed test diagnostic print_results - If True then the results are printed to the screen """ + if white_int is None and str(white_int) != '': + raise RuntimeError("No white beam integral specified. This is the minimum required to run diagnostics") + # Grab the arguments parser = ArgumentParser(kwargs) start_index = parser.start_index end_index = parser.end_index - - # Load the hard mask file if necessary - hard_mask_spectra = '' - if kwargs.get('hard_mask', None) is not None: - hard_mask_spectra = common.load_mask(hard_mask) # Map the test number to the results # Each element is the mask workspace name then the number of failures - test_results = [ [None, None], [None, None], [None, None], [None, None]] - + test_results = [ [None, None], [None, None], [None, None], [None, None], [None, None]] - ## - ## White beam Test - ## - white_counts = None - if white_int is not None and str(white_int) != '': - # Hard mask - MaskDetectors(white_int, SpectraList=hard_mask_spectra) - # Run first white beam tests - __white_masks, num_failed = _do_white_test(white_int, parser.tiny, parser.huge, + # Load the hard mask file if necessary + hard_mask_spectra = '' + if 'hard_mask' in kwargs: + hard_mask_spectra = common.load_mask(parser.hard_mask) + test_results[0][0] = os.path.basename(parser.hard_mask) + + # Hard mask + masking = MaskDetectors(white_int, SpectraList=hard_mask_spectra) + # Find out how many detectors we hard masked + hard_mask_spectra = masking['SpectraList'].value + test_results[0][1] = len(hard_mask_spectra) + + # White beam Test + __white_masks, num_failed = do_white_test(white_int, parser.tiny, parser.huge, + parser.van_out_lo, parser.van_out_hi, + parser.van_lo, parser.van_hi, + parser.van_sig, start_index, end_index) + test_results[1] = [str(__white_masks), num_failed] + add_masking(white_int, __white_masks, start_index, end_index) + DeleteWorkspace(__white_masks) + + # Second white beam test + if 'second_white' in kwargs: + __second_white_masks, num_failed = do_second_white_test(white_int, parser.second_white, parser.tiny, parser.huge, parser.van_out_lo, parser.van_out_hi, - parser.van_lo, parser.van_hi, + parser.van_lo, parser.van_hi, parser.variation, parser.van_sig, start_index, end_index) - test_results[0] = [str(__white_masks), num_failed] - _add_masking(white_int, __white_masks, start_index, end_index) - DeleteWorkspace(__white_masks) - else: - raise RuntimeError('Invalid input for white run "%s"' % str(white_int)) + test_results[2] = [str(__second_white_masks), num_failed] + add_masking(white_int, __second_white_masks, start_index, end_index) # # Zero total count check for sample counts # zero_count_failures = 0 - if hasattr(parser, 'sample_counts'): - _add_masking(parser.sample_counts, white_int) + if kwargs.get('sample_counts',None) is not None and kwargs.get('samp_zero',False): + add_masking(parser.sample_counts, white_int) checker = FindDetectorsOutsideLimits(InputWorkspace=parser.sample_counts, OutputWorkspace='maskZero', StartWorkspaceIndex=start_index, EndWorkspaceIndex=end_index, LowThreshold=1e-10, HighThreshold=1e100) zero_count_failures = checker['NumberOfFailures'].value maskZero = checker.workspace() - _add_masking(white_int, maskZero, start_index, end_index) + add_masking(white_int, maskZero, start_index, end_index) DeleteWorkspace(maskZero) - + # # Background check # if hasattr(parser, 'background_int'): - _add_masking(parser.background_int, white_int) - __bkgd_mask, failures = _do_background_test(parser.background_int, parser.samp_lo, - parser.samp_hi, parser.samp_sig, parser.samp_zero, start_index, end_index) - test_results[2] = [str(__bkgd_mask), zero_count_failures + failures] - _add_masking(white_int, __bkgd_mask, start_index, end_index) + add_masking(parser.background_int, white_int) + __bkgd_mask, failures = do_background_test(parser.background_int, parser.samp_lo, + parser.samp_hi, parser.samp_sig, parser.samp_zero, start_index, end_index) + test_results[3] = [str(__bkgd_mask), zero_count_failures + failures] + add_masking(white_int, __bkgd_mask, start_index, end_index) DeleteWorkspace(__bkgd_mask) # @@ -123,9 +132,9 @@ def diagnose(white_int, **kwargs): if hasattr(parser, 'bleed_test') and parser.bleed_test: if not hasattr(parser, 'sample_run'): raise RuntimeError("Bleed test requested but the sample_run keyword has not been provided") - __bleed_masks, failures = _do_bleed_test(parser.sample_run, parser.bleed_maxrate, parser.bleed_pixels) - test_results[3] = [str(__bleed_masks), failures] - _add_masking(white_int, __bleed_masks) + __bleed_masks, failures = do_bleed_test(parser.sample_run, parser.bleed_maxrate, parser.bleed_pixels) + test_results[4] = [str(__bleed_masks), failures] + add_masking(white_int, __bleed_masks) DeleteWorkspace(__bleed_masks) if hasattr(parser, 'print_results') and parser.print_results: @@ -133,7 +142,7 @@ def diagnose(white_int, **kwargs): #------------------------------------------------------------------------------- -def _add_masking(input_ws, mask_ws, start_index=None, end_index=None): +def add_masking(input_ws, mask_ws, start_index=None, end_index=None): """ Mask the Detectors on the input workspace that are masked on the mask_ws. Avoids a current bug in using MaskDetectors with a MaskedWorkspace in a loop @@ -145,8 +154,8 @@ def _add_masking(input_ws, mask_ws, start_index=None, end_index=None): #------------------------------------------------------------------------------- -def _do_white_test(white_int, tiny, large, out_lo, out_hi, median_lo, median_hi, sigma, - start_index=None, end_index=None): +def do_white_test(white_int, tiny, large, out_lo, out_hi, median_lo, median_hi, sigma, + start_index=None, end_index=None): """ Run the diagnostic tests on the integrated white beam run @@ -186,8 +195,9 @@ def _do_white_test(white_int, tiny, large, out_lo, out_hi, median_lo, median_hi, #------------------------------------------------------------------------------- -def _do_second_white_test(white_counts, comp_white_counts, tiny, large, median_lo, - median_hi, signif, variation): +def do_second_white_test(white_counts, comp_white_counts, tiny, large, out_lo, out_hi, + median_lo, median_hi, sigma, variation, + start_index=None, end_index=None): """ Run additional tests comparing given another white beam count workspace, comparing to the first @@ -207,7 +217,7 @@ def _do_second_white_test(white_counts, comp_white_counts, tiny, large, median_l variation - Defines a range within which the ratio of the two counts is allowed to fall in terms of the number of medians """ - mtd.sendLogMessage('Running second white beam test') + mtd.sendLogMessage('Running second white beam test') # What shall we call the output lhs_names = lhs_info('names') @@ -221,13 +231,15 @@ def _do_second_white_test(white_counts, comp_white_counts, tiny, large, median_l ConvertToMatrixWorkspace(comp_white_counts, comp_white_counts) # Do the white beam test - __second_white_tests, failed = _do_white_test(comp_white_counts, tiny, large, median_lo, median_hi, signif) + __second_white_tests, failed = do_white_test(comp_white_counts, tiny, large, median_lo, median_hi, + sigma, start_index, end_index) # and now compare it with the first - effic_var = DetectorEfficiencyVariation(white_counts, comp_white_counts, ws_name, Variation=variation) + effic_var = DetectorEfficiencyVariation(white_counts, comp_white_counts, ws_name, Variation=variation, + StartWorkspaceIndex=start_index, EndWorkspaceIndex=end_index,) # Total number of failures num_failed = effic_var['NumberOfFailures'].value + failed - mtd.deleteWorkspace(str(__second_white_tests)) + DeleteWorkspace(str(__second_white_tests)) # Mask those that failed maskWS = effic_var.workspace() MaskDetectors(white_counts, MaskedWorkspace=maskWS) @@ -236,8 +248,27 @@ def _do_second_white_test(white_counts, comp_white_counts, tiny, large, median_l return maskWS, num_failed #------------------------------------------------------------------------------ +def normalise_background(background_int, white_int, second_white_int=None): + """Normalize the background integrals + + If two white beam files are provided then the background integrals + are normalized by the harmonic mean of the two: + + hmean = 2.0/((1/v1) + (1/v2)) = 2v1*v2/(v1+v2) + + If only a single white + beam is provided then the background is normalized by the white beam itself + + """ + if second_white_int is None: + background_int /= white_int + else: + hmean = 2.0*white_int*second_white_int/(white_int+second_white_int) + background_int /= hmean + DeleteWorkspace(hmean) -def _do_background_test(background_int, median_lo, median_hi, sigma, mask_zero, +#------------------------------------------------------------------------------ +def do_background_test(background_int, median_lo, median_hi, sigma, mask_zero, start_index=None, end_index=None): """ Run the background tests @@ -252,10 +283,6 @@ def _do_background_test(background_int, median_lo, median_hi, sigma, mask_zero, """ mtd.sendLogMessage('Running background count test') - # If we need to remove zeroes as well then set the the low threshold to a tiny positive number - if mask_zero: - median_lo = 1e-40 - # What shall we call the output lhs_names = lhs_info('names') if len(lhs_names) > 0: @@ -273,7 +300,7 @@ def _do_background_test(background_int, median_lo, median_hi, sigma, mask_zero, #------------------------------------------------------------------------------- -def _do_bleed_test(sample_run, max_framerate, ignored_pixels): +def do_bleed_test(sample_run, max_framerate, ignored_pixels): """Runs the CreatePSDBleedMask algorithm Input: @@ -315,7 +342,7 @@ def print_test_summary(test_results): test_results - A list or tuple containing either the number of failed spectra or None indicating that the test was not run """ - num_diags = 4 + num_diags = 5 if len(test_results) != num_diags: raise ValueError("Invalid input for print_test_summary. A list of %d numbers is expected." % num_diags) @@ -329,10 +356,11 @@ def print_test_summary(test_results): return summary = ( - ['First white beam test:',test_results[0]], \ - ['Second white beam test:',test_results[1]], \ - ['Background test:',test_results[2]], \ - ['PSD Bleed test :',test_results[3]] \ + ['Hard mask:',test_results[0]], \ + ['First white beam test:',test_results[1]], \ + ['Second white beam test:',test_results[2]], \ + ['Background test:',test_results[3]], \ + ['PSD Bleed test :',test_results[4]] \ ) print '==== Diagnostic Test Summary ====' diff --git a/Code/Mantid/scripts/Interface/reduction_application.py b/Code/Mantid/scripts/Interface/reduction_application.py index 2b4072dd8c768d4cd9a3766a8286ffd14b74e2ef..1dd63eef89966613c1240341ca87166d54cf651e 100644 --- a/Code/Mantid/scripts/Interface/reduction_application.py +++ b/Code/Mantid/scripts/Interface/reduction_application.py @@ -404,7 +404,14 @@ class ReductionGUI(QtGui.QMainWindow, ui.ui_reduction_main.Ui_SANSReduction): file_path = unicode(action.data().toString()) # Check whether the file describes the current instrument - found_instrument = self._interface.scripter.verify_instrument(file_path) + try: + found_instrument = self._interface.scripter.verify_instrument(file_path) + except: + msg = "The file you attempted to load doesn't have a recognized format.\n\n" + msg += "Please make sure it has been produced by this application." + QtGui.QMessageBox.warning(self, "Error loading reduction parameter file", msg) + return + if not found_instrument == self._instrument: self._instrument = found_instrument self.setup_layout() diff --git a/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py b/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py index 3e38319b8a8f087204d472ead482ecd029a24fd5..c78cfee9b77b99cb89858fa3cfbdabdbd1660b1d 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py @@ -41,9 +41,11 @@ class DataSets(BaseScriptElement): script = "RefLReduction(RunNumbers=%s,\n" % ','.join([str(i) for i in self.data_files]) script += " NormalizationRunNumber=%d,\n" % self.norm_file script += " SignalPeakPixelRange=%s,\n" % str(self.DataPeakPixels) + script += " SubtractSignalBackground=%s,\n" % str(self.DataBackgroundFlag) script += " SignalBackgroundPixelRange=%s,\n" % str(self.DataBackgroundRoi[:2]) script += " NormPeakPixelRange=%s,\n" % str(self.NormPeakPixels) script += " NormBackgroundPixelRange=%s,\n" % str(self.NormBackgroundRoi) + script += " SubtractNormBackground=%s,\n" % str(self.NormBackgroundFlag) script += " LowResAxisPixelRange=%s,\n" % str(self.x_range) script += " TOFRange=%s,\n" % str(self.DataTofRange) script += " Binning=[0,200,200000],\n" @@ -115,7 +117,7 @@ class DataSets(BaseScriptElement): BaseScriptElement.getIntElement(instrument_dom, "x_max_pixel")] #discrete selection string - self.DataBackgroundFlag = BaseScriptElement.getStringElement(instrument_dom, "peak_discrete_selection") + self.DataPeakDiscreteSelection = BaseScriptElement.getStringElement(instrument_dom, "peak_discrete_selection") #background flag self.DataBackgroundFlag = BaseScriptElement.getBoolElement(instrument_dom, "background_flag") diff --git a/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py b/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py index 35e1d0c9113004a8a6c43cd9312de277aa33123c..c8cdd9b6a6d459a4b59f157d4fc37b17b0cb74d3 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/widgets/reflectometer/refl_data_simple.py @@ -59,12 +59,22 @@ class DataReflWidget(BaseWidget): self._summary.data_to_tof.setValidator(QtGui.QDoubleValidator(self._summary.data_to_tof)) # Event connections + self.connect(self._summary.norm_background_switch, QtCore.SIGNAL("clicked(bool)"), self._norm_background_clicked) self.connect(self._summary.data_background_switch, QtCore.SIGNAL("clicked(bool)"), self._data_background_clicked) self.connect(self._summary.plot_count_vs_y_btn, QtCore.SIGNAL("clicked()"), self._plot_count_vs_y) self.connect(self._summary.plot_tof_btn, QtCore.SIGNAL("clicked()"), self._plot_tof) self.connect(self._summary.add_dataset_btn, QtCore.SIGNAL("clicked()"), self._add_data) self.connect(self._summary.angle_list, QtCore.SIGNAL("itemSelectionChanged()"), self._angle_changed) + def is_running(self, is_running): + """ + Enable/disable controls depending on whether a reduction is running or not + @param is_running: True if a reduction is running + """ + super(DataReflWidget, self).is_running(is_running) + self._summary.plot_count_vs_y_btn.setEnabled(not is_running) + self._summary.plot_tof_btn.setEnabled(not is_running) + def _data_background_clicked(self, is_checked): """ This is reached when the user clicks the Background switch and will enabled or not @@ -75,6 +85,16 @@ class DataReflWidget(BaseWidget): self._summary.data_background_to_pixel1.setEnabled(is_checked) self._summary.data_background_to_pixel1_label.setEnabled(is_checked) + def _norm_background_clicked(self, is_checked): + """ + This is reached when the user clicks the Background switch and will enabled or not + the widgets that follow that button + """ + self._summary.norm_background_from_pixel1.setEnabled(is_checked) + self._summary.norm_background_from_pixel1_label.setEnabled(is_checked) + self._summary.norm_background_to_pixel1.setEnabled(is_checked) + self._summary.norm_background_to_pixel1_label.setEnabled(is_checked) + def _plot_count_vs_y(self): f = FileFinder.findRuns("REF_L%s" % str(self._summary.data_run_number_edit.text())) if len(f)>0 and os.path.isfile(f[0]): diff --git a/Code/Mantid/scripts/Interface/ui/reflectometer/data_refl_simple.ui b/Code/Mantid/scripts/Interface/ui/reflectometer/data_refl_simple.ui index 3f5b9841c80eac942b6969d6584d9343759a9be2..816043acfc287f6c1d7c3948a32e998dd34a7098 100644 --- a/Code/Mantid/scripts/Interface/ui/reflectometer/data_refl_simple.ui +++ b/Code/Mantid/scripts/Interface/ui/reflectometer/data_refl_simple.ui @@ -578,7 +578,7 @@ </palette> </property> <property name="text"> - <string>*</string> + <string/> </property> </widget> </item> @@ -667,7 +667,7 @@ </palette> </property> <property name="text"> - <string>*</string> + <string/> </property> </widget> </item> @@ -1064,7 +1064,7 @@ </widget> </item> <item> - <widget class="QLabel" name="data_peak_from_pixel_missing_2"> + <widget class="QLabel" name="norm_peak_from_pixel_missing"> <property name="minimumSize"> <size> <width>10</width> @@ -1493,7 +1493,7 @@ </palette> </property> <property name="text"> - <string>*</string> + <string/> </property> </widget> </item> @@ -1543,7 +1543,7 @@ </widget> </item> <item> - <widget class="QLabel" name="data_peak_to_pixel_missing_2"> + <widget class="QLabel" name="norm_peak_to_pixel_missing"> <property name="palette"> <palette> <active> @@ -1582,7 +1582,7 @@ </palette> </property> <property name="text"> - <string>*</string> + <string/> </property> </widget> </item> @@ -1626,7 +1626,7 @@ </widget> </item> <item> - <widget class="QLabel" name="data_background_from_pixel1_label_2"> + <widget class="QLabel" name="norm_background_from_pixel1_label"> <property name="enabled"> <bool>false</bool> </property> @@ -1739,7 +1739,7 @@ </spacer> </item> <item> - <widget class="QLabel" name="data_background_to_pixel1_label_2"> + <widget class="QLabel" name="norm_background_to_pixel1_label"> <property name="enabled"> <bool>false</bool> </property> diff --git a/Code/Mantid/scripts/Interface/ui/reflectometer/ui_data_refl_simple.py b/Code/Mantid/scripts/Interface/ui/reflectometer/ui_data_refl_simple.py index 5ceb266cecbe46092088231839705aaf50ff0148..e5f1bb8af54bae7566c697849a80d6f155954367 100644 --- a/Code/Mantid/scripts/Interface/ui/reflectometer/ui_data_refl_simple.py +++ b/Code/Mantid/scripts/Interface/ui/reflectometer/ui_data_refl_simple.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'ui/reflectometer/data_refl_simple.ui' # -# Created: Thu Jan 19 16:16:39 2012 +# Created: Fri Jan 20 08:47:21 2012 # by: PyQt4 UI code generator 4.7.4 # # WARNING! All changes made in this file will be lost! @@ -216,6 +216,7 @@ class Ui_Frame(object): brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) self.data_peak_from_pixel_missing.setPalette(palette) + self.data_peak_from_pixel_missing.setText("") self.data_peak_from_pixel_missing.setObjectName("data_peak_from_pixel_missing") self.horizontalLayout_3.addWidget(self.data_peak_from_pixel_missing) spacerItem = QtGui.QSpacerItem(30, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) @@ -245,6 +246,7 @@ class Ui_Frame(object): brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) self.data_peak_to_pixel_missing.setPalette(palette) + self.data_peak_to_pixel_missing.setText("") self.data_peak_to_pixel_missing.setObjectName("data_peak_to_pixel_missing") self.horizontalLayout_3.addWidget(self.data_peak_to_pixel_missing) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) @@ -372,9 +374,9 @@ class Ui_Frame(object): self.norm_peak_from_pixel.setMaximumSize(QtCore.QSize(50, 16777215)) self.norm_peak_from_pixel.setObjectName("norm_peak_from_pixel") self.horizontalLayout_4.addWidget(self.norm_peak_from_pixel) - self.data_peak_from_pixel_missing_2 = QtGui.QLabel(self.groupBox_2) - self.data_peak_from_pixel_missing_2.setMinimumSize(QtCore.QSize(10, 0)) - self.data_peak_from_pixel_missing_2.setMaximumSize(QtCore.QSize(10, 16777215)) + self.norm_peak_from_pixel_missing = QtGui.QLabel(self.groupBox_2) + self.norm_peak_from_pixel_missing.setMinimumSize(QtCore.QSize(10, 0)) + self.norm_peak_from_pixel_missing.setMaximumSize(QtCore.QSize(10, 16777215)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(203, 33, 5)) brush.setStyle(QtCore.Qt.SolidPattern) @@ -511,9 +513,10 @@ class Ui_Frame(object): brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) - self.data_peak_from_pixel_missing_2.setPalette(palette) - self.data_peak_from_pixel_missing_2.setObjectName("data_peak_from_pixel_missing_2") - self.horizontalLayout_4.addWidget(self.data_peak_from_pixel_missing_2) + self.norm_peak_from_pixel_missing.setPalette(palette) + self.norm_peak_from_pixel_missing.setText("") + self.norm_peak_from_pixel_missing.setObjectName("norm_peak_from_pixel_missing") + self.horizontalLayout_4.addWidget(self.norm_peak_from_pixel_missing) spacerItem6 = QtGui.QSpacerItem(30, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem6) self.data_peak_to_pixel_label_2 = QtGui.QLabel(self.groupBox_2) @@ -529,7 +532,7 @@ class Ui_Frame(object): self.norm_peak_to_pixel.setMaximumSize(QtCore.QSize(50, 16777215)) self.norm_peak_to_pixel.setObjectName("norm_peak_to_pixel") self.horizontalLayout_4.addWidget(self.norm_peak_to_pixel) - self.data_peak_to_pixel_missing_2 = QtGui.QLabel(self.groupBox_2) + self.norm_peak_to_pixel_missing = QtGui.QLabel(self.groupBox_2) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(220, 27, 7)) brush.setStyle(QtCore.Qt.SolidPattern) @@ -540,9 +543,10 @@ class Ui_Frame(object): brush = QtGui.QBrush(QtGui.QColor(69, 69, 69)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) - self.data_peak_to_pixel_missing_2.setPalette(palette) - self.data_peak_to_pixel_missing_2.setObjectName("data_peak_to_pixel_missing_2") - self.horizontalLayout_4.addWidget(self.data_peak_to_pixel_missing_2) + self.norm_peak_to_pixel_missing.setPalette(palette) + self.norm_peak_to_pixel_missing.setText("") + self.norm_peak_to_pixel_missing.setObjectName("norm_peak_to_pixel_missing") + self.horizontalLayout_4.addWidget(self.norm_peak_to_pixel_missing) spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem7) self.verticalLayout_2.addLayout(self.horizontalLayout_4) @@ -553,10 +557,10 @@ class Ui_Frame(object): self.norm_background_switch.setMaximumSize(QtCore.QSize(150, 16777215)) self.norm_background_switch.setObjectName("norm_background_switch") self.horizontalLayout_10.addWidget(self.norm_background_switch) - self.data_background_from_pixel1_label_2 = QtGui.QLabel(self.groupBox_2) - self.data_background_from_pixel1_label_2.setEnabled(False) - self.data_background_from_pixel1_label_2.setObjectName("data_background_from_pixel1_label_2") - self.horizontalLayout_10.addWidget(self.data_background_from_pixel1_label_2) + self.norm_background_from_pixel1_label = QtGui.QLabel(self.groupBox_2) + self.norm_background_from_pixel1_label.setEnabled(False) + self.norm_background_from_pixel1_label.setObjectName("norm_background_from_pixel1_label") + self.horizontalLayout_10.addWidget(self.norm_background_from_pixel1_label) self.norm_background_from_pixel1 = QtGui.QLineEdit(self.groupBox_2) self.norm_background_from_pixel1.setEnabled(False) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) @@ -588,10 +592,10 @@ class Ui_Frame(object): self.horizontalLayout_10.addWidget(self.data_background_from_pixel_missing_2) spacerItem8 = QtGui.QSpacerItem(30, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.horizontalLayout_10.addItem(spacerItem8) - self.data_background_to_pixel1_label_2 = QtGui.QLabel(self.groupBox_2) - self.data_background_to_pixel1_label_2.setEnabled(False) - self.data_background_to_pixel1_label_2.setObjectName("data_background_to_pixel1_label_2") - self.horizontalLayout_10.addWidget(self.data_background_to_pixel1_label_2) + self.norm_background_to_pixel1_label = QtGui.QLabel(self.groupBox_2) + self.norm_background_to_pixel1_label.setEnabled(False) + self.norm_background_to_pixel1_label.setObjectName("norm_background_to_pixel1_label") + self.horizontalLayout_10.addWidget(self.norm_background_to_pixel1_label) self.norm_background_to_pixel1 = QtGui.QLineEdit(self.groupBox_2) self.norm_background_to_pixel1.setEnabled(False) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) @@ -663,9 +667,7 @@ class Ui_Frame(object): self.label.setText(QtGui.QApplication.translate("Frame", "Run number", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(QtGui.QApplication.translate("Frame", "Peak selection", None, QtGui.QApplication.UnicodeUTF8)) self.data_peak_from_pixel_label.setText(QtGui.QApplication.translate("Frame", "from pixel", None, QtGui.QApplication.UnicodeUTF8)) - self.data_peak_from_pixel_missing.setText(QtGui.QApplication.translate("Frame", "*", None, QtGui.QApplication.UnicodeUTF8)) self.data_peak_to_pixel_label.setText(QtGui.QApplication.translate("Frame", "to pixel", None, QtGui.QApplication.UnicodeUTF8)) - self.data_peak_to_pixel_missing.setText(QtGui.QApplication.translate("Frame", "*", None, QtGui.QApplication.UnicodeUTF8)) self.data_background_switch.setText(QtGui.QApplication.translate("Frame", "Background", None, QtGui.QApplication.UnicodeUTF8)) self.data_background_from_pixel1_label.setText(QtGui.QApplication.translate("Frame", "from pixel", None, QtGui.QApplication.UnicodeUTF8)) self.data_background_to_pixel1_label.setText(QtGui.QApplication.translate("Frame", "to pixel", None, QtGui.QApplication.UnicodeUTF8)) @@ -676,12 +678,10 @@ class Ui_Frame(object): self.label_3.setText(QtGui.QApplication.translate("Frame", "Run number", None, QtGui.QApplication.UnicodeUTF8)) self.label_4.setText(QtGui.QApplication.translate("Frame", "Peak selection", None, QtGui.QApplication.UnicodeUTF8)) self.data_peak_from_pixel_label_2.setText(QtGui.QApplication.translate("Frame", "from pixel", None, QtGui.QApplication.UnicodeUTF8)) - self.data_peak_from_pixel_missing_2.setText(QtGui.QApplication.translate("Frame", "*", None, QtGui.QApplication.UnicodeUTF8)) self.data_peak_to_pixel_label_2.setText(QtGui.QApplication.translate("Frame", "to pixel", None, QtGui.QApplication.UnicodeUTF8)) - self.data_peak_to_pixel_missing_2.setText(QtGui.QApplication.translate("Frame", "*", None, QtGui.QApplication.UnicodeUTF8)) self.norm_background_switch.setText(QtGui.QApplication.translate("Frame", "Background", None, QtGui.QApplication.UnicodeUTF8)) - self.data_background_from_pixel1_label_2.setText(QtGui.QApplication.translate("Frame", "from pixel", None, QtGui.QApplication.UnicodeUTF8)) - self.data_background_to_pixel1_label_2.setText(QtGui.QApplication.translate("Frame", "to pixel", None, QtGui.QApplication.UnicodeUTF8)) + self.norm_background_from_pixel1_label.setText(QtGui.QApplication.translate("Frame", "from pixel", None, QtGui.QApplication.UnicodeUTF8)) + self.norm_background_to_pixel1_label.setText(QtGui.QApplication.translate("Frame", "to pixel", None, QtGui.QApplication.UnicodeUTF8)) self.label_14.setText(QtGui.QApplication.translate("Frame", "From TOF", None, QtGui.QApplication.UnicodeUTF8)) self.label_15.setText(QtGui.QApplication.translate("Frame", "microS to TOF", None, QtGui.QApplication.UnicodeUTF8)) self.label_16.setText(QtGui.QApplication.translate("Frame", "microS", None, QtGui.QApplication.UnicodeUTF8))