diff --git a/Core/Fitting/SimDataPair.cpp b/Core/Fitting/SimDataPair.cpp index 03db8dc1c8e676016a01d00ef654be75f064b944..d4f11ea909d71325423d35d60af995a9d15e9eb5 100644 --- a/Core/Fitting/SimDataPair.cpp +++ b/Core/Fitting/SimDataPair.cpp @@ -15,9 +15,9 @@ #include "Core/Fitting/SimDataPair.h" #include "Base/Math/Numeric.h" #include "Core/Scan/UnitConverter1D.h" -#include "Core/Simulation/UnitConverterUtils.h" #include "Core/Simulation/includeSimulations.h" #include "Device/Data/DataUtils.h" +#include "Device/Detector/UnitConverter2D.h" namespace { @@ -51,7 +51,7 @@ bool detHasSameDimensions(const IDetector& detector, const OutputData<double>& d std::unique_ptr<IUnitConverter> createConverter(const ISimulation& simulation) { if (auto gisas = dynamic_cast<const GISASSimulation*>(&simulation)) - return UnitConverterUtils::createConverterForGISAS(gisas->instrument()); + return UnitConverter2D::createConverterForGISAS(gisas->instrument()); if (auto spec = dynamic_cast<const SpecularSimulation*>(&simulation)) return UnitConverter1D::createUnitConverter(*spec->dataHandler()); @@ -62,8 +62,7 @@ std::unique_ptr<IUnitConverter> createConverter(const ISimulation& simulation) if (auto off_spec = dynamic_cast<const OffSpecularSimulation*>(&simulation)) return off_spec->createUnitConverter(); - throw std::runtime_error("UnitConverterUtils::createConverter -> " - "Not implemented simulation."); + ASSERT(0); } //! Convert user data to SimulationResult object for later drawing in various axes units. @@ -74,7 +73,7 @@ SimulationResult convertData(const ISimulation& simulation, const OutputData<dou bool put_masked_areas_to_zero) { auto converter = createConverter(simulation); - auto roi_data = UnitConverterUtils::createOutputData(*converter, converter->defaultUnits()); + auto roi_data = converter->createOutputData(converter->defaultUnits()); if (roi_data->hasSameDimensions(data)) { // data is already cropped to ROI @@ -165,7 +164,7 @@ void SimDataPair::execSimulation(const mumufit::Parameters& params) } else { const IUnitConverter& converter = m_sim_data.converter(); std::unique_ptr<OutputData<double>> dummy_array = - UnitConverterUtils::createOutputData(converter, converter.defaultUnits()); + converter.createOutputData(converter.defaultUnits()); m_uncertainties = SimulationResult(*dummy_array, converter); } diff --git a/Core/Scan/UnitConverter1D.cpp b/Core/Scan/UnitConverter1D.cpp index b214b42d4f1b580c80a1f4fe90d5dab65454ffad..530f9143d75debc960fdd49b0011f8329ed4ab96 100644 --- a/Core/Scan/UnitConverter1D.cpp +++ b/Core/Scan/UnitConverter1D.cpp @@ -54,10 +54,10 @@ createTranslatedAxis(const IAxis& axis, std::function<double(double)> translator std::unique_ptr<UnitConverter1D> UnitConverter1D::createUnitConverter(const ISpecularScan& scan) { if (const auto* aScan = dynamic_cast<const AngularSpecScan*>(&scan)) - return std::make_unique<UnitConverterConvSpec>(*aScan); + return std::make_unique<AngularReflectometryConverter>(*aScan); if (const auto* qScan = dynamic_cast<const QSpecScan*>(&scan)) - return std::make_unique<UnitConverterQSpec>(*qScan); + return std::make_unique<WavenumberReflectometryConverter>(*qScan); throw std::runtime_error("Bug in UnitConverter1D::createUnitConverter: invalid case"); } @@ -67,24 +67,24 @@ size_t UnitConverter1D::dimension() const return 1u; } -double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) const +double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units) const { ASSERT(i_axis == 0); - units_type = substituteDefaultUnits(units_type); - if (units_type == Axes::Units::NBINS) + units = substituteDefaultUnits(units); + if (units == Axes::Units::NBINS) return 0.0; - auto translator = getTraslatorTo(units_type); + auto translator = getTraslatorTo(units); return translator(coordinateAxis()->binCenter(0)); } -double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) const +double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units) const { ASSERT(i_axis == 0); - units_type = substituteDefaultUnits(units_type); + units = substituteDefaultUnits(units); auto coordinate_axis = coordinateAxis(); - if (units_type == Axes::Units::NBINS) + if (units == Axes::Units::NBINS) return static_cast<double>(coordinate_axis->size()); - auto translator = getTraslatorTo(units_type); + auto translator = getTraslatorTo(units); return translator(coordinate_axis->binCenter(coordinate_axis->size() - 1)); } @@ -119,11 +119,11 @@ UnitConverter1D::createConvertedData(const OutputData<double>& data, Axes::Units // ************************************************************************************************ -// class UnitConverterConvSpec +// class AngularReflectometryConverter // ************************************************************************************************ -UnitConverterConvSpec::UnitConverterConvSpec(const Beam& beam, const IAxis& axis, - Axes::Units axis_units) +AngularReflectometryConverter::AngularReflectometryConverter(const Beam& beam, const IAxis& axis, + Axes::Units axis_units) : m_wavelength(beam.wavelength()) { m_axis = createTranslatedAxis(axis, getTraslatorFrom(axis_units), axisName(0, axis_units)); @@ -131,48 +131,51 @@ UnitConverterConvSpec::UnitConverterConvSpec(const Beam& beam, const IAxis& axis throw std::runtime_error("Error in UnitConverter1D: input axis range is out of bounds"); } -UnitConverterConvSpec::UnitConverterConvSpec(const AngularSpecScan& handler) +AngularReflectometryConverter::AngularReflectometryConverter(const AngularSpecScan& handler) : m_wavelength(handler.wavelength()), m_axis(handler.coordinateAxis()->clone()) { } -UnitConverterConvSpec::~UnitConverterConvSpec() = default; +AngularReflectometryConverter::~AngularReflectometryConverter() = default; -UnitConverterConvSpec* UnitConverterConvSpec::clone() const +AngularReflectometryConverter* AngularReflectometryConverter::clone() const { - return new UnitConverterConvSpec(*this); + return new AngularReflectometryConverter(*this); } -size_t UnitConverterConvSpec::axisSize(size_t i_axis) const +size_t AngularReflectometryConverter::axisSize(size_t i_axis) const { ASSERT(i_axis == 0); return m_axis->size(); } -std::vector<Axes::Units> UnitConverterConvSpec::availableUnits() const +std::vector<Axes::Units> AngularReflectometryConverter::availableUnits() const { return {Axes::Units::NBINS, Axes::Units::RADIANS, Axes::Units::DEGREES, Axes::Units::QSPACE, Axes::Units::RQ4}; } -Axes::Units UnitConverterConvSpec::defaultUnits() const +Axes::Units AngularReflectometryConverter::defaultUnits() const { return Axes::Units::DEGREES; } -UnitConverterConvSpec::UnitConverterConvSpec(const UnitConverterConvSpec& other) +AngularReflectometryConverter::AngularReflectometryConverter( + const AngularReflectometryConverter& other) : m_wavelength(other.m_wavelength), m_axis(other.m_axis->clone()) { } -std::vector<std::map<Axes::Units, std::string>> UnitConverterConvSpec::createNameMaps() const +std::vector<std::map<Axes::Units, std::string>> +AngularReflectometryConverter::createNameMaps() const { return {AxisNames::specAxis}; } -std::function<double(double)> UnitConverterConvSpec::getTraslatorFrom(Axes::Units units_type) const +std::function<double(double)> +AngularReflectometryConverter::getTraslatorFrom(Axes::Units units) const { - switch (units_type) { + switch (units) { case Axes::Units::RADIANS: return [](double value) { return value; }; case Axes::Units::DEGREES: @@ -180,14 +183,14 @@ std::function<double(double)> UnitConverterConvSpec::getTraslatorFrom(Axes::Unit case Axes::Units::QSPACE: return [this](double value) { return getInvQ(m_wavelength, value); }; default: - throwUnitsError("UnitConverterConvSpec::getTraslatorFrom", + throwUnitsError("AngularReflectometryConverter::getTraslatorFrom", {Axes::Units::RADIANS, Axes::Units::DEGREES, Axes::Units::QSPACE}); } } -std::function<double(double)> UnitConverterConvSpec::getTraslatorTo(Axes::Units units_type) const +std::function<double(double)> AngularReflectometryConverter::getTraslatorTo(Axes::Units units) const { - switch (units_type) { + switch (units) { case Axes::Units::RADIANS: return [](double value) { return value; }; case Axes::Units::DEGREES: @@ -197,66 +200,69 @@ std::function<double(double)> UnitConverterConvSpec::getTraslatorTo(Axes::Units case Axes::Units::RQ4: return [wl = m_wavelength](double value) { return getQ(wl, value); }; default: - throwUnitsError("UnitConverterConvSpec::getTraslatorTo", availableUnits()); + throwUnitsError("AngularReflectometryConverter::getTraslatorTo", availableUnits()); } } // ************************************************************************************************ -// class UnitConverterQSpec +// class WavenumberReflectometryConverter // ************************************************************************************************ -UnitConverterQSpec::UnitConverterQSpec(const QSpecScan& handler) +WavenumberReflectometryConverter::WavenumberReflectometryConverter(const QSpecScan& handler) : m_axis(handler.coordinateAxis()->clone()) { } -UnitConverterQSpec::~UnitConverterQSpec() = default; +WavenumberReflectometryConverter::~WavenumberReflectometryConverter() = default; -UnitConverterQSpec* UnitConverterQSpec::clone() const +WavenumberReflectometryConverter* WavenumberReflectometryConverter::clone() const { - return new UnitConverterQSpec(*this); + return new WavenumberReflectometryConverter(*this); } //! Returns the size of underlying axis. -size_t UnitConverterQSpec::axisSize(size_t i_axis) const +size_t WavenumberReflectometryConverter::axisSize(size_t i_axis) const { ASSERT(i_axis == 0); return m_axis->size(); } //! Returns the list of all available units -std::vector<Axes::Units> UnitConverterQSpec::availableUnits() const +std::vector<Axes::Units> WavenumberReflectometryConverter::availableUnits() const { return {Axes::Units::NBINS, Axes::Units::QSPACE, Axes::Units::RQ4}; } //! Returns default units to convert to. -Axes::Units UnitConverterQSpec::defaultUnits() const +Axes::Units WavenumberReflectometryConverter::defaultUnits() const { return Axes::Units::QSPACE; } -UnitConverterQSpec::UnitConverterQSpec(const UnitConverterQSpec& other) +WavenumberReflectometryConverter::WavenumberReflectometryConverter( + const WavenumberReflectometryConverter& other) : m_axis(std::unique_ptr<IAxis>(other.coordinateAxis()->clone())) { } //! Creates name map for axis in various units -std::vector<std::map<Axes::Units, std::string>> UnitConverterQSpec::createNameMaps() const +std::vector<std::map<Axes::Units, std::string>> +WavenumberReflectometryConverter::createNameMaps() const { return {AxisNames::specAxisQ}; } //! Returns translating functional (inv. nm --> desired units) -std::function<double(double)> UnitConverterQSpec::getTraslatorTo(Axes::Units units_type) const +std::function<double(double)> +WavenumberReflectometryConverter::getTraslatorTo(Axes::Units units) const { - switch (units_type) { + switch (units) { case Axes::Units::QSPACE: return [](double value) { return value; }; case Axes::Units::RQ4: return [](double value) { return value; }; default: - throwUnitsError("UnitConverterQSpec::getTraslatorTo", availableUnits()); + throwUnitsError("WavenumberReflectometryConverter::getTraslatorTo", availableUnits()); } } diff --git a/Core/Scan/UnitConverter1D.h b/Core/Scan/UnitConverter1D.h index 1c86f80cc6d0671ff2653a1218249af57973a0be..a17f58382560765bc7fba318a4a607c27f3620cd 100644 --- a/Core/Scan/UnitConverter1D.h +++ b/Core/Scan/UnitConverter1D.h @@ -29,7 +29,9 @@ class ISpecularScan; class AngularSpecScan; class QSpecScan; -//! Conversion of axis units for the case of 1D simulation result. + +//! Abstract base class to support coordinate transforms and axis labels for 1D scans. +//! Inherited by AngularReflectometryConverter and WavenumberReflectometryConverter. class UnitConverter1D : public IUnitConverter { public: @@ -44,10 +46,10 @@ public: size_t dimension() const override; //! Calculates minimum on-axis value in given units. - double calculateMin(size_t i_axis, Axes::Units units_type) const override; + double calculateMin(size_t i_axis, Axes::Units units) const override; //! Calculates maximum on-axis value in given units. - double calculateMax(size_t i_axis, Axes::Units units_type) const override; + double calculateMax(size_t i_axis, Axes::Units units) const override; //! Creates axis in converted units. std::unique_ptr<IAxis> createConvertedAxis(size_t i_axis, Axes::Units units) const override; @@ -58,21 +60,22 @@ public: protected: //! Returns translating functional (rads --> output units) - virtual std::function<double(double)> getTraslatorTo(Axes::Units units_type) const = 0; + virtual std::function<double(double)> getTraslatorTo(Axes::Units units) const = 0; virtual const IAxis* coordinateAxis() const = 0; }; + //! Conversion of axis units for the case of conventional (angle-based) reflectometry. -class UnitConverterConvSpec : public UnitConverter1D { +class AngularReflectometryConverter : public UnitConverter1D { public: //! Constructs the object for unit conversion. - UnitConverterConvSpec(const Beam& beam, const IAxis& axis, - Axes::Units axis_units = Axes::Units::RADIANS); - UnitConverterConvSpec(const AngularSpecScan& handler); - ~UnitConverterConvSpec() override; + AngularReflectometryConverter(const Beam& beam, const IAxis& axis, + Axes::Units axis_units = Axes::Units::RADIANS); + AngularReflectometryConverter(const AngularSpecScan& handler); + ~AngularReflectometryConverter() override; - UnitConverterConvSpec* clone() const override; + AngularReflectometryConverter* clone() const override; //! Returns the size of underlying axis. size_t axisSize(size_t i_axis) const override; @@ -84,16 +87,16 @@ public: Axes::Units defaultUnits() const override; protected: - UnitConverterConvSpec(const UnitConverterConvSpec& other); + AngularReflectometryConverter(const AngularReflectometryConverter& other); //! Creates name map for axis in various units std::vector<std::map<Axes::Units, std::string>> createNameMaps() const override; //! Returns translating functional (input units --> rads) - std::function<double(double)> getTraslatorFrom(Axes::Units units_type) const; + std::function<double(double)> getTraslatorFrom(Axes::Units units) const; //! Returns translating functional (rads --> desired units) - std::function<double(double)> getTraslatorTo(Axes::Units units_type) const override; + std::function<double(double)> getTraslatorTo(Axes::Units units) const override; const IAxis* coordinateAxis() const override { return m_axis.get(); } @@ -101,13 +104,14 @@ protected: std::unique_ptr<IAxis> m_axis; //!< basic inclination angles (in rads). }; + //! Conversion of axis units for the case of q-defined reflectometry. -class UnitConverterQSpec : public UnitConverter1D { +class WavenumberReflectometryConverter : public UnitConverter1D { public: - UnitConverterQSpec(const QSpecScan& handler); - ~UnitConverterQSpec() override; + WavenumberReflectometryConverter(const QSpecScan& handler); + ~WavenumberReflectometryConverter() override; - UnitConverterQSpec* clone() const override; + WavenumberReflectometryConverter* clone() const override; //! Returns the size of underlying axis. size_t axisSize(size_t i_axis) const override; @@ -119,13 +123,13 @@ public: Axes::Units defaultUnits() const override; protected: - UnitConverterQSpec(const UnitConverterQSpec& other); + WavenumberReflectometryConverter(const WavenumberReflectometryConverter& other); //! Creates name map for axis in various units std::vector<std::map<Axes::Units, std::string>> createNameMaps() const override; //! Returns translating functional (inv. nm --> desired units) - std::function<double(double)> getTraslatorTo(Axes::Units units_type) const override; + std::function<double(double)> getTraslatorTo(Axes::Units units) const override; const IAxis* coordinateAxis() const override { return m_axis.get(); } diff --git a/Core/Simulation/DepthProbeSimulation.cpp b/Core/Simulation/DepthProbeSimulation.cpp index b23198d758802a0a58d79c9493d5286c32ee39c4..58d5b9f8f6aa832ad6943dd23bffcaf869467da1 100644 --- a/Core/Simulation/DepthProbeSimulation.cpp +++ b/Core/Simulation/DepthProbeSimulation.cpp @@ -16,8 +16,8 @@ #include "Core/Computation/DepthProbeComputation.h" #include "Core/Computation/IBackground.h" #include "Device/Beam/IFootprintFactor.h" -#include "Device/Detector/SimpleUnitConverters.h" #include "Device/Detector/SpecularDetector1D.h" +#include "Device/Detector/UnitConverter2D.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Param/Distrib/Distributions.h" diff --git a/Core/Simulation/GISASSimulation.cpp b/Core/Simulation/GISASSimulation.cpp index fb556a2fd649f5b6a0871e21f32b2042bd1d6e74..fc87164d1622ce33da5e9adbbf2ff9dc919b4df4 100644 --- a/Core/Simulation/GISASSimulation.cpp +++ b/Core/Simulation/GISASSimulation.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "Core/Simulation/GISASSimulation.h" -#include "Core/Simulation/UnitConverterUtils.h" +#include "Device/Detector/UnitConverter2D.h" #include "Sample/SampleBuilderEngine/ISampleBuilder.h" GISASSimulation::GISASSimulation(const Beam& beam, const MultiLayer& sample, @@ -57,7 +57,7 @@ void GISASSimulation::prepareSimulation() SimulationResult GISASSimulation::result() const { - const auto converter = UnitConverterUtils::createConverterForGISAS(instrument()); + const auto converter = UnitConverter2D::createConverterForGISAS(instrument()); const std::unique_ptr<OutputData<double>> data( detector().createDetectorIntensity(m_sim_elements)); return SimulationResult(*data, *converter); diff --git a/Core/Simulation/OffSpecularSimulation.cpp b/Core/Simulation/OffSpecularSimulation.cpp index f9b002bf15a49dfc00688137919cc7af609c0984..ff8fe0d03dbcca208c508e57e34a1212da947e7c 100644 --- a/Core/Simulation/OffSpecularSimulation.cpp +++ b/Core/Simulation/OffSpecularSimulation.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "Core/Simulation/OffSpecularSimulation.h" -#include "Device/Detector/SimpleUnitConverters.h" +#include "Device/Detector/UnitConverter2D.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Param/Distrib/Distributions.h" diff --git a/Core/Simulation/UnitConverterUtils.cpp b/Core/Simulation/UnitConverterUtils.cpp deleted file mode 100644 index 4754636a5bc48a9ed540e697d3137c44e209c627..0000000000000000000000000000000000000000 --- a/Core/Simulation/UnitConverterUtils.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Core/Simulation/UnitConverterUtils.cpp -//! @brief Implements utilities for unit convertion. -//! -//! @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 "Core/Simulation/UnitConverterUtils.h" -#include "Device/Detector/RectangularDetector.h" -#include "Device/Detector/SimpleUnitConverters.h" -#include "Device/Detector/SphericalDetector.h" -#include "Device/Instrument/Instrument.h" - -std::unique_ptr<OutputData<double>> -UnitConverterUtils::createOutputData(const IUnitConverter& converter, Axes::Units units) -{ - std::unique_ptr<OutputData<double>> result = std::make_unique<OutputData<double>>(); - for (size_t i = 0; i < converter.dimension(); ++i) - result->addAxis(*converter.createConvertedAxis(i, units)); - result->setAllTo(0.0); - return result; -} - -std::unique_ptr<IUnitConverter> -UnitConverterUtils::createConverterForGISAS(const Instrument& instrument) -{ - const IDetector* const detector = instrument.getDetector(); - - if (const auto* const det = dynamic_cast<const SphericalDetector*>(detector)) - return std::make_unique<SphericalConverter>(*det, instrument.beam()); - - if (const auto* const det = dynamic_cast<const RectangularDetector*>(detector)) - return std::make_unique<RectangularConverter>(*det, instrument.beam()); - - throw std::runtime_error("Error in createConverterForGISAS: wrong or absent detector type"); -} diff --git a/Core/Simulation/UnitConverterUtils.h b/Core/Simulation/UnitConverterUtils.h deleted file mode 100644 index c6289b1f5e6f944c4eecc16d82508aef316bc676..0000000000000000000000000000000000000000 --- a/Core/Simulation/UnitConverterUtils.h +++ /dev/null @@ -1,43 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Core/Simulation/UnitConverterUtils.h -//! @brief Declares utilities for unit converters. -//! -//! @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 - -#ifndef USER_API -#ifndef BORNAGAIN_CORE_SIMULATION_UNITCONVERTERUTILS_H -#define BORNAGAIN_CORE_SIMULATION_UNITCONVERTERUTILS_H - -#include "Device/Unit/IUnitConverter.h" - -class Instrument; -template <class T> class OutputData; - -//! Namespace enclosing a number of utilities/helpers for unit converters - -namespace UnitConverterUtils { - -//! Returns zero-valued output data array in specified units -std::unique_ptr<OutputData<double>> createOutputData(const IUnitConverter& converter, - Axes::Units units); - -//! Helper factory function to use in GISASSimulation. Depending on the type of detector, -//! returns either RectangularConverter or SphericalConverter. -std::unique_ptr<IUnitConverter> createConverterForGISAS(const Instrument& instrument); - -} // namespace UnitConverterUtils - -#endif // BORNAGAIN_CORE_SIMULATION_UNITCONVERTERUTILS_H -#endif // USER_API diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h index 24d3d5d8df6a31fea0cf208455a214033f2e600f..c6b71924ae2200af10a404b68e88a35b436c5a85 100644 --- a/Device/Detector/IDetector.h +++ b/Device/Detector/IDetector.h @@ -95,7 +95,7 @@ public: createDetectorIntensity(const std::vector<SimulationElement>& elements) const; //! Return default axes units - virtual Axes::Units defaultAxesUnits() const { return Axes::Units::DEFAULT; } + virtual Axes::Units defaultAxesUnits() const = 0; //! Returns number of simulation elements. size_t numberOfSimulationElements() const; diff --git a/Device/Detector/RectangularDetector.cpp b/Device/Detector/RectangularDetector.cpp index e5df3ededff6182d0292c4afb24cd59c920fcdc5..517ffed8a0ba9d1fa0937e1ef318aad287596f3a 100644 --- a/Device/Detector/RectangularDetector.cpp +++ b/Device/Detector/RectangularDetector.cpp @@ -161,11 +161,6 @@ RectangularDetector::EDetectorArrangement RectangularDetector::getDetectorArrang return m_detector_arrangement; } -Axes::Units RectangularDetector::defaultAxesUnits() const -{ - return Axes::Units::MM; -} - RectangularPixel* RectangularDetector::regionOfInterestPixel() const { const IAxis& u_axis = axis(0); diff --git a/Device/Detector/RectangularDetector.h b/Device/Detector/RectangularDetector.h index c21c912ea625f7de20752be1a3c5a7613b2175be..774af2c4779c505c4a4489c0a94527186756bfc1 100644 --- a/Device/Detector/RectangularDetector.h +++ b/Device/Detector/RectangularDetector.h @@ -73,7 +73,7 @@ public: EDetectorArrangement getDetectorArrangment() const; //! return default axes units - Axes::Units defaultAxesUnits() const override; + virtual Axes::Units defaultAxesUnits() const final { return Axes::Units::MM; } RectangularPixel* regionOfInterestPixel() const; diff --git a/Device/Detector/SpecularDetector1D.cpp b/Device/Detector/SpecularDetector1D.cpp index 9ed6713ce6e22e2cef12b1d5537a0dfc57d32c5a..1fc74af3801acdad13d07ddd5e86e4beee76c353 100644 --- a/Device/Detector/SpecularDetector1D.cpp +++ b/Device/Detector/SpecularDetector1D.cpp @@ -37,11 +37,6 @@ SpecularDetector1D* SpecularDetector1D::clone() const return new SpecularDetector1D(*this); } -Axes::Units SpecularDetector1D::defaultAxesUnits() const -{ - return Axes::Units::RADIANS; -} - std::string SpecularDetector1D::axisName(size_t index) const { if (index == 0) { diff --git a/Device/Detector/SpecularDetector1D.h b/Device/Detector/SpecularDetector1D.h index 353cb8ab0476fd4dbbd2b1a46f4daa02c6f25863..09501594e1010f2cc9b8eb4c8bd7bfb737301244 100644 --- a/Device/Detector/SpecularDetector1D.h +++ b/Device/Detector/SpecularDetector1D.h @@ -49,7 +49,8 @@ public: void setAxis(const IAxis& axis); //! Return default axes units - Axes::Units defaultAxesUnits() const override; + virtual Axes::Units defaultAxesUnits() const final { return Axes::Units::RADIANS; } + protected: SpecularDetector1D(const SpecularDetector1D& other); diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp index 6c4803f6529c021c2a1cf36ea2460b1742ce22f2..a1686167e80ca8e2f846670ec3e6cf4e961819c5 100644 --- a/Device/Detector/SphericalDetector.cpp +++ b/Device/Detector/SphericalDetector.cpp @@ -48,11 +48,6 @@ SphericalDetector* SphericalDetector::clone() const return new SphericalDetector(*this); } -Axes::Units SphericalDetector::defaultAxesUnits() const -{ - return Axes::Units::RADIANS; -} - IPixel* SphericalDetector::createPixel(size_t index) const { const IAxis& phi_axis = axis(0); diff --git a/Device/Detector/SphericalDetector.h b/Device/Detector/SphericalDetector.h index f31460c4cbb551f8925db6cdcea9a5ed4c7f4490..52eef2a455a44a3315c65690c102baf208d3fd71 100644 --- a/Device/Detector/SphericalDetector.h +++ b/Device/Detector/SphericalDetector.h @@ -53,7 +53,7 @@ public: ~SphericalDetector() override {} //! return default axes units - Axes::Units defaultAxesUnits() const override; + virtual Axes::Units defaultAxesUnits() const final { return Axes::Units::RADIANS; } protected: //! Creates an IPixel for the given OutputData object and index diff --git a/Device/Detector/SimpleUnitConverters.cpp b/Device/Detector/UnitConverter2D.cpp similarity index 83% rename from Device/Detector/SimpleUnitConverters.cpp rename to Device/Detector/UnitConverter2D.cpp index 7be4f59181d46eba84fb21ac70d2436cf7fba7fa..74a6d1e96b983bb9de8768dbbf74435f98982ece 100644 --- a/Device/Detector/SimpleUnitConverters.cpp +++ b/Device/Detector/UnitConverter2D.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file Device/Detector/SimpleUnitConverters.cpp +//! @file Device/Detector/UnitConverter2D.cpp //! @brief Implements IUnitConverter classes. //! //! @homepage http://www.bornagainproject.org @@ -12,13 +12,13 @@ // // ************************************************************************************************ -#include "Device/Detector/SimpleUnitConverters.h" +#include "Device/Detector/UnitConverter2D.h" #include "Base/Const/Units.h" #include "Base/Math/Constants.h" #include "Base/Pixel/RectangularPixel.h" -#include "Device/Beam/Beam.h" #include "Device/Detector/RectangularDetector.h" #include "Device/Detector/SphericalDetector.h" +#include "Device/Instrument/Instrument.h" #include "Device/ProDetector/RegionOfInterest.h" #include "Device/Unit/AxisNames.h" #include <algorithm> @@ -33,60 +33,59 @@ double getQ(double wavelength, double angle) } // namespace // ************************************************************************************************ -// class UnitConverterSimple +// class UnitConverter2D // ************************************************************************************************ -UnitConverterSimple::UnitConverterSimple(const Beam& beam) +UnitConverter2D::UnitConverter2D(const Beam& beam) : m_wavelength(beam.wavelength()) , m_alpha_i(-beam.direction().alpha()) , m_phi_i(beam.direction().phi()) { } -size_t UnitConverterSimple::dimension() const +size_t UnitConverter2D::dimension() const { return m_axis_data_table.size(); } -void UnitConverterSimple::addAxisData(std::string name, double min, double max, - Axes::Units default_units, size_t nbins) +void UnitConverter2D::addAxisData(std::string name, double min, double max, + Axes::Units default_units, size_t nbins) { m_axis_data_table.emplace_back(AxisData{name, min, max, default_units, nbins}); } -double UnitConverterSimple::calculateMin(size_t i_axis, Axes::Units units_type) const +double UnitConverter2D::calculateMin(size_t i_axis, Axes::Units units) const { ASSERT(i_axis < dimension()); - units_type = substituteDefaultUnits(units_type); + units = substituteDefaultUnits(units); const auto& axis_data = m_axis_data_table[i_axis]; - if (units_type == Axes::Units::NBINS) + if (units == Axes::Units::NBINS) return 0.0; - return calculateValue(i_axis, units_type, axis_data.min); + return calculateValue(i_axis, units, axis_data.min); } -double UnitConverterSimple::calculateMax(size_t i_axis, Axes::Units units_type) const +double UnitConverter2D::calculateMax(size_t i_axis, Axes::Units units) const { ASSERT(i_axis < dimension()); - units_type = substituteDefaultUnits(units_type); + units = substituteDefaultUnits(units); const auto& axis_data = m_axis_data_table[i_axis]; - if (units_type == Axes::Units::NBINS) + if (units == Axes::Units::NBINS) return static_cast<double>(axis_data.nbins); - return calculateValue(i_axis, units_type, axis_data.max); + return calculateValue(i_axis, units, axis_data.max); } -size_t UnitConverterSimple::axisSize(size_t i_axis) const +size_t UnitConverter2D::axisSize(size_t i_axis) const { ASSERT(i_axis < dimension()); return m_axis_data_table[i_axis].nbins; } -std::vector<Axes::Units> UnitConverterSimple::availableUnits() const +std::vector<Axes::Units> UnitConverter2D::availableUnits() const { return {Axes::Units::NBINS, Axes::Units::RADIANS, Axes::Units::DEGREES}; } -std::unique_ptr<IAxis> UnitConverterSimple::createConvertedAxis(size_t i_axis, - Axes::Units units) const +std::unique_ptr<IAxis> UnitConverter2D::createConvertedAxis(size_t i_axis, Axes::Units units) const { const double min = calculateMin(i_axis, units); const double max = calculateMax(i_axis, units); @@ -95,7 +94,7 @@ std::unique_ptr<IAxis> UnitConverterSimple::createConvertedAxis(size_t i_axis, return std::make_unique<FixedBinAxis>(axis_name, axis_size, min, max); } -UnitConverterSimple::UnitConverterSimple(const UnitConverterSimple& other) +UnitConverter2D::UnitConverter2D(const UnitConverter2D& other) : m_axis_data_table(other.m_axis_data_table) , m_wavelength(other.m_wavelength) , m_alpha_i(other.m_alpha_i) @@ -103,7 +102,7 @@ UnitConverterSimple::UnitConverterSimple(const UnitConverterSimple& other) { } -void UnitConverterSimple::addDetectorAxis(const IDetector& detector, size_t i_axis) +void UnitConverter2D::addDetectorAxis(const IDetector& detector, size_t i_axis) { const auto& axis = detector.axis(i_axis); const auto* p_roi = detector.regionOfInterest(); @@ -117,12 +116,26 @@ void UnitConverterSimple::addDetectorAxis(const IDetector& detector, size_t i_ax P_roi_axis->size()); } +std::unique_ptr<UnitConverter2D> +UnitConverter2D::createConverterForGISAS(const Instrument& instrument) +{ + const IDetector* const detector = instrument.getDetector(); + + if (const auto* const det = dynamic_cast<const SphericalDetector*>(detector)) + return std::make_unique<SphericalConverter>(*det, instrument.beam()); + + if (const auto* const det = dynamic_cast<const RectangularDetector*>(detector)) + return std::make_unique<RectangularConverter>(*det, instrument.beam()); + + throw std::runtime_error("Error in createConverterForGISAS: wrong or absent detector type"); +} + // ************************************************************************************************ // class SphericalConverter // ************************************************************************************************ SphericalConverter::SphericalConverter(const SphericalDetector& detector, const Beam& beam) - : UnitConverterSimple(beam) + : UnitConverter2D(beam) { ASSERT(detector.dimension() == 2); addDetectorAxis(detector, 0); @@ -138,7 +151,7 @@ SphericalConverter* SphericalConverter::clone() const std::vector<Axes::Units> SphericalConverter::availableUnits() const { - auto result = UnitConverterSimple::availableUnits(); + auto result = UnitConverter2D::availableUnits(); result.push_back(Axes::Units::QSPACE); return result; } @@ -148,13 +161,11 @@ Axes::Units SphericalConverter::defaultUnits() const return Axes::Units::DEGREES; } -SphericalConverter::SphericalConverter(const SphericalConverter& other) : UnitConverterSimple(other) -{ -} +SphericalConverter::SphericalConverter(const SphericalConverter& other) : UnitConverter2D(other) {} -double SphericalConverter::calculateValue(size_t i_axis, Axes::Units units_type, double value) const +double SphericalConverter::calculateValue(size_t i_axis, Axes::Units units, double value) const { - switch (units_type) { + switch (units) { case Axes::Units::RADIANS: return value; case Axes::Units::DEGREES: @@ -200,7 +211,7 @@ std::vector<std::map<Axes::Units, std::string>> SphericalConverter::createNameMa // ************************************************************************************************ RectangularConverter::RectangularConverter(const RectangularDetector& detector, const Beam& beam) - : UnitConverterSimple(beam) + : UnitConverter2D(beam) { ASSERT(detector.dimension() == 2); addDetectorAxis(detector, 0); @@ -217,7 +228,7 @@ RectangularConverter* RectangularConverter::clone() const std::vector<Axes::Units> RectangularConverter::availableUnits() const { - auto result = UnitConverterSimple::availableUnits(); + auto result = UnitConverter2D::availableUnits(); result.push_back(Axes::Units::QSPACE); result.push_back(Axes::Units::MM); return result; @@ -229,14 +240,13 @@ Axes::Units RectangularConverter::defaultUnits() const } RectangularConverter::RectangularConverter(const RectangularConverter& other) - : UnitConverterSimple(other), m_detector_pixel(other.m_detector_pixel->clone()) + : UnitConverter2D(other), m_detector_pixel(other.m_detector_pixel->clone()) { } -double RectangularConverter::calculateValue(size_t i_axis, Axes::Units units_type, - double value) const +double RectangularConverter::calculateValue(size_t i_axis, Axes::Units units, double value) const { - if (units_type == Axes::Units::MM) + if (units == Axes::Units::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); @@ -244,7 +254,7 @@ double RectangularConverter::calculateValue(size_t i_axis, Axes::Units units_typ const auto& max_pos = i_axis == 0 ? k10 : k01; // position of max along given axis const double shift = value - m_axis_data_table[i_axis].min; const auto k_f = normalizeToWavelength(k00 + shift * (max_pos - k00).unit()); - switch (units_type) { + switch (units) { case Axes::Units::RADIANS: return axisAngle(i_axis, k_f); case Axes::Units::DEGREES: @@ -303,7 +313,7 @@ double RectangularConverter::axisAngle(size_t i_axis, kvector_t k_f) const OffSpecularConverter::OffSpecularConverter(const IDetector2D& detector, const Beam& beam, const IAxis& alpha_axis) - : UnitConverterSimple(beam) + : UnitConverter2D(beam) { ASSERT(detector.dimension() == 2); addAxisData(axisName(0), alpha_axis.lowerBound(), alpha_axis.upperBound(), defaultUnits(), @@ -324,13 +334,13 @@ Axes::Units OffSpecularConverter::defaultUnits() const } OffSpecularConverter::OffSpecularConverter(const OffSpecularConverter& other) - : UnitConverterSimple(other) + : UnitConverter2D(other) { } -double OffSpecularConverter::calculateValue(size_t, Axes::Units units_type, double value) const +double OffSpecularConverter::calculateValue(size_t, Axes::Units units, double value) const { - switch (units_type) { + switch (units) { case Axes::Units::RADIANS: return value; case Axes::Units::DEGREES: @@ -382,7 +392,7 @@ const std::string z_axis_name = "Position [nm]"; DepthProbeConverter::DepthProbeConverter(const Beam& beam, const IAxis& alpha_axis, const IAxis& z_axis) - : UnitConverterSimple(beam) + : UnitConverter2D(beam) { const auto& alpha_axis_name = axisName(0); const auto& z_axis_name = axisName(1); @@ -401,23 +411,21 @@ DepthProbeConverter* DepthProbeConverter::clone() const std::vector<Axes::Units> DepthProbeConverter::availableUnits() const { - auto result = UnitConverterSimple::availableUnits(); + auto result = UnitConverter2D::availableUnits(); result.push_back(Axes::Units::QSPACE); return result; } -DepthProbeConverter::DepthProbeConverter(const DepthProbeConverter& other) - : UnitConverterSimple(other) +DepthProbeConverter::DepthProbeConverter(const DepthProbeConverter& other) : UnitConverter2D(other) { } -double DepthProbeConverter::calculateValue(size_t i_axis, Axes::Units units_type, - double value) const +double DepthProbeConverter::calculateValue(size_t i_axis, Axes::Units units, double value) const { - checkUnits(units_type); + checkUnits(units); if (i_axis == 1) return value; // unit conversions are not applied to sample position axis - switch (units_type) { + switch (units) { case Axes::Units::DEGREES: return Units::rad2deg(value); case Axes::Units::QSPACE: @@ -432,10 +440,9 @@ std::vector<std::map<Axes::Units, std::string>> DepthProbeConverter::createNameM return {AxisNames::specAxis, AxisNames::sampleDepthAxis}; } -void DepthProbeConverter::checkUnits(Axes::Units units_type) const +void DepthProbeConverter::checkUnits(Axes::Units units) const { const auto& available_units = availableUnits(); - if (std::find(available_units.begin(), available_units.end(), units_type) - == available_units.cend()) + if (std::find(available_units.begin(), available_units.end(), units) == available_units.cend()) throwUnitsError("DepthProbeConverter::checkUnits", available_units); } diff --git a/Device/Detector/SimpleUnitConverters.h b/Device/Detector/UnitConverter2D.h similarity index 78% rename from Device/Detector/SimpleUnitConverters.h rename to Device/Detector/UnitConverter2D.h index 464877ca6a66a19a253039159ec8370fd1912731..eddea1de3ce0d4890d5f0e7d5123f319e5a9a78f 100644 --- a/Device/Detector/SimpleUnitConverters.h +++ b/Device/Detector/UnitConverter2D.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file Device/Detector/SimpleUnitConverters.h -//! @brief Defines interface UnitConverterSimple and its subclasses. +//! @file Device/Detector/UnitConverter2D.h +//! @brief Defines interface UnitConverter2D and its subclasses. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -26,6 +26,7 @@ class Beam; class IDetector; class IDetector2D; +class Instrument; class RectangularDetector; class RectangularPixel; class SphericalDetector; @@ -33,15 +34,15 @@ class SphericalDetector; //! Interface for objects that provide axis translations to different units for IDetector objects //! @ingroup simulation_internal -class UnitConverterSimple : public IUnitConverter { +class UnitConverter2D : public IUnitConverter { public: - UnitConverterSimple(const Beam& beam); - ~UnitConverterSimple() override = default; + UnitConverter2D(const Beam& beam); + ~UnitConverter2D() override = default; virtual size_t dimension() const override; - double calculateMin(size_t i_axis, Axes::Units units_type) const override; - double calculateMax(size_t i_axis, Axes::Units units_type) const override; + double calculateMin(size_t i_axis, Axes::Units units) const override; + double calculateMax(size_t i_axis, Axes::Units units) const override; size_t axisSize(size_t i_axis) const override; //! Returns the list of all available units @@ -49,8 +50,12 @@ public: std::unique_ptr<IAxis> createConvertedAxis(size_t i_axis, Axes::Units units) const override; + //! Helper factory function to use in GISASSimulation. Depending on the type of detector, + //! returns either RectangularConverter or SphericalConverter. + static std::unique_ptr<UnitConverter2D> createConverterForGISAS(const Instrument& instrument); + protected: - UnitConverterSimple(const UnitConverterSimple& other); + UnitConverter2D(const UnitConverter2D& other); void addDetectorAxis(const IDetector& detector, size_t i_axis); void addAxisData(std::string name, double min, double max, Axes::Units default_units, @@ -70,14 +75,14 @@ protected: double m_phi_i; private: - virtual double calculateValue(size_t i_axis, Axes::Units units_type, double value) const = 0; + virtual double calculateValue(size_t i_axis, Axes::Units units, double value) const = 0; }; //! IUnitConverter class that handles the unit translations for spherical detectors //! Its default units are radians for both axes //! @ingroup simulation_internal -class SphericalConverter : public UnitConverterSimple { +class SphericalConverter : public UnitConverter2D { public: SphericalConverter(const SphericalDetector& detector, const Beam& beam); @@ -92,7 +97,7 @@ public: private: SphericalConverter(const SphericalConverter& other); - double calculateValue(size_t i_axis, Axes::Units units_type, double value) const override; + double calculateValue(size_t i_axis, Axes::Units units, double value) const override; std::vector<std::map<Axes::Units, std::string>> createNameMaps() const override; }; @@ -100,7 +105,7 @@ private: //! Its default units are mm for both axes //! @ingroup simulation_internal -class RectangularConverter : public UnitConverterSimple { +class RectangularConverter : public UnitConverter2D { public: RectangularConverter(const RectangularDetector& detector, const Beam& beam); ~RectangularConverter() override; @@ -114,7 +119,7 @@ public: private: RectangularConverter(const RectangularConverter& other); - double calculateValue(size_t i_axis, Axes::Units units_type, double value) const override; + double calculateValue(size_t i_axis, Axes::Units units, double value) const override; std::vector<std::map<Axes::Units, std::string>> createNameMaps() const override; kvector_t normalizeToWavelength(kvector_t vector) const; double axisAngle(size_t i_axis, kvector_t k_f) const; @@ -126,7 +131,7 @@ private: //! Its default units are radians for both axes //! @ingroup simulation_internal -class OffSpecularConverter : public UnitConverterSimple { +class OffSpecularConverter : public UnitConverter2D { public: OffSpecularConverter(const IDetector2D& detector, const Beam& beam, const IAxis& alpha_axis); ~OffSpecularConverter() override; @@ -137,7 +142,7 @@ public: private: OffSpecularConverter(const OffSpecularConverter& other); - double calculateValue(size_t i_axis, Axes::Units units_type, double value) const override; + double calculateValue(size_t i_axis, Axes::Units units, double value) const override; std::vector<std::map<Axes::Units, std::string>> createNameMaps() const override; void addDetectorYAxis(const IDetector2D& detector); }; @@ -146,7 +151,7 @@ private: //! Its default units are radians for x-axis and nm for y-axis //! @ingroup simulation_internal -class DepthProbeConverter : public UnitConverterSimple { +class DepthProbeConverter : public UnitConverter2D { public: DepthProbeConverter(const Beam& beam, const IAxis& alpha_axis, const IAxis& z_axis); ~DepthProbeConverter() override; @@ -160,9 +165,9 @@ public: private: DepthProbeConverter(const DepthProbeConverter& other); - double calculateValue(size_t, Axes::Units units_type, double value) const override; + double calculateValue(size_t, Axes::Units units, double value) const override; std::vector<std::map<Axes::Units, std::string>> createNameMaps() const override; - void checkUnits(Axes::Units units_type) const; + void checkUnits(Axes::Units units) const; }; #endif // BORNAGAIN_DEVICE_DETECTOR_SIMPLEUNITCONVERTERS_H diff --git a/Device/Histo/SimulationResult.h b/Device/Histo/SimulationResult.h index 3fdda7847800dd28049fbba7c5acf47e85aaf08e..818f97003a7ac918ec22e7de0093a92801108ef6 100644 --- a/Device/Histo/SimulationResult.h +++ b/Device/Histo/SimulationResult.h @@ -49,13 +49,13 @@ public: SimulationResult& operator=(SimulationResult&& other); #ifndef SWIG - std::unique_ptr<OutputData<double>> data(Axes::Units units = Axes::Units::DEFAULT) const; + std::unique_ptr<OutputData<double>> data(Axes::Units units = Axes::Units::UNDEFINED) const; #endif - Histogram2D* histogram2d(Axes::Units units = Axes::Units::DEFAULT) const; + Histogram2D* histogram2d(Axes::Units units = Axes::Units::UNDEFINED) const; //! Provide AxisInfo for each axis and the given units - std::vector<AxisInfo> axisInfo(Axes::Units units = Axes::Units::DEFAULT) const; + std::vector<AxisInfo> axisInfo(Axes::Units units = Axes::Units::UNDEFINED) const; //! Returns underlying unit converter const IUnitConverter& converter() const; @@ -69,14 +69,14 @@ public: //! returns intensity data as Python numpy array #ifdef BORNAGAIN_PYTHON - PyObject* array(Axes::Units units = Axes::Units::DEFAULT) const; + PyObject* array(Axes::Units units = Axes::Units::UNDEFINED) const; #endif - std::vector<double> axis(Axes::Units units = Axes::Units::DEFAULT) const; + std::vector<double> axis(Axes::Units units = Axes::Units::UNDEFINED) const; //! Returns axis coordinates as a numpy array. With no parameters given //! returns coordinates of x-axis in default units. - std::vector<double> axis(size_t i_axis, Axes::Units units = Axes::Units::DEFAULT) const; + std::vector<double> axis(size_t i_axis, Axes::Units units = Axes::Units::UNDEFINED) const; private: void checkDimensions() const; diff --git a/Device/Unit/Axes.h b/Device/Unit/Axes.h index 7e4fe791875be9a18b5e9dcb9c958296c079f71a..7183e599867fea8dd6de60e5d651c0702b6e3d47 100644 --- a/Device/Unit/Axes.h +++ b/Device/Unit/Axes.h @@ -21,7 +21,7 @@ class Axes { public: - enum Units { DEFAULT, NBINS, RADIANS, DEGREES, MM, QSPACE, QXQY, RQ4 }; + enum Units { UNDEFINED, NBINS, RADIANS, DEGREES, MM, QSPACE, QXQY, RQ4 }; }; #endif // BORNAGAIN_DEVICE_UNIT_AXES_H diff --git a/Device/Unit/AxisNames.h b/Device/Unit/AxisNames.h index 600496a852af7465685590207c0f84c67beac4f0..06f0f370277eb1287cde757aab630803042d2e24 100644 --- a/Device/Unit/AxisNames.h +++ b/Device/Unit/AxisNames.h @@ -25,10 +25,14 @@ #include <map> #include <string> -const std::map<Axes::Units, const char*> axisUnitLabel = { - {Axes::Units::DEFAULT, "undefined"}, {Axes::Units::NBINS, "bin"}, {Axes::Units::RADIANS, "rad"}, - {Axes::Units::DEGREES, "deg"}, {Axes::Units::MM, "mm"}, {Axes::Units::QSPACE, "1/nm"}, - {Axes::Units::QXQY, "1/nm"}, {Axes::Units::RQ4, "nm^-4?"}}; +const std::map<Axes::Units, const char*> axisUnitLabel = {{Axes::Units::UNDEFINED, "undefined"}, + {Axes::Units::NBINS, "bin"}, + {Axes::Units::RADIANS, "rad"}, + {Axes::Units::DEGREES, "deg"}, + {Axes::Units::MM, "mm"}, + {Axes::Units::QSPACE, "1/nm"}, + {Axes::Units::QXQY, "1/nm"}, + {Axes::Units::RQ4, "nm^-4?"}}; //! Contains const maps that give the right axis names for different detector types and units //! @ingroup detector diff --git a/Device/Unit/IUnitConverter.cpp b/Device/Unit/IUnitConverter.cpp index 416cf875b85f0c8c9e62b81d6bfdbea10904c85b..c85d66bb8a760251c6b2c1193a164ee646aff70e 100644 --- a/Device/Unit/IUnitConverter.cpp +++ b/Device/Unit/IUnitConverter.cpp @@ -16,19 +16,25 @@ #include "Device/Data/OutputData.h" #include "Device/Unit/AxisNames.h" + IUnitConverter::~IUnitConverter() = default; -std::string IUnitConverter::axisName(size_t i_axis, const Axes::Units& units_type) const +std::unique_ptr<OutputData<double>> IUnitConverter::createOutputData(Axes::Units units) const +{ + std::unique_ptr<OutputData<double>> result = std::make_unique<OutputData<double>>(); + for (size_t i = 0; i < dimension(); ++i) + result->addAxis(*createConvertedAxis(i, units)); + result->setAllTo(0.0); + return result; +} + +std::string IUnitConverter::axisName(size_t i_axis, const Axes::Units units) const { const auto& name_maps = createNameMaps(); - if (name_maps.size() <= i_axis) - throw std::runtime_error("Error in IUnitConverter::axisName: the size of name map vector " - "is smaller or equal to the axis index" - + std::to_string(static_cast<int>(i_axis))); + ASSERT(i_axis < name_maps.size()); const auto& name_map = name_maps[i_axis]; - const auto& it = name_map.find(substituteDefaultUnits(units_type)); - if (it == name_map.cend()) - throwUnitsError("IUnitConverter::axisName", availableUnits()); + const auto& it = name_map.find(units == Axes::Units::UNDEFINED ? defaultUnits() : units); + ASSERT(it != name_map.cend()); return it->second; } @@ -55,5 +61,5 @@ void IUnitConverter::throwUnitsError(std::string method, std::vector<Axes::Units Axes::Units IUnitConverter::substituteDefaultUnits(Axes::Units units) const { - return units == Axes::Units::DEFAULT ? defaultUnits() : units; + return units == Axes::Units::UNDEFINED ? defaultUnits() : units; } diff --git a/Device/Unit/IUnitConverter.h b/Device/Unit/IUnitConverter.h index 226c0c8ef3248436c7062a38c4b931ee4de9cb37..7217446b027de86337fbdab476337c1b801bbbef 100644 --- a/Device/Unit/IUnitConverter.h +++ b/Device/Unit/IUnitConverter.h @@ -26,6 +26,7 @@ #include <string> #include <vector> + class IAxis; template <class T> class OutputData; @@ -45,13 +46,16 @@ public: virtual IUnitConverter* clone() const = 0; + //! Returns zero-valued output data array in specified units + std::unique_ptr<OutputData<double>> createOutputData(Axes::Units units) const; + virtual size_t dimension() const = 0; - virtual double calculateMin(size_t i_axis, Axes::Units units_type) const = 0; - virtual double calculateMax(size_t i_axis, Axes::Units units_type) const = 0; + virtual double calculateMin(size_t i_axis, Axes::Units units) const = 0; + virtual double calculateMax(size_t i_axis, Axes::Units units) const = 0; virtual size_t axisSize(size_t i_axis) const = 0; - std::string axisName(size_t i_axis, const Axes::Units& units_type = Axes::Units::DEFAULT) const; + std::string axisName(size_t i_axis, const Axes::Units units = Axes::Units::UNDEFINED) const; virtual std::vector<Axes::Units> availableUnits() const = 0; virtual Axes::Units defaultUnits() const = 0; diff --git a/Examples/fit55_SpecularIntro/RealLifeReflectometryFitting.py b/Examples/fit55_SpecularIntro/RealLifeReflectometryFitting.py index f959222a8a8b0dccb2397a241f3e1f006b32992b..843ebfbef8a49ce43fc14056bba9e71652d0e61b 100755 --- a/Examples/fit55_SpecularIntro/RealLifeReflectometryFitting.py +++ b/Examples/fit55_SpecularIntro/RealLifeReflectometryFitting.py @@ -272,7 +272,7 @@ def plot_result(sim_result, ref_result, bin_start=0, bin_end=-1): get_real_data_values(bin_start, bin_end), sim_result.axis(), sim_data, ref_result.axis(), ref_data) - xlabel = ba_plot.get_axes_labels(sim_result, ba.Axes.DEFAULT)[0] + xlabel = ba_plot.get_axes_labels(sim_result, ba.Axes.UNDEFINED)[0] ylabel = "Intensity" plt.xlabel(xlabel, fontsize=16) plt.ylabel(ylabel, fontsize=16) diff --git a/GUI/coregui/Models/DataViewUtils.cpp b/GUI/coregui/Models/DataViewUtils.cpp index bed8a964442621797599d88c4d85b3363f8f328a..6ba163040da8f332c4dc9ffe156769940463d35f 100644 --- a/GUI/coregui/Models/DataViewUtils.cpp +++ b/GUI/coregui/Models/DataViewUtils.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/coregui/Models/DataViewUtils.h" -#include "Core/Simulation/UnitConverterUtils.h" +#include "Device/Unit/IUnitConverter.h" #include "GUI/coregui/Models/Data1DViewItem.h" #include "GUI/coregui/Models/DataItem.h" #include "GUI/coregui/Models/DataPropertyContainer.h" @@ -62,7 +62,7 @@ std::unique_ptr<OutputData<double>> DataViewUtils::getTranslatedData(Data1DViewI auto converter = getConverter(view_item); auto current_units = selectedUnits(view_item); - result = UnitConverterUtils::createOutputData(*converter, current_units); + result = converter->createOutputData(current_units); result->setRawDataVector(data_item->getOutputData()->getRawDataVector()); return result; diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp b/GUI/coregui/Models/DepthProbeInstrumentItem.cpp index 9cb127634dc38ab39113d3b1481f5f32d4d77095..afea9a15517568a9efdced3300296e2fbcb62209 100644 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.cpp +++ b/GUI/coregui/Models/DepthProbeInstrumentItem.cpp @@ -15,7 +15,6 @@ #include "GUI/coregui/Models/DepthProbeInstrumentItem.h" #include "Base/Const/Units.h" #include "Core/Simulation/DepthProbeSimulation.h" -#include "Device/Detector/SimpleUnitConverters.h" #include "GUI/coregui/Models/AxesItems.h" #include "GUI/coregui/Models/BeamItems.h" #include "GUI/coregui/Models/BeamWavelengthItem.h" @@ -98,8 +97,3 @@ std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation return simulation; } - -std::unique_ptr<IUnitConverter> DepthProbeInstrumentItem::createUnitConverter() const -{ - return createSimulation()->createUnitConverter(); -} diff --git a/GUI/coregui/Models/DepthProbeInstrumentItem.h b/GUI/coregui/Models/DepthProbeInstrumentItem.h index 73d92b9c1daa3ec07319adb6f6d22db6c16793fd..ba1f29d09a04c2e0c6fe03242fb8bf7731100855 100644 --- a/GUI/coregui/Models/DepthProbeInstrumentItem.h +++ b/GUI/coregui/Models/DepthProbeInstrumentItem.h @@ -38,8 +38,6 @@ public: // FIXME switch to base ISimulation class after InstrumentItem refactoring and // after ISimulation gets createUnitConverter method std::unique_ptr<DepthProbeSimulation> createSimulation() const; - - std::unique_ptr<IUnitConverter> createUnitConverter() const; }; #endif // BORNAGAIN_GUI_COREGUI_MODELS_DEPTHPROBEINSTRUMENTITEM_H diff --git a/GUI/coregui/Models/DomainObjectBuilder.cpp b/GUI/coregui/Models/DomainObjectBuilder.cpp index d4e7d16ac1b79b2178c70b5e534c795db643908d..a2a359ef452bbb7d4195708fbc0e967dd5306fb0 100644 --- a/GUI/coregui/Models/DomainObjectBuilder.cpp +++ b/GUI/coregui/Models/DomainObjectBuilder.cpp @@ -15,9 +15,9 @@ #include "GUI/coregui/Models/DomainObjectBuilder.h" #include "Base/Const/Units.h" #include "Core/Scan/UnitConverter1D.h" -#include "Core/Simulation/UnitConverterUtils.h" +#include "Core/Simulation/DepthProbeSimulation.h" #include "Device/Detector/IDetector2D.h" -#include "Device/Detector/SimpleUnitConverters.h" +#include "Device/Detector/UnitConverter2D.h" #include "GUI/coregui/Models/AxesItems.h" #include "GUI/coregui/Models/ComboProperty.h" #include "GUI/coregui/Models/DepthProbeInstrumentItem.h" @@ -40,11 +40,10 @@ std::unique_ptr<MultiLayer> DomainObjectBuilder::buildMultiLayer(const SessionIt ASSERT(roughnessItem); auto P_roughness = TransformToDomain::createLayerRoughness(*roughnessItem); if (P_layer) { - if (P_roughness) { + if (P_roughness) P_multilayer->addLayerWithTopRoughness(*P_layer, *P_roughness); - } else { + else P_multilayer->addLayer(*P_layer); - } } } } @@ -58,9 +57,8 @@ std::unique_ptr<Layer> DomainObjectBuilder::buildLayer(const SessionItem& item) for (int i = 0; i < children.size(); ++i) { if (children[i]->modelType() == "ParticleLayout") { auto P_layout = buildParticleLayout(*children[i]); - if (P_layout) { + if (P_layout) P_layer->addLayout(*P_layout); - } } } return P_layer; @@ -109,9 +107,8 @@ std::unique_ptr<ParticleLayout> DomainObjectBuilder::buildParticleLayout(const S QVector<SessionItem*> interferences = item.getItems(ParticleLayoutItem::T_INTERFERENCE); for (int i = 0; i < interferences.size(); i++) { auto P_interference = buildInterferenceFunction(*interferences[i]); - if (P_interference) { + if (P_interference) P_layout->setInterferenceFunction(*P_interference); - } } return P_layout; } @@ -137,13 +134,13 @@ DomainObjectBuilder::createUnitConverter(const InstrumentItem* instrumentItem) return specular_instrument->createUnitConverter(); if (auto depth_instrument = dynamic_cast<const DepthProbeInstrumentItem*>(instrumentItem)) - return depth_instrument->createUnitConverter(); + return depth_instrument->createSimulation()->createUnitConverter(); const auto instrument = instrumentItem->createInstrument(); instrument->initDetector(); if (instrumentItem->is<GISASInstrumentItem>()) - return UnitConverterUtils::createConverterForGISAS(*instrument); + return UnitConverter2D::createConverterForGISAS(*instrument); if (instrumentItem->is<OffSpecularInstrumentItem>()) { auto axis_item = diff --git a/GUI/coregui/Models/InstrumentItems.cpp b/GUI/coregui/Models/InstrumentItems.cpp index c0c85d68a72a8f7ccb1060828498886d730af6f1..cf03ebbeccc49f58ddf7b2a35b0b3afb120be711 100644 --- a/GUI/coregui/Models/InstrumentItems.cpp +++ b/GUI/coregui/Models/InstrumentItems.cpp @@ -30,12 +30,32 @@ #include "GUI/coregui/utils/GUIHelpers.h" namespace { + const QString background_group_label = "Type"; const QStringList instrument_names{"GISASInstrument", "OffSpecularInstrument", "SpecularInstrument"}; -void addAxisGroupProperty(SessionItem* parent, const QString& tag); + +void addAxisGroupProperty(SessionItem* parent, const QString& tag) +{ + auto axisItem = parent->addProperty<BasicAxisItem>(tag); + axisItem->setToolTip("Incoming alpha range [deg]"); + axisItem->getItem(BasicAxisItem::P_TITLE)->setVisible(false); + axisItem->getItem(BasicAxisItem::P_NBINS)->setToolTip("Number of points in scan"); + axisItem->getItem(BasicAxisItem::P_MIN_DEG)->setToolTip("Starting value [deg]"); + axisItem->getItem(BasicAxisItem::P_MAX_DEG)->setToolTip("Ending value [deg]"); + + axisItem->setTitle("alpha_i"); + axisItem->setLowerBound(0.0); + axisItem->setUpperBound(10.0); +} + } // namespace + +// ************************************************************************************************ +// class InstrumentItem +// ************************************************************************************************ + const QString InstrumentItem::P_IDENTIFIER = "Identifier"; const QString InstrumentItem::P_BEAM = "Beam"; const QString InstrumentItem::P_BACKGROUND = "Background"; @@ -118,6 +138,11 @@ void InstrumentItem::initBackgroundGroup() item->setToolTip("Background type"); } + +// ************************************************************************************************ +// class SpecularInstrumentItem +// ************************************************************************************************ + SpecularInstrumentItem::SpecularInstrumentItem() : InstrumentItem("SpecularInstrument") { addProperty<SpecularBeamItem>(P_BEAM); @@ -189,10 +214,10 @@ std::unique_ptr<IUnitConverter> SpecularInstrumentItem::createUnitConverter() co if (!pointwise_axis->containsNonXMLData()) // workaround for loading project return nullptr; Axes::Units native_units = JobItemUtils::axesUnitsFromName(pointwise_axis->getUnitsLabel()); - return std::make_unique<UnitConverterConvSpec>(instrument->beam(), *pointwise_axis->axis(), - native_units); + return std::make_unique<AngularReflectometryConverter>( + instrument->beam(), *pointwise_axis->axis(), native_units); } else - return std::make_unique<UnitConverterConvSpec>( + return std::make_unique<AngularReflectometryConverter>( instrument->beam(), *axis_item->createAxis(1.0), Axes::Units::DEGREES); } @@ -201,6 +226,11 @@ QString SpecularInstrumentItem::defaultName() const return "Specular"; } + +// ************************************************************************************************ +// class Instrument2DItem +// ************************************************************************************************ + const QString Instrument2DItem::P_DETECTOR = "Detector"; Instrument2DItem::Instrument2DItem(const QString& modelType) : InstrumentItem(modelType) @@ -249,6 +279,11 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const return result; } + +// ************************************************************************************************ +// class GISASInstrumentItem +// ************************************************************************************************ + GISASInstrumentItem::GISASInstrumentItem() : Instrument2DItem("GISASInstrument") {} std::vector<int> GISASInstrumentItem::shape() const @@ -275,6 +310,11 @@ QString GISASInstrumentItem::defaultName() const return "GISAS"; } + +// ************************************************************************************************ +// class OffSpecularInstrumentItem +// ************************************************************************************************ + const QString OffSpecularInstrumentItem::P_ALPHA_AXIS = "Alpha axis"; OffSpecularInstrumentItem::OffSpecularInstrumentItem() : Instrument2DItem("OffSpecularInstrument") @@ -314,19 +354,3 @@ QString OffSpecularInstrumentItem::defaultName() const { return "OffSpecular"; } - -namespace { -void addAxisGroupProperty(SessionItem* parent, const QString& tag) -{ - auto axisItem = parent->addProperty<BasicAxisItem>(tag); - axisItem->setToolTip("Incoming alpha range [deg]"); - axisItem->getItem(BasicAxisItem::P_TITLE)->setVisible(false); - axisItem->getItem(BasicAxisItem::P_NBINS)->setToolTip("Number of points in scan"); - axisItem->getItem(BasicAxisItem::P_MIN_DEG)->setToolTip("Starting value [deg]"); - axisItem->getItem(BasicAxisItem::P_MAX_DEG)->setToolTip("Ending value [deg]"); - - axisItem->setTitle("alpha_i"); - axisItem->setLowerBound(0.0); - axisItem->setUpperBound(10.0); -} -} // namespace diff --git a/GUI/coregui/Models/InstrumentItems.h b/GUI/coregui/Models/InstrumentItems.h index ca4f17774d07065e4939dfd5f48f31e4a341ce72..f733e2c7fd2b66eb1c6c70d326903b8b85ecbb9e 100644 --- a/GUI/coregui/Models/InstrumentItems.h +++ b/GUI/coregui/Models/InstrumentItems.h @@ -26,6 +26,8 @@ class IUnitConverter; class MaskContainerItem; class RealDataItem; +//! Abstract base class for instrument-specific item classes. + class BA_CORE_API_ InstrumentItem : public SessionItem { private: static const QString P_IDENTIFIER; @@ -63,6 +65,7 @@ protected: void initBackgroundGroup(); }; + class BA_CORE_API_ SpecularInstrumentItem : public InstrumentItem { public: SpecularInstrumentItem(); @@ -79,6 +82,7 @@ public: std::unique_ptr<IUnitConverter> createUnitConverter() const; }; + class BA_CORE_API_ Instrument2DItem : public InstrumentItem { public: static const QString P_DETECTOR; @@ -99,6 +103,7 @@ protected: explicit Instrument2DItem(const QString& modelType); }; + class BA_CORE_API_ GISASInstrumentItem : public Instrument2DItem { public: GISASInstrumentItem(); @@ -107,6 +112,7 @@ public: virtual QString defaultName() const override; }; + class BA_CORE_API_ OffSpecularInstrumentItem : public Instrument2DItem { public: static const QString P_ALPHA_AXIS; diff --git a/GUI/coregui/Models/JobItemUtils.cpp b/GUI/coregui/Models/JobItemUtils.cpp index 032911b5ececd381f90b3fc8556799d2c3d14231..4f99a8075eeb589a70a799d5ff4ec83e0df638c7 100644 --- a/GUI/coregui/Models/JobItemUtils.cpp +++ b/GUI/coregui/Models/JobItemUtils.cpp @@ -14,7 +14,6 @@ #include "GUI/coregui/Models/JobItemUtils.h" #include "Core/Simulation/ISimulation.h" -#include "Core/Simulation/UnitConverterUtils.h" #include "GUI/coregui/Models/DataItem.h" #include "GUI/coregui/Models/DomainObjectBuilder.h" #include "GUI/coregui/Models/InstrumentItems.h" @@ -25,6 +24,7 @@ #include <QFileInfo> namespace { + const std::map<QString, Axes::Units> units_from_names{{"nbins", Axes::Units::NBINS}, {"Radians", Axes::Units::RADIANS}, {"Degrees", Axes::Units::DEGREES}, @@ -38,9 +38,16 @@ const std::map<Axes::Units, QString> names_from_units{{Axes::Units::NBINS, "nbin {Axes::Units::DEGREES, "Degrees"}}; //! Updates axes' titles -void updateAxesTitle(DataItem* intensityItem, const IUnitConverter& converter, Axes::Units units); +void updateAxesTitle(DataItem* intensityItem, const IUnitConverter& converter, Axes::Units units) +{ + intensityItem->setXaxisTitle(QString::fromStdString(converter.axisName(0, units))); + if (converter.dimension() > 1) + intensityItem->setYaxisTitle(QString::fromStdString(converter.axisName(1, units))); +} + } // namespace + //! Updates axes of OutputData in IntensityData item to correspond with ::P_AXES_UNITS selection. //! InstrumentItem is used to get domain's detector map for given units. @@ -61,7 +68,7 @@ void JobItemUtils::updateDataAxes(DataItem* intensityItem, const InstrumentItem* Axes::Units requested_units = axesUnitsFromName(intensityItem->selectedAxesUnits()); const auto converter = DomainObjectBuilder::createUnitConverter(instrumentItem); - auto newData = UnitConverterUtils::createOutputData(*converter.get(), requested_units); + auto newData = converter->createOutputData(requested_units); newData->setRawDataVector(intensityItem->getOutputData()->getRawDataVector()); intensityItem->setOutputData(newData.release()); @@ -108,7 +115,7 @@ void JobItemUtils::createDefaultDetectorMap(DataItem* intensityItem, const InstrumentItem* instrumentItem) { const auto converter = DomainObjectBuilder::createUnitConverter(instrumentItem); - auto output_data = UnitConverterUtils::createOutputData(*converter, converter->defaultUnits()); + auto output_data = converter->createOutputData(converter->defaultUnits()); intensityItem->setOutputData(output_data.release()); setIntensityItemAxesUnits(intensityItem, *converter); updateAxesTitle(intensityItem, *converter, converter->defaultUnits()); @@ -139,12 +146,3 @@ ComboProperty JobItemUtils::availableUnits(const IUnitConverter& converter) result.setValue(nameFromAxesUnits(converter.defaultUnits())); return result; } - -namespace { -void updateAxesTitle(DataItem* intensityItem, const IUnitConverter& converter, Axes::Units units) -{ - intensityItem->setXaxisTitle(QString::fromStdString(converter.axisName(0, units))); - if (converter.dimension() > 1) - intensityItem->setYaxisTitle(QString::fromStdString(converter.axisName(1, units))); -} -} // namespace diff --git a/GUI/coregui/Models/PointwiseAxisItem.cpp b/GUI/coregui/Models/PointwiseAxisItem.cpp index 5f040fbc8e181c905750d2eb1275ef835fb01d9f..303225e2bd7bf33d98ecf9a0d032682be3573f84 100644 --- a/GUI/coregui/Models/PointwiseAxisItem.cpp +++ b/GUI/coregui/Models/PointwiseAxisItem.cpp @@ -20,12 +20,21 @@ #include "GUI/coregui/Models/InstrumentItems.h" namespace { -std::unique_ptr<OutputData<double>> makeOutputData(const IAxis& axis); + +std::unique_ptr<OutputData<double>> makeOutputData(const IAxis& axis) +{ + std::unique_ptr<OutputData<double>> result(new OutputData<double>); + result->addAxis(axis); + return result; } +} // namespace + + const QString PointwiseAxisItem::P_NATIVE_AXIS_UNITS = "NativeAxisUnits"; const QString PointwiseAxisItem::P_FILE_NAME = "FileName"; + PointwiseAxisItem::PointwiseAxisItem() : BasicAxisItem("PointwiseAxis"), m_instrument(nullptr) { getItem(P_MIN_DEG)->setEnabled(false); @@ -144,12 +153,3 @@ void PointwiseAxisItem::updateIndicators() emitDataChanged(); } - -namespace { -std::unique_ptr<OutputData<double>> makeOutputData(const IAxis& axis) -{ - std::unique_ptr<OutputData<double>> result(new OutputData<double>); - result->addAxis(axis); - return result; -} -} // namespace diff --git a/GUI/coregui/Models/RealDataItem.cpp b/GUI/coregui/Models/RealDataItem.cpp index 67b9146d7ae54b59caa755080c83640ae6dfc06a..bf528c585528076d525fa611e6cfa875be038452 100644 --- a/GUI/coregui/Models/RealDataItem.cpp +++ b/GUI/coregui/Models/RealDataItem.cpp @@ -170,7 +170,7 @@ void RealDataItem::setNativeOutputData(OutputData<double>* data) nativeData()->setOutputData(data); // takes ownership of odata } -//! Creates data item if not existing so far. +//! Creates and inserts a data item except if such item with same tag already exists. //! Checks for rank compatibility if already existing. //! No further initialization (like clearing the data etc). @@ -181,7 +181,7 @@ void RealDataItem::initDataItem(size_t rank, const QString& tag) const SessionItem* data_item = getItem(tag); if (data_item != nullptr) { if ((rank == 1 && !data_item->is<SpecularDataItem>()) - || (rank == 2 && !data_item->is<IntensityDataItem>())) + || (rank == 2 && !data_item->is<IntensityDataItem>())) throw GUIHelpers::Error("Error in RealDataItem::initDataItem: trying to set data " "incompatible with underlying data item"); } else { diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp index 78e11f84b94a111a5d12b66627e4aae3c6564938..2f68a9a26ff9cab897291f70288056019a3c98b2 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp @@ -79,16 +79,12 @@ CsvCoordinateColumn::CsvCoordinateColumn(int colNum, double multiplier, csv::Dat : CsvIntensityColumn(colNum, multiplier, values), m_units(units) { } -// Getters: + Axes::Units CsvCoordinateColumn::units() const { return m_units; } -// Setters: -void CsvCoordinateColumn::setUnits(Axes::Units const units) -{ - m_units = units; -} + void CsvCoordinateColumn::setName(csv::ColumnType const name) { m_name = name; diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h index 3b5cd9ba3e055286db78df048445141aa4a3b6e0..4b610e9478733f0fe9ea9fd23635ddf668020be7 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h @@ -54,7 +54,6 @@ public: csv::ColumnType name() const { return m_name; } // Setters: - void setUnits(Axes::Units const units); void setName(csv::ColumnType const name); void resetColumn(int colNum = -1, double multiplier = 1., csv::DataColumn values = {}, Axes::Units units = Axes::Units::NBINS, diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index 4609c658e2bf960d4b8152a8a4825318119bd60c..2e521f4585d41db799920646e3d071110dd5111f 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -299,8 +299,8 @@ void RealDataSelectorWidget::importData2D() m_itemTreeModel->removeItem(realDataItem); const QString message = QString("Error while trying to read file\n\n'%1'\n\n%2") - .arg(fileName) - .arg(QString::fromStdString(std::string(ex.what()))); + .arg(fileName) + .arg(QString::fromStdString(std::string(ex.what()))); GUIHelpers::warning("File import", message); } } diff --git a/GUI/coregui/utils/ImportDataInfo.cpp b/GUI/coregui/utils/ImportDataInfo.cpp index d78fd812efab8ef66a3f56698d78bc49c88af04f..11e0f748dd529df76e739a6669dd368144814bcf 100644 --- a/GUI/coregui/utils/ImportDataInfo.cpp +++ b/GUI/coregui/utils/ImportDataInfo.cpp @@ -99,9 +99,7 @@ QString ImportDataInfo::axisLabel(size_t axis_index) const else if (rank == 1) { if (axis_index > 0) return "Signal [a.u.]"; - - auto label_map = AxisNames::specAxis; - return QString::fromStdString(label_map[m_units]); + return QString::fromStdString(AxisNames::specAxis.at(m_units)); } throw GUIHelpers::Error("Error in ImportDataInfo::axisLabel: unsupported data type"); } diff --git a/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp b/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp index 9256f39aa384ecc8d6700110498ec833aa9aa35b..738c318c1ea88bbaa6354b55cf075712f2950266 100644 --- a/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp +++ b/Tests/UnitTests/Core/Axes/UnitConverter1DTest.cpp @@ -34,7 +34,7 @@ UnitConverter1DTest::UnitConverter1DTest() void UnitConverter1DTest::checkConventionalConverter(const UnitConverter1D& test_object) { double expected_min = m_axis.binCenter(0); - EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::DEFAULT), Units::rad2deg(expected_min), + EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::UNDEFINED), Units::rad2deg(expected_min), Units::rad2deg(expected_min) * 1e-10); EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::NBINS), 0.0, 1e-10); EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::RADIANS), expected_min, @@ -47,7 +47,7 @@ void UnitConverter1DTest::checkConventionalConverter(const UnitConverter1D& test getQ(expected_min) * 1e-10); double expected_max = m_axis.binCenters().back(); - EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::DEFAULT), Units::rad2deg(expected_max), + EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::UNDEFINED), Units::rad2deg(expected_max), Units::rad2deg(expected_max) * 1e-10); EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::NBINS), static_cast<double>(m_axis.size()), 1e-10); @@ -61,11 +61,11 @@ void UnitConverter1DTest::checkConventionalConverter(const UnitConverter1D& test getQ(expected_max) * 1e-10); // DEFAULT - auto axis_default = test_object.createConvertedAxis(0, Axes::Units::DEFAULT); + auto axis_default = test_object.createConvertedAxis(0, Axes::Units::UNDEFINED); EXPECT_TRUE(dynamic_cast<PointwiseAxis*>(axis_default.get())); EXPECT_EQ(axis_default->size(), test_object.axisSize(0)); - EXPECT_EQ(axis_default->lowerBound(), test_object.calculateMin(0, Axes::Units::DEFAULT)); - EXPECT_EQ(axis_default->upperBound(), test_object.calculateMax(0, Axes::Units::DEFAULT)); + EXPECT_EQ(axis_default->lowerBound(), test_object.calculateMin(0, Axes::Units::UNDEFINED)); + EXPECT_EQ(axis_default->upperBound(), test_object.calculateMax(0, Axes::Units::UNDEFINED)); // QSPACE auto axis_qspace = test_object.createConvertedAxis(0, Axes::Units::QSPACE); @@ -115,24 +115,24 @@ void UnitConverter1DTest::checkConventionalConverter(const UnitConverter1D& test void UnitConverter1DTest::checkQSpecConverter(const UnitConverter1D& test_object) { double expected_min = m_q_axis.binCenter(0); - EXPECT_EQ(test_object.calculateMin(0, Axes::Units::DEFAULT), expected_min); + EXPECT_EQ(test_object.calculateMin(0, Axes::Units::UNDEFINED), expected_min); EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::NBINS), 0.0, 1e-10); EXPECT_EQ(test_object.calculateMin(0, Axes::Units::QSPACE), expected_min); EXPECT_EQ(test_object.calculateMin(0, Axes::Units::RQ4), expected_min); double expected_max = m_q_axis.binCenters().back(); - EXPECT_EQ(test_object.calculateMax(0, Axes::Units::DEFAULT), expected_max); + EXPECT_EQ(test_object.calculateMax(0, Axes::Units::UNDEFINED), expected_max); EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::NBINS), static_cast<double>(m_q_axis.size()), 1e-10); EXPECT_EQ(test_object.calculateMax(0, Axes::Units::QSPACE), expected_max); EXPECT_EQ(test_object.calculateMax(0, Axes::Units::RQ4), expected_max); // DEFAULT - auto axis_default = test_object.createConvertedAxis(0, Axes::Units::DEFAULT); + auto axis_default = test_object.createConvertedAxis(0, Axes::Units::UNDEFINED); EXPECT_TRUE(dynamic_cast<PointwiseAxis*>(axis_default.get())); EXPECT_EQ(axis_default->size(), test_object.axisSize(0)); - EXPECT_EQ(axis_default->lowerBound(), test_object.calculateMin(0, Axes::Units::DEFAULT)); - EXPECT_EQ(axis_default->upperBound(), test_object.calculateMax(0, Axes::Units::DEFAULT)); + EXPECT_EQ(axis_default->lowerBound(), test_object.calculateMin(0, Axes::Units::UNDEFINED)); + EXPECT_EQ(axis_default->upperBound(), test_object.calculateMax(0, Axes::Units::UNDEFINED)); // QSPACE auto axis_qspace = test_object.createConvertedAxis(0, Axes::Units::QSPACE); @@ -182,13 +182,13 @@ void UnitConverter1DTest::checkQSpecConverter(const UnitConverter1D& test_object TEST_F(UnitConverter1DTest, MainFunctionality) { - checkConventionalConverter(UnitConverterConvSpec(m_beam, m_axis)); - checkQSpecConverter(UnitConverterQSpec(m_qscan)); + checkConventionalConverter(AngularReflectometryConverter(m_beam, m_axis)); + checkQSpecConverter(WavenumberReflectometryConverter(m_qscan)); } TEST_F(UnitConverter1DTest, Exceptions) { - UnitConverterConvSpec converter(m_beam, m_axis); + AngularReflectometryConverter converter(m_beam, m_axis); EXPECT_THROW(converter.calculateMin(0, Axes::Units::MM), std::runtime_error); EXPECT_THROW(converter.calculateMin(1, Axes::Units::RADIANS), std::runtime_error); @@ -197,12 +197,12 @@ TEST_F(UnitConverter1DTest, Exceptions) EXPECT_THROW(converter.calculateMax(1, Axes::Units::RADIANS), std::runtime_error); EXPECT_THROW(converter.createConvertedAxis(0, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(converter.createConvertedAxis(1, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.createConvertedAxis(1, Axes::Units::UNDEFINED), std::runtime_error); FixedBinAxis axis("Angles", 100, 0.0, 2.0 * M_PI); - EXPECT_THROW(UnitConverterConvSpec converter2(m_beam, axis), std::runtime_error); + EXPECT_THROW(AngularReflectometryConverter converter2(m_beam, axis), std::runtime_error); - UnitConverterQSpec converter2(m_qscan); + WavenumberReflectometryConverter converter2(m_qscan); // wrong units EXPECT_THROW(converter2.calculateMin(0, Axes::Units::MM), std::runtime_error); EXPECT_THROW(converter2.calculateMin(0, Axes::Units::RADIANS), std::runtime_error); @@ -215,16 +215,16 @@ TEST_F(UnitConverter1DTest, Exceptions) // wrong axis index EXPECT_THROW(converter2.calculateMin(1, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(converter2.calculateMax(1, Axes::Units::RQ4), std::runtime_error); - EXPECT_THROW(converter2.createConvertedAxis(1, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter2.createConvertedAxis(1, Axes::Units::UNDEFINED), std::runtime_error); } TEST_F(UnitConverter1DTest, Clone) { - UnitConverterConvSpec converter(m_beam, m_axis); + AngularReflectometryConverter converter(m_beam, m_axis); std::unique_ptr<UnitConverter1D> converter_clone(converter.clone()); checkConventionalConverter(*converter_clone); - UnitConverterQSpec converterQ(m_qscan); + WavenumberReflectometryConverter converterQ(m_qscan); std::unique_ptr<UnitConverter1D> converterQ_clone(converterQ.clone()); checkQSpecConverter(*converterQ_clone); } @@ -233,9 +233,10 @@ TEST_F(UnitConverter1DTest, NonDefaultUnitsInInput) { PointwiseAxis axis("x", std::vector<double>{0.0, 0.5, 1.0}); - EXPECT_THROW(UnitConverterConvSpec(m_beam, axis, Axes::Units::NBINS), std::runtime_error); + EXPECT_THROW(AngularReflectometryConverter(m_beam, axis, Axes::Units::NBINS), + std::runtime_error); - UnitConverterConvSpec converter(m_beam, axis, Axes::Units::DEGREES); + AngularReflectometryConverter converter(m_beam, axis, Axes::Units::DEGREES); auto axis_deg_output = converter.createConvertedAxis(0, Axes::Units::DEGREES); EXPECT_TRUE(axis.size() == axis_deg_output->size()); EXPECT_DOUBLE_EQ(axis[0], (*axis_deg_output)[0]); @@ -245,12 +246,13 @@ TEST_F(UnitConverter1DTest, NonDefaultUnitsInInput) auto values = axis.binCenters(); std::for_each(values.begin(), values.end(), [this](double& value) { value = getQ(value); }); PointwiseAxis q_axis("q", values); - UnitConverterConvSpec converter2(m_beam, q_axis, Axes::Units::QSPACE); + AngularReflectometryConverter converter2(m_beam, q_axis, Axes::Units::QSPACE); auto axis_rad_output = converter2.createConvertedAxis(0, Axes::Units::RADIANS); EXPECT_TRUE(axis.size() == axis_rad_output->size()); EXPECT_DOUBLE_EQ(axis[0], (*axis_rad_output)[0]); EXPECT_DOUBLE_EQ(axis[1], (*axis_rad_output)[1]); EXPECT_DOUBLE_EQ(axis[2], (*axis_rad_output)[2]); - EXPECT_THROW(UnitConverterConvSpec(m_beam, q_axis, Axes::Units::RQ4), std::runtime_error); + EXPECT_THROW(AngularReflectometryConverter(m_beam, q_axis, Axes::Units::RQ4), + std::runtime_error); } diff --git a/Tests/UnitTests/Core/Core/DepthProbeConverterTest.cpp b/Tests/UnitTests/Core/Core/DepthProbeConverterTest.cpp index b7b0653beabe8c0772093443d285951126235721..f44e38eaf0d0d2e97e12a59d90bda77384bf73f7 100644 --- a/Tests/UnitTests/Core/Core/DepthProbeConverterTest.cpp +++ b/Tests/UnitTests/Core/Core/DepthProbeConverterTest.cpp @@ -2,7 +2,7 @@ #include "Base/Const/Units.h" #include "Base/Math/Constants.h" #include "Device/Beam/Beam.h" -#include "Device/Detector/SimpleUnitConverters.h" +#include "Device/Detector/UnitConverter2D.h" #include "Tests/GTestWrapper/google_test.h" class DepthProbeConverterTest : public ::testing::Test { @@ -33,7 +33,7 @@ void DepthProbeConverterTest::checkMainFunctionality(const DepthProbeConverter& { EXPECT_EQ(test_object.dimension(), 2u); - EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::DEFAULT), 2.8647889757e+1, + EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::UNDEFINED), 2.8647889757e+1, 2.8647889757e+1 * 1e-10); EXPECT_NEAR(test_object.calculateMin(0, Axes::Units::DEGREES), 2.8647889757e+1, 2.8647889757e+1 * 1e-10); @@ -42,7 +42,7 @@ void DepthProbeConverterTest::checkMainFunctionality(const DepthProbeConverter& EXPECT_EQ(test_object.calculateMin(0, Axes::Units::RADIANS), m_alpha_start); EXPECT_EQ(test_object.calculateMin(0, Axes::Units::NBINS), 0.0); - EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::DEFAULT), 5.7295779513e+1, + EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::UNDEFINED), 5.7295779513e+1, 5.7295779513e+1 * 1e-10); EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::DEGREES), 5.7295779513e+1, 5.7295779513e+1 * 1e-10); @@ -52,13 +52,13 @@ void DepthProbeConverterTest::checkMainFunctionality(const DepthProbeConverter& const double n_bins = static_cast<double>(m_nbins); EXPECT_NEAR(test_object.calculateMax(0, Axes::Units::NBINS), n_bins, n_bins * 1e-10); - checkAlphaAxis(Axes::Units::DEFAULT, test_object); + checkAlphaAxis(Axes::Units::UNDEFINED, test_object); checkAlphaAxis(Axes::Units::DEGREES, test_object); checkAlphaAxis(Axes::Units::RADIANS, test_object); checkAlphaAxis(Axes::Units::QSPACE, test_object); checkAlphaAxis(Axes::Units::NBINS, test_object); - checkZAxis(Axes::Units::DEFAULT, test_object); + checkZAxis(Axes::Units::UNDEFINED, test_object); checkZAxis(Axes::Units::DEGREES, test_object); checkZAxis(Axes::Units::RADIANS, test_object); checkZAxis(Axes::Units::QSPACE, test_object); @@ -104,11 +104,11 @@ TEST_F(DepthProbeConverterTest, DepthProbeConverterExceptions) EXPECT_THROW(converter.axisName(0, Axes::Units::MM), std::runtime_error); EXPECT_THROW(converter.axisName(1, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(converter.axisName(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.axisName(2, Axes::Units::UNDEFINED), std::runtime_error); EXPECT_THROW(converter.calculateMin(0, Axes::Units::MM), std::runtime_error); EXPECT_THROW(converter.calculateMin(1, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(converter.calculateMin(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.calculateMin(2, Axes::Units::UNDEFINED), std::runtime_error); EXPECT_THROW(converter.calculateMax(0, Axes::Units::MM), std::runtime_error); EXPECT_THROW(converter.calculateMax(1, Axes::Units::MM), std::runtime_error); @@ -116,7 +116,7 @@ TEST_F(DepthProbeConverterTest, DepthProbeConverterExceptions) EXPECT_THROW(converter.createConvertedAxis(0, Axes::Units::MM), std::runtime_error); EXPECT_THROW(converter.createConvertedAxis(1, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::UNDEFINED), std::runtime_error); } TEST_F(DepthProbeConverterTest, DepthProbeConverterClone) diff --git a/Tests/UnitTests/Core/Instrument/OffSpecularConverterTest.cpp b/Tests/UnitTests/Core/Instrument/OffSpecularConverterTest.cpp index 7cc188c596325dfddc81d5c4d034f57fddc6e133..58a5a9c98306fe10d520882ccd856fcb6c24b9e5 100644 --- a/Tests/UnitTests/Core/Instrument/OffSpecularConverterTest.cpp +++ b/Tests/UnitTests/Core/Instrument/OffSpecularConverterTest.cpp @@ -1,7 +1,7 @@ #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" -#include "Device/Detector/SimpleUnitConverters.h" #include "Device/Detector/SphericalDetector.h" +#include "Device/Detector/UnitConverter2D.h" #include "Tests/GTestWrapper/google_test.h" class OffSpecularConverterTest : public ::testing::Test { @@ -27,42 +27,42 @@ TEST_F(OffSpecularConverterTest, OffSpecularConverter) EXPECT_EQ(converter.dimension(), 2u); - EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::DEFAULT), 0.0); + EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::UNDEFINED), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::RADIANS), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::DEGREES), 0.0); EXPECT_THROW(converter.calculateMin(0, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(converter.calculateMin(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::DEFAULT), 7.0); + EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::UNDEFINED), 7.0); EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::NBINS), 51.0); EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::RADIANS), Units::deg2rad(7.0)); EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::DEGREES), 7.0); EXPECT_THROW(converter.calculateMax(0, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(converter.calculateMax(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::DEFAULT), -2.0); + EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::UNDEFINED), -2.0); EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::RADIANS), Units::deg2rad(-2.0)); EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::DEGREES), -2.0); EXPECT_THROW(converter.calculateMin(1, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(converter.calculateMin(1, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::DEFAULT), Units::rad2deg(1.5)); + EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::UNDEFINED), Units::rad2deg(1.5)); EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::NBINS), 70.0); EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::RADIANS), 1.5); EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::DEGREES), Units::rad2deg(1.5)); EXPECT_THROW(converter.calculateMax(1, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(converter.calculateMax(1, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(converter.calculateMin(2, Axes::Units::DEFAULT), std::runtime_error); - EXPECT_THROW(converter.calculateMax(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.calculateMin(2, Axes::Units::UNDEFINED), std::runtime_error); + EXPECT_THROW(converter.calculateMax(2, Axes::Units::UNDEFINED), std::runtime_error); - auto axis = converter.createConvertedAxis(0, Axes::Units::DEFAULT); + auto axis = converter.createConvertedAxis(0, Axes::Units::UNDEFINED); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis.get())); EXPECT_EQ(axis->size(), converter.axisSize(0)); - EXPECT_EQ(axis->lowerBound(), converter.calculateMin(0, Axes::Units::DEFAULT)); - EXPECT_EQ(axis->upperBound(), converter.calculateMax(0, Axes::Units::DEFAULT)); + EXPECT_EQ(axis->lowerBound(), converter.calculateMin(0, Axes::Units::UNDEFINED)); + EXPECT_EQ(axis->upperBound(), converter.calculateMax(0, Axes::Units::UNDEFINED)); auto axis2 = converter.createConvertedAxis(1, Axes::Units::RADIANS); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis2.get())); @@ -70,7 +70,7 @@ TEST_F(OffSpecularConverterTest, OffSpecularConverter) EXPECT_EQ(axis2->lowerBound(), converter.calculateMin(1, Axes::Units::RADIANS)); EXPECT_EQ(axis2->upperBound(), converter.calculateMax(1, Axes::Units::RADIANS)); - EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::UNDEFINED), std::runtime_error); EXPECT_THROW(converter.createConvertedAxis(1, Axes::Units::QSPACE), std::runtime_error); } @@ -81,34 +81,34 @@ TEST_F(OffSpecularConverterTest, OffSpecularConverterClone) EXPECT_EQ(P_clone->dimension(), 2u); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::DEFAULT), 0.0); + EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::UNDEFINED), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::RADIANS), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::DEGREES), 0.0); EXPECT_THROW(P_clone->calculateMin(0, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(P_clone->calculateMin(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::DEFAULT), 7.0); + EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::UNDEFINED), 7.0); EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::NBINS), 51.0); EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::RADIANS), Units::deg2rad(7.0)); EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::DEGREES), 7.0); EXPECT_THROW(P_clone->calculateMax(0, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(P_clone->calculateMax(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::DEFAULT), -2.0); + EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::UNDEFINED), -2.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::RADIANS), Units::deg2rad(-2.0)); EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::DEGREES), -2.0); EXPECT_THROW(P_clone->calculateMin(1, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(P_clone->calculateMin(1, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::DEFAULT), Units::rad2deg(1.5)); + EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::UNDEFINED), Units::rad2deg(1.5)); EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::NBINS), 70.0); EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::RADIANS), 1.5); EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::DEGREES), Units::rad2deg(1.5)); EXPECT_THROW(P_clone->calculateMax(1, Axes::Units::QSPACE), std::runtime_error); EXPECT_THROW(P_clone->calculateMax(1, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(P_clone->calculateMin(2, Axes::Units::DEFAULT), std::runtime_error); - EXPECT_THROW(P_clone->calculateMax(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(P_clone->calculateMin(2, Axes::Units::UNDEFINED), std::runtime_error); + EXPECT_THROW(P_clone->calculateMax(2, Axes::Units::UNDEFINED), std::runtime_error); } diff --git a/Tests/UnitTests/Core/Instrument/RectangularConverterTest.cpp b/Tests/UnitTests/Core/Instrument/RectangularConverterTest.cpp index 9e30d02554e4a7ff170848de320952dc57c5045d..4470377b4ac9e05c1d3146d3115584eec96ebf16 100644 --- a/Tests/UnitTests/Core/Instrument/RectangularConverterTest.cpp +++ b/Tests/UnitTests/Core/Instrument/RectangularConverterTest.cpp @@ -1,7 +1,7 @@ #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" #include "Device/Detector/RectangularDetector.h" -#include "Device/Detector/SimpleUnitConverters.h" +#include "Device/Detector/UnitConverter2D.h" #include "Tests/GTestWrapper/google_test.h" #include <cmath> @@ -44,7 +44,7 @@ TEST_F(RectangularConverterTest, RectangularConverter) EXPECT_EQ(converter.dimension(), 2u); - EXPECT_NEAR(converter.calculateMin(0, Axes::Units::DEFAULT), 0.0, 1e-12); + EXPECT_NEAR(converter.calculateMin(0, Axes::Units::UNDEFINED), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(0, Axes::Units::NBINS), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(0, Axes::Units::MM), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(0, Axes::Units::RADIANS), -m_phi, m_phi * 1e-10); @@ -52,7 +52,7 @@ TEST_F(RectangularConverterTest, RectangularConverter) Units::rad2deg(m_phi) * 1e-10); EXPECT_NEAR(converter.calculateMin(0, Axes::Units::QSPACE), -m_kfy, m_kfy * 1e-10); - EXPECT_NEAR(converter.calculateMax(0, Axes::Units::DEFAULT), det_width, det_width * 1e-10); + EXPECT_NEAR(converter.calculateMax(0, Axes::Units::UNDEFINED), det_width, det_width * 1e-10); EXPECT_NEAR(converter.calculateMax(0, Axes::Units::NBINS), static_cast<double>(det_nx), det_nx * 1e-10); EXPECT_NEAR(converter.calculateMax(0, Axes::Units::MM), det_width, det_width * 1e-10); @@ -61,14 +61,14 @@ TEST_F(RectangularConverterTest, RectangularConverter) Units::rad2deg(m_phi) * 1e-10); EXPECT_NEAR(converter.calculateMax(0, Axes::Units::QSPACE), m_kfy, m_kfy * 1e-10); - EXPECT_NEAR(converter.calculateMin(1, Axes::Units::DEFAULT), 0.0, 1e-12); + EXPECT_NEAR(converter.calculateMin(1, Axes::Units::UNDEFINED), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(1, Axes::Units::NBINS), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(1, Axes::Units::MM), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(1, Axes::Units::RADIANS), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(1, Axes::Units::DEGREES), 0.0, 1e-12); EXPECT_NEAR(converter.calculateMin(1, Axes::Units::QSPACE), -m_kiz, std::abs(m_kiz) * 1e-10); - EXPECT_NEAR(converter.calculateMax(1, Axes::Units::DEFAULT), det_height, det_height * 1e-10); + EXPECT_NEAR(converter.calculateMax(1, Axes::Units::UNDEFINED), det_height, det_height * 1e-10); EXPECT_NEAR(converter.calculateMax(1, Axes::Units::NBINS), static_cast<double>(det_ny), det_ny * 1e-10); EXPECT_NEAR(converter.calculateMax(1, Axes::Units::MM), det_height, det_height * 1e-10); @@ -78,14 +78,14 @@ TEST_F(RectangularConverterTest, RectangularConverter) EXPECT_NEAR(converter.calculateMax(1, Axes::Units::QSPACE), m_kfz - m_kiz, std::abs(m_kfz - m_kiz) * 1e-10); - EXPECT_THROW(converter.calculateMin(2, Axes::Units::DEFAULT), std::runtime_error); - EXPECT_THROW(converter.calculateMax(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.calculateMin(2, Axes::Units::UNDEFINED), std::runtime_error); + EXPECT_THROW(converter.calculateMax(2, Axes::Units::UNDEFINED), std::runtime_error); - auto axis = converter.createConvertedAxis(0, Axes::Units::DEFAULT); + auto axis = converter.createConvertedAxis(0, Axes::Units::UNDEFINED); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis.get())); EXPECT_EQ(axis->size(), converter.axisSize(0)); - EXPECT_EQ(axis->lowerBound(), converter.calculateMin(0, Axes::Units::DEFAULT)); - EXPECT_EQ(axis->upperBound(), converter.calculateMax(0, Axes::Units::DEFAULT)); + EXPECT_EQ(axis->lowerBound(), converter.calculateMin(0, Axes::Units::UNDEFINED)); + EXPECT_EQ(axis->upperBound(), converter.calculateMax(0, Axes::Units::UNDEFINED)); auto axis2 = converter.createConvertedAxis(1, Axes::Units::QSPACE); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis2.get())); @@ -93,7 +93,7 @@ TEST_F(RectangularConverterTest, RectangularConverter) EXPECT_EQ(axis2->lowerBound(), converter.calculateMin(1, Axes::Units::QSPACE)); EXPECT_EQ(axis2->upperBound(), converter.calculateMax(1, Axes::Units::QSPACE)); - EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::UNDEFINED), std::runtime_error); } TEST_F(RectangularConverterTest, RectangularConverterClone) @@ -103,7 +103,7 @@ TEST_F(RectangularConverterTest, RectangularConverterClone) EXPECT_EQ(P_clone->dimension(), 2u); - EXPECT_NEAR(P_clone->calculateMin(0, Axes::Units::DEFAULT), 0.0, 1e-12); + EXPECT_NEAR(P_clone->calculateMin(0, Axes::Units::UNDEFINED), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(0, Axes::Units::NBINS), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(0, Axes::Units::MM), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(0, Axes::Units::RADIANS), -m_phi, m_phi * 1e-10); @@ -111,7 +111,7 @@ TEST_F(RectangularConverterTest, RectangularConverterClone) Units::rad2deg(m_phi) * 1e-10); EXPECT_NEAR(P_clone->calculateMin(0, Axes::Units::QSPACE), -m_kfy, m_kfy * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(0, Axes::Units::DEFAULT), det_width, det_width * 1e-10); + EXPECT_NEAR(P_clone->calculateMax(0, Axes::Units::UNDEFINED), det_width, det_width * 1e-10); EXPECT_NEAR(P_clone->calculateMax(0, Axes::Units::NBINS), static_cast<double>(det_nx), det_nx * 1e-10); EXPECT_NEAR(P_clone->calculateMax(0, Axes::Units::MM), det_width, det_width * 1e-10); @@ -120,14 +120,14 @@ TEST_F(RectangularConverterTest, RectangularConverterClone) Units::rad2deg(m_phi) * 1e-10); EXPECT_NEAR(P_clone->calculateMax(0, Axes::Units::QSPACE), m_kfy, m_kfy * 1e-10); - EXPECT_NEAR(P_clone->calculateMin(1, Axes::Units::DEFAULT), 0.0, 1e-12); + EXPECT_NEAR(P_clone->calculateMin(1, Axes::Units::UNDEFINED), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(1, Axes::Units::NBINS), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(1, Axes::Units::MM), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(1, Axes::Units::RADIANS), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(1, Axes::Units::DEGREES), 0.0, 1e-12); EXPECT_NEAR(P_clone->calculateMin(1, Axes::Units::QSPACE), -m_kiz, std::abs(m_kiz) * 1e-10); - EXPECT_NEAR(P_clone->calculateMax(1, Axes::Units::DEFAULT), det_height, det_height * 1e-10); + EXPECT_NEAR(P_clone->calculateMax(1, Axes::Units::UNDEFINED), det_height, det_height * 1e-10); EXPECT_NEAR(P_clone->calculateMax(1, Axes::Units::NBINS), static_cast<double>(det_ny), det_ny * 1e-10); EXPECT_NEAR(P_clone->calculateMax(1, Axes::Units::MM), det_height, det_height * 1e-10); @@ -137,8 +137,8 @@ TEST_F(RectangularConverterTest, RectangularConverterClone) EXPECT_NEAR(P_clone->calculateMax(1, Axes::Units::QSPACE), m_kfz - m_kiz, std::abs(m_kfz - m_kiz) * 1e-10); - EXPECT_THROW(P_clone->calculateMin(2, Axes::Units::DEFAULT), std::runtime_error); - EXPECT_THROW(P_clone->calculateMax(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(P_clone->calculateMin(2, Axes::Units::UNDEFINED), std::runtime_error); + EXPECT_THROW(P_clone->calculateMax(2, Axes::Units::UNDEFINED), std::runtime_error); } TEST_F(RectangularConverterTest, RectangularConverterWithROI) @@ -151,10 +151,10 @@ TEST_F(RectangularConverterTest, RectangularConverterWithROI) m_detector.setRegionOfInterest(roi_xmin, roi_ymin, roi_xmax, roi_ymax); RectangularConverter converter(m_detector, m_beam); - EXPECT_EQ(converter.calculateMin(0, Axes::Units::DEFAULT), 100); - EXPECT_EQ(converter.calculateMax(0, Axes::Units::DEFAULT), 152); - EXPECT_EQ(converter.calculateMin(1, Axes::Units::DEFAULT), 50); - EXPECT_EQ(converter.calculateMax(1, Axes::Units::DEFAULT), 102); + EXPECT_EQ(converter.calculateMin(0, Axes::Units::UNDEFINED), 100); + EXPECT_EQ(converter.calculateMax(0, Axes::Units::UNDEFINED), 152); + EXPECT_EQ(converter.calculateMin(1, Axes::Units::UNDEFINED), 50); + EXPECT_EQ(converter.calculateMax(1, Axes::Units::UNDEFINED), 102); EXPECT_NEAR(converter.calculateMin(0, Axes::Units::DEGREES), 0.0, 1e-10); EXPECT_NEAR(converter.calculateMax(0, Axes::Units::DEGREES), 2.97669946811, 1e-10); diff --git a/Tests/UnitTests/Core/Instrument/SphericalConverterTest.cpp b/Tests/UnitTests/Core/Instrument/SphericalConverterTest.cpp index a849606e3172b0e6e8ecdb53575c250f7e1867c5..3882829aee18a960f07170f3e0f80f4278d14bdb 100644 --- a/Tests/UnitTests/Core/Instrument/SphericalConverterTest.cpp +++ b/Tests/UnitTests/Core/Instrument/SphericalConverterTest.cpp @@ -1,7 +1,7 @@ #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" -#include "Device/Detector/SimpleUnitConverters.h" #include "Device/Detector/SphericalDetector.h" +#include "Device/Detector/UnitConverter2D.h" #include "Tests/GTestWrapper/google_test.h" class SphericalConverterTest : public ::testing::Test { @@ -32,42 +32,42 @@ TEST_F(SphericalConverterTest, SphericalConverter) EXPECT_EQ(converter.dimension(), 2u); - EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::DEFAULT), 0.0); + EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::UNDEFINED), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::RADIANS), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::DEGREES), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(0, Axes::Units::QSPACE), 0.0); EXPECT_THROW(converter.calculateMin(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::DEFAULT), 5.0); + EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::UNDEFINED), 5.0); EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::NBINS), 100.0); EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::RADIANS), Units::deg2rad(5.0)); EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::DEGREES), 5.0); EXPECT_DOUBLE_EQ(converter.calculateMax(0, Axes::Units::QSPACE), m_kfy); EXPECT_THROW(converter.calculateMax(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::DEFAULT), -2.0); + EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::UNDEFINED), -2.0); EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::RADIANS), Units::deg2rad(-2.0)); EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::DEGREES), -2.0); EXPECT_DOUBLE_EQ(converter.calculateMin(1, Axes::Units::QSPACE), m_kfz1 - m_kiz); EXPECT_THROW(converter.calculateMin(1, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::DEFAULT), Units::rad2deg(1.5)); + EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::UNDEFINED), Units::rad2deg(1.5)); EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::NBINS), 70.0); EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::RADIANS), 1.5); EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::DEGREES), Units::rad2deg(1.5)); EXPECT_DOUBLE_EQ(converter.calculateMax(1, Axes::Units::QSPACE), m_kfz2 - m_kiz); EXPECT_THROW(converter.calculateMax(1, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(converter.calculateMin(2, Axes::Units::DEFAULT), std::runtime_error); - EXPECT_THROW(converter.calculateMax(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.calculateMin(2, Axes::Units::UNDEFINED), std::runtime_error); + EXPECT_THROW(converter.calculateMax(2, Axes::Units::UNDEFINED), std::runtime_error); - auto axis = converter.createConvertedAxis(0, Axes::Units::DEFAULT); + auto axis = converter.createConvertedAxis(0, Axes::Units::UNDEFINED); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis.get())); EXPECT_EQ(axis->size(), converter.axisSize(0)); - EXPECT_EQ(axis->lowerBound(), converter.calculateMin(0, Axes::Units::DEFAULT)); - EXPECT_EQ(axis->upperBound(), converter.calculateMax(0, Axes::Units::DEFAULT)); + EXPECT_EQ(axis->lowerBound(), converter.calculateMin(0, Axes::Units::UNDEFINED)); + EXPECT_EQ(axis->upperBound(), converter.calculateMax(0, Axes::Units::UNDEFINED)); auto axis2 = converter.createConvertedAxis(1, Axes::Units::QSPACE); EXPECT_TRUE(dynamic_cast<FixedBinAxis*>(axis2.get())); @@ -75,7 +75,7 @@ TEST_F(SphericalConverterTest, SphericalConverter) EXPECT_EQ(axis2->lowerBound(), converter.calculateMin(1, Axes::Units::QSPACE)); EXPECT_EQ(axis2->upperBound(), converter.calculateMax(1, Axes::Units::QSPACE)); - EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(converter.createConvertedAxis(2, Axes::Units::UNDEFINED), std::runtime_error); } TEST_F(SphericalConverterTest, SphericalConverterClone) @@ -85,34 +85,34 @@ TEST_F(SphericalConverterTest, SphericalConverterClone) EXPECT_EQ(P_clone->dimension(), 2u); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::DEFAULT), 0.0); + EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::UNDEFINED), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::RADIANS), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::DEGREES), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(0, Axes::Units::QSPACE), 0.0); EXPECT_THROW(P_clone->calculateMin(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::DEFAULT), 5.0); + EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::UNDEFINED), 5.0); EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::NBINS), 100.0); EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::RADIANS), Units::deg2rad(5.0)); EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::DEGREES), 5.0); EXPECT_DOUBLE_EQ(P_clone->calculateMax(0, Axes::Units::QSPACE), m_kfy); EXPECT_THROW(P_clone->calculateMax(0, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::DEFAULT), -2.0); + EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::UNDEFINED), -2.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::NBINS), 0.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::RADIANS), Units::deg2rad(-2.0)); EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::DEGREES), -2.0); EXPECT_DOUBLE_EQ(P_clone->calculateMin(1, Axes::Units::QSPACE), m_kfz1 - m_kiz); EXPECT_THROW(P_clone->calculateMin(1, Axes::Units::MM), std::runtime_error); - EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::DEFAULT), Units::rad2deg(1.5)); + EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::UNDEFINED), Units::rad2deg(1.5)); EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::NBINS), 70.0); EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::RADIANS), 1.5); EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::DEGREES), Units::rad2deg(1.5)); EXPECT_DOUBLE_EQ(P_clone->calculateMax(1, Axes::Units::QSPACE), m_kfz2 - m_kiz); EXPECT_THROW(P_clone->calculateMax(1, Axes::Units::MM), std::runtime_error); - EXPECT_THROW(P_clone->calculateMin(2, Axes::Units::DEFAULT), std::runtime_error); - EXPECT_THROW(P_clone->calculateMax(2, Axes::Units::DEFAULT), std::runtime_error); + EXPECT_THROW(P_clone->calculateMin(2, Axes::Units::UNDEFINED), std::runtime_error); + EXPECT_THROW(P_clone->calculateMax(2, Axes::Units::UNDEFINED), std::runtime_error); } diff --git a/Wrap/Python/ba_fitmonitor.py b/Wrap/Python/ba_fitmonitor.py index 5c040ca61bbf0ef3bb00a9818b49efba0a78071d..33b14cd73031073c77b3b19ed9e68b9f5260f347 100644 --- a/Wrap/Python/ba_fitmonitor.py +++ b/Wrap/Python/ba_fitmonitor.py @@ -33,7 +33,7 @@ class Plotter: zmax=None, xlabel=None, ylabel=None, - units=ba.Axes.DEFAULT, + units=ba.Axes.UNDEFINED, aspect=None): self._fig = plt.figure(figsize=(10.25, 7.69)) @@ -65,7 +65,7 @@ class PlotterGISAS(Plotter): zmax=None, xlabel=None, ylabel=None, - units=ba.Axes.DEFAULT, + units=ba.Axes.UNDEFINED, aspect=None): Plotter.__init__(self, zmin, zmax, xlabel, ylabel, units, aspect) @@ -145,7 +145,7 @@ class PlotterSpecular(Plotter): """ Draws fit progress, for specular simulation. """ - def __init__(self, units=ba.Axes.DEFAULT): + def __init__(self, units=ba.Axes.UNDEFINED): Plotter.__init__(self) self.gs = gridspec.GridSpec(1, 2, width_ratios=[2.5, 1], wspace=0) self.units = units diff --git a/Wrap/Python/ba_plot.py b/Wrap/Python/ba_plot.py index 243266f098aeb261ece53b89d41a8d09e02d1634..eec9274c1ca013f3161f8869bc6f764e7a8d14eb 100644 --- a/Wrap/Python/ba_plot.py +++ b/Wrap/Python/ba_plot.py @@ -167,7 +167,7 @@ def plot_colormap(result, **kwargs): :param zmax: Max value on amplitude's color bar """ - units = kwargs.pop('units', ba.Axes.DEFAULT) + units = kwargs.pop('units', ba.Axes.UNDEFINED) axes_limits = get_axes_limits(result, units) axes_labels = get_axes_labels(result, units) @@ -188,7 +188,7 @@ def plot_specular_simulation_result(result, **kwargs): :param units: units on the x-axis """ - units = kwargs.pop('units', ba.Axes.DEFAULT) + units = kwargs.pop('units', ba.Axes.UNDEFINED) intensity = result.array(units) x_axis = result.axis(units) diff --git a/Wrap/Swig/libBornAgainDevice.i b/Wrap/Swig/libBornAgainDevice.i index 3bfda58e6f03094c9bcd1a592efce48acee3e4c8..6e1beacd20bad1f20f75111ed35b7ea39bcd3129 100644 --- a/Wrap/Swig/libBornAgainDevice.i +++ b/Wrap/Swig/libBornAgainDevice.i @@ -69,7 +69,7 @@ %newobject ScanResolution::scanRelativeResolution; %newobject ScanResolution::scanAbsoluteResolution; -%newobject SimulationResult::histogram2d(Axes::Units units_type = Axes::Units::DEFAULT) const; +%newobject SimulationResult::histogram2d(Axes::Units units_type = Axes::Units::UNDEFINED) const; %newobject IntensityDataIOFactory::readOutputData(const std::string& file_name); %newobject IntensityDataIOFactory::readIntensityData(const std::string& file_name); diff --git a/auto/Wrap/doxygenCore.i b/auto/Wrap/doxygenCore.i index a2dd8151f191c28328b09f113f5f0f58fc89250a..ef3daa84044bb8f3b736b8543207f9a7142b88ff 100644 --- a/auto/Wrap/doxygenCore.i +++ b/auto/Wrap/doxygenCore.i @@ -1,6 +1,44 @@ // File: index.xml +// File: classAngularReflectometryConverter.xml +%feature("docstring") AngularReflectometryConverter " + +Conversion of axis units for the case of conventional (angle-based) reflectometry. + +C++ includes: UnitConverter1D.h +"; + +%feature("docstring") AngularReflectometryConverter::AngularReflectometryConverter "AngularReflectometryConverter::AngularReflectometryConverter(const Beam &beam, const IAxis &axis, Axes::Units axis_units=Axes::Units::RADIANS) + +Constructs the object for unit conversion. +"; + +%feature("docstring") AngularReflectometryConverter::AngularReflectometryConverter "AngularReflectometryConverter::AngularReflectometryConverter(const AngularSpecScan &handler) +"; + +%feature("docstring") AngularReflectometryConverter::~AngularReflectometryConverter "AngularReflectometryConverter::~AngularReflectometryConverter() override +"; + +%feature("docstring") AngularReflectometryConverter::clone "AngularReflectometryConverter * AngularReflectometryConverter::clone() const override +"; + +%feature("docstring") AngularReflectometryConverter::axisSize "size_t AngularReflectometryConverter::axisSize(size_t i_axis) const override + +Returns the size of underlying axis. +"; + +%feature("docstring") AngularReflectometryConverter::availableUnits "std::vector< Axes::Units > AngularReflectometryConverter::availableUnits() const override + +Returns the list of all available units. +"; + +%feature("docstring") AngularReflectometryConverter::defaultUnits "Axes::Units AngularReflectometryConverter::defaultUnits() const override + +Returns default units to convert to. +"; + + // File: classAngularSpecScan.xml %feature("docstring") AngularSpecScan " @@ -2149,7 +2187,7 @@ Returns kz values for Abeles computation of reflection/transition coefficients. // File: classUnitConverter1D.xml %feature("docstring") UnitConverter1D " -Conversion of axis units for the case of 1D simulation result. +Abstract base class to support coordinate transforms and axis labels for 1D scans. Inherited by AngularReflectometryConverter and WavenumberReflectometryConverter. C++ includes: UnitConverter1D.h "; @@ -2165,12 +2203,12 @@ C++ includes: UnitConverter1D.h Returns dimensionality of converted canvas. "; -%feature("docstring") UnitConverter1D::calculateMin "double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) const override +%feature("docstring") UnitConverter1D::calculateMin "double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units) const override Calculates minimum on-axis value in given units. "; -%feature("docstring") UnitConverter1D::calculateMax "double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) const override +%feature("docstring") UnitConverter1D::calculateMax "double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units) const override Calculates maximum on-axis value in given units. "; @@ -2186,113 +2224,72 @@ Creates OutputData array in converter units. "; -// File: classUnitConverterConvSpec.xml -%feature("docstring") UnitConverterConvSpec " +// File: classVarianceConstantFunction.xml +%feature("docstring") VarianceConstantFunction " -Conversion of axis units for the case of conventional (angle-based) reflectometry. +Returns 1.0 as variance value -C++ includes: UnitConverter1D.h +C++ includes: VarianceFunctions.h "; -%feature("docstring") UnitConverterConvSpec::UnitConverterConvSpec "UnitConverterConvSpec::UnitConverterConvSpec(const Beam &beam, const IAxis &axis, Axes::Units axis_units=Axes::Units::RADIANS) - -Constructs the object for unit conversion. +%feature("docstring") VarianceConstantFunction::clone "VarianceConstantFunction * VarianceConstantFunction::clone() const override "; -%feature("docstring") UnitConverterConvSpec::UnitConverterConvSpec "UnitConverterConvSpec::UnitConverterConvSpec(const AngularSpecScan &handler) +%feature("docstring") VarianceConstantFunction::variance "double VarianceConstantFunction::variance(double, double) const override "; -%feature("docstring") UnitConverterConvSpec::~UnitConverterConvSpec "UnitConverterConvSpec::~UnitConverterConvSpec() override -"; -%feature("docstring") UnitConverterConvSpec::clone "UnitConverterConvSpec * UnitConverterConvSpec::clone() const override -"; +// File: classVarianceSimFunction.xml +%feature("docstring") VarianceSimFunction " -%feature("docstring") UnitConverterConvSpec::axisSize "size_t UnitConverterConvSpec::axisSize(size_t i_axis) const override +Returns max(sim, epsilon) -Returns the size of underlying axis. +C++ includes: VarianceFunctions.h "; -%feature("docstring") UnitConverterConvSpec::availableUnits "std::vector< Axes::Units > UnitConverterConvSpec::availableUnits() const override - -Returns the list of all available units. +%feature("docstring") VarianceSimFunction::VarianceSimFunction "VarianceSimFunction::VarianceSimFunction(double epsilon=1.0) "; -%feature("docstring") UnitConverterConvSpec::defaultUnits "Axes::Units UnitConverterConvSpec::defaultUnits() const override +%feature("docstring") VarianceSimFunction::clone "VarianceSimFunction * VarianceSimFunction::clone() const override +"; -Returns default units to convert to. +%feature("docstring") VarianceSimFunction::variance "double VarianceSimFunction::variance(double exp, double sim) const override "; -// File: classUnitConverterQSpec.xml -%feature("docstring") UnitConverterQSpec " +// File: classWavenumberReflectometryConverter.xml +%feature("docstring") WavenumberReflectometryConverter " Conversion of axis units for the case of q-defined reflectometry. C++ includes: UnitConverter1D.h "; -%feature("docstring") UnitConverterQSpec::UnitConverterQSpec "UnitConverterQSpec::UnitConverterQSpec(const QSpecScan &handler) +%feature("docstring") WavenumberReflectometryConverter::WavenumberReflectometryConverter "WavenumberReflectometryConverter::WavenumberReflectometryConverter(const QSpecScan &handler) "; -%feature("docstring") UnitConverterQSpec::~UnitConverterQSpec "UnitConverterQSpec::~UnitConverterQSpec() override +%feature("docstring") WavenumberReflectometryConverter::~WavenumberReflectometryConverter "WavenumberReflectometryConverter::~WavenumberReflectometryConverter() override "; -%feature("docstring") UnitConverterQSpec::clone "UnitConverterQSpec * UnitConverterQSpec::clone() const override +%feature("docstring") WavenumberReflectometryConverter::clone "WavenumberReflectometryConverter * WavenumberReflectometryConverter::clone() const override "; -%feature("docstring") UnitConverterQSpec::axisSize "size_t UnitConverterQSpec::axisSize(size_t i_axis) const override +%feature("docstring") WavenumberReflectometryConverter::axisSize "size_t WavenumberReflectometryConverter::axisSize(size_t i_axis) const override Returns the size of underlying axis. "; -%feature("docstring") UnitConverterQSpec::availableUnits "std::vector< Axes::Units > UnitConverterQSpec::availableUnits() const override +%feature("docstring") WavenumberReflectometryConverter::availableUnits "std::vector< Axes::Units > WavenumberReflectometryConverter::availableUnits() const override Returns the list of all available units. "; -%feature("docstring") UnitConverterQSpec::defaultUnits "Axes::Units UnitConverterQSpec::defaultUnits() const override +%feature("docstring") WavenumberReflectometryConverter::defaultUnits "Axes::Units WavenumberReflectometryConverter::defaultUnits() const override Returns default units to convert to. "; -// File: classVarianceConstantFunction.xml -%feature("docstring") VarianceConstantFunction " - -Returns 1.0 as variance value - -C++ includes: VarianceFunctions.h -"; - -%feature("docstring") VarianceConstantFunction::clone "VarianceConstantFunction * VarianceConstantFunction::clone() const override -"; - -%feature("docstring") VarianceConstantFunction::variance "double VarianceConstantFunction::variance(double, double) const override -"; - - -// File: classVarianceSimFunction.xml -%feature("docstring") VarianceSimFunction " - -Returns max(sim, epsilon) - -C++ includes: VarianceFunctions.h -"; - -%feature("docstring") VarianceSimFunction::VarianceSimFunction "VarianceSimFunction::VarianceSimFunction(double epsilon=1.0) -"; - -%feature("docstring") VarianceSimFunction::clone "VarianceSimFunction * VarianceSimFunction::clone() const override -"; - -%feature("docstring") VarianceSimFunction::variance "double VarianceSimFunction::variance(double exp, double sim) const override -"; - - -// File: namespace_0d100.xml - - // File: namespace_0d15.xml @@ -2335,6 +2332,9 @@ C++ includes: VarianceFunctions.h // File: namespace_0d94.xml +// File: namespace_0d98.xml + + // File: namespaceExportToPython.xml %feature("docstring") ExportToPython::sampleCode "std::string ExportToPython::sampleCode(const MultiLayer &multilayer) "; @@ -2682,18 +2682,6 @@ GISAS simulation with an extra long wavelength. "; -// File: namespaceUnitConverterUtils.xml -%feature("docstring") UnitConverterUtils::createOutputData "std::unique_ptr< OutputData< double > > UnitConverterUtils::createOutputData(const IUnitConverter &converter, Axes::Units units) - -Returns zero-valued output data array in specified units. -"; - -%feature("docstring") UnitConverterUtils::createConverterForGISAS "std::unique_ptr< IUnitConverter > UnitConverterUtils::createConverterForGISAS(const Instrument &instrument) - -Helper factory function to use in GISASSimulation. Depending on the type of detector, returns either RectangularConverter or SphericalConverter. -"; - - // File: ComputationStatus_8h.xml @@ -2982,12 +2970,6 @@ Helper factory function to use in GISASSimulation. Depending on the type of det // File: StandardSimulations_8h.xml -// File: UnitConverterUtils_8cpp.xml - - -// File: UnitConverterUtils_8h.xml - - // File: DepthProbeComputationTerm_8cpp.xml diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i index e9458edc8a19e90d582de446ba34f70e8ce3b5c4..a896ca2be7e057f9709af1a80702ae18ba825d29 100644 --- a/auto/Wrap/doxygenDevice.i +++ b/auto/Wrap/doxygenDevice.i @@ -10,7 +10,7 @@ C++ includes: Axes.h "; -// File: structUnitConverterSimple_1_1AxisData.xml +// File: structUnitConverter2D_1_1AxisData.xml // File: structAxisInfo.xml @@ -224,7 +224,7 @@ C++ includes: CumulativeValue.h DepthProbeConverter class handles the unit translations for depth probe simulations Its default units are radians for x-axis and nm for y-axis -C++ includes: SimpleUnitConverters.h +C++ includes: UnitConverter2D.h "; %feature("docstring") DepthProbeConverter::DepthProbeConverter "DepthProbeConverter::DepthProbeConverter(const Beam &beam, const IAxis &alpha_axis, const IAxis &z_axis) @@ -881,7 +881,7 @@ Returns detection properties. Returns new intensity map with resolution applied, and cropped to ROI if applicable. "; -%feature("docstring") IDetector::defaultAxesUnits "virtual Axes::Units IDetector::defaultAxesUnits() const +%feature("docstring") IDetector::defaultAxesUnits "virtual Axes::Units IDetector::defaultAxesUnits() const =0 Return default axes units. "; @@ -1456,7 +1456,7 @@ Returns true if area defined by two bins is inside or on border of polygon (more Interface to provide axis translations to different units for simulation output. Child classes are currently declared in - Device/Detector/SimpleUnitConverters.h, +Device/Detector/SimpleUnitConverters.h, Core/Scan/UnitConverter1D.h. @@ -1469,19 +1469,24 @@ C++ includes: IUnitConverter.h %feature("docstring") IUnitConverter::clone "virtual IUnitConverter* IUnitConverter::clone() const =0 "; +%feature("docstring") IUnitConverter::createOutputData "std::unique_ptr< OutputData< double > > IUnitConverter::createOutputData(Axes::Units units) const + +Returns zero-valued output data array in specified units. +"; + %feature("docstring") IUnitConverter::dimension "virtual size_t IUnitConverter::dimension() const =0 "; -%feature("docstring") IUnitConverter::calculateMin "virtual double IUnitConverter::calculateMin(size_t i_axis, Axes::Units units_type) const =0 +%feature("docstring") IUnitConverter::calculateMin "virtual double IUnitConverter::calculateMin(size_t i_axis, Axes::Units units) const =0 "; -%feature("docstring") IUnitConverter::calculateMax "virtual double IUnitConverter::calculateMax(size_t i_axis, Axes::Units units_type) const =0 +%feature("docstring") IUnitConverter::calculateMax "virtual double IUnitConverter::calculateMax(size_t i_axis, Axes::Units units) const =0 "; %feature("docstring") IUnitConverter::axisSize "virtual size_t IUnitConverter::axisSize(size_t i_axis) const =0 "; -%feature("docstring") IUnitConverter::axisName "std::string IUnitConverter::axisName(size_t i_axis, const Axes::Units &units_type=Axes::Units::DEFAULT) const +%feature("docstring") IUnitConverter::axisName "std::string IUnitConverter::axisName(size_t i_axis, const Axes::Units units=Axes::Units::UNDEFINED) const "; %feature("docstring") IUnitConverter::availableUnits "virtual std::vector<Axes::Units> IUnitConverter::availableUnits() const =0 @@ -1577,7 +1582,7 @@ C++ includes: LLData.h IUnitConverter class that handles the unit translations for off-specular simulations with a spherical detector Its default units are radians for both axes -C++ includes: SimpleUnitConverters.h +C++ includes: UnitConverter2D.h "; %feature("docstring") OffSpecularConverter::OffSpecularConverter "OffSpecularConverter::OffSpecularConverter(const IDetector2D &detector, const Beam &beam, const IAxis &alpha_axis) @@ -2141,7 +2146,7 @@ Returns true if area defined by two bins is inside or on border of polygon (more IUnitConverter class that handles the unit translations for rectangular detectors Its default units are mm for both axes -C++ includes: SimpleUnitConverters.h +C++ includes: UnitConverter2D.h "; %feature("docstring") RectangularConverter::RectangularConverter "RectangularConverter::RectangularConverter(const RectangularDetector &detector, const Beam &beam) @@ -2258,7 +2263,7 @@ Inits detector with the beam settings. %feature("docstring") RectangularDetector::getDetectorArrangment "RectangularDetector::EDetectorArrangement RectangularDetector::getDetectorArrangment() const "; -%feature("docstring") RectangularDetector::defaultAxesUnits "Axes::Units RectangularDetector::defaultAxesUnits() const override +%feature("docstring") RectangularDetector::defaultAxesUnits "virtual Axes::Units RectangularDetector::defaultAxesUnits() const final return default axes units "; @@ -2475,13 +2480,13 @@ C++ includes: SimulationResult.h %feature("docstring") SimulationResult::SimulationResult "SimulationResult::SimulationResult(SimulationResult &&other) "; -%feature("docstring") SimulationResult::data "std::unique_ptr< OutputData< double > > SimulationResult::data(Axes::Units units=Axes::Units::DEFAULT) const +%feature("docstring") SimulationResult::data "std::unique_ptr< OutputData< double > > SimulationResult::data(Axes::Units units=Axes::Units::UNDEFINED) const "; -%feature("docstring") SimulationResult::histogram2d "Histogram2D * SimulationResult::histogram2d(Axes::Units units=Axes::Units::DEFAULT) const +%feature("docstring") SimulationResult::histogram2d "Histogram2D * SimulationResult::histogram2d(Axes::Units units=Axes::Units::UNDEFINED) const "; -%feature("docstring") SimulationResult::axisInfo "std::vector< AxisInfo > SimulationResult::axisInfo(Axes::Units units=Axes::Units::DEFAULT) const +%feature("docstring") SimulationResult::axisInfo "std::vector< AxisInfo > SimulationResult::axisInfo(Axes::Units units=Axes::Units::UNDEFINED) const Provide AxisInfo for each axis and the given units. "; @@ -2500,15 +2505,15 @@ Returns underlying unit converter. %feature("docstring") SimulationResult::empty "bool SimulationResult::empty() const "; -%feature("docstring") SimulationResult::array "PyObject * SimulationResult::array(Axes::Units units=Axes::Units::DEFAULT) const +%feature("docstring") SimulationResult::array "PyObject * SimulationResult::array(Axes::Units units=Axes::Units::UNDEFINED) const returns intensity data as Python numpy array "; -%feature("docstring") SimulationResult::axis "std::vector< double > SimulationResult::axis(Axes::Units units=Axes::Units::DEFAULT) const +%feature("docstring") SimulationResult::axis "std::vector< double > SimulationResult::axis(Axes::Units units=Axes::Units::UNDEFINED) const "; -%feature("docstring") SimulationResult::axis "std::vector< double > SimulationResult::axis(size_t i_axis, Axes::Units units=Axes::Units::DEFAULT) const +%feature("docstring") SimulationResult::axis "std::vector< double > SimulationResult::axis(size_t i_axis, Axes::Units units=Axes::Units::UNDEFINED) const Returns axis coordinates as a numpy array. With no parameters given returns coordinates of x-axis in default units. "; @@ -2572,7 +2577,7 @@ Resets region of interest making whole detector plane available for the simulati %feature("docstring") SpecularDetector1D::setAxis "void SpecularDetector1D::setAxis(const IAxis &axis) "; -%feature("docstring") SpecularDetector1D::defaultAxesUnits "Axes::Units SpecularDetector1D::defaultAxesUnits() const override +%feature("docstring") SpecularDetector1D::defaultAxesUnits "virtual Axes::Units SpecularDetector1D::defaultAxesUnits() const final Return default axes units. "; @@ -2583,7 +2588,7 @@ Return default axes units. IUnitConverter class that handles the unit translations for spherical detectors Its default units are radians for both axes -C++ includes: SimpleUnitConverters.h +C++ includes: UnitConverter2D.h "; %feature("docstring") SphericalConverter::SphericalConverter "SphericalConverter::SphericalConverter(const SphericalDetector &detector, const Beam &beam) @@ -2673,44 +2678,44 @@ central alpha angle %feature("docstring") SphericalDetector::~SphericalDetector "SphericalDetector::~SphericalDetector() override "; -%feature("docstring") SphericalDetector::defaultAxesUnits "Axes::Units SphericalDetector::defaultAxesUnits() const override +%feature("docstring") SphericalDetector::defaultAxesUnits "virtual Axes::Units SphericalDetector::defaultAxesUnits() const final return default axes units "; -// File: classUnitConverterSimple.xml -%feature("docstring") UnitConverterSimple " +// File: classUnitConverter2D.xml +%feature("docstring") UnitConverter2D " Interface for objects that provide axis translations to different units for IDetector objects -C++ includes: SimpleUnitConverters.h +C++ includes: UnitConverter2D.h "; -%feature("docstring") UnitConverterSimple::UnitConverterSimple "UnitConverterSimple::UnitConverterSimple(const Beam &beam) +%feature("docstring") UnitConverter2D::UnitConverter2D "UnitConverter2D::UnitConverter2D(const Beam &beam) "; -%feature("docstring") UnitConverterSimple::~UnitConverterSimple "UnitConverterSimple::~UnitConverterSimple() override=default +%feature("docstring") UnitConverter2D::~UnitConverter2D "UnitConverter2D::~UnitConverter2D() override=default "; -%feature("docstring") UnitConverterSimple::dimension "size_t UnitConverterSimple::dimension() const override +%feature("docstring") UnitConverter2D::dimension "size_t UnitConverter2D::dimension() const override "; -%feature("docstring") UnitConverterSimple::calculateMin "double UnitConverterSimple::calculateMin(size_t i_axis, Axes::Units units_type) const override +%feature("docstring") UnitConverter2D::calculateMin "double UnitConverter2D::calculateMin(size_t i_axis, Axes::Units units) const override "; -%feature("docstring") UnitConverterSimple::calculateMax "double UnitConverterSimple::calculateMax(size_t i_axis, Axes::Units units_type) const override +%feature("docstring") UnitConverter2D::calculateMax "double UnitConverter2D::calculateMax(size_t i_axis, Axes::Units units) const override "; -%feature("docstring") UnitConverterSimple::axisSize "size_t UnitConverterSimple::axisSize(size_t i_axis) const override +%feature("docstring") UnitConverter2D::axisSize "size_t UnitConverter2D::axisSize(size_t i_axis) const override "; -%feature("docstring") UnitConverterSimple::availableUnits "std::vector< Axes::Units > UnitConverterSimple::availableUnits() const override +%feature("docstring") UnitConverter2D::availableUnits "std::vector< Axes::Units > UnitConverter2D::availableUnits() const override Returns the list of all available units. "; -%feature("docstring") UnitConverterSimple::createConvertedAxis "std::unique_ptr< IAxis > UnitConverterSimple::createConvertedAxis(size_t i_axis, Axes::Units units) const override +%feature("docstring") UnitConverter2D::createConvertedAxis "std::unique_ptr< IAxis > UnitConverter2D::createConvertedAxis(size_t i_axis, Axes::Units units) const override "; @@ -2754,7 +2759,7 @@ Returns true if area defined by two bins is inside or on border of polygon (more // File: namespace_0d11.xml -// File: namespace_0d28.xml +// File: namespace_0d36.xml // File: namespace_0d51.xml @@ -3035,12 +3040,6 @@ make Swappable // File: RectangularDetector_8h.xml -// File: SimpleUnitConverters_8cpp.xml - - -// File: SimpleUnitConverters_8h.xml - - // File: SimulationArea_8cpp.xml @@ -3065,6 +3064,12 @@ make Swappable // File: SphericalDetector_8h.xml +// File: UnitConverter2D_8cpp.xml + + +// File: UnitConverter2D_8h.xml + + // File: Histogram1D_8cpp.xml diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index 8fc149e36b3e022b61ecc2449620f8d1ad5678e9..c1607ab3b50b285771747cdeccc3bc5d2bf519e8 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -3695,7 +3695,7 @@ class Axes(object): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr - DEFAULT = _libBornAgainDevice.Axes_DEFAULT + UNDEFINED = _libBornAgainDevice.Axes_UNDEFINED NBINS = _libBornAgainDevice.Axes_NBINS @@ -4037,7 +4037,7 @@ class IDetector(libBornAgainBase.ICloneable, libBornAgainParam.INode): def defaultAxesUnits(self): r""" defaultAxesUnits(IDetector self) -> Axes::Units - virtual Axes::Units IDetector::defaultAxesUnits() const + virtual Axes::Units IDetector::defaultAxesUnits() const =0 Return default axes units. @@ -4402,7 +4402,7 @@ class RectangularDetector(IDetector2D): def defaultAxesUnits(self): r""" defaultAxesUnits(RectangularDetector self) -> Axes::Units - Axes::Units RectangularDetector::defaultAxesUnits() const override + virtual Axes::Units RectangularDetector::defaultAxesUnits() const final return default axes units @@ -4464,7 +4464,7 @@ class SphericalDetector(IDetector2D): def defaultAxesUnits(self): r""" defaultAxesUnits(SphericalDetector self) -> Axes::Units - Axes::Units SphericalDetector::defaultAxesUnits() const override + virtual Axes::Units SphericalDetector::defaultAxesUnits() const final return default axes units @@ -5422,16 +5422,16 @@ class SimulationResult(object): def histogram2d(self, *args): r""" - histogram2d(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> Histogram2D - Histogram2D * SimulationResult::histogram2d(Axes::Units units=Axes::Units::DEFAULT) const + histogram2d(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> Histogram2D + Histogram2D * SimulationResult::histogram2d(Axes::Units units=Axes::Units::UNDEFINED) const """ return _libBornAgainDevice.SimulationResult_histogram2d(self, *args) def axisInfo(self, *args): r""" - axisInfo(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> std::vector< AxisInfo,std::allocator< AxisInfo > > - std::vector< AxisInfo > SimulationResult::axisInfo(Axes::Units units=Axes::Units::DEFAULT) const + axisInfo(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> std::vector< AxisInfo,std::allocator< AxisInfo > > + std::vector< AxisInfo > SimulationResult::axisInfo(Axes::Units units=Axes::Units::UNDEFINED) const Provide AxisInfo for each axis and the given units. @@ -5474,8 +5474,8 @@ class SimulationResult(object): def array(self, *args): r""" - array(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> PyObject - PyObject * SimulationResult::array(Axes::Units units=Axes::Units::DEFAULT) const + array(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> PyObject + PyObject * SimulationResult::array(Axes::Units units=Axes::Units::UNDEFINED) const returns intensity data as Python numpy array @@ -5484,9 +5484,9 @@ class SimulationResult(object): def axis(self, *args): r""" - axis(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> vdouble1d_t - axis(SimulationResult self, size_t i_axis, Axes::Units units=Axes::Units::DEFAULT) -> vdouble1d_t - std::vector< double > SimulationResult::axis(size_t i_axis, Axes::Units units=Axes::Units::DEFAULT) const + axis(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> vdouble1d_t + axis(SimulationResult self, size_t i_axis, Axes::Units units=Axes::Units::UNDEFINED) -> vdouble1d_t + std::vector< double > SimulationResult::axis(size_t i_axis, Axes::Units units=Axes::Units::UNDEFINED) const Returns axis coordinates as a numpy array. With no parameters given returns coordinates of x-axis in default units. diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index e73747c2a4b81d9a4ce654dc5d01f8c67d576593..c67d4847085d0f61403c00954b6f1a9660d89e36 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -45206,7 +45206,7 @@ static PyMethodDef SwigMethods[] = { ""}, { "IDetector_defaultAxesUnits", _wrap_IDetector_defaultAxesUnits, METH_O, "\n" "IDetector_defaultAxesUnits(IDetector self) -> Axes::Units\n" - "virtual Axes::Units IDetector::defaultAxesUnits() const\n" + "virtual Axes::Units IDetector::defaultAxesUnits() const =0\n" "\n" "Return default axes units. \n" "\n" @@ -45431,7 +45431,7 @@ static PyMethodDef SwigMethods[] = { ""}, { "RectangularDetector_defaultAxesUnits", _wrap_RectangularDetector_defaultAxesUnits, METH_O, "\n" "RectangularDetector_defaultAxesUnits(RectangularDetector self) -> Axes::Units\n" - "Axes::Units RectangularDetector::defaultAxesUnits() const override\n" + "virtual Axes::Units RectangularDetector::defaultAxesUnits() const final\n" "\n" "return default axes units \n" "\n" @@ -45468,7 +45468,7 @@ static PyMethodDef SwigMethods[] = { ""}, { "SphericalDetector_defaultAxesUnits", _wrap_SphericalDetector_defaultAxesUnits, METH_O, "\n" "SphericalDetector_defaultAxesUnits(SphericalDetector self) -> Axes::Units\n" - "Axes::Units SphericalDetector::defaultAxesUnits() const override\n" + "virtual Axes::Units SphericalDetector::defaultAxesUnits() const final\n" "\n" "return default axes units \n" "\n" @@ -46028,13 +46028,13 @@ static PyMethodDef SwigMethods[] = { "\n" ""}, { "SimulationResult_histogram2d", _wrap_SimulationResult_histogram2d, METH_VARARGS, "\n" - "SimulationResult_histogram2d(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> Histogram2D\n" - "Histogram2D * SimulationResult::histogram2d(Axes::Units units=Axes::Units::DEFAULT) const\n" + "SimulationResult_histogram2d(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> Histogram2D\n" + "Histogram2D * SimulationResult::histogram2d(Axes::Units units=Axes::Units::UNDEFINED) const\n" "\n" ""}, { "SimulationResult_axisInfo", _wrap_SimulationResult_axisInfo, METH_VARARGS, "\n" - "SimulationResult_axisInfo(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> std::vector< AxisInfo,std::allocator< AxisInfo > >\n" - "std::vector< AxisInfo > SimulationResult::axisInfo(Axes::Units units=Axes::Units::DEFAULT) const\n" + "SimulationResult_axisInfo(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> std::vector< AxisInfo,std::allocator< AxisInfo > >\n" + "std::vector< AxisInfo > SimulationResult::axisInfo(Axes::Units units=Axes::Units::UNDEFINED) const\n" "\n" "Provide AxisInfo for each axis and the given units. \n" "\n" @@ -46062,16 +46062,16 @@ static PyMethodDef SwigMethods[] = { "\n" ""}, { "SimulationResult_array", _wrap_SimulationResult_array, METH_VARARGS, "\n" - "SimulationResult_array(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> PyObject\n" - "PyObject * SimulationResult::array(Axes::Units units=Axes::Units::DEFAULT) const\n" + "SimulationResult_array(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> PyObject\n" + "PyObject * SimulationResult::array(Axes::Units units=Axes::Units::UNDEFINED) const\n" "\n" "returns intensity data as Python numpy array \n" "\n" ""}, { "SimulationResult_axis", _wrap_SimulationResult_axis, METH_VARARGS, "\n" - "SimulationResult_axis(SimulationResult self, Axes::Units units=Axes::Units::DEFAULT) -> vdouble1d_t\n" - "SimulationResult_axis(SimulationResult self, size_t i_axis, Axes::Units units=Axes::Units::DEFAULT) -> vdouble1d_t\n" - "std::vector< double > SimulationResult::axis(size_t i_axis, Axes::Units units=Axes::Units::DEFAULT) const\n" + "SimulationResult_axis(SimulationResult self, Axes::Units units=Axes::Units::UNDEFINED) -> vdouble1d_t\n" + "SimulationResult_axis(SimulationResult self, size_t i_axis, Axes::Units units=Axes::Units::UNDEFINED) -> vdouble1d_t\n" + "std::vector< double > SimulationResult::axis(size_t i_axis, Axes::Units units=Axes::Units::UNDEFINED) const\n" "\n" "Returns axis coordinates as a numpy array. With no parameters given returns coordinates of x-axis in default units. \n" "\n" @@ -47524,7 +47524,7 @@ SWIG_init(void) { // thread safe initialization swig::container_owner_attribute(); - SWIG_Python_SetConstant(d, "Axes_DEFAULT",SWIG_From_int(static_cast< int >(Axes::DEFAULT))); + SWIG_Python_SetConstant(d, "Axes_UNDEFINED",SWIG_From_int(static_cast< int >(Axes::UNDEFINED))); SWIG_Python_SetConstant(d, "Axes_NBINS",SWIG_From_int(static_cast< int >(Axes::NBINS))); SWIG_Python_SetConstant(d, "Axes_RADIANS",SWIG_From_int(static_cast< int >(Axes::RADIANS))); SWIG_Python_SetConstant(d, "Axes_DEGREES",SWIG_From_int(static_cast< int >(Axes::DEGREES)));