本文整理汇总了C++中NXEntry::getString方法的典型用法代码示例。如果您正苦于以下问题:C++ NXEntry::getString方法的具体用法?C++ NXEntry::getString怎么用?C++ NXEntry::getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NXEntry
的用法示例。
在下文中一共展示了NXEntry::getString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadRunDetails
void LoadSINQFocus::loadRunDetails(NXEntry & entry) {
API::Run & runDetails = m_localWorkspace->mutableRun();
// int runNum = entry.getInt("run_number");
// std::string run_num = boost::lexical_cast<std::string>(runNum);
// runDetails.addProperty("run_number", run_num);
std::string start_time = entry.getString("start_time");
//start_time = getDateTimeInIsoFormat(start_time);
runDetails.addProperty("run_start", start_time);
std::string end_time = entry.getString("end_time");
//end_time = getDateTimeInIsoFormat(end_time);
runDetails.addProperty("run_end", end_time);
double wavelength = entry.getFloat(m_instrumentPath + "/monochromator/lambda");
runDetails.addProperty<double>("wavelength", wavelength);
double energy = entry.getFloat(m_instrumentPath + "/monochromator/energy");
runDetails.addProperty<double>("Ei", energy, true); //overwrite
std::string title = entry.getString("title");
runDetails.addProperty("title", title);
m_localWorkspace->setTitle(title);
}
示例2:
/** Load logs from Nexus file. Logs are expected to be in
* /run/sample group of the file.
* @param ws :: The workspace to load the logs to.
* @param entry :: The Nexus entry
* @param period :: The period of this workspace
*/
void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry,
int period) {
// Avoid compiler warning
(void)period;
std::string start_time = entry.getString("start_time");
std::string sampleName = entry.getString("sample/name");
NXMainClass runlogs = entry.openNXClass<NXMainClass>("sample");
ws->mutableSample().setName(sampleName);
for (std::vector<NXClassInfo>::const_iterator it = runlogs.groups().begin();
it != runlogs.groups().end(); ++it) {
NXLog nxLog = runlogs.openNXLog(it->nxname);
Kernel::Property *logv = nxLog.createTimeSeries(start_time);
if (!logv)
continue;
ws->mutableRun().addLogData(logv);
}
ws->setTitle(entry.getString("title"));
if (entry.containsDataSet("notes")) {
ws->setComment(entry.getString("notes"));
}
std::string run_num = std::to_string(entry.getInt("run_number"));
// The sample is left to delete the property
ws->mutableRun().addLogData(
new PropertyWithValue<std::string>("run_number", run_num));
ws->populateInstrumentParameters();
}
示例3: loadRunDetails
void LoadLLB::loadRunDetails(NXEntry &entry) {
API::Run &runDetails = m_localWorkspace->mutableRun();
// int runNum = entry.getInt("run_number");
// std::string run_num = boost::lexical_cast<std::string>(runNum);
// runDetails.addProperty("run_number", run_num);
std::string start_time = entry.getString("start_time");
// start_time = getDateTimeInIsoFormat(start_time);
runDetails.addProperty("run_start", start_time);
std::string end_time = entry.getString("end_time");
// end_time = getDateTimeInIsoFormat(end_time);
runDetails.addProperty("run_end", end_time);
double wavelength = entry.getFloat("nxbeam/incident_wavelength");
runDetails.addProperty<double>("wavelength", wavelength);
double energy = m_loader.calculateEnergy(wavelength);
runDetails.addProperty<double>("Ei", energy, true); // overwrite
std::string title = entry.getString("title");
runDetails.addProperty("title", title);
m_localWorkspace->setTitle(title);
}
示例4: root
/** Log the run details from the file
* @param localWorkspace :: The workspace details to use
*/
void LoadMuonNexus2::loadRunDetails(
DataObjects::Workspace2D_sptr localWorkspace) {
API::Run &runDetails = localWorkspace->mutableRun();
runDetails.addProperty("run_title", localWorkspace->getTitle(), true);
int numSpectra = static_cast<int>(localWorkspace->getNumberHistograms());
runDetails.addProperty("nspectra", numSpectra);
m_filename = getPropertyValue("Filename");
NXRoot root(m_filename);
NXEntry entry = root.openEntry(m_entry_name);
std::string start_time = entry.getString("start_time");
runDetails.addProperty("run_start", start_time);
std::string stop_time = entry.getString("end_time");
runDetails.addProperty("run_end", stop_time);
if (entry.containsGroup("run")) {
NXClass runRun = entry.openNXGroup("run");
if (runRun.containsDataSet("good_total_frames")) {
int dum = runRun.getInt("good_total_frames");
runDetails.addProperty("goodfrm", dum);
}
if (runRun.containsDataSet("number_periods")) {
int dum = runRun.getInt("number_periods");
runDetails.addProperty("nperiods", dum);
}
}
{ // Duration taken to be stop_time minus stat_time
auto start = createFromSanitizedISO8601(start_time);
auto end = createFromSanitizedISO8601(stop_time);
double duration_in_secs = DateAndTime::secondsFromDuration(end - start);
runDetails.addProperty("dur_secs", duration_in_secs);
}
}
示例5: period_index
//.........这里部分代码省略.........
Y.assign(mondata(),mondata() + m_numberOfChannels);
MantidVec& E = local_workspace->dataE(hist_index);
std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt);
local_workspace->getAxis(1)->spectraNo(hist_index) = static_cast<specid_t>(it->first);
NXFloat timeBins = monitor.openNXFloat("time_of_flight");
timeBins.load();
local_workspace->dataX(hist_index).assign(timeBins(),timeBins() + timeBins.dim0());
hist_index++;
}
if (first_monitor_spectrum > 1)
{
hist_index = 0;
}
}
if( m_have_detector )
{
NXData nxdata = entry.openNXData("detector_1");
NXDataSetTyped<int> data = nxdata.openIntData();
data.open();
//Start with thelist members that are lower than the required spectrum
const int * const spec_begin = m_spec.get();
std::vector<int64_t>::iterator min_end = m_spec_list.end();
if( !m_spec_list.empty() )
{
// If we have a list, by now it is ordered so first pull in the range below the starting block range
// Note the reverse iteration as we want the last one
if( m_range_supplied )
{
min_end = std::find_if(m_spec_list.begin(), m_spec_list.end(), std::bind2nd(std::greater<int>(), m_spec_min));
}
for( std::vector<int64_t>::iterator itr = m_spec_list.begin(); itr < min_end; ++itr )
{
// Load each
int64_t spectra_no = (*itr);
// For this to work correctly, we assume that the spectrum list increases monotonically
int64_t filestart = std::lower_bound(spec_begin,m_spec_end,spectra_no) - spec_begin;
m_progress->report("Loading data");
loadBlock(data, static_cast<int64_t>(1), period_index, filestart, hist_index, spectra_no, local_workspace);
}
}
if( m_range_supplied )
{
// When reading in blocks we need to be careful that the range is exactly divisible by the blocksize
// and if not have an extra read of the left overs
const int64_t blocksize = 8;
const int64_t rangesize = (m_spec_max - m_spec_min + 1) - m_monitors.size();
const int64_t fullblocks = rangesize / blocksize;
int64_t read_stop = 0;
int64_t spectra_no = m_spec_min;
if (first_monitor_spectrum == 1)
{// this if crudely checks whether the monitors are at the begining or end of the spectra
spectra_no += static_cast<int>(m_monitors.size());
}
// For this to work correctly, we assume that the spectrum list increases monotonically
int64_t filestart = std::lower_bound(spec_begin,m_spec_end,spectra_no) - spec_begin;
if( fullblocks > 0 )
{
read_stop = (fullblocks * blocksize);// + m_monitors.size(); //RNT: I think monitors are excluded from the data
//for( ; hist_index < read_stop; )
for(int64_t i = 0; i < fullblocks; ++i)
{
loadBlock(data, blocksize, period_index, filestart, hist_index, spectra_no, local_workspace);
filestart += blocksize;
}
}
int64_t finalblock = rangesize - (fullblocks * blocksize);
if( finalblock > 0 )
{
loadBlock(data, finalblock, period_index, filestart, hist_index, spectra_no, local_workspace);
}
}
//Load in the last of the list indices
for( std::vector<int64_t>::iterator itr = min_end; itr < m_spec_list.end(); ++itr )
{
// Load each
int64_t spectra_no = (*itr);
// For this to work correctly, we assume that the spectrum list increases monotonically
int64_t filestart = std::lower_bound(spec_begin,m_spec_end,spectra_no) - spec_begin;
loadBlock(data, 1, period_index, filestart, hist_index, spectra_no, local_workspace);
}
}
try
{
const std::string title = entry.getString("title");
local_workspace->setTitle(title);
// write the title into the log file (run object)
local_workspace->mutableRun().addProperty("run_title", title, true);
}
catch (std::runtime_error &)
{
g_log.debug() << "No title was found in the input file, " << getPropertyValue("Filename") << std::endl;
}
}
示例6: period_index
/**
* Load a given period into the workspace
* @param period :: The period number to load (starting from 1)
* @param entry :: The opened root entry node for accessing the monitor and data
* nodes
* @param local_workspace :: The workspace to place the data in
* @param update_spectra2det_mapping :: reset spectra-detector map to the one
* calculated earlier. (Warning! -- this map has to be calculated correctly!)
*/
void
LoadISISNexus2::loadPeriodData(int64_t period, NXEntry &entry,
DataObjects::Workspace2D_sptr &local_workspace,
bool update_spectra2det_mapping) {
int64_t hist_index = 0;
int64_t period_index(period - 1);
// int64_t first_monitor_spectrum = 0;
for (auto block = m_spectraBlocks.begin(); block != m_spectraBlocks.end();
++block) {
if (block->isMonitor) {
NXData monitor = entry.openNXData(block->monName);
NXInt mondata = monitor.openIntData();
m_progress->report("Loading monitor");
mondata.load(1, static_cast<int>(period - 1)); // TODO this is just wrong
MantidVec &Y = local_workspace->dataY(hist_index);
Y.assign(mondata(), mondata() + m_monBlockInfo.numberOfChannels);
MantidVec &E = local_workspace->dataE(hist_index);
std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt);
if (update_spectra2det_mapping) {
// local_workspace->getAxis(1)->setValue(hist_index,
// static_cast<specid_t>(it->first));
auto spec = local_workspace->getSpectrum(hist_index);
specid_t specID = m_specInd2specNum_map.at(hist_index);
spec->setDetectorIDs(
m_spec2det_map.getDetectorIDsForSpectrumNo(specID));
spec->setSpectrumNo(specID);
}
NXFloat timeBins = monitor.openNXFloat("time_of_flight");
timeBins.load();
local_workspace->dataX(hist_index)
.assign(timeBins(), timeBins() + timeBins.dim0());
hist_index++;
} else if (m_have_detector) {
NXData nxdata = entry.openNXData("detector_1");
NXDataSetTyped<int> data = nxdata.openIntData();
data.open();
// Start with the list members that are lower than the required spectrum
const int *const spec_begin = m_spec.get();
// When reading in blocks we need to be careful that the range is exactly
// divisible by the block-size
// and if not have an extra read of the left overs
const int64_t blocksize = 8;
const int64_t rangesize = block->last - block->first + 1;
const int64_t fullblocks = rangesize / blocksize;
int64_t spectra_no = block->first;
// For this to work correctly, we assume that the spectrum list increases
// monotonically
int64_t filestart =
std::lower_bound(spec_begin, m_spec_end, spectra_no) - spec_begin;
if (fullblocks > 0) {
for (int64_t i = 0; i < fullblocks; ++i) {
loadBlock(data, blocksize, period_index, filestart, hist_index,
spectra_no, local_workspace);
filestart += blocksize;
}
}
int64_t finalblock = rangesize - (fullblocks * blocksize);
if (finalblock > 0) {
loadBlock(data, finalblock, period_index, filestart, hist_index,
spectra_no, local_workspace);
}
}
}
try {
const std::string title = entry.getString("title");
local_workspace->setTitle(title);
// write the title into the log file (run object)
local_workspace->mutableRun().addProperty("run_title", title, true);
} catch (std::runtime_error &) {
g_log.debug() << "No title was found in the input file, "
<< getPropertyValue("Filename") << std::endl;
}
}