Skip to content

Commit

Permalink
Merge pull request #12902 from mantidproject/load_and_save_calfile
Browse files Browse the repository at this point in the history
The new algorithms can save and load offset, mask and group workspaces as designed.  The only issue found is that the instrument of the original mask workspace and the one of saved-loaded mask workspace are not same.  I point it out though I think it is another issue to mask workspace.  Issue is thus closed.
  • Loading branch information
wdzhou committed Jun 24, 2015
2 parents db61b52 + 9f66ed5 commit 6e498d2
Show file tree
Hide file tree
Showing 12 changed files with 1,080 additions and 9 deletions.
13 changes: 7 additions & 6 deletions Code/Mantid/Build/CMake/CommonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set ( TESTING_TIMEOUT 300 CACHE INTEGER
###########################################################################

set ( Boost_NO_BOOST_CMAKE TRUE )
find_package ( Boost REQUIRED date_time regex )
find_package ( Boost REQUIRED date_time regex )
include_directories( SYSTEM ${Boost_INCLUDE_DIRS} )
add_definitions ( -DBOOST_ALL_DYN_LINK )
# Need this defined globally for our log time values
Expand Down Expand Up @@ -74,10 +74,11 @@ set ( CMAKE_INCLUDE_PATH ${MAIN_CMAKE_INCLUDE_PATH} )

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" OR (APPLE AND OSX_VERSION VERSION_LESS 10.9))
set (HDF5_DIR "${CMAKE_MODULE_PATH}")
find_package ( HDF5 COMPONENTS HL REQUIRED
find_package ( HDF5 COMPONENTS CXX HL REQUIRED
CONFIGS hdf5-config.cmake )
add_definitions ( -DH5_BUILT_AS_DYNAMIC_LIB )
else()
find_package ( HDF5 COMPONENTS HL REQUIRED )
find_package ( HDF5 COMPONENTS CXX HL REQUIRED )
endif()

find_package ( PythonInterp )
Expand Down Expand Up @@ -115,7 +116,7 @@ if ( GIT_FOUND )
string ( REGEX MATCH "(g.*)[^\n]" MtdVersion_WC_LAST_CHANGED_SHA ${MtdVersion_WC_LAST_CHANGED_REV} )

# Get the date of the last commit
execute_process ( COMMAND ${GIT_EXECUTABLE} log -1 --format=format:%cD OUTPUT_VARIABLE MtdVersion_WC_LAST_CHANGED_DATE
execute_process ( COMMAND ${GIT_EXECUTABLE} log -1 --format=format:%cD OUTPUT_VARIABLE MtdVersion_WC_LAST_CHANGED_DATE
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
string ( SUBSTRING ${MtdVersion_WC_LAST_CHANGED_DATE} 0 16 MtdVersion_WC_LAST_CHANGED_DATE )
Expand Down Expand Up @@ -251,7 +252,7 @@ endif ()
if ( CMAKE_COMPILER_IS_GNUCXX )
include ( GNUSetup )
elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
# Remove once clang warnings have been fixed.
# Remove once clang warnings have been fixed.
if ( NOT APPLE)
include ( GNUSetup )
endif ()
Expand Down Expand Up @@ -287,7 +288,7 @@ find_package ( GMock )
if ( GMOCK_FOUND AND GTEST_FOUND )
message ( STATUS "GMock/GTest (${GMOCK_VERSION}) is available for unit tests." )
else ()
message ( STATUS "GMock/GTest is not available. Some unit tests will not run." )
message ( STATUS "GMock/GTest is not available. Some unit tests will not run." )
endif()

find_package ( PyUnitTest )
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Build/CMake/hdf5-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ SET (HDF5_BUILD_SHARED_LIBS ON)
#-----------------------------------------------------------------------------
# Directories
#-----------------------------------------------------------------------------
SET (HDF5_INCLUDE_DIRS "${THIRD_PARTY}/include/hdf5;${THIRD_PARTY}/include/hdf5/c++;${THIRD_PARTY}/include/hdf5/hl")
SET (HDF5_INCLUDE_DIRS "${THIRD_PARTY}/include/hdf5;${THIRD_PARTY}/include/hdf5/cpp;${THIRD_PARTY}/include/hdf5/hl")

IF (HDF5_BUILD_FORTRAN)
MESSAGE (ERROR "Sorry - we don't supply the fortran bindings.")
ENDIF (HDF5_BUILD_FORTRAN)

IF (HDF5_BUILD_CPP_LIB)
SET (HDF5_INCLUDE_DIR_CPP ${HDF5_INCLUDE_DIRS} )
ENDIF (HDF5_BUILD_CPP_LIB)
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/DataHandling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set ( SRC_FILES
src/LoadDaveGrp.cpp
src/LoadDetectorInfo.cpp
src/LoadDetectorsGroupingFile.cpp
src/LoadDiffCal.cpp
src/LoadDspacemap.cpp
src/LoadEmptyInstrument.cpp
src/LoadEventNexus.cpp
Expand Down Expand Up @@ -121,6 +122,7 @@ set ( SRC_FILES
src/SaveCanSAS1D2.cpp
src/SaveDaveGrp.cpp
src/SaveDetectorsGrouping.cpp
src/SaveDiffCal.cpp
src/SaveDspacemap.cpp
src/SaveFocusedXYE.cpp
src/SaveFullprofResolution.cpp
Expand Down Expand Up @@ -186,6 +188,7 @@ set ( INC_FILES
inc/MantidDataHandling/LoadDaveGrp.h
inc/MantidDataHandling/LoadDetectorInfo.h
inc/MantidDataHandling/LoadDetectorsGroupingFile.h
inc/MantidDataHandling/LoadDiffCal.h
inc/MantidDataHandling/LoadDspacemap.h
inc/MantidDataHandling/LoadEmptyInstrument.h
inc/MantidDataHandling/LoadEventNexus.h
Expand Down Expand Up @@ -270,6 +273,7 @@ set ( INC_FILES
inc/MantidDataHandling/SaveCanSAS1D2.h
inc/MantidDataHandling/SaveDaveGrp.h
inc/MantidDataHandling/SaveDetectorsGrouping.h
inc/MantidDataHandling/SaveDiffCal.h
inc/MantidDataHandling/SaveDspacemap.h
inc/MantidDataHandling/SaveFocusedXYE.h
inc/MantidDataHandling/SaveFullprofResolution.h
Expand Down Expand Up @@ -336,6 +340,7 @@ set ( TEST_FILES
LoadDaveGrpTest.h
LoadDetectorInfoTest.h
LoadDetectorsGroupingFileTest.h
LoadDiffCalTest.h
LoadDspacemapTest.h
LoadEmptyInstrumentTest.h
LoadEventNexusTest.h
Expand Down Expand Up @@ -415,6 +420,7 @@ set ( TEST_FILES
SaveCanSAS1dTest2.h
SaveDaveGrpTest.h
SaveDetectorsGroupingTest.h
SaveDiffCalTest.h
SaveDspacemapTest.h
SaveFocussedXYETest.h
SaveFullprofResolutionTest.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef MANTID_DATAHANDLING_LOADDIFFCAL_H_
#define MANTID_DATAHANDLING_LOADDIFFCAL_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"

namespace H5 {
class H5File;
class Group;
}

namespace Mantid {
namespace DataHandling {

/** LoadDiffCal : TODO: DESCRIPTION
Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadDiffCal : public API::Algorithm {
public:
LoadDiffCal();
virtual ~LoadDiffCal();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;

private:
void init();
void exec();
void getInstrument(H5::H5File &file);
std::vector<int32_t> readInt32Array(H5::Group &group, const std::string &name);
std::vector<double> readDoubleArray(H5::Group &group, const std::string &name);
void makeGroupingWorkspace(const std::vector<int32_t> &detids, const std::vector<int32_t> &groups);
void makeMaskWorkspace(const std::vector<int32_t> &detids, const std::vector<int32_t> &use);
void makeCalWorkspace(const std::vector<int32_t> &detids, const std::vector<double> &difc,
const std::vector<double> &difa, const std::vector<double> &tzero,
const std::vector<int32_t> &dasids, const std::vector<double> &offsets);

std::string m_filename;
std::string m_workspaceName;
Geometry::Instrument_const_sptr m_instrument;
};

} // namespace DataHandling
} // namespace Mantid

#endif /* MANTID_DATAHANDLING_LOADDIFFCAL_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef MANTID_DATAHANDLING_SAVEDIFFCAL_H_
#define MANTID_DATAHANDLING_SAVEDIFFCAL_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/ITableWorkspace_fwd.h"
#include "MantidDataObjects/SpecialWorkspace2D.h"

namespace H5 {
class Group;
}

namespace Mantid {
namespace DataHandling {

/** SaveDiffCal : TODO: DESCRIPTION
Copyright &copy; 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport SaveDiffCal : public API::Algorithm {
public:
SaveDiffCal();
virtual ~SaveDiffCal();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;

private:
void init();
void exec();
std::map<std::string, std::string> validateInputs();

void writeDoubleFieldFromTable(H5::Group &group, const std::string &name);
void writeIntFieldFromTable(H5::Group &group, const std::string &name);
void writeIntFieldFromSVWS(H5::Group &group, const std::string &name,
DataObjects::SpecialWorkspace2D_const_sptr ws);
void generateDetidToIndex();
bool tableHasColumn(const std::string name) const;

API::ITableWorkspace_sptr m_calibrationWS;
std::map<detid_t, size_t> m_detidToIndex;
};

} // namespace DataHandling
} // namespace Mantid

#endif /* MANTID_DATAHANDLING_SAVEDIFFCAL_H_ */
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/DataHandling/src/LoadCalFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void LoadCalFile::init() {
declareProperty(
new PropertyWithValue<std::string>("WorkspaceName", "", Direction::Input),
"The base of the output workspace names. Names will have '_group', "
"'_offsets', '_mask' appended to them.");
"'_cal', '_offsets', '_mask' appended to them.");
}

//----------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 6e498d2

Please sign in to comment.