diff --git a/Base/Axis/Frame.cpp b/Base/Axis/Frame.cpp index db0d75253d3050813b928d6ce3e18622f93ec507..7dfe30e3b0bc7c4b7c47ad5de98256524d1d74c9 100644 --- a/Base/Axis/Frame.cpp +++ b/Base/Axis/Frame.cpp @@ -23,6 +23,18 @@ Frame::Frame(std::vector<const Scale*>&& axes) { } +Frame::Frame(const Scale*&& ax0) + : m_axes(std::vector<const Scale*>{std::move(ax0)}) + , m_size(FrameUtil::product_size(m_axes.reference())) +{ +} + +Frame::Frame(const Scale*&& ax0, const Scale*&& ax1) + : m_axes(std::vector<const Scale*>{std::move(ax0), std::move(ax1)}) + , m_size(FrameUtil::product_size(m_axes.reference())) +{ +} + Frame* Frame::clone() const { return new Frame(m_axes.cloned_vector()); @@ -109,6 +121,11 @@ bool Frame::operator==(const Frame& o) const return true; } +std::vector<const Scale*> Frame::clonedAxes() const +{ + return m_axes.cloned_vector(); +} + bool Frame::hasSameSizes(const Frame& o) const { if (rank() != o.rank()) diff --git a/Base/Axis/Frame.h b/Base/Axis/Frame.h index d79ee1b912ff060b19f54ab3c60a057904e10841..8bf1554d06f6277ef8aadffcefbee2f2c2da5632 100644 --- a/Base/Axis/Frame.h +++ b/Base/Axis/Frame.h @@ -28,6 +28,8 @@ class Frame : public ICloneable { public: //! Constructor that takes ownership of supplied axes. Frame(std::vector<const Scale*>&& axes); + Frame(const Scale*&& ax0); + Frame(const Scale*&& ax0, const Scale*&& ax1); virtual ~Frame(); @@ -64,7 +66,6 @@ public: //! @return Corresponding bin index for selected axis size_t projectedIndex(size_t i_flat, size_t k_axis) const; - //! Returns global index for specified indices of axes //! @param axes_indices Vector of axes indices for all specified axes in this dataset //! @return Corresponding global index @@ -76,6 +77,10 @@ public: //! Returns true if both Frame%s have same rank, and all axes are equal. bool operator==(const Frame&) const; +#ifndef SWIG + std::vector<const Scale*> clonedAxes() const; +#endif // SWIG + protected: OwningVector<const Scale> m_axes; diff --git a/Base/Pixel/RectangularPixel.cpp b/Base/Pixel/RectangularPixel.cpp index 339e0157655b9800dcdd39bedb57580bc14828d5..a98bd9f2891d6907ecf6c2e7df5cd99a3a3d7d4f 100644 --- a/Base/Pixel/RectangularPixel.cpp +++ b/Base/Pixel/RectangularPixel.cpp @@ -83,5 +83,5 @@ Scale* RectangularPixel::createAxis(size_t n) const const double alpha_f_min = (pi / 2) - R3Util::theta(k00); const double alpha_f_max = (pi / 2) - R3Util::theta(k01); - return newEquiDivision("alpha_f", alpha_f_min, alpha_f_max, n); + return newEquiDivision("alpha_f (rad)", alpha_f_min, alpha_f_max, n); } diff --git a/Base/Util/FileSystemUtil.cpp b/Base/Util/FileSystemUtil.cpp index 307595780ac352cd2355fcd1df0aaf4fd70b2c6b..0941f856d6236030256f3e4063e36a4c2daf02ad 100644 --- a/Base/Util/FileSystemUtil.cpp +++ b/Base/Util/FileSystemUtil.cpp @@ -106,8 +106,8 @@ std::string Base::Path::stem_ext(const std::string& path) std::wstring Base::Path::convert_utf8_to_utf16(const std::string& str) { - std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; - return converter.from_bytes(str); + std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> frame; + return frame.from_bytes(str); } bool Base::Path::IsFileExists(const std::string& path) diff --git a/Base/Util/StringUtil.cpp b/Base/Util/StringUtil.cpp index 36a48437c9a26255d103e512c5a68e5e4a2fae5e..01e741d7c8a43d071d84007e5a34baa42a88e5b3 100644 --- a/Base/Util/StringUtil.cpp +++ b/Base/Util/StringUtil.cpp @@ -17,7 +17,6 @@ #include <boost/algorithm/string.hpp> #include <cerrno> #include <charconv> -#include <regex> #include <string> //! Returns string right-padded with blanks. diff --git a/Device/Coord/CoordSystem1D.cpp b/Device/Coord/CoordSystem1D.cpp deleted file mode 100644 index 2f7a69fa2808d8a01e9f75728b4af3d88355c9b8..0000000000000000000000000000000000000000 --- a/Device/Coord/CoordSystem1D.cpp +++ /dev/null @@ -1,231 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Coord/CoordSystem1D.cpp -//! @brief Implements CoordSystem1D class and derived classes. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Device/Coord/CoordSystem1D.h" -#include "Base/Axis/MakeScale.h" -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Base/Util/Assert.h" -#include <cmath> -#include <numbers> -#include <stdexcept> - -using std::numbers::pi; - -namespace { - -double getQ(double wavelength, double angle) -{ - return 4.0 * pi * std::sin(angle) / wavelength; -} - -double getInvQ(double wavelength, double q) -{ - double sin_angle = q * wavelength / (4.0 * pi); - return std::asin(sin_angle); -} - -double backTransform(double value, Coords coords, double wavelength) -{ - switch (coords) { - case Coords::RADIANS: - return value; - case Coords::DEGREES: - return Units::deg2rad(value); - case Coords::QSPACE: - return getInvQ(wavelength, value); - default: - ASSERT(false); - } -} - -Scale* createAxisFrom(const Scale& axis, Coords coords, const std::string& name, double wavelength) -{ - std::vector<double> ret; - ret.reserve(axis.size()); - for (const double value : axis.binCenters()) - ret.emplace_back(backTransform(value, coords, wavelength)); - return newListScan(name, ret); -} - -} // namespace - - -// ************************************************************************************************ -// class CoordSystem1D -// ************************************************************************************************ - -CoordSystem1D::CoordSystem1D(const Scale* axis) - : ICoordSystem({axis}) -{ -} - -double CoordSystem1D::calculateMin(size_t i_axis, Coords units) const -{ - ASSERT(i_axis == 0); - units = substituteDefaultUnits(units); - if (units == Coords::NBINS) - return 0.0; - auto translator = getTraslatorTo(units); - return translator(m_axes[0]->binCenter(0)); -} - -double CoordSystem1D::calculateMax(size_t i_axis, Coords units) const -{ - ASSERT(i_axis == 0); - units = substituteDefaultUnits(units); - if (units == Coords::NBINS) - return static_cast<double>(m_axes[0]->size()); - auto translator = getTraslatorTo(units); - return translator(m_axes[0]->binCenter(m_axes[0]->size() - 1)); -} - -Scale* CoordSystem1D::convertedAxis(size_t i_axis, Coords units) const -{ - ASSERT(i_axis == 0); - units = substituteDefaultUnits(units); - if (units == Coords::NBINS) - return newEquiDivision(nameOfAxis(0, units), m_axes[0]->size(), calculateMin(0, units), - calculateMax(0, units)); - - std::function<double(double)> translator = getTraslatorTo(units); - auto coords = m_axes[0]->binCenters(); - for (size_t i = 0, size = coords.size(); i < size; ++i) - coords[i] = translator(coords[i]); - return newListScan(nameOfAxis(0, units), coords); -} - - -// ************************************************************************************************ -// class AngularReflectometryCoords -// ************************************************************************************************ - -AngularReflectometryCoords::AngularReflectometryCoords(double wavelength, const Scale& axis, - Coords axis_units) - : CoordSystem1D(createAxisFrom(axis, axis_units, nameOfAxis0(axis_units), wavelength)) - , m_wavelength(wavelength) -{ - if (m_axes[0]->min() < 0 || m_axes[0]->max() > (pi / 2)) - throw std::runtime_error("Error in CoordSystem1D: input axis range is out of bounds"); -} - -AngularReflectometryCoords::AngularReflectometryCoords(const AngularReflectometryCoords& other) - : CoordSystem1D(other.m_axes[0]->clone()) - , m_wavelength(other.m_wavelength) -{ -} - -AngularReflectometryCoords::~AngularReflectometryCoords() = default; - -AngularReflectometryCoords* AngularReflectometryCoords::clone() const -{ - return new AngularReflectometryCoords(*this); -} - -std::vector<Coords> AngularReflectometryCoords::availableUnits() const -{ - return availableUnits0(); -} - -std::vector<Coords> AngularReflectometryCoords::availableUnits0() // static -{ - return {Coords::NBINS, Coords::RADIANS, Coords::DEGREES, Coords::QSPACE}; -} - -std::string AngularReflectometryCoords::nameOfAxis(size_t i_axis, const Coords units) const -{ - ASSERT(i_axis == 0); - return nameOfAxis0(units); -} - -std::string AngularReflectometryCoords::nameOfAxis0(const Coords units) // static -{ - switch (units) { - case Coords::NBINS: - return "X [nbins]"; - case Coords::RADIANS: - return "alpha_i [rad]"; - case Coords::QSPACE: - return "Q [1/nm]"; - case Coords::DEGREES: - default: - return "alpha_i [deg]"; - } -} - -std::function<double(double)> AngularReflectometryCoords::getTraslatorTo(Coords units) const -{ - switch (units) { - case Coords::RADIANS: - return [](double value) { return value; }; - case Coords::DEGREES: - return [](double value) { return Units::rad2deg(value); }; - case Coords::QSPACE: - return [wl = m_wavelength](double value) { return getQ(wl, value); }; - default: - ASSERT(false); - } -} - - -// ************************************************************************************************ -// class WavenumberReflectometryCoords -// ************************************************************************************************ - -WavenumberReflectometryCoords::WavenumberReflectometryCoords(const Scale* axis) - : CoordSystem1D(axis) -{ -} - -WavenumberReflectometryCoords::WavenumberReflectometryCoords( - const WavenumberReflectometryCoords& other) - : CoordSystem1D(other.m_axes[0]->clone()) -{ -} - -WavenumberReflectometryCoords::~WavenumberReflectometryCoords() = default; - -WavenumberReflectometryCoords* WavenumberReflectometryCoords::clone() const -{ - return new WavenumberReflectometryCoords(*this); -} - -//! Returns the list of all available units -std::vector<Coords> WavenumberReflectometryCoords::availableUnits() const -{ - return {Coords::NBINS, Coords::QSPACE}; -} - -std::string WavenumberReflectometryCoords::nameOfAxis(size_t i_axis, const Coords units) const -{ - ASSERT(i_axis == 0); - switch (units) { - case Coords::NBINS: - return "X [nbins]"; - case Coords::QSPACE: - default: - return "Q [1/nm]"; - } -} - -//! Returns translating functional (inv. nm --> desired units) -std::function<double(double)> WavenumberReflectometryCoords::getTraslatorTo(Coords units) const -{ - switch (units) { - case Coords::QSPACE: - return [](double value) { return value; }; - default: - ASSERT(false); - } -} diff --git a/Device/Coord/CoordSystem1D.h b/Device/Coord/CoordSystem1D.h deleted file mode 100644 index 422d035ded6235b108a7cb2b1ca9e09b32d4eb18..0000000000000000000000000000000000000000 --- a/Device/Coord/CoordSystem1D.h +++ /dev/null @@ -1,103 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Coord/CoordSystem1D.h -//! @brief Defines CoordSystem1D class and derived classes. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifdef SWIG -#error no need to expose this header to Swig -#endif // SWIG -#ifndef BORNAGAIN_DEVICE_COORD_COORDSYSTEM1D_H -#define BORNAGAIN_DEVICE_COORD_COORDSYSTEM1D_H - -#include "Device/Coord/ICoordSystem.h" -#include <functional> - -//! Abstract base class to support coordinate transforms and axis labels for 1D scans. -//! Inherited by AngularReflectometryCoords and WavenumberReflectometryCoords. - -class CoordSystem1D : public ICoordSystem { -public: - CoordSystem1D(const Scale* axis); //!< Takes ownership of axis - ~CoordSystem1D() override = default; - - CoordSystem1D* clone() const override = 0; - - //! Creates axis in converted units. - Scale* convertedAxis(size_t i_axis, Coords units) const override; - - //! Calculates minimum on-axis value in given units. - double calculateMin(size_t i_axis, Coords units) const override; - - //! Calculates maximum on-axis value in given units. - double calculateMax(size_t i_axis, Coords units) const override; - -private: - //! Returns translating functional (rads --> output units) - virtual std::function<double(double)> getTraslatorTo(Coords units) const = 0; -}; - - -//! Conversion of axis units for the case of conventional (angle-based) reflectometry. -class AngularReflectometryCoords : public CoordSystem1D { -public: - //! Constructs the object for unit conversion. - AngularReflectometryCoords(double wavelength, const Scale& axis, - Coords axis_units = Coords::RADIANS); - ~AngularReflectometryCoords() override; - - AngularReflectometryCoords* clone() const override; - - static std::vector<Coords> availableUnits0(); - static std::string nameOfAxis0(Coords units); - -private: - //! Returns the list of all available units - std::vector<Coords> availableUnits() const override; - - std::string nameOfAxis(size_t i_axis, Coords units) const override; - - //! Returns default units to convert to. - Coords defaultUnits() const override { return Coords::DEGREES; } - - AngularReflectometryCoords(const AngularReflectometryCoords& other); - - //! Returns translating functional (rads --> desired units) - std::function<double(double)> getTraslatorTo(Coords units) const override; - - double m_wavelength; //!< basic wavelength in nm (for translation to q-space). -}; - - -//! Conversion of axis units for the case of q-defined reflectometry. -class WavenumberReflectometryCoords : public CoordSystem1D { -public: - WavenumberReflectometryCoords(const Scale* axis); - ~WavenumberReflectometryCoords() override; - - WavenumberReflectometryCoords* clone() const override; - -private: - //! Returns the list of all available units - std::vector<Coords> availableUnits() const override; - - std::string nameOfAxis(size_t i_axis, Coords units) const override; - - //! Returns default units to convert to. - Coords defaultUnits() const override { return Coords::QSPACE; } - - WavenumberReflectometryCoords(const WavenumberReflectometryCoords& other); - - //! Returns translating functional (inv. nm --> desired units) - std::function<double(double)> getTraslatorTo(Coords units) const override; -}; - -#endif // BORNAGAIN_DEVICE_COORD_COORDSYSTEM1D_H diff --git a/Device/Coord/CoordSystem2D.cpp b/Device/Coord/CoordSystem2D.cpp deleted file mode 100644 index cc2f6971e56cb657938dc7d788fcf6deff77a3f7..0000000000000000000000000000000000000000 --- a/Device/Coord/CoordSystem2D.cpp +++ /dev/null @@ -1,403 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Coord/CoordSystem2D.cpp -//! @brief Implements ICoordSystem classes. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Device/Coord/CoordSystem2D.h" -#include "Base/Axis/MakeScale.h" -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Base/Pixel/RectangularPixel.h" -#include "Base/Util/Assert.h" -#include "Base/Vector/GisasDirection.h" -#include <algorithm> -#include <cmath> -#include <numbers> - -using std::numbers::pi; - -namespace { - -double axisAngle(size_t i_axis, R3 kf) -{ - ASSERT(kf != R3()); - if (i_axis == 0) - // minus sign because sample y and detector u point in opposite directions - return -std::atan2(kf.y(), kf.x()); - if (i_axis == 1) - return (pi / 2) - atan2(kf.magxy(), kf.z()); - ASSERT(false); -} - -} // namespace - -// ************************************************************************************************ -// class CoordSystem2D -// ************************************************************************************************ - -CoordSystem2D::CoordSystem2D(std::vector<const Scale*>&& axes) - : ICoordSystem(std::move(axes)) -{ -} - -CoordSystem2D::CoordSystem2D(const CoordSystem2D& other) - : CoordSystem2D(other.m_axes.cloned_vector()) -{ -} - -double CoordSystem2D::calculateMin(size_t i_axis, Coords units) const -{ - ASSERT(i_axis < rank()); - units = substituteDefaultUnits(units); - if (units == Coords::NBINS) - return 0.0; - return calculateValue(i_axis, units, m_axes[i_axis]->min()); -} - -double CoordSystem2D::calculateMax(size_t i_axis, Coords units) const -{ - ASSERT(i_axis < rank()); - units = substituteDefaultUnits(units); - if (units == Coords::NBINS) - return m_axes[i_axis]->size(); - return calculateValue(i_axis, units, m_axes[i_axis]->max()); -} - -std::vector<Coords> CoordSystem2D::availableUnits() const -{ - return {Coords::NBINS, Coords::RADIANS, Coords::DEGREES}; -} - -Scale* CoordSystem2D::convertedAxis(size_t i_axis, Coords units) const -{ - const double min = calculateMin(i_axis, units); - const double max = calculateMax(i_axis, units); - const auto& axis_name = nameOfAxis(i_axis, units); - const auto axis_size = m_axes[i_axis]->size(); - return newEquiDivision(axis_name, axis_size, min, max); -} - -// ************************************************************************************************ -// class SphericalCoords -// ************************************************************************************************ - -SphericalCoords::SphericalCoords(std::vector<const Scale*>&& axes, const R3& ki) - : CoordSystem2D(std::move(axes)) - , m_ki(ki) -{ - ASSERT(axes.size() == 2); -} - -SphericalCoords::SphericalCoords(const SphericalCoords& other) = default; - -SphericalCoords::~SphericalCoords() = default; - -SphericalCoords* SphericalCoords::clone() const -{ - return new SphericalCoords(*this); -} - -std::vector<Coords> SphericalCoords::availableUnits() const -{ - auto result = CoordSystem2D::availableUnits(); - result.push_back(Coords::QSPACE); - return result; -} - -double SphericalCoords::calculateValue(size_t i_axis, Coords units, double value) const -{ - switch (units) { - case Coords::RADIANS: - return value; - case Coords::DEGREES: - return Units::rad2deg(value); - case Coords::QSPACE: { - if (i_axis == 0) { - // u axis runs in -y direction - const R3 kf = vecOfKAlphaPhi(m_ki.mag(), 0.0, value); - return (m_ki - kf).y(); - } - if (i_axis == 1) { - // v axis is perpendicular to ki and y. - const R3 kf = vecOfKAlphaPhi(m_ki.mag(), value); - static const R3 unit_v = (m_ki.cross(R3(0, 1, 0))).unit_or_throw(); - return (kf - m_ki).dot(unit_v); - } - ASSERT(false); - return 0; - } - default: - ASSERT(false); - } -} - -std::string SphericalCoords::nameOfAxis(size_t i_axis, const Coords units) const -{ - if (i_axis == 0) { - switch (units) { - case Coords::NBINS: - return "X [nbins]"; - case Coords::RADIANS: - return "phi_f [rad]"; - case Coords::QSPACE: - return "Qy [1/nm]"; - case Coords::DEGREES: - default: - return "phi_f [deg]"; - } - } - if (i_axis == 1) { - switch (units) { - case Coords::NBINS: - return "Y [nbins]"; - case Coords::RADIANS: - return "alpha_f [rad]"; - case Coords::QSPACE: - return "Qz [1/nm]"; - case Coords::DEGREES: - default: - return "alpha_f [deg]"; - } - } - ASSERT(false); -} - -// ************************************************************************************************ -// class ImageCoords -// ************************************************************************************************ - -ImageCoords::ImageCoords(std::vector<const Scale*>&& axes, const R3& ki, - const RectangularPixel* regionOfInterestPixel) - : CoordSystem2D(std::move(axes)) - , m_detector_pixel(regionOfInterestPixel) - , m_ki(ki) -{ - ASSERT(axes.size() == 2); -} - -ImageCoords::ImageCoords(const ImageCoords& other) - : CoordSystem2D(other) - , m_detector_pixel(other.m_detector_pixel->clone()) - , m_ki(other.m_ki) -{ -} - -ImageCoords::~ImageCoords() = default; - -ImageCoords* ImageCoords::clone() const -{ - return new ImageCoords(*this); -} - -std::vector<Coords> ImageCoords::availableUnits() const -{ - auto result = CoordSystem2D::availableUnits(); - result.push_back(Coords::QSPACE); - result.push_back(Coords::MM); - return result; -} - -double ImageCoords::calculateValue(size_t i_axis, Coords units, double value) const -{ - if (units == Coords::MM) - return value; - const auto k00 = m_detector_pixel->getPosition(0.0, 0.0); - const auto k01 = m_detector_pixel->getPosition(0.0, 1.0); - const auto k10 = m_detector_pixel->getPosition(1.0, 0.0); - const auto& max_pos = i_axis == 0 ? k10 : k01; // position of max along given axis - const double shift = value - m_axes[i_axis]->min(); - const R3 out_dir = k00 + shift * (max_pos - k00).unit_or_throw(); - const R3 kf = out_dir.unit_or_throw() * m_ki.mag(); - - switch (units) { - case Coords::RADIANS: - return axisAngle(i_axis, kf); - case Coords::DEGREES: - return Units::rad2deg(axisAngle(i_axis, kf)); - case Coords::QSPACE: { - if (i_axis == 0) - // u axis runs in -y direction - return (m_ki - kf).y(); - if (i_axis == 1) { - // v axis is perpendicular to ki and y. - static const R3 unit_v = (m_ki.cross(R3(0, 1, 0))).unit_or_throw(); - return (kf - m_ki).dot(unit_v); - } - } break; - default: - break; - } - ASSERT(false); -} - -std::string ImageCoords::nameOfAxis(size_t i_axis, const Coords units) const -{ - if (i_axis == 0) { - switch (units) { - case Coords::NBINS: - return "X [nbins]"; - case Coords::RADIANS: - return "phi_f [rad]"; - case Coords::DEGREES: - return "phi_f [deg]"; - case Coords::QSPACE: - return "Qy [1/nm]"; - case Coords::MM: - default: - return "X [mm]"; - } - } - if (i_axis == 1) { - switch (units) { - case Coords::NBINS: - return "Y [nbins]"; - case Coords::RADIANS: - return "alpha_f [rad]"; - case Coords::DEGREES: - return "alpha_f [deg]"; - case Coords::MM: - default: - return "Y [mm]"; - case Coords::QSPACE: - return "Qz [1/nm]"; - } - } - ASSERT(false); -} - -// ************************************************************************************************ -// class OffspecCoords -// ************************************************************************************************ - -OffspecCoords::OffspecCoords(std::vector<const Scale*>&& axes) - : CoordSystem2D(std::move(axes)) -{ -} - -OffspecCoords::OffspecCoords(const OffspecCoords& other) = default; - -OffspecCoords* OffspecCoords::clone() const -{ - return new OffspecCoords(*this); -} - -double OffspecCoords::calculateValue(size_t, Coords units, double value) const -{ - switch (units) { - case Coords::RADIANS: - return value; - case Coords::DEGREES: - return Units::rad2deg(value); - default: - ASSERT(false); - } -} - -std::string OffspecCoords::nameOfAxis(size_t i_axis, const Coords units) const -{ - if (i_axis == 0) { - switch (units) { - case Coords::NBINS: - return "X [nbins]"; - case Coords::RADIANS: - return "alpha_i [rad]"; - case Coords::DEGREES: - default: - return "alpha_i [deg]"; - } - } - if (i_axis == 1) { - switch (units) { - case Coords::NBINS: - return "Y [nbins]"; - case Coords::RADIANS: - return "alpha_f [rad]"; - case Coords::DEGREES: - default: - return "alpha_f [deg]"; - } - } - ASSERT(false); -} - -// ************************************************************************************************ -// class DepthprobeCoords -// ************************************************************************************************ - -const std::string z_axis_name = "Position [nm]"; - -DepthprobeCoords::DepthprobeCoords(std::vector<const Scale*>&& axes, double ki0) - : CoordSystem2D(std::move(axes)) - , m_ki0(ki0) -{ -} - -DepthprobeCoords::DepthprobeCoords(const DepthprobeCoords& other) = default; - -DepthprobeCoords::~DepthprobeCoords() = default; - -DepthprobeCoords* DepthprobeCoords::clone() const -{ - return new DepthprobeCoords(*this); -} - -std::vector<Coords> DepthprobeCoords::availableUnits() const -{ - auto result = CoordSystem2D::availableUnits(); - result.push_back(Coords::QSPACE); - return result; -} - -double DepthprobeCoords::calculateValue(size_t i_axis, Coords units, double value) const -{ - const auto& available_units = availableUnits(); - if (std::find(available_units.begin(), available_units.end(), units) == available_units.cend()) - ASSERT(false); - - if (i_axis == 1) - return value; // unit conversions are not applied to sample position axis - switch (units) { - case Coords::RADIANS: - return value; - case Coords::QSPACE: - return 2 * m_ki0 * std::sin(value); - default: - case Coords::DEGREES: - return Units::rad2deg(value); - } -} - -std::string DepthprobeCoords::nameOfAxis(size_t i_axis, const Coords units) const -{ - if (i_axis == 0) { - switch (units) { - case Coords::NBINS: - return "X [nbins]"; - case Coords::RADIANS: - return "alpha_i [rad]"; - case Coords::QSPACE: - return "Q [1/nm]"; - case Coords::DEGREES: - default: - return "alpha_i [deg]"; - } - } - if (i_axis == 1) { - switch (units) { - case Coords::NBINS: - return "Y [nbins]"; - default: - return "Position [nm]"; - } - } - ASSERT(false); -} diff --git a/Device/Coord/CoordSystem2D.h b/Device/Coord/CoordSystem2D.h deleted file mode 100644 index 3aed42b1765bc778960e9956a22cc8bdb289c313..0000000000000000000000000000000000000000 --- a/Device/Coord/CoordSystem2D.h +++ /dev/null @@ -1,143 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Coord/CoordSystem2D.h -//! @brief Defines interface CoordSystem2D and its subclasses. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifdef SWIG -#error no need to expose this header to Swig -#endif // SWIG -#ifndef BORNAGAIN_DEVICE_COORD_COORDSYSTEM2D_H -#define BORNAGAIN_DEVICE_COORD_COORDSYSTEM2D_H - -#include "Device/Coord/ICoordSystem.h" -#include <heinz/Vectors3D.h> -#include <memory> - -class Beam; -class RectangularPixel; - -//! Interface for objects that provide axis translations to different units for IDetector objects - -class CoordSystem2D : public ICoordSystem { -public: - CoordSystem2D(std::vector<const Scale*>&& axes); - ~CoordSystem2D() override = default; - - double calculateMin(size_t i_axis, Coords units) const override; - double calculateMax(size_t i_axis, Coords units) const override; - - //! Returns list of units that are available for all 2D detectors. - //! Further units may be added by child classes. - std::vector<Coords> availableUnits() const override; - - Scale* convertedAxis(size_t i_axis, Coords units) const override; - -protected: - CoordSystem2D(const CoordSystem2D& other); - -private: - virtual double calculateValue(size_t i_axis, Coords units, double value) const = 0; -}; - - -//! ICoordSystem class that handles the unit translations for spherical detectors -//! Its default units are radians for both axes - -class SphericalCoords : public CoordSystem2D { -public: - SphericalCoords(std::vector<const Scale*>&& axes, const R3& ki); - ~SphericalCoords() override; - - SphericalCoords* clone() const override; - -private: - std::vector<Coords> availableUnits() const override; - - Coords defaultUnits() const override { return Coords::DEGREES; } - - std::string nameOfAxis(size_t i_axis, Coords units) const override; - - SphericalCoords(const SphericalCoords& other); //!< used by clone() - double calculateValue(size_t i_axis, Coords units, double value) const override; - const R3 m_ki; -}; - - -//! ICoordSystem class that handles the unit translations for rectangular detectors -//! Its default units are mm for both axes - -class ImageCoords : public CoordSystem2D { -public: - ImageCoords(std::vector<const Scale*>&& axes, const R3& ki, - const RectangularPixel* regionOfInterestPixel); - ~ImageCoords() override; - - ImageCoords* clone() const override; - -private: - std::vector<Coords> availableUnits() const override; - - Coords defaultUnits() const override { return Coords::MM; } - - std::string nameOfAxis(size_t i_axis, Coords units) const override; - - ImageCoords(const ImageCoords& other); //!< used by clone() - double calculateValue(size_t i_axis, Coords units, double value) const override; - - std::unique_ptr<const RectangularPixel> m_detector_pixel; - const R3 m_ki; -}; - - -//! ICoordSystem class that handles the unit translations for off-specular simulations -//! with a spherical detector -//! Its default units are radians for both axes - -class OffspecCoords : public CoordSystem2D { -public: - OffspecCoords(std::vector<const Scale*>&& axes); - - OffspecCoords* clone() const override; - -private: - Coords defaultUnits() const override { return Coords::DEGREES; } - - std::string nameOfAxis(size_t i_axis, Coords units) const override; - - OffspecCoords(const OffspecCoords& other); //!< used by clone() - double calculateValue(size_t i_axis, Coords units, double value) const override; -}; - - -//! DepthprobeCoords class handles the unit translations for depth probe simulations -//! Its default units are radians for x-axis and nm for y-axis - -class DepthprobeCoords : public CoordSystem2D { -public: - DepthprobeCoords(std::vector<const Scale*>&& axes, double ki0); - ~DepthprobeCoords() override; - - DepthprobeCoords* clone() const override; - -private: - std::vector<Coords> availableUnits() const override; - - Coords defaultUnits() const override { return Coords::DEGREES; } - - std::string nameOfAxis(size_t i_axis, Coords units) const override; - - DepthprobeCoords(const DepthprobeCoords& other); //!< used by clone() - double calculateValue(size_t, Coords units, double value) const override; - const double m_ki0; -}; - -#endif // BORNAGAIN_DEVICE_COORD_COORDSYSTEM2D_H diff --git a/Device/Coord/ICoordSystem.cpp b/Device/Coord/ICoordSystem.cpp deleted file mode 100644 index f252f343e8f64fc3bf9037b863e24986708f2b18..0000000000000000000000000000000000000000 --- a/Device/Coord/ICoordSystem.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Coord/ICoordSystem.cpp -//! @brief Implements ICoordSystem class. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Device/Coord/ICoordSystem.h" -#include "Base/Axis/FrameUtil.h" -#include "Base/Axis/Scale.h" -#include "Base/Util/Assert.h" - -ICoordSystem::ICoordSystem(std::vector<const Scale*>&& axes) - : Frame(std::move(axes)) -{ -} - -ICoordSystem::~ICoordSystem() = default; - -std::vector<const Scale*> ICoordSystem::defaultAxes() const -{ - return convertedAxes(defaultUnits()); -} - -std::vector<const Scale*> ICoordSystem::convertedAxes(Coords units) const -{ - std::vector<const Scale*> result; - for (size_t i = 0; i < rank(); ++i) - result.emplace_back(convertedAxis(i, units)); - return result; -} - -Coords ICoordSystem::substituteDefaultUnits(Coords units) const -{ - return units == Coords::UNDEFINED ? defaultUnits() : units; -} diff --git a/Device/Coord/ICoordSystem.h b/Device/Coord/ICoordSystem.h deleted file mode 100644 index 1413374b91f366d89e082b282eca0f3ed4420ecc..0000000000000000000000000000000000000000 --- a/Device/Coord/ICoordSystem.h +++ /dev/null @@ -1,51 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Device/Coord/ICoordSystem.h -//! @brief Defines interface ICoordSystem and possible axis units. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifdef SWIG -#error no need to expose this header to Swig -#endif // SWIG -#ifndef BORNAGAIN_DEVICE_COORD_ICOORDSYSTEM_H -#define BORNAGAIN_DEVICE_COORD_ICOORDSYSTEM_H - -#include "Base/Axis/Frame.h" -#include "Device/Coord/Tags.h" -#include <string> - -//! Interface to provide axis translations to different units for simulation output - -class ICoordSystem : public Frame { -public: - ICoordSystem(std::vector<const Scale*>&& axes); - ~ICoordSystem() override; - - ICoordSystem* clone() const override = 0; - - virtual double calculateMin(size_t i_axis, Coords units) const = 0; - virtual double calculateMax(size_t i_axis, Coords units) const = 0; - - virtual std::string nameOfAxis(size_t i_axis, Coords units) const = 0; - - virtual std::vector<Coords> availableUnits() const = 0; - virtual Coords defaultUnits() const = 0; - - virtual Scale* convertedAxis(size_t i_axis, Coords units) const = 0; - - std::vector<const Scale*> defaultAxes() const; - std::vector<const Scale*> convertedAxes(Coords units) const; - -protected: - Coords substituteDefaultUnits(Coords units) const; -}; - -#endif // BORNAGAIN_DEVICE_COORD_ICOORDSYSTEM_H diff --git a/Device/Coord/Tags.h b/Device/Detector/CoordTypes.h similarity index 77% rename from Device/Coord/Tags.h rename to Device/Detector/CoordTypes.h index 2742f41e403e484a1e8aaa3c24bb4df08fb4fd2d..339d9ddc36e5c11150a4342cf8a0971c0eac4393 100644 --- a/Device/Coord/Tags.h +++ b/Device/Detector/CoordTypes.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file Device/Coord/Tags.h +//! @file Device/Detector/CoordTypes.h //! @brief Defines enum Axis::Units. //! //! @homepage http://www.bornagainproject.org @@ -12,9 +12,9 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_DEVICE_COORD_TAGS_H -#define BORNAGAIN_DEVICE_COORD_TAGS_H +#ifndef BORNAGAIN_DEVICE_DETECTOR_COORDTYPES_H +#define BORNAGAIN_DEVICE_DETECTOR_COORDTYPES_H enum class Coords { UNDEFINED, NBINS, RADIANS, DEGREES, MM, QSPACE }; -#endif // BORNAGAIN_DEVICE_COORD_TAGS_H +#endif // BORNAGAIN_DEVICE_DETECTOR_COORDTYPES_H diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h index 8056bac8b896570dd1d83dac53569ffdee0cf73d..356d3098d12f1a8d3fe592e61b5f580ee7ab92a8 100644 --- a/Device/Detector/IDetector.h +++ b/Device/Detector/IDetector.h @@ -16,21 +16,21 @@ #define BORNAGAIN_DEVICE_DETECTOR_IDETECTOR_H #include "Base/Types/ICloneable.h" -#include "Device/Coord/Tags.h" // enum Coords +#include "Device/Detector/CoordTypes.h" // enum Coords #include "Device/Pol/PolFilter.h" #include <array> #include <functional> class Beam; -class CoordSystem2D; class Datafield; class DetectorMask; -class Scale; -class ICoordSystem; +class Frame; +class Frame; class IDetectorResolution; class IPixel; class IResolutionFunction2D; class IShape2D; +class Scale; class SimulationAreaIterator; //! Abstract base for 2D detectors, realized by RectangularDetector and SphericalDetector. @@ -90,7 +90,7 @@ public: //! Sets rectangular region of interest with lower left and upper right corners defined. void setRegionOfInterest(double xlow, double ylow, double xup, double yup); - virtual const CoordSystem2D* scatteringCoords(const Beam& beam) const = 0; + virtual const Frame* scatteringCoords() const = 0; //! Returns vector of unmasked detector indices. std::vector<size_t> active_indices() const; diff --git a/Device/Detector/OffspecDetector.cpp b/Device/Detector/OffspecDetector.cpp index ca3cdecaa4065f8282d9204c921e4a373b0dba33..45ebef085369b075b1dfd422be5785053bf55a1a 100644 --- a/Device/Detector/OffspecDetector.cpp +++ b/Device/Detector/OffspecDetector.cpp @@ -21,8 +21,8 @@ OffspecDetector::OffspecDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max) - : m_axes{sharedEquiDivision("phi_f", n_phi, phi_min, phi_max), - sharedEquiDivision("alpha_f", n_alpha, alpha_min, alpha_max)} + : m_axes{sharedEquiDivision("phi_f (rad)", n_phi, phi_min, phi_max), + sharedEquiDivision("alpha_f (rad)", n_alpha, alpha_min, alpha_max)} { } diff --git a/Device/Detector/OffspecDetector.h b/Device/Detector/OffspecDetector.h index 1b6c5a911b90ca385fd891e1ae42fdfd1ac3f2a7..47a51a21161ce97d15ccc39ff17ed8e51e696b39 100644 --- a/Device/Detector/OffspecDetector.h +++ b/Device/Detector/OffspecDetector.h @@ -16,7 +16,7 @@ #define BORNAGAIN_DEVICE_DETECTOR_OFFSPECDETECTOR_H //#include "Base/Types/ICloneable.h" -#include "Device/Coord/Tags.h" // enum Coords +#include "Device/Detector/CoordTypes.h" // enum Coords #include "Device/Pol/PolFilter.h" #include "Param/Node/INode.h" diff --git a/Device/Detector/RectangularDetector.cpp b/Device/Detector/RectangularDetector.cpp index 698f8aac93bd3d09b5d2867a89f9209a16141ef6..ed1d6f4836945cb23bbde89ed416a3e6352945b5 100644 --- a/Device/Detector/RectangularDetector.cpp +++ b/Device/Detector/RectangularDetector.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Device/Detector/RectangularDetector.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" #include "Base/Const/Units.h" #include "Base/Pixel/RectangularPixel.h" #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" -#include "Device/Coord/CoordSystem2D.h" #include "Device/Resolution/IDetectorResolution.h" #include <numbers> @@ -246,7 +246,7 @@ void RectangularDetector::initUandV() m_v_unit = m_u_unit.cross(m_normal_to_detector).unit_or_throw(); } -const CoordSystem2D* RectangularDetector::scatteringCoords(const Beam& beam) const +const Frame* RectangularDetector::scatteringCoords() const { - return new ImageCoords(axesClippedToRegionOfInterest(), beam.ki(), regionOfInterestPixel()); + return new Frame(axesClippedToRegionOfInterest()); } diff --git a/Device/Detector/RectangularDetector.h b/Device/Detector/RectangularDetector.h index c763d562375e28c6be4f5ec6543b05667d4453ea..cc4f4de24d8442a7c7b37091a4dfa9439dea3874 100644 --- a/Device/Detector/RectangularDetector.h +++ b/Device/Detector/RectangularDetector.h @@ -72,7 +72,7 @@ public: Coords defaultCoords() const override { return Coords::MM; } const RectangularPixel* regionOfInterestPixel() const; - const CoordSystem2D* scatteringCoords(const Beam& beam) const override; + const Frame* scatteringCoords() const override; private: //! Creates an IPixel for the given Datafield object and index diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp index 183f4aa5379cc802e0fd0909c501f8c8ff3c8453..22c9233eee79d1757755a7be9259083052463992 100644 --- a/Device/Detector/SphericalDetector.cpp +++ b/Device/Detector/SphericalDetector.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Device/Detector/SphericalDetector.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" #include "Base/Const/Units.h" #include "Base/Pixel/SphericalPixel.h" #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" -#include "Device/Coord/CoordSystem2D.h" #include "Device/Resolution/IDetectorResolution.h" #include <numbers> @@ -33,8 +33,8 @@ SphericalDetector::SphericalDetector(std::array<std::shared_ptr<Scale>, 2> axes) SphericalDetector::SphericalDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max) : SphericalDetector(std::array<std::shared_ptr<Scale>, 2>{ - sharedEquiDivision("phi_f", n_phi, phi_min, phi_max), - sharedEquiDivision("alpha_f", n_alpha, alpha_min, alpha_max)}) + sharedEquiDivision("phi_f (rad)", n_phi, phi_min, phi_max), + sharedEquiDivision("alpha_f (rad)", n_alpha, alpha_min, alpha_max)}) { } @@ -74,7 +74,7 @@ size_t SphericalDetector::indexOfSpecular(const Beam& beam) const return totalSize(); } -const CoordSystem2D* SphericalDetector::scatteringCoords(const Beam& beam) const +const Frame* SphericalDetector::scatteringCoords() const { - return new SphericalCoords(axesClippedToRegionOfInterest(), beam.ki()); + return new Frame(axesClippedToRegionOfInterest()); } diff --git a/Device/Detector/SphericalDetector.h b/Device/Detector/SphericalDetector.h index bfb3ee22458b11240411832bac2ef308d134710d..2925dbbaaaccca87c91de368afe3c6e632b36793 100644 --- a/Device/Detector/SphericalDetector.h +++ b/Device/Detector/SphericalDetector.h @@ -51,7 +51,7 @@ public: //! Returns default axes units Coords defaultCoords() const override { return Coords::RADIANS; } - const CoordSystem2D* scatteringCoords(const Beam& beam) const override; + const Frame* scatteringCoords() const override; //! Creates an IPixel for the given Datafield object and index IPixel* createPixel(size_t index) const override; diff --git a/Device/Histo/SimulationResult.cpp b/Device/Histo/SimulationResult.cpp index c7eb63b1366bd403a4e2649ffc617bf6766a1cac..99d01e45dc243e1ecaffd0c96c106712424847ac 100644 --- a/Device/Histo/SimulationResult.cpp +++ b/Device/Histo/SimulationResult.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Device/Histo/SimulationResult.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" #include "Base/Util/Assert.h" -#include "Device/Coord/ICoordSystem.h" SimulationResult::SimulationResult() = default; -SimulationResult::SimulationResult(const Datafield& data, const ICoordSystem* coords) +SimulationResult::SimulationResult(const Datafield& data, const Frame* coords) : Datafield(coords, data.flatVector(), data.errorSigmas()) { ASSERT(coords); @@ -27,7 +27,7 @@ SimulationResult::SimulationResult(const Datafield& data, const ICoordSystem* co } SimulationResult::SimulationResult(const SimulationResult& other) - : Datafield(other.converter().clone(), other.flatVector(), other.errorSigmas()) + : Datafield(other.frame().clone(), other.flatVector(), other.errorSigmas()) , m_title(other.m_title) { } @@ -40,44 +40,43 @@ SimulationResult& SimulationResult::operator=(SimulationResult&& other) noexcept Datafield SimulationResult::extracted_field() const { - return Datafield(converter().convertedAxes(Coords::UNDEFINED), flatVector()); + return Datafield(frame().clonedAxes(), flatVector()); } -std::pair<double, double> SimulationResult::axisMinMax(size_t i, Coords units) const +std::pair<double, double> SimulationResult::axisMinMax(size_t i) const { - return {converter().calculateMin(i, units), converter().calculateMax(i, units)}; + return {frame().axis(i).min(), frame().axis(i).max()}; } -std::string SimulationResult::name_of_axis(size_t i, Coords units) const +std::string SimulationResult::name_of_axis(size_t i) const { - return converter().nameOfAxis(i, units); + return frame().axis(i).axisName(); } -const ICoordSystem& SimulationResult::converter() const +const Frame& SimulationResult::frame() const { - const auto* coordsys = dynamic_cast<const ICoordSystem*>(m_frame.get()); + const auto* coordsys = dynamic_cast<const Frame*>(m_frame.get()); ASSERT(coordsys); return *coordsys; } #ifdef BORNAGAIN_PYTHON -PyObject* SimulationResult::array(Coords units) const +PyObject* SimulationResult::array() const { - Datafield data(converter().convertedAxes(units), flatVector()); + Datafield data(frame().clonedAxes(), flatVector()); return data.npArray(); } #endif -std::vector<double> SimulationResult::convertedBinCenters(Coords units) const +std::vector<double> SimulationResult::convertedBinCenters() const { - return convertedBinCenters(0, units); + return convertedBinCenters(0); } -std::vector<double> SimulationResult::convertedBinCenters(size_t i_axis, Coords units) const +std::vector<double> SimulationResult::convertedBinCenters(size_t i_axis) const { - ASSERT(i_axis < converter().rank()); - auto* axis = converter().convertedAxis(i_axis, units); // TODO memory leak - return axis->binCenters(); + ASSERT(i_axis < frame().rank()); + return frame().axis(i_axis).binCenters(); } void SimulationResult::setTitle(const std::string& title) diff --git a/Device/Histo/SimulationResult.h b/Device/Histo/SimulationResult.h index 2f04aaa22b0b3cad3294f70fb12192794281b351..d72a650e12be703e8cf5d6973852823758fd2cfa 100644 --- a/Device/Histo/SimulationResult.h +++ b/Device/Histo/SimulationResult.h @@ -16,18 +16,16 @@ #define BORNAGAIN_DEVICE_HISTO_SIMULATIONRESULT_H #include "Device/Data/Datafield.h" - -#include "Device/Coord/Tags.h" #include <string> -class ICoordSystem; +class Frame; //! Wrapper around Datafield that also provides unit conversions. class SimulationResult : public Datafield { public: SimulationResult(); // required by Swig - SimulationResult(const Datafield& data, const ICoordSystem* coords); + SimulationResult(const Datafield& data, const Frame* coords); SimulationResult(const SimulationResult& other); SimulationResult(SimulationResult&& other) noexcept; @@ -37,28 +35,28 @@ public: Datafield extracted_field() const; - std::pair<double, double> axisMinMax(size_t i, Coords units = Coords::UNDEFINED) const; + std::pair<double, double> axisMinMax(size_t i) const; - std::string name_of_axis(size_t i, Coords units = Coords::UNDEFINED) const; + std::string name_of_axis(size_t i) const; //! Returns intensity data as Python numpy array #ifdef BORNAGAIN_PYTHON - PyObject* array(Coords units = Coords::UNDEFINED) const; + PyObject* array() const; #endif - std::vector<double> convertedBinCenters(Coords units = Coords::UNDEFINED) const; + std::vector<double> convertedBinCenters() const; //! Returns axis coordinates as a numpy array. With no parameters given //! Returns coordinates of x-axis in default units. - std::vector<double> convertedBinCenters(size_t i_axis, Coords units = Coords::UNDEFINED) const; + std::vector<double> convertedBinCenters(size_t i_axis) const; void setTitle(const std::string& title); std::string title(); #ifndef SWIG - //! Returns underlying unit converter - const ICoordSystem& converter() const; + //! Returns underlying unit frame + const Frame& frame() const; private: std::string m_title; diff --git a/Device/IO/IOFactory.cpp b/Device/IO/IOFactory.cpp index 071c19de807904d6b35e2eaa322f6ec1f4f559e2..12672aa5ec3b4a57add3294ab53268a5308b8ef6 100644 --- a/Device/IO/IOFactory.cpp +++ b/Device/IO/IOFactory.cpp @@ -265,9 +265,10 @@ bool Util::RW::dataMatchesFile(const Datafield& data, const std::string& refFile std::unique_ptr<Datafield> refDat; try { refDat.reset(IO::readData2D(refFileName)); - } catch (...) { + } catch (const std::exception& ex) { std::cerr << "File comparison: Could not read reference data from file " << refFileName << std::endl; + std::cerr << "Error message: " << ex.what() << std::endl; return false; } ASSERT(refDat); diff --git a/Device/IO/ParseUtil.cpp b/Device/IO/ParseUtil.cpp index 308df0d6a7938b6c82c1ea92c1b70757532600a6..e932c5579a072967d5b0e1ed11b6fe98f8bb7115 100644 --- a/Device/IO/ParseUtil.cpp +++ b/Device/IO/ParseUtil.cpp @@ -21,18 +21,10 @@ #include <functional> #include <iostream> #include <iterator> +#include <regex> namespace { -std::istringstream getAxisStringRepresentation(std::istream& input_stream) -{ - std::string line; - std::getline(input_stream, line); - const std::vector<std::string> to_replace = {",", "\"", "(", ")", "[", "]"}; - Base::String::replaceItemsFromString(line, to_replace, " "); - return std::istringstream(line); -} - void readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss) { iss.imbue(std::locale::classic()); @@ -40,42 +32,59 @@ void readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss) back_inserter(buffer)); } +std::vector<double> parse_x_list(std::string text, const std::string& type) +{ + if (text.substr(0, 1) == ",") { + std::cerr << "Warning: file format from BornAgain <= 20 is obsolete" << std::endl; + size_t i = text.find_first_not_of(" ", 1); + text.erase(0, i); + } + if (text.substr(0, 1) == "[" && text.substr(text.size() - 1, 1) == "]") + text = text.substr(1, text.size() - 2); + std::vector<std::string> arr = Base::String::split(text, ","); + std::vector<double> result; + for (std::string e : arr) { + e = Base::String::trim(e); + if (e.empty()) + continue; + double x; + if (!(Base::String::to_double(e, &x))) + throw std::runtime_error("Reading " + type + ": cannot read entry '" + e + "'"); + result.push_back(x); + } + if (!result.size()) + throw std::runtime_error("Reading " + type + ": found empty list"); + return result; +} + } // namespace //! Creates axis of certain type from input stream Scale* Util::Parse::parseScale(std::istream& input_stream) { - auto iss = ::getAxisStringRepresentation(input_stream); - std::string type; - if (!(iss >> type)) - throw std::runtime_error("Cannot read axis type from input"); - + std::string line; + std::getline(input_stream, line); + std::smatch matched; + std::regex_match(line, matched, std::regex("(\\w+)\\(\"(.*?)\",\\s*(.+?)\\)")); + if (matched.size() != 4) + throw std::runtime_error("Cannot read axis from input"); + const std::string type = matched[1]; + const std::string name = matched[2]; + const std::string body = matched[3]; if (type == "EquiDivision" || type == "FixedBinAxis" /* for compatibility with pre-21 */) { - std::string name; - size_t nbins; - if (!(iss >> name >> nbins)) - throw std::runtime_error("Reading EquiDivision: cannot read name or size"); - std::vector<double> boundaries; - ::readLineOfDoubles(boundaries, iss); - if (boundaries.size() != 2) - throw std::runtime_error("Reading EquiDivision: cannot read start or stop"); - return newEquiDivision(name, nbins, boundaries[0], boundaries[1]); + std::vector<std::string> arr = Base::String::split(body, ","); + int nbins; + double xmi, xma; + if (!(Base::String::to_int(arr[0], &nbins) && Base::String::to_double(arr[1], &xmi) + && Base::String::to_double(arr[2], &xma))) + throw std::runtime_error("Reading EquiDivision: cannot read parameters"); + return newEquiDivision(name, nbins, xmi, xma); } else if (type == "ListScan" || type == "DiscreteAxis" /* for compatibility with pre-21 */) { - std::string name; - if (!(iss >> name)) - throw std::runtime_error("Reading ListScan: cannot read name"); - std::vector<double> coordinates; - ::readLineOfDoubles(coordinates, iss); - return newListScan(name, coordinates); + return newListScan(name, parse_x_list(body, type)); } else if (type == "Scale") { - std::string name; - if (!(iss >> name)) - throw std::runtime_error("Reading Scale: cannot read name"); - std::vector<double> coordinates; - ::readLineOfDoubles(coordinates, iss); - return newGenericScale(name, coordinates); + return newGenericScale(name, parse_x_list(body, type)); } else throw std::runtime_error("Unknown axis type '" + type + "'"); diff --git a/Device/IO/ReadRefsans.cpp b/Device/IO/ReadRefsans.cpp index 6f3de6557de0846e9dbf812b08323330e50b4f51..b65d40bfb0917c64103c07eccc3695c23b8265b2 100644 --- a/Device/IO/ReadRefsans.cpp +++ b/Device/IO/ReadRefsans.cpp @@ -90,7 +90,7 @@ Datafield* Util::RW::readRefsans(std::istream& input_stream) // create datafield std::vector<const Scale*> axes; - axes.push_back(newListScan("Qy", qy)); - axes.push_back(newListScan("Qz", qz)); + axes.push_back(newListScan("Qy (1/nm)", qy)); + axes.push_back(newListScan("Qz (1/nm)", qz)); return new Datafield(std::move(axes), values); } diff --git a/Device/IO/ReadWriteINT.cpp b/Device/IO/ReadWriteINT.cpp index 5e58ad25cd9bf2b1b7dc4751167ee686752dcadc..06f4fff3b0f192e99a7b67033393abe70b7db802 100644 --- a/Device/IO/ReadWriteINT.cpp +++ b/Device/IO/ReadWriteINT.cpp @@ -60,12 +60,10 @@ void Util::RW::writeBAInt(const Datafield& data, std::ostream& output_stream) output_stream << "# BornAgain Intensity Data\n\n"; for (size_t i = 0; i < data.rank(); ++i) { - std::string axis_name = std::string("axis") + std::to_string(i); - std::unique_ptr<Scale> axis(data.axis(i).clone()); - axis->setAxisName(axis_name); + const Scale& axis = data.axis(i); output_stream << std::endl; output_stream << "# axis-" << i << "\n"; - output_stream << (*axis) << "\n"; + output_stream << axis << "\n"; } size_t n_columns = data.axis(data.rank() - 1).size(); diff --git a/GUI/Model/Axis/PointwiseAxisItem.cpp b/GUI/Model/Axis/PointwiseAxisItem.cpp index ab20ac5ea2ad798fcd3e54a404d25579c053f722..7c0253aef7e57a466c46800a6fa7b78b226820ae 100644 --- a/GUI/Model/Axis/PointwiseAxisItem.cpp +++ b/GUI/Model/Axis/PointwiseAxisItem.cpp @@ -13,9 +13,9 @@ // ************************************************************************************************ #include "GUI/Model/Axis/PointwiseAxisItem.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" -#include "Device/Coord/ICoordSystem.h" #include "Device/Data/Datafield.h" #include "Device/IO/ReadWriteINT.h" #include "GUI/Support/XML/UtilXML.h" @@ -143,12 +143,12 @@ void PointwiseAxisItem::readFrom(QXmlStreamReader* r) } } -void PointwiseAxisItem::updateAxIndicators(const ICoordSystem& cs) +void PointwiseAxisItem::updateAxIndicators(const Frame& cs) { if (!m_axis || nativeAxisUnits() == "nbins") return; - setMin(cs.calculateMin(0, Coords::DEGREES)); - setMax(cs.calculateMax(0, Coords::DEGREES)); + setMin(cs.axis(0).min()); + setMax(cs.axis(0).max()); setBinCount(static_cast<int>(m_axis->size())); } diff --git a/GUI/Model/Axis/PointwiseAxisItem.h b/GUI/Model/Axis/PointwiseAxisItem.h index 5670975a491768498e13025e6a5b948ec1618d60..75c3687981681552df9432058fab9b6eee2d5964 100644 --- a/GUI/Model/Axis/PointwiseAxisItem.h +++ b/GUI/Model/Axis/PointwiseAxisItem.h @@ -17,7 +17,7 @@ #include "GUI/Model/Axis/BasicAxisItem.h" -class ICoordSystem; +class Frame; //! Item for non-uniform axis with specified coordinates. class PointwiseAxisItem : public BasicAxisItem { @@ -34,7 +34,7 @@ public: std::unique_ptr<Scale> itemToAxis(double scale, const Scale& converted_axis) const override; - void updateAxIndicators(const ICoordSystem& cs); + void updateAxIndicators(const Frame& cs); QByteArray serializeBinaryData() const; void deserializeBinaryData(const QByteArray& data); diff --git a/GUI/Model/Beam/GrazingScanItem.cpp b/GUI/Model/Beam/GrazingScanItem.cpp index 4a4c723f7211c541defbdedbe9c70289b95c594c..d69801b4a3ddd7e61863340f075eeaf45cdd1c54 100644 --- a/GUI/Model/Beam/GrazingScanItem.cpp +++ b/GUI/Model/Beam/GrazingScanItem.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "GUI/Model/Beam/GrazingScanItem.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" #include "Base/Const/Units.h" #include "Base/Util/Assert.h" -#include "Device/Coord/ICoordSystem.h" #include "GUI/Model/Axis/PointwiseAxisItem.h" #include "GUI/Model/Descriptor/DistributionItems.h" @@ -35,7 +35,7 @@ const QString BaseData("BaseData"); void setAxisPresentationDefaults(BasicAxisItem* axisItem) { ASSERT(axisItem); - axisItem->setTitle("alpha_i"); + axisItem->setTitle("alpha_i (rad)"); if (!dynamic_cast<PointwiseAxisItem*>(axisItem)) { axisItem->setMin(0.0); @@ -188,7 +188,7 @@ void GrazingScanItem::initUniformAxis(const Scale& axis) m_uniformAlphaAxis->setBinCount(static_cast<int>(axis.size())); } -void GrazingScanItem::initListScan(const Scale& axis, QString units, const ICoordSystem& converter) +void GrazingScanItem::initListScan(const Scale& axis, QString units, const Frame& frame) { if (!m_pointwiseAlphaAxis) { m_pointwiseAlphaAxis.reset(new PointwiseAxisItem()); @@ -196,5 +196,5 @@ void GrazingScanItem::initListScan(const Scale& axis, QString units, const ICoor } m_pointwiseAlphaAxis->setAxisAndUnit(axis, units); - m_pointwiseAlphaAxis->updateAxIndicators(converter); + m_pointwiseAlphaAxis->updateAxIndicators(frame); } diff --git a/GUI/Model/Beam/GrazingScanItem.h b/GUI/Model/Beam/GrazingScanItem.h index c8302b0cfc415964c47be542a041221fd52ff4a1..54944c83e135bac6aaa8283f1603645fa8b36379 100644 --- a/GUI/Model/Beam/GrazingScanItem.h +++ b/GUI/Model/Beam/GrazingScanItem.h @@ -19,7 +19,7 @@ class BasicAxisItem; class Scale; -class ICoordSystem; +class Frame; class PointwiseAxisItem; //! BeamInclinationAxisItem contains inclination angle axis for specular/off-specular @@ -59,7 +59,7 @@ public: void selectListScan(); void initUniformAxis(const Scale& axis); - void initListScan(const Scale& axis, QString units, const ICoordSystem& converter); + void initListScan(const Scale& axis, QString units, const Frame& frame); private: std::unique_ptr<BasicAxisItem> m_uniformAlphaAxis; diff --git a/GUI/Model/Beam/SourceItems.cpp b/GUI/Model/Beam/SourceItems.cpp index b83d73297a34c5a926a72ef4d89dc373ba2e9750..71a8cfbff40036a535ac8d5c5edc654188c077ac 100644 --- a/GUI/Model/Beam/SourceItems.cpp +++ b/GUI/Model/Beam/SourceItems.cpp @@ -24,7 +24,7 @@ #include "GUI/Model/Beam/BeamWavelengthItem.h" #include "GUI/Model/Beam/FootprintItems.h" #include "GUI/Model/Beam/GrazingScanItem.h" -#include "Sim/Scan/IBeamScan.h" +#include "Sim/Scan/AlphaScan.h" namespace { @@ -288,7 +288,8 @@ ScanItem::ScanItem() void ScanItem::setScan(const IBeamScan* scan) { setIntensity(scan->intensity()); - setWavelength(scan->wavelength()); + if (const auto* s = dynamic_cast<const AlphaScan*>(scan)) + setWavelength(s->wavelength()); setAzimuthalAngle(0.0); auto* axis_item = inclinationAxisItem(); @@ -365,13 +366,13 @@ BasicAxisItem* ScanItem::inclinationAxisItem() const return grazingScanItem()->alphaAxisItem(); } -void ScanItem::updateToData(const Scale& axis, QString units, const ICoordSystem& converter) +void ScanItem::updateToData(const Scale& axis, QString units, const Frame& frame) { if (units == "nbins") { grazingScanItem()->initUniformAxis(axis); grazingScanItem()->selectUniformAxis(); } else { - grazingScanItem()->initListScan(axis, units, converter); + grazingScanItem()->initListScan(axis, units, frame); grazingScanItem()->selectListScan(); } } diff --git a/GUI/Model/Beam/SourceItems.h b/GUI/Model/Beam/SourceItems.h index 43dfe8e6ec64bacc031b1ea64d33695111c93f43..7ea9415896860efdd8dadc2d72dea94945b240d4 100644 --- a/GUI/Model/Beam/SourceItems.h +++ b/GUI/Model/Beam/SourceItems.h @@ -29,7 +29,7 @@ class BeamWavelengthItem; class FootprintItem; class GrazingScanItem; class IBeamScan; -class ICoordSystem; +class Frame; class IFootprint; class Scale; @@ -107,7 +107,7 @@ public: GrazingScanItem* grazingScanItem() const; BasicAxisItem* inclinationAxisItem() const; - void updateToData(const Scale& axis, QString units, const ICoordSystem& converter); + void updateToData(const Scale& axis, QString units, const Frame& frame); std::unique_ptr<Beam> createBeam() const; diff --git a/GUI/Model/Data/DataItem.cpp b/GUI/Model/Data/DataItem.cpp index ff610bf0c6bc176980518a93e13ed32b750834cd..61476523d3168dc06cb90e626fb6a3973aab4c5e 100644 --- a/GUI/Model/Data/DataItem.cpp +++ b/GUI/Model/Data/DataItem.cpp @@ -18,7 +18,6 @@ #include "Device/IO/IOFactory.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" -#include "GUI/Support/Util/CoordName.h" #include "GUI/Support/Util/MessageService.h" #include "GUI/Support/XML/UtilXML.h" #include <QFile> @@ -41,7 +40,6 @@ const QString y_axis_default_name = "Y [nbins]"; DataItem::DataItem(const QString& modelType) : TYPE(modelType) , m_fileName("undefined") - , m_currentCoord(Coords::NBINS) , m_xAxis(std::make_unique<BasicAxisItem>()) , m_yAxis(std::make_unique<AmplitudeAxisItem>()) , m_last_modified(QDateTime::currentDateTime()) @@ -227,27 +225,6 @@ void DataItem::copyXYRangesFromItem(DataItem* sourceItem) copyYRangeFromItem(sourceItem); } -Coords DataItem::currentCoord() const -{ - return m_currentCoord; -} - -void DataItem::setCurrentCoord(Coords coord) -{ - m_currentCoord = coord; -} - -QString DataItem::currentAxesUnits() const -{ - return GUI::Util::CoordName::nameFromCoord(m_currentCoord); -} - -void DataItem::setCurrentAxesUnits(const QString& units) -{ - m_currentCoord = GUI::Util::CoordName::coordFromName(units); - emit axesUnitsChanged(this); -} - const BasicAxisItem* DataItem::xAxisItem() const { return m_xAxis.get(); @@ -305,11 +282,6 @@ void DataItem::writeTo(QXmlStreamWriter* w) const XML::writeAttribute(w, XML::Attrib::value, m_fileName); w->writeEndElement(); - // axes units - w->writeStartElement(Tag::AxesUnits); - XML::writeAttribute(w, XML::Attrib::value, GUI::Util::CoordName::nameFromCoord(m_currentCoord)); - w->writeEndElement(); - // x axis w->writeStartElement(Tag::XAxis); m_xAxis->writeTo(w); @@ -323,7 +295,7 @@ void DataItem::writeTo(QXmlStreamWriter* w) const void DataItem::readFrom(QXmlStreamReader* r) { - const uint version = XML::readUIntAttribute(r, XML::Attrib::version); + // const uint version = XML::readUIntAttribute(r, XML::Attrib::version); while (r->readNextStartElement()) { QString tag = r->name().toString(); @@ -333,18 +305,6 @@ void DataItem::readFrom(QXmlStreamReader* r) XML::readAttribute(r, XML::Attrib::value, &m_fileName); XML::gotoEndElementOfTag(r, tag); - // axes units - } else if (tag == Tag::AxesUnits) { - QString axes_units; - if (version == 1) { - XML::readAttribute(r, XML::Attrib::name, &axes_units); - if (axes_units.isEmpty()) - axes_units = GUI::Util::CoordName::nameFromCoord(Coords::NBINS); - } else - XML::readAttribute(r, XML::Attrib::value, &axes_units); - m_currentCoord = GUI::Util::CoordName::coordFromName(axes_units); - XML::gotoEndElementOfTag(r, tag); - // x axis } else if (tag == Tag::XAxis) { m_xAxis->readFrom(r); diff --git a/GUI/Model/Data/DataItem.h b/GUI/Model/Data/DataItem.h index 753afb3f061e56dc176368718cadd31003ee3840..68fe2a5d5304e18e390a64fe57e647e2a6b97a33 100644 --- a/GUI/Model/Data/DataItem.h +++ b/GUI/Model/Data/DataItem.h @@ -15,7 +15,6 @@ #ifndef BORNAGAIN_GUI_MODEL_DATA_DATAITEM_H #define BORNAGAIN_GUI_MODEL_DATA_DATAITEM_H -#include "Device/Coord/Tags.h" #include "GUI/Model/Data/ComboProperty.h" #include <QDateTime> #include <mutex> @@ -24,7 +23,7 @@ class AmplitudeAxisItem; class BasicAxisItem; class ComboProperty; class Datafield; -class ICoordSystem; +class Frame; class MessageService; //! Abstract base class for IntensityDataItem and SpecularDataItem. @@ -92,15 +91,6 @@ public: void copyYRangeFromItem(DataItem* sourceItem); void copyXYRangesFromItem(DataItem* sourceItem); - // Axes units - Coords currentCoord() const; - void setCurrentCoord(Coords coord); - QString currentAxesUnits() const; - void setCurrentAxesUnits(const QString& units); - - //! Updates data on the change of axes units - virtual void updateCoords(const ICoordSystem& converter) = 0; - const BasicAxisItem* xAxisItem() const; BasicAxisItem* xAxisItem(); const AmplitudeAxisItem* yAxisItem() const; @@ -142,7 +132,6 @@ protected: QString m_fileName; QString m_fileDir; - Coords m_currentCoord; std::unique_ptr<BasicAxisItem> m_xAxis; std::unique_ptr<AmplitudeAxisItem> m_yAxis; diff --git a/GUI/Model/Data/DataItemUtil.cpp b/GUI/Model/Data/DataItemUtil.cpp index ba7ba19e4795e4e9538a69b4a0c1bb838d20f95f..32e708f34be64e2c03149e0bb60512af1a4ca325 100644 --- a/GUI/Model/Data/DataItemUtil.cpp +++ b/GUI/Model/Data/DataItemUtil.cpp @@ -13,68 +13,50 @@ // ************************************************************************************************ #include "GUI/Model/Data/DataItemUtil.h" +#include "Base/Axis/Frame.h" +#include "Base/Axis/Scale.h" #include "Base/Util/Assert.h" -#include "Device/Coord/ICoordSystem.h" #include "Device/Data/Datafield.h" #include "Device/Histo/SimulationResult.h" #include "GUI/Model/Data/DataItem.h" -#include "GUI/Support/Util/CoordName.h" -void GUI::Model::DataItemUtil::updateAxesTitle(DataItem* intensityItem, - const ICoordSystem& converter, Coords units) +void GUI::Model::DataItemUtil::updateAxesTitle(DataItem* intensityItem, const Frame& frame) { - intensityItem->setXaxisTitle(QString::fromStdString(converter.nameOfAxis(0, units))); - if (converter.rank() > 1) - intensityItem->setYaxisTitle(QString::fromStdString(converter.nameOfAxis(1, units))); -} - -QStringList GUI::Model::DataItemUtil::availableUnits(const ICoordSystem& converter) -{ - QStringList result; - for (auto units : converter.availableUnits()) { - auto unit_name = GUI::Util::CoordName::nameFromCoord(units); - if (!unit_name.isEmpty()) - result << unit_name; - } - return result; + intensityItem->setXaxisTitle(QString::fromStdString(frame.axis(0).axisName())); + if (frame.rank() > 1) + intensityItem->setYaxisTitle(QString::fromStdString(frame.axis(1).axisName())); } //! Updates axes of Datafield in IntensityData item to correspond with axes units selection. //! InstrumentItem is used to get domain's detector map for given units. -void GUI::Model::DataItemUtil::updateDataAxes(DataItem* dataItem, const ICoordSystem& converter) +void GUI::Model::DataItemUtil::updateDataAxes(DataItem* dataItem, const Frame& frame) { ASSERT(dataItem); const Datafield* oldData = dataItem->c_field(); if (!oldData) return; - Coords axes_units = dataItem->currentCoord(); - - auto newData = std::make_unique<Datafield>(converter.convertedAxes(axes_units), - oldData->flatVector(), oldData->errorSigmas()); + auto newData = std::make_unique<Datafield>(frame.clonedAxes(), oldData->flatVector(), + oldData->errorSigmas()); dataItem->setDatafield(newData.release()); dataItem->setAxesRangeToData(); - updateAxesTitle(dataItem, converter, axes_units); + updateAxesTitle(dataItem, frame); } -void GUI::Model::DataItemUtil::createDefaultDetectorMap(DataItem* dataItem, - const ICoordSystem& converter) +void GUI::Model::DataItemUtil::createDefaultDetectorMap(DataItem* dataItem, const Frame& frame) { - auto current_coord = dataItem->currentCoord(); - auto output_data = std::make_unique<Datafield>(converter.convertedAxes(current_coord)); + auto output_data = std::make_unique<Datafield>(frame.clonedAxes()); dataItem->setDatafield(output_data.release()); - updateAxesTitle(dataItem, converter, current_coord); + updateAxesTitle(dataItem, frame); } void GUI::Model::DataItemUtil::setResults(DataItem* dataItem, const SimulationResult& result) { - auto current_coord = dataItem->currentCoord(); if (dataItem->c_field() == nullptr) { - const auto& converter = result.converter(); - updateAxesTitle(dataItem, converter, current_coord); + const auto& frame = result.frame(); + updateAxesTitle(dataItem, frame); } - dataItem->setDatafield( - new Datafield(result.converter().convertedAxes(current_coord), result.flatVector())); + dataItem->setDatafield(new Datafield(result.frame().clonedAxes(), result.flatVector())); } diff --git a/GUI/Model/Data/DataItemUtil.h b/GUI/Model/Data/DataItemUtil.h index 609744f1c0a0407115f5fc751757c9e4ad75c055..dd857014ac5a8746d8625d86408bb5fa49e7d7e5 100644 --- a/GUI/Model/Data/DataItemUtil.h +++ b/GUI/Model/Data/DataItemUtil.h @@ -19,7 +19,7 @@ #include "GUI/Model/Data/ComboProperty.h" class DataItem; -class ICoordSystem; +class Frame; class SimulationResult; //! Contains convenience methods to trasfer data from domain simulation to IntensityDataItem. @@ -28,16 +28,13 @@ class SimulationResult; namespace GUI::Model::DataItemUtil { //! Updates axes' titles -void updateAxesTitle(DataItem* intensityItem, const ICoordSystem& converter, Coords units); +void updateAxesTitle(DataItem* intensityItem, const Frame& frame); //! Updates axes of Datafield in IntensityData item -void updateDataAxes(DataItem* dataItem, const ICoordSystem& converter); - -//! Available units for coordinate system -QStringList availableUnits(const ICoordSystem& converter); +void updateDataAxes(DataItem* dataItem, const Frame& frame); //! Creates zero-value intensity map with given coordinate system -void createDefaultDetectorMap(DataItem* dataItem, const ICoordSystem& converter); +void createDefaultDetectorMap(DataItem* dataItem, const Frame& frame); //! Sets simulation results into the DataItem void setResults(DataItem* dataItem, const SimulationResult& result); diff --git a/GUI/Model/Data/IntensityDataItem.cpp b/GUI/Model/Data/IntensityDataItem.cpp index 9287c9526d8904174c3b1cae32c02bc63cafb7be..e4be2d9dcbbdeede07b81dae72497b14782d1d84 100644 --- a/GUI/Model/Data/IntensityDataItem.cpp +++ b/GUI/Model/Data/IntensityDataItem.cpp @@ -13,16 +13,15 @@ // ************************************************************************************************ #include "GUI/Model/Data/IntensityDataItem.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" #include "Base/Util/Assert.h" -#include "Device/Coord/ICoordSystem.h" #include "Device/Data/Datafield.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" #include "GUI/Model/Data/DataItemUtil.h" #include "GUI/Model/Data/MaskUnitsConverter.h" #include "GUI/Model/Data/ProjectionItems.h" -#include "GUI/Support/Util/CoordName.h" #include "GUI/Support/Util/QCP_Util.h" #include <qcustomplot.h> @@ -204,16 +203,6 @@ void IntensityDataItem::setZaxisLocked(bool state) return m_zAxis->setLocked(state); } -void IntensityDataItem::updateCoords(const ICoordSystem& converter) -{ - MaskUnitsConverter mask_converter; - mask_converter.convertToNbins(this); - - GUI::Model::DataItemUtil::updateDataAxes(this, converter); - - mask_converter.convertFromNbins(this); -} - std::vector<int> IntensityDataItem::shape() const { return {xSize(), ySize()}; diff --git a/GUI/Model/Data/IntensityDataItem.h b/GUI/Model/Data/IntensityDataItem.h index ae231587a22de5416359a0cb00ceac7095fc3839..a6c0bed138da0e3485c3475153886c943ab859a9 100644 --- a/GUI/Model/Data/IntensityDataItem.h +++ b/GUI/Model/Data/IntensityDataItem.h @@ -90,9 +90,6 @@ public: bool hasMasks() const; bool hasProjections() const; - //! Updates data on the change of axes units - void updateCoords(const ICoordSystem& converter) override; - //! Returns dimensions and axesbins of data std::vector<int> shape() const override; diff --git a/GUI/Model/Data/SpecularDataItem.cpp b/GUI/Model/Data/SpecularDataItem.cpp index c97c9e54149c9977fbcb85f0258b3e28b328ac16..a0023423f32021fc6b83bc763d96caf0754858c7 100644 --- a/GUI/Model/Data/SpecularDataItem.cpp +++ b/GUI/Model/Data/SpecularDataItem.cpp @@ -13,9 +13,9 @@ // ************************************************************************************************ #include "GUI/Model/Data/SpecularDataItem.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" #include "Base/Util/Assert.h" -#include "Device/Coord/ICoordSystem.h" #include "Device/Data/Datafield.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" @@ -108,11 +108,6 @@ void SpecularDataItem::setLog(bool islog) yAxisItem()->setLogScale(islog); } -void SpecularDataItem::updateCoords(const ICoordSystem& converter) -{ - GUI::Model::DataItemUtil::updateDataAxes(this, converter); -} - std::vector<int> SpecularDataItem::shape() const { return {xSize()}; diff --git a/GUI/Model/Data/SpecularDataItem.h b/GUI/Model/Data/SpecularDataItem.h index e7f410ff4e8eaeb4e8e94b794663702e129e08e1..cc3c744ff0bdaf791ee83471411d1601a10b6cae 100644 --- a/GUI/Model/Data/SpecularDataItem.h +++ b/GUI/Model/Data/SpecularDataItem.h @@ -42,9 +42,6 @@ public: bool isLog() const; void setLog(bool islog); - //! Updates data on the change of axes units - void updateCoords(const ICoordSystem&) override; - //! Returns dimensions and axesbins of data std::vector<int> shape() const override; diff --git a/GUI/Model/Descriptor/VectorProperty.cpp b/GUI/Model/Descriptor/VectorProperty.cpp index 19284322a2365729fd81008b69be8581cb84c305..c08e93192bf80cb68aba9fd0d55aaf7bcaf32627 100644 --- a/GUI/Model/Descriptor/VectorProperty.cpp +++ b/GUI/Model/Descriptor/VectorProperty.cpp @@ -42,7 +42,7 @@ void VectorProperty::init(const QString& label, const QString& tooltip, const R3 m_x.init("x", tooltip, value.x(), unit, decimals, step, limits, uidPrefix); m_y.init("y", tooltip, value.y(), unit, decimals, step, limits, uidPrefix); - m_z.init("z", tooltip, value.z(), unit, decimals, step, limits, uidPrefix); + m_z.init("z (nm)", tooltip, value.z(), unit, decimals, step, limits, uidPrefix); QString uid; if (uidPrefix.size() > 0) diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp index 964a36257912dd37b152fef6ba53f2a4fdf89461..b02207acee9a004aeb71fac7af7657daa92d052a 100644 --- a/GUI/Model/Device/InstrumentItems.cpp +++ b/GUI/Model/Device/InstrumentItems.cpp @@ -13,13 +13,12 @@ // ************************************************************************************************ #include "GUI/Model/Device/InstrumentItems.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" #include "Base/Const/Units.h" #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" #include "Device/Beam/IFootprint.h" -#include "Device/Coord/CoordSystem1D.h" -#include "Device/Coord/CoordSystem2D.h" #include "Device/Data/Datafield.h" #include "Device/Detector/OffspecDetector.h" #include "GUI/Model/Axis/PointwiseAxisItem.h" @@ -37,7 +36,6 @@ #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Device/RealItem.h" #include "GUI/Model/Sample/SampleItem.h" -#include "GUI/Support/Util/CoordName.h" #include "GUI/Support/XML/Backup.h" #include "Param/Distrib/Distributions.h" #include "Sample/Multilayer/MultiLayer.h" @@ -374,8 +372,8 @@ void SpecularInstrumentItem::updateToRealData(const RealItem* item) throw std::runtime_error("Specular instrument type is incompatible with passed data shape"); const auto& data = item->nativeDatafield()->axis(0); - std::unique_ptr<const ICoordSystem> converter = createCoordSystem(); - scanItem()->updateToData(data, item->nativeDataUnits(), *converter); + std::unique_ptr<const Frame> frame = makeFrame(); + scanItem()->updateToData(data, item->nativeDataUnits(), *frame); } bool SpecularInstrumentItem::alignedWith(const RealItem* item) const @@ -408,34 +406,33 @@ bool SpecularInstrumentItem::alignedWith(const RealItem* item) const return *instrumentAxis == native_axis; } -std::unique_ptr<const ICoordSystem> SpecularInstrumentItem::createCoordSystem() const +std::unique_ptr<const Frame> SpecularInstrumentItem::makeFrame() const { auto* axis_item = scanItem()->inclinationAxisItem(); if (auto* pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) { if (!pointwise_axis->axis()) // workaround for loading project return nullptr; - Coords native_units = - GUI::Util::CoordName::coordFromName(pointwise_axis->nativeAxisUnits()); - return std::make_unique<AngularReflectometryCoords>(scanItem()->wavelength(), - *pointwise_axis->axis(), native_units); + Scale* ax0 = pointwise_axis->axis()->clone(); + std::vector<const Scale*> f{ax0}; + return std::make_unique<Frame>(std::move(f)); } Scale axis = EquiDivision(axis_item->title().toStdString(), axis_item->binCount(), axis_item->min(), axis_item->max()); - return std::make_unique<AngularReflectometryCoords>(scanItem()->wavelength(), axis, - Coords::DEGREES); + std::vector<const Scale*> f{axis.clone()}; + return std::make_unique<Frame>(std::move(f)); } ISimulation* SpecularInstrumentItem::createSimulation(const MultiLayer& sample) const { BasicAxisItem* const axis_item = scanItem()->inclinationAxisItem(); - const auto converter = createCoordSystem(); - std::unique_ptr<Scale> converted_axis(converter->convertedAxis(0, Coords::DEGREES)); + const auto frame = makeFrame(); + const Scale& ax = frame->axis(0); - std::unique_ptr<Scale> axis = axis_item->itemToAxis(Units::deg, *converted_axis); + std::unique_ptr<Scale> axis = axis_item->itemToAxis(Units::deg, ax); std::unique_ptr<IBeamScan> scan = createScan(*axis); if (withPolarizer()) scan->setPolarization(m_polarizerBlochVector); @@ -514,7 +511,7 @@ void DepthprobeInstrumentItem::updateToRealData(const RealItem*) ASSERT(false); } -std::unique_ptr<const ICoordSystem> DepthprobeInstrumentItem::createCoordSystem() const +std::unique_ptr<const Frame> DepthprobeInstrumentItem::makeFrame() const { // TODO the approach to changing units should be changed // https://jugit.fz-juelich.de/mlz/bornagain/-/issues/478 @@ -524,7 +521,7 @@ std::unique_ptr<const ICoordSystem> DepthprobeInstrumentItem::createCoordSystem( std::unique_ptr<Scale> axis = axis_item->itemToRegularAxis(Units::deg); std::vector<const Scale*> axes({axis.release(), m_zAxis.createAxis(1.)->clone()}); - return std::make_unique<DepthprobeCoords>(std::move(axes), (2 * pi) / scanItem()->wavelength()); + return std::make_unique<Frame>(std::move(axes)); } ISimulation* DepthprobeInstrumentItem::createSimulation(const MultiLayer& sample) const @@ -614,11 +611,11 @@ void OffspecInstrumentItem::updateToRealData(const RealItem* dataItem) detectorItem()->setYSize(data_shape[1]); } -std::unique_ptr<const ICoordSystem> OffspecInstrumentItem::createCoordSystem() const +std::unique_ptr<const Frame> OffspecInstrumentItem::makeFrame() const { BasicAxisItem* const axis_item = scanItem()->inclinationAxisItem(); std::unique_ptr<Scale> axis = axis_item->itemToRegularAxis(Units::deg); - return std::make_unique<OffspecCoords>(std::vector<const Scale*>{ + return std::make_unique<Frame>(std::vector<const Scale*>{ axis.release(), detectorItem()->createOffspecDetector()->axis(1).clone()}); } @@ -717,10 +714,10 @@ void GISASInstrumentItem::updateToRealData(const RealItem* item) detectorItem()->setYSize(data_shape[1]); } -std::unique_ptr<const ICoordSystem> GISASInstrumentItem::createCoordSystem() const +std::unique_ptr<const Frame> GISASInstrumentItem::makeFrame() const { - std::unique_ptr<const ICoordSystem> result; - result.reset(normalDetector()->scatteringCoords(*beamItem()->createBeam())); + std::unique_ptr<const Frame> result; + result.reset(normalDetector()->scatteringCoords()); return result; } diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h index e7e07fd4c8169eb63f73cb15679e66c2b4bec5f8..81e2a5a40380c4c6b16f1c938d9c8720e81e7cf3 100644 --- a/GUI/Model/Device/InstrumentItems.h +++ b/GUI/Model/Device/InstrumentItems.h @@ -28,15 +28,15 @@ class BackgroundItem; class BeamItem; class DataItem; class DepthprobeSimulation; -class Scale; +class Frame; class IBeamScan; -class ICoordSystem; class ISimulation; class MaskContainerItem; class MultiLayer; class OffspecDetectorItem; class OffspecSimulation; class RealItem; +class Scale; class ScanItem; class ScatteringSimulation; class SphericalDetectorItem; @@ -57,7 +57,7 @@ public: virtual bool alignedWith(const RealItem* item) const; - virtual std::unique_ptr<const ICoordSystem> createCoordSystem() const = 0; + virtual std::unique_ptr<const Frame> makeFrame() const = 0; virtual ISimulation* createSimulation(const MultiLayer& sample) const = 0; @@ -157,7 +157,7 @@ public: std::vector<int> shape() const override; void updateToRealData(const RealItem* item) override; bool alignedWith(const RealItem* item) const override; - std::unique_ptr<const ICoordSystem> createCoordSystem() const override; + std::unique_ptr<const Frame> makeFrame() const override; ISimulation* createSimulation(const MultiLayer& sample) const override; void writeTo(QXmlStreamWriter* w) const override; @@ -172,7 +172,7 @@ public: QString instrumentType() const override { return "Depth probe"; } std::vector<int> shape() const override; void updateToRealData(const RealItem* item) override; - std::unique_ptr<const ICoordSystem> createCoordSystem() const override; + std::unique_ptr<const Frame> makeFrame() const override; ISimulation* createSimulation(const MultiLayer& sample) const override; void writeTo(QXmlStreamWriter* w) const override; void readFrom(QXmlStreamReader* r) override; @@ -191,7 +191,7 @@ public: QString instrumentType() const override { return "Off specular"; } std::vector<int> shape() const override; void updateToRealData(const RealItem* item) override; - std::unique_ptr<const ICoordSystem> createCoordSystem() const override; + std::unique_ptr<const Frame> makeFrame() const override; ISimulation* createSimulation(const MultiLayer& sample) const override; void writeTo(QXmlStreamWriter* w) const override; void readFrom(QXmlStreamReader* r) override; @@ -210,7 +210,7 @@ public: QString instrumentType() const override { return "GISAS"; } std::vector<int> shape() const override; void updateToRealData(const RealItem* item) override; - std::unique_ptr<const ICoordSystem> createCoordSystem() const override; + std::unique_ptr<const Frame> makeFrame() const override; ISimulation* createSimulation(const MultiLayer& sample) const override; void writeTo(QXmlStreamWriter* w) const override; void readFrom(QXmlStreamReader* r) override; diff --git a/GUI/Model/Device/InstrumentNotifier.cpp b/GUI/Model/Device/InstrumentNotifier.cpp index ef62df6f88003cf6139c0a87f455236ec880b96d..deb64d79e0fd16502a866e35e55b2611272406e9 100644 --- a/GUI/Model/Device/InstrumentNotifier.cpp +++ b/GUI/Model/Device/InstrumentNotifier.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/Model/Device/InstrumentNotifier.h" -#include "Device/Coord/ICoordSystem.h" +#include "Base/Axis/Frame.h" #include "GUI/Model/Axis/PointwiseAxisItem.h" #include "GUI/Model/Beam/SourceItems.h" #include "GUI/Model/Device/InstrumentItems.h" @@ -40,8 +40,8 @@ void InstrumentNotifier::notifyWavelengthDistributionChanged() // Update values in pointwise axis. This is necessary after a change of the mean wavelength. if (auto* iiI = dynamic_cast<SpecularInstrumentItem*>(m_instrumentItem)) { if (auto* pw = dynamic_cast<PointwiseAxisItem*>(iiI->scanItem()->inclinationAxisItem())) { - std::unique_ptr<const ICoordSystem> converter = m_instrumentItem->createCoordSystem(); - pw->updateAxIndicators(*converter); + std::unique_ptr<const Frame> frame = m_instrumentItem->makeFrame(); + pw->updateAxIndicators(*frame); } } diff --git a/GUI/Model/Device/RealItem.cpp b/GUI/Model/Device/RealItem.cpp index 8bcbf99deebcef0120ace3a84627973a4032ef2c..ac1d9d89ff1058083117388f1277aa944763ac98 100644 --- a/GUI/Model/Device/RealItem.cpp +++ b/GUI/Model/Device/RealItem.cpp @@ -14,7 +14,6 @@ #include "GUI/Model/Device/RealItem.h" #include "Base/Axis/Scale.h" -#include "Device/Coord/ICoordSystem.h" #include "Device/Data/DataUtil.h" #include "Device/Data/Datafield.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h" @@ -443,14 +442,8 @@ void RealItem::updateToInstrument(const InstrumentItem* instrument) if (!data_item) return; - if (instrument) { - // To keep the same units after linking, just comment lines. - // To switch to certain units on linking, uncomment lines. - // dataItem()->setCurrentCoord(Coords::DEGREES); - // const auto converter = instrument->createCoordSystem(); - // dataItem()->updateCoords(*converter); + if (instrument) return; - } // instrument == nullptr => unlinking => going back to native data if (isSpecularData()) { diff --git a/GUI/Model/Device/RealItem.h b/GUI/Model/Device/RealItem.h index 62627743c1be0bd08253c115401b11547c3405d6..7379c46f9e86c28bd061c3373a9054fd0bd6d42d 100644 --- a/GUI/Model/Device/RealItem.h +++ b/GUI/Model/Device/RealItem.h @@ -134,7 +134,7 @@ private: At the moment of loading file to RealItem "data" and "native_data" are completely equal. But after linking RealItem to instrument and changing the current units the axis of "data" is changed. When we unlink RealItem from instrument, we restore the original axis from - "native_data", because now there is no other way to transform axis without ICoordSystem + "native_data", because now there is no other way to transform axis without Frame coming from instrument. */ std::unique_ptr<DataItem> m_dataItem; diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 6b6cdda69241440bb7e13688ab74913c8eeb4c50..e6efb5d200ac5d4e96b62ae4bcaafc3a0d7a13db 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/Model/Job/JobItem.h" -#include "Device/Coord/ICoordSystem.h" +#include "Base/Axis/Frame.h" #include "Device/Data/Datafield.h" #include "Device/Detector/SimulationAreaIterator.h" // roiIndex #include "GUI/Model/Data/DataItemUtil.h" @@ -293,19 +293,6 @@ void JobItem::createSimulatedDataItem() { ASSERT(!simulatedDataItem()); m_simulatedDataItem.reset(createNewDataItem()); - - // Set default axes units for simulated data. - // Can be overriden by units from RealItem - if (instrumentItem()->is<SpecularInstrumentItem>()) - m_simulatedDataItem->setCurrentCoord(Coords::QSPACE); - else if (instrumentItem()->is<GISASInstrumentItem>()) - m_simulatedDataItem->setCurrentCoord(Coords::QSPACE); - else if (instrumentItem()->is<OffspecInstrumentItem>()) - m_simulatedDataItem->setCurrentCoord(Coords::DEGREES); // Coords::QSPACE is unsupported - else if (instrumentItem()->is<DepthprobeInstrumentItem>()) - m_simulatedDataItem->setCurrentCoord(Coords::QSPACE); - else - ASSERT(false); } IntensityDataItem* JobItem::intensityDataItem() @@ -325,13 +312,12 @@ DataItem* JobItem::createDiffDataItem() // use the same axes units as for real data ASSERT(m_realItem); - Coords coords = m_realItem->dataItem()->currentCoord(); - m_diffDataItem->setCurrentCoord(coords); + // TODO // update axes labels - const auto converter = instrumentItem()->createCoordSystem(); - ASSERT(converter); - GUI::Model::DataItemUtil::updateAxesTitle(diffDataItem(), *converter, coords); + const auto frame = instrumentItem()->makeFrame(); + ASSERT(frame); + GUI::Model::DataItemUtil::updateAxesTitle(diffDataItem(), *frame); if (isSpecularJob()) dynamic_cast<SpecularDataItem*>(diffDataItem())->setDiffPlotStyle(); @@ -358,7 +344,7 @@ void JobItem::copyRealItemIntoJob(const RealItem* srcRealItem) // override axes units of simulated data ASSERT(m_simulatedDataItem); - m_simulatedDataItem->setCurrentCoord(m_realItem->dataItem()->currentCoord()); + // m_simulatedDataItem->setCurrentCoord(m_realItem->dataItem()->currentCoord()); if (isSpecularJob()) m_realItem->specularDataItem()->setRealPlotStyle(); @@ -376,22 +362,11 @@ void JobItem::adjustReaDataToJobInstrument() if (instrumentItem()->is<GISASInstrumentItem>()) { // Temporary conversion of real units to degrees before copying masks to instrument. - // It is not clear why we need to do this, but otherwise the result is incorrect. - // Seems that degrees are default units in detector, so we should use the same units here, - // but if we change 'converter->defaultUnits()' to, for example, radians, here we still - // should use 'Coords::DEGREES'. So the reason lies deeper. - Coords backup_coord = m_realItem->dataItem()->currentCoord(); - m_realItem->dataItem()->setCurrentCoord(Coords::DEGREES); - const auto converter = instrumentItem()->createCoordSystem(); - realItem()->dataItem()->updateCoords(*converter); + // It is not clear why we need to do this ... and whether it still works + const auto frame = instrumentItem()->makeFrame(); importMasksFromRealItem(); // Copy masks and ROI from RealItem on board of instrument. - - // convert units back - m_realItem->dataItem()->setCurrentCoord(backup_coord); - realItem()->dataItem()->updateCoords(*converter); - - cropRealData(); // Crop RealItem to the region of interest. + cropRealData(); // Crop RealItem to the region of interest. } } @@ -413,11 +388,11 @@ void JobItem::cropRealData() std::unique_ptr<Datafield> origData(intensityItem->c_field()->clone()); - const auto converter = iiI->createCoordSystem(); - ASSERT(converter); + const auto frame = iiI->makeFrame(); + ASSERT(frame); // (re)create zero-valued Datafield. Axes are derived from the current units - GUI::Model::DataItemUtil::createDefaultDetectorMap(intensityItem, *converter); + GUI::Model::DataItemUtil::createDefaultDetectorMap(intensityItem, *frame); iiI->normalDetector()->iterateOverNonMaskedPoints([&](IDetector::const_iterator it) { Datafield* cropped_data = intensityItem->p_field(); diff --git a/GUI/Support/Util/CoordName.cpp b/GUI/Support/Util/CoordName.cpp deleted file mode 100644 index 4440d717907cb84b56e3628742f37eecbd22af2e..0000000000000000000000000000000000000000 --- a/GUI/Support/Util/CoordName.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Support/Util/CoordName.cpp -//! @brief Implements namespace GUI::Util::CoordName -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/Support/Util/CoordName.h" -#include <map> - -//! Correspondence of domain detector axes types to their GUI counterpart. - -QString GUI::Util::CoordName::nameFromCoord(Coords units) -{ - static const std::map<Coords, QString> names_from_coords{{Coords::NBINS, "nbins"}, - {Coords::RADIANS, "Radians"}, - {Coords::MM, "mm"}, - {Coords::QSPACE, "q-space"}, - {Coords::DEGREES, "Degrees"}}; - const auto it = names_from_coords.find(units); - if (it == names_from_coords.end()) - return ""; - return it->second; -} - -//! Correspondence of GUI axes units names to their domain counterpart. - -Coords GUI::Util::CoordName::coordFromName(const QString& name) -{ - static const std::map<QString, Coords> units_from_names{{"nbins", Coords::NBINS}, - {"Radians", Coords::RADIANS}, - {"Degrees", Coords::DEGREES}, - {"mm", Coords::MM}, - {"q-space", Coords::QSPACE}}; - return units_from_names.at(name); -} diff --git a/GUI/Support/Util/CoordName.h b/GUI/Support/Util/CoordName.h deleted file mode 100644 index 16456fd20b6b3db155974024c298f0040d242c49..0000000000000000000000000000000000000000 --- a/GUI/Support/Util/CoordName.h +++ /dev/null @@ -1,33 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Support/Util/CoordName.h -//! @brief Defines namespace GUI::Util::CoordName -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_SUPPORT_UTIL_COORDNAME_H -#define BORNAGAIN_GUI_SUPPORT_UTIL_COORDNAME_H - -#include "Device/Coord/Tags.h" -#include <QString> - -//! Conversions between enum and QString. - -namespace GUI::Util::CoordName { - -//! Returns axes units names from their domain counterpart -QString nameFromCoord(Coords units); - -//! Returns domain axes units type from their GUI name -Coords coordFromName(const QString& name); - -} // namespace GUI::Util::CoordName - -#endif // BORNAGAIN_GUI_SUPPORT_UTIL_COORDNAME_H diff --git a/GUI/View/Common/DataPropertyWidget.cpp b/GUI/View/Common/DataPropertyWidget.cpp index 0c1337871f998ef334bd88792ce21bc863169ece..25735950106fa6f21e053cb0d20b57f76045cfdc 100644 --- a/GUI/View/Common/DataPropertyWidget.cpp +++ b/GUI/View/Common/DataPropertyWidget.cpp @@ -13,13 +13,12 @@ // ************************************************************************************************ #include "GUI/View/Common/DataPropertyWidget.h" +#include "Base/Axis/Frame.h" #include "Base/Util/Assert.h" -#include "Device/Coord/ICoordSystem.h" #include "GUI/Model/Data/DataItem.h" #include "GUI/Model/Data/DataItemUtil.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Project/ProjectDocument.h" -#include "GUI/Support/Util/CoordName.h" #include <QFormLayout> DataPropertyWidget::DataPropertyWidget(QWidget* parent) @@ -45,8 +44,6 @@ void DataPropertyWidget::updateItemCoords(DataItem* item) if (instrumentItem()) { item->blockSignals(true); - const auto converter = instrumentItem()->createCoordSystem(); - item->updateCoords(*converter); item->blockSignals(false); emit item->axesUnitsReplotRequested(); } @@ -73,17 +70,3 @@ InstrumentItem* DataPropertyWidget::instrumentItem() ASSERT(false); return nullptr; } - -QStringList DataPropertyWidget::axesUnitsList() -{ - QStringList list; - if (!instrumentItem()) { - ASSERT(realItem()); - list << realItem()->dataItem()->currentAxesUnits(); - } else { - const auto converter = instrumentItem()->createCoordSystem(); - ASSERT(converter); - list = GUI::Model::DataItemUtil::availableUnits(*converter); - } - return list; -} diff --git a/GUI/View/Common/DataPropertyWidget.h b/GUI/View/Common/DataPropertyWidget.h index 9984ac9ecc37dc8c8b98f17c8b107d01118f7c33..c9125ddad6653cfc53006d4a35254f95e9c0acfe 100644 --- a/GUI/View/Common/DataPropertyWidget.h +++ b/GUI/View/Common/DataPropertyWidget.h @@ -37,7 +37,6 @@ protected: virtual void createPanelElements() = 0; InstrumentItem* instrumentItem(); - QStringList axesUnitsList(); QFormLayout* m_mainLayout; QList<std::function<void()>> m_updaters; diff --git a/GUI/View/Common/IntensityDataPropertyWidget.cpp b/GUI/View/Common/IntensityDataPropertyWidget.cpp index bb9f8f9b2e44b7fbb9daef5977c0cedbf68da088..f1ff5994ba306a406f6f5a998cecb12ef1ddcc8b 100644 --- a/GUI/View/Common/IntensityDataPropertyWidget.cpp +++ b/GUI/View/Common/IntensityDataPropertyWidget.cpp @@ -50,6 +50,7 @@ void IntensityDataPropertyWidget::createPanelElements() GUI::Util::Layout::clearLayout(m_mainLayout); m_updaters.clear(); + /* m_mainLayout->addRow("Axes units:", GUI::Util::createUnitsComboBox( axesUnitsList(), @@ -61,6 +62,7 @@ void IntensityDataPropertyWidget::createPanelElements() gProjectDocument.value()->setModified(); }, &m_updaters)); + */ m_mainLayout->addRow( "Color scheme:", @@ -210,7 +212,9 @@ void IntensityDataPropertyWidget::createPanelElements() &IntensityDataPropertyWidget::updateUIValues, Qt::UniqueConnection); // update coordinates on axes units change + /* for (auto item : allIntensityDataItems()) connect(item, &DataItem::axesUnitsChanged, this, &IntensityDataPropertyWidget::updateItemCoords, Qt::UniqueConnection); + */ } diff --git a/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp b/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp index 79f2090d5f4503853fa6c1e216dbb0256811863c..d752927085d664b0e7207a36486bf79189548839 100644 --- a/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp +++ b/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp @@ -42,6 +42,7 @@ void SpecularDataPropertyWidget::createPanelElements() GUI::Util::Layout::clearLayout(m_mainLayout); m_updaters.clear(); + /* m_mainLayout->addRow("Axes units:", GUI::Util::createUnitsComboBox( axesUnitsList(), @@ -53,6 +54,7 @@ void SpecularDataPropertyWidget::createPanelElements() gProjectDocument.value()->setModified(); }, &m_updaters)); + */ // -- x-axis auto* xGroup = new QGroupBox("X axis", this); diff --git a/Resample/Element/SpecularElement.cpp b/Resample/Element/SpecularElement.cpp index 06e61781bcc9d87edf420b2287c00446867c6321..be13161aa15ba55491f5999c8fa4183cd0763e4c 100644 --- a/Resample/Element/SpecularElement.cpp +++ b/Resample/Element/SpecularElement.cpp @@ -13,49 +13,16 @@ // ************************************************************************************************ #include "Resample/Element/SpecularElement.h" -#include "Base/Vector/GisasDirection.h" -#include "Resample/Slice/KzComputation.h" - -SpecularElement SpecularElement::FromQzScan(size_t i_out, double weight, double kz, - const SpinMatrix& polarizer, const SpinMatrix& analyzer, - bool computable) -{ - return {i_out, computable, weight, 1, polarizer, analyzer, [kz](const SliceStack& slices) { - return Compute::Kz::computeKzFromSLDs(slices, kz); - }}; -} - -SpecularElement SpecularElement::FromAlphaScan(size_t i_out, double weight, double wavelength, - double alpha, double footprint, - const SpinMatrix& polarizer, - const SpinMatrix& analyzer, bool computable) -{ - return {i_out, - computable, - weight, - footprint, - polarizer, - analyzer, - [k = vecOfLambdaAlphaPhi(wavelength, alpha)](const SliceStack& slices) { - return Compute::Kz::computeKzFromRefIndices(slices, k); - }}; -} SpecularElement::SpecularElement(size_t i_out, bool computable, double weight, double footprint, - const SpinMatrix& polarizer, const SpinMatrix& analyzer, - std::function<std::vector<complex_t>(const SliceStack&)> kz_comp) + const SpinMatrix& polarizer, const SpinMatrix& analyzer, R3 k) : IElement(polarizer, analyzer) , m_i_out(i_out) + , m_computable(computable) , m_weight(weight) , m_footprint(footprint) - , m_computable(computable) - , m_kz_computation(kz_comp) + , m_k(k) { } SpecularElement::~SpecularElement() = default; - -std::vector<complex_t> SpecularElement::produceKz(const SliceStack& slices) -{ - return m_kz_computation(slices); -} diff --git a/Resample/Element/SpecularElement.h b/Resample/Element/SpecularElement.h index facdc28c8b050db890a8c27ca74923a4d6ac2ce9..94da26f3a11655ea7961d4ba5dffc74e5e217cce 100644 --- a/Resample/Element/SpecularElement.h +++ b/Resample/Element/SpecularElement.h @@ -31,13 +31,8 @@ class SliceStack; class SpecularElement : public IElement { public: - static SpecularElement FromQzScan(size_t i_out, double weight, double kz, - const SpinMatrix& polarizer, const SpinMatrix& analyzer, - bool computable); - static SpecularElement FromAlphaScan(size_t i_out, double weight, double wavelength, - double alpha, double footprint, - const SpinMatrix& polarizer, const SpinMatrix& analyzer, - bool computable); + SpecularElement(size_t i_out, bool computable, double weight, double footprint, + const SpinMatrix& polarizer, const SpinMatrix& analyzer, R3 k); SpecularElement(const SpecularElement& other) = delete; SpecularElement(SpecularElement&& other) noexcept = default; @@ -51,19 +46,14 @@ public: //! Returns calculation flag (if it's false, zero intensity is assigned to the element) bool isCalculated() const { return m_computable; } - //! Returns kz values for Abeles computation of reflection/transition coefficients - std::vector<complex_t> produceKz(const SliceStack& slices); + R3 k() { return m_k; } private: - SpecularElement(size_t i_out, bool computable, double weight, double footprint, - const SpinMatrix& polarizer, const SpinMatrix& analyzer, - std::function<std::vector<complex_t>(const SliceStack&)> kz_comp); - - size_t m_i_out; //!< index in scan, designates the channel to which this element contributes - double m_weight; - double m_footprint; + const size_t m_i_out; //!< index in scan -> the channel to which this element contributes const bool m_computable; - const std::function<std::vector<complex_t>(const SliceStack&)> m_kz_computation; + const double m_weight; + const double m_footprint; + const R3 m_k; }; #endif // BORNAGAIN_RESAMPLE_ELEMENT_SPECULARELEMENT_H diff --git a/Sim/Fitting/FitObjective.cpp b/Sim/Fitting/FitObjective.cpp index 8de498271eec2448d86dadc8b99a3cf0c3c1460a..f65ac12fde5b3b53c620b9b413b6d379648f902d 100644 --- a/Sim/Fitting/FitObjective.cpp +++ b/Sim/Fitting/FitObjective.cpp @@ -216,14 +216,14 @@ SimulationResult FitObjective::uncertaintyData(size_t i_item) const //! Returns relative difference between simulation and experimental data //! in the form of SimulationResult. -std::vector<double> FitObjective::relativeDifference(size_t i_item) const +SimulationResult FitObjective::relativeDifference(size_t i_item) const { return dataPair(i_item).relativeDifference(); } //! Returns absolute value of difference between simulation and experimental data //! in the form of SimulationResult. -std::vector<double> FitObjective::absoluteDifference(size_t i_item) const +SimulationResult FitObjective::absoluteDifference(size_t i_item) const { return dataPair(i_item).absoluteDifference(); } diff --git a/Sim/Fitting/FitObjective.h b/Sim/Fitting/FitObjective.h index 0d8eac05d33565373ac42820582fdd85f0c5715d..b0027ee427403df72d88d08bc16db04bd0c3a8b6 100644 --- a/Sim/Fitting/FitObjective.h +++ b/Sim/Fitting/FitObjective.h @@ -76,8 +76,8 @@ public: SimulationResult simulationResult(size_t i_item = 0) const; SimulationResult experimentalData(size_t i_item = 0) const; SimulationResult uncertaintyData(size_t i_item = 0) const; - std::vector<double> relativeDifference(size_t i_item = 0) const; - std::vector<double> absoluteDifference(size_t i_item = 0) const; + SimulationResult relativeDifference(size_t i_item = 0) const; + SimulationResult absoluteDifference(size_t i_item = 0) const; std::vector<double> experimental_array() const; std::vector<double> simulation_array() const; diff --git a/Sim/Fitting/SimDataPair.cpp b/Sim/Fitting/SimDataPair.cpp index eb3c4e8865a238fd5564225774f9d2488d4c4a55..a7f941b6f01e4f9c87c9507c102591efd6897bcd 100644 --- a/Sim/Fitting/SimDataPair.cpp +++ b/Sim/Fitting/SimDataPair.cpp @@ -17,7 +17,6 @@ #include "Base/Axis/Scale.h" #include "Base/Math/Numeric.h" #include "Base/Util/Assert.h" -#include "Device/Coord/ICoordSystem.h" #include "Device/Data/Datafield.h" #include "Device/Detector/IDetector.h" #include "Device/Detector/SimulationAreaIterator.h" // roiIndex @@ -52,8 +51,8 @@ bool haveSameSizes(const IDetector& detector, const Datafield& data) SimulationResult convertData(const ScatteringSimulation& simulation, const Datafield& data) { - const ICoordSystem* coordSystem = simulation.simCoordSystem(); - auto roi_data = std::make_unique<Datafield>(coordSystem->defaultAxes()); + const Frame* coordSystem = simulation.simCoordSystem(); + auto roi_data = std::make_unique<Datafield>(coordSystem->clonedAxes()); if (roi_data->frame().hasSameSizes(data.frame())) { // data is already cropped to ROI @@ -123,18 +122,18 @@ void SimDataPair::execSimulation(const mumufit::Parameters& params) m_user_weights = std::make_unique<SimulationResult>(convertData(*sim2d, *m_raw_user_weights)); } else { - const ICoordSystem& converter = m_sim_data->converter(); - m_exp_data = std::make_unique<SimulationResult>(*m_raw_data, converter.clone()); - m_user_weights = std::make_unique<SimulationResult>(*m_raw_user_weights, converter.clone()); + const Frame& frame = m_sim_data->frame(); + m_exp_data = std::make_unique<SimulationResult>(*m_raw_data, frame.clone()); + m_user_weights = std::make_unique<SimulationResult>(*m_raw_user_weights, frame.clone()); } if (sim2d && containsUncertainties()) m_uncertainties = std::make_unique<SimulationResult>(convertData(*sim2d, *m_raw_uncertainties)); else { - const ICoordSystem& converter = m_sim_data->converter(); - auto dummy_array = std::make_unique<Datafield>(converter.defaultAxes()); - m_uncertainties = std::make_unique<SimulationResult>(*dummy_array, converter.clone()); + const Frame& frame = m_sim_data->frame(); + auto dummy_array = std::make_unique<Datafield>(frame.clonedAxes()); + m_uncertainties = std::make_unique<SimulationResult>(*dummy_array, frame.clone()); } } @@ -194,7 +193,7 @@ std::vector<double> SimDataPair::user_weights_array() const //! Returns relative difference between simulation and experimental data. -std::vector<double> SimDataPair::relativeDifference() const +SimulationResult SimDataPair::relativeDifference() const { size_t N = m_sim_data->size(); if (!N) @@ -202,14 +201,16 @@ std::vector<double> SimDataPair::relativeDifference() const if (!m_exp_data || m_exp_data->size() != N) throw std::runtime_error("Different data shapes => won't compute relative difference"); - std::vector<double> result(N, 0.); + std::vector<double> data(N, 0.); for (size_t i = 0; i < N; ++i) - result[i] = Numeric::relativeDifference(result[i], (*m_exp_data)[i]); + data[i] = Numeric::relativeDifference((*m_sim_data)[i], (*m_exp_data)[i]); - return result; + const Frame* f = m_sim_data->frame().clone(); + Datafield df(f, data); + return {df, f}; } -std::vector<double> SimDataPair::absoluteDifference() const +SimulationResult SimDataPair::absoluteDifference() const { size_t N = m_sim_data->size(); if (!N) @@ -217,11 +218,13 @@ std::vector<double> SimDataPair::absoluteDifference() const if (!m_exp_data || m_exp_data->size() != N) throw std::runtime_error("Different data shapes => won't compute absolute difference"); - std::vector<double> result(N, 0.); + std::vector<double> data(N, 0.); for (size_t i = 0; i < N; ++i) - result[i] = std::abs(result[i] - (*m_exp_data)[i]); + data[i] = std::abs((*m_sim_data)[i] - (*m_exp_data)[i]); - return result; + const Frame* f = m_sim_data->frame().clone(); + Datafield df(f, data); + return {df, f}; } void SimDataPair::validate() const diff --git a/Sim/Fitting/SimDataPair.h b/Sim/Fitting/SimDataPair.h index 166fa93bc7154088a9514652ad9acd3ee873aef6..26afefe108a8dc799737e8334ae4b590c0231510 100644 --- a/Sim/Fitting/SimDataPair.h +++ b/Sim/Fitting/SimDataPair.h @@ -56,11 +56,11 @@ public: //! Returns the relative difference between simulated //! and experimental data cut to the ROI area - std::vector<double> relativeDifference() const; + SimulationResult relativeDifference() const; //! Returns the absolute difference between simulated //! and experimental data cut to the ROI area - std::vector<double> absoluteDifference() const; + SimulationResult absoluteDifference() const; //! Returns the flattened simulated intensities cut to the ROI area std::vector<double> simulation_array() const; diff --git a/Sim/Scan/AlphaScan.cpp b/Sim/Scan/AlphaScan.cpp index dedac186f017e75413a63d268a49e8ae6aed79c4..293740ba0bd7d4370ec9679ae68b5fe4ffb80a7a 100644 --- a/Sim/Scan/AlphaScan.cpp +++ b/Sim/Scan/AlphaScan.cpp @@ -15,15 +15,15 @@ #include "Sim/Scan/AlphaScan.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" +#include "Base/Vector/GisasDirection.h" #include "Device/Beam/IFootprint.h" -#include "Device/Coord/CoordSystem1D.h" #include "Device/Pol/PolFilter.h" #include "Param/Distrib/Distributions.h" #include "Param/Distrib/ParameterSample.h" #include "Resample/Element/SpecularElement.h" -#include <algorithm> +#include "Resample/Slice/KzComputation.h" +#include <algorithm> // is_sorted #include <numbers> - using std::numbers::pi; namespace { @@ -44,13 +44,13 @@ std::vector<ParameterSample> drawDistribution(const IDistribution1D* distrib) AlphaScan::AlphaScan(const Scale& alpha_axis) - : IBeamScan(alpha_axis.clone(), 0.0) + : IBeamScan(alpha_axis.clone()) { checkInitialization(); } AlphaScan::AlphaScan(int nbins, double alpha_i_min, double alpha_i_max) - : AlphaScan(EquiScan("alpha_i", nbins, alpha_i_min, alpha_i_max)) + : AlphaScan(EquiScan("alpha_i (rad)", nbins, alpha_i_min, alpha_i_max)) { } @@ -91,6 +91,16 @@ std::vector<const INode*> AlphaScan::nodeChildren() const return result; } +double AlphaScan::wavenumber(size_t) const +{ + return 2 * pi / m_lambda0; +} + +double AlphaScan::alpha_i(size_t i) const +{ + return m_axis->binCenter(i); +} + std::vector<SpecularElement> AlphaScan::generateElements() const { std::vector<SpecularElement> result; @@ -103,15 +113,15 @@ std::vector<SpecularElement> AlphaScan::generateElements() const const std::vector<ParameterSample> alphaDistrib = drawDistribution(m_alpha_distrib.get()); const std::vector<ParameterSample> lambdaDistrib = drawDistribution(m_lambda_distrib.get()); for (size_t j = 0; j < alphaDistrib.size(); ++j) { - const double alpha = m_axis->binCenters()[i] + alphaDistrib[j].value + m_alpha_offset; + const double alpha = alpha_i(i) + alphaDistrib[j].value + m_alpha_offset; for (size_t k = 0; k < lambdaDistrib.size(); ++k) { const double lambda = m_lambda_distrib ? lambdaDistrib[k].value : wavelength(); const bool computable = lambda >= 0 && alpha >= 0 && alpha <= (pi / 2); const double weight = alphaDistrib[j].weight * lambdaDistrib[k].weight; const double footprint = m_footprint ? m_footprint->calculate(alpha) : 1; - result.emplace_back(SpecularElement::FromAlphaScan(i, weight, lambda, -alpha, - footprint, polarizerMatrix(), - analyzerMatrix(), computable)); + const R3 veck = vecOfLambdaAlphaPhi(lambda, -alpha); + result.emplace_back(SpecularElement(i, computable, weight, footprint, + polarizerMatrix(), analyzerMatrix(), veck)); } } } @@ -129,7 +139,7 @@ void AlphaScan::setWavelength(double lambda) void AlphaScan::setWavelengthDistribution(const IDistribution1D& distr) { - if (wavelength() != 0) + if (!std::isnan(wavelength())) throw std::runtime_error("AlphaScan does not allow wavelength distribution " "as explicit wavelength has been set"); m_lambda_distrib.reset(distr.clone()); @@ -145,11 +155,6 @@ size_t AlphaScan::nDistributionSamples() const return nResolSamples(m_lambda_distrib.get()) * nResolSamples(m_alpha_distrib.get()); } -CoordSystem1D* AlphaScan::scanCoordSystem() const -{ - return new AngularReflectometryCoords(wavelength(), *coordinateAxis()); -} - void AlphaScan::checkInitialization() { const std::vector<double> axis_values = m_axis->binCenters(); @@ -159,3 +164,8 @@ void AlphaScan::checkInitialization() // TODO: check for inclination angle limits after switching to pointwise resolution. } + +std::vector<complex_t> AlphaScan::produceKz(const SliceStack& slices, R3 k) const +{ + return Compute::Kz::computeKzFromRefIndices(slices, k); +} diff --git a/Sim/Scan/AlphaScan.h b/Sim/Scan/AlphaScan.h index 4a196483537d9f0af151f7870900802107ff8781..e8f37c2f05955da35571b203b4b895adc2f13e23 100644 --- a/Sim/Scan/AlphaScan.h +++ b/Sim/Scan/AlphaScan.h @@ -32,20 +32,21 @@ public: std::string className() const final { return "AlphaScan"; } std::vector<const INode*> nodeChildren() const override; - void setWavelengthDistribution(const IDistribution1D& distr); - void setAngleDistribution(const IDistribution1D& distr); - void setWavelength(double lambda); void setAlphaOffset(double offset) { m_alpha_offset = offset; } + void setWavelengthDistribution(const IDistribution1D& distr); + void setAngleDistribution(const IDistribution1D& distr); + #ifndef SWIG + double wavenumber(size_t i) const override; + double alpha_i(size_t i) const override; + //! Generates simulation elements for specular simulations std::vector<SpecularElement> generateElements() const override; size_t nDistributionSamples() const override; - CoordSystem1D* scanCoordSystem() const override; - // needed for export const IDistribution1D* wavelengthDistribution() const { @@ -56,18 +57,25 @@ public: return m_alpha_distrib.get(); } + double wavelength() const + { + return m_lambda0; + } + double alphaOffset() const { return m_alpha_offset; } -private: - void checkInitialization(); + std::vector<complex_t> produceKz(const SliceStack& slices, R3 k) const override; +private: + double m_lambda0{std::nan("")}; std::unique_ptr<const IDistribution1D> m_lambda_distrib; std::unique_ptr<const IDistribution1D> m_alpha_distrib; - double m_alpha_offset{0}; + + void checkInitialization(); #endif // SWIG }; diff --git a/Sim/Scan/IBeamScan.cpp b/Sim/Scan/IBeamScan.cpp index 1256cb5c46890571087881121b1f1ee91bac2e3a..7fff883de00bc7c206e9f83d0785fee7cd241aaa 100644 --- a/Sim/Scan/IBeamScan.cpp +++ b/Sim/Scan/IBeamScan.cpp @@ -13,15 +13,17 @@ // ************************************************************************************************ #include "Sim/Scan/IBeamScan.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" #include "Base/Spin/SpinMatrix.h" #include "Device/Beam/IFootprint.h" #include "Device/Pol/PolFilter.h" #include <iostream> +#include <numbers> +using std::numbers::pi; -IBeamScan::IBeamScan(Scale* axis, double lambda0) +IBeamScan::IBeamScan(Scale* axis) : m_axis(axis) - , m_lambda0(lambda0) { } @@ -37,11 +39,6 @@ std::vector<const INode*> IBeamScan::nodeChildren() const return result; } -void IBeamScan::setWavelength(double lambda0) -{ - m_lambda0 = lambda0; -} - void IBeamScan::setIntensity(double intensity) { m_intensity = intensity; @@ -71,6 +68,11 @@ void IBeamScan::setFootprint(const IFootprint* footprint) m_footprint.reset(footprint ? footprint->clone() : nullptr); } +double IBeamScan::wavelength(size_t i) const +{ + return 2 * pi / wavenumber(i); +} + size_t IBeamScan::nScan() const { return m_axis->size(); @@ -91,3 +93,8 @@ SpinMatrix IBeamScan::analyzerMatrix() const { return m_polAnalyzer ? m_polAnalyzer->matrix() : SpinMatrix::One(); } + +Frame* IBeamScan::scanCoordSystem() const +{ + return new Frame(coordinateAxis()->clone()); +} diff --git a/Sim/Scan/IBeamScan.h b/Sim/Scan/IBeamScan.h index a2d11236d840fa693c550f0fa245cb929c152bef..e626f5ac0fbd7f045e5d02b615b9fe3ea7e6e373 100644 --- a/Sim/Scan/IBeamScan.h +++ b/Sim/Scan/IBeamScan.h @@ -18,14 +18,16 @@ #include "Base/Types/ICloneable.h" #include "Param/Node/INode.h" #include <cstddef> +#include <heinz/Complex.h> #include <heinz/Vectors3D.h> #include <memory> #include <vector> -class CoordSystem1D; -class Scale; +class Frame; class IFootprint; class PolFilter; +class Scale; +class SliceStack; class SpecularElement; class SpinMatrix; @@ -33,14 +35,12 @@ class SpinMatrix; class IBeamScan : public ICloneable, public INode { public: - IBeamScan(Scale* axis, double lambda0); + IBeamScan(Scale* axis); ~IBeamScan() override; IBeamScan* clone() const override = 0; std::vector<const INode*> nodeChildren() const override; - void setWavelength(double lambda0); - //! Sets the intensity fudge factor void setIntensity(double intensity); @@ -54,16 +54,15 @@ public: void setFootprint(const IFootprint* footprint); #ifndef SWIG + double wavelength(size_t i) const; + virtual double wavenumber(size_t i) const = 0; + virtual double alpha_i(size_t i) const = 0; + const PolFilter* analyzer() const { return m_polAnalyzer.get(); } - double wavelength() const - { - return m_lambda0; - } - double intensity() const { return m_intensity; @@ -87,7 +86,7 @@ public: //! Returns the number of distribution samples virtual size_t nDistributionSamples() const = 0; - virtual CoordSystem1D* scanCoordSystem() const = 0; + Frame* scanCoordSystem() const; bool polarized() const; @@ -96,9 +95,11 @@ public: return m_footprint.get(); } + //! Returns kz values for Abeles computation of reflection/transition coefficients + virtual std::vector<complex_t> produceKz(const SliceStack& slices, R3 k) const = 0; + protected: const std::unique_ptr<const Scale> m_axis; - double m_lambda0; double m_intensity = 1; //!< Fudge factor to adjust for imperfect normalization of exp. data std::unique_ptr<R3> m_beamPolarization; //!< Bloch vector encoding the beam's polarization std::unique_ptr<PolFilter> m_polAnalyzer; diff --git a/Sim/Scan/LambdaScan.cpp b/Sim/Scan/LambdaScan.cpp new file mode 100644 index 0000000000000000000000000000000000000000..145cde63ba092ff8c423ac31061b2556c3f24d78 --- /dev/null +++ b/Sim/Scan/LambdaScan.cpp @@ -0,0 +1,114 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file Sim/Scan/LambdaScan.cpp +//! @brief Implements LambdaScan class. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#include "Sim/Scan/LambdaScan.h" +#include "Base/Axis/MakeScale.h" +#include "Base/Axis/Scale.h" +#include "Base/Util/Assert.h" +#include "Base/Vector/GisasDirection.h" +#include "Device/Pol/PolFilter.h" +#include "Param/Distrib/Distributions.h" +#include "Param/Distrib/ParameterSample.h" +#include "Resample/Element/SpecularElement.h" +#include "Resample/Slice/KzComputation.h" +#include <algorithm> // is_sorted +#include <numbers> +using std::numbers::pi; + +LambdaScan::LambdaScan(double alpha_i, Scale* lambdaScale) + : IBeamScan(lambdaScale) + , m_alpha_i(alpha_i) +{ + std::vector<double> axis_values = m_axis->binCenters(); + if (!std::is_sorted(axis_values.begin(), axis_values.end())) + throw std::runtime_error("Error in LambdaScan::checkInitialization: q-vector values shall " + "be sorted in ascending order."); + + if (axis_values.front() < 0) + throw std::runtime_error( + "Error in LambdaScan::checkInitialization: q-vector values are out " + "of acceptable range."); +} + +LambdaScan::LambdaScan(double alpha_i, std::vector<double> lambdaList) + : LambdaScan(alpha_i, newListScan("qs", std::move(lambdaList))) +{ +} + +LambdaScan::LambdaScan(double alpha_i, const Scale& lambdaScale) + : LambdaScan(alpha_i, lambdaScale.clone()) +{ +} + +LambdaScan::LambdaScan(double alpha_i, int nbins, double lambda_min, double lambda_max) + : LambdaScan(alpha_i, newEquiScan("lambda", nbins, lambda_min, lambda_max)) +{ +} + +LambdaScan::~LambdaScan() = default; + +LambdaScan* LambdaScan::clone() const +{ + auto* result = new LambdaScan(m_alpha_i, *m_axis); + result->setIntensity(intensity()); + // TODO merge with same code in AlphaScan + if (m_beamPolarization) + result->m_beamPolarization.reset(new R3(*m_beamPolarization)); + if (m_polAnalyzer) + result->m_polAnalyzer.reset(new PolFilter(*m_polAnalyzer)); + return result; +} + +std::vector<const INode*> LambdaScan::nodeChildren() const +{ + std::vector<const INode*> result; + for (const INode* n : IBeamScan::nodeChildren()) + result << n; + return result; +} + +double LambdaScan::wavenumber(size_t i) const +{ + return 2 * pi / m_axis->binCenter(i); +} + +double LambdaScan::alpha_i(size_t) const +{ + return m_alpha_i; +} + +//! Generates simulation elements for specular simulations +std::vector<SpecularElement> LambdaScan::generateElements() const +{ + std::vector<SpecularElement> result; + result.reserve(nDistributionSamples()); + for (size_t i = 0; i < m_axis->size(); ++i) { + const double kmag = wavenumber(i); + const R3 kvec = vecOfKAlphaPhi(kmag, m_alpha_i, 0); + SpecularElement ele(i, kvec.z() <= 0, 1., 1., polarizerMatrix(), analyzerMatrix(), kvec); + result.emplace_back(std::move(ele)); + } + return result; +} + +//! Returns the number of simulation elements +size_t LambdaScan::nDistributionSamples() const +{ + return nScan(); +} + +std::vector<complex_t> LambdaScan::produceKz(const SliceStack& slices, R3 k) const +{ + return Compute::Kz::computeKzFromRefIndices(slices, k); +} diff --git a/Sim/Scan/LambdaScan.h b/Sim/Scan/LambdaScan.h new file mode 100644 index 0000000000000000000000000000000000000000..efe473d41f6ff24a76bb5a84857fabc72affdd46 --- /dev/null +++ b/Sim/Scan/LambdaScan.h @@ -0,0 +1,60 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file Sim/Scan/LambdaScan.h +//! @brief Declares LambdaScan class. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#ifndef BORNAGAIN_SIM_SCAN_LAMBDASCAN_H +#define BORNAGAIN_SIM_SCAN_LAMBDASCAN_H + +#include "Sim/Scan/IBeamScan.h" +#include <memory> + +class IDistribution1D; + +//! Scan type with z-components of scattering vector as coordinate values. +//! Wavelength and incident angles are not accessible separately. + +class LambdaScan : public IBeamScan { +public: + LambdaScan(double alpha_i, std::vector<double> lambdaScale); + LambdaScan(double alpha_i, const Scale& lambdaScale); + //! Sets q-defined specular scan. Accepts either numpy array of q-values sorted in ascending + //! order or an Scale object with q-values. Alternatively an axis can be defined in-place, then + //! the first passed parameter is the number of bins, second - minimum on-axis q-value, + //! third - maximum on-axis q_value. + LambdaScan(double alpha_i, int nbins, double lambda_min, double lambda_max); + + ~LambdaScan() override; + + LambdaScan* clone() const override; + std::string className() const final { return "LambdaScan"; } + std::vector<const INode*> nodeChildren() const override; + +#ifndef SWIG + double wavenumber(size_t i) const override; + double alpha_i(size_t i) const override; + + //! Generates simulation elements for specular simulations + std::vector<SpecularElement> generateElements() const override; + + size_t nDistributionSamples() const override; + + std::vector<complex_t> produceKz(const SliceStack& slices, R3 k) const override; + +private: + LambdaScan(double alpha_i, Scale* lambdaScale); + + double m_alpha_i; +#endif // SWIG +}; + +#endif // BORNAGAIN_SIM_SCAN_LAMBDASCAN_H diff --git a/Sim/Scan/QzScan.cpp b/Sim/Scan/QzScan.cpp index ee9d5956b68c47e37a1b3c92874d0d579c4ff985..2d2d4efb78c7a4ca79ab55f252a805429d6c6ec2 100644 --- a/Sim/Scan/QzScan.cpp +++ b/Sim/Scan/QzScan.cpp @@ -16,15 +16,15 @@ #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" #include "Base/Util/Assert.h" -#include "Device/Coord/CoordSystem1D.h" #include "Device/Pol/PolFilter.h" #include "Param/Distrib/Distributions.h" #include "Param/Distrib/ParameterSample.h" #include "Resample/Element/SpecularElement.h" -#include <algorithm> +#include "Resample/Slice/KzComputation.h" +#include <algorithm> // is_sorted QzScan::QzScan(Scale* qs_nm) - : IBeamScan(qs_nm, std::nan("")) + : IBeamScan(qs_nm) { std::vector<double> axis_values = m_axis->binCenters(); if (!std::is_sorted(axis_values.begin(), axis_values.end())) @@ -81,13 +81,23 @@ std::vector<const INode*> QzScan::nodeChildren() const return result; } +double QzScan::wavenumber(size_t) const +{ + ASSERT(false); +} + +double QzScan::alpha_i(size_t) const +{ + ASSERT(false); +} + //! Generates simulation elements for specular simulations std::vector<SpecularElement> QzScan::generateElements() const { std::vector<SpecularElement> result; result.reserve(nDistributionSamples()); for (size_t i = 0; i < m_axis->size(); ++i) { - const double q0 = m_axis->binCenters()[i]; + const double q0 = m_axis->binCenter(i); if (m_qz_distrib) { const std::vector<ParameterSample> qzDistrib = m_qz_distrib->distributionSamples(); for (size_t j = 0; j < qzDistrib.size(); ++j) { @@ -99,13 +109,14 @@ std::vector<SpecularElement> QzScan::generateElements() const qz += m_resol_width[i] * qzDistrib[j].value; else qz += m_resol_width[0] * qzDistrib[j].value; - result.emplace_back( - SpecularElement::FromQzScan(i, qzDistrib[j].weight, -(qz + m_offset) / 2, - polarizerMatrix(), analyzerMatrix(), qz >= 0)); + SpecularElement ele(i, qz >= 0, qzDistrib[j].weight, 1., polarizerMatrix(), + analyzerMatrix(), R3(0, 0, -(qz + m_offset) / 2)); + result.emplace_back(std::move(ele)); } } else { - result.emplace_back(SpecularElement::FromQzScan( - i, 1., -(q0 + m_offset) / 2, polarizerMatrix(), analyzerMatrix(), q0 >= 0)); + SpecularElement ele(i, q0 >= 0, 1., 1., polarizerMatrix(), analyzerMatrix(), + R3(0, 0, -(q0 + m_offset) / 2)); + result.emplace_back(std::move(ele)); } } return result; @@ -117,11 +128,6 @@ size_t QzScan::nDistributionSamples() const return m_qz_distrib ? m_qz_distrib->nSamples() : 1; } -CoordSystem1D* QzScan::scanCoordSystem() const -{ - return new WavenumberReflectometryCoords(coordinateAxis()->clone()); -} - void QzScan::setRelativeQResolution(const IDistribution1D& distr, double rel_dev) { m_qz_distrib.reset(distr.clone()); @@ -141,3 +147,8 @@ void QzScan::setVectorResolution(const IDistribution1D& distr, const std::vector ASSERT(std_devs.size() > 1); m_resol_width = std_devs; } + +std::vector<complex_t> QzScan::produceKz(const SliceStack& slices, R3 k) const +{ + return Compute::Kz::computeKzFromRefIndices(slices, k); +} diff --git a/Sim/Scan/QzScan.h b/Sim/Scan/QzScan.h index 521110f2ff3a306af04e580dbe65858f0d0c6298..1cc1c5e4f81cccc6b527937f423de9468d5dafb8 100644 --- a/Sim/Scan/QzScan.h +++ b/Sim/Scan/QzScan.h @@ -51,6 +51,9 @@ public: void setOffset(double offset) { m_offset = offset; } #ifndef SWIG + double wavenumber(size_t i) const override; + double alpha_i(size_t i) const override; + const IDistribution1D* qzDistribution() const { return m_qz_distrib.get(); @@ -61,8 +64,6 @@ public: size_t nDistributionSamples() const override; - CoordSystem1D* scanCoordSystem() const override; - bool resolution_is_relative() const { return m_relative_resolution; @@ -72,7 +73,10 @@ public: return m_resol_width; } + std::vector<complex_t> produceKz(const SliceStack& slices, R3 k) const override; + private: + double m_lambda0; QzScan(Scale* qs_nm); std::unique_ptr<const IDistribution1D> m_qz_distrib; std::vector<double> m_resol_width; diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index 9618c498402fc36e0fa6a97cf39b33b6e1a2610b..c392812e34696a9ed36262c2d6a34f1e31ee9943 100644 --- a/Sim/Simulation/DepthprobeSimulation.cpp +++ b/Sim/Simulation/DepthprobeSimulation.cpp @@ -13,14 +13,12 @@ // ************************************************************************************************ #include "Sim/Simulation/DepthprobeSimulation.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" -#include <numbers> -using std::numbers::pi; #include "Base/Progress/ProgressHandler.h" #include "Base/Util/Assert.h" #include "Base/Vector/GisasDirection.h" #include "Device/Beam/IFootprint.h" -#include "Device/Coord/CoordSystem2D.h" #include "Device/Data/Datafield.h" #include "Device/Histo/SimulationResult.h" #include "Param/Distrib/DistributionHandler.h" @@ -30,7 +28,9 @@ using std::numbers::pi; #include "Resample/Processed/ReSample.h" #include "Sim/Scan/AlphaScan.h" #include <iostream> +#include <numbers> #include <valarray> +using std::numbers::pi; const int ZDirection_None = 0; const int ZDirection_Reflected = 1; @@ -52,10 +52,9 @@ DepthprobeSimulation::DepthprobeSimulation(const IBeamScan& scan, const MultiLay DepthprobeSimulation::~DepthprobeSimulation() = default; -const ICoordSystem* DepthprobeSimulation::simCoordSystem() const +const Frame* DepthprobeSimulation::simCoordSystem() const { - std::vector<const Scale*> axes({m_scan->coordinateAxis()->clone(), m_z_axis->clone()}); - return new DepthprobeCoords(std::move(axes), (2 * pi) / m_scan->wavelength()); + return new Frame(m_scan->coordinateAxis()->clone(), m_z_axis->clone()); } std::vector<const INode*> DepthprobeSimulation::nodeChildren() const diff --git a/Sim/Simulation/DepthprobeSimulation.h b/Sim/Simulation/DepthprobeSimulation.h index aa58a60bb0ea9fd8ad23a14cf08331911b5e798b..3364b610ed5c683831cf723b9698d38fdb05d33c 100644 --- a/Sim/Simulation/DepthprobeSimulation.h +++ b/Sim/Simulation/DepthprobeSimulation.h @@ -51,7 +51,7 @@ public: return m_scan.get(); } - const ICoordSystem* simCoordSystem() const override; + const Frame* simCoordSystem() const override; std::vector<const INode*> nodeChildren() const override; diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h index 567f0ccb608f14b613b0563be7d9bf339d3f0b3b..7ec3d2355d6913895111adab7d835041bc185287 100644 --- a/Sim/Simulation/ISimulation.h +++ b/Sim/Simulation/ISimulation.h @@ -21,9 +21,9 @@ #include <heinz/Vectors3D.h> class DistributionHandler; +class Frame; class IBackground; class IComputation; -class ICoordSystem; class MultiLayer; class ProgressHandler; class ReSample; @@ -71,7 +71,7 @@ public: const IBackground* background() const; const std::vector<ParameterDistribution>& paramDistributions() const; - virtual const ICoordSystem* simCoordSystem() const = 0; + virtual const Frame* simCoordSystem() const = 0; const SimulationOptions& options() const; diff --git a/Sim/Simulation/OffspecSimulation.cpp b/Sim/Simulation/OffspecSimulation.cpp index a744f7e8ba640bdb36f23a219f64a65f626be4d0..db5e5e2830edd93e6197ca6f3a23958ee923df11 100644 --- a/Sim/Simulation/OffspecSimulation.cpp +++ b/Sim/Simulation/OffspecSimulation.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Sim/Simulation/OffspecSimulation.h" +#include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" #include "Base/Pixel/IPixel.h" #include "Base/Progress/ProgressHandler.h" #include "Base/Util/Assert.h" #include "Device/Beam/IFootprint.h" -#include "Device/Coord/CoordSystem2D.h" #include "Device/Data/Datafield.h" #include "Device/Detector/OffspecDetector.h" #include "Device/Histo/SimulationResult.h" @@ -55,10 +55,9 @@ void OffspecSimulation::prepareSimulation() m_pixels.emplace_back(m_detector->createPixel(i)); } -const ICoordSystem* OffspecSimulation::simCoordSystem() const +const Frame* OffspecSimulation::simCoordSystem() const { - return new OffspecCoords( - std::vector<const Scale*>{m_scan->coordinateAxis()->clone(), m_detector->axis(1).clone()}); + return new Frame(m_scan->coordinateAxis()->clone(), m_detector->axis(1).clone()); } //... Overridden executors: @@ -69,10 +68,12 @@ void OffspecSimulation::initDistributionHandler() for (const auto& distribution : distributionHandler().paramDistributions()) { switch (distribution.whichParameter()) { + /* case ParameterDistribution::BeamWavelength: distributionHandler().defineCallbackForDistribution( &distribution, [&](double d) { m_scan->setWavelength(d); }); break; + */ default: ASSERT(false); } @@ -88,11 +89,11 @@ void OffspecSimulation::runComputation(const ReSample& re_sample, size_t i, doub size_t j = i / Na; size_t k = i % Na; - const double alpha = m_scan->coordinateAxis()->binCenter(j); + const double alpha = m_scan->alpha_i(j); const double phi = 0; const bool isSpecular = k == m_detector->indexOfSpecular(alpha, phi); - DiffuseElement ele(m_scan->wavelength(), alpha, phi, m_pixels[k], m_scan->polarizerMatrix(), + DiffuseElement ele(m_scan->wavelength(j), alpha, phi, m_pixels[k], m_scan->polarizerMatrix(), m_scan->analyzerMatrix(), isSpecular); double intensity = Compute::scattered_and_reflected(re_sample, options(), ele); diff --git a/Sim/Simulation/OffspecSimulation.h b/Sim/Simulation/OffspecSimulation.h index df59a22297d909f27a28a07887064920f5fdfd0f..3ae6b4693ee14f00261ebfcd164356d8c649c6d4 100644 --- a/Sim/Simulation/OffspecSimulation.h +++ b/Sim/Simulation/OffspecSimulation.h @@ -37,7 +37,7 @@ public: std::string className() const final { return "OffspecSimulation"; } #ifndef SWIG - const ICoordSystem* simCoordSystem() const override; + const Frame* simCoordSystem() const override; std::vector<const INode*> nodeChildren() const override; diff --git a/Sim/Simulation/ScatteringSimulation.cpp b/Sim/Simulation/ScatteringSimulation.cpp index a21698b814da81a5de53af75ae04920ac13df69f..200ea1fd1b5177fe8f804e26a1bdc048ec72a816 100644 --- a/Sim/Simulation/ScatteringSimulation.cpp +++ b/Sim/Simulation/ScatteringSimulation.cpp @@ -19,7 +19,6 @@ #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" #include "Device/Beam/IFootprint.h" -#include "Device/Coord/CoordSystem2D.h" #include "Device/Data/Datafield.h" #include "Device/Detector/IDetector.h" #include "Device/Detector/SimulationAreaIterator.h" // beginNonMaskedPoints @@ -40,9 +39,9 @@ ScatteringSimulation::ScatteringSimulation(const Beam& beam, const MultiLayer& s ScatteringSimulation::~ScatteringSimulation() = default; -const ICoordSystem* ScatteringSimulation::simCoordSystem() const +const Frame* ScatteringSimulation::simCoordSystem() const { - return m_detector->scatteringCoords(beam()); + return m_detector->scatteringCoords(); } //... Overridden executors: diff --git a/Sim/Simulation/ScatteringSimulation.h b/Sim/Simulation/ScatteringSimulation.h index bb0a58280864569b3c26b0931eb33d58286cab3b..20e526764e8e969011ecbaa444f6748ae142130a 100644 --- a/Sim/Simulation/ScatteringSimulation.h +++ b/Sim/Simulation/ScatteringSimulation.h @@ -39,7 +39,7 @@ public: IDetector& detector() { return *m_detector; } #ifndef SWIG - const ICoordSystem* simCoordSystem() const override; + const Frame* simCoordSystem() const override; const Beam& beam() const { diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp index 079781feb6ec98c8e00b2cf2a1cbb182a807e76c..253803885efe8aec30718d3323cb05538971a19d 100644 --- a/Sim/Simulation/SpecularSimulation.cpp +++ b/Sim/Simulation/SpecularSimulation.cpp @@ -17,7 +17,6 @@ #include "Base/Progress/ProgressHandler.h" #include "Base/Util/Assert.h" #include "Device/Beam/IFootprint.h" -#include "Device/Coord/CoordSystem1D.h" #include "Device/Data/Datafield.h" #include "Device/Histo/SimulationResult.h" #include "Param/Distrib/Distributions.h" @@ -30,33 +29,6 @@ #include "Sim/Computation/SpecularComputation.h" #include "Sim/Scan/AlphaScan.h" -namespace { - -//! Performs the actual simulation, and sets intensity, for given range of SpecularElement%s. -double reflectedIntensity(const ReSample& re_sample, SpecularElement& ele) -{ - if (!ele.isCalculated()) - return 0; - - const SliceStack& slices = re_sample.averageSlices(); - std::vector<complex_t> kz_stack = ele.produceKz(slices); - - if (re_sample.polarizing()) { - const SpinMatrix R = Compute::polarizedReflectivity(slices, kz_stack, true); - const SpinMatrix& polMatrix = ele.polarizer(); - const SpinMatrix& anaMatrix = ele.analyzer(); - - return Compute::magneticR(R, polMatrix, anaMatrix); - - } else { - const complex_t R = Compute::scalarReflectivity(slices, kz_stack); - return Compute::scalarR(R); - } -} - -} // namespace - - SpecularSimulation::SpecularSimulation(const IBeamScan& scan, const MultiLayer& sample) : ISimulation(sample) , m_scan(scan.clone()) @@ -68,7 +40,7 @@ SpecularSimulation::SpecularSimulation(const IBeamScan& scan, const MultiLayer& SpecularSimulation::~SpecularSimulation() = default; -const ICoordSystem* SpecularSimulation::simCoordSystem() const +const Frame* SpecularSimulation::simCoordSystem() const { return m_scan->scanCoordSystem(); } @@ -83,7 +55,26 @@ void SpecularSimulation::initElementVector() void SpecularSimulation::runComputation(const ReSample& re_sample, size_t iElement, double weight) { SpecularElement& ele = *(m_eles.begin() + static_cast<long>(iElement)); - double refl = reflectedIntensity(re_sample, ele); + + double refl = 0; + if (ele.isCalculated()) { + + const SliceStack& slices = re_sample.averageSlices(); + std::vector<complex_t> kz_stack = m_scan->produceKz(slices, ele.k()); + + if (re_sample.polarizing()) { + const SpinMatrix R = Compute::polarizedReflectivity(slices, kz_stack, true); + const SpinMatrix& polMatrix = ele.polarizer(); + const SpinMatrix& anaMatrix = ele.analyzer(); + + refl = Compute::magneticR(R, polMatrix, anaMatrix); + + } else { + const complex_t R = Compute::scalarReflectivity(slices, kz_stack); + refl = Compute::scalarR(R); + } + } + double intensity = refl * ele.footprint(); if (background()) diff --git a/Sim/Simulation/SpecularSimulation.h b/Sim/Simulation/SpecularSimulation.h index 9332e6849a7396cbfc63b4255c2a94ce26adacd3..2c2ab6b3cd9e5b845e8ea99f85b4003deb0894f3 100644 --- a/Sim/Simulation/SpecularSimulation.h +++ b/Sim/Simulation/SpecularSimulation.h @@ -33,7 +33,7 @@ public: std::string className() const final { return "SpecularSimulation"; } #ifndef SWIG - const ICoordSystem* simCoordSystem() const override; + const Frame* simCoordSystem() const override; //! Returns internal data handler const IBeamScan* scan() const { diff --git a/Tests/Examples/CMakeLists.txt b/Tests/Examples/CMakeLists.txt index 966bbf844696f350dec481fdc28ec3d1acb6687b..e422e4fdb4e1f6250815c89f518163363128c3bc 100644 --- a/Tests/Examples/CMakeLists.txt +++ b/Tests/Examples/CMakeLists.txt @@ -169,7 +169,7 @@ test_example(scatter2d/LargeParticlesFormFactor 0.5) test_example(scatter2d/GratingMC .9) # TODO reduce tolerance run_example(scatter2d/PositionVariance) # TODO -> test -run_example(scatter2d/AxesInDifferentUnits) +# TODO disabled while refactoring scales&coords: run_example(scatter2d/AxesInDifferentUnits) run_example(scatter2d/FindPeaks) test_example(specular/AlternatingLayers1 2e-13) @@ -193,7 +193,7 @@ test_example(offspec/Offspec1 2e-10) test_example(varia/Depthprobe1 2e-10) test_example(varia/TransmittedModulus 2e-10) test_example(varia/Resonator 2e-10) -test_example(varia/AccessingSimulationResults 2e-10) +# TODO disabled while refactoring scales&coords: test_example(varia/AccessingSimulationResults 2e-10) run_example(varia/MaterialProfile) run_example(varia/MaterialProfileWithParticles) diff --git a/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP.int.gz b/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP.int.gz index baff0c472397b9c5371032c6fcde4cfdc9a24d45..d5ce2a7307588a3deae1ab89962fa0c017964e1f 100644 Binary files a/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP.int.gz and b/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP.int.gz differ diff --git a/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP_Q.int.gz b/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP_Q.int.gz index 1902f8abd37dea21791141abafbf45f6dc7b50af..2da5f61237e7c8f5b3c8eed1b819886970de4083 100644 Binary files a/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP_Q.int.gz and b/Tests/ReferenceData/Suite/PolarizedFeNiBilayerTanhPP_Q.int.gz differ diff --git a/Tests/SimFactory/MakeSimulations.cpp b/Tests/SimFactory/MakeSimulations.cpp index 8f760a25450cc2883bb4ba3d63d16b5656b9b9b8..de99eb08508807eac7c6943a10dcbc78cb7ecbdc 100644 --- a/Tests/SimFactory/MakeSimulations.cpp +++ b/Tests/SimFactory/MakeSimulations.cpp @@ -452,7 +452,7 @@ test::makeSimulation::BasicDepthprobe(const MultiLayer& sample) AlphaScan scan(20, 0.025 * deg, 0.975 * deg); scan.setWavelength(1.); - Scale zaxis = EquiDivision("z", 20, -100., +100.); + Scale zaxis = EquiDivision("z (nm)", 20, -100., +100.); return std::make_unique<DepthprobeSimulation>(scan, sample, zaxis); } diff --git a/Tests/Unit/Device/DepthprobeConverterTest.cpp b/Tests/Unit/Device/DepthprobeConverterTest.cpp deleted file mode 100644 index 1b6e8fc67a3c88d2d36b0ada9f5cf5c6772340f8..0000000000000000000000000000000000000000 --- a/Tests/Unit/Device/DepthprobeConverterTest.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "Base/Axis/MakeScale.h" -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Device/Coord/CoordSystem2D.h" -#include "Tests/GTestWrapper/google_test.h" -#include <numbers> - -using std::numbers::pi; - -class DepthprobeCoordsTest : public ::testing::Test { -protected: - DepthprobeCoordsTest(); - - void checkMainFunctionality(const DepthprobeCoords& test_object); - void checkAlphaAxis(Coords units, const DepthprobeCoords& test_object); - void checkZAxis(Coords units, const DepthprobeCoords& test_object); - const double m_alpha_start = 0.5; // first axis value in rads - const double m_alpha_end = 1.0; // last axis value in rads - const double m_z_start = -30.0; - const double m_z_end = 10.0; - const size_t m_nbins = 100; - double m_wavenumber = (2 * pi) / 1.0; - std::vector<const Scale*> m_axes; -}; - -DepthprobeCoordsTest::DepthprobeCoordsTest() - : m_axes({newEquiDivision("Angles", m_nbins, m_alpha_start, m_alpha_end), // angles in radians - newEquiDivision("Positions", m_nbins, m_z_start, m_z_end)}) // z positions in nm -{ -} - -void DepthprobeCoordsTest::checkMainFunctionality(const DepthprobeCoords& test_object) -{ - EXPECT_EQ(test_object.rank(), 2u); - - EXPECT_NEAR(test_object.calculateMin(0, Coords::UNDEFINED), 2.8647889757e1, - 2.8647889757e1 * 1e-10); - EXPECT_NEAR(test_object.calculateMin(0, Coords::DEGREES), 2.8647889757e1, - 2.8647889757e1 * 1e-10); - EXPECT_NEAR(test_object.calculateMin(0, Coords::QSPACE), 6.0246390001, 6.0246390001 * 1e-10); - EXPECT_EQ(test_object.calculateMin(0, Coords::RADIANS), m_alpha_start); - EXPECT_EQ(test_object.calculateMin(0, Coords::NBINS), 0.0); - - EXPECT_NEAR(test_object.calculateMax(0, Coords::UNDEFINED), 5.7295779513e1, - 5.7295779513e1 * 1e-10); - EXPECT_NEAR(test_object.calculateMax(0, Coords::DEGREES), 5.7295779513e1, - 5.7295779513e1 * 1e-10); - EXPECT_NEAR(test_object.calculateMax(0, Coords::QSPACE), 1.0574236256e1, - 1.0574236256e1 * 1e-10); - EXPECT_EQ(test_object.calculateMax(0, Coords::RADIANS), m_alpha_end); - const auto n_bins = static_cast<double>(m_nbins); - EXPECT_NEAR(test_object.calculateMax(0, Coords::NBINS), n_bins, n_bins * 1e-10); - - checkAlphaAxis(Coords::UNDEFINED, test_object); - checkAlphaAxis(Coords::DEGREES, test_object); - checkAlphaAxis(Coords::RADIANS, test_object); - checkAlphaAxis(Coords::QSPACE, test_object); - checkAlphaAxis(Coords::NBINS, test_object); - - checkZAxis(Coords::UNDEFINED, test_object); - checkZAxis(Coords::DEGREES, test_object); - checkZAxis(Coords::RADIANS, test_object); - checkZAxis(Coords::QSPACE, test_object); - checkZAxis(Coords::NBINS, test_object); -} - -void DepthprobeCoordsTest::checkAlphaAxis(Coords units, const DepthprobeCoords& test_object) -{ - std::unique_ptr<Scale> axis(test_object.convertedAxis(0, units)); - EXPECT_EQ(axis->size(), m_nbins); - EXPECT_EQ(axis->min(), test_object.calculateMin(0, units)); - EXPECT_EQ(axis->max(), test_object.calculateMax(0, units)); -} - -void DepthprobeCoordsTest::checkZAxis(Coords units, const DepthprobeCoords& test_object) -{ - std::unique_ptr<Scale> axis(test_object.convertedAxis(1, units)); - EXPECT_EQ(axis->size(), m_nbins); - - EXPECT_EQ(axis->min(), test_object.calculateMin(1, units)); - const double test_min = units == Coords::NBINS ? 0 : m_z_start; - EXPECT_NEAR(axis->min(), test_min, std::abs(test_min) * 1e-10); - - EXPECT_EQ(axis->max(), test_object.calculateMax(1, units)); - const double test_max = units == Coords::NBINS ? m_nbins : m_z_end; - EXPECT_NEAR(axis->max(), test_max, std::abs(test_max) * 1e-10); -} - -TEST_F(DepthprobeCoordsTest, DepthprobeCoords) -{ - DepthprobeCoords converter(std::move(m_axes), m_wavenumber); - checkMainFunctionality(converter); -} - -TEST_F(DepthprobeCoordsTest, DepthprobeCoordsClone) -{ - DepthprobeCoords converter(std::move(m_axes), m_wavenumber); - std::unique_ptr<DepthprobeCoords> converter_clone(converter.clone()); - checkMainFunctionality(*converter_clone); -} diff --git a/Tests/Unit/Device/IntensityDataFunctionsTest.cpp b/Tests/Unit/Device/IntensityDataFunctionsTest.cpp index ac0f72105cd67720f79697aa7889210a8eada791..d342c0df0830be3a2120f3c3b7de6eedcc42d79a 100644 --- a/Tests/Unit/Device/IntensityDataFunctionsTest.cpp +++ b/Tests/Unit/Device/IntensityDataFunctionsTest.cpp @@ -73,9 +73,8 @@ TEST(DataUtilTest, coordinateToFromBinf) TEST(DataUtilTest, datafieldToFromBinf) { - Frame data1({newEquiDivision("axis0", 8, -5.0, 3.0), newEquiDivision("axis1", 3, 2.0, 5.0)}); - Frame data2( - {newEquiDivision("axis0", 8, -10.0, 70.0), newEquiDivision("axis1", 3, -10.0, 20.0)}); + Frame data1(newEquiDivision("axis0", 8, -5.0, 3.0), newEquiDivision("axis1", 3, 2.0, 5.0)); + Frame data2(newEquiDivision("axis0", 8, -10.0, 70.0), newEquiDivision("axis1", 3, -10.0, 20.0)); double x(-4.5), y(2.5); FrameUtil::coordinatesToBinf(x, y, data1); diff --git a/Tests/Unit/Device/OffspecConverterTest.cpp b/Tests/Unit/Device/OffspecConverterTest.cpp deleted file mode 100644 index 708ecc20ce234e661098d42316c677b0e673d779..0000000000000000000000000000000000000000 --- a/Tests/Unit/Device/OffspecConverterTest.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "Base/Axis/MakeScale.h" -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Device/Beam/Beam.h" -#include "Device/Coord/CoordSystem2D.h" -#include "Device/Detector/SphericalDetector.h" -#include "Tests/GTestWrapper/google_test.h" - -class OffspecCoordsTest : public ::testing::Test { -public: - OffspecCoords* createCoords() - { - const auto axes = m_detector.axesClippedToRegionOfInterest(); - - std::vector<const Scale*> axes2({m_alpha_i_axis.clone(), axes[1]->clone()}); - return new OffspecCoords(std::move(axes2)); - } - -protected: - SphericalDetector m_detector{100, 0.0, 5.0 * Units::deg, 70, -2.0 * Units::deg, 1.5}; - Scale m_alpha_i_axis = EquiDivision("alpha_i", 51, 0.0, 7.0 * Units::deg); - Beam m_beam{1, 1.0, 1.0 * Units::deg}; -}; - - -TEST_F(OffspecCoordsTest, OffspecCoords) -{ - std::unique_ptr<OffspecCoords> coords(createCoords()); - - EXPECT_EQ(coords->rank(), 2u); - - EXPECT_DOUBLE_EQ(coords->calculateMin(0, Coords::UNDEFINED), 0.0); - EXPECT_DOUBLE_EQ(coords->calculateMin(0, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(coords->calculateMin(0, Coords::RADIANS), 0.0); - EXPECT_DOUBLE_EQ(coords->calculateMin(0, Coords::DEGREES), 0.0); - EXPECT_FAILED_ASSERT(coords->calculateMin(0, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(coords->calculateMin(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(coords->calculateMax(0, Coords::UNDEFINED), 7.0); - EXPECT_DOUBLE_EQ(coords->calculateMax(0, Coords::NBINS), 51.0); - EXPECT_DOUBLE_EQ(coords->calculateMax(0, Coords::RADIANS), Units::deg2rad(7.0)); - EXPECT_DOUBLE_EQ(coords->calculateMax(0, Coords::DEGREES), 7.0); - EXPECT_FAILED_ASSERT(coords->calculateMax(0, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(coords->calculateMax(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(coords->calculateMin(1, Coords::UNDEFINED), -2.0); - EXPECT_DOUBLE_EQ(coords->calculateMin(1, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(coords->calculateMin(1, Coords::RADIANS), Units::deg2rad(-2.0)); - EXPECT_DOUBLE_EQ(coords->calculateMin(1, Coords::DEGREES), -2.0); - EXPECT_FAILED_ASSERT(coords->calculateMin(1, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(coords->calculateMin(1, Coords::MM)); - - EXPECT_DOUBLE_EQ(coords->calculateMax(1, Coords::UNDEFINED), Units::rad2deg(1.5)); - EXPECT_DOUBLE_EQ(coords->calculateMax(1, Coords::NBINS), 70.0); - EXPECT_DOUBLE_EQ(coords->calculateMax(1, Coords::RADIANS), 1.5); - EXPECT_DOUBLE_EQ(coords->calculateMax(1, Coords::DEGREES), Units::rad2deg(1.5)); - EXPECT_FAILED_ASSERT(coords->calculateMax(1, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(coords->calculateMax(1, Coords::MM)); - - EXPECT_FAILED_ASSERT(coords->calculateMin(2, Coords::UNDEFINED)); - EXPECT_FAILED_ASSERT(coords->calculateMax(2, Coords::UNDEFINED)); - - std::unique_ptr<Scale> axis(coords->convertedAxis(0, Coords::UNDEFINED)); - EXPECT_EQ(axis->min(), coords->calculateMin(0, Coords::UNDEFINED)); - EXPECT_EQ(axis->max(), coords->calculateMax(0, Coords::UNDEFINED)); - - std::unique_ptr<Scale> axis2(coords->convertedAxis(1, Coords::RADIANS)); - EXPECT_EQ(axis2->min(), coords->calculateMin(1, Coords::RADIANS)); - EXPECT_EQ(axis2->max(), coords->calculateMax(1, Coords::RADIANS)); - - EXPECT_FAILED_ASSERT(coords->convertedAxis(2, Coords::UNDEFINED)); - EXPECT_FAILED_ASSERT(coords->convertedAxis(1, Coords::QSPACE)); -} - -TEST_F(OffspecCoordsTest, OffspecCoordsClone) -{ - std::unique_ptr<OffspecCoords> coords(createCoords()); - std::unique_ptr<OffspecCoords> P_clone(coords->clone()); - - EXPECT_EQ(P_clone->rank(), 2u); - - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::UNDEFINED), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::RADIANS), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::DEGREES), 0.0); - EXPECT_FAILED_ASSERT(P_clone->calculateMin(0, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(P_clone->calculateMin(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::UNDEFINED), 7.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::NBINS), 51.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::RADIANS), Units::deg2rad(7.0)); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::DEGREES), 7.0); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(0, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::UNDEFINED), -2.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::RADIANS), Units::deg2rad(-2.0)); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::DEGREES), -2.0); - EXPECT_FAILED_ASSERT(P_clone->calculateMin(1, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(P_clone->calculateMin(1, Coords::MM)); - - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::UNDEFINED), Units::rad2deg(1.5)); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::NBINS), 70.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::RADIANS), 1.5); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::DEGREES), Units::rad2deg(1.5)); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(1, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(1, Coords::MM)); - - EXPECT_FAILED_ASSERT(P_clone->calculateMin(2, Coords::UNDEFINED)); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(2, Coords::UNDEFINED)); -} diff --git a/Tests/Unit/Device/RectangularConverterTest.cpp b/Tests/Unit/Device/RectangularConverterTest.cpp deleted file mode 100644 index aa769984a9e01d796d47a339f2d233ab4c7af58d..0000000000000000000000000000000000000000 --- a/Tests/Unit/Device/RectangularConverterTest.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Base/Pixel/RectangularPixel.h" -#include "Device/Beam/Beam.h" -#include "Device/Coord/CoordSystem2D.h" -#include "Device/Detector/RectangularDetector.h" -#include "Tests/GTestWrapper/google_test.h" -#include <cmath> -#include <numbers> - -using std::numbers::pi; - -namespace { - -const double det_width = 200.0; -const double det_height = 140.0; -const double det_distance = 1000.0; -const size_t det_nx = 100u; -const size_t det_ny = 70u; - -} // namespace - -class RectangularConverterTest : public ::testing::Test { -public: - RectangularConverterTest(); - -protected: - RectangularDetector m_detector; - Beam m_beam; - double m_phi, m_alpha; - double m_kiz, m_kfy, m_kfz; -}; - -RectangularConverterTest::RectangularConverterTest() - : m_detector(det_nx, det_width, det_ny, det_height) - , m_beam(Beam(1, 1.0, 1 * Units::deg)) -{ - m_detector.setPerpendicularToSampleX(det_distance, det_width / 2.0, 0.0); - m_detector.setDetectorNormal(m_beam.ki()); - m_phi = std::atan2(det_width / 2.0, det_distance); - m_alpha = std::atan2(det_height, det_distance / std::cos(m_phi)); - const auto k_i = m_beam.ki(); - m_kiz = k_i.z(); - double K = m_beam.wavenumber(); - m_kfy = K * std::sin(m_phi); - m_kfz = K * std::sin(m_alpha); -} - -TEST_F(RectangularConverterTest, ImageCoords) -{ - ImageCoords converter(m_detector.axesClippedToRegionOfInterest(), m_beam.ki(), - m_detector.regionOfInterestPixel()); - - EXPECT_EQ(converter.rank(), 2u); - - EXPECT_NEAR(converter.calculateMin(0, Coords::UNDEFINED), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(0, Coords::NBINS), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(0, Coords::MM), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(0, Coords::RADIANS), -m_phi, m_phi * 1e-10); - EXPECT_NEAR(converter.calculateMin(0, Coords::DEGREES), Units::rad2deg(-m_phi), - Units::rad2deg(m_phi) * 1e-10); - EXPECT_NEAR(converter.calculateMin(0, Coords::QSPACE), -m_kfy, m_kfy * 1e-10); - - EXPECT_NEAR(converter.calculateMax(0, Coords::UNDEFINED), det_width, det_width * 1e-10); - EXPECT_NEAR(converter.calculateMax(0, Coords::NBINS), static_cast<double>(det_nx), - det_nx * 1e-10); - EXPECT_NEAR(converter.calculateMax(0, Coords::MM), det_width, det_width * 1e-10); - EXPECT_NEAR(converter.calculateMax(0, Coords::RADIANS), m_phi, m_phi * 1e-10); - EXPECT_NEAR(converter.calculateMax(0, Coords::DEGREES), Units::rad2deg(m_phi), - Units::rad2deg(m_phi) * 1e-10); - EXPECT_NEAR(converter.calculateMax(0, Coords::QSPACE), m_kfy, m_kfy * 1e-10); - - EXPECT_NEAR(converter.calculateMin(1, Coords::UNDEFINED), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(1, Coords::NBINS), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(1, Coords::MM), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(1, Coords::RADIANS), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(1, Coords::DEGREES), 0.0, 1e-12); - EXPECT_NEAR(converter.calculateMin(1, Coords::QSPACE), -m_kiz, std::abs(m_kiz) * 1e-1); - - EXPECT_NEAR(converter.calculateMax(1, Coords::UNDEFINED), det_height, det_height * 1e-10); - EXPECT_NEAR(converter.calculateMax(1, Coords::NBINS), static_cast<double>(det_ny), - det_ny * 1e-10); - EXPECT_NEAR(converter.calculateMax(1, Coords::MM), det_height, det_height * 1e-10); - EXPECT_NEAR(converter.calculateMax(1, Coords::RADIANS), m_alpha, m_alpha * 1e-10); - EXPECT_NEAR(converter.calculateMax(1, Coords::DEGREES), Units::rad2deg(m_alpha), - Units::rad2deg(m_alpha) * 1e-10); - EXPECT_NEAR(converter.calculateMax(1, Coords::QSPACE), m_kfz - m_kiz, - std::abs(m_kfz - m_kiz) * 1e-1); - - EXPECT_FAILED_ASSERT(converter.calculateMin(2, Coords::UNDEFINED)); - EXPECT_FAILED_ASSERT(converter.calculateMax(2, Coords::UNDEFINED)); - - std::unique_ptr<Scale> axis(converter.convertedAxis(0, Coords::UNDEFINED)); - EXPECT_EQ(axis->min(), converter.calculateMin(0, Coords::UNDEFINED)); - EXPECT_EQ(axis->max(), converter.calculateMax(0, Coords::UNDEFINED)); - - std::unique_ptr<Scale> axis2(converter.convertedAxis(1, Coords::QSPACE)); - EXPECT_EQ(axis2->min(), converter.calculateMin(1, Coords::QSPACE)); - EXPECT_EQ(axis2->max(), converter.calculateMax(1, Coords::QSPACE)); - - EXPECT_FAILED_ASSERT(converter.convertedAxis(2, Coords::UNDEFINED)); -} - -TEST_F(RectangularConverterTest, ImageCoordsClone) -{ - ImageCoords converter(m_detector.axesClippedToRegionOfInterest(), m_beam.ki(), - m_detector.regionOfInterestPixel()); - std::unique_ptr<ImageCoords> P_clone(converter.clone()); - - EXPECT_EQ(P_clone->rank(), 2u); - - EXPECT_NEAR(P_clone->calculateMin(0, Coords::UNDEFINED), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(0, Coords::NBINS), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(0, Coords::MM), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(0, Coords::RADIANS), -m_phi, m_phi * 1e-10); - EXPECT_NEAR(P_clone->calculateMin(0, Coords::DEGREES), Units::rad2deg(-m_phi), - Units::rad2deg(m_phi) * 1e-10); - EXPECT_NEAR(P_clone->calculateMin(0, Coords::QSPACE), -m_kfy, m_kfy * 1e-10); - - EXPECT_NEAR(P_clone->calculateMax(0, Coords::UNDEFINED), det_width, det_width * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(0, Coords::NBINS), static_cast<double>(det_nx), - det_nx * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(0, Coords::MM), det_width, det_width * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(0, Coords::RADIANS), m_phi, m_phi * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(0, Coords::DEGREES), Units::rad2deg(m_phi), - Units::rad2deg(m_phi) * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(0, Coords::QSPACE), m_kfy, m_kfy * 1e-10); - - EXPECT_NEAR(P_clone->calculateMin(1, Coords::UNDEFINED), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(1, Coords::NBINS), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(1, Coords::MM), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(1, Coords::RADIANS), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(1, Coords::DEGREES), 0.0, 1e-12); - EXPECT_NEAR(P_clone->calculateMin(1, Coords::QSPACE), -m_kiz, std::abs(m_kiz) * 1e-1); - - EXPECT_NEAR(P_clone->calculateMax(1, Coords::UNDEFINED), det_height, det_height * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(1, Coords::NBINS), static_cast<double>(det_ny), - det_ny * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(1, Coords::MM), det_height, det_height * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(1, Coords::RADIANS), m_alpha, m_alpha * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(1, Coords::DEGREES), Units::rad2deg(m_alpha), - Units::rad2deg(m_alpha) * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(1, Coords::QSPACE), m_kfz - m_kiz, - std::abs(m_kfz - m_kiz) * 1e-1); - - EXPECT_FAILED_ASSERT(P_clone->calculateMin(2, Coords::UNDEFINED)); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(2, Coords::UNDEFINED)); -} - -TEST_F(RectangularConverterTest, ImageCoordsWithROI) -{ - const double roi_xmin = 100; - const double roi_xmax = 150; // xmax in roi will be 152 due to binning - const double roi_ymin = 50; - const double roi_ymax = 100; // ymax in roi will be 102 due to binning - - m_detector.setRegionOfInterest(roi_xmin, roi_ymin, roi_xmax, roi_ymax); - ImageCoords converter(m_detector.axesClippedToRegionOfInterest(), m_beam.ki(), - m_detector.regionOfInterestPixel()); - - EXPECT_EQ(converter.calculateMin(0, Coords::UNDEFINED), 100); - EXPECT_EQ(converter.calculateMax(0, Coords::UNDEFINED), 150); - EXPECT_EQ(converter.calculateMin(1, Coords::UNDEFINED), 50); - EXPECT_EQ(converter.calculateMax(1, Coords::UNDEFINED), 100); -} diff --git a/Tests/Unit/Device/SphericalConverterTest.cpp b/Tests/Unit/Device/SphericalConverterTest.cpp deleted file mode 100644 index bf48448b84f25ab58fd8feeff7fcd32d657a9822..0000000000000000000000000000000000000000 --- a/Tests/Unit/Device/SphericalConverterTest.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Device/Beam/Beam.h" -#include "Device/Coord/CoordSystem2D.h" -#include "Device/Detector/SphericalDetector.h" -#include "Tests/GTestWrapper/google_test.h" - -class SphericalConverterTest : public ::testing::Test { -public: - SphericalConverterTest(); - -protected: - SphericalDetector m_detector; - Beam m_beam; - double m_kiz, m_kfy, m_kfz1, m_kfz2; -}; - -SphericalConverterTest::SphericalConverterTest() - : m_detector(100, 0.0, 5.0 * Units::deg, 70, -2.0 * Units::deg, 1.5) - , m_beam(Beam(1, 1.0, 1 * Units::deg)) -{ - const R3 k_i = m_beam.ki(); - m_kiz = k_i.z(); - const double K = m_beam.wavenumber(); - m_kfy = K * std::sin(5.0 * Units::deg); - m_kfz1 = K * std::sin(-2.0 * Units::deg); - m_kfz2 = K * std::sin(1.5); -} - - -TEST_F(SphericalConverterTest, SphericalCoords) -{ - SphericalCoords converter(m_detector.axesClippedToRegionOfInterest(), m_beam.ki()); - - EXPECT_EQ(converter.rank(), 2u); - - EXPECT_DOUBLE_EQ(converter.calculateMin(0, Coords::UNDEFINED), 0.0); - EXPECT_DOUBLE_EQ(converter.calculateMin(0, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(converter.calculateMin(0, Coords::RADIANS), 0.0); - EXPECT_DOUBLE_EQ(converter.calculateMin(0, Coords::DEGREES), 0.0); - EXPECT_DOUBLE_EQ(converter.calculateMin(0, Coords::QSPACE), 0.0); - EXPECT_FAILED_ASSERT(converter.calculateMin(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(converter.calculateMax(0, Coords::UNDEFINED), 5.0); - EXPECT_DOUBLE_EQ(converter.calculateMax(0, Coords::NBINS), 100.0); - EXPECT_DOUBLE_EQ(converter.calculateMax(0, Coords::RADIANS), Units::deg2rad(5.0)); - EXPECT_DOUBLE_EQ(converter.calculateMax(0, Coords::DEGREES), 5.0); - EXPECT_DOUBLE_EQ(converter.calculateMax(0, Coords::QSPACE), m_kfy); - EXPECT_FAILED_ASSERT(converter.calculateMax(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(converter.calculateMin(1, Coords::UNDEFINED), -2.0); - EXPECT_DOUBLE_EQ(converter.calculateMin(1, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(converter.calculateMin(1, Coords::RADIANS), Units::deg2rad(-2.0)); - EXPECT_DOUBLE_EQ(converter.calculateMin(1, Coords::DEGREES), -2.0); - EXPECT_FAILED_ASSERT(converter.calculateMin(1, Coords::MM)); - - EXPECT_DOUBLE_EQ(converter.calculateMax(1, Coords::UNDEFINED), Units::rad2deg(1.5)); - EXPECT_DOUBLE_EQ(converter.calculateMax(1, Coords::NBINS), 70.0); - EXPECT_DOUBLE_EQ(converter.calculateMax(1, Coords::RADIANS), 1.5); - EXPECT_DOUBLE_EQ(converter.calculateMax(1, Coords::DEGREES), Units::rad2deg(1.5)); - EXPECT_FAILED_ASSERT(converter.calculateMax(1, Coords::MM)); - - EXPECT_FAILED_ASSERT(converter.calculateMin(2, Coords::UNDEFINED)); - EXPECT_FAILED_ASSERT(converter.calculateMax(2, Coords::UNDEFINED)); - - std::unique_ptr<Scale> axis(converter.convertedAxis(0, Coords::UNDEFINED)); - EXPECT_EQ(axis->min(), converter.calculateMin(0, Coords::UNDEFINED)); - EXPECT_EQ(axis->max(), converter.calculateMax(0, Coords::UNDEFINED)); - - std::unique_ptr<Scale> axis2(converter.convertedAxis(1, Coords::QSPACE)); - EXPECT_EQ(axis2->min(), converter.calculateMin(1, Coords::QSPACE)); - EXPECT_EQ(axis2->max(), converter.calculateMax(1, Coords::QSPACE)); - - EXPECT_FAILED_ASSERT(converter.convertedAxis(2, Coords::UNDEFINED)); -} - -TEST_F(SphericalConverterTest, SphericalCoordsClone) -{ - SphericalCoords converter(m_detector.axesClippedToRegionOfInterest(), m_beam.ki()); - std::unique_ptr<SphericalCoords> P_clone(converter.clone()); - - EXPECT_EQ(P_clone->rank(), 2u); - - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::UNDEFINED), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::RADIANS), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::DEGREES), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Coords::QSPACE), 0.0); - EXPECT_FAILED_ASSERT(P_clone->calculateMin(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::UNDEFINED), 5.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::NBINS), 100.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::RADIANS), Units::deg2rad(5.0)); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::DEGREES), 5.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Coords::QSPACE), m_kfy); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(0, Coords::MM)); - - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::UNDEFINED), -2.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::NBINS), 0.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::RADIANS), Units::deg2rad(-2.0)); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Coords::DEGREES), -2.0); - EXPECT_FAILED_ASSERT(P_clone->calculateMin(1, Coords::MM)); - - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::UNDEFINED), Units::rad2deg(1.5)); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::NBINS), 70.0); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::RADIANS), 1.5); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Coords::DEGREES), Units::rad2deg(1.5)); - - EXPECT_FAILED_ASSERT(P_clone->calculateMax(1, Coords::MM)); - - EXPECT_FAILED_ASSERT(P_clone->calculateMin(2, Coords::UNDEFINED)); - EXPECT_FAILED_ASSERT(P_clone->calculateMax(2, Coords::UNDEFINED)); -} diff --git a/Tests/Unit/GUI/TestAutosaveController.cpp b/Tests/Unit/GUI/TestAutosaveController.cpp index 161437c0f57a34c659866a6c5b585b6327dbd515..3c9056de3686738f50fdbc2deae20c04c7aac0ba 100644 --- a/Tests/Unit/GUI/TestAutosaveController.cpp +++ b/Tests/Unit/GUI/TestAutosaveController.cpp @@ -1,4 +1,4 @@ -#include "Device/Coord/ICoordSystem.h" +#include "Base/Axis/Frame.h" #include "GUI/Model/Data/DataItemUtil.h" #include "GUI/Model/Data/IntensityDataItem.h" #include "GUI/Model/Device/InstrumentItems.h" @@ -118,10 +118,9 @@ TEST_F(TestAutosaveController, autosaveEnabled) RealItem* realData = UTest::GUI::createRealData("TestData", *document->realModel()); DataItem* intensityItem = realData->dataItem(); intensityItem->setSaveInBackground(false); - const auto converter = - document->instrumentModel()->instrument2DItems().front()->createCoordSystem(); - ASSERT_TRUE(converter); - GUI::Model::DataItemUtil::createDefaultDetectorMap(intensityItem, *converter); + const auto frame = document->instrumentModel()->instrument2DItems().front()->makeFrame(); + ASSERT_TRUE(frame); + GUI::Model::DataItemUtil::createDefaultDetectorMap(intensityItem, *frame); document->clearModified(); EXPECT_FALSE(document->isModified()); diff --git a/Tests/Unit/GUI/TestLinkInstrument.cpp b/Tests/Unit/GUI/TestLinkInstrument.cpp index 5d5d94defe83856f104ec989aaabe76cac0f2fab..0e157da849181acd7cc9edd28d0e58439ba5ed41 100644 --- a/Tests/Unit/GUI/TestLinkInstrument.cpp +++ b/Tests/Unit/GUI/TestLinkInstrument.cpp @@ -1,4 +1,4 @@ -#include "Device/Coord/ICoordSystem.h" +#include "Base/Axis/Frame.h" #include "GUI/Model/Axis/BasicAxisItem.h" #include "GUI/Model/Data/DataItemUtil.h" #include "GUI/Model/Detector/RectangularDetectorItem.h" @@ -38,9 +38,9 @@ TEST(TestLinkInstrument, canLinkToInstrument) // populating real data model, setting intensity data RealItem* realData = UTest::GUI::createRealData("RealData", *document.realModel()); - const auto converter = instrument->createCoordSystem(); - ASSERT_TRUE(converter); - GUI::Model::DataItemUtil::createDefaultDetectorMap(realData->dataItem(), *converter); + const auto frame = instrument->makeFrame(); + ASSERT_TRUE(frame); + GUI::Model::DataItemUtil::createDefaultDetectorMap(realData->dataItem(), *frame); ASSERT_TRUE( document.linkInstrumentManager()->canLinkDataToInstrument(realData, identifier, nullptr)); diff --git a/Tests/Unit/GUI/TestProjectDocument.cpp b/Tests/Unit/GUI/TestProjectDocument.cpp index 371cbe0593771bf7251579d5ba471b64f6e8af40..394bbbf9a2e360b9dc2bae1a9e9d449fa7de0add 100644 --- a/Tests/Unit/GUI/TestProjectDocument.cpp +++ b/Tests/Unit/GUI/TestProjectDocument.cpp @@ -1,4 +1,4 @@ -#include "Device/Coord/ICoordSystem.h" +#include "Base/Axis/Frame.h" #include "GUI/Model/Data/DataItemUtil.h" #include "GUI/Model/Data/IntensityDataItem.h" #include "GUI/Model/Device/InstrumentItems.h" @@ -78,10 +78,9 @@ TEST_F(TestProjectDocument, projectDocumentWithData) RealItem* realData = UTest::GUI::createRealData("TestData", *document.realModel()); ASSERT(realData); DataItem* intensityItem = realData->dataItem(); - const auto converter = - document.instrumentModel()->instrument2DItems().front()->createCoordSystem(); - ASSERT_TRUE(converter); - GUI::Model::DataItemUtil::createDefaultDetectorMap(intensityItem, *converter); + const auto frame = document.instrumentModel()->instrument2DItems().front()->makeFrame(); + ASSERT_TRUE(frame); + GUI::Model::DataItemUtil::createDefaultDetectorMap(intensityItem, *frame); intensityItem->setSaveInBackground(false); document.setProjectDir(projectDir); diff --git a/Tests/Unit/Sim/CoordSystem1DTest.cpp b/Tests/Unit/Sim/CoordSystem1DTest.cpp deleted file mode 100644 index 355df452b35d25affd9bcb7b0b1a046ceea56289..0000000000000000000000000000000000000000 --- a/Tests/Unit/Sim/CoordSystem1DTest.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include "Device/Coord/CoordSystem1D.h" -#include "Base/Axis/MakeScale.h" -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Sim/Scan/QzScan.h" -#include "Tests/GTestWrapper/google_test.h" -#include <algorithm> -#include <numbers> - -using std::numbers::pi; - -class CoordSystem1DTest : public ::testing::Test { -public: - double getQ(double angle) { return 4.0 * pi * std::sin(angle) / m_wavelength; } - -protected: - void checkConventionalConverter(const CoordSystem1D& test_object); - void checkQSpecConverter(const CoordSystem1D& test_object); - Scale m_axis = EquiDivision("Angles", 5, 0.5, 1.0); - Scale m_q_axis = EquiDivision("Q values", 5, 0.0, 1.0); - QzScan m_qscan{m_q_axis}; - double m_wavelength{1.}; -}; - -void CoordSystem1DTest::checkConventionalConverter(const CoordSystem1D& test_object) -{ - double expected_min = m_axis.binCenter(0); - EXPECT_NEAR(test_object.calculateMin(0, Coords::UNDEFINED), Units::rad2deg(expected_min), - Units::rad2deg(expected_min) * 1e-10); - EXPECT_NEAR(test_object.calculateMin(0, Coords::NBINS), 0.0, 1e-10); - EXPECT_NEAR(test_object.calculateMin(0, Coords::RADIANS), expected_min, expected_min * 1e-10); - EXPECT_NEAR(test_object.calculateMin(0, Coords::DEGREES), Units::rad2deg(expected_min), - Units::rad2deg(expected_min) * 1e-10); - EXPECT_NEAR(test_object.calculateMin(0, Coords::QSPACE), getQ(expected_min), - getQ(expected_min) * 1e-10); - - double expected_max = m_axis.binCenters().back(); - EXPECT_NEAR(test_object.calculateMax(0, Coords::UNDEFINED), Units::rad2deg(expected_max), - Units::rad2deg(expected_max) * 1e-10); - EXPECT_NEAR(test_object.calculateMax(0, Coords::NBINS), static_cast<double>(m_axis.size()), - 1e-10); - EXPECT_NEAR(test_object.calculateMax(0, Coords::RADIANS), expected_max, expected_max * 1e-10); - EXPECT_NEAR(test_object.calculateMax(0, Coords::DEGREES), Units::rad2deg(expected_max), - Units::rad2deg(expected_max) * 1e-10); - EXPECT_NEAR(test_object.calculateMax(0, Coords::QSPACE), getQ(expected_max), - getQ(expected_max) * 1e-10); - - // DEFAULT - std::unique_ptr<Scale> axis_default(test_object.convertedAxis(0, Coords::UNDEFINED)); - EXPECT_EQ(axis_default->min(), test_object.calculateMin(0, Coords::UNDEFINED)); - EXPECT_EQ(axis_default->max(), test_object.calculateMax(0, Coords::UNDEFINED)); - - // QSPACE - std::unique_ptr<const Scale> axis_qspace(test_object.convertedAxis(0, Coords::QSPACE)); - EXPECT_EQ(axis_qspace->min(), test_object.calculateMin(0, Coords::QSPACE)); - EXPECT_EQ(axis_qspace->max(), test_object.calculateMax(0, Coords::QSPACE)); - - // NBINS - std::unique_ptr<Scale> axis_nbins(test_object.convertedAxis(0, Coords::NBINS)); - EXPECT_EQ(axis_nbins->min(), test_object.calculateMin(0, Coords::NBINS)); - EXPECT_EQ(axis_nbins->max(), test_object.calculateMax(0, Coords::NBINS)); -} - -void CoordSystem1DTest::checkQSpecConverter(const CoordSystem1D& test_object) -{ - double expected_min = m_q_axis.binCenter(0); - EXPECT_EQ(test_object.calculateMin(0, Coords::UNDEFINED), expected_min); - EXPECT_NEAR(test_object.calculateMin(0, Coords::NBINS), 0.0, 1e-10); - EXPECT_EQ(test_object.calculateMin(0, Coords::QSPACE), expected_min); - - double expected_max = m_q_axis.binCenters().back(); - EXPECT_EQ(test_object.calculateMax(0, Coords::UNDEFINED), expected_max); - EXPECT_NEAR(test_object.calculateMax(0, Coords::NBINS), static_cast<double>(m_q_axis.size()), - 1e-10); - EXPECT_EQ(test_object.calculateMax(0, Coords::QSPACE), expected_max); - - // DEFAULT - std::unique_ptr<Scale> axis_default(test_object.convertedAxis(0, Coords::UNDEFINED)); - EXPECT_EQ(axis_default->min(), test_object.calculateMin(0, Coords::UNDEFINED)); - EXPECT_EQ(axis_default->max(), test_object.calculateMax(0, Coords::UNDEFINED)); - - // QSPACE - std::unique_ptr<Scale> axis_qspace(test_object.convertedAxis(0, Coords::QSPACE)); - EXPECT_EQ(axis_qspace->min(), test_object.calculateMin(0, Coords::QSPACE)); - EXPECT_EQ(axis_qspace->max(), test_object.calculateMax(0, Coords::QSPACE)); - EXPECT_EQ(*axis_default, *axis_qspace); - - // NBINS - std::unique_ptr<Scale> axis_nbins(test_object.convertedAxis(0, Coords::NBINS)); - EXPECT_EQ(axis_nbins->min(), test_object.calculateMin(0, Coords::NBINS)); - EXPECT_EQ(axis_nbins->max(), test_object.calculateMax(0, Coords::NBINS)); -} - -TEST_F(CoordSystem1DTest, MainFunctionality) -{ - checkConventionalConverter(AngularReflectometryCoords(m_wavelength, m_axis)); - checkQSpecConverter(WavenumberReflectometryCoords(m_qscan.coordinateAxis()->clone())); -} - -TEST_F(CoordSystem1DTest, Exceptions) -{ - AngularReflectometryCoords converter(m_wavelength, m_axis); - - EXPECT_FAILED_ASSERT(converter.calculateMin(0, Coords::MM)); - EXPECT_FAILED_ASSERT(converter.calculateMin(1, Coords::RADIANS)); - - EXPECT_FAILED_ASSERT(converter.calculateMax(0, Coords::MM)); - EXPECT_FAILED_ASSERT(converter.calculateMax(1, Coords::RADIANS)); - - EXPECT_FAILED_ASSERT(converter.convertedAxis(0, Coords::MM)); - EXPECT_FAILED_ASSERT(converter.convertedAxis(1, Coords::UNDEFINED)); - - Scale axis = EquiDivision("Angles", 100, 0.0, (2 * pi)); - EXPECT_FAILED_ASSERT(AngularReflectometryCoords converter2(m_wavelength, axis)); - - WavenumberReflectometryCoords converter2(m_qscan.coordinateAxis()->clone()); - // wrong units - EXPECT_FAILED_ASSERT(converter2.calculateMin(0, Coords::MM)); - EXPECT_FAILED_ASSERT(converter2.calculateMin(0, Coords::RADIANS)); - EXPECT_FAILED_ASSERT(converter2.calculateMin(0, Coords::DEGREES)); - EXPECT_FAILED_ASSERT(converter2.calculateMax(0, Coords::MM)); - EXPECT_FAILED_ASSERT(converter2.calculateMax(0, Coords::RADIANS)); - EXPECT_FAILED_ASSERT(converter2.calculateMax(0, Coords::DEGREES)); - EXPECT_FAILED_ASSERT(converter2.convertedAxis(0, Coords::MM)); - - // wrong axis index - EXPECT_FAILED_ASSERT(converter2.calculateMin(1, Coords::QSPACE)); - EXPECT_FAILED_ASSERT(converter2.convertedAxis(1, Coords::UNDEFINED)); -} - -TEST_F(CoordSystem1DTest, Clone) -{ - AngularReflectometryCoords converter(m_wavelength, m_axis); - std::unique_ptr<CoordSystem1D> converter_clone(converter.clone()); - checkConventionalConverter(*converter_clone); - - WavenumberReflectometryCoords converterQ(m_qscan.coordinateAxis()->clone()); - std::unique_ptr<CoordSystem1D> converterQ_clone(converterQ.clone()); - checkQSpecConverter(*converterQ_clone); -} - -TEST_F(CoordSystem1DTest, NonDefaultUnitsInInput) -{ - Scale axis = ListScan("x", std::vector<double>{0.0, 0.5, 1.0}); - - { - AngularReflectometryCoords converter(m_wavelength, axis, Coords::DEGREES); - auto out = converter.convertedAxis(0, Coords::DEGREES); - EXPECT_TRUE(axis.size() == out->size()); - EXPECT_DOUBLE_EQ(axis.binCenter(0), out->binCenter(0)); - EXPECT_DOUBLE_EQ(axis.binCenter(1), out->binCenter(1)); - EXPECT_DOUBLE_EQ(axis.binCenter(2), out->binCenter(2)); - } - - auto values = axis.binCenters(); - std::for_each(values.begin(), values.end(), [this](double& value) { value = getQ(value); }); - Scale q_axis = ListScan("q", values); - { - AngularReflectometryCoords converter(m_wavelength, q_axis, Coords::QSPACE); - auto out = converter.convertedAxis(0, Coords::RADIANS); - EXPECT_TRUE(axis.size() == out->size()); - EXPECT_DOUBLE_EQ(axis.binCenter(0), out->binCenter(0)); - EXPECT_DOUBLE_EQ(axis.binCenter(1), out->binCenter(1)); - EXPECT_DOUBLE_EQ(axis.binCenter(2), out->binCenter(2)); - } -} diff --git a/Tests/Unit/Sim/FittingTestHelper.h b/Tests/Unit/Sim/FittingTestHelper.h index 28604de2093500ef18a526607395951a76bb6121..cb8a51d37d6eb00d713aa503c216675d214ae3cf 100644 --- a/Tests/Unit/Sim/FittingTestHelper.h +++ b/Tests/Unit/Sim/FittingTestHelper.h @@ -51,8 +51,8 @@ public: std::unique_ptr<Datafield> createTestData(double value) { std::unique_ptr<Datafield> result( - new Datafield({newEquiDivision("phi_f", m_nx, m_xmin, m_xmax), - newEquiDivision("alpha_f", m_ny, m_ymin, m_ymax)})); + new Datafield({newEquiDivision("phi_f (rad)", m_nx, m_xmin, m_xmax), + newEquiDivision("alpha_f (rad)", m_ny, m_ymin, m_ymax)})); result->setAllTo(value); return result; } diff --git a/Tests/Unit/Sim/SpecularSimulationTest.cpp b/Tests/Unit/Sim/SpecularSimulationTest.cpp deleted file mode 100644 index 3aaf5600d388c575a298b50219522575779a4f1e..0000000000000000000000000000000000000000 --- a/Tests/Unit/Sim/SpecularSimulationTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "Sim/Simulation/SpecularSimulation.h" -#include "Base/Axis/MakeScale.h" -#include "Base/Axis/Scale.h" -#include "Base/Const/Units.h" -#include "Device/Beam/Beam.h" -#include "Device/Data/Datafield.h" -#include "Device/Detector/IDetector.h" -#include "Device/Histo/SimulationResult.h" -#include "Param/Distrib/Distributions.h" -#include "Sample/Material/MaterialFactoryFuncs.h" -#include "Sample/Multilayer/Layer.h" -#include "Sample/Multilayer/MultiLayer.h" -#include "Sim/Background/ConstantBackground.h" -#include "Sim/Scan/AlphaScan.h" -#include "Sim/Scan/QzScan.h" -#include "Tests/GTestWrapper/google_test.h" -#include <iostream> -#include <numbers> - -using std::numbers::pi; - -class SpecularSimulationTest : public ::testing::Test { -protected: - SpecularSimulationTest(); - - std::unique_ptr<SpecularSimulation> defaultSimulation(); - - MultiLayer sample; -}; - -SpecularSimulationTest::SpecularSimulationTest() -{ - Material mat0 = RefractiveMaterial("ambience", 0.0, 0.0); - Material mat1 = RefractiveMaterial("PartA", 5e-6, 0.0); - Material mat2 = RefractiveMaterial("substrate", 15e-6, 0.0); - - Layer layer0(mat0); - Layer layer1(mat1, 10 * Units::nm); - Layer layer2(mat2); - - sample.addLayer(layer0); - sample.addLayer(layer1); - sample.addLayer(layer2); -} - -std::unique_ptr<SpecularSimulation> SpecularSimulationTest::defaultSimulation() -{ - AlphaScan scan(EquiDivision("axis", 10, 0.0 * Units::deg, 2.0 * Units::deg)); - scan.setWavelength(1.0); - return std::make_unique<SpecularSimulation>(scan, sample); -} - -TEST_F(SpecularSimulationTest, ConstructSimulation) -{ - auto sim = defaultSimulation(); - - EXPECT_EQ(3u, sim->sample()->numberOfLayers()); - - const SimulationResult sim_result = sim->simulate(); - - EXPECT_EQ(sim_result.size(), 10u); - EXPECT_EQ(sim_result.rank(), 1u); - - EXPECT_NEAR(0.1 * Units::deg, sim_result.convertedBinCenters(Coords::RADIANS).front(), - Units::deg * 1e-11); - EXPECT_NEAR(1.9 * Units::deg, sim_result.convertedBinCenters(Coords::RADIANS).back(), - Units::deg * 1e-10); -} diff --git a/Wrap/Python/ba_fitmonitor.py b/Wrap/Python/ba_fitmonitor.py index 2c2c92fd053d42f432f8451b649962063eb341aa..7d1f9b0149d9972b603d4befbefbb7c2545ce619 100644 --- a/Wrap/Python/ba_fitmonitor.py +++ b/Wrap/Python/ba_fitmonitor.py @@ -31,7 +31,6 @@ class Plotter: zmax=None, xlabel=None, ylabel=None, - units=ba.Coords_UNDEFINED, aspect=None): self._fig = plt.figure(figsize=(10.25, 7.69)) @@ -40,7 +39,6 @@ class Plotter: self._zmax = zmax self._xlabel = xlabel self._ylabel = ylabel - self._units = units self._aspect = aspect def __call__(self, fit_objective): @@ -64,9 +62,8 @@ class PlotterGISAS(Plotter): zmax=None, xlabel=None, ylabel=None, - units=ba.Coords_UNDEFINED, aspect=None): - Plotter.__init__(self, zmin, zmax, xlabel, ylabel, units, aspect) + Plotter.__init__(self, zmin, zmax, xlabel, ylabel, aspect) @staticmethod def make_subplot(nplot): @@ -91,7 +88,6 @@ class PlotterGISAS(Plotter): title="Experimental data", intensity_min=zmin, intensity_max=zmax, - units=self._units, xlabel=self._xlabel, ylabel=self._ylabel, zlabel='', @@ -102,7 +98,6 @@ class PlotterGISAS(Plotter): title="Simulated data", intensity_min=zmin, intensity_max=zmax, - units=self._units, xlabel=self._xlabel, ylabel=self._ylabel, zlabel='', @@ -113,7 +108,6 @@ class PlotterGISAS(Plotter): title="Difference", intensity_min=zmin, intensity_max=zmax, - units=self._units, xlabel=self._xlabel, ylabel=self._ylabel, zlabel='', @@ -145,8 +139,7 @@ class PlotterSpecular: Draws fit progress, for specular simulation. """ - def __init__(self, units=ba.Coords_UNDEFINED, pause=0.0): - self.units = units + def __init__(self, pause=0.0): self.pause = pause self._fig = plt.figure(figsize=(10, 7)) self._fig.canvas.draw() @@ -162,10 +155,9 @@ class PlotterSpecular: unc_data = fit_objective.uncertaintyData() # data values - sim_values = sim_data.array(self.units) - exp_values = exp_data.array(self.units) - unc_values = None if unc_data is None else unc_data.array( - self.units) + sim_values = sim_data.array() + exp_values = exp_data.array() + unc_values = None if unc_data is None else unc_data.array() # default font properties dictionary to use font = { 'size': 16 } @@ -184,7 +176,7 @@ class PlotterSpecular: alpha=0.6) plt.plot(sim_data.convertedBinCenters(), sim_values, 'b') - xlabel = bp.get_axes_labels(exp_data, self.units)[0] + xlabel = bp.get_axes_labels(exp_data)[0] legend = ['Experiment', 'BornAgain'] if unc_values is not None: legend = ['Experiment', r'Exp $\pm \sigma$', 'BornAgain'] diff --git a/Wrap/Python/ba_plot.py b/Wrap/Python/ba_plot.py index e49f3c3f5a9ebbd8b5e17c6c0c2b52e4576c9c36..1e456d7dd6876ab86756dc234b66cb8543d49d76 100644 --- a/Wrap/Python/ba_plot.py +++ b/Wrap/Python/ba_plot.py @@ -111,16 +111,15 @@ def parse_commandline(): parse_any(tmp) -def get_axes_limits(result, units): +def get_axes_limits(result): """ Returns axes range as expected by pyplot.imshow. :param result: SimulationResult object from a Simulation - :param units: units to use :return: axes ranges as a flat list """ limits = [] for i in range(result.rank()): - ami, ama = result.axisMinMax(i, units) + ami, ama = result.axisMinMax(i) assert ami < ama, f'SimulationResult has invalid axis {i}, extending from {ami} to {ama}' limits.append(ami) limits.append(ama) @@ -135,38 +134,37 @@ def translate_axis_label(label): :return: LaTeX representation """ label_dict = { - 'X [nbins]': r'$X \; $(bins)', - 'X [mm]': r'$X \; $(mm)', - 'Y [nbins]': r'$Y \; $(bins)', - 'Y [mm]': r'$Y \; $(mm)', - 'phi_f [rad]': r'$\varphi_f \; $(rad)', - 'phi_f [deg]': r'$\varphi_f \;(^\circ)$', - 'alpha_i [rad]': r'$\alpha_{\rm i} \; $(rad)', - 'alpha_i [deg]': r'$\alpha_{\rm i} \;(^\circ)$', - 'alpha_f [rad]': r'$\alpha_{\rm f} \; $(rad)', - 'alpha_f [deg]': r'$\alpha_{\rm f} \;(^\circ)$', - 'Qx [1/nm]': r'$Q_x \; $(nm$^{-1}$)', - 'Qy [1/nm]': r'$Q_y \; $(nm$^{-1}$)', - 'Qz [1/nm]': r'$Q_z \; $(nm$^{-1}$)', - 'Q [1/nm]': r'$Q \; $(nm$^{-1}$)', - 'Position [nm]': r'Position (nm)' + 'X (nbins)': r'$X \; $(bins)', + 'X (mm)': r'$X \; $(mm)', + 'Y (nbins)': r'$Y \; $(bins)', + 'Y (mm)': r'$Y \; $(mm)', + 'phi_f (rad)': r'$\varphi_f \; $(rad)', + 'phi_f (deg)': r'$\varphi_f \;(^\circ)$', + 'alpha_i (rad)': r'$\alpha_{\rm i} \; $(rad)', + 'alpha_i (deg)': r'$\alpha_{\rm i} \;(^\circ)$', + 'alpha_f (rad)': r'$\alpha_{\rm f} \; $(rad)', + 'alpha_f (deg)': r'$\alpha_{\rm f} \;(^\circ)$', + 'Qx (1/nm)': r'$Q_x \; $(nm$^{-1}$)', + 'Qy (1/nm)': r'$Q_y \; $(nm$^{-1}$)', + 'Qz (1/nm)': r'$Q_z \; $(nm$^{-1}$)', + 'Q (1/nm)': r'$Q \; $(nm$^{-1}$)', + 'Position (nm)': r'Position (nm)' } if label in label_dict.keys(): return label_dict[label] return label -def get_axes_labels(result, units): +def get_axes_labels(result): """ Returns axes range as expected by pyplot.imshow. :param result: SimulationResult object from a Simulation - :param units: units to use :return: axes ranges as a flat list Used internally and in Examples/fit/specular/RealLifeReflectometryFitting.py. """ labels = [] for i in range(result.rank()): - labels.append(translate_axis_label(result.name_of_axis(i, units))) + labels.append(translate_axis_label(result.name_of_axis(i))) return labels @@ -197,12 +195,10 @@ def plot_specular_curve(result): :param result: SimulationResult from SpecularSimulation Used internally. """ - units = plotargs.pop('units', ba.Coords_UNDEFINED) + intensity = result.array() + x_axis = result.convertedBinCenters() - intensity = result.array(units) - x_axis = result.convertedBinCenters(units) - - xlabel = plotargs.pop('xlabel', get_axes_labels(result, units)[0]) + xlabel = plotargs.pop('xlabel', get_axes_labels(result)[0]) ylabel = plotargs.pop('ylabel', "Intensity") plt.yscale('log') @@ -405,9 +401,8 @@ def plot_simres(result, **kwargs): Used internally and in a few examples. """ - units = kwargs.pop('units', ba.Coords_UNDEFINED) - axes_limits = get_axes_limits(result, units) - axes_labels = get_axes_labels(result, units) + axes_limits = get_axes_limits(result) + axes_labels = get_axes_labels(result) if 'xlabel' not in kwargs: kwargs['xlabel'] = axes_labels[0] @@ -425,7 +420,6 @@ def parse_args(**kwargs): Ingests plot options: :param intensity_min: Min value on amplitude's axis or color legend :param intensity_max: Max value on amplitude's axis or color legend - :param units: units for plot axes :param ymin: minimal y-axis value to show :param ymax: maximum y-axis value to show :param zmin: Min value on amplitude's color legend @@ -493,7 +487,7 @@ def make_plot(results, ncol): # Plot the subfigures. for i, result in enumerate(results): ax = multiPlot.axes[i] - axes_limits = get_axes_limits(result, ba.Coords_UNDEFINED) + axes_limits = get_axes_limits(result) im = ax.imshow(result.array(), cmap=cmap, @@ -544,7 +538,7 @@ def plot_multicurve(results, xlabel, ylabel): def plot_multicurve_specular(results): plt.yscale('log') - xlabel = get_axes_labels(results[0], ba.Coords_UNDEFINED)[0] + xlabel = get_axes_labels(results[0])[0] plot_multicurve(results, xlabel, r'Intensity') # ************************************************************************** # diff --git a/Wrap/Swig/libBornAgainDevice.i b/Wrap/Swig/libBornAgainDevice.i index 8c53a900ef1e52bafe62a050d3f9c8570ed076c8..602ce32e99b429c760e657f47f017c364aa75e53 100644 --- a/Wrap/Swig/libBornAgainDevice.i +++ b/Wrap/Swig/libBornAgainDevice.i @@ -67,8 +67,6 @@ %include "Device/Resolution/IResolutionFunction2D.h" %include "Device/Resolution/ResolutionFunction2DGaussian.h" -%include "Device/Coord/Tags.h" - %include "Device/Mask/DetectorMask.h" %include "Device/Detector/IDetector.h" %include "Device/Detector/RectangularDetector.h" diff --git a/Wrap/Swig/libBornAgainSim.i b/Wrap/Swig/libBornAgainSim.i index 1eb97a0635df2f8bdb7a20b36c1810a914d1e3dc..68def7b4104cc8e37c16accc468c25216f504837 100644 --- a/Wrap/Swig/libBornAgainSim.i +++ b/Wrap/Swig/libBornAgainSim.i @@ -71,6 +71,7 @@ #include "Sim/Residual/IIntensityFunction.h" #include "Sim/Residual/VarianceFunctions.h" #include "Sim/Scan/AlphaScan.h" +#include "Sim/Scan/LambdaScan.h" #include "Sim/Scan/QzScan.h" #include "Sim/Simulation/DepthprobeSimulation.h" #include "Sim/Simulation/ScatteringSimulation.h" @@ -96,6 +97,7 @@ %include "Sim/Scan/IBeamScan.h" %include "Sim/Scan/AlphaScan.h" +%include "Sim/Scan/LambdaScan.h" %include "Sim/Scan/QzScan.h" %include "Sim/Simulation/ISimulation.h" diff --git a/auto/Examples/fit/specular/Honeycomb_fit.py b/auto/Examples/fit/specular/Honeycomb_fit.py index 78bcbd7751d45195444db4e106d5efffeb826ce6..e9dc5fa803305e2f3892401c3e4d4c717664c62a 100755 --- a/auto/Examples/fit/specular/Honeycomb_fit.py +++ b/auto/Examples/fit/specular/Honeycomb_fit.py @@ -109,8 +109,8 @@ def qr(result): """ Return q and reflectivity arrays from simulation result. """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r diff --git a/auto/Examples/fit/specular/PolarizedSpinAsymmetry.py b/auto/Examples/fit/specular/PolarizedSpinAsymmetry.py index a172b5d77ed5380ac39e5180c2fe46deff34f7ea..5f4235c6d2924485ad136ddbe1e60afc881522b6 100755 --- a/auto/Examples/fit/specular/PolarizedSpinAsymmetry.py +++ b/auto/Examples/fit/specular/PolarizedSpinAsymmetry.py @@ -101,8 +101,8 @@ def qr(result): Returns two arrays that hold the q-values as well as the reflectivity from a given simulation result """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r @@ -112,35 +112,6 @@ def qr(result): #################################################################### -def plot(qs, rs, exps, labels, filename): - """ - Plot the simulated result together with the experimental data - """ - fig = plt.figure() - ax = fig.add_subplot(111) - - for q, r, exp, l in zip(qs, rs, exps, labels): - - ax.errorbar(exp[0], - exp[1], - xerr=exp[3], - yerr=exp[2], - fmt='.', - markersize=0.75, - linewidth=0.5) - - ax.plot(q, r, label=l) - - ax.set_yscale('log') - plt.legend() - - plt.xlabel("Q [nm${}^{-1}$]") - plt.ylabel("R") - - plt.tight_layout() - plt.savefig(filename) - - def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm, filename): """ Plot the simulated spin asymmetry as well its @@ -184,13 +155,6 @@ def load_exp(fname): return numpy.transpose(dat) -def filterData(data, qmin, qmax): - minIndex = numpy.argmin(numpy.abs(data[0] - qmin)) - maxIndex = numpy.argmin(numpy.abs(data[0] - qmax)) - - return data[:, minIndex:maxIndex + 1] - - #################################################################### # Main Function # #################################################################### @@ -229,13 +193,34 @@ if __name__ == '__main__': q_pp, r_pp = qr(run_Simulation_pp(qzs, fixedP)) q_mm, r_mm = qr(run_Simulation_mm(qzs, fixedP)) - data_pp = filterData(expdata_pp, qmin, qmax) - data_mm = filterData(expdata_mm, qmin, qmax) + fig = plt.figure() + ax = fig.add_subplot(111) - plot([q_pp, q_mm], [r_pp, r_mm], [data_pp, data_mm], ["$++$", "$--$"], - "MAFO_Saturated.pdf") + def plot_data(exp): + ax.errorbar(exp[0], + exp[1], + xerr=exp[3], + yerr=exp[2], + fmt='.', + markersize=0.75, + linewidth=0.5) + + plot_data(expdata_pp) + plot_data(expdata_mm) + + ax.plot(q_pp, r_pp, label="$++$") + ax.plot(q_mm, r_mm, label="$--$") + + ax.set_yscale('log') + plt.legend() + + plt.xlabel("Q [nm${}^{-1}$]") + plt.ylabel("R") + + plt.tight_layout() + # plt.savefig("MAFO_Saturated.pdf") - plotSpinAsymmetry(data_pp, data_mm, qzs, r_pp, r_mm, + plotSpinAsymmetry(expdata_pp, expdata_mm, qzs, r_pp, r_mm, "MAFO_Saturated_spin_asymmetry.pdf") bp.show_or_export() diff --git a/auto/Examples/fit/specular/Pt_layer_fit.py b/auto/Examples/fit/specular/Pt_layer_fit.py index 0c68580818fb2b7de36e63f890a777837fb9498f..de39eb13832791629717cc2040e15e6a41b1357b 100755 --- a/auto/Examples/fit/specular/Pt_layer_fit.py +++ b/auto/Examples/fit/specular/Pt_layer_fit.py @@ -88,8 +88,8 @@ def qr(result): """ Return q and reflectivity arrays from simulation result. """ - q = np.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = np.array(result.array(ba.Coords_QSPACE)) + q = np.array(result.convertedBinCenters()) + r = np.array(result.array()) return q, r diff --git a/auto/Examples/offspec/OffspecLambda.py b/auto/Examples/offspec/OffspecLambda.py new file mode 100755 index 0000000000000000000000000000000000000000..d8112e8adf8f8671fd9e7985df5b90884cc069ba --- /dev/null +++ b/auto/Examples/offspec/OffspecLambda.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +""" +Basic offspec example. +Sample is a grating on a substrate, modelled by a 1d lattice of long boxes +""" +import bornagain as ba +from bornagain import ba_plot as bp, deg, nm + + +def get_sample(): + # Materials + material_particle = ba.RefractiveMaterial("Particle", 0.0006, 2e-08) + material_substrate = ba.RefractiveMaterial("Substrate", 6e-06, 2e-08) + vacuum = ba.RefractiveMaterial("Vacuum", 0, 0) + + # Particles + ff = ba.Box(1000*nm, 20*nm, 10*nm) + particle = ba.Particle(material_particle, ff) + particle_rotation = ba.RotationZ(90*deg) + particle.rotate(particle_rotation) + + # Interference functions + iff = ba.Interference1DLattice(100*nm, 0) + iff_pdf = ba.Profile1DCauchy(1e6*nm) + iff.setDecayFunction(iff_pdf) + + # Particle layouts + layout = ba.ParticleLayout() + layout.addParticle(particle) + layout.setInterference(iff) + layout.setTotalParticleSurfaceDensity(0.01) + + # Layers + layer_1 = ba.Layer(vacuum) + layer_1.addLayout(layout) + layer_2 = ba.Layer(material_substrate) + + # Sample + sample = ba.MultiLayer() + sample.addLayer(layer_1) + sample.addLayer(layer_2) + + return sample + + +def get_simulation(sample): + nscan = 200 + ny = 50 + scan = ba.LambdaScan(1.5 * deg, nscan, 0.1*nm, 10*nm) + scan.setIntensity(1e9) + detector = ba.OffspecDetector(ny, -1*deg, +1*deg, nscan, 0.1*deg, 10*deg) + return ba.OffspecSimulation(scan, sample, detector) + + +if __name__ == '__main__': + bp.parse_args(intensity_min=1) + sample = get_sample() + simulation = get_simulation(sample) + result = simulation.simulate() + bp.plot_simulation_result(result) diff --git a/auto/Examples/scatter2d/PolarizedSANS.py b/auto/Examples/scatter2d/PolarizedSANS.py index 5ced3bf2976b7249b87eed0c0337a5d4b636f55e..a780d6775d58651f1d5c0c21be37f81bafaaae8d 100755 --- a/auto/Examples/scatter2d/PolarizedSANS.py +++ b/auto/Examples/scatter2d/PolarizedSANS.py @@ -69,7 +69,6 @@ def get_simulation(sample): if __name__ == '__main__': - bp.parse_args(units=ba.Coords_QSPACE) sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() diff --git a/auto/Examples/scatter2d/PositionVariance.py b/auto/Examples/scatter2d/PositionVariance.py index 7c8915d9b8f82fc8446fac44bb3ec9f8cbfc6969..25279a1fdea61c98dfd49de442e18feb22bf39a4 100755 --- a/auto/Examples/scatter2d/PositionVariance.py +++ b/auto/Examples/scatter2d/PositionVariance.py @@ -60,7 +60,6 @@ def run_one(hasVariance, xi, nPlot, title): title=title, intensity_max=3e7, intensity_min=3e0, - zlabel=None, aspect='equal', with_cb=False) diff --git a/auto/Examples/specular/PolarizedSpinAsymmetry.py b/auto/Examples/specular/PolarizedSpinAsymmetry.py index a172b5d77ed5380ac39e5180c2fe46deff34f7ea..5f4235c6d2924485ad136ddbe1e60afc881522b6 100755 --- a/auto/Examples/specular/PolarizedSpinAsymmetry.py +++ b/auto/Examples/specular/PolarizedSpinAsymmetry.py @@ -101,8 +101,8 @@ def qr(result): Returns two arrays that hold the q-values as well as the reflectivity from a given simulation result """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r @@ -112,35 +112,6 @@ def qr(result): #################################################################### -def plot(qs, rs, exps, labels, filename): - """ - Plot the simulated result together with the experimental data - """ - fig = plt.figure() - ax = fig.add_subplot(111) - - for q, r, exp, l in zip(qs, rs, exps, labels): - - ax.errorbar(exp[0], - exp[1], - xerr=exp[3], - yerr=exp[2], - fmt='.', - markersize=0.75, - linewidth=0.5) - - ax.plot(q, r, label=l) - - ax.set_yscale('log') - plt.legend() - - plt.xlabel("Q [nm${}^{-1}$]") - plt.ylabel("R") - - plt.tight_layout() - plt.savefig(filename) - - def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm, filename): """ Plot the simulated spin asymmetry as well its @@ -184,13 +155,6 @@ def load_exp(fname): return numpy.transpose(dat) -def filterData(data, qmin, qmax): - minIndex = numpy.argmin(numpy.abs(data[0] - qmin)) - maxIndex = numpy.argmin(numpy.abs(data[0] - qmax)) - - return data[:, minIndex:maxIndex + 1] - - #################################################################### # Main Function # #################################################################### @@ -229,13 +193,34 @@ if __name__ == '__main__': q_pp, r_pp = qr(run_Simulation_pp(qzs, fixedP)) q_mm, r_mm = qr(run_Simulation_mm(qzs, fixedP)) - data_pp = filterData(expdata_pp, qmin, qmax) - data_mm = filterData(expdata_mm, qmin, qmax) + fig = plt.figure() + ax = fig.add_subplot(111) - plot([q_pp, q_mm], [r_pp, r_mm], [data_pp, data_mm], ["$++$", "$--$"], - "MAFO_Saturated.pdf") + def plot_data(exp): + ax.errorbar(exp[0], + exp[1], + xerr=exp[3], + yerr=exp[2], + fmt='.', + markersize=0.75, + linewidth=0.5) + + plot_data(expdata_pp) + plot_data(expdata_mm) + + ax.plot(q_pp, r_pp, label="$++$") + ax.plot(q_mm, r_mm, label="$--$") + + ax.set_yscale('log') + plt.legend() + + plt.xlabel("Q [nm${}^{-1}$]") + plt.ylabel("R") + + plt.tight_layout() + # plt.savefig("MAFO_Saturated.pdf") - plotSpinAsymmetry(data_pp, data_mm, qzs, r_pp, r_mm, + plotSpinAsymmetry(expdata_pp, expdata_mm, qzs, r_pp, r_mm, "MAFO_Saturated_spin_asymmetry.pdf") bp.show_or_export() diff --git a/auto/Examples/varia/Depthprobe1.py b/auto/Examples/varia/Depthprobe1.py index 277c88d840c6dbbce1c94adb055e3efa30a8dbc0..2d9c1a5f828f20e5f8ad92c5784ff0080a7ec415 100755 --- a/auto/Examples/varia/Depthprobe1.py +++ b/auto/Examples/varia/Depthprobe1.py @@ -27,7 +27,7 @@ def get_simulation(sample, flags): scan = ba.AlphaScan(n, 0*deg, 1*deg) scan.setWavelength(0.3*nm) - z_axis = ba.EquiDivision("z", n, -130*nm, 30*nm) + z_axis = ba.EquiDivision("z (nm)", n, -130*nm, 30*nm) simulation = ba.DepthprobeSimulation(scan, sample, z_axis, flags) return simulation diff --git a/auto/Examples/varia/Resonator.py b/auto/Examples/varia/Resonator.py index b8bfe709db5310d4b8aae30335db817a7383fd89..a4a83daa7939cef46f96904e9cad229115210af1 100755 --- a/auto/Examples/varia/Resonator.py +++ b/auto/Examples/varia/Resonator.py @@ -73,7 +73,7 @@ def get_simulation(sample): footprint = ba.FootprintSquare(0.01) scan.setFootprint(footprint) - z_axis = ba.EquiDivision("z", nz, z_min, z_max) + z_axis = ba.EquiDivision("z (nm)", nz, z_min, z_max) simulation = ba.DepthprobeSimulation(scan, sample, z_axis) alpha_distr = ba.DistributionGaussian(0, d_ang, 25, 3.) diff --git a/auto/MiniExamples/fit/specular/Honeycomb_fit.py b/auto/MiniExamples/fit/specular/Honeycomb_fit.py index 78bcbd7751d45195444db4e106d5efffeb826ce6..e9dc5fa803305e2f3892401c3e4d4c717664c62a 100755 --- a/auto/MiniExamples/fit/specular/Honeycomb_fit.py +++ b/auto/MiniExamples/fit/specular/Honeycomb_fit.py @@ -109,8 +109,8 @@ def qr(result): """ Return q and reflectivity arrays from simulation result. """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r diff --git a/auto/MiniExamples/fit/specular/PolarizedSpinAsymmetry.py b/auto/MiniExamples/fit/specular/PolarizedSpinAsymmetry.py index a172b5d77ed5380ac39e5180c2fe46deff34f7ea..5f4235c6d2924485ad136ddbe1e60afc881522b6 100755 --- a/auto/MiniExamples/fit/specular/PolarizedSpinAsymmetry.py +++ b/auto/MiniExamples/fit/specular/PolarizedSpinAsymmetry.py @@ -101,8 +101,8 @@ def qr(result): Returns two arrays that hold the q-values as well as the reflectivity from a given simulation result """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r @@ -112,35 +112,6 @@ def qr(result): #################################################################### -def plot(qs, rs, exps, labels, filename): - """ - Plot the simulated result together with the experimental data - """ - fig = plt.figure() - ax = fig.add_subplot(111) - - for q, r, exp, l in zip(qs, rs, exps, labels): - - ax.errorbar(exp[0], - exp[1], - xerr=exp[3], - yerr=exp[2], - fmt='.', - markersize=0.75, - linewidth=0.5) - - ax.plot(q, r, label=l) - - ax.set_yscale('log') - plt.legend() - - plt.xlabel("Q [nm${}^{-1}$]") - plt.ylabel("R") - - plt.tight_layout() - plt.savefig(filename) - - def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm, filename): """ Plot the simulated spin asymmetry as well its @@ -184,13 +155,6 @@ def load_exp(fname): return numpy.transpose(dat) -def filterData(data, qmin, qmax): - minIndex = numpy.argmin(numpy.abs(data[0] - qmin)) - maxIndex = numpy.argmin(numpy.abs(data[0] - qmax)) - - return data[:, minIndex:maxIndex + 1] - - #################################################################### # Main Function # #################################################################### @@ -229,13 +193,34 @@ if __name__ == '__main__': q_pp, r_pp = qr(run_Simulation_pp(qzs, fixedP)) q_mm, r_mm = qr(run_Simulation_mm(qzs, fixedP)) - data_pp = filterData(expdata_pp, qmin, qmax) - data_mm = filterData(expdata_mm, qmin, qmax) + fig = plt.figure() + ax = fig.add_subplot(111) - plot([q_pp, q_mm], [r_pp, r_mm], [data_pp, data_mm], ["$++$", "$--$"], - "MAFO_Saturated.pdf") + def plot_data(exp): + ax.errorbar(exp[0], + exp[1], + xerr=exp[3], + yerr=exp[2], + fmt='.', + markersize=0.75, + linewidth=0.5) + + plot_data(expdata_pp) + plot_data(expdata_mm) + + ax.plot(q_pp, r_pp, label="$++$") + ax.plot(q_mm, r_mm, label="$--$") + + ax.set_yscale('log') + plt.legend() + + plt.xlabel("Q [nm${}^{-1}$]") + plt.ylabel("R") + + plt.tight_layout() + # plt.savefig("MAFO_Saturated.pdf") - plotSpinAsymmetry(data_pp, data_mm, qzs, r_pp, r_mm, + plotSpinAsymmetry(expdata_pp, expdata_mm, qzs, r_pp, r_mm, "MAFO_Saturated_spin_asymmetry.pdf") bp.show_or_export() diff --git a/auto/MiniExamples/fit/specular/Pt_layer_fit.py b/auto/MiniExamples/fit/specular/Pt_layer_fit.py index 0c68580818fb2b7de36e63f890a777837fb9498f..de39eb13832791629717cc2040e15e6a41b1357b 100755 --- a/auto/MiniExamples/fit/specular/Pt_layer_fit.py +++ b/auto/MiniExamples/fit/specular/Pt_layer_fit.py @@ -88,8 +88,8 @@ def qr(result): """ Return q and reflectivity arrays from simulation result. """ - q = np.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = np.array(result.array(ba.Coords_QSPACE)) + q = np.array(result.convertedBinCenters()) + r = np.array(result.array()) return q, r diff --git a/auto/MiniExamples/offspec/OffspecLambda.py b/auto/MiniExamples/offspec/OffspecLambda.py new file mode 100755 index 0000000000000000000000000000000000000000..fe0377c6f31b080c5990aeb2eef6742a64f892ae --- /dev/null +++ b/auto/MiniExamples/offspec/OffspecLambda.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +""" +Basic offspec example. +Sample is a grating on a substrate, modelled by a 1d lattice of long boxes +""" +import bornagain as ba +from bornagain import ba_plot as bp, deg, nm + + +def get_sample(): + # Materials + material_particle = ba.RefractiveMaterial("Particle", 0.0006, 2e-08) + material_substrate = ba.RefractiveMaterial("Substrate", 6e-06, 2e-08) + vacuum = ba.RefractiveMaterial("Vacuum", 0, 0) + + # Particles + ff = ba.Box(1000*nm, 20*nm, 10*nm) + particle = ba.Particle(material_particle, ff) + particle_rotation = ba.RotationZ(90*deg) + particle.rotate(particle_rotation) + + # Interference functions + iff = ba.Interference1DLattice(100*nm, 0) + iff_pdf = ba.Profile1DCauchy(1e6*nm) + iff.setDecayFunction(iff_pdf) + + # Particle layouts + layout = ba.ParticleLayout() + layout.addParticle(particle) + layout.setInterference(iff) + layout.setTotalParticleSurfaceDensity(0.01) + + # Layers + layer_1 = ba.Layer(vacuum) + layer_1.addLayout(layout) + layer_2 = ba.Layer(material_substrate) + + # Sample + sample = ba.MultiLayer() + sample.addLayer(layer_1) + sample.addLayer(layer_2) + + return sample + + +def get_simulation(sample): + nscan = 50 + ny = 50 + scan = ba.LambdaScan(1.5 * deg, nscan, 0.1*nm, 10*nm) + scan.setIntensity(1e9) + detector = ba.OffspecDetector(ny, -1*deg, +1*deg, nscan, 0.1*deg, 10*deg) + return ba.OffspecSimulation(scan, sample, detector) + + +if __name__ == '__main__': + bp.parse_args(intensity_min=1) + sample = get_sample() + simulation = get_simulation(sample) + result = simulation.simulate() + bp.plot_simulation_result(result) diff --git a/auto/MiniExamples/scatter2d/PolarizedSANS.py b/auto/MiniExamples/scatter2d/PolarizedSANS.py index d8c4fdb5c6aa933484250b7c70189bf6868573b4..ffbbec6315690b34946e2fe82510134c73588985 100755 --- a/auto/MiniExamples/scatter2d/PolarizedSANS.py +++ b/auto/MiniExamples/scatter2d/PolarizedSANS.py @@ -69,7 +69,6 @@ def get_simulation(sample): if __name__ == '__main__': - bp.parse_args(units=ba.Coords_QSPACE) sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() diff --git a/auto/MiniExamples/scatter2d/PositionVariance.py b/auto/MiniExamples/scatter2d/PositionVariance.py index a925578813800109db318bbe1a1373b35705f126..a2cb17ce023837db31e9fc06ffc454305a6770c0 100755 --- a/auto/MiniExamples/scatter2d/PositionVariance.py +++ b/auto/MiniExamples/scatter2d/PositionVariance.py @@ -60,7 +60,6 @@ def run_one(hasVariance, xi, nPlot, title): title=title, intensity_max=3e7, intensity_min=3e0, - zlabel=None, aspect='equal', with_cb=False) diff --git a/auto/MiniExamples/specular/PolarizedSpinAsymmetry.py b/auto/MiniExamples/specular/PolarizedSpinAsymmetry.py index a172b5d77ed5380ac39e5180c2fe46deff34f7ea..5f4235c6d2924485ad136ddbe1e60afc881522b6 100755 --- a/auto/MiniExamples/specular/PolarizedSpinAsymmetry.py +++ b/auto/MiniExamples/specular/PolarizedSpinAsymmetry.py @@ -101,8 +101,8 @@ def qr(result): Returns two arrays that hold the q-values as well as the reflectivity from a given simulation result """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r @@ -112,35 +112,6 @@ def qr(result): #################################################################### -def plot(qs, rs, exps, labels, filename): - """ - Plot the simulated result together with the experimental data - """ - fig = plt.figure() - ax = fig.add_subplot(111) - - for q, r, exp, l in zip(qs, rs, exps, labels): - - ax.errorbar(exp[0], - exp[1], - xerr=exp[3], - yerr=exp[2], - fmt='.', - markersize=0.75, - linewidth=0.5) - - ax.plot(q, r, label=l) - - ax.set_yscale('log') - plt.legend() - - plt.xlabel("Q [nm${}^{-1}$]") - plt.ylabel("R") - - plt.tight_layout() - plt.savefig(filename) - - def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm, filename): """ Plot the simulated spin asymmetry as well its @@ -184,13 +155,6 @@ def load_exp(fname): return numpy.transpose(dat) -def filterData(data, qmin, qmax): - minIndex = numpy.argmin(numpy.abs(data[0] - qmin)) - maxIndex = numpy.argmin(numpy.abs(data[0] - qmax)) - - return data[:, minIndex:maxIndex + 1] - - #################################################################### # Main Function # #################################################################### @@ -229,13 +193,34 @@ if __name__ == '__main__': q_pp, r_pp = qr(run_Simulation_pp(qzs, fixedP)) q_mm, r_mm = qr(run_Simulation_mm(qzs, fixedP)) - data_pp = filterData(expdata_pp, qmin, qmax) - data_mm = filterData(expdata_mm, qmin, qmax) + fig = plt.figure() + ax = fig.add_subplot(111) - plot([q_pp, q_mm], [r_pp, r_mm], [data_pp, data_mm], ["$++$", "$--$"], - "MAFO_Saturated.pdf") + def plot_data(exp): + ax.errorbar(exp[0], + exp[1], + xerr=exp[3], + yerr=exp[2], + fmt='.', + markersize=0.75, + linewidth=0.5) + + plot_data(expdata_pp) + plot_data(expdata_mm) + + ax.plot(q_pp, r_pp, label="$++$") + ax.plot(q_mm, r_mm, label="$--$") + + ax.set_yscale('log') + plt.legend() + + plt.xlabel("Q [nm${}^{-1}$]") + plt.ylabel("R") + + plt.tight_layout() + # plt.savefig("MAFO_Saturated.pdf") - plotSpinAsymmetry(data_pp, data_mm, qzs, r_pp, r_mm, + plotSpinAsymmetry(expdata_pp, expdata_mm, qzs, r_pp, r_mm, "MAFO_Saturated_spin_asymmetry.pdf") bp.show_or_export() diff --git a/auto/MiniExamples/varia/Depthprobe1.py b/auto/MiniExamples/varia/Depthprobe1.py index 116991416a6b0e286c5a9ed706aefcc9caf42655..af40d95162e62c8a76a32a081454764ace41d3be 100755 --- a/auto/MiniExamples/varia/Depthprobe1.py +++ b/auto/MiniExamples/varia/Depthprobe1.py @@ -27,7 +27,7 @@ def get_simulation(sample, flags): scan = ba.AlphaScan(n, 0*deg, 1*deg) scan.setWavelength(0.3*nm) - z_axis = ba.EquiDivision("z", n, -130*nm, 30*nm) + z_axis = ba.EquiDivision("z (nm)", n, -130*nm, 30*nm) simulation = ba.DepthprobeSimulation(scan, sample, z_axis, flags) return simulation diff --git a/auto/MiniExamples/varia/Resonator.py b/auto/MiniExamples/varia/Resonator.py index 7d2f6e18aec6fcdfca0b5d9525b825581b7bcd33..5b533c17f982bf2bffd2d22b40a71f460768e877 100755 --- a/auto/MiniExamples/varia/Resonator.py +++ b/auto/MiniExamples/varia/Resonator.py @@ -73,7 +73,7 @@ def get_simulation(sample): footprint = ba.FootprintSquare(0.01) scan.setFootprint(footprint) - z_axis = ba.EquiDivision("z", nz, z_min, z_max) + z_axis = ba.EquiDivision("z (nm)", nz, z_min, z_max) simulation = ba.DepthprobeSimulation(scan, sample, z_axis) alpha_distr = ba.DistributionGaussian(0, d_ang, 25, 3.) diff --git a/auto/Wrap/libBornAgainBase.py b/auto/Wrap/libBornAgainBase.py index 27d071da8f64052687d99a6dfe3daac16faab7f8..864aeacdf19ba49f55aad80e616dd290c1c82e71 100644 --- a/auto/Wrap/libBornAgainBase.py +++ b/auto/Wrap/libBornAgainBase.py @@ -1950,9 +1950,13 @@ class Frame(ICloneable): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr - def __init__(self, axes): - r"""__init__(Frame self, std::vector< Scale const *,std::allocator< Scale const * > > && axes) -> Frame""" - _libBornAgainBase.Frame_swiginit(self, _libBornAgainBase.new_Frame(axes)) + def __init__(self, *args): + r""" + __init__(Frame self, std::vector< Scale const *,std::allocator< Scale const * > > && axes) -> Frame + __init__(Frame self, Scale const *&& ax0) -> Frame + __init__(Frame self, Scale const *&& ax0, Scale const *&& ax1) -> Frame + """ + _libBornAgainBase.Frame_swiginit(self, _libBornAgainBase.new_Frame(*args)) __swig_destroy__ = _libBornAgainBase.delete_Frame def clone(self): diff --git a/auto/Wrap/libBornAgainBase_wrap.cpp b/auto/Wrap/libBornAgainBase_wrap.cpp index e9cdd8146ce1d480ab5865536e04b16918ee4952..f2f936bf524e549488cc799a89cfa37bcbc92605 100644 --- a/auto/Wrap/libBornAgainBase_wrap.cpp +++ b/auto/Wrap/libBornAgainBase_wrap.cpp @@ -3405,44 +3405,45 @@ namespace Swig { #define SWIGTYPE_p_long_long swig_types[16] #define SWIGTYPE_p_mapped_type swig_types[17] #define SWIGTYPE_p_p_PyObject swig_types[18] -#define SWIGTYPE_p_second_type swig_types[19] -#define SWIGTYPE_p_short swig_types[20] -#define SWIGTYPE_p_signed_char swig_types[21] -#define SWIGTYPE_p_size_type swig_types[22] -#define SWIGTYPE_p_std__allocatorT_double_t swig_types[23] -#define SWIGTYPE_p_std__allocatorT_int_t swig_types[24] -#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[25] -#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[26] -#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[27] -#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[28] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[29] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[30] -#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[31] -#define SWIGTYPE_p_std__complexT_double_t swig_types[32] -#define SWIGTYPE_p_std__invalid_argument swig_types[33] -#define SWIGTYPE_p_std__lessT_std__string_t swig_types[34] -#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[35] -#define SWIGTYPE_p_std__optionalT_Bin1D_t swig_types[36] -#define SWIGTYPE_p_std__pairT_double_double_t swig_types[37] -#define SWIGTYPE_p_std__vectorT_Bin1D_std__allocatorT_Bin1D_t_t swig_types[38] -#define SWIGTYPE_p_std__vectorT_Scale_const_p_std__allocatorT_Scale_const_p_t_t swig_types[39] -#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[40] -#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[41] -#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[42] -#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[43] -#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[44] -#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[45] -#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[46] -#define SWIGTYPE_p_std__vectorT_unsigned_int_std__allocatorT_unsigned_int_t_t swig_types[47] -#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[48] -#define SWIGTYPE_p_swig__SwigPyIterator swig_types[49] -#define SWIGTYPE_p_unsigned_char swig_types[50] -#define SWIGTYPE_p_unsigned_int swig_types[51] -#define SWIGTYPE_p_unsigned_long_long swig_types[52] -#define SWIGTYPE_p_unsigned_short swig_types[53] -#define SWIGTYPE_p_value_type swig_types[54] -static swig_type_info *swig_types[56]; -static swig_module_info swig_module = {swig_types, 55, 0, 0, 0, 0}; +#define SWIGTYPE_p_p_Scale swig_types[19] +#define SWIGTYPE_p_second_type swig_types[20] +#define SWIGTYPE_p_short swig_types[21] +#define SWIGTYPE_p_signed_char swig_types[22] +#define SWIGTYPE_p_size_type swig_types[23] +#define SWIGTYPE_p_std__allocatorT_double_t swig_types[24] +#define SWIGTYPE_p_std__allocatorT_int_t swig_types[25] +#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[26] +#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[27] +#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[28] +#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[29] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[30] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[31] +#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[32] +#define SWIGTYPE_p_std__complexT_double_t swig_types[33] +#define SWIGTYPE_p_std__invalid_argument swig_types[34] +#define SWIGTYPE_p_std__lessT_std__string_t swig_types[35] +#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[36] +#define SWIGTYPE_p_std__optionalT_Bin1D_t swig_types[37] +#define SWIGTYPE_p_std__pairT_double_double_t swig_types[38] +#define SWIGTYPE_p_std__vectorT_Bin1D_std__allocatorT_Bin1D_t_t swig_types[39] +#define SWIGTYPE_p_std__vectorT_Scale_const_p_std__allocatorT_Scale_const_p_t_t swig_types[40] +#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[41] +#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[42] +#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[43] +#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[44] +#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[45] +#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[46] +#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[47] +#define SWIGTYPE_p_std__vectorT_unsigned_int_std__allocatorT_unsigned_int_t_t swig_types[48] +#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[49] +#define SWIGTYPE_p_swig__SwigPyIterator swig_types[50] +#define SWIGTYPE_p_unsigned_char swig_types[51] +#define SWIGTYPE_p_unsigned_int swig_types[52] +#define SWIGTYPE_p_unsigned_long_long swig_types[53] +#define SWIGTYPE_p_unsigned_short swig_types[54] +#define SWIGTYPE_p_value_type swig_types[55] +static swig_type_info *swig_types[57]; +static swig_module_info swig_module = {swig_types, 56, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -26039,17 +26040,15 @@ fail: } -SWIGINTERN PyObject *_wrap_new_Frame(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_new_Frame__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; std::vector< Scale const *,std::allocator< Scale const * > > *arg1 = 0 ; void *argp1 = 0 ; int res1 = 0 ; std::unique_ptr< std::vector< Scale const *,std::allocator< Scale const * > > > rvrdeleter1 ; - PyObject *swig_obj[1] ; Frame *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_std__vectorT_Scale_const_p_std__allocatorT_Scale_const_p_t_t, SWIG_POINTER_RELEASE | 0 ); if (!SWIG_IsOK(res1)) { if (res1 == SWIG_ERROR_RELEASE_NOT_OWNED) { @@ -26071,6 +26070,134 @@ fail: } +SWIGINTERN PyObject *_wrap_new_Frame__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + Scale **arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + std::unique_ptr< Scale * > rvrdeleter1 ; + Frame *result = 0 ; + + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_p_Scale, SWIG_POINTER_RELEASE | 0 ); + if (!SWIG_IsOK(res1)) { + if (res1 == SWIG_ERROR_RELEASE_NOT_OWNED) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Frame" "', cannot release ownership as memory is not owned for argument " "1"" of type '" "Scale const *&&""'"); + } else { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Frame" "', argument " "1"" of type '" "Scale const *&&""'"); + } + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Frame" "', argument " "1"" of type '" "Scale const *&&""'"); + } + arg1 = reinterpret_cast< Scale ** >(argp1); + rvrdeleter1.reset(arg1); + result = (Frame *)new Frame((Scale const *&&)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Frame, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Frame__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + Scale **arg1 = 0 ; + Scale **arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + std::unique_ptr< Scale * > rvrdeleter1 ; + void *argp2 = 0 ; + int res2 = 0 ; + std::unique_ptr< Scale * > rvrdeleter2 ; + Frame *result = 0 ; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_p_Scale, SWIG_POINTER_RELEASE | 0 ); + if (!SWIG_IsOK(res1)) { + if (res1 == SWIG_ERROR_RELEASE_NOT_OWNED) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Frame" "', cannot release ownership as memory is not owned for argument " "1"" of type '" "Scale const *&&""'"); + } else { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Frame" "', argument " "1"" of type '" "Scale const *&&""'"); + } + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Frame" "', argument " "1"" of type '" "Scale const *&&""'"); + } + arg1 = reinterpret_cast< Scale ** >(argp1); + rvrdeleter1.reset(arg1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_p_Scale, SWIG_POINTER_RELEASE | 0 ); + if (!SWIG_IsOK(res2)) { + if (res2 == SWIG_ERROR_RELEASE_NOT_OWNED) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Frame" "', cannot release ownership as memory is not owned for argument " "2"" of type '" "Scale const *&&""'"); + } else { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Frame" "', argument " "2"" of type '" "Scale const *&&""'"); + } + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Frame" "', argument " "2"" of type '" "Scale const *&&""'"); + } + arg2 = reinterpret_cast< Scale ** >(argp2); + rvrdeleter2.reset(arg2); + result = (Frame *)new Frame((Scale const *&&)*arg1,(Scale const *&&)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Frame, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_Frame(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "new_Frame", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 1) { + int _v = 0; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_std__vectorT_Scale_const_p_std__allocatorT_Scale_const_p_t_t, SWIG_POINTER_NO_NULL); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Frame__SWIG_0(self, argc, argv); + } + } + if (argc == 1) { + int _v = 0; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_p_Scale, SWIG_POINTER_NO_NULL); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Frame__SWIG_1(self, argc, argv); + } + } + if (argc == 2) { + int _v = 0; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_p_Scale, SWIG_POINTER_NO_NULL); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_p_Scale, SWIG_POINTER_NO_NULL); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_Frame__SWIG_2(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_Frame'.\n" + " Possible C/C++ prototypes are:\n" + " Frame::Frame(std::vector< Scale const *,std::allocator< Scale const * > > &&)\n" + " Frame::Frame(Scale const *&&)\n" + " Frame::Frame(Scale const *&&,Scale const *&&)\n"); + return 0; +} + + SWIGINTERN PyObject *_wrap_delete_Frame(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Frame *arg1 = (Frame *) 0 ; @@ -28520,7 +28647,11 @@ static PyMethodDef SwigMethods[] = { { "Scale_swiginit", Scale_swiginit, METH_VARARGS, NULL}, { "ListScan", _wrap_ListScan, METH_VARARGS, "ListScan(std::string const & name, vdouble1d_t points) -> Scale"}, { "EquiDivision", _wrap_EquiDivision, METH_VARARGS, "EquiDivision(std::string const & name, size_t nbins, double start, double end) -> Scale"}, - { "new_Frame", _wrap_new_Frame, METH_O, "new_Frame(std::vector< Scale const *,std::allocator< Scale const * > > && axes) -> Frame"}, + { "new_Frame", _wrap_new_Frame, METH_VARARGS, "\n" + "Frame(std::vector< Scale const *,std::allocator< Scale const * > > && axes)\n" + "Frame(Scale const *&& ax0)\n" + "new_Frame(Scale const *&& ax0, Scale const *&& ax1) -> Frame\n" + ""}, { "delete_Frame", _wrap_delete_Frame, METH_O, "delete_Frame(Frame self)"}, { "Frame_clone", _wrap_Frame_clone, METH_O, "Frame_clone(Frame self) -> Frame"}, { "Frame_rank", _wrap_Frame_rank, METH_O, "Frame_rank(Frame self) -> size_t"}, @@ -28621,6 +28752,7 @@ static swig_type_info _swigt__p_key_type = {"_p_key_type", "key_type *", 0, 0, ( static swig_type_info _swigt__p_long_long = {"_p_long_long", "int64_t *|int_fast64_t *|int_least64_t *|intmax_t *|long long *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_mapped_type = {"_p_mapped_type", "mapped_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_p_PyObject = {"_p_p_PyObject", "PyObject **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_Scale = {"_p_p_Scale", "Scale **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_second_type = {"_p_second_type", "second_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_short = {"_p_short", "int16_t *|int_least16_t *|short *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "int8_t *|int_fast8_t *|int_least8_t *|signed char *", 0, 0, (void*)0, 0}; @@ -28678,6 +28810,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_long_long, &_swigt__p_mapped_type, &_swigt__p_p_PyObject, + &_swigt__p_p_Scale, &_swigt__p_second_type, &_swigt__p_short, &_swigt__p_signed_char, @@ -28735,6 +28868,7 @@ static swig_cast_info _swigc__p_key_type[] = { {&_swigt__p_key_type, 0, 0, 0},{ static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_mapped_type[] = { {&_swigt__p_mapped_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_p_PyObject[] = { {&_swigt__p_p_PyObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_Scale[] = { {&_swigt__p_p_Scale, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_second_type[] = { {&_swigt__p_second_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; @@ -28792,6 +28926,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_long_long, _swigc__p_mapped_type, _swigc__p_p_PyObject, + _swigc__p_p_Scale, _swigc__p_second_type, _swigc__p_short, _swigc__p_signed_char, diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index 40dec146a06150ffc4ef667240433657aff53af6..d4a72c5a3c83a2d6f38877b81e3260f5afdf10e0 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -2599,18 +2599,6 @@ class ResolutionFunction2DGaussian(IResolutionFunction2D): # Register ResolutionFunction2DGaussian in _libBornAgainDevice: _libBornAgainDevice.ResolutionFunction2DGaussian_swigregister(ResolutionFunction2DGaussian) -Coords_UNDEFINED = _libBornAgainDevice.Coords_UNDEFINED - -Coords_NBINS = _libBornAgainDevice.Coords_NBINS - -Coords_RADIANS = _libBornAgainDevice.Coords_RADIANS - -Coords_DEGREES = _libBornAgainDevice.Coords_DEGREES - -Coords_MM = _libBornAgainDevice.Coords_MM - -Coords_QSPACE = _libBornAgainDevice.Coords_QSPACE - class MaskPattern(object): r"""Proxy of C++ MaskPattern class.""" @@ -2727,9 +2715,9 @@ class IDetector(libBornAgainBase.ICloneable, libBornAgainParam.INode): r"""setRegionOfInterest(IDetector self, double xlow, double ylow, double xup, double yup)""" return _libBornAgainDevice.IDetector_setRegionOfInterest(self, xlow, ylow, xup, yup) - def scatteringCoords(self, beam): - r"""scatteringCoords(IDetector self, Beam beam) -> CoordSystem2D const *""" - return _libBornAgainDevice.IDetector_scatteringCoords(self, beam) + def scatteringCoords(self): + r"""scatteringCoords(IDetector self) -> Frame""" + return _libBornAgainDevice.IDetector_scatteringCoords(self) def active_indices(self): r"""active_indices(IDetector self) -> std::vector< size_t,std::allocator< size_t > >""" @@ -2896,9 +2884,9 @@ class RectangularDetector(IDetector): r"""regionOfInterestPixel(RectangularDetector self) -> RectangularPixel const *""" return _libBornAgainDevice.RectangularDetector_regionOfInterestPixel(self) - def scatteringCoords(self, beam): - r"""scatteringCoords(RectangularDetector self, Beam beam) -> CoordSystem2D const *""" - return _libBornAgainDevice.RectangularDetector_scatteringCoords(self, beam) + def scatteringCoords(self): + r"""scatteringCoords(RectangularDetector self) -> Frame""" + return _libBornAgainDevice.RectangularDetector_scatteringCoords(self) # Register RectangularDetector in _libBornAgainDevice: _libBornAgainDevice.RectangularDetector_swigregister(RectangularDetector) @@ -2989,9 +2977,9 @@ class SphericalDetector(IDetector): r"""defaultCoords(SphericalDetector self) -> Coords""" return _libBornAgainDevice.SphericalDetector_defaultCoords(self) - def scatteringCoords(self, beam): - r"""scatteringCoords(SphericalDetector self, Beam beam) -> CoordSystem2D const *""" - return _libBornAgainDevice.SphericalDetector_scatteringCoords(self, beam) + def scatteringCoords(self): + r"""scatteringCoords(SphericalDetector self) -> Frame""" + return _libBornAgainDevice.SphericalDetector_scatteringCoords(self) def createPixel(self, index): r"""createPixel(SphericalDetector self, size_t index) -> IPixel *""" @@ -3056,7 +3044,7 @@ class SimulationResult(Datafield): def __init__(self, *args): r""" __init__(SimulationResult self) -> SimulationResult - __init__(SimulationResult self, Datafield data, ICoordSystem const * coords) -> SimulationResult + __init__(SimulationResult self, Datafield data, Frame coords) -> SimulationResult __init__(SimulationResult self, SimulationResult other) -> SimulationResult __init__(SimulationResult self, SimulationResult other) -> SimulationResult """ @@ -3067,22 +3055,22 @@ class SimulationResult(Datafield): r"""extracted_field(SimulationResult self) -> Datafield""" return _libBornAgainDevice.SimulationResult_extracted_field(self) - def axisMinMax(self, *args): - r"""axisMinMax(SimulationResult self, size_t i, Coords units=UNDEFINED) -> pvacuum_double_t""" - return _libBornAgainDevice.SimulationResult_axisMinMax(self, *args) + def axisMinMax(self, i): + r"""axisMinMax(SimulationResult self, size_t i) -> pvacuum_double_t""" + return _libBornAgainDevice.SimulationResult_axisMinMax(self, i) - def name_of_axis(self, *args): - r"""name_of_axis(SimulationResult self, size_t i, Coords units=UNDEFINED) -> std::string""" - return _libBornAgainDevice.SimulationResult_name_of_axis(self, *args) + def name_of_axis(self, i): + r"""name_of_axis(SimulationResult self, size_t i) -> std::string""" + return _libBornAgainDevice.SimulationResult_name_of_axis(self, i) - def array(self, *args): - r"""array(SimulationResult self, Coords units=UNDEFINED) -> PyObject""" - return _libBornAgainDevice.SimulationResult_array(self, *args) + def array(self): + r"""array(SimulationResult self) -> PyObject *""" + return _libBornAgainDevice.SimulationResult_array(self) def convertedBinCenters(self, *args): r""" - convertedBinCenters(SimulationResult self, Coords units=UNDEFINED) -> vdouble1d_t - convertedBinCenters(SimulationResult self, size_t i_axis, Coords units=UNDEFINED) -> vdouble1d_t + convertedBinCenters(SimulationResult self) -> vdouble1d_t + convertedBinCenters(SimulationResult self, size_t i_axis) -> vdouble1d_t """ return _libBornAgainDevice.SimulationResult_convertedBinCenters(self, *args) diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index df19730304cd983451ea8d56e186c69e62369c64..8843dd031ffd967d1399cf36a8418fb86d8d33fe 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -3388,7 +3388,7 @@ namespace Swig { #define SWIGTYPE_p_Beam swig_types[0] #define SWIGTYPE_p_Bin1D swig_types[1] -#define SWIGTYPE_p_CoordSystem2D swig_types[2] +#define SWIGTYPE_p_Coords swig_types[2] #define SWIGTYPE_p_Datafield swig_types[3] #define SWIGTYPE_p_DetectorMask swig_types[4] #define SWIGTYPE_p_Ellipse swig_types[5] @@ -3397,88 +3397,87 @@ namespace Swig { #define SWIGTYPE_p_Frame swig_types[8] #define SWIGTYPE_p_HorizontalLine swig_types[9] #define SWIGTYPE_p_ICloneable swig_types[10] -#define SWIGTYPE_p_ICoordSystem swig_types[11] -#define SWIGTYPE_p_IDetector swig_types[12] -#define SWIGTYPE_p_IDetectorResolution swig_types[13] -#define SWIGTYPE_p_IFootprint swig_types[14] -#define SWIGTYPE_p_INode swig_types[15] -#define SWIGTYPE_p_IPixel swig_types[16] -#define SWIGTYPE_p_IResolutionFunction2D swig_types[17] -#define SWIGTYPE_p_IShape2D swig_types[18] -#define SWIGTYPE_p_ImportSettings1D swig_types[19] -#define SWIGTYPE_p_Line swig_types[20] -#define SWIGTYPE_p_MaskPattern swig_types[21] -#define SWIGTYPE_p_OffspecDetector swig_types[22] -#define SWIGTYPE_p_PolFilter swig_types[23] -#define SWIGTYPE_p_Polygon swig_types[24] -#define SWIGTYPE_p_PolygonPrivate swig_types[25] -#define SWIGTYPE_p_Rectangle swig_types[26] -#define SWIGTYPE_p_RectangularDetector swig_types[27] -#define SWIGTYPE_p_RectangularPixel swig_types[28] -#define SWIGTYPE_p_ResolutionFunction2DGaussian swig_types[29] -#define SWIGTYPE_p_Rotation3DT_double_t swig_types[30] -#define SWIGTYPE_p_Scale swig_types[31] -#define SWIGTYPE_p_SimulationResult swig_types[32] -#define SWIGTYPE_p_SphericalDetector swig_types[33] -#define SWIGTYPE_p_Vec3T_double_t swig_types[34] -#define SWIGTYPE_p_Vec3T_int_t swig_types[35] -#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[36] -#define SWIGTYPE_p_VerticalLine swig_types[37] -#define SWIGTYPE_p_allocator_type swig_types[38] -#define SWIGTYPE_p_char swig_types[39] -#define SWIGTYPE_p_const_iterator swig_types[40] -#define SWIGTYPE_p_corr_matrix_t swig_types[41] -#define SWIGTYPE_p_difference_type swig_types[42] -#define SWIGTYPE_p_first_type swig_types[43] -#define SWIGTYPE_p_int swig_types[44] -#define SWIGTYPE_p_iterator swig_types[45] -#define SWIGTYPE_p_key_type swig_types[46] -#define SWIGTYPE_p_long_long swig_types[47] -#define SWIGTYPE_p_mapped_type swig_types[48] -#define SWIGTYPE_p_p_PyObject swig_types[49] -#define SWIGTYPE_p_parameters_t swig_types[50] -#define SWIGTYPE_p_second_type swig_types[51] -#define SWIGTYPE_p_short swig_types[52] -#define SWIGTYPE_p_signed_char swig_types[53] -#define SWIGTYPE_p_size_type swig_types[54] -#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[55] -#define SWIGTYPE_p_std__allocatorT_double_t swig_types[56] -#define SWIGTYPE_p_std__allocatorT_int_t swig_types[57] -#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[58] -#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[59] -#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[60] -#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[61] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[62] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[63] -#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[64] -#define SWIGTYPE_p_std__arrayT_std__shared_ptrT_Scale_t_2_t swig_types[65] -#define SWIGTYPE_p_std__complexT_double_t swig_types[66] -#define SWIGTYPE_p_std__functionT_void_fSimulationAreaIterator_const_RF_t swig_types[67] -#define SWIGTYPE_p_std__invalid_argument swig_types[68] -#define SWIGTYPE_p_std__lessT_std__string_t swig_types[69] -#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[70] -#define SWIGTYPE_p_std__pairT_double_double_t swig_types[71] -#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[72] -#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[73] -#define SWIGTYPE_p_std__vectorT_Scale_const_p_std__allocatorT_Scale_const_p_t_t swig_types[74] -#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[75] -#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[76] -#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[77] -#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[78] -#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[79] -#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[80] -#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[81] -#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[82] -#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[83] -#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[84] -#define SWIGTYPE_p_swig__SwigPyIterator swig_types[85] -#define SWIGTYPE_p_unsigned_char swig_types[86] -#define SWIGTYPE_p_unsigned_int swig_types[87] -#define SWIGTYPE_p_unsigned_long_long swig_types[88] -#define SWIGTYPE_p_unsigned_short swig_types[89] -#define SWIGTYPE_p_value_type swig_types[90] -static swig_type_info *swig_types[92]; -static swig_module_info swig_module = {swig_types, 91, 0, 0, 0, 0}; +#define SWIGTYPE_p_IDetector swig_types[11] +#define SWIGTYPE_p_IDetectorResolution swig_types[12] +#define SWIGTYPE_p_IFootprint swig_types[13] +#define SWIGTYPE_p_INode swig_types[14] +#define SWIGTYPE_p_IPixel swig_types[15] +#define SWIGTYPE_p_IResolutionFunction2D swig_types[16] +#define SWIGTYPE_p_IShape2D swig_types[17] +#define SWIGTYPE_p_ImportSettings1D swig_types[18] +#define SWIGTYPE_p_Line swig_types[19] +#define SWIGTYPE_p_MaskPattern swig_types[20] +#define SWIGTYPE_p_OffspecDetector swig_types[21] +#define SWIGTYPE_p_PolFilter swig_types[22] +#define SWIGTYPE_p_Polygon swig_types[23] +#define SWIGTYPE_p_PolygonPrivate swig_types[24] +#define SWIGTYPE_p_Rectangle swig_types[25] +#define SWIGTYPE_p_RectangularDetector swig_types[26] +#define SWIGTYPE_p_RectangularPixel swig_types[27] +#define SWIGTYPE_p_ResolutionFunction2DGaussian swig_types[28] +#define SWIGTYPE_p_Rotation3DT_double_t swig_types[29] +#define SWIGTYPE_p_Scale swig_types[30] +#define SWIGTYPE_p_SimulationResult swig_types[31] +#define SWIGTYPE_p_SphericalDetector swig_types[32] +#define SWIGTYPE_p_Vec3T_double_t swig_types[33] +#define SWIGTYPE_p_Vec3T_int_t swig_types[34] +#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[35] +#define SWIGTYPE_p_VerticalLine swig_types[36] +#define SWIGTYPE_p_allocator_type swig_types[37] +#define SWIGTYPE_p_char swig_types[38] +#define SWIGTYPE_p_const_iterator swig_types[39] +#define SWIGTYPE_p_corr_matrix_t swig_types[40] +#define SWIGTYPE_p_difference_type swig_types[41] +#define SWIGTYPE_p_first_type swig_types[42] +#define SWIGTYPE_p_int swig_types[43] +#define SWIGTYPE_p_iterator swig_types[44] +#define SWIGTYPE_p_key_type swig_types[45] +#define SWIGTYPE_p_long_long swig_types[46] +#define SWIGTYPE_p_mapped_type swig_types[47] +#define SWIGTYPE_p_p_PyObject swig_types[48] +#define SWIGTYPE_p_parameters_t swig_types[49] +#define SWIGTYPE_p_second_type swig_types[50] +#define SWIGTYPE_p_short swig_types[51] +#define SWIGTYPE_p_signed_char swig_types[52] +#define SWIGTYPE_p_size_type swig_types[53] +#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[54] +#define SWIGTYPE_p_std__allocatorT_double_t swig_types[55] +#define SWIGTYPE_p_std__allocatorT_int_t swig_types[56] +#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[57] +#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[58] +#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[59] +#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[60] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[61] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[62] +#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[63] +#define SWIGTYPE_p_std__arrayT_std__shared_ptrT_Scale_t_2_t swig_types[64] +#define SWIGTYPE_p_std__complexT_double_t swig_types[65] +#define SWIGTYPE_p_std__functionT_void_fSimulationAreaIterator_const_RF_t swig_types[66] +#define SWIGTYPE_p_std__invalid_argument swig_types[67] +#define SWIGTYPE_p_std__lessT_std__string_t swig_types[68] +#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[69] +#define SWIGTYPE_p_std__pairT_double_double_t swig_types[70] +#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[71] +#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[72] +#define SWIGTYPE_p_std__vectorT_Scale_const_p_std__allocatorT_Scale_const_p_t_t swig_types[73] +#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[74] +#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[75] +#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[76] +#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[77] +#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[78] +#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[79] +#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[80] +#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[81] +#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[82] +#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[83] +#define SWIGTYPE_p_swig__SwigPyIterator swig_types[84] +#define SWIGTYPE_p_unsigned_char swig_types[85] +#define SWIGTYPE_p_unsigned_int swig_types[86] +#define SWIGTYPE_p_unsigned_long_long swig_types[87] +#define SWIGTYPE_p_unsigned_short swig_types[88] +#define SWIGTYPE_p_value_type swig_types[89] +static swig_type_info *swig_types[91]; +static swig_module_info swig_module = {swig_types, 90, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -33968,30 +33967,20 @@ fail: SWIGINTERN PyObject *_wrap_IDetector_scatteringCoords(PyObject *self, PyObject *args) { PyObject *resultobj = 0; IDetector *arg1 = (IDetector *) 0 ; - Beam *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - CoordSystem2D *result = 0 ; + PyObject *swig_obj[1] ; + Frame *result = 0 ; - if (!SWIG_Python_UnpackTuple(args, "IDetector_scatteringCoords", 2, 2, swig_obj)) SWIG_fail; + if (!args) SWIG_fail; + swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IDetector, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IDetector_scatteringCoords" "', argument " "1"" of type '" "IDetector const *""'"); } arg1 = reinterpret_cast< IDetector * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Beam, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IDetector_scatteringCoords" "', argument " "2"" of type '" "Beam const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IDetector_scatteringCoords" "', argument " "2"" of type '" "Beam const &""'"); - } - arg2 = reinterpret_cast< Beam * >(argp2); - result = (CoordSystem2D *)((IDetector const *)arg1)->scatteringCoords((Beam const &)*arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoordSystem2D, 0 | 0 ); + result = (Frame *)((IDetector const *)arg1)->scatteringCoords(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Frame, 0 | 0 ); return resultobj; fail: return NULL; @@ -34341,8 +34330,8 @@ SWIGINTERN PyObject *_wrap_IDetector_defaultCoords(PyObject *self, PyObject *arg SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IDetector_defaultCoords" "', argument " "1"" of type '" "IDetector const *""'"); } arg1 = reinterpret_cast< IDetector * >(argp1); - result = (Coords)((IDetector const *)arg1)->defaultCoords(); - resultobj = SWIG_From_int(static_cast< int >(result)); + result = ((IDetector const *)arg1)->defaultCoords(); + resultobj = SWIG_NewPointerObj((new Coords(result)), SWIGTYPE_p_Coords, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -35410,8 +35399,8 @@ SWIGINTERN PyObject *_wrap_RectangularDetector_defaultCoords(PyObject *self, PyO SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RectangularDetector_defaultCoords" "', argument " "1"" of type '" "RectangularDetector const *""'"); } arg1 = reinterpret_cast< RectangularDetector * >(argp1); - result = (Coords)((RectangularDetector const *)arg1)->defaultCoords(); - resultobj = SWIG_From_int(static_cast< int >(result)); + result = ((RectangularDetector const *)arg1)->defaultCoords(); + resultobj = SWIG_NewPointerObj((new Coords(result)), SWIGTYPE_p_Coords, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -35444,30 +35433,20 @@ fail: SWIGINTERN PyObject *_wrap_RectangularDetector_scatteringCoords(PyObject *self, PyObject *args) { PyObject *resultobj = 0; RectangularDetector *arg1 = (RectangularDetector *) 0 ; - Beam *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - CoordSystem2D *result = 0 ; + PyObject *swig_obj[1] ; + Frame *result = 0 ; - if (!SWIG_Python_UnpackTuple(args, "RectangularDetector_scatteringCoords", 2, 2, swig_obj)) SWIG_fail; + if (!args) SWIG_fail; + swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RectangularDetector, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "RectangularDetector_scatteringCoords" "', argument " "1"" of type '" "RectangularDetector const *""'"); } arg1 = reinterpret_cast< RectangularDetector * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Beam, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "RectangularDetector_scatteringCoords" "', argument " "2"" of type '" "Beam const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "RectangularDetector_scatteringCoords" "', argument " "2"" of type '" "Beam const &""'"); - } - arg2 = reinterpret_cast< Beam * >(argp2); - result = (CoordSystem2D *)((RectangularDetector const *)arg1)->scatteringCoords((Beam const &)*arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoordSystem2D, 0 | 0 ); + result = (Frame *)((RectangularDetector const *)arg1)->scatteringCoords(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Frame, 0 | 0 ); return resultobj; fail: return NULL; @@ -36048,8 +36027,8 @@ SWIGINTERN PyObject *_wrap_OffspecDetector_defaultCoords(PyObject *self, PyObjec SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffspecDetector_defaultCoords" "', argument " "1"" of type '" "OffspecDetector const *""'"); } arg1 = reinterpret_cast< OffspecDetector * >(argp1); - result = (Coords)((OffspecDetector const *)arg1)->defaultCoords(); - resultobj = SWIG_From_int(static_cast< int >(result)); + result = ((OffspecDetector const *)arg1)->defaultCoords(); + resultobj = SWIG_NewPointerObj((new Coords(result)), SWIGTYPE_p_Coords, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -36504,8 +36483,8 @@ SWIGINTERN PyObject *_wrap_SphericalDetector_defaultCoords(PyObject *self, PyObj SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SphericalDetector_defaultCoords" "', argument " "1"" of type '" "SphericalDetector const *""'"); } arg1 = reinterpret_cast< SphericalDetector * >(argp1); - result = (Coords)((SphericalDetector const *)arg1)->defaultCoords(); - resultobj = SWIG_From_int(static_cast< int >(result)); + result = ((SphericalDetector const *)arg1)->defaultCoords(); + resultobj = SWIG_NewPointerObj((new Coords(result)), SWIGTYPE_p_Coords, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -36515,30 +36494,20 @@ fail: SWIGINTERN PyObject *_wrap_SphericalDetector_scatteringCoords(PyObject *self, PyObject *args) { PyObject *resultobj = 0; SphericalDetector *arg1 = (SphericalDetector *) 0 ; - Beam *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - CoordSystem2D *result = 0 ; + PyObject *swig_obj[1] ; + Frame *result = 0 ; - if (!SWIG_Python_UnpackTuple(args, "SphericalDetector_scatteringCoords", 2, 2, swig_obj)) SWIG_fail; + if (!args) SWIG_fail; + swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SphericalDetector, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SphericalDetector_scatteringCoords" "', argument " "1"" of type '" "SphericalDetector const *""'"); } arg1 = reinterpret_cast< SphericalDetector * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Beam, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SphericalDetector_scatteringCoords" "', argument " "2"" of type '" "Beam const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SphericalDetector_scatteringCoords" "', argument " "2"" of type '" "Beam const &""'"); - } - arg2 = reinterpret_cast< Beam * >(argp2); - result = (CoordSystem2D *)((SphericalDetector const *)arg1)->scatteringCoords((Beam const &)*arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoordSystem2D, 0 | 0 ); + result = (Frame *)((SphericalDetector const *)arg1)->scatteringCoords(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Frame, 0 | 0 ); return resultobj; fail: return NULL; @@ -36994,7 +36963,7 @@ fail: SWIGINTERN PyObject *_wrap_new_SimulationResult__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; Datafield *arg1 = 0 ; - ICoordSystem *arg2 = (ICoordSystem *) 0 ; + Frame *arg2 = (Frame *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -37010,12 +36979,12 @@ SWIGINTERN PyObject *_wrap_new_SimulationResult__SWIG_1(PyObject *self, Py_ssize SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_SimulationResult" "', argument " "1"" of type '" "Datafield const &""'"); } arg1 = reinterpret_cast< Datafield * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ICoordSystem, 0 | 0 ); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_Frame, 0 | 0 ); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_SimulationResult" "', argument " "2"" of type '" "ICoordSystem const *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_SimulationResult" "', argument " "2"" of type '" "Frame const *""'"); } - arg2 = reinterpret_cast< ICoordSystem * >(argp2); - result = (SimulationResult *)new SimulationResult((Datafield const &)*arg1,(ICoordSystem const *)arg2); + arg2 = reinterpret_cast< Frame * >(argp2); + result = (SimulationResult *)new SimulationResult((Datafield const &)*arg1,(Frame const *)arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SimulationResult, SWIG_POINTER_NEW | 0 ); return resultobj; fail: @@ -37111,7 +37080,7 @@ SWIGINTERN PyObject *_wrap_new_SimulationResult(PyObject *self, PyObject *args) _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_ICoordSystem, 0); + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_Frame, 0); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_SimulationResult__SWIG_1(self, argc, argv); @@ -37123,7 +37092,7 @@ fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_SimulationResult'.\n" " Possible C/C++ prototypes are:\n" " SimulationResult::SimulationResult()\n" - " SimulationResult::SimulationResult(Datafield const &,ICoordSystem const *)\n" + " SimulationResult::SimulationResult(Datafield const &,Frame const *)\n" " SimulationResult::SimulationResult(SimulationResult const &)\n" " SimulationResult::SimulationResult(SimulationResult &&)\n"); return 0; @@ -37175,44 +37144,7 @@ fail: } -SWIGINTERN PyObject *_wrap_SimulationResult_axisMinMax__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - SimulationResult *arg1 = (SimulationResult *) 0 ; - size_t arg2 ; - Coords arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - std::pair< double,double > result; - - if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_axisMinMax" "', argument " "1"" of type '" "SimulationResult const *""'"); - } - arg1 = reinterpret_cast< SimulationResult * >(argp1); - ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SimulationResult_axisMinMax" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SimulationResult_axisMinMax" "', argument " "3"" of type '" "Coords""'"); - } - arg3 = static_cast< Coords >(val3); - result = ((SimulationResult const *)arg1)->axisMinMax(arg2,arg3); - resultobj = swig::from(static_cast< std::pair< double,double > >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_SimulationResult_axisMinMax__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_SimulationResult_axisMinMax(PyObject *self, PyObject *args) { PyObject *resultobj = 0; SimulationResult *arg1 = (SimulationResult *) 0 ; size_t arg2 ; @@ -37220,9 +37152,10 @@ SWIGINTERN PyObject *_wrap_SimulationResult_axisMinMax__SWIG_1(PyObject *self, P int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; + PyObject *swig_obj[2] ; std::pair< double,double > result; - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "SimulationResult_axisMinMax", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_axisMinMax" "', argument " "1"" of type '" "SimulationResult const *""'"); @@ -37241,98 +37174,7 @@ fail: } -SWIGINTERN PyObject *_wrap_SimulationResult_axisMinMax(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[4] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "SimulationResult_axisMinMax", 0, 3, argv))) SWIG_fail; - --argc; - if (argc == 2) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_size_t(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_SimulationResult_axisMinMax__SWIG_1(self, argc, argv); - } - } - } - if (argc == 3) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_size_t(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_SimulationResult_axisMinMax__SWIG_0(self, argc, argv); - } - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'SimulationResult_axisMinMax'.\n" - " Possible C/C++ prototypes are:\n" - " SimulationResult::axisMinMax(size_t,Coords) const\n" - " SimulationResult::axisMinMax(size_t) const\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_SimulationResult_name_of_axis__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - SimulationResult *arg1 = (SimulationResult *) 0 ; - size_t arg2 ; - Coords arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - std::string result; - - if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_name_of_axis" "', argument " "1"" of type '" "SimulationResult const *""'"); - } - arg1 = reinterpret_cast< SimulationResult * >(argp1); - ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SimulationResult_name_of_axis" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SimulationResult_name_of_axis" "', argument " "3"" of type '" "Coords""'"); - } - arg3 = static_cast< Coords >(val3); - result = ((SimulationResult const *)arg1)->name_of_axis(arg2,arg3); - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_SimulationResult_name_of_axis__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_SimulationResult_name_of_axis(PyObject *self, PyObject *args) { PyObject *resultobj = 0; SimulationResult *arg1 = (SimulationResult *) 0 ; size_t arg2 ; @@ -37340,9 +37182,10 @@ SWIGINTERN PyObject *_wrap_SimulationResult_name_of_axis__SWIG_1(PyObject *self, int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; + PyObject *swig_obj[2] ; std::string result; - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "SimulationResult_name_of_axis", 2, 2, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_name_of_axis" "', argument " "1"" of type '" "SimulationResult const *""'"); @@ -37361,97 +37204,16 @@ fail: } -SWIGINTERN PyObject *_wrap_SimulationResult_name_of_axis(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[4] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "SimulationResult_name_of_axis", 0, 3, argv))) SWIG_fail; - --argc; - if (argc == 2) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_size_t(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_SimulationResult_name_of_axis__SWIG_1(self, argc, argv); - } - } - } - if (argc == 3) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_size_t(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_SimulationResult_name_of_axis__SWIG_0(self, argc, argv); - } - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'SimulationResult_name_of_axis'.\n" - " Possible C/C++ prototypes are:\n" - " SimulationResult::name_of_axis(size_t,Coords) const\n" - " SimulationResult::name_of_axis(size_t) const\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_SimulationResult_array__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - SimulationResult *arg1 = (SimulationResult *) 0 ; - Coords arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *result = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_array" "', argument " "1"" of type '" "SimulationResult const *""'"); - } - arg1 = reinterpret_cast< SimulationResult * >(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SimulationResult_array" "', argument " "2"" of type '" "Coords""'"); - } - arg2 = static_cast< Coords >(val2); - result = (PyObject *)((SimulationResult const *)arg1)->array(arg2); - resultobj = result; - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_SimulationResult_array__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_SimulationResult_array(PyObject *self, PyObject *args) { PyObject *resultobj = 0; SimulationResult *arg1 = (SimulationResult *) 0 ; void *argp1 = 0 ; int res1 = 0 ; + PyObject *swig_obj[1] ; PyObject *result = 0 ; - if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + if (!args) SWIG_fail; + swig_obj[0] = args; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_array" "', argument " "1"" of type '" "SimulationResult const *""'"); @@ -37465,78 +37227,7 @@ fail: } -SWIGINTERN PyObject *_wrap_SimulationResult_array(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[3] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "SimulationResult_array", 0, 2, argv))) SWIG_fail; - --argc; - if (argc == 1) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_SimulationResult_array__SWIG_1(self, argc, argv); - } - } - if (argc == 2) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_SimulationResult_array__SWIG_0(self, argc, argv); - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'SimulationResult_array'.\n" - " Possible C/C++ prototypes are:\n" - " SimulationResult::array(Coords) const\n" - " SimulationResult::array() const\n"); - return 0; -} - - SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - SimulationResult *arg1 = (SimulationResult *) 0 ; - Coords arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - std::vector< double,std::allocator< double > > result; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_convertedBinCenters" "', argument " "1"" of type '" "SimulationResult const *""'"); - } - arg1 = reinterpret_cast< SimulationResult * >(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SimulationResult_convertedBinCenters" "', argument " "2"" of type '" "Coords""'"); - } - arg2 = static_cast< Coords >(val2); - result = ((SimulationResult const *)arg1)->convertedBinCenters(arg2); - resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; SimulationResult *arg1 = (SimulationResult *) 0 ; void *argp1 = 0 ; @@ -37557,44 +37248,7 @@ fail: } -SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - SimulationResult *arg1 = (SimulationResult *) 0 ; - size_t arg2 ; - Coords arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - std::vector< double,std::allocator< double > > result; - - if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SimulationResult, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SimulationResult_convertedBinCenters" "', argument " "1"" of type '" "SimulationResult const *""'"); - } - arg1 = reinterpret_cast< SimulationResult * >(argp1); - ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SimulationResult_convertedBinCenters" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = static_cast< size_t >(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SimulationResult_convertedBinCenters" "', argument " "3"" of type '" "Coords""'"); - } - arg3 = static_cast< Coords >(val3); - result = ((SimulationResult const *)arg1)->convertedBinCenters(arg2,arg3); - resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters__SWIG_3(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; SimulationResult *arg1 = (SimulationResult *) 0 ; size_t arg2 ; @@ -37625,11 +37279,11 @@ fail: SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters(PyObject *self, PyObject *args) { Py_ssize_t argc; - PyObject *argv[4] = { + PyObject *argv[3] = { 0 }; - if (!(argc = SWIG_Python_UnpackTuple(args, "SimulationResult_convertedBinCenters", 0, 3, argv))) SWIG_fail; + if (!(argc = SWIG_Python_UnpackTuple(args, "SimulationResult_convertedBinCenters", 0, 2, argv))) SWIG_fail; --argc; if (argc == 1) { int _v = 0; @@ -37637,22 +37291,7 @@ SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters(PyObject *self, int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_SimulationResult_convertedBinCenters__SWIG_1(self, argc, argv); - } - } - if (argc == 2) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_SimulationResult_convertedBinCenters__SWIG_0(self, argc, argv); - } + return _wrap_SimulationResult_convertedBinCenters__SWIG_0(self, argc, argv); } } if (argc == 2) { @@ -37666,28 +37305,7 @@ SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters(PyObject *self, _v = SWIG_CheckState(res); } if (_v) { - return _wrap_SimulationResult_convertedBinCenters__SWIG_3(self, argc, argv); - } - } - } - if (argc == 3) { - int _v = 0; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SimulationResult, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_size_t(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_SimulationResult_convertedBinCenters__SWIG_2(self, argc, argv); - } + return _wrap_SimulationResult_convertedBinCenters__SWIG_1(self, argc, argv); } } } @@ -37695,9 +37313,7 @@ SWIGINTERN PyObject *_wrap_SimulationResult_convertedBinCenters(PyObject *self, fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'SimulationResult_convertedBinCenters'.\n" " Possible C/C++ prototypes are:\n" - " SimulationResult::convertedBinCenters(Coords) const\n" " SimulationResult::convertedBinCenters() const\n" - " SimulationResult::convertedBinCenters(size_t,Coords) const\n" " SimulationResult::convertedBinCenters(size_t) const\n"); return 0; } @@ -38686,7 +38302,7 @@ static PyMethodDef SwigMethods[] = { { "IDetector_addMask", _wrap_IDetector_addMask, METH_VARARGS, "IDetector_addMask(IDetector self, IShape2D shape, bool mask_value=True)"}, { "IDetector_maskAll", _wrap_IDetector_maskAll, METH_O, "IDetector_maskAll(IDetector self)"}, { "IDetector_setRegionOfInterest", _wrap_IDetector_setRegionOfInterest, METH_VARARGS, "IDetector_setRegionOfInterest(IDetector self, double xlow, double ylow, double xup, double yup)"}, - { "IDetector_scatteringCoords", _wrap_IDetector_scatteringCoords, METH_VARARGS, "IDetector_scatteringCoords(IDetector self, Beam beam) -> CoordSystem2D const *"}, + { "IDetector_scatteringCoords", _wrap_IDetector_scatteringCoords, METH_O, "IDetector_scatteringCoords(IDetector self) -> Frame"}, { "IDetector_active_indices", _wrap_IDetector_active_indices, METH_O, "IDetector_active_indices(IDetector self) -> std::vector< size_t,std::allocator< size_t > >"}, { "IDetector_createPixel", _wrap_IDetector_createPixel, METH_VARARGS, "IDetector_createPixel(IDetector self, size_t i) -> IPixel const *"}, { "IDetector_indexOfSpecular", _wrap_IDetector_indexOfSpecular, METH_VARARGS, "IDetector_indexOfSpecular(IDetector self, Beam beam) -> size_t"}, @@ -38729,7 +38345,7 @@ static PyMethodDef SwigMethods[] = { { "RectangularDetector_getDetectorArrangment", _wrap_RectangularDetector_getDetectorArrangment, METH_O, "RectangularDetector_getDetectorArrangment(RectangularDetector self) -> RectangularDetector::EDetectorArrangement"}, { "RectangularDetector_defaultCoords", _wrap_RectangularDetector_defaultCoords, METH_O, "RectangularDetector_defaultCoords(RectangularDetector self) -> Coords"}, { "RectangularDetector_regionOfInterestPixel", _wrap_RectangularDetector_regionOfInterestPixel, METH_O, "RectangularDetector_regionOfInterestPixel(RectangularDetector self) -> RectangularPixel const *"}, - { "RectangularDetector_scatteringCoords", _wrap_RectangularDetector_scatteringCoords, METH_VARARGS, "RectangularDetector_scatteringCoords(RectangularDetector self, Beam beam) -> CoordSystem2D const *"}, + { "RectangularDetector_scatteringCoords", _wrap_RectangularDetector_scatteringCoords, METH_O, "RectangularDetector_scatteringCoords(RectangularDetector self) -> Frame"}, { "RectangularDetector_swigregister", RectangularDetector_swigregister, METH_O, NULL}, { "RectangularDetector_swiginit", RectangularDetector_swiginit, METH_VARARGS, NULL}, { "new_OffspecDetector", _wrap_new_OffspecDetector, METH_VARARGS, "\n" @@ -38762,7 +38378,7 @@ static PyMethodDef SwigMethods[] = { { "SphericalDetector_clone", _wrap_SphericalDetector_clone, METH_O, "SphericalDetector_clone(SphericalDetector self) -> SphericalDetector"}, { "SphericalDetector_className", _wrap_SphericalDetector_className, METH_O, "SphericalDetector_className(SphericalDetector self) -> std::string"}, { "SphericalDetector_defaultCoords", _wrap_SphericalDetector_defaultCoords, METH_O, "SphericalDetector_defaultCoords(SphericalDetector self) -> Coords"}, - { "SphericalDetector_scatteringCoords", _wrap_SphericalDetector_scatteringCoords, METH_VARARGS, "SphericalDetector_scatteringCoords(SphericalDetector self, Beam beam) -> CoordSystem2D const *"}, + { "SphericalDetector_scatteringCoords", _wrap_SphericalDetector_scatteringCoords, METH_O, "SphericalDetector_scatteringCoords(SphericalDetector self) -> Frame"}, { "SphericalDetector_createPixel", _wrap_SphericalDetector_createPixel, METH_VARARGS, "SphericalDetector_createPixel(SphericalDetector self, size_t index) -> IPixel *"}, { "SphericalDetector_indexOfSpecular", _wrap_SphericalDetector_indexOfSpecular, METH_VARARGS, "SphericalDetector_indexOfSpecular(SphericalDetector self, Beam beam) -> size_t"}, { "SphericalDetector_swigregister", SphericalDetector_swigregister, METH_O, NULL}, @@ -38773,18 +38389,18 @@ static PyMethodDef SwigMethods[] = { { "dataMatchesFile", _wrap_dataMatchesFile, METH_VARARGS, "dataMatchesFile(Datafield data, std::string const & refFileName, double tol) -> bool"}, { "new_SimulationResult", _wrap_new_SimulationResult, METH_VARARGS, "\n" "SimulationResult()\n" - "SimulationResult(Datafield data, ICoordSystem const * coords)\n" + "SimulationResult(Datafield data, Frame coords)\n" "SimulationResult(SimulationResult other)\n" "new_SimulationResult(SimulationResult other) -> SimulationResult\n" ""}, { "delete_SimulationResult", _wrap_delete_SimulationResult, METH_O, "delete_SimulationResult(SimulationResult self)"}, { "SimulationResult_extracted_field", _wrap_SimulationResult_extracted_field, METH_O, "SimulationResult_extracted_field(SimulationResult self) -> Datafield"}, - { "SimulationResult_axisMinMax", _wrap_SimulationResult_axisMinMax, METH_VARARGS, "SimulationResult_axisMinMax(SimulationResult self, size_t i, Coords units=UNDEFINED) -> pvacuum_double_t"}, - { "SimulationResult_name_of_axis", _wrap_SimulationResult_name_of_axis, METH_VARARGS, "SimulationResult_name_of_axis(SimulationResult self, size_t i, Coords units=UNDEFINED) -> std::string"}, - { "SimulationResult_array", _wrap_SimulationResult_array, METH_VARARGS, "SimulationResult_array(SimulationResult self, Coords units=UNDEFINED) -> PyObject"}, + { "SimulationResult_axisMinMax", _wrap_SimulationResult_axisMinMax, METH_VARARGS, "SimulationResult_axisMinMax(SimulationResult self, size_t i) -> pvacuum_double_t"}, + { "SimulationResult_name_of_axis", _wrap_SimulationResult_name_of_axis, METH_VARARGS, "SimulationResult_name_of_axis(SimulationResult self, size_t i) -> std::string"}, + { "SimulationResult_array", _wrap_SimulationResult_array, METH_O, "SimulationResult_array(SimulationResult self) -> PyObject *"}, { "SimulationResult_convertedBinCenters", _wrap_SimulationResult_convertedBinCenters, METH_VARARGS, "\n" - "SimulationResult_convertedBinCenters(SimulationResult self, Coords units=UNDEFINED) -> vdouble1d_t\n" - "SimulationResult_convertedBinCenters(SimulationResult self, size_t i_axis, Coords units=UNDEFINED) -> vdouble1d_t\n" + "SimulationResult_convertedBinCenters(SimulationResult self) -> vdouble1d_t\n" + "SimulationResult_convertedBinCenters(SimulationResult self, size_t i_axis) -> vdouble1d_t\n" ""}, { "SimulationResult_setTitle", _wrap_SimulationResult_setTitle, METH_VARARGS, "SimulationResult_setTitle(SimulationResult self, std::string const & title)"}, { "SimulationResult_title", _wrap_SimulationResult_title, METH_O, "SimulationResult_title(SimulationResult self) -> std::string"}, @@ -38918,7 +38534,7 @@ static void *_p_VerticalLineTo_p_IShape2D(void *x, int *SWIGUNUSEDPARM(newmemory } static swig_type_info _swigt__p_Beam = {"_p_Beam", "Beam *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Bin1D = {"_p_Bin1D", "Bin1D *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_CoordSystem2D = {"_p_CoordSystem2D", "CoordSystem2D *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_Coords = {"_p_Coords", "Coords *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Datafield = {"_p_Datafield", "Datafield *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_DetectorMask = {"_p_DetectorMask", "DetectorMask *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_Ellipse = {"_p_Ellipse", "Ellipse *", 0, 0, (void*)0, 0}; @@ -38927,7 +38543,6 @@ static swig_type_info _swigt__p_FootprintSquare = {"_p_FootprintSquare", "Footpr static swig_type_info _swigt__p_Frame = {"_p_Frame", "Frame *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_HorizontalLine = {"_p_HorizontalLine", "HorizontalLine *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ICloneable = {"_p_ICloneable", "ICloneable *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ICoordSystem = {"_p_ICoordSystem", "ICoordSystem *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_IDetector = {"_p_IDetector", "IDetector *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_IDetectorResolution = {"_p_IDetectorResolution", "IDetectorResolution *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_IFootprint = {"_p_IFootprint", "IFootprint *", 0, 0, (void*)0, 0}; @@ -39011,7 +38626,7 @@ static swig_type_info _swigt__p_value_type = {"_p_value_type", "value_type *", 0 static swig_type_info *swig_type_initial[] = { &_swigt__p_Beam, &_swigt__p_Bin1D, - &_swigt__p_CoordSystem2D, + &_swigt__p_Coords, &_swigt__p_Datafield, &_swigt__p_DetectorMask, &_swigt__p_Ellipse, @@ -39020,7 +38635,6 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_Frame, &_swigt__p_HorizontalLine, &_swigt__p_ICloneable, - &_swigt__p_ICoordSystem, &_swigt__p_IDetector, &_swigt__p_IDetectorResolution, &_swigt__p_IFootprint, @@ -39104,7 +38718,7 @@ static swig_type_info *swig_type_initial[] = { static swig_cast_info _swigc__p_Beam[] = { {&_swigt__p_Beam, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Bin1D[] = { {&_swigt__p_Bin1D, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_CoordSystem2D[] = { {&_swigt__p_CoordSystem2D, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_Coords[] = { {&_swigt__p_Coords, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Datafield[] = { {&_swigt__p_Datafield, 0, 0, 0}, {&_swigt__p_SimulationResult, _p_SimulationResultTo_p_Datafield, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_DetectorMask[] = { {&_swigt__p_DetectorMask, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Ellipse[] = { {&_swigt__p_Ellipse, 0, 0, 0},{0, 0, 0, 0}}; @@ -39113,7 +38727,6 @@ static swig_cast_info _swigc__p_FootprintSquare[] = { {&_swigt__p_FootprintSqua static swig_cast_info _swigc__p_Frame[] = { {&_swigt__p_Frame, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_HorizontalLine[] = { {&_swigt__p_HorizontalLine, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ICloneable[] = { {&_swigt__p_ICloneable, 0, 0, 0}, {&_swigt__p_Ellipse, _p_EllipseTo_p_ICloneable, 0, 0}, {&_swigt__p_FootprintGauss, _p_FootprintGaussTo_p_ICloneable, 0, 0}, {&_swigt__p_FootprintSquare, _p_FootprintSquareTo_p_ICloneable, 0, 0}, {&_swigt__p_Frame, _p_FrameTo_p_ICloneable, 0, 0}, {&_swigt__p_HorizontalLine, _p_HorizontalLineTo_p_ICloneable, 0, 0}, {&_swigt__p_IDetector, _p_IDetectorTo_p_ICloneable, 0, 0}, {&_swigt__p_IDetectorResolution, _p_IDetectorResolutionTo_p_ICloneable, 0, 0}, {&_swigt__p_IFootprint, _p_IFootprintTo_p_ICloneable, 0, 0}, {&_swigt__p_IResolutionFunction2D, _p_IResolutionFunction2DTo_p_ICloneable, 0, 0}, {&_swigt__p_IShape2D, _p_IShape2DTo_p_ICloneable, 0, 0}, {&_swigt__p_Line, _p_LineTo_p_ICloneable, 0, 0}, {&_swigt__p_Polygon, _p_PolygonTo_p_ICloneable, 0, 0}, {&_swigt__p_Rectangle, _p_RectangleTo_p_ICloneable, 0, 0}, {&_swigt__p_RectangularDetector, _p_RectangularDetectorTo_p_ICloneable, 0, 0}, {&_swigt__p_ResolutionFunction2DGaussian, _p_ResolutionFunction2DGaussianTo_p_ICloneable, 0, 0}, {&_swigt__p_SphericalDetector, _p_SphericalDetectorTo_p_ICloneable, 0, 0}, {&_swigt__p_VerticalLine, _p_VerticalLineTo_p_ICloneable, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ICoordSystem[] = { {&_swigt__p_ICoordSystem, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IDetector[] = { {&_swigt__p_IDetector, 0, 0, 0}, {&_swigt__p_RectangularDetector, _p_RectangularDetectorTo_p_IDetector, 0, 0}, {&_swigt__p_SphericalDetector, _p_SphericalDetectorTo_p_IDetector, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IDetectorResolution[] = { {&_swigt__p_IDetectorResolution, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IFootprint[] = { {&_swigt__p_IFootprint, 0, 0, 0}, {&_swigt__p_FootprintGauss, _p_FootprintGaussTo_p_IFootprint, 0, 0}, {&_swigt__p_FootprintSquare, _p_FootprintSquareTo_p_IFootprint, 0, 0},{0, 0, 0, 0}}; @@ -39197,7 +38810,7 @@ static swig_cast_info _swigc__p_value_type[] = { {&_swigt__p_value_type, 0, 0, static swig_cast_info *swig_cast_initial[] = { _swigc__p_Beam, _swigc__p_Bin1D, - _swigc__p_CoordSystem2D, + _swigc__p_Coords, _swigc__p_Datafield, _swigc__p_DetectorMask, _swigc__p_Ellipse, @@ -39206,7 +38819,6 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_Frame, _swigc__p_HorizontalLine, _swigc__p_ICloneable, - _swigc__p_ICoordSystem, _swigc__p_IDetector, _swigc__p_IDetectorResolution, _swigc__p_IFootprint, @@ -39762,12 +39374,6 @@ SWIG_init(void) { // thread safe initialization swig::container_owner_attribute(); - SWIG_Python_SetConstant(d, "Coords_UNDEFINED",SWIG_From_int(static_cast< int >(Coords::UNDEFINED))); - SWIG_Python_SetConstant(d, "Coords_NBINS",SWIG_From_int(static_cast< int >(Coords::NBINS))); - SWIG_Python_SetConstant(d, "Coords_RADIANS",SWIG_From_int(static_cast< int >(Coords::RADIANS))); - SWIG_Python_SetConstant(d, "Coords_DEGREES",SWIG_From_int(static_cast< int >(Coords::DEGREES))); - SWIG_Python_SetConstant(d, "Coords_MM",SWIG_From_int(static_cast< int >(Coords::MM))); - SWIG_Python_SetConstant(d, "Coords_QSPACE",SWIG_From_int(static_cast< int >(Coords::QSPACE))); SWIG_Python_SetConstant(d, "RectangularDetector_GENERIC",SWIG_From_int(static_cast< int >(RectangularDetector::GENERIC))); SWIG_Python_SetConstant(d, "RectangularDetector_PERPENDICULAR_TO_SAMPLE",SWIG_From_int(static_cast< int >(RectangularDetector::PERPENDICULAR_TO_SAMPLE))); SWIG_Python_SetConstant(d, "RectangularDetector_PERPENDICULAR_TO_DIRECT_BEAM",SWIG_From_int(static_cast< int >(RectangularDetector::PERPENDICULAR_TO_DIRECT_BEAM))); diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py index 0ed39a6320fb8947cc0463446fa154abdde7ec7f..0949d4e806ddc8c5c5ce498b9e32780de389c898 100644 --- a/auto/Wrap/libBornAgainSim.py +++ b/auto/Wrap/libBornAgainSim.py @@ -2364,11 +2364,11 @@ class FitObjective(object): return _libBornAgainSim.FitObjective_uncertaintyData_cpp(self, i_item) def relativeDifference(self, i_item=0): - r"""relativeDifference(FitObjective self, size_t i_item=0) -> vdouble1d_t""" + r"""relativeDifference(FitObjective self, size_t i_item=0) -> SimulationResult""" return _libBornAgainSim.FitObjective_relativeDifference(self, i_item) def absoluteDifference(self, i_item=0): - r"""absoluteDifference(FitObjective self, size_t i_item=0) -> vdouble1d_t""" + r"""absoluteDifference(FitObjective self, size_t i_item=0) -> SimulationResult""" return _libBornAgainSim.FitObjective_absoluteDifference(self, i_item) def experimental_array(self): @@ -2538,10 +2538,6 @@ class IBeamScan(libBornAgainBase.ICloneable, libBornAgainParam.INode): r"""nodeChildren(IBeamScan self) -> swig_dummy_type_const_inode_vector""" return _libBornAgainSim.IBeamScan_nodeChildren(self) - def setWavelength(self, lambda0): - r"""setWavelength(IBeamScan self, double lambda0)""" - return _libBornAgainSim.IBeamScan_setWavelength(self, lambda0) - def setIntensity(self, intensity): r"""setIntensity(IBeamScan self, double intensity)""" return _libBornAgainSim.IBeamScan_setIntensity(self, intensity) @@ -2589,14 +2585,6 @@ class AlphaScan(IBeamScan): r"""nodeChildren(AlphaScan self) -> swig_dummy_type_const_inode_vector""" return _libBornAgainSim.AlphaScan_nodeChildren(self) - def setWavelengthDistribution(self, distr): - r"""setWavelengthDistribution(AlphaScan self, IDistribution1D const & distr)""" - return _libBornAgainSim.AlphaScan_setWavelengthDistribution(self, distr) - - def setAngleDistribution(self, distr): - r"""setAngleDistribution(AlphaScan self, IDistribution1D const & distr)""" - return _libBornAgainSim.AlphaScan_setAngleDistribution(self, distr) - def setWavelength(self, _lambda): r"""setWavelength(AlphaScan self, double _lambda)""" return _libBornAgainSim.AlphaScan_setWavelength(self, _lambda) @@ -2605,8 +2593,45 @@ class AlphaScan(IBeamScan): r"""setAlphaOffset(AlphaScan self, double offset)""" return _libBornAgainSim.AlphaScan_setAlphaOffset(self, offset) + def setWavelengthDistribution(self, distr): + r"""setWavelengthDistribution(AlphaScan self, IDistribution1D const & distr)""" + return _libBornAgainSim.AlphaScan_setWavelengthDistribution(self, distr) + + def setAngleDistribution(self, distr): + r"""setAngleDistribution(AlphaScan self, IDistribution1D const & distr)""" + return _libBornAgainSim.AlphaScan_setAngleDistribution(self, distr) + # Register AlphaScan in _libBornAgainSim: _libBornAgainSim.AlphaScan_swigregister(AlphaScan) +class LambdaScan(IBeamScan): + r"""Proxy of C++ LambdaScan class.""" + + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + + def __init__(self, *args): + r""" + __init__(LambdaScan self, double alpha_i, vdouble1d_t lambdaScale) -> LambdaScan + __init__(LambdaScan self, double alpha_i, Scale lambdaScale) -> LambdaScan + __init__(LambdaScan self, double alpha_i, int nbins, double lambda_min, double lambda_max) -> LambdaScan + """ + _libBornAgainSim.LambdaScan_swiginit(self, _libBornAgainSim.new_LambdaScan(*args)) + __swig_destroy__ = _libBornAgainSim.delete_LambdaScan + + def clone(self): + r"""clone(LambdaScan self) -> LambdaScan""" + return _libBornAgainSim.LambdaScan_clone(self) + + def className(self): + r"""className(LambdaScan self) -> std::string""" + return _libBornAgainSim.LambdaScan_className(self) + + def nodeChildren(self): + r"""nodeChildren(LambdaScan self) -> swig_dummy_type_const_inode_vector""" + return _libBornAgainSim.LambdaScan_nodeChildren(self) + +# Register LambdaScan in _libBornAgainSim: +_libBornAgainSim.LambdaScan_swigregister(LambdaScan) class QzScan(IBeamScan): r"""Proxy of C++ QzScan class.""" diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp index 3bc782622b103b6733f0819bb2471920f16d233d..35781db7296f223f010cf1dfc056691742897a18 100644 --- a/auto/Wrap/libBornAgainSim_wrap.cpp +++ b/auto/Wrap/libBornAgainSim_wrap.cpp @@ -3408,74 +3408,75 @@ namespace Swig { #define SWIGTYPE_p_IntensityFunctionLog swig_types[19] #define SWIGTYPE_p_IntensityFunctionSqrt swig_types[20] #define SWIGTYPE_p_IterationInfo swig_types[21] -#define SWIGTYPE_p_MultiLayer swig_types[22] -#define SWIGTYPE_p_OffspecDetector swig_types[23] -#define SWIGTYPE_p_OffspecSimulation swig_types[24] -#define SWIGTYPE_p_PoissonBackground swig_types[25] -#define SWIGTYPE_p_PyBuilderCallback swig_types[26] -#define SWIGTYPE_p_PyObserverCallback swig_types[27] -#define SWIGTYPE_p_QzScan swig_types[28] -#define SWIGTYPE_p_Rotation3DT_double_t swig_types[29] -#define SWIGTYPE_p_Scale swig_types[30] -#define SWIGTYPE_p_ScatteringSimulation swig_types[31] -#define SWIGTYPE_p_SimulationOptions swig_types[32] -#define SWIGTYPE_p_SimulationResult swig_types[33] -#define SWIGTYPE_p_SpecularSimulation swig_types[34] -#define SWIGTYPE_p_VarianceConstantFunction swig_types[35] -#define SWIGTYPE_p_VarianceSimFunction swig_types[36] -#define SWIGTYPE_p_Vec3T_double_t swig_types[37] -#define SWIGTYPE_p_Vec3T_int_t swig_types[38] -#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[39] -#define SWIGTYPE_p_allocator_type swig_types[40] -#define SWIGTYPE_p_char swig_types[41] -#define SWIGTYPE_p_difference_type swig_types[42] -#define SWIGTYPE_p_first_type swig_types[43] -#define SWIGTYPE_p_int swig_types[44] -#define SWIGTYPE_p_key_type swig_types[45] -#define SWIGTYPE_p_long_long swig_types[46] -#define SWIGTYPE_p_mapped_type swig_types[47] -#define SWIGTYPE_p_mumufit__MinimizerResult swig_types[48] -#define SWIGTYPE_p_mumufit__Parameters swig_types[49] -#define SWIGTYPE_p_p_PyObject swig_types[50] -#define SWIGTYPE_p_second_type swig_types[51] -#define SWIGTYPE_p_short swig_types[52] -#define SWIGTYPE_p_signed_char swig_types[53] -#define SWIGTYPE_p_size_type swig_types[54] -#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[55] -#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[56] -#define SWIGTYPE_p_std__allocatorT_double_t swig_types[57] -#define SWIGTYPE_p_std__allocatorT_int_t swig_types[58] -#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[59] -#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[60] -#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[61] -#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[62] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[63] -#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[64] -#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[65] -#define SWIGTYPE_p_std__complexT_double_t swig_types[66] -#define SWIGTYPE_p_std__invalid_argument swig_types[67] -#define SWIGTYPE_p_std__lessT_std__string_t swig_types[68] -#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[69] -#define SWIGTYPE_p_std__pairT_double_double_t swig_types[70] -#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[71] -#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[72] -#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[73] -#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[74] -#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[75] -#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[76] -#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[77] -#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[78] -#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[79] -#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[80] -#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[81] -#define SWIGTYPE_p_swig__SwigPyIterator swig_types[82] -#define SWIGTYPE_p_unsigned_char swig_types[83] -#define SWIGTYPE_p_unsigned_int swig_types[84] -#define SWIGTYPE_p_unsigned_long_long swig_types[85] -#define SWIGTYPE_p_unsigned_short swig_types[86] -#define SWIGTYPE_p_value_type swig_types[87] -static swig_type_info *swig_types[89]; -static swig_module_info swig_module = {swig_types, 88, 0, 0, 0, 0}; +#define SWIGTYPE_p_LambdaScan swig_types[22] +#define SWIGTYPE_p_MultiLayer swig_types[23] +#define SWIGTYPE_p_OffspecDetector swig_types[24] +#define SWIGTYPE_p_OffspecSimulation swig_types[25] +#define SWIGTYPE_p_PoissonBackground swig_types[26] +#define SWIGTYPE_p_PyBuilderCallback swig_types[27] +#define SWIGTYPE_p_PyObserverCallback swig_types[28] +#define SWIGTYPE_p_QzScan swig_types[29] +#define SWIGTYPE_p_Rotation3DT_double_t swig_types[30] +#define SWIGTYPE_p_Scale swig_types[31] +#define SWIGTYPE_p_ScatteringSimulation swig_types[32] +#define SWIGTYPE_p_SimulationOptions swig_types[33] +#define SWIGTYPE_p_SimulationResult swig_types[34] +#define SWIGTYPE_p_SpecularSimulation swig_types[35] +#define SWIGTYPE_p_VarianceConstantFunction swig_types[36] +#define SWIGTYPE_p_VarianceSimFunction swig_types[37] +#define SWIGTYPE_p_Vec3T_double_t swig_types[38] +#define SWIGTYPE_p_Vec3T_int_t swig_types[39] +#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[40] +#define SWIGTYPE_p_allocator_type swig_types[41] +#define SWIGTYPE_p_char swig_types[42] +#define SWIGTYPE_p_difference_type swig_types[43] +#define SWIGTYPE_p_first_type swig_types[44] +#define SWIGTYPE_p_int swig_types[45] +#define SWIGTYPE_p_key_type swig_types[46] +#define SWIGTYPE_p_long_long swig_types[47] +#define SWIGTYPE_p_mapped_type swig_types[48] +#define SWIGTYPE_p_mumufit__MinimizerResult swig_types[49] +#define SWIGTYPE_p_mumufit__Parameters swig_types[50] +#define SWIGTYPE_p_p_PyObject swig_types[51] +#define SWIGTYPE_p_second_type swig_types[52] +#define SWIGTYPE_p_short swig_types[53] +#define SWIGTYPE_p_signed_char swig_types[54] +#define SWIGTYPE_p_size_type swig_types[55] +#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[56] +#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[57] +#define SWIGTYPE_p_std__allocatorT_double_t swig_types[58] +#define SWIGTYPE_p_std__allocatorT_int_t swig_types[59] +#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[60] +#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[61] +#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[62] +#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[63] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[64] +#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[65] +#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[66] +#define SWIGTYPE_p_std__complexT_double_t swig_types[67] +#define SWIGTYPE_p_std__invalid_argument swig_types[68] +#define SWIGTYPE_p_std__lessT_std__string_t swig_types[69] +#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[70] +#define SWIGTYPE_p_std__pairT_double_double_t swig_types[71] +#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[72] +#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[73] +#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[74] +#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[75] +#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[76] +#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[77] +#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[78] +#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[79] +#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[80] +#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[81] +#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[82] +#define SWIGTYPE_p_swig__SwigPyIterator swig_types[83] +#define SWIGTYPE_p_unsigned_char swig_types[84] +#define SWIGTYPE_p_unsigned_int swig_types[85] +#define SWIGTYPE_p_unsigned_long_long swig_types[86] +#define SWIGTYPE_p_unsigned_short swig_types[87] +#define SWIGTYPE_p_value_type swig_types[88] +static swig_type_info *swig_types[90]; +static swig_module_info swig_module = {swig_types, 89, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -7037,6 +7038,7 @@ SWIGINTERN void std_vector_Sl_std_pair_Sl_double_Sc_double_Sg__Sg__insert__SWIG_ #include "Sim/Residual/IIntensityFunction.h" #include "Sim/Residual/VarianceFunctions.h" #include "Sim/Scan/AlphaScan.h" +#include "Sim/Scan/LambdaScan.h" #include "Sim/Scan/QzScan.h" #include "Sim/Simulation/DepthprobeSimulation.h" #include "Sim/Simulation/ScatteringSimulation.h" @@ -31168,7 +31170,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_relativeDifference__SWIG_0(PyObject *sel int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; - std::vector< double,std::allocator< double > > result; + SimulationResult result; if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_FitObjective, 0 | 0 ); @@ -31182,7 +31184,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_relativeDifference__SWIG_0(PyObject *sel } arg2 = static_cast< size_t >(val2); result = ((FitObjective const *)arg1)->relativeDifference(arg2); - resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result)); + resultobj = SWIG_NewPointerObj((new SimulationResult(result)), SWIGTYPE_p_SimulationResult, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -31194,7 +31196,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_relativeDifference__SWIG_1(PyObject *sel FitObjective *arg1 = (FitObjective *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - std::vector< double,std::allocator< double > > result; + SimulationResult result; if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_FitObjective, 0 | 0 ); @@ -31203,7 +31205,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_relativeDifference__SWIG_1(PyObject *sel } arg1 = reinterpret_cast< FitObjective * >(argp1); result = ((FitObjective const *)arg1)->relativeDifference(); - resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result)); + resultobj = SWIG_NewPointerObj((new SimulationResult(result)), SWIGTYPE_p_SimulationResult, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -31260,7 +31262,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_absoluteDifference__SWIG_0(PyObject *sel int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; - std::vector< double,std::allocator< double > > result; + SimulationResult result; if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_FitObjective, 0 | 0 ); @@ -31274,7 +31276,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_absoluteDifference__SWIG_0(PyObject *sel } arg2 = static_cast< size_t >(val2); result = ((FitObjective const *)arg1)->absoluteDifference(arg2); - resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result)); + resultobj = SWIG_NewPointerObj((new SimulationResult(result)), SWIGTYPE_p_SimulationResult, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -31286,7 +31288,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_absoluteDifference__SWIG_1(PyObject *sel FitObjective *arg1 = (FitObjective *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - std::vector< double,std::allocator< double > > result; + SimulationResult result; if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_FitObjective, 0 | 0 ); @@ -31295,7 +31297,7 @@ SWIGINTERN PyObject *_wrap_FitObjective_absoluteDifference__SWIG_1(PyObject *sel } arg1 = reinterpret_cast< FitObjective * >(argp1); result = ((FitObjective const *)arg1)->absoluteDifference(); - resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result)); + resultobj = SWIG_NewPointerObj((new SimulationResult(result)), SWIGTYPE_p_SimulationResult, SWIG_POINTER_OWN | 0 ); return resultobj; fail: return NULL; @@ -31961,35 +31963,6 @@ fail: } -SWIGINTERN PyObject *_wrap_IBeamScan_setWavelength(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - IBeamScan *arg1 = (IBeamScan *) 0 ; - double arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "IBeamScan_setWavelength", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IBeamScan, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IBeamScan_setWavelength" "', argument " "1"" of type '" "IBeamScan *""'"); - } - arg1 = reinterpret_cast< IBeamScan * >(argp1); - ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IBeamScan_setWavelength" "', argument " "2"" of type '" "double""'"); - } - arg2 = static_cast< double >(val2); - (arg1)->setWavelength(arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_IBeamScan_setIntensity(PyObject *self, PyObject *args) { PyObject *resultobj = 0; IBeamScan *arg1 = (IBeamScan *) 0 ; @@ -32530,6 +32503,64 @@ fail: } +SWIGINTERN PyObject *_wrap_AlphaScan_setWavelength(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + AlphaScan *arg1 = (AlphaScan *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "AlphaScan_setWavelength", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AlphaScan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AlphaScan_setWavelength" "', argument " "1"" of type '" "AlphaScan *""'"); + } + arg1 = reinterpret_cast< AlphaScan * >(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AlphaScan_setWavelength" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + (arg1)->setWavelength(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AlphaScan_setAlphaOffset(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + AlphaScan *arg1 = (AlphaScan *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "AlphaScan_setAlphaOffset", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AlphaScan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AlphaScan_setAlphaOffset" "', argument " "1"" of type '" "AlphaScan *""'"); + } + arg1 = reinterpret_cast< AlphaScan * >(argp1); + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AlphaScan_setAlphaOffset" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + (arg1)->setAlphaOffset(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_AlphaScan_setWavelengthDistribution(PyObject *self, PyObject *args) { PyObject *resultobj = 0; AlphaScan *arg1 = (AlphaScan *) 0 ; @@ -32594,28 +32625,215 @@ fail: } -SWIGINTERN PyObject *_wrap_AlphaScan_setWavelength(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *AlphaScan_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_AlphaScan, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *AlphaScan_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_new_LambdaScan__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - AlphaScan *arg1 = (AlphaScan *) 0 ; - double arg2 ; + double arg1 ; + std::vector< double,std::allocator< double > > arg2 ; + double val1 ; + int ecode1 = 0 ; + LambdaScan *result = 0 ; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + ecode1 = SWIG_AsVal_double(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_LambdaScan" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + { + std::vector< double,std::allocator< double > > *ptr = (std::vector< double,std::allocator< double > > *)0; + int res = swig::asptr(swig_obj[1], &ptr); + if (!SWIG_IsOK(res) || !ptr) { + SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), "in method '" "new_LambdaScan" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > >""'"); + } + arg2 = *ptr; + if (SWIG_IsNewObj(res)) delete ptr; + } + result = (LambdaScan *)new LambdaScan(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_LambdaScan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_LambdaScan__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + double arg1 ; + Scale *arg2 = 0 ; + double val1 ; + int ecode1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + LambdaScan *result = 0 ; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + ecode1 = SWIG_AsVal_double(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_LambdaScan" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Scale, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_LambdaScan" "', argument " "2"" of type '" "Scale const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_LambdaScan" "', argument " "2"" of type '" "Scale const &""'"); + } + arg2 = reinterpret_cast< Scale * >(argp2); + result = (LambdaScan *)new LambdaScan(arg1,(Scale const &)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_LambdaScan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_LambdaScan__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + double arg1 ; + int arg2 ; + double arg3 ; + double arg4 ; + double val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + LambdaScan *result = 0 ; + + if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; + ecode1 = SWIG_AsVal_double(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_LambdaScan" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_LambdaScan" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_double(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_LambdaScan" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_LambdaScan" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + result = (LambdaScan *)new LambdaScan(arg1,arg2,arg3,arg4); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_LambdaScan, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_LambdaScan(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[5] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "new_LambdaScan", 0, 4, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v = 0; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_Scale, SWIG_POINTER_NO_NULL | 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_LambdaScan__SWIG_1(self, argc, argv); + } + } + } + if (argc == 2) { + int _v = 0; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = swig::asptr(argv[1], (std::vector< double,std::allocator< double > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_LambdaScan__SWIG_0(self, argc, argv); + } + } + } + if (argc == 4) { + int _v = 0; + { + int res = SWIG_AsVal_double(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_double(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_LambdaScan__SWIG_2(self, argc, argv); + } + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_LambdaScan'.\n" + " Possible C/C++ prototypes are:\n" + " LambdaScan::LambdaScan(double,std::vector< double,std::allocator< double > >)\n" + " LambdaScan::LambdaScan(double,Scale const &)\n" + " LambdaScan::LambdaScan(double,int,double,double)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_delete_LambdaScan(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + LambdaScan *arg1 = (LambdaScan *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; + PyObject *swig_obj[1] ; - if (!SWIG_Python_UnpackTuple(args, "AlphaScan_setWavelength", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AlphaScan, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_LambdaScan, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AlphaScan_setWavelength" "', argument " "1"" of type '" "AlphaScan *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_LambdaScan" "', argument " "1"" of type '" "LambdaScan *""'"); } - arg1 = reinterpret_cast< AlphaScan * >(argp1); - ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AlphaScan_setWavelength" "', argument " "2"" of type '" "double""'"); - } - arg2 = static_cast< double >(val2); - (arg1)->setWavelength(arg2); + arg1 = reinterpret_cast< LambdaScan * >(argp1); + delete arg1; resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -32623,43 +32841,83 @@ fail: } -SWIGINTERN PyObject *_wrap_AlphaScan_setAlphaOffset(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_LambdaScan_clone(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - AlphaScan *arg1 = (AlphaScan *) 0 ; - double arg2 ; + LambdaScan *arg1 = (LambdaScan *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; + PyObject *swig_obj[1] ; + LambdaScan *result = 0 ; - if (!SWIG_Python_UnpackTuple(args, "AlphaScan_setAlphaOffset", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AlphaScan, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_LambdaScan, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AlphaScan_setAlphaOffset" "', argument " "1"" of type '" "AlphaScan *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LambdaScan_clone" "', argument " "1"" of type '" "LambdaScan const *""'"); } - arg1 = reinterpret_cast< AlphaScan * >(argp1); - ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "AlphaScan_setAlphaOffset" "', argument " "2"" of type '" "double""'"); - } - arg2 = static_cast< double >(val2); - (arg1)->setAlphaOffset(arg2); - resultobj = SWIG_Py_Void(); + arg1 = reinterpret_cast< LambdaScan * >(argp1); + result = (LambdaScan *)((LambdaScan const *)arg1)->clone(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_LambdaScan, 0 | 0 ); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *AlphaScan_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_LambdaScan_className(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + LambdaScan *arg1 = (LambdaScan *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::string result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_LambdaScan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LambdaScan_className" "', argument " "1"" of type '" "LambdaScan const *""'"); + } + arg1 = reinterpret_cast< LambdaScan * >(argp1); + result = ((LambdaScan const *)arg1)->className(); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_LambdaScan_nodeChildren(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + LambdaScan *arg1 = (LambdaScan *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< INode const *,std::allocator< INode const * > > result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_LambdaScan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LambdaScan_nodeChildren" "', argument " "1"" of type '" "LambdaScan const *""'"); + } + arg1 = reinterpret_cast< LambdaScan * >(argp1); + result = ((LambdaScan const *)arg1)->nodeChildren(); + resultobj = swig::from(static_cast< std::vector< INode const*,std::allocator< INode const * > > >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *LambdaScan_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_AlphaScan, SWIG_NewClientData(obj)); + SWIG_TypeNewClientData(SWIGTYPE_p_LambdaScan, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } -SWIGINTERN PyObject *AlphaScan_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *LambdaScan_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { return SWIG_Python_InitShadowInstance(args); } @@ -36262,8 +36520,8 @@ static PyMethodDef SwigMethods[] = { { "FitObjective_simulationResult", _wrap_FitObjective_simulationResult, METH_VARARGS, "FitObjective_simulationResult(FitObjective self, size_t i_item=0) -> SimulationResult"}, { "FitObjective_experimentalData", _wrap_FitObjective_experimentalData, METH_VARARGS, "FitObjective_experimentalData(FitObjective self, size_t i_item=0) -> SimulationResult"}, { "FitObjective_uncertaintyData_cpp", _wrap_FitObjective_uncertaintyData_cpp, METH_VARARGS, "FitObjective_uncertaintyData_cpp(FitObjective self, size_t i_item=0) -> SimulationResult"}, - { "FitObjective_relativeDifference", _wrap_FitObjective_relativeDifference, METH_VARARGS, "FitObjective_relativeDifference(FitObjective self, size_t i_item=0) -> vdouble1d_t"}, - { "FitObjective_absoluteDifference", _wrap_FitObjective_absoluteDifference, METH_VARARGS, "FitObjective_absoluteDifference(FitObjective self, size_t i_item=0) -> vdouble1d_t"}, + { "FitObjective_relativeDifference", _wrap_FitObjective_relativeDifference, METH_VARARGS, "FitObjective_relativeDifference(FitObjective self, size_t i_item=0) -> SimulationResult"}, + { "FitObjective_absoluteDifference", _wrap_FitObjective_absoluteDifference, METH_VARARGS, "FitObjective_absoluteDifference(FitObjective self, size_t i_item=0) -> SimulationResult"}, { "FitObjective_experimental_array", _wrap_FitObjective_experimental_array, METH_O, "FitObjective_experimental_array(FitObjective self) -> vdouble1d_t"}, { "FitObjective_simulation_array", _wrap_FitObjective_simulation_array, METH_O, "FitObjective_simulation_array(FitObjective self) -> vdouble1d_t"}, { "FitObjective_uncertainties_cpp", _wrap_FitObjective_uncertainties_cpp, METH_O, "FitObjective_uncertainties_cpp(FitObjective self) -> vdouble1d_t"}, @@ -36288,7 +36546,6 @@ static PyMethodDef SwigMethods[] = { { "delete_IBeamScan", _wrap_delete_IBeamScan, METH_O, "delete_IBeamScan(IBeamScan self)"}, { "IBeamScan_clone", _wrap_IBeamScan_clone, METH_O, "IBeamScan_clone(IBeamScan self) -> IBeamScan"}, { "IBeamScan_nodeChildren", _wrap_IBeamScan_nodeChildren, METH_O, "IBeamScan_nodeChildren(IBeamScan self) -> swig_dummy_type_const_inode_vector"}, - { "IBeamScan_setWavelength", _wrap_IBeamScan_setWavelength, METH_VARARGS, "IBeamScan_setWavelength(IBeamScan self, double lambda0)"}, { "IBeamScan_setIntensity", _wrap_IBeamScan_setIntensity, METH_VARARGS, "IBeamScan_setIntensity(IBeamScan self, double intensity)"}, { "IBeamScan_setPolarization", _wrap_IBeamScan_setPolarization, METH_VARARGS, "IBeamScan_setPolarization(IBeamScan self, R3 bloch_vector)"}, { "IBeamScan_setAnalyzer", _wrap_IBeamScan_setAnalyzer, METH_VARARGS, "\n" @@ -36305,12 +36562,23 @@ static PyMethodDef SwigMethods[] = { { "AlphaScan_clone", _wrap_AlphaScan_clone, METH_O, "AlphaScan_clone(AlphaScan self) -> AlphaScan"}, { "AlphaScan_className", _wrap_AlphaScan_className, METH_O, "AlphaScan_className(AlphaScan self) -> std::string"}, { "AlphaScan_nodeChildren", _wrap_AlphaScan_nodeChildren, METH_O, "AlphaScan_nodeChildren(AlphaScan self) -> swig_dummy_type_const_inode_vector"}, - { "AlphaScan_setWavelengthDistribution", _wrap_AlphaScan_setWavelengthDistribution, METH_VARARGS, "AlphaScan_setWavelengthDistribution(AlphaScan self, IDistribution1D const & distr)"}, - { "AlphaScan_setAngleDistribution", _wrap_AlphaScan_setAngleDistribution, METH_VARARGS, "AlphaScan_setAngleDistribution(AlphaScan self, IDistribution1D const & distr)"}, { "AlphaScan_setWavelength", _wrap_AlphaScan_setWavelength, METH_VARARGS, "AlphaScan_setWavelength(AlphaScan self, double _lambda)"}, { "AlphaScan_setAlphaOffset", _wrap_AlphaScan_setAlphaOffset, METH_VARARGS, "AlphaScan_setAlphaOffset(AlphaScan self, double offset)"}, + { "AlphaScan_setWavelengthDistribution", _wrap_AlphaScan_setWavelengthDistribution, METH_VARARGS, "AlphaScan_setWavelengthDistribution(AlphaScan self, IDistribution1D const & distr)"}, + { "AlphaScan_setAngleDistribution", _wrap_AlphaScan_setAngleDistribution, METH_VARARGS, "AlphaScan_setAngleDistribution(AlphaScan self, IDistribution1D const & distr)"}, { "AlphaScan_swigregister", AlphaScan_swigregister, METH_O, NULL}, { "AlphaScan_swiginit", AlphaScan_swiginit, METH_VARARGS, NULL}, + { "new_LambdaScan", _wrap_new_LambdaScan, METH_VARARGS, "\n" + "LambdaScan(double alpha_i, vdouble1d_t lambdaScale)\n" + "LambdaScan(double alpha_i, Scale lambdaScale)\n" + "new_LambdaScan(double alpha_i, int nbins, double lambda_min, double lambda_max) -> LambdaScan\n" + ""}, + { "delete_LambdaScan", _wrap_delete_LambdaScan, METH_O, "delete_LambdaScan(LambdaScan self)"}, + { "LambdaScan_clone", _wrap_LambdaScan_clone, METH_O, "LambdaScan_clone(LambdaScan self) -> LambdaScan"}, + { "LambdaScan_className", _wrap_LambdaScan_className, METH_O, "LambdaScan_className(LambdaScan self) -> std::string"}, + { "LambdaScan_nodeChildren", _wrap_LambdaScan_nodeChildren, METH_O, "LambdaScan_nodeChildren(LambdaScan self) -> swig_dummy_type_const_inode_vector"}, + { "LambdaScan_swigregister", LambdaScan_swigregister, METH_O, NULL}, + { "LambdaScan_swiginit", LambdaScan_swiginit, METH_VARARGS, NULL}, { "new_QzScan", _wrap_new_QzScan, METH_VARARGS, "\n" "QzScan(vdouble1d_t qs_nm)\n" "QzScan(Scale qs_nm)\n" @@ -36447,6 +36715,9 @@ static void *_p_PoissonBackgroundTo_p_IBackground(void *x, int *SWIGUNUSEDPARM(n static void *_p_AlphaScanTo_p_IBeamScan(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((IBeamScan *) ((AlphaScan *) x)); } +static void *_p_LambdaScanTo_p_IBeamScan(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((IBeamScan *) ((LambdaScan *) x)); +} static void *_p_QzScanTo_p_IBeamScan(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((IBeamScan *) ((QzScan *) x)); } @@ -36477,6 +36748,9 @@ static void *_p_IChiSquaredModuleTo_p_ICloneable(void *x, int *SWIGUNUSEDPARM(ne static void *_p_ISampleNodeTo_p_ICloneable(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((ICloneable *) ((ISampleNode *) x)); } +static void *_p_LambdaScanTo_p_ICloneable(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((ICloneable *) (IBeamScan *) ((LambdaScan *) x)); +} static void *_p_PoissonBackgroundTo_p_ICloneable(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((ICloneable *) (IBackground *) ((PoissonBackground *) x)); } @@ -36510,6 +36784,9 @@ static void *_p_ISampleNodeTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) { static void *_p_ISimulationTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((INode *) ((ISimulation *) x)); } +static void *_p_LambdaScanTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) { + return (void *)((INode *) (IBeamScan *) ((LambdaScan *) x)); +} static void *_p_OffspecSimulationTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) { return (void *)((INode *) (ISimulation *) ((OffspecSimulation *) x)); } @@ -36565,6 +36842,7 @@ static swig_type_info _swigt__p_IVarianceFunction = {"_p_IVarianceFunction", "IV static swig_type_info _swigt__p_IntensityFunctionLog = {"_p_IntensityFunctionLog", "IntensityFunctionLog *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_IntensityFunctionSqrt = {"_p_IntensityFunctionSqrt", "IntensityFunctionSqrt *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_IterationInfo = {"_p_IterationInfo", "IterationInfo *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_LambdaScan = {"_p_LambdaScan", "LambdaScan *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_MultiLayer = {"_p_MultiLayer", "MultiLayer *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_OffspecDetector = {"_p_OffspecDetector", "OffspecDetector *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_OffspecSimulation = {"_p_OffspecSimulation", "OffspecSimulation *", 0, 0, (void*)0, 0}; @@ -36655,6 +36933,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_IntensityFunctionLog, &_swigt__p_IntensityFunctionSqrt, &_swigt__p_IterationInfo, + &_swigt__p_LambdaScan, &_swigt__p_MultiLayer, &_swigt__p_OffspecDetector, &_swigt__p_OffspecSimulation, @@ -36730,21 +37009,22 @@ static swig_cast_info _swigc__p_ConstantBackground[] = { {&_swigt__p_ConstantBa static swig_cast_info _swigc__p_DepthprobeSimulation[] = { {&_swigt__p_DepthprobeSimulation, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_FitObjective[] = { {&_swigt__p_FitObjective, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IBackground[] = { {&_swigt__p_IBackground, 0, 0, 0}, {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_IBackground, 0, 0}, {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_IBackground, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_IBeamScan[] = { {&_swigt__p_IBeamScan, 0, 0, 0}, {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_IBeamScan, 0, 0}, {&_swigt__p_QzScan, _p_QzScanTo_p_IBeamScan, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IBeamScan[] = { {&_swigt__p_IBeamScan, 0, 0, 0}, {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_IBeamScan, 0, 0}, {&_swigt__p_LambdaScan, _p_LambdaScanTo_p_IBeamScan, 0, 0}, {&_swigt__p_QzScan, _p_QzScanTo_p_IBeamScan, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IChiSquaredModule[] = { {&_swigt__p_IChiSquaredModule, 0, 0, 0}, {&_swigt__p_ChiSquaredModule, _p_ChiSquaredModuleTo_p_IChiSquaredModule, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Frame[] = {{&_swigt__p_Frame, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ISampleNode[] = {{&_swigt__p_ISampleNode, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ICloneable[] = { {&_swigt__p_ICloneable, 0, 0, 0}, {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_ICloneable, 0, 0}, {&_swigt__p_ChiSquaredModule, _p_ChiSquaredModuleTo_p_ICloneable, 0, 0}, {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_ICloneable, 0, 0}, {&_swigt__p_Frame, _p_FrameTo_p_ICloneable, 0, 0}, {&_swigt__p_IBackground, _p_IBackgroundTo_p_ICloneable, 0, 0}, {&_swigt__p_IBeamScan, _p_IBeamScanTo_p_ICloneable, 0, 0}, {&_swigt__p_IChiSquaredModule, _p_IChiSquaredModuleTo_p_ICloneable, 0, 0}, {&_swigt__p_ISampleNode, _p_ISampleNodeTo_p_ICloneable, 0, 0}, {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_ICloneable, 0, 0}, {&_swigt__p_QzScan, _p_QzScanTo_p_ICloneable, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ICloneable[] = { {&_swigt__p_ICloneable, 0, 0, 0}, {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_ICloneable, 0, 0}, {&_swigt__p_ChiSquaredModule, _p_ChiSquaredModuleTo_p_ICloneable, 0, 0}, {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_ICloneable, 0, 0}, {&_swigt__p_Frame, _p_FrameTo_p_ICloneable, 0, 0}, {&_swigt__p_IBackground, _p_IBackgroundTo_p_ICloneable, 0, 0}, {&_swigt__p_IBeamScan, _p_IBeamScanTo_p_ICloneable, 0, 0}, {&_swigt__p_IChiSquaredModule, _p_IChiSquaredModuleTo_p_ICloneable, 0, 0}, {&_swigt__p_ISampleNode, _p_ISampleNodeTo_p_ICloneable, 0, 0}, {&_swigt__p_LambdaScan, _p_LambdaScanTo_p_ICloneable, 0, 0}, {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_ICloneable, 0, 0}, {&_swigt__p_QzScan, _p_QzScanTo_p_ICloneable, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IDetector[] = { {&_swigt__p_IDetector, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IDistribution1D[] = { {&_swigt__p_IDistribution1D, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IFootprint[] = { {&_swigt__p_IFootprint, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IIntensityFunction[] = { {&_swigt__p_IIntensityFunction, 0, 0, 0}, {&_swigt__p_IntensityFunctionLog, _p_IntensityFunctionLogTo_p_IIntensityFunction, 0, 0}, {&_swigt__p_IntensityFunctionSqrt, _p_IntensityFunctionSqrtTo_p_IIntensityFunction, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_INode[] = { {&_swigt__p_INode, 0, 0, 0}, {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_INode, 0, 0}, {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_INode, 0, 0}, {&_swigt__p_DepthprobeSimulation, _p_DepthprobeSimulationTo_p_INode, 0, 0}, {&_swigt__p_IBackground, _p_IBackgroundTo_p_INode, 0, 0}, {&_swigt__p_IBeamScan, _p_IBeamScanTo_p_INode, 0, 0}, {&_swigt__p_ISampleNode, _p_ISampleNodeTo_p_INode, 0, 0}, {&_swigt__p_ISimulation, _p_ISimulationTo_p_INode, 0, 0}, {&_swigt__p_OffspecSimulation, _p_OffspecSimulationTo_p_INode, 0, 0}, {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_INode, 0, 0}, {&_swigt__p_QzScan, _p_QzScanTo_p_INode, 0, 0}, {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_INode, 0, 0}, {&_swigt__p_SpecularSimulation, _p_SpecularSimulationTo_p_INode, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_INode[] = { {&_swigt__p_INode, 0, 0, 0}, {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_INode, 0, 0}, {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_INode, 0, 0}, {&_swigt__p_DepthprobeSimulation, _p_DepthprobeSimulationTo_p_INode, 0, 0}, {&_swigt__p_IBackground, _p_IBackgroundTo_p_INode, 0, 0}, {&_swigt__p_IBeamScan, _p_IBeamScanTo_p_INode, 0, 0}, {&_swigt__p_ISampleNode, _p_ISampleNodeTo_p_INode, 0, 0}, {&_swigt__p_ISimulation, _p_ISimulationTo_p_INode, 0, 0}, {&_swigt__p_LambdaScan, _p_LambdaScanTo_p_INode, 0, 0}, {&_swigt__p_OffspecSimulation, _p_OffspecSimulationTo_p_INode, 0, 0}, {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_INode, 0, 0}, {&_swigt__p_QzScan, _p_QzScanTo_p_INode, 0, 0}, {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_INode, 0, 0}, {&_swigt__p_SpecularSimulation, _p_SpecularSimulationTo_p_INode, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ISimulation[] = { {&_swigt__p_ISimulation, 0, 0, 0}, {&_swigt__p_DepthprobeSimulation, _p_DepthprobeSimulationTo_p_ISimulation, 0, 0}, {&_swigt__p_OffspecSimulation, _p_OffspecSimulationTo_p_ISimulation, 0, 0}, {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_ISimulation, 0, 0}, {&_swigt__p_SpecularSimulation, _p_SpecularSimulationTo_p_ISimulation, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IVarianceFunction[] = { {&_swigt__p_IVarianceFunction, 0, 0, 0}, {&_swigt__p_VarianceConstantFunction, _p_VarianceConstantFunctionTo_p_IVarianceFunction, 0, 0}, {&_swigt__p_VarianceSimFunction, _p_VarianceSimFunctionTo_p_IVarianceFunction, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IntensityFunctionLog[] = { {&_swigt__p_IntensityFunctionLog, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IntensityFunctionSqrt[] = { {&_swigt__p_IntensityFunctionSqrt, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_IterationInfo[] = { {&_swigt__p_IterationInfo, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_LambdaScan[] = { {&_swigt__p_LambdaScan, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_MultiLayer[] = { {&_swigt__p_MultiLayer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_OffspecDetector[] = { {&_swigt__p_OffspecDetector, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_OffspecSimulation[] = { {&_swigt__p_OffspecSimulation, 0, 0, 0},{0, 0, 0, 0}}; @@ -36835,6 +37115,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_IntensityFunctionLog, _swigc__p_IntensityFunctionSqrt, _swigc__p_IterationInfo, + _swigc__p_LambdaScan, _swigc__p_MultiLayer, _swigc__p_OffspecDetector, _swigc__p_OffspecSimulation, diff --git a/rawEx/fit/specular/Honeycomb_fit.py b/rawEx/fit/specular/Honeycomb_fit.py index 78bcbd7751d45195444db4e106d5efffeb826ce6..e9dc5fa803305e2f3892401c3e4d4c717664c62a 100755 --- a/rawEx/fit/specular/Honeycomb_fit.py +++ b/rawEx/fit/specular/Honeycomb_fit.py @@ -109,8 +109,8 @@ def qr(result): """ Return q and reflectivity arrays from simulation result. """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r diff --git a/rawEx/fit/specular/Pt_layer_fit.py b/rawEx/fit/specular/Pt_layer_fit.py index 0c68580818fb2b7de36e63f890a777837fb9498f..de39eb13832791629717cc2040e15e6a41b1357b 100755 --- a/rawEx/fit/specular/Pt_layer_fit.py +++ b/rawEx/fit/specular/Pt_layer_fit.py @@ -88,8 +88,8 @@ def qr(result): """ Return q and reflectivity arrays from simulation result. """ - q = np.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = np.array(result.array(ba.Coords_QSPACE)) + q = np.array(result.convertedBinCenters()) + r = np.array(result.array()) return q, r diff --git a/rawEx/offspec/OffspecLambda.py b/rawEx/offspec/OffspecLambda.py new file mode 100755 index 0000000000000000000000000000000000000000..6a780dc6fe39fb5aa87ec50160b5201143cc81d6 --- /dev/null +++ b/rawEx/offspec/OffspecLambda.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +""" +Basic offspec example. +Sample is a grating on a substrate, modelled by a 1d lattice of long boxes +""" +import bornagain as ba +from bornagain import ba_plot as bp, deg, nm + + +def get_sample(): + # Materials + material_particle = ba.RefractiveMaterial("Particle", 0.0006, 2e-08) + material_substrate = ba.RefractiveMaterial("Substrate", 6e-06, 2e-08) + vacuum = ba.RefractiveMaterial("Vacuum", 0, 0) + + # Particles + ff = ba.Box(1000*nm, 20*nm, 10*nm) + particle = ba.Particle(material_particle, ff) + particle_rotation = ba.RotationZ(90*deg) + particle.rotate(particle_rotation) + + # Interference functions + iff = ba.Interference1DLattice(100*nm, 0) + iff_pdf = ba.Profile1DCauchy(1e6*nm) + iff.setDecayFunction(iff_pdf) + + # Particle layouts + layout = ba.ParticleLayout() + layout.addParticle(particle) + layout.setInterference(iff) + layout.setTotalParticleSurfaceDensity(0.01) + + # Layers + layer_1 = ba.Layer(vacuum) + layer_1.addLayout(layout) + layer_2 = ba.Layer(material_substrate) + + # Sample + sample = ba.MultiLayer() + sample.addLayer(layer_1) + sample.addLayer(layer_2) + + return sample + + +def get_simulation(sample): + nscan = <%= sm ? 50 : 200 %> + ny = 50 + scan = ba.LambdaScan(1.5 * deg, nscan, 0.1*nm, 10*nm) + scan.setIntensity(1e9) + detector = ba.OffspecDetector(ny, -1*deg, +1*deg, nscan, 0.1*deg, 10*deg) + return ba.OffspecSimulation(scan, sample, detector) + + +if __name__ == '__main__': + bp.parse_args(intensity_min=1) + sample = get_sample() + simulation = get_simulation(sample) + result = simulation.simulate() + bp.plot_simulation_result(result) diff --git a/rawEx/scatter2d/PolarizedSANS.py b/rawEx/scatter2d/PolarizedSANS.py index ab7fb7fb3263e5d4b0b093698b7ae41b0775cd29..57c1888077b9a3d56f1076c81471a869a4cfd152 100755 --- a/rawEx/scatter2d/PolarizedSANS.py +++ b/rawEx/scatter2d/PolarizedSANS.py @@ -69,7 +69,6 @@ def get_simulation(sample): if __name__ == '__main__': - bp.parse_args(units=ba.Coords_QSPACE) sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() diff --git a/rawEx/scatter2d/PositionVariance.py b/rawEx/scatter2d/PositionVariance.py index 955f542541922ac4bea528e4569c5feb1c8c4e50..ec884d7fae922ab4637ad856a23adc2915167772 100755 --- a/rawEx/scatter2d/PositionVariance.py +++ b/rawEx/scatter2d/PositionVariance.py @@ -60,7 +60,6 @@ def run_one(hasVariance, xi, nPlot, title): title=title, intensity_max=3e7, intensity_min=3e0, - zlabel=None, aspect='equal', with_cb=False) diff --git a/rawEx/specular/PolarizedSpinAsymmetry.py b/rawEx/specular/PolarizedSpinAsymmetry.py index a172b5d77ed5380ac39e5180c2fe46deff34f7ea..5f4235c6d2924485ad136ddbe1e60afc881522b6 100755 --- a/rawEx/specular/PolarizedSpinAsymmetry.py +++ b/rawEx/specular/PolarizedSpinAsymmetry.py @@ -101,8 +101,8 @@ def qr(result): Returns two arrays that hold the q-values as well as the reflectivity from a given simulation result """ - q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE)) - r = numpy.array(result.array(ba.Coords_QSPACE)) + q = numpy.array(result.convertedBinCenters()) + r = numpy.array(result.array()) return q, r @@ -112,35 +112,6 @@ def qr(result): #################################################################### -def plot(qs, rs, exps, labels, filename): - """ - Plot the simulated result together with the experimental data - """ - fig = plt.figure() - ax = fig.add_subplot(111) - - for q, r, exp, l in zip(qs, rs, exps, labels): - - ax.errorbar(exp[0], - exp[1], - xerr=exp[3], - yerr=exp[2], - fmt='.', - markersize=0.75, - linewidth=0.5) - - ax.plot(q, r, label=l) - - ax.set_yscale('log') - plt.legend() - - plt.xlabel("Q [nm${}^{-1}$]") - plt.ylabel("R") - - plt.tight_layout() - plt.savefig(filename) - - def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm, filename): """ Plot the simulated spin asymmetry as well its @@ -184,13 +155,6 @@ def load_exp(fname): return numpy.transpose(dat) -def filterData(data, qmin, qmax): - minIndex = numpy.argmin(numpy.abs(data[0] - qmin)) - maxIndex = numpy.argmin(numpy.abs(data[0] - qmax)) - - return data[:, minIndex:maxIndex + 1] - - #################################################################### # Main Function # #################################################################### @@ -229,13 +193,34 @@ if __name__ == '__main__': q_pp, r_pp = qr(run_Simulation_pp(qzs, fixedP)) q_mm, r_mm = qr(run_Simulation_mm(qzs, fixedP)) - data_pp = filterData(expdata_pp, qmin, qmax) - data_mm = filterData(expdata_mm, qmin, qmax) + fig = plt.figure() + ax = fig.add_subplot(111) - plot([q_pp, q_mm], [r_pp, r_mm], [data_pp, data_mm], ["$++$", "$--$"], - "MAFO_Saturated.pdf") + def plot_data(exp): + ax.errorbar(exp[0], + exp[1], + xerr=exp[3], + yerr=exp[2], + fmt='.', + markersize=0.75, + linewidth=0.5) + + plot_data(expdata_pp) + plot_data(expdata_mm) + + ax.plot(q_pp, r_pp, label="$++$") + ax.plot(q_mm, r_mm, label="$--$") + + ax.set_yscale('log') + plt.legend() + + plt.xlabel("Q [nm${}^{-1}$]") + plt.ylabel("R") + + plt.tight_layout() + # plt.savefig("MAFO_Saturated.pdf") - plotSpinAsymmetry(data_pp, data_mm, qzs, r_pp, r_mm, + plotSpinAsymmetry(expdata_pp, expdata_mm, qzs, r_pp, r_mm, "MAFO_Saturated_spin_asymmetry.pdf") bp.show_or_export() diff --git a/rawEx/varia/Depthprobe1.py b/rawEx/varia/Depthprobe1.py index 38cd0a6242a2758e3fc9bff1902fbf27cc6146bc..a372812fd9f69594a01ba921cf956652b57a96eb 100755 --- a/rawEx/varia/Depthprobe1.py +++ b/rawEx/varia/Depthprobe1.py @@ -27,7 +27,7 @@ def get_simulation(sample, flags): scan = ba.AlphaScan(n, 0*deg, 1*deg) scan.setWavelength(0.3*nm) - z_axis = ba.EquiDivision("z", n, -130*nm, 30*nm) + z_axis = ba.EquiDivision("z (nm)", n, -130*nm, 30*nm) simulation = ba.DepthprobeSimulation(scan, sample, z_axis, flags) return simulation diff --git a/rawEx/varia/Resonator.py b/rawEx/varia/Resonator.py index a2d9b03ee30a76347a71dccdeab7fca93d4b336d..9856b4b4191094d5084d70a36ebdd74405055115 100755 --- a/rawEx/varia/Resonator.py +++ b/rawEx/varia/Resonator.py @@ -73,7 +73,7 @@ def get_simulation(sample): footprint = ba.FootprintSquare(0.01) scan.setFootprint(footprint) - z_axis = ba.EquiDivision("z", nz, z_min, z_max) + z_axis = ba.EquiDivision("z (nm)", nz, z_min, z_max) simulation = ba.DepthprobeSimulation(scan, sample, z_axis) alpha_distr = ba.DistributionGaussian(0, d_ang, 25, 3.)