Skip to content

Commit

Permalink
Make necessary changes in code for this re #5874
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Nov 29, 2012
1 parent 10fc078 commit 6765973
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ namespace API
/// Detector grouping information
det2group_map m_detgroups;

/// Default of the Nexus File Instrument section version number
int m_defaultNexusInstrumentVersionNumber;
};

/// Shared pointer to ExperimentInfo
Expand Down
30 changes: 8 additions & 22 deletions Code/Mantid/Framework/API/src/ExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace API
m_parmap(new ParameterMap()),
sptr_instrument(new Instrument())
{
m_defaultNexusInstrumentVersionNumber = 0;
}

//----------------------------------------------------------------------------------------------
Expand All @@ -74,7 +73,6 @@ namespace API
{
m_sample = other->m_sample;
m_run = other->m_run;
m_defaultNexusInstrumentVersionNumber = other->m_defaultNexusInstrumentVersionNumber;
this->setInstrument(other->getInstrument());
if(other->m_moderatorModel) m_moderatorModel = other->m_moderatorModel->clone();
m_choppers.clear();
Expand Down Expand Up @@ -834,21 +832,6 @@ namespace API
return mostRecentIDF;
}

/**
* The instrument section of a Nexus file may have differening structure.
* This will be determined by the version number attribute of the instrument entry,
* if such an attribute exists. If there is no such attribute then a default value
* is used. This must be 0 for a PrecessedNexus file, to allow old versions to be read.
* For other types of Nexus file this value may need to be set, hence this function
*
* @param vn :: the required default version number of the instrument section
*/
void ExperimentInfo::setdefaultNexusInstrumentVersionNumber( int vn )
{
m_defaultNexusInstrumentVersionNumber = vn;
}


//--------------------------------------------------------------------------------------------
/** Save the object to an open NeXus file.
* @param file :: open NeXus file
Expand Down Expand Up @@ -1002,14 +985,17 @@ namespace API
file->openGroup("instrument", "NXinstrument");
file->readData("name", instrumentName);

int version = m_defaultNexusInstrumentVersionNumber; // 0 for ProcessedNexus
try { file->getAttr("version", version); } catch (...) {}
if (version == 0)
{ // Old style: instrument_source and instrument_parameter_map were at the same level as instrument.
// We first assume this is a new version file, but if the next step fails we assume its and old version file.
int version = 1;
try {
file->readData("instrument_source", instrumentFilename);
}
catch(...) {
version = 0;
file->closeGroup();
file->readData("instrument_source", instrumentFilename);
}

file->readData("instrument_source", instrumentFilename);
file->openGroup("instrument_parameter_map", "NXnote");
file->readData("data", parameterStr);
file->closeGroup();
Expand Down
1 change: 0 additions & 1 deletion Code/Mantid/Framework/DataHandling/src/LoadISISNexus2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ namespace Mantid

//Load instrument and other data once then copy it later
m_progress->report("Loading instrument");
local_workspace->setdefaultNexusInstrumentVersionNumber(1);
loadRunDetails(local_workspace, entry);
m_cppFile->openPath(entry.path());
std::string parameterString;
Expand Down

0 comments on commit 6765973

Please sign in to comment.