htmie.h (5022B)
1 /* Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2018 Centre National de la Recherche Scientifique 3 * Copyright (C) 2018 Université Paul Sabatier 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 18 #ifndef HTMIE_H 19 #define HTMIE_H 20 21 #include <rsys/rsys.h> 22 23 /* Library symbol management */ 24 #if defined(HTMIE_SHARED_BUILD) /* Build shared library */ 25 #define HTMIE_API extern EXPORT_SYM 26 #elif defined(HTMIE_STATIC) /* Use/build static library */ 27 #define HTMIE_API extern LOCAL_SYM 28 #else /* Use shared library */ 29 #define HTMIE_API extern IMPORT_SYM 30 #endif 31 32 /* Helper macro that asserts if the invocation of the htmie function `Func' 33 * returns an error. One should use this macro on htmie function calls for 34 * which no explicit error checking is performed */ 35 #ifndef NDEBUG 36 #define HTMIE(Func) ASSERT(htmie_ ## Func == RES_OK) 37 #else 38 #define HTMIE(Func) htmie_ ## Func 39 #endif 40 41 /* Forward declaration of external data types */ 42 struct logger; 43 struct mem_allocator; 44 45 enum htmie_filter_type { 46 HTMIE_FILTER_LINEAR, 47 HTMIE_FILTER_NEAREST, 48 HTMIE_FILTER_TYPES_COUNT__ 49 }; 50 51 /* Forward declaration of opaque data types */ 52 struct htmie; 53 54 BEGIN_DECLS 55 56 /******************************************************************************* 57 * HTMIE API 58 ******************************************************************************/ 59 HTMIE_API res_T 60 htmie_create 61 (struct logger* logger, /* May be NULL <=> Use default logger */ 62 struct mem_allocator* allocator, /* May be NULL <=> Use default allocator */ 63 const int verbose, /* Verbosity level */ 64 struct htmie** htmie); 65 66 HTMIE_API res_T 67 htmie_ref_get 68 (struct htmie* htmie); 69 70 HTMIE_API res_T 71 htmie_ref_put 72 (struct htmie* htmie); 73 74 HTMIE_API res_T 75 htmie_load 76 (struct htmie *htmie, 77 const char* path); 78 79 /* In nano-meter */ 80 HTMIE_API const double* 81 htmie_get_wavelengths 82 (const struct htmie* htmie); 83 84 /* In m^2.kg^-1 */ 85 HTMIE_API const double* 86 htmie_get_xsections_absorption 87 (const struct htmie* htmie); 88 89 /* In m^2.kg^-1 */ 90 HTMIE_API const double* 91 htmie_get_xsections_scattering 92 (const struct htmie* htmie); 93 94 HTMIE_API const double* 95 htmie_get_asymmetry_parameter 96 (const struct htmie* htmie); 97 98 HTMIE_API size_t 99 htmie_get_wavelengths_count 100 (const struct htmie* htmie); 101 102 /* In m^2.kg^-1 */ 103 HTMIE_API double 104 htmie_fetch_xsection_absorption 105 (const struct htmie* htmie, 106 const double wavelength, 107 const enum htmie_filter_type type); 108 109 /* In m^2.kg^-1 */ 110 HTMIE_API double 111 htmie_fetch_xsection_scattering 112 (const struct htmie* htmie, 113 const double wavelength, 114 const enum htmie_filter_type type); 115 116 HTMIE_API double 117 htmie_fetch_asymmetry_parameter 118 (const struct htmie* htmie, 119 const double wavelength, 120 const enum htmie_filter_type type); 121 122 /* Compute the maximum and the minimum value of the absorption cross section in 123 * a given spectral interval */ 124 HTMIE_API void 125 htmie_compute_xsection_absorption_bounds 126 (const struct htmie* htmie, 127 const double band[2], /* Boundaries of the spectral band in nanometer */ 128 const enum htmie_filter_type type, 129 double bounds[2]); /* Min and Max scattering cross sections in m^2.kg^-1 */ 130 131 /* Compute the maximum and the minimum value of the scattering cross section in 132 * a given spectral interval */ 133 HTMIE_API void 134 htmie_compute_xsection_scattering_bounds 135 (const struct htmie* htmie, 136 const double band[2], /* Boundaries of the spectral band in nanometer */ 137 const enum htmie_filter_type type, 138 double bounds[2]); /* Min and Max scattering cross sections in m^2.kg^-1 */ 139 140 /* Compute the average absorption cross section in a given spectral interval */ 141 HTMIE_API double 142 htmie_compute_xsection_absorption_average 143 (const struct htmie* htmie, 144 const double band[2], /* Boundaries of of the spectral band in nanometer */ 145 const enum htmie_filter_type type); 146 147 /* Compute the average scattering cross section in a given spectral interval */ 148 HTMIE_API double 149 htmie_compute_xsection_scattering_average 150 (const struct htmie* htmie, 151 const double band[2], /* Boundaries of of the spectral band in nanometer */ 152 const enum htmie_filter_type type); 153 154 /* Compute the average asymmetry parameter in a given spectral interval */ 155 HTMIE_API double 156 htmie_compute_asymmetry_parameter_average 157 (const struct htmie* htmie, 158 const double band[2], /* Boundaries of of the spectral band in nanometer */ 159 const enum htmie_filter_type type); 160 161 END_DECLS 162 163 #endif /* HTMIE_H */ 164