void LoadIsawUB::readModulatedUB(std::ifstream &in, DblMatrix &ub) { int ModDim = 0; Kernel::DblMatrix modub(3, 3); Kernel::DblMatrix ModVecErr(3, 3); int maxorder = 0; bool crossterm = false; std::string s; double val; s = getWord(in, true); if (!convert(s, val)) { readToEndOfLine(in, true); for (size_t row = 0; row < 3; row++) { for (size_t col = 0; col < 3; col++) { s = getWord(in, true); if (!convert(s, val)) throw std::runtime_error( "The string '" + s + "' in the file was not understood as a number."); modub[row][col] = val; } readToEndOfLine(in, true); if (modub[row][0] != 0.0 || modub[row][1] != 0.0 || modub[row][2] != 0.0) ModDim++; } } readToEndOfLine(in, true); double latVals[6]; for (double &latVal : latVals) { s = getWord(in, true); if (!convert(s, val)) throw std::runtime_error("The string '" + s + "' in the file was not understood as a number."); latVal = val; } if (ModDim > 0) { readToEndOfLine(in, true); readToEndOfLine(in, true); for (int i = 0; i < ModDim; i++) { readToEndOfLine(in, true); for (int j = 0; j < 4; j++) s = getWord(in, true); for (int j = 0; j < 3; j++) { s = getWord(in, true); if (!convert(s, val)) throw std::runtime_error( "The string '" + s + "' in the file was not understood as a number."); ModVecErr[i][j] = val; } readToEndOfLine(in, true); } readToEndOfLine(in, true); for (int j = 0; j < 3; j++) s = getWord(in, true); if (!convert(s, val)) throw std::runtime_error("The string '" + s + "' in the file was not understood as a number."); maxorder = static_cast<int>(val); readToEndOfLine(in, true); for (int j = 0; j < 3; j++) s = getWord(in, true); bool valBool; if (!convert(s, valBool)) throw std::runtime_error("The string '" + s + "' in the file was not understood as a number."); crossterm = valBool; } // Adjust the UB by transposing ub = ub.Transpose(); modub = modub.Transpose(); /* The method in OrientedLattice gets both the lattice parameters and the U * matrix from the UB matrix. * This is compatible (same results) with the ISAW lattice parameters */ OrientedLattice *latt = new OrientedLattice(); latt->setUB(ub); latt->setError(latVals[0], latVals[1], latVals[2], latVals[3], latVals[4], latVals[5]); latt->setModUB(modub); for (int i = 0; i < ModDim; i++) latt->setModerr(i, ModVecErr[i][0], ModVecErr[i][1], ModVecErr[i][2]); latt->setMaxOrder(maxorder); latt->setCrossTerm(crossterm); DblMatrix U = latt->getU(); // Swap rows around to accound for IPNS convention DblMatrix U2 = U; // Swap rows around for (size_t r = 0; r < 3; r++) { U2[2][r] = U[0][r]; U2[1][r] = U[2][r]; U2[0][r] = U[1][r]; } U = U2; const bool checkU = getProperty("CheckUMatrix"); latt->setU(U, !checkU); // In and Out workspace. Workspace_sptr ws1 = getProperty("InputWorkspace"); ExperimentInfo_sptr ws; MultipleExperimentInfos_sptr MDWS = boost::dynamic_pointer_cast<MultipleExperimentInfos>(ws1); if (MDWS != nullptr) { ws = MDWS->getExperimentInfo(0); } else { ws = boost::dynamic_pointer_cast<ExperimentInfo>(ws1); } if (!ws) throw std::invalid_argument("Must specify either a MatrixWorkspace or a " "PeaksWorkspace or a MDWorkspace."); // Save it into the workspace ws->mutableSample().setOrientedLattice(latt); // Save it to every experiment info in MD workspaces if ((MDWS != nullptr) && (MDWS->getNumExperimentInfo() > 1)) { for (uint16_t i = 1; i < MDWS->getNumExperimentInfo(); i++) { ws = MDWS->getExperimentInfo(i); ws->mutableSample().setOrientedLattice(latt); } } delete latt; this->setProperty("InputWorkspace", ws1); }
void LoadFlexiNexus::addMetaData(NeXus::File *fin, Workspace_sptr ws, ExperimentInfo_sptr info) { std::map<std::string, std::string>::const_iterator it; // assign a title if ((it = dictionary.find("title")) == dictionary.end()) { const std::string title("No title found"); ws->setTitle(title); } else { if (it->second.find('/') == it->second.npos) { const std::string title(it->second); ws->setTitle(title); } else { if (safeOpenpath(fin, it->second)) { const std::string title = fin->getStrData(); ws->setTitle(title); } } } // assign a sample name std::string sample; if ((it = dictionary.find("sample")) == dictionary.end()) { sample = "No sample found"; } else { if (it->second.find('/') == it->second.npos) { sample = it->second; } else { if (safeOpenpath(fin, it->second)) { sample = fin->getStrData(); } else { sample = "Sampe plath not found"; } } } info->mutableSample().setName(sample); /** * load all the extras into the Run information */ Run &r = info->mutableRun(); std::set<std::string> specialMap = populateSpecialMap(); for (it = dictionary.begin(); it != dictionary.end(); ++it) { if (specialMap.find(it->first) == specialMap.end()) { // not in specials! if (it->second.find('/') == it->second.npos) { r.addProperty(it->first, it->second, true); } else { if (safeOpenpath(fin, it->second)) { NeXus::Info inf = fin->getInfo(); if (inf.type == ::NeXus::CHAR) { std::string data = fin->getStrData(); r.addProperty(it->first, data, true); } else if (inf.type == ::NeXus::FLOAT32 || inf.type == ::NeXus::FLOAT64) { std::vector<double> data; fin->getDataCoerce(data); r.addProperty(it->first, data, true); } else { std::vector<int> data; fin->getDataCoerce(data); r.addProperty(it->first, data, true); } } } } } }