Пример #1
0
/**
 * Shift the time in a time series. This is similar to the implementation in
 * @param ws :: a matrix workspace
 * @param prop :: a time series log
 * @param timeShift :: the time shift in seconds
 */
void ChangeTimeZero::shiftTimeInLogForTimeSeries(
    Mantid::API::MatrixWorkspace_sptr ws, Mantid::Kernel::Property *prop,
    double timeShift) const {
  if (auto timeSeries =
          dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(prop)) {
    auto newlog = timeSeries->cloneWithTimeShift(timeShift);
    ws->mutableRun().addProperty(newlog, true);
  }
}
Пример #2
0
/**
 * Change the time of the logs.
 * @param ws :: a workspace
 * @param timeShift :: the time shift that is applied to the log files
 * @param startProgress :: start point of the progress
 * @param stopProgress :: end point of the progress
 */
void ChangeTimeZero::shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws,
                                     double timeShift, double startProgress,
                                     double stopProgress) {
  // We need to change the entries for each log which can be:
  // 1. any time series: here we change the time values
  // 2. string properties: here we change the values if they are ISO8601 times
  auto logs = ws->mutableRun().getLogData();
  Progress prog(this, startProgress, stopProgress, logs.size());
  for (auto iter = logs.begin(); iter != logs.end(); ++iter) {
    if (isTimeSeries(*iter)) {
      shiftTimeInLogForTimeSeries(ws, *iter, timeShift);

    } else if (auto stringProperty =
                   dynamic_cast<PropertyWithValue<std::string> *>(*iter)) {
      shiftTimeOfLogForStringProperty(stringProperty, timeShift);
    }

    prog.report(name());
  }
}