27 double getQ(
double wavelength,
double angle)
29 return 4.0 *
M_PI * std::sin(angle) / wavelength;
32 double getInvQ(
double wavelength,
double q)
34 double sin_angle = q * wavelength / (4.0 *
M_PI);
35 return std::asin(sin_angle);
38 double backTransform(
double value,
Coords coords,
double wavelength)
46 return getInvQ(wavelength, value);
48 throw std::runtime_error(
"CoordSystem1D/backTransform: invalid coord system");
52 std::string angularAxisName(
const Coords units)
56 ASSERT(it != name_map.cend());
63 std::vector<double> ret;
64 ret.reserve(axis.
size());
66 ret.emplace_back(backTransform(value, coords, wavelength));
105 return static_cast<double>(coordinate_axis->
size());
107 return translator(coordinate_axis->
binCenter(coordinate_axis->
size() - 1));
120 for (
size_t i = 0, size = coords.size(); i < size; ++i)
121 coords[i] = translator(coords[i]);
137 for (
size_t i = 0, size = result->
size(); i < size; ++i)
138 (*result)[i] = data[i] * std::pow((*q_axis)[i], 4);
150 :
CoordSystem1D(createAxisFrom(axis, axis_units, angularAxisName(axis_units), wavelength))
151 , m_wavelength(wavelength)
154 throw std::runtime_error(
"Error in CoordSystem1D: input axis range is out of bounds");
160 , m_wavelength(other.m_wavelength)
185 return [](
double value) {
return value; };
189 return [wl =
m_wavelength](
double value) {
return getQ(wl, value); };
191 return [wl =
m_wavelength](
double value) {
return getQ(wl, value); };
227 std::vector<std::map<Coords, std::string>>
238 return [](
double value) {
return value; };
240 return [](
double value) {
return value; };
Defines the macro ASSERT.
#define ASSERT(condition)
Defines axisUnitLabel and maps in namespace AxisNames.
Defines M_PI and some more mathematical constants.
Defines CoordSystem1D class and derived classes.
Defines and implements templated class Datafield.
Defines class FixedBinAxis.
Defines class PointwiseAxis.
Defines some unit conversion factors and other constants in namespace Units.
Conversion of axis units for the case of conventional (angle-based) reflectometry.
AngularReflectometryCoordinates * clone() const override
std::vector< Coords > availableUnits() const override
Returns the list of all available units.
AngularReflectometryCoordinates(double wavelength, const IAxis &axis, Coords axis_units=Coords::RADIANS)
Constructs the object for unit conversion.
double m_wavelength
basic wavelength in nm (for translation to q-space).
std::function< double(double)> getTraslatorTo(Coords units) const override
Returns translating functional (rads --> desired units)
~AngularReflectometryCoordinates() override
std::vector< std::map< Coords, std::string > > createNameMaps() const override
Creates name map for axis in various units.
Abstract base class to support coordinate transforms and axis labels for 1D scans....
const IAxis * coordinateAxis() const
double calculateMax(size_t i_axis, Coords units) const override
Calculates maximum on-axis value in given units.
virtual std::function< double(double)> getTraslatorTo(Coords units) const =0
Returns translating functional (rads --> output units)
std::unique_ptr< const IAxis > m_axis
semantics depends on subclass
double calculateMin(size_t i_axis, Coords units) const override
Calculates minimum on-axis value in given units.
CoordSystem1D(const IAxis *&&axis)
Takes ownership of axis.
IAxis * createConvertedAxis(size_t i_axis, Coords units) const override
Creates axis in converted units.
size_t axisSize(size_t i_axis) const override
Returns the size of underlying axis.
Datafield * createConvertedData(const Datafield &data, Coords units) const override
Creates Datafield array in converter units.
Stores radiation power per bin.
void setVector(const std::vector< double > &data_vector)
Sets new values to raw data vector.
std::vector< double > flatVector() const
Returns copy of raw data vector.
size_t size() const
Returns total size of data buffer (product of bin number in every dimension).
Axis with fixed bin size.
Abstract base class for one-dimensional axes.
virtual std::vector< double > binCenters() const
virtual size_t size() const =0
Returns the number of bins.
virtual double binCenter(size_t index) const =0
Coords substituteDefaultUnits(Coords units) const
std::string axisName(size_t i_axis, Coords units=Coords::UNDEFINED) const
Axis containing arbitrary (non-equidistant) coordinate values. Lower boundary of the first bin and up...
Conversion of axis units for the case of q-defined reflectometry.
std::vector< Coords > availableUnits() const override
Returns the list of all available units.
WavenumberReflectometryCoordinates * clone() const override
~WavenumberReflectometryCoordinates() override
std::vector< std::map< Coords, std::string > > createNameMaps() const override
Creates name map for axis in various units.
WavenumberReflectometryCoordinates(const IAxis *&&axis)
std::function< double(double)> getTraslatorTo(Coords units) const override
Returns translating functional (inv. nm --> desired units)
BA_DEVICE_API_ const std::map< Coords, std::string > specAxisQ
BA_DEVICE_API_ const std::map< Coords, std::string > specAxis
double deg2rad(double angle)
double rad2deg(double angle)