Skip to content

Commit

Permalink
Merge branch 'master' into feature/7614_interface_categories
Browse files Browse the repository at this point in the history
Refs #7614

Conflicts:
	Code/Mantid/MantidPlot/src/ApplicationWindow.h
  • Loading branch information
PeterParker committed Oct 25, 2013
2 parents 6ccc7f6 + 32de26a commit 59e4c47
Show file tree
Hide file tree
Showing 152 changed files with 6,213 additions and 2,873 deletions.
3 changes: 2 additions & 1 deletion Code/Mantid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ if ( ENABLE_CPACK )
# rhel requirements
set ( CPACK_RPM_PACKAGE_REQUIRES "boost >= 1.34.1,qt4 >= 4.2,nexus,nexus-python,qwt,gsl,glibc,qwtplot3d-qt4,OpenCASCADE-libs-modelling >= 6.3.0,OpenCASCADE-libs-foundation >= 6.3.0,OpenCASCADE-libs-visualization >= 6.3.0,OpenCASCADE-libs-ocaf >= 6.3.0,OpenCASCADE-libs-ocaf-lite >= 6.3.0,muParser,numpy" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},poco-crypto,poco-data,poco-mysql,poco-sqlite,poco-odbc,poco-util,poco-xml,poco-zip,poco-net,poco-netssl,poco-foundation,PyQt4,sip" )
# scipy & matplotlib (ipython is too low a version to be used)
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},python-ipython >= 1.1.0" )
# scipy & matplotlib
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},scipy,python-matplotlib" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},mxml,hdf,hdf5" )

Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IBackgroundFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class DLLExport IBackgroundFunction : public IFunctionWithLocation
virtual void fit(const std::vector<double>& X,const std::vector<double>& Y) = 0;
};

typedef boost::shared_ptr<IBackgroundFunction> IBackgroundFunction_sptr;

} // namespace API
} // namespace Mantid

Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ namespace Mantid

/// Empty the values out of all TimeSeriesProperty logs
void clearTimeSeriesLogs();
/// Empty all but the last value out of all TimeSeriesProperty logs
void clearOutdatedTimeSeriesLogValues();

/// Save the run to a NeXus file with a given group name
virtual void saveNexus(::NeXus::File * file, const std::string & group,bool keepOpen=false) const;
Expand Down
4 changes: 3 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/ScriptRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,12 @@ They will work as was expected for folders @ref folders-sec.
@param option: flag to set for auto-update, or not. If true, new versions of the path will replace the local file as soon as they are available at the central repository.
@return int: number of files changed (because of the cascading of folders)
@exception ScriptRepoException : Invalid entry.
*/
virtual void setAutoUpdate(const std::string & path, bool option = true) = 0;
virtual int setAutoUpdate(const std::string & path, bool option = true) = 0;


};
Expand Down
57 changes: 37 additions & 20 deletions Code/Mantid/Framework/API/src/ExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <Poco/SAX/ContentHandler.h>
#include <Poco/SAX/SAXParser.h>
#include <Poco/ScopedLock.h>
#include <nexus/NeXusException.hpp>

using namespace Mantid::Geometry;
using namespace Mantid::Kernel;
Expand Down Expand Up @@ -867,6 +868,8 @@ namespace API
* @param file :: open NeXus file
* @param[out] parameterStr :: special string for all the parameters.
* Feed that to ExperimentInfo::readParameterMap() after the instrument is done.
* @throws Exception::NotFoundError If instrument definition is not in the nexus file and cannot
* be loaded from the IDF.
*/
void ExperimentInfo::loadExperimentInfoNexus(::NeXus::File * file, std::string & parameterStr)
{
Expand All @@ -890,34 +893,50 @@ namespace API
this->mutableRun().loadNexus(file, "logs");
}

// Now the instrument source
instrumentXml = "";
instrumentName = "";

// Try to get the instrument file
file->openGroup("instrument", "NXinstrument");
file->readData("name", instrumentName);

try {
file->openGroup("instrument_xml", "NXnote");
file->readData("data", instrumentXml );
file->closeGroup();
}
catch (NeXus::Exception& ex) {
// Just carry on - it might not be there (e.g. old-style processed files)
g_log.debug(ex.what());
}

// 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(...) {
}
catch (NeXus::Exception&) {
version = 0;
// In the old version 'processed' file, this was held at the top level (as was the parameter map)
file->closeGroup();
file->readData("instrument_source", instrumentFilename);
try {
file->readData("instrument_source", instrumentFilename);
}
catch (NeXus::Exception& ex) {
// Just carry on - it might not be there (e.g. for SNS files)
g_log.debug(ex.what());
}
}

file->openGroup("instrument_parameter_map", "NXnote");
file->readData("data", parameterStr);
file->closeGroup();
try {
file->openGroup("instrument_parameter_map", "NXnote");
file->readData("data", parameterStr);
file->closeGroup();
}
catch (NeXus::Exception& ex) {
// Just carry on - it might not be there (e.g. for SNS files)
g_log.debug(ex.what());
}

if (version > 0)
if ( version == 1 )
{
file->openGroup("instrument_xml", "NXnote");
file->readData("data", instrumentXml );
file->closeGroup();
file->closeGroup();
}

Expand All @@ -937,16 +956,14 @@ namespace API
}
catch (std::exception & e)
{
g_log.error() << "Error loading instrument IDF file for '" << instrumentName << "'." << std::endl;
g_log.error() << e.what() << std::endl;
g_log.error() << "Error loading instrument IDF file for '" << instrumentName << "'.\n";
g_log.debug() << e.what() << std::endl;
throw;
}
}
else
{
// The filename in the file = just bare file.
// So Get the full path back to the instrument directory.
instrumentFilename = ConfigService::Instance().getInstrumentDirectory() + "/" + instrumentFilename;
g_log.debug() << "Using instrument IDF XML text contained in .nxs file." << std::endl;
g_log.debug() << "Using instrument IDF XML text contained in nexus file.\n";
}


Expand Down
17 changes: 16 additions & 1 deletion Code/Mantid/Framework/API/src/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,22 @@ Kernel::Logger& LogManager::g_log = Kernel::Logger::get("LogManager");
}
}


/** Clears out all but the last entry of all logs of type TimeSeriesProperty
* Check the documentation/definition of TimeSeriesProperty::clearOutdated for
* the definition of 'last entry'.
*/
void LogManager::clearOutdatedTimeSeriesLogValues()
{
auto & props = getProperties();
for ( auto it = props.begin(); it != props.end(); ++it)
{
if ( auto tsp = dynamic_cast<ITimeSeriesProperty*>(*it) )
{
tsp->clearOutdated();
}
}
}

//--------------------------------------------------------------------------------------------
/** Save the object to an open NeXus file.
* @param file :: open NeXus file
Expand Down
30 changes: 30 additions & 0 deletions Code/Mantid/Framework/API/test/LogManagerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,37 @@ class LogManagerTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( runInfo.getPropertyValueAsType<int>(intProp), 99 );
}

void clearOutdatedTimeSeriesLogValues()
{
// Set up a Run object with 3 properties in it (1 time series, 2 single value)
LogManager runInfo;
const std::string stringProp("aStringProp");
const std::string stringVal("testing");
runInfo.addProperty(stringProp,stringVal);
const std::string intProp("anIntProp");
runInfo.addProperty(intProp,99);
const std::string tspProp("tsp");
addTestTimeSeries(runInfo,"tsp");

// Check it's set up right
TS_ASSERT_EQUALS( runInfo.getProperties().size(), 3 );
auto tsp = runInfo.getTimeSeriesProperty<double>(tspProp);
TS_ASSERT_EQUALS( tsp->realSize(), 10 );

auto lastTime = tsp->lastTime();
auto lastValue = tsp->lastValue();

// Do the clearing work
TS_ASSERT_THROWS_NOTHING( runInfo.clearOutdatedTimeSeriesLogValues() );

// Check the time-series property has 1 entry, & the others are unchanged
TS_ASSERT_EQUALS( runInfo.getProperties().size(), 3 );
TS_ASSERT_EQUALS( tsp->realSize(), 1 );
TS_ASSERT_EQUALS( tsp->firstTime(), lastTime );
TS_ASSERT_EQUALS( tsp->firstValue(), lastValue );
TS_ASSERT_EQUALS( runInfo.getPropertyValueAsType<std::string>(stringProp), stringVal );
TS_ASSERT_EQUALS( runInfo.getPropertyValueAsType<int>(intProp), 99 );
}

/** Save and load to NXS file */
void test_nexus()
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ set ( SRC_FILES
src/FindDetectorsOutsideLimits.cpp
src/FindPeaks.cpp
src/FindPeakBackground.cpp
src/FitPeak.cpp
src/FlatPlateAbsorption.cpp
src/GeneralisedSecondDifference.cpp
src/GenerateEventsFilter.cpp
Expand Down Expand Up @@ -327,6 +328,7 @@ set ( INC_FILES
inc/MantidAlgorithms/FindDetectorsOutsideLimits.h
inc/MantidAlgorithms/FindPeaks.h
inc/MantidAlgorithms/FindPeakBackground.h
inc/MantidAlgorithms/FitPeak.h
inc/MantidAlgorithms/FlatPlateAbsorption.h
inc/MantidAlgorithms/GSLFunctions.h
inc/MantidAlgorithms/GeneralisedSecondDifference.h
Expand Down Expand Up @@ -554,6 +556,7 @@ set ( TEST_FILES
FindDetectorsOutsideLimitsTest.h
FindPeaksTest.h
FindPeakBackgroundTest.h
FitPeakTest.h
FlatPlateAbsorptionTest.h
GenerateEventsFilterTest.h
GeneratePeaksTest.h
Expand Down

0 comments on commit 59e4c47

Please sign in to comment.