htrdr_atmosphere_c.h (5779B)
1 /* Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique 2 * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux 3 * Copyright (C) 2022-2025 Institut Pierre-Simon Laplace 4 * Copyright (C) 2022-2025 Institut de Physique du Globe de Paris 5 * Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com) 6 * Copyright (C) 2022-2025 Observatoire de Paris 7 * Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne 8 * Copyright (C) 2022-2025 Université de Versaille Saint-Quentin 9 * Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier 10 * 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 23 24 #ifndef HTRDR_ATMOSPHERE_C_H 25 #define HTRDR_ATMOSPHERE_C_H 26 27 #include "atmosphere/htrdr_atmosphere_args.h" 28 29 #include "core/htrdr_accum.h" 30 #include "core/htrdr_buffer.h" 31 #include "core/htrdr_spectral.h" 32 33 #include <rsys/ref_count.h> 34 #include <rsys/rsys.h> 35 #include <rsys/str.h> 36 37 /* Define the radiance component */ 38 enum atmosphere_radiance_cpnt_flag { 39 ATMOSPHERE_RADIANCE_DIRECT = BIT(0), 40 ATMOSPHERE_RADIANCE_DIFFUSE = BIT(1), 41 ATMOSPHERE_RADIANCE_ALL = 42 ATMOSPHERE_RADIANCE_DIRECT 43 | ATMOSPHERE_RADIANCE_DIFFUSE 44 }; 45 46 struct atmosphere_pixel_xwave { 47 struct htrdr_estimate radiance; /* In W/m^2/sr */ 48 struct htrdr_estimate radiance_temperature; /* In K */ 49 struct htrdr_accum time; /* In microseconds */ 50 }; 51 #define ATMOSPHERE_PIXEL_XWAVE_NULL__ { \ 52 HTRDR_ESTIMATE_NULL__, /* Radiance */ \ 53 HTRDR_ESTIMATE_NULL__, /* Radiance temperature */ \ 54 HTRDR_ACCUM_NULL__ /* Time */ \ 55 } 56 static const struct atmosphere_pixel_xwave ATMOSPHERE_PIXEL_XWAVE_NULL = 57 ATMOSPHERE_PIXEL_XWAVE_NULL__; 58 59 struct atmosphere_pixel_flux { 60 struct htrdr_accum flux; 61 struct htrdr_accum time; 62 }; 63 #define ATMOSPHERE_PIXEL_FLUX_NULL__ { \ 64 HTRDR_ACCUM_NULL__, \ 65 HTRDR_ACCUM_NULL__ \ 66 } 67 static const struct atmosphere_pixel_flux ATMOSPHERE_PIXEL_FLUX_NULL = 68 ATMOSPHERE_PIXEL_FLUX_NULL__; 69 70 struct atmosphere_pixel_image { 71 struct htrdr_estimate X; /* In W/m^2/sr */ 72 struct htrdr_estimate Y; /* In W/m^2/sr */ 73 struct htrdr_estimate Z; /* In W/m^2/sr */ 74 struct htrdr_accum time; /* In microseconds */ 75 }; 76 #define ATMOSPHERE_PIXEL_IMAGE_NULL__ { \ 77 HTRDR_ESTIMATE_NULL__, /* X */ \ 78 HTRDR_ESTIMATE_NULL__, /* Y */ \ 79 HTRDR_ESTIMATE_NULL__, /* Z */ \ 80 HTRDR_ACCUM_NULL__ /* Time */ \ 81 } 82 static const struct atmosphere_pixel_image ATMOSPHERE_PIXEL_IMAGE_NULL = 83 ATMOSPHERE_PIXEL_IMAGE_NULL__; 84 85 /* Forward declarations */ 86 struct htsky; 87 struct htrdr; 88 struct htrdr_atmosphere_args; 89 struct htrdr_buffer; 90 struct htrdr_materials; 91 struct htrdr_ran_wlen_cie_xyz; 92 struct htrdr_ran_wlen_planck; 93 struct ssp_rng; 94 95 struct htrdr_atmosphere { 96 struct htrdr_atmosphere_ground* ground; 97 struct htrdr_atmosphere_sun* sun; 98 struct htrdr_materials* mats; 99 struct htrdr_ran_wlen_cie_xyz* cie; 100 struct htrdr_ran_wlen_planck* planck; 101 102 struct scam* camera; /* Camera */ 103 struct htrdr_rectangle* flux_map; /* Flux map */ 104 105 struct htrdr_buffer_layout buf_layout; 106 struct htrdr_buffer* buf; /* NULL on non master processes */ 107 108 struct htsky* sky; 109 const char* sky_mtl_name; 110 enum htrdr_spectral_type spectral_type; 111 double wlen_range_m[2]; /* Integration range in *meters* */ 112 double ref_temperature; /* Reference temperature in Kelvin */ 113 114 size_t spp; /* #samples per pixel */ 115 size_t width; /* Image width */ 116 size_t height; /* Image height */ 117 118 FILE* output; 119 struct str output_name; 120 121 unsigned grid_max_definition[3]; /* Max definition of the acceleration grids */ 122 unsigned nthreads; /* #threads of the process */ 123 enum htrdr_atmosphere_args_output_type output_type; 124 int verbose; /* Verbosity level */ 125 126 ref_T ref; 127 struct htrdr* htrdr; 128 }; 129 130 extern LOCAL_SYM void 131 atmosphere_get_pixel_format 132 (const struct htrdr_atmosphere* cmd, 133 struct htrdr_pixel_format* fmt); 134 135 extern LOCAL_SYM res_T 136 atmosphere_draw_map 137 (struct htrdr_atmosphere* cmd); 138 139 /* Return the shortwave radiance in W/m^2/sr/m */ 140 extern LOCAL_SYM double 141 atmosphere_compute_radiance_sw 142 (struct htrdr_atmosphere* cmd, 143 const size_t ithread, 144 struct ssp_rng* rng, 145 const int cpnt_mask, /* Combination of enum atmosphere_radiance_cpnt_flag */ 146 const double pos_in[3], 147 const double dir_in[3], 148 const double wlen, /* In nanometer */ 149 const size_t iband, 150 const size_t iquad); 151 152 /* Return the longwave radiance in W/m^2/sr/m */ 153 extern LOCAL_SYM double 154 atmosphere_compute_radiance_lw 155 (struct htrdr_atmosphere* cmd, 156 const size_t ithread, 157 struct ssp_rng* rng, 158 const double pos_in[3], 159 const double dir_in[3], 160 const double wlen, /* In nanometer */ 161 const size_t iband, 162 const size_t iquad); 163 164 #endif /* HTRDR_ATMOSPHERE_C_H */ 165