Esempio n. 1
0
//----------------------------------------------------------------------------------------------
/// @copydoc Mantid::API::Algorithm::init()
void LoadPreNexus::init()
{
    // runfile to read in
    declareProperty(new FileProperty(RUNINFO_PARAM, "", FileProperty::Load, "_runinfo.xml"),
                    "The name of the runinfo file to read, including its full or relative path.");

    // copied (by hand) from LoadEventPreNexus2
    declareProperty(new FileProperty(MAP_PARAM, "", FileProperty::OptionalLoad, ".dat"),
                    "File containing the pixel mapping (DAS pixels to pixel IDs) file (typically INSTRUMENT_TS_YYYY_MM_DD.dat). The filename will be found automatically if not specified.");
    auto mustBePositive = boost::make_shared<BoundedValidator<int> >();
    mustBePositive->setLower(1);
    declareProperty("ChunkNumber", EMPTY_INT(), mustBePositive,
                    "If loading the file by sections ('chunks'), this is the section number of this execution of the algorithm.");
    declareProperty("TotalChunks", EMPTY_INT(), mustBePositive,
                    "If loading the file by sections ('chunks'), this is the total number of sections.");
    // TotalChunks is only meaningful if ChunkNumber is set
    // Would be nice to be able to restrict ChunkNumber to be <= TotalChunks at validation
    setPropertySettings("TotalChunks", new VisibleWhenProperty("ChunkNumber", IS_NOT_DEFAULT));
    std::vector<std::string> propOptions;
    propOptions.push_back("Auto");
    propOptions.push_back("Serial");
    propOptions.push_back("Parallel");
    declareProperty("UseParallelProcessing", "Auto", boost::make_shared<StringListValidator>(propOptions),
                    "Use multiple cores for loading the data?\n"
                    "  Auto: Use serial loading for small data sets, parallel for large data sets.\n"
                    "  Serial: Use a single core.\n"
                    "  Parallel: Use all available cores.");

    declareProperty(new PropertyWithValue<bool>("LoadMonitors", true, Direction::Input),
                    "Load the monitors from the file.");


    declareProperty(new WorkspaceProperty<>("OutputWorkspace","",Direction::Output), "An output workspace.");
}
/**
 * Initialize common properties
 */
void SpecularReflectionAlgorithm::initCommonProperties() {
  std::stringstream message;
  message << "The type of analysis to perform. " << multiDetectorAnalysis
          << ", " << lineDetectorAnalysis << " or " << multiDetectorAnalysis
          << ". Used to help automatically determine the detector components "
             "to move";

  std::vector<std::string> propOptions;
  propOptions.push_back(pointDetectorAnalysis);
  propOptions.push_back(lineDetectorAnalysis);
  propOptions.push_back(multiDetectorAnalysis);

  declareProperty("AnalysisMode", pointDetectorAnalysis,
                  boost::make_shared<StringListValidator>(propOptions),
                  message.str());

  declareProperty(make_unique<PropertyWithValue<std::string>>(
                      "DetectorComponentName", "", Direction::Input),
                  "Name of the detector component i.e. point-detector. If "
                  "these are not specified, the algorithm will attempt lookup "
                  "using a standard naming convention.");

  declareProperty(make_unique<PropertyWithValue<std::string>>(
                      "SampleComponentName", "", Direction::Input),
                  "Name of the sample component i.e. some-surface-holder. If "
                  "these are not specified, the algorithm will attempt lookup "
                  "using a standard naming convention.");

  auto boundedArrayValidator = boost::make_shared<ArrayBoundedValidator<int>>();
  boundedArrayValidator->setLower(0);
  declareProperty(
      make_unique<ArrayProperty<int>>("SpectrumNumbersOfDetectors",
                                      boundedArrayValidator, Direction::Input),
      "A list of spectrum numbers making up an effective point detector.");

  declareProperty(make_unique<PropertyWithValue<bool>>("StrictSpectrumChecking",
                                                       true, Direction::Input),
                  "Enable, disable strict spectrum checking. Strict spectrum "
                  "checking protects against non-sequential integers in which "
                  "spectrum numbers are not in {min, min+1, ..., max}");

  setPropertySettings("SpectrumNumbersOfDetectors",
                      make_unique<Kernel::EnabledWhenProperty>(
                          "SampleComponentName", IS_NOT_DEFAULT));
}
/** Initialize the algorithm, i.e, declare properties
 */
void LoadEventPreNexus2::init() {
  // which files to use
  vector<string> eventExts(EVENT_EXTS, EVENT_EXTS + NUM_EXT);
  declareProperty(
      Kernel::make_unique<FileProperty>(EVENT_PARAM, "", FileProperty::Load,
                                        eventExts),
      "The name of the neutron event file to read, including its full or "
      "relative path. In most cases, the file typically ends in "
      "neutron_event.dat (N.B. case sensitive if running on Linux).");
  vector<string> pulseExts(PULSE_EXTS, PULSE_EXTS + NUM_EXT);
  declareProperty(Kernel::make_unique<FileProperty>(
                      PULSEID_PARAM, "", FileProperty::OptionalLoad, pulseExts),
                  "File containing the accelerator pulse information; the "
                  "filename will be found automatically if not specified.");
  declareProperty(
      Kernel::make_unique<FileProperty>(MAP_PARAM, "",
                                        FileProperty::OptionalLoad, ".dat"),
      "File containing the pixel mapping (DAS pixels to pixel IDs) file "
      "(typically INSTRUMENT_TS_YYYY_MM_DD.dat). The filename will be found "
      "automatically if not specified.");

  // which pixels to load
  declareProperty(Kernel::make_unique<ArrayProperty<int64_t>>(PID_PARAM),
                  "A list of individual spectra (pixel IDs) to read, specified "
                  "as e.g. 10:20. Only used if set.");

  auto mustBePositive = boost::make_shared<BoundedValidator<int>>();
  mustBePositive->setLower(1);
  declareProperty("ChunkNumber", EMPTY_INT(), mustBePositive,
                  "If loading the file by sections ('chunks'), this is the "
                  "section number of this execution of the algorithm.");
  declareProperty("TotalChunks", EMPTY_INT(), mustBePositive,
                  "If loading the file by sections ('chunks'), this is the "
                  "total number of sections.");
  // TotalChunks is only meaningful if ChunkNumber is set
  // Would be nice to be able to restrict ChunkNumber to be <= TotalChunks at
  // validation
  setPropertySettings("TotalChunks", make_unique<VisibleWhenProperty>(
                                         "ChunkNumber", IS_NOT_DEFAULT));

  std::vector<std::string> propOptions{"Auto", "Serial", "Parallel"};
  declareProperty("UseParallelProcessing", "Auto",
                  boost::make_shared<StringListValidator>(propOptions),
                  "Use multiple cores for loading the data?\n"
                  "  Auto: Use serial loading for small data sets, parallel "
                  "for large data sets.\n"
                  "  Serial: Use a single core.\n"
                  "  Parallel: Use all available cores.");

  // the output workspace name
  declareProperty(Kernel::make_unique<WorkspaceProperty<IEventWorkspace>>(
                      OUT_PARAM, "", Direction::Output),
                  "The name of the workspace that will be created, filled "
                  "with the read-in "
                  "data and stored in the [[Analysis Data Service]].");

  declareProperty(Kernel::make_unique<WorkspaceProperty<MatrixWorkspace>>(
                      "EventNumberWorkspace", "", Direction::Output,
                      PropertyMode::Optional),
                  "Workspace with number of events per pulse");

  // Some debugging options
  auto mustBeNonNegative = boost::make_shared<BoundedValidator<int>>();
  mustBeNonNegative->setLower(0);
  declareProperty("DBOutputBlockNumber", EMPTY_INT(), mustBeNonNegative,
                  "Index of the loading block for debugging output. ");

  declareProperty("DBNumberOutputEvents", 40, mustBePositive,
                  "Number of output events for debugging purpose.  Must be "
                  "defined with DBOutputBlockNumber.");

  declareProperty("DBNumberOutputPulses", EMPTY_INT(), mustBePositive,
                  "Number of output pulses for debugging purpose. ");

  std::string dbgrp = "Investigation Use";
  setPropertyGroup("EventNumberWorkspace", dbgrp);
  setPropertyGroup("DBOutputBlockNumber", dbgrp);
  setPropertyGroup("DBNumberOutputEvents", dbgrp);
  setPropertyGroup("DBNumberOutputPulses", dbgrp);
}
Esempio n. 4
0
    /** Initialize the algorithm's properties.
    */
    void ConvertToMDParent::init()
    {
      auto ws_valid = boost::make_shared<CompositeValidator>();
      //
      ws_valid->add<InstrumentValidator>();
      // the validator which checks if the workspace has axis and any units
      ws_valid->add<WorkspaceUnitValidator>("");


      declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace","",Direction::Input,ws_valid),
        "An input Matrix Workspace (2DMatrix or Event workspace) ");


      std::vector<std::string> Q_modes = MDEvents::MDTransfFactory::Instance().getKeys();
      // something to do with different moments of time when algorithm or test loads library. To avoid empty factory always do this. 
      if(Q_modes.empty()) Q_modes.assign(1,"ERROR IN LOADING Q-converters");

      /// this variable describes default possible ID-s for Q-dimensions   
      declareProperty("QDimensions",Q_modes[0],boost::make_shared<StringListValidator>(Q_modes),
        "String, describing available analysis modes, registered with MD Transformation factory."
        "There are 3 modes currently available and described in details on *MD Transformation factory* page."
        "The modes names are **CopyToMD**, **|Q|** and **Q3D**",
        Direction::InOut);
      /// temporary, until dEMode is not properly defined on Workspace
      std::vector<std::string> dE_modes = Kernel::DeltaEMode().availableTypes();
      declareProperty("dEAnalysisMode",dE_modes[Kernel::DeltaEMode::Direct],boost::make_shared<StringListValidator>(dE_modes),
        "You can analyze neutron energy transfer in **Direct**, **Indirect** or **Elastic** mode."
        "The analysis mode has to correspond to experimental set up. Selecting inelastic mode increases"
        "the number of the target workspace dimensions by one. See *MD Transformation factory* for further details.",
        Direction::InOut);

      MDEvents::MDWSTransform QSclAndFrames;
      std::vector<std::string> TargFrames = QSclAndFrames.getTargetFrames();
      declareProperty("Q3DFrames", TargFrames[CnvrtToMD::AutoSelect],boost::make_shared<StringListValidator>(TargFrames),
        "Selects Q-dimensions of the output workspace in **Q3D** case. "
        " **AutoSelect**: Choose the target coordinate frame as the function of goniometer and UB matrix values set on the input workspace."
        " **Q (lab frame)**: Wave-vector converted into the lab frame."
        " **Q (sample frame)**: Wave-vector converted into the frame of the sample (taking out the goniometer rotation)."
        " **HKL**: Use the sample's UB matrix to convert Wave-vector to crystal's HKL indices."
        "See *MD Transformation factory* **(Q3D)** for more details about this. "
        );


      std::vector<std::string> QScales = QSclAndFrames.getQScalings();
      declareProperty("QConversionScales",QScales[CnvrtToMD::NoScaling], boost::make_shared<StringListValidator>(QScales),
        "This property to normalize three momentums obtained in **Q3D** mode."
        " See *MD Transformation factory* "
        "for description and available scaling modes. The value can be modified depending on the target coordinate "
        "system, defined by the property **OutputDimensions**. "
        );


      setPropertySettings("Q3DFrames",new Kernel::VisibleWhenProperty("QDimensions",IS_EQUAL_TO,"Q3D"));
      setPropertySettings("QconversionScales",new Kernel::VisibleWhenProperty("QDimensions",IS_EQUAL_TO,"Q3D"));



      declareProperty(new ArrayProperty<std::string>("OtherDimensions",Direction::Input),
        "List(comma separated) of additional to **Q** and **DeltaE** variables which form additional "
        "(orthogonal) to **Q** dimensions in the target workspace (e.g. Temperature or Magnetic field). "
        "These variables had to be logged during experiment and the names of these variables have to coincide "
        "with the log names for the records of these variables in the source workspace."
        );

      // this property is mainly for ChildAlgorithms to set-up as they have to identify if they use the same instrument. 
      declareProperty(new PropertyWithValue<std::string>("PreprocDetectorsWS","PreprocessedDetectorsWS",Direction::Input), 
        "The name of the table workspace where the part of the detectors transformation into reciprocal space, "
        "calculated by :ref:`algm-PreprocessDetectorsToMD` algorithm is stored. If the workspace is not found in analysis "
        "data service, :ref:`algm-PreprocessDetectorsToMD` used to calculate it. If found, the algorithm uses existing "
        "workspace. The field is useful if one expects to analyze number of different experiments obtained on "
        "the same instrument."
        ".. warning:: Dangerous if one uses number of workspaces with modified derived instrument one after another."
        " *In this case this property has to be set to* **\"-\"** *sting (minus without quotes) or empty (possible from script only) "
        "to force the workspace recalculation each time the algorithm is invoked.*"
        );

      declareProperty(new PropertyWithValue<bool>("UpdateMasks", false, Direction::Input),
        "if PreprocessDetectorWS is used to build the workspace with preprocessed detectors at first algorithm call,"
        "and the input workspaces instruments are different by just different masked detectors, setting this "
        "option to true forces :ref:`algm-PreprocessDetectorsToMD`  update only the detectors masks for all subsequent "
        "calls to this algorithm."
        ".. warning:: *This is temporary solution necessary until Mantid masks spectra by 0 rather then by NaN.*"
        );

      // if one needs to use Lorentz corrections
      declareProperty(new PropertyWithValue<bool>("LorentzCorrection", false, Direction::Input),
        "Correct the weights of events or signals and errors transformed into reciprocal space by multiplying them "
        "by the Lorentz multiplier:\n :math:`sin(\\theta)^2/\\lambda^4`. Currently works in Q3D Elastic case only "
        "and is ignored in any other case."
        );
      declareProperty(new PropertyWithValue<bool>("IgnoreZeroSignals", false, Direction::Input),
        "Enabling this property forces the algorithm to ignore bins with zero signal for an input matrix workspace. Input event workspaces are not affected. "
        "This violates the data normalization but may substantially accelerate calculations in situations when the normalization is not important (e.g. peak finding)."
        );

      declareProperty(new ArrayProperty<double>("Uproj"),
        //"The functionality of this parameter set to non-default value is still not fully verified (see ticket #5982). "
        "Defines the first projection vector of the target Q coordinate system in **Q3D** mode - Default (1,0,0)");

      declareProperty(new ArrayProperty<double>("Vproj"),
        //"The functionality of this parameter set to non-default value is still not fully verified (see ticket #5982). "
        "Defines the second projection vector of the target Q coordinate system in **Q3D** mode - Default (0,1,0).");

      declareProperty(new ArrayProperty<double>("Wproj"),
        //"The functionality of this parameter set to non-default value is still not fully verified (see ticket #5982). "
        "Defines the third projection vector of the target Q coordinate system in **Q3D** mode. - Default (0,0,1)");

    }