| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This file is part of INSTINCT, the INS Toolkit for Integrated | ||
| 2 | // Navigation Concepts and Training by the Institute of Navigation of | ||
| 3 | // the University of Stuttgart, Germany. | ||
| 4 | // | ||
| 5 | // This Source Code Form is subject to the terms of the Mozilla Public | ||
| 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| 7 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| 8 | |||
| 9 | /// @file Troposphere.hpp | ||
| 10 | /// @brief Troposphere Models | ||
| 11 | /// @author T. Topp (topp@ins.uni-stuttgart.de) | ||
| 12 | /// @author Rui Wang (rui.wang@ins.uni-stuttgart.de) | ||
| 13 | /// @date 2022-05-26 | ||
| 14 | |||
| 15 | #pragma once | ||
| 16 | |||
| 17 | #include <array> | ||
| 18 | #include <Eigen/Core> | ||
| 19 | #include <fmt/format.h> | ||
| 20 | |||
| 21 | #include "ZenithDelay.hpp" | ||
| 22 | #include "Navigation/Time/InsTime.hpp" | ||
| 23 | #include "Navigation/Atmosphere/Pressure/Pressure.hpp" | ||
| 24 | #include "Navigation/Atmosphere/Temperature/Temperature.hpp" | ||
| 25 | #include "Navigation/Atmosphere/WaterVapor/WaterVapor.hpp" | ||
| 26 | #include "Navigation/Atmosphere/Troposphere/MappingFunctions/ViennaMappingFunction.hpp" | ||
| 27 | |||
| 28 | namespace NAV | ||
| 29 | { | ||
| 30 | |||
| 31 | /// @brief Atmospheric model selection for temperature, pressure and water vapor | ||
| 32 | struct AtmosphereModels | ||
| 33 | { | ||
| 34 | PressureModel pressureModel = PressureModel::ISA; ///< Pressure model | ||
| 35 | TemperatureModel temperatureModel{ TemperatureModel::ISA }; ///< Temperature model | ||
| 36 | WaterVaporModel waterVaporModel = WaterVaporModel::ISA; ///< WaterVapor model | ||
| 37 | }; | ||
| 38 | |||
| 39 | /// Available Troposphere delay models | ||
| 40 | enum class TroposphereModel : uint8_t | ||
| 41 | { | ||
| 42 | None, ///< Troposphere Model turned off | ||
| 43 | Saastamoinen, ///< Saastamoinen model | ||
| 44 | GPT2, ///< GPT2 | ||
| 45 | GPT3, ///< GPT3 | ||
| 46 | COUNT, ///< Amount of items in the enum | ||
| 47 | }; | ||
| 48 | |||
| 49 | /// Available Mapping Functions | ||
| 50 | enum class MappingFunction : uint8_t | ||
| 51 | { | ||
| 52 | None, ///< Mapping Function turned off (= 1) | ||
| 53 | Cosecant, ///< Cosecant of elevation | ||
| 54 | GMF, ///< Global Mapping Function (GMF) | ||
| 55 | NMF, ///< Niell Mapping Function (NMF) | ||
| 56 | VMF_GPT2, ///< Vienna Mapping Function based on the GPT2 grid | ||
| 57 | VMF_GPT3, ///< Vienna Mapping Function based on the GPT3 grid | ||
| 58 | COUNT, ///< Amount of items in the enum | ||
| 59 | }; | ||
| 60 | |||
| 61 | /// @brief Collection of troposphere model selections | ||
| 62 | struct TroposphereModelSelection | ||
| 63 | { | ||
| 64 | /// Troposphere ZHD model, atmosphere models | ||
| 65 | std::pair<TroposphereModel, AtmosphereModels> zhdModel = std::make_pair(TroposphereModel::Saastamoinen, AtmosphereModels{}); | ||
| 66 | /// Troposphere ZWD model, atmosphere models | ||
| 67 | std::pair<TroposphereModel, AtmosphereModels> zwdModel = std::make_pair(TroposphereModel::Saastamoinen, AtmosphereModels{}); | ||
| 68 | |||
| 69 | /// Mapping function ZHD, atmosphere models | ||
| 70 | std::pair<MappingFunction, AtmosphereModels> zhdMappingFunction = std::make_pair(MappingFunction::GMF, AtmosphereModels{}); | ||
| 71 | /// Mapping function ZWD, atmosphere models | ||
| 72 | std::pair<MappingFunction, AtmosphereModels> zwdMappingFunction = std::make_pair(MappingFunction::GMF, AtmosphereModels{}); | ||
| 73 | }; | ||
| 74 | |||
| 75 | /// @brief Converts the enum to a string | ||
| 76 | /// @param[in] troposphereZhdModel Enum value to convert into text | ||
| 77 | /// @return String representation of the enum | ||
| 78 | const char* to_string(TroposphereModel troposphereZhdModel); | ||
| 79 | |||
| 80 | /// @brief Converts the enum to a string | ||
| 81 | /// @param[in] mappingFunction Enum value to convert into text | ||
| 82 | /// @return String representation of the enum | ||
| 83 | const char* to_string(MappingFunction mappingFunction); | ||
| 84 | |||
| 85 | /// @brief Shows a ComboBox and button for advanced configuration to select the troposphere models | ||
| 86 | /// @param[in] label Label to show beside the combo box. This has to be a unique id for ImGui. | ||
| 87 | /// @param[in] troposphereModelSelection Reference to the troposphere model to select | ||
| 88 | /// @param[in] width Width of the widget | ||
| 89 | bool ComboTroposphereModel(const char* label, TroposphereModelSelection& troposphereModelSelection, float width = 0.0F); | ||
| 90 | |||
| 91 | /// @brief Calculates the tropospheric zenith hydrostatic and wet delays and corresponding mapping factors | ||
| 92 | /// @param[in] insTime Time to calculate the values for | ||
| 93 | /// @param[in] lla_pos [𝜙, λ, h]^T Geodetic latitude, longitude and height in [rad, rad, m] | ||
| 94 | /// @param[in] elevation Satellite elevation [rad] | ||
| 95 | /// @param[in] azimuth Satellite azimuth [rad] | ||
| 96 | /// @param[in] troposphereModels Models to use for each calculation | ||
| 97 | /// @param[in] nameId Name and Id of the node used for log messages only | ||
| 98 | /// @return ZHD, ZWD and mapping factors for ZHD and ZWD | ||
| 99 | ZenithDelay calcTroposphericDelayAndMapping(const InsTime& insTime, const Eigen::Vector3d& lla_pos, double elevation, double azimuth, | ||
| 100 | const TroposphereModelSelection& troposphereModels, const std::string& nameId); | ||
| 101 | |||
| 102 | /// @brief Calculates the tropospheric error variance | ||
| 103 | /// @param[in] dpsr_T Tropospheric propagation error [m] | ||
| 104 | /// @param[in] elevation Satellite elevation in [rad] | ||
| 105 | /// @return Variance of the error [m^2] | ||
| 106 | double tropoErrorVar(double dpsr_T, double elevation); | ||
| 107 | |||
| 108 | /// @brief Converts the provided object into json | ||
| 109 | /// @param[out] j Json object which gets filled with the info | ||
| 110 | /// @param[in] obj Object to convert into json | ||
| 111 | void to_json(json& j, const AtmosphereModels& obj); | ||
| 112 | /// @brief Converts the provided json object into a node object | ||
| 113 | /// @param[in] j Json object with the needed values | ||
| 114 | /// @param[out] obj Object to fill from the json | ||
| 115 | void from_json(const json& j, AtmosphereModels& obj); | ||
| 116 | |||
| 117 | /// @brief Converts the provided object into json | ||
| 118 | /// @param[out] j Json object which gets filled with the info | ||
| 119 | /// @param[in] obj Object to convert into json | ||
| 120 | void to_json(json& j, const TroposphereModelSelection& obj); | ||
| 121 | /// @brief Converts the provided json object into a node object | ||
| 122 | /// @param[in] j Json object with the needed values | ||
| 123 | /// @param[out] obj Object to fill from the json | ||
| 124 | void from_json(const json& j, TroposphereModelSelection& obj); | ||
| 125 | |||
| 126 | } // namespace NAV | ||
| 127 | |||
| 128 | #ifndef DOXYGEN_IGNORE | ||
| 129 | |||
| 130 | /// @brief Formatter | ||
| 131 | template<> | ||
| 132 | struct fmt::formatter<NAV::TroposphereModel> : fmt::formatter<std::string> | ||
| 133 | { | ||
| 134 | /// @brief Defines how to format structs | ||
| 135 | /// @param[in] data Struct to format | ||
| 136 | /// @param[in, out] ctx Format context | ||
| 137 | /// @return Output iterator | ||
| 138 | template<typename FormatContext> | ||
| 139 | auto format(const NAV::TroposphereModel& data, FormatContext& ctx) const | ||
| 140 | { | ||
| 141 | return fmt::formatter<std::string>::format(NAV::to_string(data), ctx); | ||
| 142 | } | ||
| 143 | }; | ||
| 144 | |||
| 145 | /// @brief Formatter | ||
| 146 | template<> | ||
| 147 | struct fmt::formatter<NAV::MappingFunction> : fmt::formatter<std::string> | ||
| 148 | { | ||
| 149 | /// @brief Defines how to format structs | ||
| 150 | /// @param[in] data Struct to format | ||
| 151 | /// @param[in, out] ctx Format context | ||
| 152 | /// @return Output iterator | ||
| 153 | template<typename FormatContext> | ||
| 154 | ✗ | auto format(const NAV::MappingFunction& data, FormatContext& ctx) const | |
| 155 | { | ||
| 156 | ✗ | return fmt::formatter<std::string>::format(NAV::to_string(data), ctx); | |
| 157 | } | ||
| 158 | }; | ||
| 159 | |||
| 160 | #endif | ||
| 161 |