FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
antenna::H5Antenna Class Referencefinal

Represents an antenna whose gain pattern is loaded from a HDF5 file. More...

#include "antenna_factory.h"

+ Inheritance diagram for antenna::H5Antenna:
+ Collaboration diagram for antenna::H5Antenna:

Public Member Functions

 H5Antenna (const std::string_view name, const std::string &filename, const SimId id=0)
 Constructs a H5Antenna with the specified name and gain pattern file.
 
 ~H5Antenna () override=default
 
 H5Antenna (const H5Antenna &)=delete
 
H5Antennaoperator= (const H5Antenna &)=delete
 
 H5Antenna (H5Antenna &&)=delete
 
H5Antennaoperator= (H5Antenna &&)=delete
 
RealType getGain (const math::SVec3 &angle, const math::SVec3 &refangle, RealType) const override
 Computes the gain of the antenna based on the input angle and reference angle.
 
const std::string & getFilename () const noexcept
 Gets the filename of the antenna description.
 
const std::vector< std::vector< RealType > > & getPattern () const noexcept
 Gets the gain pattern object.
 
RealType getEfficiencyFactor () const noexcept
 Retrieves the efficiency factor of the antenna.
 
std::string getName () const noexcept
 Retrieves the name of the antenna.
 
SimId getId () const noexcept
 Retrieves the unique ID of the antenna.
 
virtual RealType getNoiseTemperature (const math::SVec3 &) const noexcept
 Computes the noise temperature of the antenna based on the angle.
 
void setEfficiencyFactor (RealType loss) noexcept
 Sets the efficiency factor of the antenna.
 
void setName (std::string name) noexcept
 Sets the name of the antenna.
 

Static Protected Member Functions

static RealType getAngle (const math::SVec3 &angle, const math::SVec3 &refangle) noexcept
 Computes the angle between the input and reference angles.
 

Detailed Description

Represents an antenna whose gain pattern is loaded from a HDF5 file.

This class models an antenna with a gain pattern defined in an HDF5 file. The gain pattern is stored in a Pattern object, which is used to compute the antenna's gain based on the input angle and reference angle.

Definition at line 524 of file antenna_factory.h.

Constructor & Destructor Documentation

◆ H5Antenna() [1/3]

antenna::H5Antenna::H5Antenna ( const std::string_view  name,
const std::string &  filename,
const SimId  id = 0 
)

Constructs a H5Antenna with the specified name and gain pattern file.

Parameters
nameThe name of the antenna.
filenameThe path to the file containing the antenna's gain pattern.

Definition at line 533 of file antenna_factory.h.

533 :
534 Antenna(name.data(), id), _pattern(serial::readPattern(filename, "antenna")), _filename(filename)
535 {
536 }
Antenna(std::string name, const SimId id=0) noexcept
Constructs an Antenna object with the given name.
std::vector< std::vector< RealType > > readPattern(const std::string &name, const std::string &datasetName)
Reads a 2D antenna gain pattern from the named dataset.
math::Vec3 max

◆ ~H5Antenna()

antenna::H5Antenna::~H5Antenna ( )
overridedefault

◆ H5Antenna() [2/3]

antenna::H5Antenna::H5Antenna ( const H5Antenna )
delete

◆ H5Antenna() [3/3]

antenna::H5Antenna::H5Antenna ( H5Antenna &&  )
delete

Member Function Documentation

◆ getAngle()

RealType antenna::Antenna::getAngle ( const math::SVec3 angle,
const math::SVec3 refangle 
)
staticprotectednoexceptinherited

Computes the angle between the input and reference angles.

Parameters
angleThe input angle.
refangleThe reference angle.
Returns
The computed angle.

Definition at line 356 of file antenna_factory.cpp.

357 {
359 normangle.length = 1;
360 return std::acos(dotProduct(Vec3(normangle), Vec3(refangle)));
361 }
A class representing a vector in spherical coordinates.
A class representing a vector in rectangular coordinates.
RealType length() const noexcept
Calculates the length (magnitude) of the vector.
RealType dotProduct(const Vec3 &a, const Vec3 &b) noexcept
Computes the dot product of two Vec3 vectors.

References math::SVec3::length.

◆ getEfficiencyFactor()

RealType antenna::Antenna::getEfficiencyFactor ( ) const
noexceptinherited

Retrieves the efficiency factor of the antenna.

Returns
The efficiency factor of the antenna.

Definition at line 80 of file antenna_factory.h.

80{ return _loss_factor; }

Referenced by antenna::Isotropic::getGain(), antenna::XmlAntenna::getGain(), and getGain().

+ Here is the caller graph for this function:

◆ getFilename()

const std::string & antenna::H5Antenna::getFilename ( ) const
noexcept

Gets the filename of the antenna description.

Definition at line 559 of file antenna_factory.h.

559{ return _filename; }

◆ getGain()

RealType antenna::H5Antenna::getGain ( const math::SVec3 angle,
const math::SVec3 refangle,
RealType   
) const
overridevirtual

Computes the gain of the antenna based on the input angle and reference angle.

Parameters
angleThe angle at which the gain is to be computed.
refangleThe reference angle.
Returns
The gain of the antenna at the specified angle.

Implements antenna::Antenna.

Definition at line 447 of file antenna_factory.cpp.

448 {
449 constexpr RealType two_pi = 2.0 * PI;
450
452
453 const double ex1 = (pattern_angle.azimuth + PI) / two_pi;
454 const double ey1 = (pattern_angle.elevation + PI) / two_pi;
455
456 const auto calc_grid_point = [](const double value, const std::size_t size)
457 {
458 const double grid_size = static_cast<double>(size - 1);
459 const double x1 = std::floor(value * grid_size) / grid_size;
460 const double x2 = std::min(x1 + 1.0 / static_cast<double>(size), 1.0);
461 return std::pair{x1, x2};
462 };
463
464 const std::size_t size_azi = _pattern.size();
465 const std::size_t size_elev = _pattern[0].size();
466
467 LOG(logging::Level::TRACE, "Size of pattern: {} x {}", size_azi, size_elev);
468
469 const auto [x1, x2] = calc_grid_point(ex1, size_azi);
470 const auto [y1, y2] = calc_grid_point(ey1, size_elev);
471
472 const double t = (ex1 - x1) / (x2 - x1);
473 const double u = (ey1 - y1) / (y2 - y1);
474
475 const auto calc_array_index = [](const double value, const std::size_t size)
476 { return std::min(static_cast<std::size_t>(std::floor(value * static_cast<double>(size))), size - 1); };
477
478 const std::size_t arr_x = calc_array_index(x1, size_azi);
479 const std::size_t arr_y = calc_array_index(y1, size_elev);
480
481 const RealType interp = (1.0 - t) * (1.0 - u) * _pattern[arr_x][arr_y] +
482 t * (1.0 - u) * _pattern[(arr_x + 1) % size_azi][arr_y] +
483 t * u * _pattern[(arr_x + 1) % size_azi][(arr_y + 1) % size_elev] +
484 (1.0 - t) * u * _pattern[arr_x][(arr_y + 1) % size_elev];
485
486 return interp * getEfficiencyFactor();
487 }
RealType getEfficiencyFactor() const noexcept
Retrieves the efficiency factor of the antenna.
double RealType
Type for real numbers.
Definition config.h:27
constexpr RealType PI
Mathematical constant π (pi).
Definition config.h:43
#define LOG(level,...)
Definition logging.h:19
@ TRACE
Trace level for detailed debugging information.

References math::SVec3::azimuth, math::SVec3::elevation, antenna::Antenna::getEfficiencyFactor(), LOG, PI, and logging::TRACE.

+ Here is the call graph for this function:

◆ getId()

SimId antenna::Antenna::getId ( ) const
noexceptinherited

Retrieves the unique ID of the antenna.

Returns
The antenna SimId.

Definition at line 94 of file antenna_factory.h.

94{ return _id; }

Referenced by radar::to_json().

+ Here is the caller graph for this function:

◆ getName()

std::string antenna::Antenna::getName ( ) const
noexceptinherited

Retrieves the name of the antenna.

Returns
The name of the antenna.

Definition at line 87 of file antenna_factory.h.

87{ return _name; }

◆ getNoiseTemperature()

virtual RealType antenna::Antenna::getNoiseTemperature ( const math::SVec3 ) const
virtualnoexceptinherited

Computes the noise temperature of the antenna based on the angle.

Parameters
angleThe angle at which the noise temperature is to be computed.
Returns
The noise temperature of the antenna.

Definition at line 103 of file antenna_factory.h.

103{ return 0; }

◆ getPattern()

const std::vector< std::vector< RealType > > & antenna::H5Antenna::getPattern ( ) const
noexcept

Gets the gain pattern object.

Definition at line 562 of file antenna_factory.h.

562{ return _pattern; }

◆ operator=() [1/2]

H5Antenna & antenna::H5Antenna::operator= ( const H5Antenna )
delete

◆ operator=() [2/2]

H5Antenna & antenna::H5Antenna::operator= ( H5Antenna &&  )
delete

◆ setEfficiencyFactor()

void antenna::Antenna::setEfficiencyFactor ( RealType  loss)
noexceptinherited

Sets the efficiency factor of the antenna.

Parameters
lossThe new efficiency factor.

Definition at line 347 of file antenna_factory.cpp.

348 {
349 if (loss > 1)
350 {
351 LOG(Level::INFO, "Using greater than unity antenna efficiency.");
352 }
353 _loss_factor = loss;
354 }

References LOG.

◆ setName()

void antenna::Antenna::setName ( std::string  name)
noexceptinherited

Sets the name of the antenna.

Parameters
nameThe new name of the antenna.

Definition at line 117 of file antenna_factory.h.

117{ _name = std::move(name); }

The documentation for this class was generated from the following files: