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

added setBeamPolarization and setDetectorPolarization to both Simulation and Instrument

parent 24fdc6b7
No related branches found
No related tags found
No related merge requests found
......@@ -28,9 +28,11 @@ class BA_CORE_API_ Instrument : public IParameterized
{
public:
Instrument();
Instrument(const Instrument& other);
Instrument(const Instrument &other);
~Instrument() {}
~Instrument()
{
}
//! Returns the beam data
Beam getBeam() const;
......@@ -42,29 +44,44 @@ public:
void setBeamParameters(double wavelength, double alpha_i, double phi_i);
//! Sets the beam's intensity
void setBeamIntensity(double intensity) { m_beam.setIntensity(intensity); }
void setBeamIntensity(double intensity)
{
m_beam.setIntensity(intensity);
}
//! Sets the beam's polarization according to the given Bloch vector
void setBeamPolarization(const kvector_t &bloch_vector)
{
m_beam.setPolarization(bloch_vector);
}
//! Returns the beam's intensity
double getIntensity() const { return m_beam.getIntensity(); }
double getIntensity() const
{
return m_beam.getIntensity();
}
//! Returns the detector data
Detector getDetector() const;
//! Returns a detector axis
const IAxis& getDetectorAxis(size_t index) const;
const IAxis &getDetectorAxis(size_t index) const;
//! Returns the detector's dimension
size_t getDetectorDimension() const { return m_detector.getDimension(); }
size_t getDetectorDimension() const
{
return m_detector.getDimension();
}
//! Sets detector parameters using axes of output data
void matchDetectorParameters(const OutputData<double >& output_data);
void matchDetectorParameters(const OutputData<double> &output_data);
//! Sets detector parameters using angle ranges
void setDetectorParameters(size_t n_phi, double phi_f_min, double phi_f_max,
size_t n_alpha, double alpha_f_min, double alpha_f_max, bool isgisaxs_style=false);
void setDetectorParameters(size_t n_phi, double phi_f_min, double phi_f_max, size_t n_alpha,
double alpha_f_min, double alpha_f_max, bool isgisaxs_style = false);
//! Sets detector parameters using parameter object
void setDetectorParameters(const DetectorParameters& params);
void setDetectorParameters(const DetectorParameters &params);
//! Sets detector parameters using axes
void setDetectorAxes(const IAxis &axis0, const IAxis &axis1);
......@@ -73,29 +90,34 @@ public:
void setDetectorResolutionFunction(IResolutionFunction2D *p_resolution_function);
void setDetectorResolutionFunction(const IResolutionFunction2D &p_resolution_function);
//! Sets the detector's polarization with the given Bloch vector
void setDetectorPolarization(const kvector_t& bloch_vector) {
m_detector.setPolarization(bloch_vector);
}
#ifndef GCCXML_SKIP_THIS
//! apply the detector resolution to the given intensity map
void applyDetectorResolution(OutputData<double> *p_intensity_map,
OutputData<Eigen::Matrix2d> *p_matrix_intensity=0) const;
OutputData<Eigen::Matrix2d> *p_matrix_intensity = 0) const;
#endif
//! Adds parameters from local pool to external pool and call recursion over direct children
virtual std::string addParametersToExternalPool(std::string path, ParameterPool *external_pool, int copy_number=-1) const;
virtual std::string addParametersToExternalPool(std::string path, ParameterPool *external_pool,
int copy_number = -1) const;
#ifndef GCCXML_SKIP_THIS
//! normalize a detector image
void normalize(OutputData<double> *p_intensity,
OutputData<Eigen::Matrix2d> *p_polarized_intensity = 0) const;
OutputData<Eigen::Matrix2d> *p_polarized_intensity = 0) const;
#endif
protected:
virtual void print(std::ostream& ostr) const;
virtual void print(std::ostream &ostr) const;
//! Registers some class members for later access via parameter pool
virtual void init_parameters();
Detector m_detector;
Beam m_beam;
};
inline Beam Instrument::getBeam() const
......@@ -118,7 +140,7 @@ inline Detector Instrument::getDetector() const
return m_detector;
}
inline const IAxis& Instrument::getDetectorAxis(size_t index) const
inline const IAxis &Instrument::getDetectorAxis(size_t index) const
{
return m_detector.getAxis(index);
}
......
......@@ -87,6 +87,9 @@ public:
//! Sets beam intensity from here (forwarded to Instrument)
void setBeamIntensity(double intensity);
//! Sets the beam polarization according to the given Bloch vector
void setBeamPolarization(const kvector_t& bloch_vector);
//! Sets detector parameters using axes of output data
void setDetectorParameters(const OutputData<double> &output_data);
......@@ -108,6 +111,9 @@ public:
//! Removes detector resolution function
void removeDetectorResolutionFunction();
//! Sets the detector's polarization with the given Bloch vector
void setDetectorPolarization(const kvector_t& bloch_vector);
//! Sets simulation parameters
void setSimulationParameters(const SimulationParameters& sim_params)
{ m_sim_params = sim_params; }
......
......@@ -221,6 +221,11 @@ void Simulation::setBeamIntensity(double intensity)
m_instrument.setBeamIntensity(intensity);
}
void Simulation::setBeamPolarization(const kvector_t &bloch_vector)
{
m_instrument.setBeamPolarization(bloch_vector);
}
std::string Simulation::addParametersToExternalPool(
std::string path, ParameterPool* external_pool, int copy_number) const
{
......@@ -325,6 +330,11 @@ void Simulation::removeDetectorResolutionFunction()
m_instrument.setDetectorResolutionFunction(0);
}
void Simulation::setDetectorPolarization(const kvector_t &bloch_vector)
{
m_instrument.setDetectorPolarization(bloch_vector);
}
void Simulation::addToIntensityMap(DWBASimulation* p_dwba_simulation)
{
m_intensity_map += p_dwba_simulation->getDWBAIntensity();
......
......@@ -230,6 +230,16 @@ void register_Instrument_class(){
, setBeamParameters_function_type( &::Instrument::setBeamParameters )
, ( bp::arg("wavelength"), bp::arg("alpha_i"), bp::arg("phi_i") ) );
}
{ //::Instrument::setBeamPolarization
typedef void ( ::Instrument::*setBeamPolarization_function_type)( ::kvector_t const & ) ;
Instrument_exposer.def(
"setBeamPolarization"
, setBeamPolarization_function_type( &::Instrument::setBeamPolarization )
, ( bp::arg("bloch_vector") ) );
}
{ //::Instrument::setDetectorAxes
......@@ -260,6 +270,16 @@ void register_Instrument_class(){
, setDetectorParameters_function_type( &::Instrument::setDetectorParameters )
, ( bp::arg("params") ) );
}
{ //::Instrument::setDetectorPolarization
typedef void ( ::Instrument::*setDetectorPolarization_function_type)( ::kvector_t const & ) ;
Instrument_exposer.def(
"setDetectorPolarization"
, setDetectorPolarization_function_type( &::Instrument::setDetectorPolarization )
, ( bp::arg("bloch_vector") ) );
}
{ //::Instrument::setDetectorResolutionFunction
......
......@@ -328,6 +328,16 @@ void register_Simulation_class(){
, setBeamParameters_function_type( &::Simulation::setBeamParameters )
, ( bp::arg("wavelength"), bp::arg("alpha_i"), bp::arg("phi_i") ) );
}
{ //::Simulation::setBeamPolarization
typedef void ( ::Simulation::*setBeamPolarization_function_type)( ::kvector_t const & ) ;
Simulation_exposer.def(
"setBeamPolarization"
, setBeamPolarization_function_type( &::Simulation::setBeamPolarization )
, ( bp::arg("bloch_vector") ) );
}
{ //::Simulation::setDetectorParameters
......@@ -358,6 +368,16 @@ void register_Simulation_class(){
, setDetectorParameters_function_type( &::Simulation::setDetectorParameters )
, ( bp::arg("params") ) );
}
{ //::Simulation::setDetectorPolarization
typedef void ( ::Simulation::*setDetectorPolarization_function_type)( ::kvector_t const & ) ;
Simulation_exposer.def(
"setDetectorPolarization"
, setDetectorPolarization_function_type( &::Simulation::setDetectorPolarization )
, ( bp::arg("bloch_vector") ) );
}
{ //::Simulation::setDetectorResolutionFunction
......
......@@ -9,11 +9,6 @@ int main(int argc, char **argv)
{
if(argc == 2) Utils::FileSystem::SetReferenceDataDir(argv[1]);
SimulationRegistry sim_registry;
Simulation* simulation = sim_registry.createSimulation("polmagcylinders2");
simulation->runSimulation();
simulation->normalize();
boost::scoped_ptr<OutputData<double> > reference00(IntensityDataIOFactory::readIntensityData(
Utils::FileSystem::GetReferenceDataDir()+ "polmagcylinders2_reference_00.int.gz"));
boost::scoped_ptr<OutputData<double> > reference01(IntensityDataIOFactory::readIntensityData(
......@@ -23,10 +18,34 @@ int main(int argc, char **argv)
boost::scoped_ptr<OutputData<double> > reference11(IntensityDataIOFactory::readIntensityData(
Utils::FileSystem::GetReferenceDataDir()+ "polmagcylinders2_reference_11.int.gz"));
boost::scoped_ptr<OutputData<double> > data00(simulation->getPolarizedIntensityData(0,0));
boost::scoped_ptr<OutputData<double> > data01(simulation->getPolarizedIntensityData(0,1));
boost::scoped_ptr<OutputData<double> > data10(simulation->getPolarizedIntensityData(1,0));
boost::scoped_ptr<OutputData<double> > data11(simulation->getPolarizedIntensityData(1,1));
SimulationRegistry sim_registry;
Simulation* simulation = sim_registry.createSimulation("polmagcylinders2");
kvector_t zplus(0.0, 0.0, 1.0);
kvector_t zmin(0.0, 0.0, -1.0);
simulation->setBeamPolarization(zplus);
simulation->setDetectorPolarization(zplus);
simulation->runSimulation();
simulation->normalize();
boost::scoped_ptr<OutputData<double> > data00(simulation->getIntensityData());
simulation->setBeamPolarization(zplus);
simulation->setDetectorPolarization(zmin);
simulation->runSimulation();
simulation->normalize();
boost::scoped_ptr<OutputData<double> > data01(simulation->getIntensityData());
simulation->setBeamPolarization(zmin);
simulation->setDetectorPolarization(zplus);
simulation->runSimulation();
simulation->normalize();
boost::scoped_ptr<OutputData<double> > data10(simulation->getIntensityData());
simulation->setBeamPolarization(zmin);
simulation->setDetectorPolarization(zmin);
simulation->runSimulation();
simulation->normalize();
boost::scoped_ptr<OutputData<double> > data11(simulation->getIntensityData());
const double threshold(2e-10);
double diff(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment