本文整理汇总了C++中api::ITableWorkspace_sptr类的典型用法代码示例。如果您正苦于以下问题:C++ ITableWorkspace_sptr类的具体用法?C++ ITableWorkspace_sptr怎么用?C++ ITableWorkspace_sptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ITableWorkspace_sptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mergeTables
void EnggDiffFittingModel::mergeTables(
const API::ITableWorkspace_sptr tableToCopy,
API::ITableWorkspace_sptr targetTable) const {
for (size_t i = 0; i < tableToCopy->rowCount(); ++i) {
API::TableRow rowToCopy = tableToCopy->getRow(i);
API::TableRow newRow = targetTable->appendRow();
for (size_t j = 0; j < tableToCopy->columnCount(); ++j) {
double valueToCopy;
rowToCopy >> valueToCopy;
newRow << valueToCopy;
}
}
}
开发者ID:DanNixon,项目名称:mantid,代码行数:14,代码来源:EnggDiffFittingModel.cpp
示例2: getDomainSize
size_t LatticeDomainCreator::getDomainSize() const {
API::IPeaksWorkspace_sptr peaksWorkspace =
boost::dynamic_pointer_cast<IPeaksWorkspace>(m_workspace);
if (peaksWorkspace) {
return peaksWorkspace->getNumberPeaks();
}
API::ITableWorkspace_sptr tableWorkspace =
boost::dynamic_pointer_cast<ITableWorkspace>(m_workspace);
if (tableWorkspace) {
return tableWorkspace->rowCount();
}
return 0;
}
开发者ID:DanNixon,项目名称:mantid,代码行数:15,代码来源:LatticeDomainCreator.cpp
示例3: getTableRowNumbers
/* This function fills in a list of the row numbers starting 0 of the parameters
in the table workspace, so one can find the position in a column of
the value of the given parameter.
*/
void LoadFullprofResolution::getTableRowNumbers(
const API::ITableWorkspace_sptr &tablews,
std::map<std::string, size_t> ¶mmap) {
parammap.clear();
size_t numrows = tablews->rowCount();
for (size_t i = 0; i < numrows; ++i) {
TableRow row = tablews->getRow(i);
std::string name;
row >> name;
parammap.emplace(name, i);
}
return;
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:19,代码来源:LoadFullprofResolution.cpp
示例4: saveInvestigations
/** This method saves investigations to a table workspace
* @param investigations :: a vector containing investigation data
* @param outputws :: shared pointer to output workspace
*/
void CICatHelper::saveInvestigations(
const std::vector<ns1__investigation *> &investigations,
API::ITableWorkspace_sptr &outputws) {
try {
std::vector<ns1__investigation *>::const_iterator citr;
for (citr = investigations.begin(); citr != investigations.end(); ++citr) {
API::TableRow t = outputws->appendRow();
std::string id = std::to_string(*(*citr)->id);
savetoTableWorkspace(&id, t);
savetoTableWorkspace((*citr)->facility, t);
savetoTableWorkspace((*citr)->title, t);
savetoTableWorkspace((*citr)->instrument, t);
savetoTableWorkspace((*citr)->invParamValue, t);
std::string startDate = std::to_string(*(*citr)->invStartDate);
savetoTableWorkspace(&startDate, t);
std::string endDate = std::to_string(*(*citr)->invEndDate);
savetoTableWorkspace(&endDate, t);
std::string sessionID = m_session->getSessionId();
savetoTableWorkspace(&sessionID, t);
}
} catch (std::runtime_error &) {
throw std::runtime_error(
"Error when saving the ICat Search Results data to Workspace");
}
}
开发者ID:DanNixon,项目名称:mantid,代码行数:34,代码来源:ICat3Helper.cpp
示例5: fitWorkspace
/** Fits each spectrum in the workspace to f(x) = A * sin( w * x + p)
* @param ws :: [input] The workspace to fit
* @param freq :: [input] Hint for the frequency (w)
* @param groupName :: [input] The name of the output workspace group
* @param resTab :: [output] Table workspace storing the asymmetries and phases
* @param resGroup :: [output] Workspace group storing the fitting results
*/
void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws,
double freq, std::string groupName,
API::ITableWorkspace_sptr &resTab,
API::WorkspaceGroup_sptr &resGroup) {
int nhist = static_cast<int>(ws->getNumberHistograms());
// Create the fitting function f(x) = A * sin ( w * x + p )
// The same function and initial parameters are used for each fit
std::string funcStr = createFittingFunction(freq, true);
// Set up results table
resTab->addColumn("int", "Spectrum number");
resTab->addColumn("double", "Asymmetry");
resTab->addColumn("double", "Phase");
// Loop through fitting all spectra individually
const static std::string success = "success";
for (int wsIndex = 0; wsIndex < nhist; wsIndex++) {
reportProgress(wsIndex, nhist);
auto fit = createChildAlgorithm("Fit");
fit->initialize();
fit->setPropertyValue("Function", funcStr);
fit->setProperty("InputWorkspace", ws);
fit->setProperty("WorkspaceIndex", wsIndex);
fit->setProperty("CreateOutput", true);
fit->setPropertyValue("Output", groupName);
fit->execute();
std::string status = fit->getProperty("OutputStatus");
if (!fit->isExecuted() || status != success) {
std::ostringstream error;
error << "Fit failed for spectrum at workspace index " << wsIndex;
error << ": " << status;
throw std::runtime_error(error.str());
}
API::MatrixWorkspace_sptr fitOut = fit->getProperty("OutputWorkspace");
resGroup->addWorkspace(fitOut);
API::ITableWorkspace_sptr tab = fit->getProperty("OutputParameters");
// Now we have our fitting results stored in tab
// but we need to extract the relevant information, i.e.
// the detector phases (parameter 'p') and asymmetries ('A')
const auto &spectrum = ws->getSpectrum(static_cast<size_t>(wsIndex));
extractDetectorInfo(tab, resTab, spectrum.getSpectrumNo());
}
}
开发者ID:liyulun,项目名称:mantid,代码行数:54,代码来源:CalMuonDetectorPhases.cpp
示例6: saveSearchRessults
/** This method saves the search response( investigations )data to a table
* workspace
* @param response :: const reference to response object
* @param outputws :: shared pointer to output workspace
*/
void CICatHelper::saveSearchRessults(
const ns1__searchByAdvancedPaginationResponse &response,
API::ITableWorkspace_sptr &outputws) {
if (outputws->getColumnNames().empty()) {
outputws->addColumn("str", "Investigation id");
outputws->addColumn("str", "Facility");
outputws->addColumn("str", "Title");
outputws->addColumn("str", "Instrument");
outputws->addColumn("str", "Run range");
outputws->addColumn("str", "Start date");
outputws->addColumn("str", "End date");
outputws->addColumn("str", "SessionID");
}
saveInvestigations(response.return_, outputws);
}
开发者ID:DanNixon,项目名称:mantid,代码行数:20,代码来源:ICat3Helper.cpp
示例7: writeData
void SaveDiffFittingAscii::writeData(const API::ITableWorkspace_sptr workspace,
std::ofstream &file,
const size_t columnSize) {
for (size_t rowIndex = 0; rowIndex < workspace->rowCount(); ++rowIndex) {
TableRow row = workspace->getRow(rowIndex);
for (size_t columnIndex = 0; columnIndex < columnSize; columnIndex++) {
const auto row_str =
boost::lexical_cast<std::string>(row.Double(columnIndex));
g_log.debug() << row_str << std::endl;
if (columnIndex == columnSize - 1)
writeVal(row_str, file, true);
else
writeVal(row_str, file, false);
}
}
}
开发者ID:mantidproject,项目名称:mantid,代码行数:19,代码来源:SaveDiffFittingAscii.cpp
示例8: fitFrequencyFromAsymmetry
/**
* Fit the asymmetry and return the frequency found.
* Starting value for the frequency is taken from the hint.
* If the fit fails, return the initial hint.
* @param wsAsym :: [input] Workspace with asymmetry to fit
* @return :: Frequency found from fit
*/
double CalMuonDetectorPhases::fitFrequencyFromAsymmetry(
const API::MatrixWorkspace_sptr &wsAsym) {
// Starting value for frequency is hint
double hint = getFrequencyHint();
std::string funcStr = createFittingFunction(hint, false);
double frequency = hint;
std::string fitStatus = "success";
try {
auto func = API::FunctionFactory::Instance().createInitialized(funcStr);
auto fit = createChildAlgorithm("Fit");
fit->setProperty("Function", func);
fit->setProperty("InputWorkspace", wsAsym);
fit->setProperty("WorkspaceIndex", 0);
fit->setProperty("CreateOutput", true);
fit->setProperty("OutputParametersOnly", true);
fit->setProperty("Output", "__Invisible");
fit->executeAsChildAlg();
fitStatus = fit->getPropertyValue("OutputStatus");
if (fitStatus == "success") {
API::ITableWorkspace_sptr params = fit->getProperty("OutputParameters");
const size_t rows = params->rowCount();
static size_t colName(0), colValue(1);
for (size_t iRow = 0; iRow < rows; iRow++) {
if (params->cell<std::string>(iRow, colName) == "w") {
frequency = params->cell<double>(iRow, colValue);
break;
}
}
}
} catch (const std::exception &e) {
// Report fit failure to user
fitStatus = e.what();
}
if (fitStatus != "success") { // Either failed, or threw an exception
std::ostringstream message;
message << "Fit failed (" << fitStatus << "), using omega hint = " << hint;
g_log.error(message.str());
}
return frequency;
}
开发者ID:mantidproject,项目名称:mantid,代码行数:48,代码来源:CalMuonDetectorPhases.cpp
示例9: extractDetectorInfo
/** Extracts detector asymmetries and phases from fitting results
* and adds a new row to the results table with them
* @param paramTab :: [input] Output parameter table resulting from the fit
* @param resultsTab :: [input] Results table to update with a new row
* @param spectrumNumber :: [input] Spectrum number
*/
void CalMuonDetectorPhases::extractDetectorInfo(
const API::ITableWorkspace_sptr ¶mTab,
const API::ITableWorkspace_sptr &resultsTab,
const specnum_t spectrumNumber) {
double asym = paramTab->Double(0, 1);
double phase = paramTab->Double(2, 1);
// If asym<0, take the absolute value and add \pi to phase
// f(x) = A * sin( w * x + p) = -A * sin( w * x + p + PI)
if (asym < 0) {
asym = -asym;
phase = phase + M_PI;
}
// Now convert phases to interval [0, 2PI)
int factor = static_cast<int>(floor(phase / 2 / M_PI));
if (factor) {
phase = phase - factor * 2 * M_PI;
}
// Copy parameters to new row in results table
API::TableRow row = resultsTab->appendRow();
row << static_cast<int>(spectrumNumber) << asym << phase;
}
开发者ID:liyulun,项目名称:mantid,代码行数:28,代码来源:CalMuonDetectorPhases.cpp
示例10: exec
/** Execute the algorithm.
*/
void CreateEPP::exec() {
API::MatrixWorkspace_sptr inputWS =
getProperty(PropertyNames::INPUT_WORKSPACE);
const auto &spectrumInfo = inputWS->spectrumInfo();
API::ITableWorkspace_sptr outputWS =
API::WorkspaceFactory::Instance().createTable("TableWorkspace");
addEPPColumns(outputWS);
const double sigma = getProperty(PropertyNames::SIGMA);
const size_t spectraCount = spectrumInfo.size();
outputWS->setRowCount(spectraCount);
const auto l1 = spectrumInfo.l1();
const double EFixed = inputWS->run().getPropertyAsSingleValue("Ei");
for (size_t i = 0; i < spectraCount; ++i) {
const auto l2 = spectrumInfo.l2(i);
const auto elasticTOF = Kernel::UnitConversion::run(
"Energy", "TOF", EFixed, l1, l2, 0, Kernel::DeltaEMode::Direct, EFixed);
outputWS->getRef<int>(ColumnNames::WS_INDEX, i) = static_cast<int>(i);
outputWS->getRef<double>(ColumnNames::PEAK_CENTRE, i) = elasticTOF;
outputWS->getRef<double>(ColumnNames::PEAK_CENTRE_ERR, i) = 0;
outputWS->getRef<double>(ColumnNames::SIGMA, i) = sigma;
outputWS->getRef<double>(ColumnNames::SIGMA_ERR, i) = 0;
double height = 0;
try {
const auto elasticIndex = inputWS->binIndexOf(elasticTOF, i);
height = inputWS->y(i)[elasticIndex];
} catch (std::out_of_range &) {
std::ostringstream sout;
sout << "EPP out of TOF range for workspace index " << i
<< ". Peak height set to zero.";
g_log.warning() << sout.str();
}
outputWS->getRef<double>(ColumnNames::HEIGHT, i) = height;
outputWS->getRef<double>(ColumnNames::CHI_SQUARED, i) = 1;
outputWS->getRef<std::string>(ColumnNames::STATUS, i) = "success";
}
setProperty(PropertyNames::OUTPUT_WORKSPACE, outputWS);
}
开发者ID:samueljackson92,项目名称:mantid,代码行数:39,代码来源:CreateEPP.cpp
示例11: runtime_error
/**
* Saves result from "getDataFiles" to workspace.
* @param response :: result response from the catalog.
* @param outputws :: shared pointer to datasets
*/
void ICat4Catalog::saveDataFiles(std::vector<xsd__anyType *> response,
API::ITableWorkspace_sptr &outputws) {
if (outputws->getColumnNames().empty()) {
// Add rows headers to the output workspace.
outputws->addColumn("str", "Name");
outputws->addColumn("str", "Location");
outputws->addColumn("str", "Create Time");
outputws->addColumn("long64", "Id");
outputws->addColumn("long64", "File size(bytes)");
outputws->addColumn("str", "File size");
outputws->addColumn("str", "Description");
}
std::vector<xsd__anyType *>::const_iterator iter;
for (iter = response.begin(); iter != response.end(); ++iter) {
ns1__datafile *datafile = dynamic_cast<ns1__datafile *>(*iter);
if (datafile) {
API::TableRow table = outputws->appendRow();
// Now add the relevant investigation data to the table.
savetoTableWorkspace(datafile->name, table);
savetoTableWorkspace(datafile->location, table);
std::string createDate =
formatDateTime(*datafile->createTime, "%Y-%m-%d %H:%M:%S");
savetoTableWorkspace(&createDate, table);
savetoTableWorkspace(datafile->id, table);
savetoTableWorkspace(datafile->fileSize, table);
std::string fileSize = bytesToString(*datafile->fileSize);
savetoTableWorkspace(&fileSize, table);
if (datafile->description)
savetoTableWorkspace(datafile->description, table);
} else {
throw std::runtime_error("ICat4Catalog::saveDataFiles expected a "
"datafile. Please contact the Mantid "
"development team.");
}
}
}
开发者ID:DanNixon,项目名称:mantid,代码行数:46,代码来源:ICat4Catalog.cpp
示例12: exec
/** Executes the algorithm. Moving detectors of input workspace to positions indicated in table workspace
*
* @throw FileError Thrown if unable to get instrument from workspace,
* table workspace is incompatible with instrument
*/
void ApplyCalibration::exec()
{
// Get pointers to the workspace, parameter map and table
API::MatrixWorkspace_sptr inputWS = getProperty("Workspace");
m_pmap = &(inputWS->instrumentParameters()); // Avoids a copy if you get the reference before the instrument
API::ITableWorkspace_sptr PosTable = getProperty("PositionTable");
Geometry::Instrument_const_sptr instrument = inputWS->getInstrument();
if(!instrument)
{
throw std::runtime_error("Workspace to apply calibration to has no defined instrument");
}
size_t numDetector = PosTable->rowCount();
ColumnVector<int> detID = PosTable->getVector("Detector ID");
ColumnVector<V3D> detPos = PosTable->getVector("Detector Position");
// numDetector needs to be got as the number of rows in the table and the detID got from the (i)th row of table.
for (size_t i = 0; i < numDetector; ++i)
{
setDetectorPosition(instrument, detID[i], detPos[i], false );
}
// Ensure pointer is only valid for execution
m_pmap = NULL;
}
开发者ID:trnielsen,项目名称:mantid,代码行数:29,代码来源:ApplyCalibration.cpp
示例13: saveDataSets
/** This method loops through the response return_vector and saves the datasets details to a table workspace
* @param response :: const reference to response object
* @param outputws :: shred pointer to workspace
* @returns shared pointer to table workspace which stores the data
*/
void CICatHelper::saveDataSets(const ns1__getInvestigationIncludesResponse& response,API::ITableWorkspace_sptr& outputws)
{
//create table workspace
if (outputws->getColumnNames().empty())
{
outputws->addColumn("str","Name");//File name
outputws->addColumn("str","Status");
outputws->addColumn("str","Type");
outputws->addColumn("str","Description");
outputws->addColumn("long64","Sample Id");
}
try
{
std::vector<ns1__dataset*> datasetVec;
datasetVec.assign((response.return_)->datasetCollection.begin(),(response.return_)->datasetCollection.end());
std::vector<ns1__dataset*>::const_iterator dataset_citr;
for(dataset_citr=datasetVec.begin();dataset_citr!=datasetVec.end();++dataset_citr)
{
API::TableRow t = outputws->appendRow();
// DataSet Name
savetoTableWorkspace((*dataset_citr)->name,t);
// DataSet Status
savetoTableWorkspace((*dataset_citr)->datasetStatus,t);
//DataSet Type
savetoTableWorkspace((*dataset_citr)->datasetType,t);
//DataSet Type
savetoTableWorkspace((*dataset_citr)->description,t);
//DataSet Type
savetoTableWorkspace((*dataset_citr)->sampleId,t);
}
}
catch(std::runtime_error& )
{
throw;
}
//return outputws;
}
开发者ID:AlistairMills,项目名称:mantid,代码行数:47,代码来源:ICat3Helper.cpp
示例14: readExpIni
/**
* Parse the (optional) exp.ini file found on NOMAD
* @param filename full path to a exp.ini file
* @param wksp The table workspace to modify.
*/
void PDLoadCharacterizations::readExpIni(const std::string &filename,
API::ITableWorkspace_sptr &wksp) {
if (wksp->rowCount() == 0)
throw std::runtime_error("Characterizations file does not have any "
"characterizations information");
std::ifstream file(filename.c_str());
if (!file) {
throw Exception::FileError("Unable to open file", filename);
}
// parse the file
for (std::string line = Strings::getLine(file); !file.eof();
line = Strings::getLine(file)) {
line = Strings::strip(line);
// skip empty lines and "comments"
if (line.empty())
continue;
if (line.substr(0, 1) == "#")
continue;
// split the line and see if it has something meaningful
std::vector<std::string> splitted;
boost::split(splitted, line, boost::is_any_of("\t "),
boost::token_compress_on);
if (splitted.size() < 2)
continue;
// update the various charaterization runs
if (splitted[0] == EXP_INI_VAN_KEY) {
wksp->getRef<std::string>("vanadium", 0) = splitted[1];
} else if (splitted[0] == EXP_INI_EMPTY_KEY) {
wksp->getRef<std::string>("container", 0) = splitted[1];
} else if (splitted[0] == EXP_INI_CAN_KEY) {
wksp->getRef<std::string>("empty", 0) = splitted[1];
}
}
}
开发者ID:spaceyatom,项目名称:mantid,代码行数:43,代码来源:PDLoadCharacterizations.cpp
示例15: loadPhaseTable
/** Load PhaseTable file to a vector of HistData.
* @param phaseTable :: [input] phase table containing detector info
* @param deadTimeTable :: [output] phase table containing dead times
*/
void PhaseQuadMuon::loadPhaseTable(API::ITableWorkspace_sptr phaseTable, API::ITableWorkspace_sptr deadTimeTable)
{
if ( phaseTable->rowCount() )
{
if ( phaseTable->columnCount()<4 )
{
throw std::invalid_argument("PhaseQuad: PhaseTable must contain at least four columns");
}
// Check number of histograms in inputWs match number of detectors in phase table
if (m_nHist != static_cast<int>(phaseTable->rowCount()))
{
throw std::runtime_error("PhaseQuad: Number of histograms in phase table does not match number of spectra in workspace");
}
for (size_t i=0; i<phaseTable->rowCount(); ++i)
{
API::TableRow phaseRow = phaseTable->getRow(i);
// The first three columns go to m_histData
HistData tempHist;
tempHist.detOK = phaseRow.Bool(0);
tempHist.alpha = phaseRow.Double(1);
tempHist.phi = phaseRow.Double(2);
m_histData.push_back(tempHist);
// The last column goes to deadTimeTable
API::TableRow deadRow = deadTimeTable->appendRow();
deadRow << static_cast<int>(i)+1 << phaseRow.Double(3);
}
}
else
{
throw std::invalid_argument("PhaseQuad: PhaseTable is empty");
}
}
开发者ID:utkarshayachit,项目名称:mantid,代码行数:42,代码来源:PhaseQuadMuon.cpp
示例16: generatePeaksList
/** Generate a list of peaks that meets= all the requirements for fitting offset
* @param peakslist :: table workspace as the output of FindPeaks
* @param wi :: workspace index of the spectrum
* @param peakPositionRef :: reference peaks positions
* @param peakPosToFit :: output of reference centres of the peaks used to fit
* offset
* @param peakPosFitted :: output of fitted centres of the peaks used to fit
* offset
* @param peakHeightFitted :: heights of the peaks used to fit offset
* @param chisq :: chi squares of the peaks used to fit offset
* @param useFitWindows :: boolean whether FitWindows is used
* @param fitWindowsToUse :: fit windows
* @param minD :: minimum d-spacing of the spectrum
* @param maxD :: minimum d-spacing of the spectrum
* @param deltaDovD :: delta(d)/d of the peak for fitting
* @param dev_deltaDovD :: standard deviation of delta(d)/d of all the peaks in
* the spectrum
*/
void GetDetOffsetsMultiPeaks::generatePeaksList(
const API::ITableWorkspace_sptr &peakslist, int wi,
const std::vector<double> &peakPositionRef,
std::vector<double> &peakPosToFit, std::vector<double> &peakPosFitted,
std::vector<double> &peakHeightFitted, std::vector<double> &chisq,
bool useFitWindows, const std::vector<double> &fitWindowsToUse,
const double minD, const double maxD, double &deltaDovD,
double &dev_deltaDovD) {
// FIXME - Need to make sure that the peakPositionRef and peakslist have the
// same order of peaks
// Check
size_t numrows = peakslist->rowCount();
if (numrows != peakPositionRef.size()) {
std::stringstream msg;
msg << "Number of peaks in PeaksList (from FindPeaks=" << numrows
<< ") is not same as number of "
<< "referenced peaks' positions (" << peakPositionRef.size() << ")";
throw std::runtime_error(msg.str());
}
std::vector<double> vec_widthDivPos;
std::vector<double> vec_offsets;
for (size_t i = 0; i < peakslist->rowCount(); ++i) {
// Get peak value
double centre = peakslist->getRef<double>("centre", i);
double width = peakslist->getRef<double>("width", i);
double height = peakslist->getRef<double>("height", i);
double chi2 = peakslist->getRef<double>("chi2", i);
// Identify whether this peak would be accepted to optimize offset
// - peak position within D-range
if (centre <= minD || centre >= maxD) {
std::stringstream dbss;
dbss << " wi = " << wi << " c = " << centre << " out of D-range ";
g_log.debug(dbss.str());
continue;
}
// - rule out of peak with wrong position
if (useFitWindows) {
// outside peak fit window o
if (centre <= fitWindowsToUse[2 * i] ||
centre >= fitWindowsToUse[2 * i + 1]) {
std::stringstream dbss;
dbss << " wi = " << wi << " c = " << centre << " out of fit window ";
g_log.debug(dbss.str());
continue;
}
}
// - check chi-square
if (chi2 > m_maxChiSq || chi2 < 0) {
std::stringstream dbss;
dbss << " wi = " << wi << " c = " << centre << " chi2 = " << chi2
<< ": Too large";
g_log.debug(dbss.str());
continue;
}
// - check peak height
if (height < m_minPeakHeight) {
g_log.debug() << " wi = " << wi << " c = " << centre << " h = " << height
<< ": Too low "
<< "\n";
continue;
}
// - check peak's resolution
double widthdevpos = width / centre;
if (m_hasInputResolution) {
double recres = m_inputResolutionWS->readY(wi)[0];
double resmax = recres * m_maxResFactor;
double resmin = recres * m_minResFactor;
if (widthdevpos < resmin || widthdevpos > resmax) {
std::stringstream dbss;
dbss << " wi = " << wi << " c = " << centre
<< " Delta(d)/d = " << widthdevpos
<< " too far away from suggested value " << recres;
g_log.debug(dbss.str());
continue;
//.........这里部分代码省略.........
开发者ID:spaceyatom,项目名称:mantid,代码行数:101,代码来源:GetDetOffsetsMultiPeaks.cpp
示例17: saveInvestigationIncludesResponse
/**
* This method loops through the response return_vector and saves the datafile
* details to a table workspace
* @param response :: const reference to response object
* @param outputws :: shared pointer to table workspace which stores the data
*/
void CICatHelper::saveInvestigationIncludesResponse(
const ns1__getInvestigationIncludesResponse &response,
API::ITableWorkspace_sptr &outputws) {
if (outputws->getColumnNames().empty()) {
outputws->addColumn("str", "Name");
outputws->addColumn("str", "Location");
outputws->addColumn("str", "Create Time");
outputws->addColumn("long64", "Id");
outputws->addColumn("long64", "File size(bytes)");
outputws->addColumn("str", "File size");
outputws->addColumn("str", "Description");
}
try {
std::vector<ns1__dataset *> datasetVec;
datasetVec.assign((response.return_)->datasetCollection.begin(),
(response.return_)->datasetCollection.end());
if (datasetVec.empty()) {
throw std::runtime_error("No data files exists in the ICAT database for "
"the selected investigation");
}
std::vector<ns1__dataset *>::const_iterator dataset_citr;
for (dataset_citr = datasetVec.begin(); dataset_citr != datasetVec.end();
++dataset_citr) {
std::vector<ns1__datafile *> datafileVec;
datafileVec.assign((*dataset_citr)->datafileCollection.begin(),
(*dataset_citr)->datafileCollection.end());
if (datafileVec.empty()) {
throw std::runtime_error("No data files exists in the ICAT database "
"for the selected investigation ");
}
std::vector<ns1__datafile *>::const_iterator datafile_citr;
for (datafile_citr = datafileVec.begin();
datafile_citr != datafileVec.end(); ++datafile_citr) {
API::TableRow t = outputws->appendRow();
// File Name
savetoTableWorkspace((*datafile_citr)->name, t);
savetoTableWorkspace((*datafile_citr)->location, t);
// File creation Time.
std::string *creationtime = nullptr;
if ((*datafile_citr)->datafileCreateTime != nullptr) {
time_t crtime = *(*datafile_citr)->datafileCreateTime;
char temp[25];
strftime(temp, 25, "%Y-%b-%d %H:%M:%S", localtime(&crtime));
std::string ftime(temp);
creationtime = new std::string;
creationtime->assign(ftime);
}
savetoTableWorkspace(creationtime, t);
if (creationtime)
delete creationtime;
//
savetoTableWorkspace((*datafile_citr)->id, t);
LONG64 fileSize =
boost::lexical_cast<LONG64>(*(*datafile_citr)->fileSize);
savetoTableWorkspace(&fileSize, t);
savetoTableWorkspace((*datafile_citr)->description, t);
}
}
} catch (std::runtime_error &) {
throw;
}
}
开发者ID:DanNixon,项目名称:mantid,代码行数:77,代码来源:ICat3Helper.cpp
示例18: loadPhaseList
/** Load PhaseList file to a vector of HistData and a deadTimeTable.
* @param filename :: [input] phase list .inf filename
* @param deadTimeTable :: [output] table containing dead times
*/
void PhaseQuadMuon::loadPhaseList(const std::string& filename, API::ITableWorkspace_sptr deadTimeTable )
{
std::ifstream input(filename.c_str(), std::ios_base::in);
if (input.is_open())
{
if ( input.eof() )
{
throw Exception::FileError("PhaseQuad: File is empty.", filename);
}
else
{
std::string line;
// Header of .INF file is as follows:
//
// Comment on the output file
// Top row of numbers are:
// #histos, typ. first good bin#, typ. bin# when pulse over, mean lag.
// Tabulated numbers are, per histogram:
// det ok, asymmetry, phase, lag, deadtime_c, deadtime_m.
//
std::getline( input, line ); // Skip first line in header
std::getline( input, line ); // Skip second line
std::getline( input, line ); // ...
std::getline( input, line );
std::getline( input, line );
// Read first useful line
int nHist;
input >> nHist >> m_tValid >> m_tPulseOver >> m_meanLag;
if (m_nHist!=nHist)
{
throw std::runtime_error("PhaseQuad: Number of histograms in phase list does not match number of spectra in workspace");
}
// Read histogram data
int cont=0;
HistData tempData;
double lag, dead, deadm;
while( input >> tempData.detOK >> tempData.alpha >> tempData.phi >> lag >> dead >> deadm )
{
m_histData.push_back (tempData);
cont++;
// Add dead time to deadTimeTable
API::TableRow row = deadTimeTable->appendRow();
row << cont << dead;
}
if ( cont != m_nHist )
{
if ( cont < m_nHist )
{
throw Exception::FileError("PhaseQuad: Lines missing in phase list", filename);
}
else
{
throw Exception::FileError("PhaseQuad: Extra lines in phase list", filename);
}
}
}
}
else
{
// Throw exception if file cannot be opened
throw std::runtime_error("PhaseQuad: Unable to open PhaseList");
开发者ID:utkarshayachit,项目名称:mantid,代码行数:75,代码来源:PhaseQuadMuon.cpp
示例19: invalid_argument
/** Forms the quadrature phase signal (squashogram)
* @param ws :: [input] workspace containing the measured spectra
* @param phase :: [input] table workspace containing the detector phases
* @param n0 :: [input] vector containing the normalization constants
* @return :: workspace containing the quadrature phase signal
*/
API::MatrixWorkspace_sptr
PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws,
const API::ITableWorkspace_sptr &phase,
const std::vector<double> &n0) {
// Poisson limit: below this number we consider we don't have enough
// statistics
// to apply sqrt(N). This is an arbitrary number used in the original code
// provided by scientists
double poissonLimit = 30.;
size_t nspec = ws->getNumberHistograms();
size_t npoints = ws->blocksize();
// Muon life time in microseconds
double muLife = PhysicalConstants::MuonLifetime * 1e6;
if (n0.size() != nspec) {
throw std::invalid_argument("Invalid normalization constants");
}
// Get the maximum asymmetry
double maxAsym = 0.;
for (size_t h = 0; h < nspec; h++) {
if (phase->Double(h, 1) > maxAsym) {
maxAsym = phase->Double(h, 1);
}
}
if (maxAsym == 0.0) {
throw std::invalid_argument("Invalid detector asymmetries");
}
std::vector<double> aj, bj;
{
// Calculate coefficients aj, bj
double sxx = 0;
double syy = 0;
double sxy = 0;
for (size_t h = 0; h < nspec; h++) {
double asym = phase->Double(h, 1) / maxAsym;
double phi = phase->Double(h, 2);
double X = n0[h] * asym * cos(phi);
double Y = n0[h] * asym * sin(phi);
sxx += X * X;
syy += Y * Y;
sxy += X * Y;
}
double lam1 = 2 * syy / (sxx * syy - sxy * sxy);
double mu1 = 2 * sxy / (sxy * sxy - sxx * syy);
double lam2 = 2 * sxy / (sxy * sxy - sxx * syy);
double mu2 = 2 * sxx / (sxx * syy - sxy * sxy);
for (size_t h = 0; h < nspec; h++) {
double asym = phase->Double(h, 1) / maxAsym;
double phi = phase->Double(h, 2);
double X = n0[h] * asym * cos(phi);
double Y = n0[h] * asym * sin(phi);
aj.push_back((lam1 * X + mu1 * Y) * 0.5);
bj.push_back((lam2 * X + mu2 * Y) * 0.5);
}
}
// First X value
double X0 = ws->x(0).front();
// Create and populate output workspace
API::MatrixWorkspace_sptr ows = API::WorkspaceFactory::Instance().create(
"Workspace2D", 2, npoints + 1, npoints);
// X
ows->setSharedX(0, ws->sharedX(0));
ows->setSharedX(1, ws->sharedX(0));
// Phase quadrature
auto &realY = ows->mutableY(0);
auto &imagY = ows->mutableY(1);
auto &realE = ows->mutableE(0);
auto &imagE = ows->mutableE(1);
for (size_t i = 0; i < npoints; i++) {
for (size_t h = 0; h < nspec; h++) {
// (X,Y,E) with exponential decay removed
const double X = ws->x(h)[i];
const double Y = ws->y(h)[i] - n0[h] * exp(-(X - X0) / muLife);
const double E = (ws->y(h)[i] > poissonLimit)
? ws->e(h)[i]
: sqrt(n0[h] * exp(-(X - X0) / muLife));
realY[i] += aj[h] * Y;
imagY[i] += bj[h] * Y;
realE[i] += aj[h] * aj[h] * E * E;
//.........这里部分代码省略.........
开发者ID:rosswhitfield,项目名称:mantid,代码行数:101,代码来源:PhaseQuadMuon.cpp
示例20: invalid_argument
/** Forms the quadrature phase signal (squashogram)
* @param ws :: [input] workspace containing the measured spectra
* @param phase :: [input] table workspace containing the detector phases
* @param n0 :: [input] vector containing the normalization constants
* @return :: workspace containing the quadrature phase signal
*/
API::MatrixWorkspace_sptr
PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws,
const API::ITableWorkspace_sptr &phase,
const std::vector<double> &n0) {
// Poisson limit: below this number we consider we don't have enough
// statistics
// to apply sqrt(N). This is an arbitrary number used in the original code
// provided by scientists
const double poissonLimit = 30.;
// Muon life time in microseconds
const double muLife = PhysicalConstants::MuonLifetime * 1e6;
const size_t nspec = ws->getNumberHistograms();
if (n0.size() != nspec) {
throw std::invalid_argument("Invalid normalization constants");
}
auto names = phase->getColumnNames();
for (auto &name : names) {
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
}
auto phaseIndex = findName(phaseNames, names);
auto asymmetryIndex = findName(asymmNames, names);
// Get the maximum asymmetry
double maxAsym = 0.;
for (size_t h = 0; h < nspec; h++) {
if (phase->Double(h, asymmetryIndex) > maxAsym &&
phase->Double(h, asymmetryIndex) != ASYMM_ERROR) {
maxAsym = phase->Double(h, asymmetryIndex);
}
}
if (maxAsym == 0.0) {
throw std::invalid_argument("Invalid detector asymmetries");
}
std::vector<bool> emptySpectrum;
emptySpectrum.reserve(nspec);
std::vector<double> aj, bj;
{
// Calculate coefficients aj, bj
double sxx = 0.;
double syy = 0.;
double sxy = 0.;
for (size_t h
|
请发表评论