FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
simulation::CwPhaseNoiseLookup Struct Reference

Lookup table for CW phase noise across timing sources. More...

#include "channel_model.h"

Public Member Functions

RealType sample (const timing::Timing *timing, RealType time) const noexcept
 Samples phase noise for one timing source at the specified time.
 
RealType phaseDifference (const timing::Timing *rx_timing, RealType rx_time, const timing::Timing *tx_timing, RealType tx_time) const noexcept
 Computes receiver-minus-transmitter phase noise at two propagation times.
 

Static Public Member Functions

static CwPhaseNoiseLookup build (std::span< const std::shared_ptr< timing::Timing > > timings, RealType start_time, RealType end_time)
 Builds a phase-noise lookup for the requested timing sources and time range.
 

Public Attributes

RealType start_time {}
 Lookup start time in seconds.
 
RealType end_time {}
 Lookup end time in seconds.
 
RealType dt {}
 Lookup sample spacing in seconds.
 
std::unordered_map< SimId, CwPhaseNoiseBufferbuffers
 Per-timing-source phase-noise buffers.
 

Detailed Description

Lookup table for CW phase noise across timing sources.

Definition at line 75 of file channel_model.h.

Member Function Documentation

◆ build()

CwPhaseNoiseLookup simulation::CwPhaseNoiseLookup::build ( std::span< const std::shared_ptr< timing::Timing > >  timings,
RealType  start_time,
RealType  end_time 
)
static

Builds a phase-noise lookup for the requested timing sources and time range.

Definition at line 540 of file channel_model.cpp.

542 {
543 CwPhaseNoiseLookup lookup{};
544 lookup.start_time = start_time;
545 lookup.end_time = std::max(start_time, end_time);
546
547 const RealType sample_rate = params::rate() * params::oversampleRatio();
548 lookup.dt = sample_rate > 0.0 ? (1.0 / sample_rate) : 1.0;
549
550 const auto sample_count =
551 static_cast<std::size_t>(std::ceil((lookup.end_time - lookup.start_time) / lookup.dt) + 1.0);
552 constexpr std::size_t phase_noise_warning_threshold_bytes = 500ULL * 1024ULL * 1024ULL;
553 const auto bytes_per_buffer = sample_count * sizeof(RealType);
554
555 for (const auto& timing : timings)
556 {
557 if (!timing || lookup.buffers.contains(timing->getId()))
558 {
559 continue;
560 }
561
562 CwPhaseNoiseBuffer buffer{};
563 buffer.start_time = lookup.start_time;
564 buffer.dt = lookup.dt;
565 if (timing->isEnabled())
566 {
567 auto timing_clone = timing->clone();
568 if (lookup.start_time > 0.0)
569 {
570 const auto skip_count = static_cast<std::size_t>(std::llround(lookup.start_time / lookup.dt));
571 timing_clone->skipSamples(skip_count);
572 }
573 // TODO: Replace whole-simulation CW lookup generation with chunked/streaming generation.
575 {
576 LOG(Level::WARNING,
577 "CW phase-noise lookup for timing '{}' allocates {} bytes; large scenarios need chunked "
578 "streaming.",
579 timing->getName(), bytes_per_buffer);
580 }
581 buffer.samples.resize(sample_count);
582 std::ranges::generate(buffer.samples, [&] { return timing_clone->getNextSample(); });
583 }
584
585 lookup.buffers.emplace(timing->getId(), std::move(buffer));
586 }
587
588 return lookup;
589 }
double RealType
Type for real numbers.
Definition config.h:27
#define LOG(level,...)
Definition logging.h:19
RealType rate() noexcept
Get the rendering sample rate.
Definition parameters.h:121
unsigned oversampleRatio() noexcept
Get the oversampling ratio.
Definition parameters.h:151
math::Vec3 max
RealType end_time
Lookup end time in seconds.
RealType start_time
Lookup start time in seconds.

References end_time, LOG, max, params::oversampleRatio(), params::rate(), and start_time.

Referenced by processing::pipeline::applyStreamingInterference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phaseDifference()

RealType simulation::CwPhaseNoiseLookup::phaseDifference ( const timing::Timing rx_timing,
RealType  rx_time,
const timing::Timing tx_timing,
RealType  tx_time 
) const
noexcept

Computes receiver-minus-transmitter phase noise at two propagation times.

Definition at line 605 of file channel_model.cpp.

608 {
610 }
RealType sample(const timing::Timing *timing, RealType time) const noexcept
Samples phase noise for one timing source at the specified time.

References max.

◆ sample()

RealType simulation::CwPhaseNoiseLookup::sample ( const timing::Timing timing,
RealType  time 
) const
noexcept

Samples phase noise for one timing source at the specified time.

Definition at line 591 of file channel_model.cpp.

592 {
593 if (timing == nullptr)
594 {
595 return 0.0;
596 }
597 const auto it = buffers.find(timing->getId());
598 if (it == buffers.end())
599 {
600 return 0.0;
601 }
602 return it->second.sampleAt(time);
603 }
std::unordered_map< SimId, CwPhaseNoiseBuffer > buffers
Per-timing-source phase-noise buffers.

References max.

Member Data Documentation

◆ buffers

std::unordered_map<SimId, CwPhaseNoiseBuffer> simulation::CwPhaseNoiseLookup::buffers

Per-timing-source phase-noise buffers.

Definition at line 80 of file channel_model.h.

◆ dt

RealType simulation::CwPhaseNoiseLookup::dt {}

Lookup sample spacing in seconds.

Definition at line 79 of file channel_model.h.

79{}; ///< Lookup sample spacing in seconds.

◆ end_time

RealType simulation::CwPhaseNoiseLookup::end_time {}

Lookup end time in seconds.

Definition at line 78 of file channel_model.h.

78{}; ///< Lookup end time in seconds.

Referenced by build().

◆ start_time

RealType simulation::CwPhaseNoiseLookup::start_time {}

Lookup start time in seconds.

Definition at line 77 of file channel_model.h.

77{}; ///< Lookup start time in seconds.

Referenced by build().


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