13#include <highfive/highfive.hpp>
18#include <unordered_map>
117 const std::vector<std::unique_ptr<radar::Target>>*
targets,
122 std::optional<simulation::CwPhaseNoiseLookup>
owned_lookup;
125 std::unordered_map<SimId, std::shared_ptr<timing::Timing>>
unique_timings;
133 std::vector<std::shared_ptr<timing::Timing>> timings;
137 timings.push_back(
entry.second);
194 throw std::runtime_error(
195 "Pulsed interference sample rate must match the streaming output sample rate.");
234 w *= std::polar(1.0,
n);
259 HighFive::File
file(
filename, HighFive::File::Truncate);
263 std::ranges::transform(
iq_buffer,
i_data.begin(), [](
const auto&
c) { return c.real(); });
264 std::ranges::transform(
iq_buffer,
q_data.begin(), [](
const auto&
c) { return c.imag(); });
266 HighFive::DataSet i_dataset =
file.createDataSet<
RealType>(
"I_data", HighFive::DataSpace::From(
i_data));
268 HighFive::DataSet q_dataset =
file.createDataSet<
RealType>(
"Q_data", HighFive::DataSpace::From(
q_data));
271 file.createAttribute(
"sampling_rate", sample_rate > 0.0 ? sample_rate :
params::rate());
273 file.createAttribute(
"fullscale", fullscale);
274 file.createAttribute(
"reference_carrier_frequency",
ref_freq);
275 if (metadata !=
nullptr)
282 catch (
const HighFive::Exception&
err)
const Receiver & receiver
Header for radar channel propagation and interaction models.
Manages radar signal reception and response processing.
@ FLAG_NODIRECT
Disable direct-path reception.
Represents a timing source for simulation.
double RealType
Type for real numbers.
std::complex< RealType > ComplexType
Type for complex numbers.
constexpr RealType PI
Mathematical constant π (pi).
Header file for Digital Signal Processing (DSP) filters and upsampling/downsampling functionality.
Declares focused, testable pipeline steps for receiver finalization.
Header file for HDF5 data export and import functions.
Header file for the logging system.
std::vector< ComplexType > downsample(std::span< const ComplexType > in)
Low-pass filters and decimates an oversampled complex waveform back to base rate.
@ FATAL
Fatal level for severe error events.
@ INFO
Info level for informational messages.
RealType rate() noexcept
Get the rendering sample rate.
RealType startTime() noexcept
Get the start time for the simulation.
unsigned oversampleRatio() noexcept
Get the oversampling ratio.
void applyStreamingInterference(std::span< ComplexType > window, const RealType actual_start, const RealType dt, const radar::Receiver *receiver, const std::vector< core::ActiveStreamingSource > &streaming_sources, const std::vector< std::unique_ptr< radar::Target > > *targets, core::ReceiverTrackerCache &tracker_cache, const simulation::CwPhaseNoiseLookup *phase_noise_lookup)
Applies streaming interference to a time window.
void addPhaseNoiseToWindow(std::span< const RealType > noise, std::span< ComplexType > window)
Applies a pre-generated sequence of phase noise samples to an I/Q buffer.
RealType applyDownsamplingAndQuantization(std::vector< ComplexType > &buffer)
Downsamples and quantizes an IQ buffer.
void advanceTimingModel(timing::Timing *timing_model, const radar::Receiver *receiver, const RealType rate)
Advances the receiver's timing model to the start of the next processing window.
std::tuple< RealType, RealType > calculateJitteredStart(const RealType ideal_start, const RealType first_phase_noise, const RealType carrier_freq, const RealType rate)
Calculates the jittered start time and fractional delay from a phase noise sample.
void applyPulsedInterference(std::vector< ComplexType > &iq_buffer, const std::vector< std::unique_ptr< serial::Response > > &interference_log)
Renders and applies pulsed interference to a streaming IQ buffer.
void exportStreamingToHdf5(const std::string &filename, const std::vector< ComplexType > &iq_buffer, const RealType fullscale, const RealType ref_freq, const core::OutputFileMetadata *metadata, const RealType sample_rate)
Exports a finalized streaming IQ buffer to an HDF5 file.
void applyDownsampling(std::vector< ComplexType > &buffer)
Downsamples an IQ buffer to the configured output rate without quantization.
RealType quantizeAndScaleWindow(std::span< ComplexType > window)
Simulates ADC quantization and scales a window of complex I/Q samples.
std::mutex hdf5_global_mutex
Global mutex to protect all HDF5 C-library calls, which are not thread-safe.
void writeOutputFileMetadataAttributes(HighFive::File &file, const core::OutputFileMetadata &metadata)
Writes additive FERS output metadata attributes to an open HDF5 file.
ComplexType calculateStreamingDirectPathContribution(const core::ActiveStreamingSource &source, const Receiver *recv, const RealType timeK, const CwPhaseNoiseLookup *const phase_noise_lookup, core::FmcwChirpBoundaryTracker *const chirp_tracker, const StreamingTimingPhaseMode timing_phase_mode)
Calculates a direct-path contribution from a cached streaming source.
ComplexType calculateStreamingReflectedPathContribution(const core::ActiveStreamingSource &source, const Receiver *recv, const Target *targ, const RealType timeK, const CwPhaseNoiseLookup *const phase_noise_lookup, core::FmcwChirpBoundaryTracker *const chirp_tracker, const StreamingTimingPhaseMode timing_phase_mode)
Calculates a reflected-path contribution from a cached streaming source.
Defines the Parameters struct and provides methods for managing simulation parameters.
Radar Receiver class for managing signal reception and response handling.
Classes for managing radar signal responses.
Header for receiver-side signal processing and rendering.
Per-receiver FMCW tracker state for direct and reflected streaming paths.
Half-open sample span used for dechirped LO-active finalization ranges.
std::size_t start
Inclusive first sample index in the span.
Lookup table for CW phase noise across timing sources.
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.
Defines classes for radar targets and their Radar Cross-Section (RCS) models.
Timing source for simulation objects.
Header file for the Transmitter class in the radar namespace.