FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
ParameterLibrary Class Reference

#include <ParameterLibrary.h>

Classes

class  Species
 One species of the library. More...
 

Public Member Functions

const std::string & Version () const
 The library version, e.g. "0.6.0".
 
const std::string & Path () const
 The file the library was read from; empty when it was read from a string.
 
const Species * Find (const std::string &key) const
 
std::vector< std::string > SpeciesKeys () const
 The species keys, sorted.
 

Static Public Member Functions

static std::vector< std::string > CandidatePaths (const std::string &configured, const std::string &inputFilePath)
 
static ParameterLibrary Load (const std::string &configured, const std::string &inputFilePath)
 
static ParameterLibrary FromFile (const std::string &path)
 
static ParameterLibrary FromJsonString (const std::string &document)
 

Static Public Attributes

static constexpr const char * kInstalledPath = "resources/acoustics/parameter_library.json"
 The installed library, relative to a resources directory.
 

Detailed Description

The versioned set of empirical acoustic parameters per species, read from a JSON file.

The file is a copy of the echosounder sensor repository's parameters/parameter_library.json (data/acoustics/README.md), and this class ports that repository's reference model (julia/EchosounderModel/src/fish.jl): a species' target strength TS(L, f), its weight W(L) = a L^b and its normal length spread with coefficient of variation length_cv. Only the species section is read; the calibration targets and sediments are not used in FhSim.

Two kinds of species are known: ts_length, TS = 20 log10(L / cm) + b20(f), and ts_table, TS tabulated over length and interpolated linearly in log10(L), never extrapolated. Data exist only at the frequencies the file lists (18, 38, 70, 120 and 200 kHz).

Member Function Documentation

◆ CandidatePaths()

static std::vector< std::string > ParameterLibrary::CandidatePaths ( const std::string &  configured,
const std::string &  inputFilePath 
)
static

The files tried, in order, for the ParameterLibrary parameter of a SimObject.

An empty configured is the installed copy: <input dir>/resources/..., which is where an FMU keeps it (the model XML sits in the FMU root), then ../resources/... from the working directory, which is a playpen's bin. An absolute configured is itself; a relative one is tried beside the input file, then in the working directory, as fhsim's InputReader does.

Parameters
configuredThe ParameterLibrary parameter; empty for the installed copy.
inputFilePathThe main input file (ISimObjectCreator::GetInputfilePath); empty when unknown.
Returns
The candidate paths, the first existing one to be used.

◆ Find()

const Species * ParameterLibrary::Find ( const std::string &  key) const

The species of a key.

Parameters
keyThe species key, e.g. "herring".
Returns
The species, or null when the library has no such key.

◆ FromFile()

static ParameterLibrary ParameterLibrary::FromFile ( const std::string &  path)
static

Reads the library from a JSON file.

Parameters
pathThe file, relative to the working directory or absolute.
Returns
The library.
Exceptions
std::invalid_argumentif the file cannot be read or is not a valid library.

◆ FromJsonString()

static ParameterLibrary ParameterLibrary::FromJsonString ( const std::string &  document)
static

Reads the library from a JSON document.

Parameters
documentThe JSON text.
Returns
The library.
Exceptions
std::invalid_argumentif the document is not a valid library.

◆ Load()

static ParameterLibrary ParameterLibrary::Load ( const std::string &  configured,
const std::string &  inputFilePath 
)
static

Finds and reads the library for the ParameterLibrary parameter of a SimObject: the first existing file of CandidatePaths().

Parameters
configuredThe ParameterLibrary parameter; empty for the installed copy.
inputFilePathThe main input file (ISimObjectCreator::GetInputfilePath); empty when unknown.
Returns
The library.
Exceptions
std::invalid_argumentnaming every path tried when none exists, or as FromFile.

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