281#include "SampledSensor.h"
284#include <fhsim/simobject/SimObject.h>
286#include <marenv/marenv.h>
294class EnvironmentProvider;
297class IntegrableField;
346 std::shared_ptr<const environment::field::ScalarField>
field;
347 const environment::field::IntegrableField*
integrable =
nullptr;
405 static double AltitudeOf(
double slantRange,
const double beamDirection[3]);
454 static double BeamPattern(
double offAxisRad,
double beamWidthDeg);
473 static bool IsDiskBeam(
const double axis[3],
double halfWidthRad);
484 static void DiskConcentrations(
const environment::field::IntegrableField& field,
const double position[3],
const double axis[3],
485 double binSize,
double radiusPerRange, std::span<double> concentration);
494 static void SampleDirections(
const double axis[3],
int beamSamples,
double ringAngleRad, std::vector<std::array<double, 3>>& directions);
504 static int DetectBottomBin(
const std::vector<double>& svLinear,
double binSize,
double beamRange,
double minRange,
double thresholdDb);
516 static double IntegrateOverWindow(std::span<const double> perBin,
double binSize,
double beamRange,
double windowStart,
double windowEnd);
537 static double NoiseFloorLinear(
double noiseSvAt1mDb,
double absorptionDbPerKm,
double range);
540 void OdeFcn(
const double dT,
const double*
const adX,
double*
const adXDot)
const override;
553 void FinalSetup(
const double dT,
const double*
const adX, ISimObjectCreator*
const creator)
override;
555#ifdef FH_VISUALIZATION
565 void RenderInit(Ogre::Root*
const ogreRoot, ISimObjectCreator*
const creator)
override;
571 void RenderUpdate(
const double dT,
const double*
const adX)
override;
581 const std::vector<Species>&
GetSpecies()
const {
return m_species; }
590 const std::vector<double>&
Frequencies()
const {
return m_frequencykHz; }
598 const double*
OutAltitude(
const double dT,
const double*
const adX);
600 const double*
OutValid(
const double dT,
const double*
const adX);
602 const double*
OutPingTime(
const double dT,
const double*
const adX);
604 const double*
OutSa(
const double dT,
const double*
const adX,
const int index);
612 bool outOfRange =
false;
619 void ReadFrequencyArrays(ISimObjectCreator*
const creator);
622 void PrepareFrequencyConstants();
627 void ReadFileParameters(ISimObjectCreator*
const creator);
632 void RefuseRemovedParameters(ISimObjectCreator*
const creator);
637 void ResolveSpecies(ISimObjectCreator*
const creator);
643 void Ping(
double dT,
const double*
const adX);
652 double MeasureBottom(
double dT,
const double position[3],
const double beamDown[3]);
661 void UpdateAbsorption(
double dT,
const double position[3],
const double direction[3],
double beamRange);
670 void FormPingColumns(
double dT,
const double position[3],
const double direction[3],
double bottomRange);
678 void WriteRow(
double dT,
const double position[3],
size_t channel,
const std::vector<double>& svLinear);
683 void OpenFileAndWriteHeader(ISimObjectCreator*
const creator);
688 std::vector<std::string> m_speciesFieldNames;
689 bool m_autoDiscover =
false;
690 std::vector<Species> m_species;
691 std::string m_parameterLibrary;
693 std::vector<double> m_frequencykHz;
694 std::vector<double> m_beamWidthDeg;
695 std::vector<double> m_absorptionDbPerKm;
696 bool m_absorptionGiven =
false;
697 std::vector<double> m_bottomBackscatterDb;
698 std::vector<double> m_noiseSvAt1mDb;
699 std::vector<double> m_svBiasDb;
701 bool m_writeFile =
true;
702 std::string m_fileName;
703 int m_flushEveryNPings = 20;
704 int m_svPrecision = 2;
706 std::unique_ptr<std::ofstream> m_stream;
708 int m_pingsTaken = 0;
710 FieldWarnings m_fieldWarned;
713 std::vector<double> m_sa;
714 std::vector<double> m_integratedBiomass;
716 double m_halfWidthRad = 0.0;
717 std::vector<double> m_ringWeight;
718 std::vector<double> m_diskRadiusPerRange;
719 std::vector<size_t> m_diskOfFrequency;
720 std::vector<double> m_svBiasLinear;
721 std::vector<double> m_bottomBackscatterLinear;
724 std::vector<std::array<double, 3>> m_directions;
726 std::vector<double> m_axisConcentration;
728 std::vector<double> m_diskConcentration;
730 std::vector<double> m_ringConcentration;
732 std::vector<std::vector<double>> m_svLinear;
736#ifdef FH_VISUALIZATION
737 Ogre::SceneManager* m_sceneMgr =
nullptr;
738 Ogre::SceneNode* m_beamNode =
nullptr;
739 Ogre::ManualObject* m_beamObject =
nullptr;
Definition SampledSensor.h:49
Definition SensorEchosounder.h:303
static double NoiseFloorLinear(double noiseSvAt1mDb, double absorptionDbPerKm, double range)
static bool IsDiskBeam(const double axis[3], double halfWidthRad)
static double EquivalentBeamAngle(double beamWidthDeg)
const double * OutSeafloorDepth(const double dT, const double *const adX)
The inferred depth of the seafloor, m.
const double * OutAltitude(const double dT, const double *const adX)
The measured height above the seafloor, m.
const double * OutValid(const double dT, const double *const adX)
One when the last ping found a bottom, zero otherwise.
static int DetectBottomBin(const std::vector< double > &svLinear, double binSize, double beamRange, double minRange, double thresholdDb)
const std::vector< double > & Frequencies() const
The operating frequencies, kHz.
Definition SensorEchosounder.h:590
static double SampleRangeOf(int bin, double binSize, double beamRange)
static double AltitudeOf(double slantRange, const double beamDirection[3])
void FinalSetup(const double dT, const double *const adX, ISimObjectCreator *const creator) override
static double PerturbRange(double trueRange, const Settings &settings, SensorNoise &noise)
int PingsTaken() const
The number of pings taken so far.
Definition SensorEchosounder.h:587
static double BeamPattern(double offAxisRad, double beamWidthDeg)
const double * OutSeafloorDistance(const double dT, const double *const adX)
The measured slant range to the seafloor, m.
static double BottomClearance(double rayTolerance, const double beamDirection[3])
const std::vector< double > & DiskRadiiPerRange() const
The disk radius per range of each distinct beam width, in order of first appearance among the frequen...
Definition SensorEchosounder.h:584
static double IntegrateOverWindow(std::span< const double > perBin, double binSize, double beamRange, double windowStart, double windowEnd)
SensorEchosounder(std::string simObjectName, const Settings &settings)
static int BinCountOf(double range, double binSize)
static double DiskRadiusPerRange(double beamWidthDeg)
void OdeFcn(const double dT, const double *const adX, double *const adXDot) const override
Writes no derivatives: this SimObject declares no states.
const double * OutSa(const double dT, const double *const adX, const int index)
sa over the Integration window at one frequency, m^2/m^2.
SensorEchosounder(std::string simObjectName, ISimObjectCreator *creator)
const std::vector< Species > & GetSpecies() const
The species entering the acoustic model, in file column order.
Definition SensorEchosounder.h:581
const Reading & HeldReading() const
The reading currently held on the output ports.
Definition SensorEchosounder.h:575
static void DiskConcentrations(const environment::field::IntegrableField &field, const double position[3], const double axis[3], double binSize, double radiusPerRange, std::span< double > concentration)
static void SampleDirections(const double axis[3], int beamSamples, double ringAngleRad, std::vector< std::array< double, 3 > > &directions)
static std::string FieldStatusWarning(const std::string &sensorName, const std::string &fieldName, double depth, marenv::Status status)
static double DownSampleRangeOf(int bin, double binSize, double bottomRange, double clearance)
const double * OutIntegratedBiomass(const double dT, const double *const adX, const int index)
The Integrated biomass of one species field, kg/m^2.
~SensorEchosounder() override
Flushes and closes the echogram file, and releases the visualisation geometry.
static bool IsValidMaxRange(double maxRange)
const double * OutPingTime(const double dT, const double *const adX)
The time of the ping the held reading came from, s.
static bool IsValidRaySearch(double rayStepSize, double rayTolerance)
void AcceptedStep(const double dT, const double *const adX) override
const Settings & GetSettings() const
The settings the instrument was built with.
Definition SensorEchosounder.h:578
Definition SensorNoise.h:43
Status
Definition marenv.h:40
The altimeter reading held on the output ports between pings.
Definition SensorEchosounder.h:332
double valid
One when a bottom was found, zero otherwise.
Definition SensorEchosounder.h:336
double pingTime
The time of the ping this reading came from, s.
Definition SensorEchosounder.h:337
double seafloorDepth
The inferred depth of the seafloor, m.
Definition SensorEchosounder.h:334
double seafloorDistance
The measured slant range to the seafloor, m.
Definition SensorEchosounder.h:333
double altitude
The measured height above the seafloor, m.
Definition SensorEchosounder.h:335
Everything the instrument is configured with.
Definition SensorEchosounder.h:307
double independentSamplesPerBin
The Gamma shape of the speckle.
Definition SensorEchosounder.h:321
double rayTolerance
The convergence tolerance of the ray intersection, m.
Definition SensorEchosounder.h:311
double rangeNoiseRelative
The relative range noise standard deviation.
Definition SensorEchosounder.h:314
double beamWidthDeg
The widest full beam opening angle, degrees; the drawn cone and the sampling ring.
Definition SensorEchosounder.h:316
double minRange
The start of the Integration window, the near-field limit, m.
Definition SensorEchosounder.h:323
double rangeBias
The constant offset of the measured range, m.
Definition SensorEchosounder.h:312
double bottomOffset
The Integration window ends this far short of the detected bottom, m.
Definition SensorEchosounder.h:324
double svFloorDb
The lowest Sv ever reported, dB.
Definition SensorEchosounder.h:320
int beamSamples
The samples across the beam per range bin: the axis, then a ring.
Definition SensorEchosounder.h:317
double bottomThresholdDb
The Sv a bin needs to be detected as the bottom, dB.
Definition SensorEchosounder.h:325
double rayStepSize
The search step of the ray intersection, m.
Definition SensorEchosounder.h:310
unsigned int noiseSeed
The random seed; zero is a perfect instrument.
Definition SensorEchosounder.h:327
double maxRangeDown
The longest slant range searched and binned, m.
Definition SensorEchosounder.h:309
double rangeNoiseStd
The absolute range noise standard deviation, m.
Definition SensorEchosounder.h:313
double binSize
The echogram range bin size, m.
Definition SensorEchosounder.h:319
double pingPeriod
The time between pings, s.
Definition SensorEchosounder.h:308
One Species Concentration field as the acoustic model sees it.
Definition SensorEchosounder.h:342
std::shared_ptr< const environment::field::ScalarField > field
The field, kept alive here; set at bind time.
Definition SensorEchosounder.h:346
const environment::field::IntegrableField * integrable
field as an IntegrableField (D20), or null: then the species is point sampled.
Definition SensorEchosounder.h:347
int handle
The field handle, resolved once in FinalSetup.
Definition SensorEchosounder.h:344
std::string name
The scalar field name.
Definition SensorEchosounder.h:343
double lengthCm
The field's mean length, cm.
Definition SensorEchosounder.h:348
std::string speciesKey
The field's species, a key of the Parameter library.
Definition SensorEchosounder.h:345
std::vector< double > sigmaBsPerKg
sigma_bs per kg at each frequency, m^2/kg.
Definition SensorEchosounder.h:349