Skip to content
Snippets Groups Projects
Commit 9f31f951 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Added special detector for IsGISAXS comparison

parent bfd04787
No related branches found
No related tags found
No related merge requests found
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file Algorithms/inc/IsGISAXSDetector.h
//! @brief Defines class IsGISAXSDetector.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2015
//! @authors Scientific Computing Group at MLZ Garching
//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
#ifndef ISGISAXSDETECTOR_H_
#define ISGISAXSDETECTOR_H_
#include "SphericalDetector.h"
//! @class IsGISAXSDetector
//! @ingroup simulation
//! @brief A spherical detector used for validation with IsGISAXS results.
class BA_CORE_API_ IsGISAXSDetector : public SphericalDetector
{
public:
IsGISAXSDetector();
IsGISAXSDetector(const IsGISAXSDetector &other);
IsGISAXSDetector &operator=(const IsGISAXSDetector &other);
virtual IsGISAXSDetector* clone() const;
virtual ~IsGISAXSDetector() {}
protected:
virtual void print(std::ostream &ostr) const;
//! Generates an axis with correct name and default binning for given index
virtual IAxis* createAxis(size_t index, size_t n_bins, double min, double max) const;
};
#endif /* ISGISAXSDETECTOR_H_ */
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file Algorithms/src/IsGISAXSDetector.cpp
//! @brief Implements class IsGISAXSDetector.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2015
//! @authors Scientific Computing Group at MLZ Garching
//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
#include "IsGISAXSDetector.h"
#include "CustomBinAxis.h"
IsGISAXSDetector::IsGISAXSDetector()
{
setName("IsGISAXSDetector");
init_parameters();
}
IsGISAXSDetector::IsGISAXSDetector(const IsGISAXSDetector &other)
: SphericalDetector(other)
{
setName("IsGISAXSDetector");
init_parameters();
}
IsGISAXSDetector &IsGISAXSDetector::operator=(const IsGISAXSDetector &other)
{
if (this != &other) {
IsGISAXSDetector tmp(other);
tmp.swapContent(*this);
}
return *this;
}
IsGISAXSDetector *IsGISAXSDetector::clone() const
{
return new IsGISAXSDetector(*this);
}
void IsGISAXSDetector::print(std::ostream &ostr) const
{
ostr << "IsGISAXSDetector: '" << getName() << "' " << m_parameters;
for (size_t i = 0; i < m_axes.size(); ++i) {
ostr << " IAxis:" << *m_axes[i] << std::endl;
}
}
IAxis *IsGISAXSDetector::createAxis(size_t index, size_t n_bins, double min, double max) const
{
if (max <= min) {
throw LogicErrorException(
"IsGISAXSDetector::createAxis() -> Error! max <= min");
}
if (n_bins == 0) {
throw LogicErrorException(
"IsGISAXSDetector::createAxis() -> Error! Number n_bins can't be zero.");
} return new CustomBinAxis(getAxisName(index), n_bins, min, max);
}
...@@ -51,18 +51,6 @@ SphericalDetector *SphericalDetector::clone() const ...@@ -51,18 +51,6 @@ SphericalDetector *SphericalDetector::clone() const
return new SphericalDetector(*this); return new SphericalDetector(*this);
} }
IPixelMap *SphericalDetector::createPixelMap(size_t index) const
{
const IAxis &phi_axis = getAxis(BornAgain::X_AXIS_INDEX);
const IAxis &alpha_axis = getAxis(BornAgain::Y_AXIS_INDEX);
size_t phi_index = getAxisBinIndex(index, BornAgain::X_AXIS_INDEX);
size_t alpha_index = getAxisBinIndex(index, BornAgain::Y_AXIS_INDEX);
Bin1D alpha_bin = alpha_axis.getBin(alpha_index);
Bin1D phi_bin = phi_axis.getBin(phi_index);
return new AngularPixelMap(alpha_bin, phi_bin);
}
std::string SphericalDetector::addParametersToExternalPool(std::string path, ParameterPool *external_pool, std::string SphericalDetector::addParametersToExternalPool(std::string path, ParameterPool *external_pool,
int copy_number) const int copy_number) const
{ {
...@@ -77,6 +65,18 @@ std::string SphericalDetector::addParametersToExternalPool(std::string path, Par ...@@ -77,6 +65,18 @@ std::string SphericalDetector::addParametersToExternalPool(std::string path, Par
return new_path; return new_path;
} }
IPixelMap *SphericalDetector::createPixelMap(size_t index) const
{
const IAxis &phi_axis = getAxis(BornAgain::X_AXIS_INDEX);
const IAxis &alpha_axis = getAxis(BornAgain::Y_AXIS_INDEX);
size_t phi_index = getAxisBinIndex(index, BornAgain::X_AXIS_INDEX);
size_t alpha_index = getAxisBinIndex(index, BornAgain::Y_AXIS_INDEX);
Bin1D alpha_bin = alpha_axis.getBin(alpha_index);
Bin1D phi_bin = phi_axis.getBin(phi_index);
return new AngularPixelMap(alpha_bin, phi_bin);
}
void SphericalDetector::print(std::ostream &ostr) const void SphericalDetector::print(std::ostream &ostr) const
{ {
ostr << "SphericalDetector: '" << getName() << "' " << m_parameters; ostr << "SphericalDetector: '" << getName() << "' " << m_parameters;
......
// This file has been generated by Py++.
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file Automatically generated boost::python code for BornAgain Python bindings
//! @brief Automatically generated boost::python code for BornAgain Python bindings
//!
//! @homepage http://bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Juelich GmbH 2015
//! @authors Scientific Computing Group at MLZ Garching
//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
#ifndef IsGISAXSDetector_hpp__pyplusplus_wrapper
#define IsGISAXSDetector_hpp__pyplusplus_wrapper
void register_IsGISAXSDetector_class();
#endif//IsGISAXSDetector_hpp__pyplusplus_wrapper
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#include "ISample.h" #include "ISample.h"
#include "ISampleBuilder.h" #include "ISampleBuilder.h"
#include "ISelectionRule.h" #include "ISelectionRule.h"
#include "IsGISAXSDetector.h"
#include "IShape2D.h" #include "IShape2D.h"
#include "ISingleton.h" #include "ISingleton.h"
#include "Lattice.h" #include "Lattice.h"
......
// This file has been generated by Py++.
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file Automatically generated boost::python code for BornAgain Python bindings
//! @brief Automatically generated boost::python code for BornAgain Python bindings
//!
//! @homepage http://bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Juelich GmbH 2015
//! @authors Scientific Computing Group at MLZ Garching
//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
#include "Macros.h"
GCC_DIAG_OFF(unused-parameter)
GCC_DIAG_OFF(missing-field-initializers)
#include "boost/python.hpp"
GCC_DIAG_ON(unused-parameter)
GCC_DIAG_ON(missing-field-initializers)
#include "__call_policies.pypp.hpp"
#include "__convenience.pypp.hpp"
#include "PythonCoreList.h"
#include "IsGISAXSDetector.pypp.h"
namespace bp = boost::python;
struct IsGISAXSDetector_wrapper : IsGISAXSDetector, bp::wrapper< IsGISAXSDetector > {
IsGISAXSDetector_wrapper( )
: IsGISAXSDetector( )
, bp::wrapper< IsGISAXSDetector >(){
// null constructor
m_pyobj = 0;
}
IsGISAXSDetector_wrapper(::IsGISAXSDetector const & other )
: IsGISAXSDetector( boost::ref(other) )
, bp::wrapper< IsGISAXSDetector >(){
// copy constructor
m_pyobj = 0;
}
virtual ::IsGISAXSDetector * clone( ) const {
if( bp::override func_clone = this->get_override( "clone" ) )
return func_clone( );
else{
return this->IsGISAXSDetector::clone( );
}
}
::IsGISAXSDetector * default_clone( ) const {
return IsGISAXSDetector::clone( );
}
virtual bool areParametersChanged( ) {
if( bp::override func_areParametersChanged = this->get_override( "areParametersChanged" ) )
return func_areParametersChanged( );
else{
return this->IParameterized::areParametersChanged( );
}
}
bool default_areParametersChanged( ) {
return IParameterized::areParametersChanged( );
}
virtual void clearParameterPool( ) {
if( bp::override func_clearParameterPool = this->get_override( "clearParameterPool" ) )
func_clearParameterPool( );
else{
this->IParameterized::clearParameterPool( );
}
}
void default_clearParameterPool( ) {
IParameterized::clearParameterPool( );
}
virtual ::ParameterPool * createParameterTree( ) const {
if( bp::override func_createParameterTree = this->get_override( "createParameterTree" ) )
return func_createParameterTree( );
else{
return this->IParameterized::createParameterTree( );
}
}
::ParameterPool * default_createParameterTree( ) const {
return IParameterized::createParameterTree( );
}
virtual void printParameters( ) const {
if( bp::override func_printParameters = this->get_override( "printParameters" ) )
func_printParameters( );
else{
this->IParameterized::printParameters( );
}
}
void default_printParameters( ) const {
IParameterized::printParameters( );
}
virtual void registerParameter( ::std::string const & name, double * parpointer, ::AttLimits const & limits=AttLimits::limitless( ) ) {
namespace bpl = boost::python;
if( bpl::override func_registerParameter = this->get_override( "registerParameter" ) ){
bpl::object py_result = bpl::call<bpl::object>( func_registerParameter.ptr(), name, parpointer, limits );
}
else{
IParameterized::registerParameter( name, parpointer, boost::ref(limits) );
}
}
static void default_registerParameter( ::IParameterized & inst, ::std::string const & name, long unsigned int parpointer, ::AttLimits const & limits=AttLimits::limitless( ) ){
if( dynamic_cast< IsGISAXSDetector_wrapper * >( boost::addressof( inst ) ) ){
inst.::IParameterized::registerParameter(name, reinterpret_cast< double * >( parpointer ), limits);
}
else{
inst.registerParameter(name, reinterpret_cast< double * >( parpointer ), limits);
}
}
virtual bool setParameterValue( ::std::string const & name, double value ) {
if( bp::override func_setParameterValue = this->get_override( "setParameterValue" ) )
return func_setParameterValue( name, value );
else{
return this->IParameterized::setParameterValue( name, value );
}
}
bool default_setParameterValue( ::std::string const & name, double value ) {
return IParameterized::setParameterValue( name, value );
}
virtual void setParametersAreChanged( ) {
if( bp::override func_setParametersAreChanged = this->get_override( "setParametersAreChanged" ) )
func_setParametersAreChanged( );
else{
this->IParameterized::setParametersAreChanged( );
}
}
void default_setParametersAreChanged( ) {
IParameterized::setParametersAreChanged( );
}
PyObject* m_pyobj;
};
void register_IsGISAXSDetector_class(){
{ //::IsGISAXSDetector
typedef bp::class_< IsGISAXSDetector_wrapper, bp::bases< SphericalDetector >, std::auto_ptr< IsGISAXSDetector_wrapper > > IsGISAXSDetector_exposer_t;
IsGISAXSDetector_exposer_t IsGISAXSDetector_exposer = IsGISAXSDetector_exposer_t( "IsGISAXSDetector", "A spherical detector used for validation with IsGISAXS results.", bp::init< >() );
bp::scope IsGISAXSDetector_scope( IsGISAXSDetector_exposer );
IsGISAXSDetector_exposer.def( bp::init< IsGISAXSDetector const & >(( bp::arg("other") )) );
{ //::IsGISAXSDetector::clone
typedef ::IsGISAXSDetector * ( ::IsGISAXSDetector::*clone_function_type)( ) const;
typedef ::IsGISAXSDetector * ( IsGISAXSDetector_wrapper::*default_clone_function_type)( ) const;
IsGISAXSDetector_exposer.def(
"clone"
, clone_function_type(&::IsGISAXSDetector::clone)
, default_clone_function_type(&IsGISAXSDetector_wrapper::default_clone)
, bp::return_value_policy< bp::manage_new_object >() );
}
{ //::IsGISAXSDetector::operator=
typedef ::IsGISAXSDetector & ( ::IsGISAXSDetector::*assign_function_type)( ::IsGISAXSDetector const & ) ;
IsGISAXSDetector_exposer.def(
"assign"
, assign_function_type( &::IsGISAXSDetector::operator= )
, ( bp::arg("other") )
, bp::return_self< >() );
}
{ //::IParameterized::areParametersChanged
typedef bool ( ::IParameterized::*areParametersChanged_function_type)( ) ;
typedef bool ( IsGISAXSDetector_wrapper::*default_areParametersChanged_function_type)( ) ;
IsGISAXSDetector_exposer.def(
"areParametersChanged"
, areParametersChanged_function_type(&::IParameterized::areParametersChanged)
, default_areParametersChanged_function_type(&IsGISAXSDetector_wrapper::default_areParametersChanged) );
}
{ //::IParameterized::clearParameterPool
typedef void ( ::IParameterized::*clearParameterPool_function_type)( ) ;
typedef void ( IsGISAXSDetector_wrapper::*default_clearParameterPool_function_type)( ) ;
IsGISAXSDetector_exposer.def(
"clearParameterPool"
, clearParameterPool_function_type(&::IParameterized::clearParameterPool)
, default_clearParameterPool_function_type(&IsGISAXSDetector_wrapper::default_clearParameterPool) );
}
{ //::IParameterized::createParameterTree
typedef ::ParameterPool * ( ::IParameterized::*createParameterTree_function_type)( ) const;
typedef ::ParameterPool * ( IsGISAXSDetector_wrapper::*default_createParameterTree_function_type)( ) const;
IsGISAXSDetector_exposer.def(
"createParameterTree"
, createParameterTree_function_type(&::IParameterized::createParameterTree)
, default_createParameterTree_function_type(&IsGISAXSDetector_wrapper::default_createParameterTree)
, bp::return_value_policy< bp::manage_new_object >() );
}
{ //::IParameterized::printParameters
typedef void ( ::IParameterized::*printParameters_function_type)( ) const;
typedef void ( IsGISAXSDetector_wrapper::*default_printParameters_function_type)( ) const;
IsGISAXSDetector_exposer.def(
"printParameters"
, printParameters_function_type(&::IParameterized::printParameters)
, default_printParameters_function_type(&IsGISAXSDetector_wrapper::default_printParameters) );
}
{ //::IParameterized::registerParameter
typedef void ( *default_registerParameter_function_type )( ::IParameterized &,::std::string const &,long unsigned int,::AttLimits const & );
IsGISAXSDetector_exposer.def(
"registerParameter"
, default_registerParameter_function_type( &IsGISAXSDetector_wrapper::default_registerParameter )
, ( bp::arg("inst"), bp::arg("name"), bp::arg("parpointer"), bp::arg("limits")=AttLimits::limitless( ) )
, "main method to register data address in the pool." );
}
{ //::IParameterized::setParameterValue
typedef bool ( ::IParameterized::*setParameterValue_function_type)( ::std::string const &,double ) ;
typedef bool ( IsGISAXSDetector_wrapper::*default_setParameterValue_function_type)( ::std::string const &,double ) ;
IsGISAXSDetector_exposer.def(
"setParameterValue"
, setParameterValue_function_type(&::IParameterized::setParameterValue)
, default_setParameterValue_function_type(&IsGISAXSDetector_wrapper::default_setParameterValue)
, ( bp::arg("name"), bp::arg("value") ) );
}
{ //::IParameterized::setParametersAreChanged
typedef void ( ::IParameterized::*setParametersAreChanged_function_type)( ) ;
typedef void ( IsGISAXSDetector_wrapper::*default_setParametersAreChanged_function_type)( ) ;
IsGISAXSDetector_exposer.def(
"setParametersAreChanged"
, setParametersAreChanged_function_type(&::IParameterized::setParametersAreChanged)
, default_setParametersAreChanged_function_type(&IsGISAXSDetector_wrapper::default_setParametersAreChanged) );
}
}
}
...@@ -78,6 +78,7 @@ GCC_DIAG_ON(missing-field-initializers) ...@@ -78,6 +78,7 @@ GCC_DIAG_ON(missing-field-initializers)
#include "Bin1DCVector.pypp.h" #include "Bin1DCVector.pypp.h"
#include "FormFactorSphereGaussianRadius.pypp.h" #include "FormFactorSphereGaussianRadius.pypp.h"
#include "ParameterPool.pypp.h" #include "ParameterPool.pypp.h"
#include "IsGISAXSDetector.pypp.h"
#include "FormFactorPrism3.pypp.h" #include "FormFactorPrism3.pypp.h"
#include "IMaterial.pypp.h" #include "IMaterial.pypp.h"
#include "FTDistribution1DVoigt.pypp.h" #include "FTDistribution1DVoigt.pypp.h"
...@@ -280,6 +281,8 @@ BOOST_PYTHON_MODULE(libBornAgainCore){ ...@@ -280,6 +281,8 @@ BOOST_PYTHON_MODULE(libBornAgainCore){
register_InterferenceFunction2DParaCrystal_class(); register_InterferenceFunction2DParaCrystal_class();
register_InterferenceFunctionNone_class(); register_InterferenceFunctionNone_class();
register_InterferenceFunctionRadialParaCrystal_class(); register_InterferenceFunctionRadialParaCrystal_class();
register_SphericalDetector_class();
register_IsGISAXSDetector_class();
register_Lattice_class(); register_Lattice_class();
register_Lattice1DIFParameters_class(); register_Lattice1DIFParameters_class();
register_Lattice2DIFParameters_class(); register_Lattice2DIFParameters_class();
...@@ -307,7 +310,6 @@ BOOST_PYTHON_MODULE(libBornAgainCore){ ...@@ -307,7 +310,6 @@ BOOST_PYTHON_MODULE(libBornAgainCore){
register_SimpleSelectionRule_class(); register_SimpleSelectionRule_class();
register_SimulationParameters_class(); register_SimulationParameters_class();
register_SpecularSimulation_class(); register_SpecularSimulation_class();
register_SphericalDetector_class();
register_ThreadInfo_class(); register_ThreadInfo_class();
register_WavevectorInfo_class(); register_WavevectorInfo_class();
register_global_variables(); register_global_variables();
......
...@@ -130,16 +130,17 @@ include_classes = [ ...@@ -130,16 +130,17 @@ include_classes = [
"Histogram1D", "Histogram1D",
"Histogram2D", "Histogram2D",
"IMaterial", "IMaterial",
"IntensityDataFunctions",
"IObserver", "IObserver",
"IObservable", "IObservable",
"IParameterized", "IParameterized",
"IParticle", "IParticle",
"IResolutionFunction2D", "IResolutionFunction2D",
"IntensityDataFunctions",
"IRotation", "IRotation",
"ISample", "ISample",
"ISampleBuilder", "ISampleBuilder",
"ISelectionRule", "ISelectionRule",
"IsGISAXSDetector",
"Instrument", "Instrument",
"InterferenceFunction1DLattice", "InterferenceFunction1DLattice",
"InterferenceFunctionRadialParaCrystal", "InterferenceFunctionRadialParaCrystal",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment