31 if (image_data_function_record)
33 if (instrument_id ==
"goesn_imager" && std::stoi(channel) > 0 && std::stoi(channel) <= 5)
35 const float goesn_imager_wavelength_table[5] = {
36 630, 3900, 6480, 10700, 13300,
39 pro.
set_channel_wavenumber(pro.images.size() - 1, 1e7 / goesn_imager_wavelength_table[std::stoi(channel) - 1]);
41 else if (instrument_id ==
"abi" && channel.find_first_not_of(
"0123456789") == std::string::npos && std::stoi(channel) > 0 && std::stoi(channel) <= 16)
43 const float goes_abi_wavelength_table[16] = {
44 470, 640, 860, 1380, 1610, 2260, 3900, 6190, 6950, 7340, 8500, 9610, 10350, 11200, 12300, 13300,
47 pro.
set_channel_wavenumber(pro.images.size() - 1, 1e7 / goes_abi_wavelength_table[std::stoi(channel) - 1]);
49 else if (instrument_id ==
"ahi" && std::stoi(channel) > 0 && std::stoi(channel) <= 16)
51 const float hima_ahi_wavelength_table[16] = {
52 470, 510, 640, 860, 1600, 2300, 3900, 6200, 6900, 7300, 8600, 9600, 10400, 11200, 12400, 13300,
55 pro.
set_channel_wavenumber(pro.images.size() - 1, 1e7 / hima_ahi_wavelength_table[std::stoi(channel) - 1]);
57 else if (instrument_id ==
"ami")
59 double wavelength_nm = std::stod(channel.substr(2, channel.size() - 1)) * 100;
68 auto lines = splitString(image_data_function_record->datas,
'\n');
71 lines = splitString(image_data_function_record->datas,
'\r');
74 logger->error(
"Error parsing calibration info into lines!");
82 if (lines[0].find(
"HALFTONE:=") != std::string::npos)
85 if (instrument_id ==
"goesn_imager" || instrument_id ==
"abi")
87 if (lines[1] ==
"_NAME:=toa_lambertian_equivalent_albedo_multiplied_by_cosine_solar_zenith_angle")
89 std::vector<std::pair<int, float>> lut;
90 for (
size_t i = 3; i < lines.size(); i++)
94 if (sscanf(lines[i].c_str(),
"%d:=%f", &val, &valo) == 2)
95 lut.push_back({val, valo});
98 nlohmann::json calib_cfg = pro.get_calibration_raw();
100 calib_cfg[channel] = lut;
101 pro.set_calibration(
"generic_xrit", calib_cfg);
104 else if (lines[1] ==
"_NAME:=toa_brightness_temperature")
106 std::vector<std::pair<int, float>> lut;
107 for (
size_t i = 3; i < lines.size(); i++)
111 if (sscanf(lines[i].c_str(),
"%d:=%f", &val, &valo) == 2)
112 lut.push_back({val, valo});
115 nlohmann::json calib_cfg = pro.get_calibration_raw();
117 calib_cfg[channel] = lut;
118 pro.set_calibration(
"generic_xrit", calib_cfg);
119 pro.
set_channel_unit(pro.images.size() - 1, CALIBRATION_ID_EMISSIVE_RADIANCE);
124 if (instrument_id ==
"ami")
126 int bits_for_calib = 8;
127 if (lines[0].find(
"HALFTONE:=9") != std::string::npos)
129 else if (lines[0].find(
"HALFTONE:=10") != std::string::npos)
131 else if (lines[0].find(
"HALFTONE:=11") != std::string::npos)
133 else if (lines[0].find(
"HALFTONE:=12") != std::string::npos)
135 else if (lines[0].find(
"HALFTONE:=13") != std::string::npos)
137 else if (lines[0].find(
"HALFTONE:=14") != std::string::npos)
140 if (lines[2] ==
"_UNIT:=ALBEDO(%)")
142 std::vector<std::pair<int, float>> lut;
143 for (
size_t i = 3; i < lines.size(); i++)
147 if (sscanf(lines[i].c_str(),
"%d:=%f", &val, &valo) == 2)
148 lut.push_back({val, valo / 100.0});
151 nlohmann::json calib_cfg = pro.get_calibration_raw();
153 calib_cfg[
"bits_for_calib"][channel] = bits_for_calib;
154 calib_cfg[
"to_complete"] =
true;
156 calib_cfg[channel] = lut;
157 pro.set_calibration(
"generic_xrit", calib_cfg);
160 else if (lines[2] ==
"_UNIT:=KELVIN")
162 std::vector<std::pair<int, float>> lut;
163 for (
size_t i = 3; i < lines.size(); i++)
167 if (sscanf(lines[i].c_str(),
"%d:=%f", &val, &valo) == 2)
168 lut.push_back({val, valo});
171 nlohmann::json calib_cfg = pro.get_calibration_raw();
173 calib_cfg[
"bits_for_calib"][channel] = bits_for_calib;
174 calib_cfg[
"to_complete"] =
true;
176 calib_cfg[channel] = lut;
177 pro.set_calibration(
"generic_xrit", calib_cfg);
178 pro.
set_channel_unit(pro.images.size() - 1, CALIBRATION_ID_EMISSIVE_RADIANCE);
183 if (instrument_id ==
"ahi")
185 int bits_for_calib = 8;
186 bool lut_has_1023 =
false, lut_has_4095 =
false, lut_has_16383 =
false;
187 if (lines[2].find(
"_UNIT:=PERCENT") != std::string::npos || lines[2].find(
"_UNIT:=ALBEDO(%)") != std::string::npos)
189 std::vector<std::pair<int, float>> lut;
190 for (
size_t i = 3; i < lines.size(); i++)
194 if (sscanf(lines[i].c_str(),
"%d:=%f", &val, &valo) == 2)
196 lut.push_back({val, valo / 100.0});
197 lut_has_1023 |= (val == 1023);
198 lut_has_4095 |= (val == 4095);
199 lut_has_16383 |= (val == 16383);
210 nlohmann::json calib_cfg = pro.get_calibration_raw();
212 calib_cfg[
"bits_for_calib"][channel] = bits_for_calib;
213 calib_cfg[
"to_complete"] =
true;
215 calib_cfg[channel] = lut;
216 pro.set_calibration(
"generic_xrit", calib_cfg);
219 else if (lines[2].find(
"_UNIT:=KELVIN") != std::string::npos)
221 std::vector<std::pair<int, float>> lut;
222 for (
size_t i = 3; i < lines.size(); i++)
226 if (sscanf(lines[i].c_str(),
"%d:=%f", &val, &valo) == 2)
228 lut.push_back({val, valo});
229 lut_has_1023 |= (val == 1023);
230 lut_has_4095 |= (val == 4095);
231 lut_has_16383 |= (val == 16383);
242 nlohmann::json calib_cfg = pro.get_calibration_raw();
244 calib_cfg[
"bits_for_calib"][channel] = bits_for_calib;
245 calib_cfg[
"to_complete"] =
true;
247 calib_cfg[channel] = lut;
248 pro.set_calibration(
"generic_xrit", calib_cfg);
249 pro.
set_channel_unit(pro.images.size() - 1, CALIBRATION_ID_EMISSIVE_RADIANCE);