diff --git a/App/src/TestFormFactors.cpp b/App/src/TestFormFactors.cpp index f0c9857a1351f13ed107fa00d6f4bd3132f6da1c..17b6710ab376919590304ea44c86e67e2ba82250 100644 --- a/App/src/TestFormFactors.cpp +++ b/App/src/TestFormFactors.cpp @@ -153,7 +153,7 @@ void TestFormFactors::run_isgisaxs_simulation(IFormFactor *p_form_factor) simulation.setSample(multi_layer); simulation.runSimulation(); std::cout << mp_form_factor->getName().substr(10) <<std::endl; - IntensityDataIOFactory::writeIntensityData(*simulation.getOutputData(), + IntensityDataIOFactory::writeOutputData(*simulation.getOutputData(), "this_"+mp_form_factor->getName().substr(10)+"_BA.ima"); } @@ -222,9 +222,9 @@ void TestFormFactors::finalise() const double threshold(2e-10); for(size_t i=0; i<tocompare.size(); ++i) { - OutputData<double> *isgi_data = IntensityDataIOFactory::readIntensityData( + OutputData<double> *isgi_data = IntensityDataIOFactory::readOutputData( tocompare[i].isginame); - OutputData<double> *our_data = IntensityDataIOFactory::readIntensityData( + OutputData<double> *our_data = IntensityDataIOFactory::readOutputData( tocompare[i].thisname); IsGISAXSTools::drawOutputDataComparisonResults(*our_data, *isgi_data, diff --git a/App/src/TestFourier.cpp b/App/src/TestFourier.cpp index ffd0371813365cfe5d7eb1bcd636c3f5e8fc9027..0d879846031baa0826d5c8e68e0ad2a8b470d8cc 100644 --- a/App/src/TestFourier.cpp +++ b/App/src/TestFourier.cpp @@ -58,7 +58,7 @@ void TestFourier::execute() OutputDataFunctions::FourierTransformR(fft_map, mp_intensity_output); IsGISAXSTools::drawOutputData(*p_real_fft_map, "c1_four", "Fourier transform", "CONT4 Z", "Fourier transform"); - IntensityDataIOFactory::writeIntensityData(*p_real_fft_map, Utils::FileSystem::GetHomePath()+"./Examples/MesoCrystals/Fourier.ima"); + IntensityDataIOFactory::writeOutputData(*p_real_fft_map, Utils::FileSystem::GetHomePath()+"./Examples/MesoCrystals/Fourier.ima"); } diff --git a/App/src/TestInfLongBox.cpp b/App/src/TestInfLongBox.cpp index 98b9cd9917ebf04c7d0cfedad488c43ba3edf561..40c6b757abac38c7533a7852ea4df4927f6d097a 100644 --- a/App/src/TestInfLongBox.cpp +++ b/App/src/TestInfLongBox.cpp @@ -77,7 +77,7 @@ void TestInfLongBox::execute() void TestInfLongBox::save_results() { std::string filename(getOutputPath()+"test_inflongbox.ima"); - IntensityDataIOFactory::writeIntensityData(*(mp_simulation->getDetectorIntensity()), + IntensityDataIOFactory::writeOutputData(*(mp_simulation->getDetectorIntensity()), filename); } diff --git a/App/src/TestInfLongRipple1.cpp b/App/src/TestInfLongRipple1.cpp index a0bb4a9606f299faebad3dd68df3e9315295b732..77ee331ca39c521b6c7381a34f85b21c95e3f2e0 100644 --- a/App/src/TestInfLongRipple1.cpp +++ b/App/src/TestInfLongRipple1.cpp @@ -79,7 +79,7 @@ void TestInfLongRipple1::save_results() // run simulation for default sample parameters //mp_simulation->runSimulation(); std::string filename(getOutputPath()+"test_inflongripple1.ima"); - IntensityDataIOFactory::writeIntensityData(*(mp_simulation->getDetectorIntensity()), + IntensityDataIOFactory::writeOutputData(*(mp_simulation->getDetectorIntensity()), filename); } diff --git a/App/src/TestInfLongRipple2.cpp b/App/src/TestInfLongRipple2.cpp index e381215263ed838c6512667d8a8f6a6a4e92ded4..dbeafc2308e9a7424a0b47a53b4ffb8ad92c898e 100644 --- a/App/src/TestInfLongRipple2.cpp +++ b/App/src/TestInfLongRipple2.cpp @@ -80,7 +80,7 @@ void TestInfLongRipple2::save_results() // run simulation for default sample parameters //mp_simulation->runSimulation(); std::string filename(getOutputPath()+"test_inflongripple2.ima"); - IntensityDataIOFactory::writeIntensityData(*(mp_simulation->getDetectorIntensity()), + IntensityDataIOFactory::writeOutputData(*(mp_simulation->getDetectorIntensity()), filename); } diff --git a/App/src/TestIsGISAXS12.cpp b/App/src/TestIsGISAXS12.cpp index 3342937a8705b470106cf49f8ecaeb0b07498959..04677f34883aa4a4eee8ae8e350a7c2ec3cf3856 100644 --- a/App/src/TestIsGISAXS12.cpp +++ b/App/src/TestIsGISAXS12.cpp @@ -105,7 +105,7 @@ void TestIsGISAXS12::run_isgisaxs_comparison() { // run simulation for default sample parameters m_simulation->runSimulation(); - IntensityDataIOFactory::writeIntensityData(*(m_simulation->getOutputData()), "this_fitconstraints.ima"); + IntensityDataIOFactory::writeOutputData(*(m_simulation->getOutputData()), "this_fitconstraints.ima"); // plotting results of comparison we/isgisaxs for the sample with default parameters std::string isgi_file(getOutputPath()+"isgi_fitconstraints_optimal.ima.gz"); @@ -114,8 +114,8 @@ void TestIsGISAXS12::run_isgisaxs_comparison() // ------------- // plot results // ------------- - OutputData<double> *isgi_data = IntensityDataIOFactory::readIntensityData(isgi_file); - OutputData<double> *our_data = IntensityDataIOFactory::readIntensityData(this_file); + OutputData<double> *isgi_data = IntensityDataIOFactory::readOutputData(isgi_file); + OutputData<double> *our_data = IntensityDataIOFactory::readOutputData(this_file); IsGISAXSTools::drawOutputDataComparisonResults(*our_data, *isgi_data,"TestIsGISAXS12_c1", "ex-12: Mixture of cylindrical particles with different size distribution"); delete isgi_data; diff --git a/App/src/TestIsGISAXS5.cpp b/App/src/TestIsGISAXS5.cpp index e18b2178c7a9a38f13f227c7baa4704b8421696d..2661ba003983e3fe635c9ade4060099dd1446030 100644 --- a/App/src/TestIsGISAXS5.cpp +++ b/App/src/TestIsGISAXS5.cpp @@ -80,7 +80,7 @@ void TestIsGISAXS5::run_isgisaxs_comparison() { // run simulation for default sample parameters mp_simulation->runSimulation(); - IntensityDataIOFactory::writeIntensityData(*(mp_simulation->getOutputData()), + IntensityDataIOFactory::writeOutputData(*(mp_simulation->getOutputData()), "this_fitexample.ima"); // plotting results of comparison we/isgisaxs for the sample with default parameters @@ -90,8 +90,8 @@ void TestIsGISAXS5::run_isgisaxs_comparison() // ------------- // plot results // ------------- - OutputData<double> *isgi_data = IntensityDataIOFactory::readIntensityData(isgi_file); - OutputData<double> *our_data = IntensityDataIOFactory::readIntensityData(this_file); + OutputData<double> *isgi_data = IntensityDataIOFactory::readOutputData(isgi_file); + OutputData<double> *our_data = IntensityDataIOFactory::readOutputData(this_file); IsGISAXSTools::drawOutputDataComparisonResults( *our_data, *isgi_data, "TestIsGISAXS5_c1", diff --git a/App/src/TestMesoCrystal1.cpp b/App/src/TestMesoCrystal1.cpp index 19ef4d50bc3b4c0f623434902f28c7e9b8271c4d..673ded99dcc2aeef575662179328b9e6865fb152 100644 --- a/App/src/TestMesoCrystal1.cpp +++ b/App/src/TestMesoCrystal1.cpp @@ -33,7 +33,7 @@ void TestMesoCrystal1::execute() + "mesocrystal01_reference.int.gz"; OutputData<double> *reference = - IntensityDataIOFactory::readIntensityData(filename); + IntensityDataIOFactory::readOutputData(filename); simulation->runSimulation(); simulation->normalize(); @@ -57,7 +57,7 @@ void TestMesoCrystal1::execute() IsGISAXSTools::drawOutputDataComparisonResults( *data, *reference, "found", "found params", 100, 1e6); - IntensityDataIOFactory::writeIntensityData(*data,"test_mesocrystal1.int"); + IntensityDataIOFactory::writeOutputData(*data,"test_mesocrystal1.int"); delete data; delete simulation; diff --git a/App/src/TestRipple1.cpp b/App/src/TestRipple1.cpp index 93f64ede4eef7d4b4840ef4bf91a770c8a3f0d15..4a8feb0934f069fc6bba4a669047c110f18f2754 100644 --- a/App/src/TestRipple1.cpp +++ b/App/src/TestRipple1.cpp @@ -77,7 +77,7 @@ void TestRipple1::execute() void TestRipple1::save_results() { std::string filename(getOutputPath()+"test_ripple1.ima"); - IntensityDataIOFactory::writeIntensityData(*(mp_simulation->getDetectorIntensity()), + IntensityDataIOFactory::writeOutputData(*(mp_simulation->getDetectorIntensity()), filename); std::cout << "Data saved to " << filename << std::endl; } diff --git a/App/src/TestRipple2.cpp b/App/src/TestRipple2.cpp index a9798d74de003406f932d839b2907b368caeeae3..a783c514043163d29efde1932723c4c0ba4d414f 100644 --- a/App/src/TestRipple2.cpp +++ b/App/src/TestRipple2.cpp @@ -78,7 +78,7 @@ void TestRipple2::save_results() // run simulation for default sample parameters //mp_simulation->runSimulation(); std::string filename(getOutputPath()+"test_ripple2_asym.ima"); - IntensityDataIOFactory::writeIntensityData(*(mp_simulation->getDetectorIntensity()), + IntensityDataIOFactory::writeOutputData(*(mp_simulation->getDetectorIntensity()), filename); } diff --git a/Core/PythonAPI/src/IHistogram.pypp.cpp b/Core/PythonAPI/src/IHistogram.pypp.cpp index 84de17e651ca161b9b955b1def51ab500d7a5b8d..5b0b690ba2e9775508efb32f8975d071ad20c4bb 100644 --- a/Core/PythonAPI/src/IHistogram.pypp.cpp +++ b/Core/PythonAPI/src/IHistogram.pypp.cpp @@ -104,13 +104,13 @@ void register_IHistogram_class(){ } { //::IHistogram::findGlobalBin - typedef int ( ::IHistogram::*findGlobalBin_function_type)( double,double ) const; + typedef ::std::size_t ( ::IHistogram::*findGlobalBin_function_type)( double,double ) const; IHistogram_exposer.def( "findGlobalBin" , findGlobalBin_function_type( &::IHistogram::findGlobalBin ) , ( bp::arg("x"), bp::arg("y") ) - , "Returns closest global bin index for given axes coordinates. For 1D @param x Value on x-axis @param y Value on y-axis @return Closest global bin index \n\n:Parameters:\n - 'x' - Value on x-axis\n - 'y' - Value on y-axis\n" ); + , "Returns closest global bin index for given axes coordinates. For 1D @param x Value on x-axis @param y Value on y-axis (for 2D histograms) @return Closest global bin index \n\n:Parameters:\n - 'x' - Value on x-axis\n - 'y' - Value on y-axis (for 2D histograms)\n" ); } { //::IHistogram::getArray @@ -126,101 +126,101 @@ void register_IHistogram_class(){ } { //::IHistogram::getBinAverage - typedef double ( ::IHistogram::*getBinAverage_function_type)( int ) const; + typedef double ( ::IHistogram::*getBinAverage_function_type)( ::std::size_t ) const; IHistogram_exposer.def( "getBinAverage" , getBinAverage_function_type( &::IHistogram::getBinAverage ) - , ( bp::arg("bin") ) - , "Returns average value in the bin with given index. For 1D histograms bin index is related to x-axis. For 2D histograms bin index is global bin index. " ); + , ( bp::arg("globalbin") ) + , "Returns average value in the bin with given index." ); } { //::IHistogram::getBinAverage - typedef double ( ::IHistogram::*getBinAverage_function_type)( int,int ) const; + typedef double ( ::IHistogram::*getBinAverage_function_type)( ::std::size_t,::std::size_t ) const; IHistogram_exposer.def( "getBinAverage" , getBinAverage_function_type( &::IHistogram::getBinAverage ) , ( bp::arg("binx"), bp::arg("biny") ) - , "Returns average value in the bin of 2D histogram with given axes indices." ); + , "Returns average value of the bin with given indices (for 2D histograms)." ); } { //::IHistogram::getBinContent - typedef double ( ::IHistogram::*getBinContent_function_type)( int ) const; + typedef double ( ::IHistogram::*getBinContent_function_type)( ::std::size_t ) const; IHistogram_exposer.def( "getBinContent" , getBinContent_function_type( &::IHistogram::getBinContent ) - , ( bp::arg("bin") ) - , "Returns content (accumulated value) of the bin with given index. For 1D histograms bin index is related to x-axis. For 2D histograms bin index is global bin index. @param bin Bin index @return The value accumulated by the bin (integral) \n\n:Parameters:\n - 'bin' - Bin index\n" ); + , ( bp::arg("globalbin") ) + , "Returns content (accumulated value) of the bin with given index. @param globalbin The global bin index @return The value accumulated by the bin (integral) \n\n:Parameters:\n - 'globalbin' - The global bin index\n" ); } { //::IHistogram::getBinContent - typedef double ( ::IHistogram::*getBinContent_function_type)( int,int ) const; + typedef double ( ::IHistogram::*getBinContent_function_type)( ::std::size_t,::std::size_t ) const; IHistogram_exposer.def( "getBinContent" , getBinContent_function_type( &::IHistogram::getBinContent ) , ( bp::arg("binx"), bp::arg("biny") ) - , "Returns content (accumulated value) of the bin of 2D histogram with given axes indices. @param binx X-axis bin index @param biny Y-axis bin index @return The value accumulated by the bin (integral) \n\n:Parameters:\n - 'binx' - X-axis bin index\n - 'biny' - Y-axis bin index\n" ); + , "Returns content (accumulated value) of the bin with given indices (for 2D histograms). @param binx x-axis bin index @param biny y-axis bin index @return The value accumulated by the bin (integral) \n\n:Parameters:\n - 'binx' - x-axis bin index\n - 'biny' - y-axis bin index\n" ); } { //::IHistogram::getBinError - typedef double ( ::IHistogram::*getBinError_function_type)( int ) const; + typedef double ( ::IHistogram::*getBinError_function_type)( ::std::size_t ) const; IHistogram_exposer.def( "getBinError" , getBinError_function_type( &::IHistogram::getBinError ) - , ( bp::arg("bin") ) - , "Returns error of the bin with given index. For 1D histograms bin index is related to x-axis. For 2D histograms bin index is global bin index. " ); + , ( bp::arg("globalbin") ) + , "Returns error of the bin with given index." ); } { //::IHistogram::getBinError - typedef double ( ::IHistogram::*getBinError_function_type)( int,int ) const; + typedef double ( ::IHistogram::*getBinError_function_type)( ::std::size_t,::std::size_t ) const; IHistogram_exposer.def( "getBinError" , getBinError_function_type( &::IHistogram::getBinError ) , ( bp::arg("binx"), bp::arg("biny") ) - , "Returns error of the bin of 2D histogram with given axes indices." ); + , "Returns error of the bin with given indices (for 2D histograms)." ); } { //::IHistogram::getBinNumberOfEntries - typedef int ( ::IHistogram::*getBinNumberOfEntries_function_type)( int ) const; + typedef int ( ::IHistogram::*getBinNumberOfEntries_function_type)( ::std::size_t ) const; IHistogram_exposer.def( "getBinNumberOfEntries" , getBinNumberOfEntries_function_type( &::IHistogram::getBinNumberOfEntries ) - , ( bp::arg("bin") ) - , "Returns number of entries in the bin with given index. For 1D histograms bin index is related to x-axis. For 2D histograms bin index is global bin index. " ); + , ( bp::arg("globalbin") ) + , "Returns number of entries in the bin with given index." ); } { //::IHistogram::getBinNumberOfEntries - typedef int ( ::IHistogram::*getBinNumberOfEntries_function_type)( int,int ) const; + typedef int ( ::IHistogram::*getBinNumberOfEntries_function_type)( ::std::size_t,::std::size_t ) const; IHistogram_exposer.def( "getBinNumberOfEntries" , getBinNumberOfEntries_function_type( &::IHistogram::getBinNumberOfEntries ) , ( bp::arg("binx"), bp::arg("biny") ) - , "Returns number of entries in the bin of 2D histogram with given axes indices." ); + , "Returns number of entries in the bin with given indices (for 2D histograms)." ); } { //::IHistogram::getGlobalBin - typedef int ( ::IHistogram::*getGlobalBin_function_type)( int,int ) const; + typedef ::std::size_t ( ::IHistogram::*getGlobalBin_function_type)( ::std::size_t,::std::size_t ) const; IHistogram_exposer.def( "getGlobalBin" , getGlobalBin_function_type( &::IHistogram::getGlobalBin ) - , ( bp::arg("binx"), bp::arg("biny")=(int)(0) ) - , "Returns global bin index for given axes indices. For 1D histogram the global bin index coinside with axis index. @param binx X-axis bin index @param biny Y-axis bin index @return The global bin index \n\n:Parameters:\n - 'binx' - X-axis bin index\n - 'biny' - Y-axis bin index\n" ); + , ( bp::arg("binx"), bp::arg("biny")=(::std::size_t)(0) ) + , "Returns global bin index for given axes indices. For 1D histogram the global bin index coinside with x-axis index. @param binx x-axis bin index @param biny y-axis bin index (for 2D histograms) @return The global bin index \n\n:Parameters:\n - 'binx' - x-axis bin index\n - 'biny' - y-axis bin index (for 2D histograms)\n" ); } { //::IHistogram::getMaximum @@ -235,12 +235,12 @@ void register_IHistogram_class(){ } { //::IHistogram::getMaximumBinIndex - typedef int ( ::IHistogram::*getMaximumBinIndex_function_type)( ) const; + typedef ::std::size_t ( ::IHistogram::*getMaximumBinIndex_function_type)( ) const; IHistogram_exposer.def( "getMaximumBinIndex" , getMaximumBinIndex_function_type( &::IHistogram::getMaximumBinIndex ) - , "Returns histogram maximum bin global index." ); + , "Returns globalbin index with maximum content." ); } { //::IHistogram::getMinimum @@ -255,12 +255,12 @@ void register_IHistogram_class(){ } { //::IHistogram::getMinimumBinIndex - typedef int ( ::IHistogram::*getMinimumBinIndex_function_type)( ) const; + typedef ::std::size_t ( ::IHistogram::*getMinimumBinIndex_function_type)( ) const; IHistogram_exposer.def( "getMinimumBinIndex" , getMinimumBinIndex_function_type( &::IHistogram::getMinimumBinIndex ) - , "Returns histogram minimum bin global index." ); + , "Returns globalbin index with minimum content." ); } { //::IHistogram::getNbinsX @@ -323,7 +323,7 @@ void register_IHistogram_class(){ "getXaxisIndex" , getXaxisIndex_function_type( &::IHistogram::getXaxisIndex ) , ( bp::arg("globalbin") ) - , "Returns x-axis bin index for given globalbin. For 1D histograms returned value conicide with globalbin value " ); + , "Returns x-axis bin index for given globalbin. For 1D histograms returned value conicide with globalbin value. " ); } { //::IHistogram::getXaxisValue @@ -334,7 +334,7 @@ void register_IHistogram_class(){ "getXaxisValue" , getXaxisValue_function_type( &::IHistogram::getXaxisValue ) , ( bp::arg("globalbin") ) - , "Returns the value on x-axis corresponding to the global bin index. @param binGlobalIndex The global bin index @return The center of axis's corresponding bin \n\n:Parameters:\n - 'binGlobalIndex' - The global bin index\n" ); + , "Returns the value on x-axis corresponding to the global bin index. @param globalbin The global bin index @return The center of corresponding bin of the axis \n\n:Parameters:\n - 'globalbin' - The global bin index\n" ); } { //::IHistogram::getXmax @@ -376,7 +376,7 @@ void register_IHistogram_class(){ "getYaxisIndex" , getYaxisIndex_function_type( &::IHistogram::getYaxisIndex ) , ( bp::arg("globalbin") ) - , "Returns x-axis bin index for given globalbin. For 1D histograms returned value conicide with globalbin value " ); + , "Returns y-axis bin index for given globalbin (for 2D histograms)." ); } { //::IHistogram::getYaxisValue @@ -387,7 +387,7 @@ void register_IHistogram_class(){ "getYaxisValue" , getYaxisValue_function_type( &::IHistogram::getYaxisValue ) , ( bp::arg("globalbin") ) - , "Returns the value on y-axis corresponding to the global bin index (for 2D histograms). @param globalbin The global bin index @return The center of axis's corresponding bin \n\n:Parameters:\n - 'globalbin' - The global bin index\n" ); + , "Returns the value on y-axis corresponding to the global bin index (for 2D histograms). @param globalbin The global bin index @return The center of corresponding bin of the axis \n\n:Parameters:\n - 'globalbin' - The global bin index\n" ); } { //::IHistogram::getYmax @@ -431,6 +431,16 @@ void register_IHistogram_class(){ , ( bp::arg("other") ) , "Returns true if object have same dimensions and shape of axises." ); + } + { //::IHistogram::integral + + typedef double ( ::IHistogram::*integral_function_type)( ) const; + + IHistogram_exposer.def( + "integral" + , integral_function_type( &::IHistogram::integral ) + , "Returns integral of bins content (computed as a sum of all bin content)." ); + } { //::IHistogram::reset @@ -450,7 +460,18 @@ void register_IHistogram_class(){ "scale" , scale_function_type( &::IHistogram::scale ) , ( bp::arg("value") ) - , "Multiply this histogram by a constant." ); + , "Multiply this histogram (every bin content value) by a constant." ); + + } + { //::IHistogram::setBinContent + + typedef void ( ::IHistogram::*setBinContent_function_type)( ::std::size_t,double ) ; + + IHistogram_exposer.def( + "setBinContent" + , setBinContent_function_type( &::IHistogram::setBinContent ) + , ( bp::arg("globalbin"), bp::arg("value") ) + , "Sets content of the bin corresponding to the globalbin number." ); } IHistogram_exposer.staticmethod( "createHistogram" ); diff --git a/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp b/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp index cd70f21f427279f697c47941ff61eff6ffe32454..4cb15e9a33c22f639690105d7213b6abfc7876a7 100644 --- a/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp +++ b/Core/PythonAPI/src/IntensityDataIOFactory.pypp.cpp @@ -40,18 +40,29 @@ void register_IntensityDataIOFactory_class(){ "readHistogram" , readHistogram_function_type( &::IntensityDataIOFactory::readHistogram ) , ( bp::arg("file_name") ) - , bp::return_value_policy< bp::reference_existing_object >() ); + , bp::return_value_policy< bp::manage_new_object >() ); } { //::IntensityDataIOFactory::readIntensityData - typedef ::OutputData< double > * ( *readIntensityData_function_type )( ::std::string const & ); + typedef ::IHistogram * ( *readIntensityData_function_type )( ::std::string const & ); IntensityDataIOFactory_exposer.def( "readIntensityData" , readIntensityData_function_type( &::IntensityDataIOFactory::readIntensityData ) , ( bp::arg("file_name") ) - , bp::return_value_policy< bp::reference_existing_object >() ); + , bp::return_value_policy< bp::manage_new_object >() ); + + } + { //::IntensityDataIOFactory::readOutputData + + typedef ::OutputData< double > * ( *readOutputData_function_type )( ::std::string const & ); + + IntensityDataIOFactory_exposer.def( + "readOutputData" + , readOutputData_function_type( &::IntensityDataIOFactory::readOutputData ) + , ( bp::arg("file_name") ) + , bp::return_value_policy< bp::manage_new_object >() ); } { //::IntensityDataIOFactory::writeHistogram @@ -66,28 +77,30 @@ void register_IntensityDataIOFactory_class(){ } { //::IntensityDataIOFactory::writeIntensityData - typedef void ( *writeIntensityData_function_type )( ::OutputData< double > const &,::std::string const & ); + typedef void ( *writeIntensityData_function_type )( ::IHistogram const &,::std::string const & ); IntensityDataIOFactory_exposer.def( "writeIntensityData" , writeIntensityData_function_type( &::IntensityDataIOFactory::writeIntensityData ) - , ( bp::arg("data"), bp::arg("file_name") ) ); + , ( bp::arg("histogram"), bp::arg("file_name") ) ); } - { //::IntensityDataIOFactory::writeIntensityData + { //::IntensityDataIOFactory::writeOutputData - typedef void ( *writeIntensityData_function_type )( ::IHistogram const &,::std::string const & ); + typedef void ( *writeOutputData_function_type )( ::OutputData< double > const &,::std::string const & ); IntensityDataIOFactory_exposer.def( - "writeIntensityData" - , writeIntensityData_function_type( &::IntensityDataIOFactory::writeIntensityData ) - , ( bp::arg("histogram"), bp::arg("file_name") ) ); + "writeOutputData" + , writeOutputData_function_type( &::IntensityDataIOFactory::writeOutputData ) + , ( bp::arg("data"), bp::arg("file_name") ) ); } IntensityDataIOFactory_exposer.staticmethod( "readHistogram" ); IntensityDataIOFactory_exposer.staticmethod( "readIntensityData" ); + IntensityDataIOFactory_exposer.staticmethod( "readOutputData" ); IntensityDataIOFactory_exposer.staticmethod( "writeHistogram" ); IntensityDataIOFactory_exposer.staticmethod( "writeIntensityData" ); + IntensityDataIOFactory_exposer.staticmethod( "writeOutputData" ); } } diff --git a/Core/StandardSamples/CoreFunctionalTest.cpp b/Core/StandardSamples/CoreFunctionalTest.cpp index 36c65b3e8edb4a719a13076411ffb0e24ea1946b..eeb1454b7c4c09dea85f985e5b5658a4595a2bd8 100644 --- a/Core/StandardSamples/CoreFunctionalTest.cpp +++ b/Core/StandardSamples/CoreFunctionalTest.cpp @@ -93,7 +93,7 @@ void CoreFunctionalTest::saveSimulationResults() const { Utils::FileSystem::CreateDirectory(directory_name_for_failed_tests); boost::scoped_ptr<OutputData<double> > result_data(getIntensityData()); - IntensityDataIOFactory::writeIntensityData(*result_data.get(), + IntensityDataIOFactory::writeOutputData(*result_data.get(), getSimulationResultsFileNameAndPath()); } diff --git a/Core/StandardSamples/FunctionalTestComponentService.cpp b/Core/StandardSamples/FunctionalTestComponentService.cpp index 9c2b58b7d7c2ec4e3833ede89a7fd0914db58397..b47acba0225dc0432e969bd72a8f1590ddeadaaf 100644 --- a/Core/StandardSamples/FunctionalTestComponentService.cpp +++ b/Core/StandardSamples/FunctionalTestComponentService.cpp @@ -80,7 +80,7 @@ OutputData<double> *FunctionalTestComponentService::getReferenceData() const std::string filename = Utils::FileSystem::GetReferenceDataDir() + getReferenceFileName(); try { - result = IntensityDataIOFactory::readIntensityData(filename); + result = IntensityDataIOFactory::readOutputData(filename); } catch(const std::exception &ex) { std::cout << "FunctionalTestComponentService::getReferenceData() -> Exception caught." << ex.what() << std::endl; diff --git a/Core/StandardSamples/PyScriptFunctionalTest.cpp b/Core/StandardSamples/PyScriptFunctionalTest.cpp index cb993c371bfe66be505514600d9aa3335fd781c2..ebc446be08f25cbd369790dbfa6c0606e9c0396e 100644 --- a/Core/StandardSamples/PyScriptFunctionalTest.cpp +++ b/Core/StandardSamples/PyScriptFunctionalTest.cpp @@ -60,7 +60,7 @@ void PyScriptFunctionalTest::runTest() int PyScriptFunctionalTest::analyseResults() { - boost::scoped_ptr<OutputData<double> > P_domain_data(IntensityDataIOFactory::readIntensityData(temp_intensity_data_file_name)); + boost::scoped_ptr<OutputData<double> > P_domain_data(IntensityDataIOFactory::readOutputData(temp_intensity_data_file_name)); boost::scoped_ptr<OutputData<double> > P_reference_data( m_reference_simulation->getDetectorIntensity()); diff --git a/Core/Tools/inc/IHistogram.h b/Core/Tools/inc/IHistogram.h index 98f2009fbaee0dbb3ae6460b1d17ee74f600fe3d..6ad1e3fb3963184a97fddfbca0e1c75dcef5abcc 100644 --- a/Core/Tools/inc/IHistogram.h +++ b/Core/Tools/inc/IHistogram.h @@ -44,7 +44,7 @@ public: IHistogram(const IAxis &axis_x); IHistogram(const IAxis &axis_x, const IAxis &axis_y); - //! Returns number of histogram dimensions (1 or 2). + //! Returns number of histogram dimensions. virtual size_t getRank() const; //! Returns total number of histogram bins. For 2D histograms the result will be the product @@ -76,88 +76,85 @@ public: size_t getNbinsY() const; //! Returns global bin index for given axes indices. For 1D histogram the global bin - //! index coinside with axis index. - //! @param binx X-axis bin index - //! @param biny Y-axis bin index + //! index coinside with x-axis index. + //! @param binx x-axis bin index + //! @param biny y-axis bin index (for 2D histograms) //! @return The global bin index - int getGlobalBin(int binx, int biny = 0) const; + size_t getGlobalBin(size_t binx, size_t biny = 0) const; //! Returns closest global bin index for given axes coordinates. For 1D //! @param x Value on x-axis - //! @param y Value on y-axis + //! @param y Value on y-axis (for 2D histograms) //! @return Closest global bin index - int findGlobalBin(double x, double y) const; + size_t findGlobalBin(double x, double y) const; //! Returns x-axis bin index for given globalbin. For 1D histograms returned value conicide - //! with globalbin value + //! with globalbin value. int getXaxisIndex(size_t globalbin) const; - //! Returns x-axis bin index for given globalbin. For 1D histograms returned value conicide - //! with globalbin value + //! Returns y-axis bin index for given globalbin (for 2D histograms). int getYaxisIndex(size_t globalbin) const; //! Returns the value on x-axis corresponding to the global bin index. - //! @param binGlobalIndex The global bin index - //! @return The center of axis's corresponding bin + //! @param globalbin The global bin index + //! @return The center of corresponding bin of the axis double getXaxisValue(size_t globalbin); //! Returns the value on y-axis corresponding to the global bin index (for 2D histograms). //! @param globalbin The global bin index - //! @return The center of axis's corresponding bin + //! @return The center of corresponding bin of the axis double getYaxisValue(size_t globalbin); //! Returns content (accumulated value) of the bin with given index. - //! For 1D histograms bin index is related to x-axis. - //! For 2D histograms bin index is global bin index. - //! @param bin Bin index + //! @param globalbin The global bin index //! @return The value accumulated by the bin (integral) - double getBinContent(int bin) const; + double getBinContent(size_t globalbin) const; - //! Returns content (accumulated value) of the bin of 2D histogram with given axes indices. - //! @param binx X-axis bin index - //! @param biny Y-axis bin index + //! Returns content (accumulated value) of the bin with given indices (for 2D histograms). + //! @param binx x-axis bin index + //! @param biny y-axis bin index //! @return The value accumulated by the bin (integral) - double getBinContent(int binx, int biny) const; + double getBinContent(size_t binx, size_t biny) const; + + //! Sets content of the bin corresponding to the globalbin number + void setBinContent(size_t globalbin, double value); //! Returns error of the bin with given index. - //! For 1D histograms bin index is related to x-axis. - //! For 2D histograms bin index is global bin index. - double getBinError(int bin) const; + double getBinError(size_t globalbin) const; - //! Returns error of the bin of 2D histogram with given axes indices. - double getBinError(int binx, int biny) const; + //! Returns error of the bin with given indices (for 2D histograms). + double getBinError(size_t binx, size_t biny) const; //! Returns average value in the bin with given index. - //! For 1D histograms bin index is related to x-axis. - //! For 2D histograms bin index is global bin index. - double getBinAverage(int bin) const; + double getBinAverage(size_t globalbin) const; - //! Returns average value in the bin of 2D histogram with given axes indices. - double getBinAverage(int binx, int biny) const; + //! Returns average value of the bin with given indices (for 2D histograms). + double getBinAverage(size_t binx, size_t biny) const; //! Returns number of entries in the bin with given index. - //! For 1D histograms bin index is related to x-axis. - //! For 2D histograms bin index is global bin index. - int getBinNumberOfEntries(int bin) const; + int getBinNumberOfEntries(size_t globalbin) const; - //! Returns number of entries in the bin of 2D histogram with given axes indices. - int getBinNumberOfEntries(int binx, int biny) const; + //! Returns number of entries in the bin with given indices (for 2D histograms). + int getBinNumberOfEntries(size_t binx, size_t biny) const; //! Returns histogram maximum value (maximum of getBinContent() over all bins) double getMaximum() const; - //! Returns histogram maximum bin global index - int getMaximumBinIndex() const; + //! Returns globalbin index with maximum content + size_t getMaximumBinIndex() const; //! Returns histogram minimum value (minimum of getBinContent() over all bins) double getMinimum() const; - //! Returns histogram minimum bin global index - int getMinimumBinIndex() const; + //! Returns globalbin index with minimum content + size_t getMinimumBinIndex() const; - //! Multiply this histogram by a constant + //! Multiply this histogram (every bin content value) by a constant void scale(double value); + //! Returns integral of bins content (computed as a sum of all bin content). + double integral() const; + // double& operator[](size_t index); // const double& operator[](size_t index) const; diff --git a/Core/Tools/inc/IntensityDataIOFactory.h b/Core/Tools/inc/IntensityDataIOFactory.h index deaa6f1b55f1aa51efdad1775873748e5a2971b9..90604005718d770242b9cb134574a92bf62554e1 100644 --- a/Core/Tools/inc/IntensityDataIOFactory.h +++ b/Core/Tools/inc/IntensityDataIOFactory.h @@ -32,10 +32,14 @@ class IHistogram; class BA_CORE_API_ IntensityDataIOFactory { public: - static OutputData<double > *readIntensityData(const std::string& file_name); + static OutputData<double > *readOutputData(const std::string& file_name); + static IHistogram *readHistogram(const std::string& file_name); - static void writeIntensityData(const OutputData<double>& data, + static IHistogram *readIntensityData(const std::string& file_name); + + + static void writeOutputData(const OutputData<double>& data, const std::string& file_name); static void writeHistogram(const IHistogram &histogram, diff --git a/Core/Tools/src/IHistogram.cpp b/Core/Tools/src/IHistogram.cpp index 98c618a0dda0c94fe6b7d774cc54b9af5fc75b70..0a80237db4eef14771c0e97c59009f6fd83f78f7 100644 --- a/Core/Tools/src/IHistogram.cpp +++ b/Core/Tools/src/IHistogram.cpp @@ -92,7 +92,7 @@ size_t IHistogram::getNbinsY() const return getYaxis()->getSize(); } -int IHistogram::getGlobalBin(int binx, int biny) const +size_t IHistogram::getGlobalBin(size_t binx, size_t biny) const { std::vector<int > axes_indices; axes_indices.push_back(binx); @@ -100,7 +100,7 @@ int IHistogram::getGlobalBin(int binx, int biny) const return m_data.toGlobalIndex(axes_indices); } -int IHistogram::findGlobalBin(double x, double y) const +size_t IHistogram::findGlobalBin(double x, double y) const { std::vector<double> coordinates; coordinates.push_back(x); @@ -130,42 +130,47 @@ double IHistogram::getYaxisValue(size_t globalbin) return m_data.getAxisValue(globalbin, 1); } -double IHistogram::getBinContent(int bin) const +double IHistogram::getBinContent(size_t globalbin) const { - return m_data[bin].getContent(); + return m_data[globalbin].getContent(); } -double IHistogram::getBinContent(int binx, int biny) const +double IHistogram::getBinContent(size_t binx, size_t biny) const { return getBinContent(getGlobalBin(binx, biny)); } -double IHistogram::getBinError(int bin) const +void IHistogram::setBinContent(size_t globalbin, double value) { - return m_data[bin].getRMS(); + m_data[globalbin].setContent(value); } -double IHistogram::getBinError(int binx, int biny) const +double IHistogram::getBinError(size_t globalbin) const +{ + return m_data[globalbin].getRMS(); +} + +double IHistogram::getBinError(size_t binx, size_t biny) const { return getBinError(getGlobalBin(binx, biny)); } -double IHistogram::getBinAverage(int bin) const +double IHistogram::getBinAverage(size_t globalbin) const { - return m_data[bin].getAverage(); + return m_data[globalbin].getAverage(); } -double IHistogram::getBinAverage(int binx, int biny) const +double IHistogram::getBinAverage(size_t binx, size_t biny) const { return getBinAverage(getGlobalBin(binx, biny)); } -int IHistogram::getBinNumberOfEntries(int bin) const +int IHistogram::getBinNumberOfEntries(size_t globalbin) const { - return m_data[bin].getNumberOfEntries(); + return m_data[globalbin].getNumberOfEntries(); } -int IHistogram::getBinNumberOfEntries(int binx, int biny) const +int IHistogram::getBinNumberOfEntries(size_t binx, size_t biny) const { return getBinNumberOfEntries(getGlobalBin(binx, biny)); } @@ -177,7 +182,7 @@ double IHistogram::getMaximum() const return it->getContent(); } -int IHistogram::getMaximumBinIndex() const +size_t IHistogram::getMaximumBinIndex() const { OutputData<CumulativeValue>::const_iterator it = std::max_element(m_data.begin(), m_data.end()); @@ -191,7 +196,7 @@ double IHistogram::getMinimum() const return it->getContent(); } -int IHistogram::getMinimumBinIndex() const +size_t IHistogram::getMinimumBinIndex() const { OutputData<CumulativeValue>::const_iterator it = std::min_element(m_data.begin(), m_data.end()); @@ -205,6 +210,15 @@ void IHistogram::scale(double value) } } +double IHistogram::integral() const +{ + double result(0.0); + for(size_t index=0; index<getTotalNumberOfBins(); ++index) { + result += m_data[index].getContent(); + } + return result; +} + PyObject *IHistogram::getArray(DataType dataType) const { boost::scoped_ptr<OutputData<double> > data(createOutputData(dataType)); diff --git a/Core/Tools/src/IntensityDataIOFactory.cpp b/Core/Tools/src/IntensityDataIOFactory.cpp index e5d1b651518369f2e52d7f63064c8c12d3a31598..8fb3ff3fed8870c4c287af46e973d1ea4814ec0a 100644 --- a/Core/Tools/src/IntensityDataIOFactory.cpp +++ b/Core/Tools/src/IntensityDataIOFactory.cpp @@ -28,7 +28,7 @@ /* ************************************************************************* */ // reading output data /* ************************************************************************* */ -OutputData<double > *IntensityDataIOFactory::readIntensityData( +OutputData<double > *IntensityDataIOFactory::readOutputData( const std::string& file_name) { boost::scoped_ptr<OutputDataReader> P_reader(getReader(file_name)); @@ -37,10 +37,15 @@ OutputData<double > *IntensityDataIOFactory::readIntensityData( IHistogram *IntensityDataIOFactory::readHistogram(const std::string &file_name) { - boost::scoped_ptr<OutputData<double> > data(readIntensityData(file_name)); + boost::scoped_ptr<OutputData<double> > data(readOutputData(file_name)); return IHistogram::createHistogram(*data); } +IHistogram *IntensityDataIOFactory::readIntensityData(const std::string &file_name) +{ + return readHistogram(file_name); +} + OutputDataReader* IntensityDataIOFactory::getReader( const std::string& file_name) @@ -66,24 +71,29 @@ OutputDataReader* IntensityDataIOFactory::getReader( /* ************************************************************************* */ // writing output data /* ************************************************************************* */ -void IntensityDataIOFactory::writeIntensityData(const OutputData<double>& data, +void IntensityDataIOFactory::writeOutputData(const OutputData<double>& data, const std::string& file_name) { boost::scoped_ptr<OutputDataWriter> P_writer(getWriter(file_name)); return P_writer->writeOutputData(data); } -void IntensityDataIOFactory::writeIntensityData(const IHistogram &histogram, - const std::string &file_name) -{ - writeHistogram(histogram, file_name); -} +//void IntensityDataIOFactory::writeOutputData(const IHistogram &histogram, +// const std::string &file_name) +//{ +// writeHistogram(histogram, file_name); +//} void IntensityDataIOFactory::writeHistogram(const IHistogram &histogram, const std::string &file_name) { boost::scoped_ptr<OutputData<double> > data(histogram.createOutputData()); - writeIntensityData(*data, file_name); + writeOutputData(*data, file_name); +} + +void IntensityDataIOFactory::writeIntensityData(const IHistogram &histogram, const std::string &file_name) +{ + writeHistogram(histogram, file_name); } OutputDataWriter* IntensityDataIOFactory::getWriter( diff --git a/Core/Tools/src/PyGenTools.cpp b/Core/Tools/src/PyGenTools.cpp index 75f22613003c31a3f9017e26744a382f060858eb..15dedb20048b5bb04d52980f1160ca3835ec9bba 100644 --- a/Core/Tools/src/PyGenTools.cpp +++ b/Core/Tools/src/PyGenTools.cpp @@ -118,7 +118,7 @@ bool PyGenTools::testPyScript(GISASSimulation *simulation) boost::scoped_ptr<const OutputData<double> > P_reference_data( simulation->getDetectorIntensity()); boost::scoped_ptr<const OutputData<double> > P_simulated_data( - IntensityDataIOFactory::readIntensityData("output.int")); + IntensityDataIOFactory::readOutputData("output.int")); if (std::remove("output.int") != 0) { throw RuntimeErrorException("PyGenTools::testPyScript: " "output.int could not be removed from filesystem"); diff --git a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py index e1139cfc7b911305ee59cc9761e9849ab4c7fd21..243129ddc073d660f5ee4898fce99b87dfd4a7aa 100644 --- a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py +++ b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py @@ -6,10 +6,9 @@ We show how to generate "real" data and how to draw fit progress. Please take a note, that performance here is determined by poor performance of matplotlib drawing routines. """ - -import numpy import matplotlib from matplotlib import pyplot as plt +import math from bornagain import * plt.ion() @@ -63,15 +62,15 @@ def create_real_data(): real_data = simulation.getIntensityData() # spoiling simulated data with the noise to produce "real" data - # noise_factor = 0.1 - # for i in range(0, real_data.getAllocatedSize()): - # amplitude = real_data[i] - # sigma = noise_factor*math.sqrt(amplitude) - # noisy_amplitude = GenerateNormalRandom(amplitude, sigma) - # if noisy_amplitude < 0.0: - # noisy_amplitude = 0.0 - # real_data[i] = noisy_amplitude - #IntensityDataIOFactory.writeIntensityData(real_data, 'refdata_fitcylinderprisms.int') + noise_factor = 0.1 + for i in range(0, real_data.getTotalNumberOfBins()): + amplitude = real_data.getBinContent(i) + sigma = noise_factor*math.sqrt(amplitude) + noisy_amplitude = GenerateNormalRandom(amplitude, sigma) + if noisy_amplitude < 0.0: + noisy_amplitude = 0.0 + real_data.setBinContent(i, noisy_amplitude) + IntensityDataIOFactory.writeIntensityData(real_data, 'refdata_fitcylinderprisms.int') @@ -88,7 +87,7 @@ def get_simulation(): class DrawObserver(IFitObserver): """ Draws fit progress every nth iteration. This class has to be attached to FitSuite via attachObserver method. - FitSuite kernel will call DrawObserver's update method every n'th iteration. + FitSuite kernel will call DrawObserver's update() method every n'th iteration. It is up to the user what to do here. """ def __init__(self, draw_every_nth=10): @@ -99,15 +98,16 @@ class DrawObserver(IFitObserver): plt.subplots_adjust(wspace=0.2, hspace=0.2) im = plt.imshow(data.getArray(), norm=matplotlib.colors.LogNorm(min, max), - extent=[-1.0, 1.0, 0, 2.0]) + extent=[data.getXmin()/deg, data.getXmax()/deg, data.getYmin()/deg, data.getYmax()/deg]) plt.colorbar(im) plt.title(title) def update(self, fit_suite): fig.clf() - self.plot(fit_suite.getRealData(), "\"Real\" data", 1) - self.plot(fit_suite.getSimulationData(), "Simulated data", 2) - self.plot(fit_suite.getChiSquaredMap(), "Chi2 map", 3, min=0.001, max=1.0) + real_data = fit_suite.getRealData() + self.plot(real_data, "\"Real\" data", nplot=1, min=1.0, max=real_data.getMaximum()) + self.plot(fit_suite.getSimulationData(), "Simulated data", nplot=2, min=1.0, max=real_data.getMaximum()) + self.plot(fit_suite.getChiSquaredMap(), "Chi2 map", nplot=3, min=0.001, max=1.0) plt.subplot(2, 2, 4) plt.title('Parameters') @@ -128,8 +128,8 @@ def run_fitting(): main function to run fitting """ - # uncomment to regenerate "real" data - #create_real_data() + # uncomment to regenerate file with "real" data + # create_real_data() sample = get_sample() simulation = get_simulation() diff --git a/Fit/FitKernel/inc/FitSuite.h b/Fit/FitKernel/inc/FitSuite.h index 45c15877c982b22931fb500900a658af4f0840fd..12ce29d0e45572c1723228eb5dec0a2c1586f7f2 100644 --- a/Fit/FitKernel/inc/FitSuite.h +++ b/Fit/FitKernel/inc/FitSuite.h @@ -38,6 +38,10 @@ public: void addSimulationAndRealData(const GISASSimulation& simulation, const OutputData<double>& real_data); + //! Assigns pair of (simulation, real data) for fitting. More than one pair can be added. + void addSimulationAndRealData(const GISASSimulation& simulation, + const IHistogram& real_data); + //! Adds fit parameter //! @param name The name of fit parameter //! @param value Parameter's starting value diff --git a/Fit/FitKernel/src/FitSuite.cpp b/Fit/FitKernel/src/FitSuite.cpp index bde2984469896de2746dd8dc4ba8ec835d86a2e5..409a868c077d47fc44b92726b0ad945f45d8c523 100644 --- a/Fit/FitKernel/src/FitSuite.cpp +++ b/Fit/FitKernel/src/FitSuite.cpp @@ -31,6 +31,13 @@ void FitSuite::addSimulationAndRealData(const GISASSimulation &simulation, m_kernel->addSimulationAndRealData(simulation, real_data); } +void FitSuite::addSimulationAndRealData(const GISASSimulation &simulation, + const IHistogram &real_data) +{ + boost::scoped_ptr<OutputData<double> > data(real_data.createOutputData()); + m_kernel->addSimulationAndRealData(simulation, *data); +} + void FitSuite::addFitParameter(const std::string &name, double value, const AttLimits &attlim, double step) { diff --git a/Fit/PythonAPI/src/FitObject.pypp.cpp b/Fit/PythonAPI/src/FitObject.pypp.cpp index 07915f3485942324d3eb019effc49bee6f11941d..5d278ef6120c95b407c67c3cdf00d61ee40cdc71 100644 --- a/Fit/PythonAPI/src/FitObject.pypp.cpp +++ b/Fit/PythonAPI/src/FitObject.pypp.cpp @@ -115,17 +115,6 @@ void register_FitObject_class(){ typedef bp::class_< FitObject_wrapper, bp::bases< IParameterized >, boost::noncopyable > FitObject_exposer_t; FitObject_exposer_t FitObject_exposer = FitObject_exposer_t( "FitObject", "Holds simulation description and real data to run the fit.", bp::init< GISASSimulation const &, OutputData< double > const &, bp::optional< double > >(( bp::arg("simulation"), bp::arg("real_data"), bp::arg("weight")=1 ), "FitObject constructor @param simulaiton The simulation to eun @param real_data The real data @param weight Weight of dataset in chi2 calculations \n\n:Parameters:\n - 'simulaiton' - The simulation to eun\n - 'real_data' - The real data\n - 'weight' - Weight of dataset in chi2 calculations\n") ); bp::scope FitObject_scope( FitObject_exposer ); - { //::FitObject::getChiSquaredMap - - typedef ::OutputData< double > * ( ::FitObject::*getChiSquaredMap_function_type)( ::__gnu_cxx::__normal_iterator< const FitElement*, std::vector< FitElement > >,::__gnu_cxx::__normal_iterator< const FitElement*, std::vector< FitElement > > ) const; - - FitObject_exposer.def( - "getChiSquaredMap" - , getChiSquaredMap_function_type( &::FitObject::getChiSquaredMap ) - , ( bp::arg("first"), bp::arg("last") ) - , bp::return_value_policy< bp::reference_existing_object >() ); - - } { //::FitObject::getRealData typedef ::OutputData< double > const * ( ::FitObject::*getRealData_function_type)( ) const; diff --git a/Fit/PythonAPI/src/FitSuite.pypp.cpp b/Fit/PythonAPI/src/FitSuite.pypp.cpp index a56af35f0d9c50d8bc0deff4675359b059941245..93c00f207b954dd186d1b2033e09706a6b3342d2 100644 --- a/Fit/PythonAPI/src/FitSuite.pypp.cpp +++ b/Fit/PythonAPI/src/FitSuite.pypp.cpp @@ -89,6 +89,17 @@ void register_FitSuite_class(){ , ( bp::arg("simulation"), bp::arg("real_data") ) , "Assigns pair of (simulation, real data) for fitting. More than one pair can be added." ); + } + { //::FitSuite::addSimulationAndRealData + + typedef void ( ::FitSuite::*addSimulationAndRealData_function_type)( ::GISASSimulation const &,::IHistogram const & ) ; + + FitSuite_exposer.def( + "addSimulationAndRealData" + , addSimulationAndRealData_function_type( &::FitSuite::addSimulationAndRealData ) + , ( bp::arg("simulation"), bp::arg("real_data") ) + , "Assigns pair of (simulation, real data) for fitting. More than one pair can be added." ); + } { //::FitSuite::fixAllParameters diff --git a/GUI/coregui/mainwindow/projectdocument.cpp b/GUI/coregui/mainwindow/projectdocument.cpp index aedc6a5068e2e2a3092e6561462d6ace725ac095..854f86d184d5ce358873e345b4cb5b4f00ba41eb 100644 --- a/GUI/coregui/mainwindow/projectdocument.cpp +++ b/GUI/coregui/mainwindow/projectdocument.cpp @@ -357,7 +357,7 @@ void ProjectDocument::saveOutputData() QString filename = getProjectDir() + "/" + dataItem->itemName(); const OutputData<double> *data = dataItem->getOutputData(); if (data) { - IntensityDataIOFactory::writeIntensityData(*data, filename.toStdString()); + IntensityDataIOFactory::writeOutputData(*data, filename.toStdString()); } } } @@ -374,7 +374,7 @@ void ProjectDocument::loadOutputData() QFileInfo info(filename); if (info.exists()) { jobItem->getIntensityDataItem()->setOutputData( - IntensityDataIOFactory::readIntensityData(filename.toStdString())); + IntensityDataIOFactory::readOutputData(filename.toStdString())); } else { jobItem->setStatus(Constants::STATUS_FAILED); QString warning("Error while loading job from file, intensity data file '"); diff --git a/Tests/FunctionalTests/TestCore/CustomRotatedLattice/CustomRotatedLattice.cpp b/Tests/FunctionalTests/TestCore/CustomRotatedLattice/CustomRotatedLattice.cpp index 70528975aacf2fbe04496f88ea06fd33e7e7475e..37ff05ca0c09a300a4086579b11aaa013211af2c 100644 --- a/Tests/FunctionalTests/TestCore/CustomRotatedLattice/CustomRotatedLattice.cpp +++ b/Tests/FunctionalTests/TestCore/CustomRotatedLattice/CustomRotatedLattice.cpp @@ -20,7 +20,7 @@ int main() std::string filename = Utils::FileSystem::GetReferenceDataDir() + "isgisaxs06_reference_variants.int.gz"; OutputData<double> *reference = - IntensityDataIOFactory::readIntensityData(filename); + IntensityDataIOFactory::readOutputData(filename); // running simulation and copying data int nbins = 3; diff --git a/Tests/FunctionalTests/TestCore/PolDWBAMagCylinders2/PolDWBAMagCylinders2.cpp b/Tests/FunctionalTests/TestCore/PolDWBAMagCylinders2/PolDWBAMagCylinders2.cpp index 8903e3e448804fd7e0cfa8d5e72cb291f2d04f37..892bcf8c6104a188adc2799d6d527737817dfd1a 100644 --- a/Tests/FunctionalTests/TestCore/PolDWBAMagCylinders2/PolDWBAMagCylinders2.cpp +++ b/Tests/FunctionalTests/TestCore/PolDWBAMagCylinders2/PolDWBAMagCylinders2.cpp @@ -6,13 +6,13 @@ int main(int argc, char **argv) { - boost::scoped_ptr<OutputData<double> > P_reference00(IntensityDataIOFactory::readIntensityData( + boost::scoped_ptr<OutputData<double> > P_reference00(IntensityDataIOFactory::readOutputData( Utils::FileSystem::GetReferenceDataDir()+ "polmagcylinders2_reference_00.int.gz")); - boost::scoped_ptr<OutputData<double> > P_reference01(IntensityDataIOFactory::readIntensityData( + boost::scoped_ptr<OutputData<double> > P_reference01(IntensityDataIOFactory::readOutputData( Utils::FileSystem::GetReferenceDataDir()+ "polmagcylinders2_reference_01.int.gz")); - boost::scoped_ptr<OutputData<double> > P_reference10(IntensityDataIOFactory::readIntensityData( + boost::scoped_ptr<OutputData<double> > P_reference10(IntensityDataIOFactory::readOutputData( Utils::FileSystem::GetReferenceDataDir()+ "polmagcylinders2_reference_10.int.gz")); - boost::scoped_ptr<OutputData<double> > P_reference11(IntensityDataIOFactory::readIntensityData( + boost::scoped_ptr<OutputData<double> > P_reference11(IntensityDataIOFactory::readOutputData( Utils::FileSystem::GetReferenceDataDir()+ "polmagcylinders2_reference_11.int.gz")); SimulationRegistry sim_registry; diff --git a/Tests/UnitTests/TestCore/Histogram1DTest.h b/Tests/UnitTests/TestCore/Histogram1DTest.h index 2c0019cc5504d591c9634dda4d05dcd335711b04..0a29faf46ff0737ae9449d97ff39ee1830d8125c 100644 --- a/Tests/UnitTests/TestCore/Histogram1DTest.h +++ b/Tests/UnitTests/TestCore/Histogram1DTest.h @@ -209,6 +209,29 @@ TEST_F(Histogram1DTest, GetMaximumGetMinimum) EXPECT_EQ(1, hist.getMaximumBinIndex()); } +TEST_F(Histogram1DTest, Scale) +{ + Histogram1D hist(10, -5.0, 5.0); + + for(size_t i=0; i<hist.getTotalNumberOfBins(); ++i) { + hist.fill(-4.5+i, 1.0); + } + hist.scale(10.0); + for(size_t i=0; i<hist.getTotalNumberOfBins(); ++i) { + EXPECT_EQ(10.0, hist.getBinContent(i)); + } + +} + +TEST_F(Histogram1DTest, Integral) +{ + Histogram1D hist(10, -5.0, 5.0); + + for(size_t i=0; i<hist.getTotalNumberOfBins(); ++i) { + hist.fill(-4.5+i, 1.0); + } + EXPECT_EQ(10.0, hist.integral()); +} #endif diff --git a/dev-tools/python-bindings/settings_core.py b/dev-tools/python-bindings/settings_core.py index e33fdf39aa0b338324ffc20430fd3d2322ff00ea..ea6d74082638954a212ca442ed6400c9d5ff8f21 100644 --- a/dev-tools/python-bindings/settings_core.py +++ b/dev-tools/python-bindings/settings_core.py @@ -375,8 +375,8 @@ def ManualClassTunings(mb): cl = mb.class_("IHistogram") cl.member_function("getArray").call_policies = call_policies.custom_call_policies("") - cl.member_function( "getXaxis" ).call_policies = call_policies.return_internal_reference() - cl.member_function( "getYaxis" ).call_policies = call_policies.return_internal_reference() + cl.member_function("getXaxis").call_policies = call_policies.return_internal_reference() + cl.member_function("getYaxis").call_policies = call_policies.return_internal_reference() # cl = mb.class_("Histogram2D") @@ -385,6 +385,13 @@ def ManualClassTunings(mb): fun.call_policies = call_policies.return_value_policy(call_policies.manage_new_object) + cl = mb.class_("IntensityDataIOFactory") + + cl.member_function("readOutputData").call_policies = call_policies.return_value_policy(call_policies.manage_new_object) + cl.member_function("readHistogram").call_policies = call_policies.return_value_policy(call_policies.manage_new_object) + cl.member_function("readIntensityData").call_policies = call_policies.return_value_policy(call_policies.manage_new_object) + + # excluding specific member functions def ManualExcludeMemberFunctions(mb): # with given name in function name diff --git a/dev-tools/python-bindings/settings_fit.py b/dev-tools/python-bindings/settings_fit.py index 16a9683cbf833806ad4f4b28144ac7f1cc78284b..f112da35005ea9918ff45740d7895aed85ff6767 100644 --- a/dev-tools/python-bindings/settings_fit.py +++ b/dev-tools/python-bindings/settings_fit.py @@ -206,8 +206,10 @@ def ManualClassTunings(mb): cl.member_function("processFitElements").exclude() cl = mb.class_("IChiSquaredModule") cl.member_function("processFitElements").exclude() + cl = mb.class_("FitObject") cl.member_function("prepareFitElements").exclude() + cl.member_function("getChiSquaredMap").exclude() # excluding specific member functions