2022-02-28 12:51:55 +01:00
|
|
|
#include "module_eos_instruments.h"
|
2024-08-10 15:50:25 +02:00
|
|
|
#include "common/ccsds/ccsds_aos/demuxer.h"
|
|
|
|
|
#include "common/ccsds/ccsds_aos/vcdu.h"
|
2022-02-28 12:51:55 +01:00
|
|
|
#include "common/utils.h"
|
2025-05-31 20:26:47 +02:00
|
|
|
#include "core/resources.h"
|
|
|
|
|
#include "image/bowtie.h"
|
2025-05-23 12:30:42 +02:00
|
|
|
#include "imgui/imgui.h"
|
2025-09-26 10:25:46 +02:00
|
|
|
#include "init.h"
|
2023-10-23 12:40:08 +02:00
|
|
|
#include "instruments/modis/modis_histmatch.h"
|
2025-05-23 12:30:42 +02:00
|
|
|
#include "logger.h"
|
2024-02-16 22:47:18 +01:00
|
|
|
#include "nlohmann/json_utils.h"
|
2025-07-23 12:21:02 +02:00
|
|
|
#include "products/dataset.h"
|
|
|
|
|
#include "products/image_product.h"
|
2025-05-31 20:26:47 +02:00
|
|
|
#include <cstdint>
|
2025-05-23 12:30:42 +02:00
|
|
|
#include <filesystem>
|
|
|
|
|
#include <fstream>
|
2022-02-28 12:51:55 +01:00
|
|
|
|
2023-11-21 11:28:01 +01:00
|
|
|
#include "common/calibration.h"
|
2024-03-14 12:12:34 +01:00
|
|
|
#include "core/exception.h"
|
2025-05-23 12:30:42 +02:00
|
|
|
#include "instruments/modis/calibrator/modis_calibrator.h"
|
2023-11-21 11:28:01 +01:00
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
#include "common/tracking/tle.h"
|
2025-05-25 14:30:24 +02:00
|
|
|
#include "image/image_utils.h"
|
|
|
|
|
#include "image/io.h"
|
2024-05-08 22:03:25 +02:00
|
|
|
|
2022-02-28 12:51:55 +01:00
|
|
|
namespace eos
|
|
|
|
|
{
|
|
|
|
|
namespace instruments
|
|
|
|
|
{
|
|
|
|
|
EOSInstrumentsDecoderModule::EOSInstrumentsDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
|
2025-05-31 20:26:47 +02:00
|
|
|
: satdump::pipeline::base::FileStreamToFileStreamModule(input_file, output_file_hint, parameters), d_modis_bowtie(d_parameters["modis_bowtie"].get<bool>())
|
2022-02-28 12:51:55 +01:00
|
|
|
{
|
|
|
|
|
if (parameters["satellite"] == "terra")
|
|
|
|
|
d_satellite = TERRA;
|
|
|
|
|
else if (parameters["satellite"] == "aqua")
|
|
|
|
|
d_satellite = AQUA;
|
|
|
|
|
else if (parameters["satellite"] == "aura")
|
|
|
|
|
d_satellite = AURA;
|
|
|
|
|
else
|
2024-03-14 12:12:34 +01:00
|
|
|
throw satdump_exception("EOS Instruments Decoder : EOS satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");
|
2025-05-31 20:26:47 +02:00
|
|
|
fsfsm_enable_output = false;
|
2022-02-28 12:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EOSInstrumentsDecoderModule::process()
|
|
|
|
|
{
|
|
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/MODIS";
|
|
|
|
|
|
|
|
|
|
uint8_t cadu[1024];
|
|
|
|
|
|
|
|
|
|
// Demuxers
|
2024-08-10 15:50:25 +02:00
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid3;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid10;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid15;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid20;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid25;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid26;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid30;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid35;
|
|
|
|
|
ccsds::ccsds_aos::Demuxer demuxer_vcid42;
|
2022-02-28 12:51:55 +01:00
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
while (should_run())
|
2022-02-28 12:51:55 +01:00
|
|
|
{
|
|
|
|
|
// Read buffer
|
2025-05-31 20:26:47 +02:00
|
|
|
read_data((uint8_t *)&cadu, 1024);
|
2022-02-28 12:51:55 +01:00
|
|
|
|
|
|
|
|
// Parse this transport frame
|
2024-08-10 15:50:25 +02:00
|
|
|
ccsds::ccsds_aos::VCDU vcdu = ccsds::ccsds_aos::parseVCDU(cadu);
|
2022-02-28 12:51:55 +01:00
|
|
|
|
|
|
|
|
if (d_satellite == TERRA)
|
|
|
|
|
{
|
|
|
|
|
if (vcdu.vcid == 42) // MODIS
|
|
|
|
|
{
|
|
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid42.work(cadu);
|
|
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
if (pkt.header.apid == 64)
|
|
|
|
|
modis_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (d_satellite == AQUA)
|
|
|
|
|
{
|
2023-10-26 00:05:11 +02:00
|
|
|
if (vcdu.vcid == 3) // GBAD
|
|
|
|
|
{
|
2023-11-02 12:47:34 +01:00
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid3.work(cadu);
|
2023-10-26 00:05:11 +02:00
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
if (pkt.header.apid == 957)
|
|
|
|
|
gbad_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
else if (vcdu.vcid == 30) // MODIS
|
2022-02-28 12:51:55 +01:00
|
|
|
{
|
|
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid30.work(cadu);
|
|
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
if (pkt.header.apid == 64)
|
|
|
|
|
modis_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
else if (vcdu.vcid == 35) // AIRS
|
|
|
|
|
{
|
|
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid35.work(cadu);
|
|
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
if (pkt.header.apid == 404)
|
|
|
|
|
airs_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
else if (vcdu.vcid == 20) // AMSU-A1
|
|
|
|
|
{
|
|
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid20.work(cadu);
|
|
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
if (pkt.header.apid == 261 || pkt.header.apid == 262)
|
|
|
|
|
amsu_a1_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
else if (vcdu.vcid == 25) // AMSU-A2
|
|
|
|
|
{
|
|
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid25.work(cadu);
|
|
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
if (pkt.header.apid == 290)
|
|
|
|
|
amsu_a2_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
else if (vcdu.vcid == 10) // CERES FM-3
|
|
|
|
|
{
|
|
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid10.work(cadu);
|
|
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
if (pkt.header.apid == 141)
|
|
|
|
|
ceres_fm3_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
else if (vcdu.vcid == 15) // CERES FM-4
|
|
|
|
|
{
|
2025-03-13 14:19:35 +01:00
|
|
|
// std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid15.work(cadu);
|
|
|
|
|
// for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
// if (pkt.header.apid == 157)
|
|
|
|
|
// ceres_fm4_reader.work(pkt);
|
2022-02-28 12:51:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (d_satellite == AURA)
|
|
|
|
|
{
|
|
|
|
|
if (vcdu.vcid == 26) // OMI
|
|
|
|
|
{
|
|
|
|
|
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid26.work(cadu);
|
|
|
|
|
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
|
|
|
|
|
{
|
|
|
|
|
if (pkt.header.apid == 1838)
|
|
|
|
|
omi_1_reader.work(pkt);
|
|
|
|
|
else if (pkt.header.apid == 1840)
|
|
|
|
|
omi_2_reader.work(pkt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
cleanup();
|
2022-02-28 12:51:55 +01:00
|
|
|
|
2022-04-26 15:07:18 +02:00
|
|
|
// Products dataset
|
2025-03-13 14:19:35 +01:00
|
|
|
satdump::products::DataSet dataset;
|
2022-04-26 15:07:18 +02:00
|
|
|
if (d_satellite == AQUA)
|
|
|
|
|
dataset.satellite_name = "Aqua";
|
|
|
|
|
else if (d_satellite == TERRA)
|
|
|
|
|
dataset.satellite_name = "Terra";
|
|
|
|
|
else if (d_satellite == AURA)
|
|
|
|
|
dataset.satellite_name = "Aura";
|
|
|
|
|
|
2024-05-24 20:59:18 +02:00
|
|
|
if (d_satellite == AQUA || d_satellite == TERRA) // MODIS
|
2025-05-26 19:21:10 +01:00
|
|
|
dataset.timestamp = satdump::get_median(modis_reader.timestamps_1000);
|
2024-05-24 20:59:18 +02:00
|
|
|
else
|
|
|
|
|
dataset.timestamp = time(0);
|
|
|
|
|
|
2022-05-24 15:03:04 +02:00
|
|
|
std::optional<satdump::TLE> satellite_tle;
|
|
|
|
|
if (d_satellite == AQUA)
|
2025-09-26 10:25:46 +02:00
|
|
|
satellite_tle = satdump::db_tle->get_from_norad_time(27424, dataset.timestamp);
|
2022-05-24 15:03:04 +02:00
|
|
|
else if (d_satellite == TERRA)
|
2025-09-26 10:25:46 +02:00
|
|
|
satellite_tle = satdump::db_tle->get_from_norad_time(25994, dataset.timestamp);
|
2022-05-24 15:03:04 +02:00
|
|
|
else if (d_satellite == AURA)
|
2025-09-26 10:25:46 +02:00
|
|
|
satellite_tle = satdump::db_tle->get_from_norad_time(28376, dataset.timestamp);
|
2022-05-24 15:03:04 +02:00
|
|
|
|
2022-02-28 12:51:55 +01:00
|
|
|
if (d_satellite == AQUA || d_satellite == TERRA) // MODIS
|
|
|
|
|
{
|
|
|
|
|
modis_status = SAVING;
|
|
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/MODIS";
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
|
|
|
|
|
|
|
|
|
logger->info("----------- MODIS");
|
|
|
|
|
logger->info("Lines (1km) : " + std::to_string(modis_reader.lines));
|
|
|
|
|
|
|
|
|
|
// BowTie values
|
|
|
|
|
const float alpha = 1.0 / 1.8;
|
|
|
|
|
const float beta = 0.58333;
|
|
|
|
|
const long scanHeight_250 = 40;
|
|
|
|
|
const long scanHeight_500 = 20;
|
|
|
|
|
const long scanHeight_1000 = 10;
|
|
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
satdump::products::ImageProduct modis_products;
|
2022-03-20 20:56:32 +01:00
|
|
|
modis_products.instrument_name = "modis";
|
2023-10-26 00:05:11 +02:00
|
|
|
nlohmann::json proj_cfg;
|
2022-05-26 16:56:21 +02:00
|
|
|
if (d_satellite == AQUA)
|
2023-10-26 00:05:11 +02:00
|
|
|
proj_cfg = loadJsonFile(resources::getResourcePath("projections_settings/aqua_modis.json"));
|
|
|
|
|
else if (d_satellite == TERRA)
|
|
|
|
|
proj_cfg = loadJsonFile(resources::getResourcePath("projections_settings/terra_modis.json"));
|
|
|
|
|
// if (d_satellite == AQUA)
|
|
|
|
|
// proj_cfg["ephemeris"] = gbad_reader.getEphem();
|
2025-03-13 14:19:35 +01:00
|
|
|
modis_products.set_proj_cfg_tle_timestamps(proj_cfg, satellite_tle, modis_reader.timestamps_250);
|
2022-03-20 20:56:32 +01:00
|
|
|
|
2022-02-28 12:51:55 +01:00
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
|
{
|
2024-05-09 01:16:08 +02:00
|
|
|
image::Image image = modis_reader.getImage250m(i);
|
2023-10-23 12:40:08 +02:00
|
|
|
// modis::modis_match_detector_histograms(image, 1 /*4*/, 40 * 2);
|
2022-02-28 12:51:55 +01:00
|
|
|
if (d_modis_bowtie)
|
2024-05-09 01:16:08 +02:00
|
|
|
image = image::bowtie::correctGenericBowTie(image, 1, scanHeight_250, alpha, beta);
|
2025-03-13 14:19:35 +01:00
|
|
|
modis_products.images.push_back({i, "MODIS-" + std::to_string(i + 1), std::to_string(i + 1), image, 12});
|
2022-02-28 12:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
2024-05-09 01:16:08 +02:00
|
|
|
image::Image image = modis_reader.getImage500m(i);
|
2023-10-23 12:40:08 +02:00
|
|
|
// modis::modis_match_detector_histograms(image, 1 /*2*/, 20 * 2);
|
2022-02-28 12:51:55 +01:00
|
|
|
if (d_modis_bowtie)
|
2024-05-09 01:16:08 +02:00
|
|
|
image = image::bowtie::correctGenericBowTie(image, 1, scanHeight_500, alpha, beta);
|
2025-03-22 16:06:15 +01:00
|
|
|
modis_products.images.push_back({i + 2, "MODIS-" + std::to_string(i + 3), std::to_string(i + 3), image, 12, satdump::ChannelTransform().init_affine(2, 2, 0, 0)});
|
2022-02-28 12:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
2023-11-25 17:42:54 +01:00
|
|
|
std::vector<std::vector<int>> bowtie_lut_1km;
|
2022-02-28 12:51:55 +01:00
|
|
|
for (int i = 0; i < 31; i++)
|
|
|
|
|
{
|
2024-05-09 01:16:08 +02:00
|
|
|
image::Image image = modis_reader.getImage1000m(i);
|
2022-02-28 12:51:55 +01:00
|
|
|
|
2023-10-23 12:40:08 +02:00
|
|
|
// modis::modis_match_detector_histograms(image, 1, 10 * 2);
|
|
|
|
|
|
2023-11-25 17:42:54 +01:00
|
|
|
if (d_modis_bowtie)
|
2024-05-09 01:16:08 +02:00
|
|
|
image = image::bowtie::correctGenericBowTie(image, 1, scanHeight_1000, alpha, beta, &bowtie_lut_1km);
|
2022-02-28 12:51:55 +01:00
|
|
|
|
2025-03-22 16:06:15 +01:00
|
|
|
auto cht = satdump::ChannelTransform().init_affine(4, 4, 0, 0);
|
|
|
|
|
|
2022-02-28 12:51:55 +01:00
|
|
|
if (i < 5)
|
2025-03-22 16:06:15 +01:00
|
|
|
modis_products.images.push_back({i + 7, "MODIS-" + std::to_string(i + 8), std::to_string(i + 8), image, 12, cht});
|
2022-02-28 12:51:55 +01:00
|
|
|
else if (i == 5)
|
2025-03-22 16:06:15 +01:00
|
|
|
modis_products.images.push_back({i + 7, "MODIS-13L", "13L", image, 12, cht});
|
2022-02-28 12:51:55 +01:00
|
|
|
else if (i == 6)
|
2025-03-22 16:06:15 +01:00
|
|
|
modis_products.images.push_back({i + 7, "MODIS-13H", "13H", image, 12, cht});
|
2022-02-28 12:51:55 +01:00
|
|
|
else if (i == 7)
|
2025-03-22 16:06:15 +01:00
|
|
|
modis_products.images.push_back({i + 7, "MODIS-14L", "14L", image, 12, cht});
|
2022-02-28 12:51:55 +01:00
|
|
|
else if (i == 8)
|
2025-03-22 16:06:15 +01:00
|
|
|
modis_products.images.push_back({i + 7, "MODIS-14H", "14H", image, 12, cht});
|
2022-02-28 12:51:55 +01:00
|
|
|
else
|
2025-03-22 16:06:15 +01:00
|
|
|
modis_products.images.push_back({i + 7, "MODIS-" + std::to_string(i + 6), std::to_string(i + 6), image, 12, cht});
|
2022-02-28 12:51:55 +01:00
|
|
|
}
|
2022-03-20 20:56:32 +01:00
|
|
|
|
2023-11-21 11:28:01 +01:00
|
|
|
// Calibration
|
|
|
|
|
nlohmann::json calib_cfg;
|
2023-11-25 17:18:04 +01:00
|
|
|
calib_cfg["vars"] = modis::precompute::precomputeVars(&modis_products, modis_reader.getCalib(), d_satellite == AQUA);
|
2023-11-21 20:04:39 +01:00
|
|
|
calib_cfg["is_aqua"] = d_satellite == AQUA;
|
2023-11-25 17:42:54 +01:00
|
|
|
calib_cfg["bowtie_lut_1km"] = bowtie_lut_1km;
|
2025-03-13 14:19:35 +01:00
|
|
|
modis_products.set_calibration("eos_modis", calib_cfg);
|
2023-11-21 11:28:01 +01:00
|
|
|
for (int i = 0; i < 21; i++)
|
2025-03-13 14:19:35 +01:00
|
|
|
modis_products.set_channel_unit(i, CALIBRATION_ID_REFLECTIVE_RADIANCE);
|
2023-11-21 11:28:01 +01:00
|
|
|
for (int i = 21; i < 38; i++)
|
2025-03-13 14:19:35 +01:00
|
|
|
modis_products.set_channel_unit(i, CALIBRATION_ID_EMISSIVE_RADIANCE);
|
|
|
|
|
modis_products.set_channel_unit(27, CALIBRATION_ID_REFLECTIVE_RADIANCE);
|
2023-11-21 11:28:01 +01:00
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
// for (int i = 0; i < 38; i++)
|
|
|
|
|
// { // Set to 0 for now
|
|
|
|
|
// modis_products.set_channel_wavenumber(i, -1);
|
|
|
|
|
// }
|
2023-11-25 19:02:32 +01:00
|
|
|
|
|
|
|
|
auto modis_table = loadJsonFile(resources::getResourcePath("calibration/modis_table.json"));
|
2023-11-21 11:28:01 +01:00
|
|
|
|
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
|
{
|
|
|
|
|
int ch = i;
|
|
|
|
|
if (ch >= 6)
|
|
|
|
|
ch++;
|
2025-05-23 12:30:42 +02:00
|
|
|
modis_products.set_channel_wavenumber(21 + ch, freq_to_wavenumber(SPEED_OF_LIGHT_M_S / modis_table["wavelengths"][i].get<double>()));
|
2023-11-21 11:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-20 20:56:32 +01:00
|
|
|
modis_products.save(directory);
|
2022-04-26 15:07:18 +02:00
|
|
|
dataset.products_list.push_back("MODIS");
|
2022-03-20 20:56:32 +01:00
|
|
|
|
2022-02-28 12:51:55 +01:00
|
|
|
modis_status = DONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d_satellite == AQUA) // AIRS
|
|
|
|
|
{
|
|
|
|
|
airs_status = SAVING;
|
2022-05-24 15:03:04 +02:00
|
|
|
std::string directory_hd = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/AIRS/HD";
|
2022-02-28 12:51:55 +01:00
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/AIRS";
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
2022-05-24 15:03:04 +02:00
|
|
|
if (!std::filesystem::exists(directory_hd))
|
|
|
|
|
std::filesystem::create_directory(directory_hd);
|
2022-02-28 12:51:55 +01:00
|
|
|
|
|
|
|
|
logger->info("----------- AIRS");
|
|
|
|
|
logger->info("Lines : " + std::to_string(airs_reader.lines));
|
|
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
satdump::products::ImageProduct airs_hd_products;
|
2022-05-24 15:03:04 +02:00
|
|
|
airs_hd_products.instrument_name = "airs_hd";
|
2025-03-13 14:19:35 +01:00
|
|
|
airs_hd_products.set_proj_cfg_tle_timestamps(loadJsonFile(resources::getResourcePath("projections_settings/aqua_airs.json")), satellite_tle, airs_reader.timestamps_ifov);
|
2022-05-24 15:03:04 +02:00
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
2025-03-13 14:19:35 +01:00
|
|
|
airs_hd_products.images.push_back({i, "AIRS-HD-" + std::to_string(i + 1), std::to_string(i + 1), airs_reader.getHDChannel(i), 16});
|
2022-05-24 15:03:04 +02:00
|
|
|
|
|
|
|
|
airs_hd_products.save(directory_hd);
|
|
|
|
|
dataset.products_list.push_back("AIRS/HD");
|
2022-03-20 20:56:32 +01:00
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
satdump::products::ImageProduct airs_products;
|
2022-03-20 20:56:32 +01:00
|
|
|
airs_products.instrument_name = "airs";
|
2022-05-24 15:03:04 +02:00
|
|
|
airs_products.save_as_matrix = true;
|
2025-03-13 14:19:35 +01:00
|
|
|
airs_products.set_proj_cfg_tle_timestamps(loadJsonFile(resources::getResourcePath("projections_settings/aqua_airs.json")), satellite_tle, airs_reader.timestamps_ifov);
|
2022-03-20 20:56:32 +01:00
|
|
|
|
2022-05-24 15:03:04 +02:00
|
|
|
for (int i = 0; i < 2666; i++)
|
2025-03-13 14:19:35 +01:00
|
|
|
airs_products.images.push_back({i, "AIRS-" + std::to_string(i + 1), std::to_string(i + 1), airs_reader.getChannel(i), 16});
|
2022-03-20 20:56:32 +01:00
|
|
|
|
|
|
|
|
airs_products.save(directory);
|
2022-05-24 15:03:04 +02:00
|
|
|
dataset.products_list.push_back("AIRS");
|
2022-02-28 12:51:55 +01:00
|
|
|
|
|
|
|
|
airs_status = DONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d_satellite == AQUA) // AMSU
|
|
|
|
|
{
|
|
|
|
|
amsu_status = SAVING;
|
|
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/AMSU";
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
|
|
|
|
|
|
|
|
|
logger->info("----------- AMSU");
|
|
|
|
|
logger->info("Lines (AMSU A1) : " + std::to_string(amsu_a1_reader.lines));
|
|
|
|
|
logger->info("Lines (AMSU A2) : " + std::to_string(amsu_a2_reader.lines));
|
|
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
satdump::products::ImageProduct amsu_products;
|
2022-05-24 15:03:04 +02:00
|
|
|
amsu_products.instrument_name = "amsu_a";
|
2025-03-13 14:19:35 +01:00
|
|
|
amsu_products.set_proj_cfg_tle_timestamps(loadJsonFile(resources::getResourcePath("projections_settings/aqua_amsu.json")), satellite_tle, amsu_a1_reader.timestamps);
|
|
|
|
|
// TODOREWORK CORRELATE AMSU
|
|
|
|
|
logger->critical(" TODOREWORK CORRELATE AMSU. If you see this, PLEASE REPORT");
|
2022-05-24 15:03:04 +02:00
|
|
|
|
2022-02-28 12:51:55 +01:00
|
|
|
for (int i = 0; i < 2; i++)
|
2025-03-13 14:19:35 +01:00
|
|
|
amsu_products.images.push_back({i, "AMSU-A2-" + std::to_string(i + 1), std::to_string(i + 1), amsu_a2_reader.getChannel(i), 16});
|
2022-02-28 12:51:55 +01:00
|
|
|
|
|
|
|
|
for (int i = 0; i < 13; i++)
|
2025-03-13 14:19:35 +01:00
|
|
|
amsu_products.images.push_back({i + 2, "AMSU-A1-" + std::to_string(i + 1), std::to_string(i + 3), amsu_a1_reader.getChannel(i), 16});
|
2022-05-24 15:03:04 +02:00
|
|
|
|
|
|
|
|
amsu_products.save(directory);
|
|
|
|
|
dataset.products_list.push_back("AMSU");
|
|
|
|
|
|
2022-02-28 12:51:55 +01:00
|
|
|
amsu_status = DONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d_satellite == AQUA) // CERES FM-3 and FM-4
|
|
|
|
|
{
|
|
|
|
|
ceres_fm3_status = ceres_fm4_status = SAVING;
|
|
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/CERES";
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
|
|
|
|
|
|
|
|
|
logger->info("----------- CERES");
|
|
|
|
|
logger->info("Lines (FM3) : " + std::to_string(ceres_fm3_reader.lines));
|
|
|
|
|
logger->info("Lines (FM4) : " + std::to_string(ceres_fm4_reader.lines));
|
|
|
|
|
|
1980-01-01 00:00:00 +00:00
|
|
|
{
|
|
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/CERES-FM3";
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
|
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
satdump::products::ImageProduct ceres_products;
|
1980-01-01 00:00:00 +00:00
|
|
|
ceres_products.instrument_name = "ceres";
|
2025-03-13 14:19:35 +01:00
|
|
|
ceres_products.set_proj_cfg_tle_timestamps(loadJsonFile(resources::getResourcePath("projections_settings/aqua_ceres_fm3.json")), satellite_tle, ceres_fm3_reader.timestamps);
|
1980-01-01 00:00:00 +00:00
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
ceres_products.images.push_back({0, "CERES-LONGWAVE", "l", ceres_fm3_reader.getImage(0), 16});
|
|
|
|
|
ceres_products.images.push_back({1, "CERES-SHORTWAVE", "s", ceres_fm3_reader.getImage(1), 16});
|
|
|
|
|
ceres_products.images.push_back({2, "CERES-TOTAL", "t", ceres_fm3_reader.getImage(2), 16});
|
1980-01-01 00:00:00 +00:00
|
|
|
|
|
|
|
|
ceres_products.save(directory);
|
|
|
|
|
dataset.products_list.push_back("CERES-FM3");
|
|
|
|
|
ceres_fm3_status = DONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/CERES-FM4";
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
|
|
|
|
|
2025-03-13 14:19:35 +01:00
|
|
|
satdump::products::ImageProduct ceres_products;
|
1980-01-01 00:00:00 +00:00
|
|
|
ceres_products.instrument_name = "ceres";
|
2025-03-13 14:19:35 +01:00
|
|
|
ceres_products.set_proj_cfg_tle_timestamps(loadJsonFile(resources::getResourcePath("projections_settings/aqua_ceres_fm4.json")), satellite_tle, ceres_fm4_reader.timestamps);
|
|
|
|
|
|
|
|
|
|
ceres_products.images.push_back({0, "CERES-LONGWAVE", "l", ceres_fm4_reader.getImage(0), 16});
|
|
|
|
|
ceres_products.images.push_back({1, "CERES-SHORTWAVE", "s", ceres_fm4_reader.getImage(1), 16});
|
|
|
|
|
ceres_products.images.push_back({2, "CERES-TOTAL", "t", ceres_fm4_reader.getImage(2), 16});
|
1980-01-01 00:00:00 +00:00
|
|
|
|
|
|
|
|
ceres_products.save(directory);
|
|
|
|
|
dataset.products_list.push_back("CERES-FM4");
|
|
|
|
|
ceres_fm3_status = DONE;
|
|
|
|
|
}
|
2022-02-28 12:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d_satellite == AURA) // OMI
|
|
|
|
|
{
|
|
|
|
|
omi_status = SAVING;
|
|
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/OMI";
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
|
|
|
|
|
|
|
|
|
logger->info("----------- OMI");
|
|
|
|
|
logger->info("Lines (UV) : " + std::to_string(omi_1_reader.lines));
|
|
|
|
|
logger->info("Lines (VIS) : " + std::to_string(omi_2_reader.lines));
|
|
|
|
|
|
2024-05-08 22:03:25 +02:00
|
|
|
auto img = omi_1_reader.getImageRaw();
|
2024-05-09 01:16:08 +02:00
|
|
|
image::save_img(img, directory + "/OMI-1");
|
2024-05-08 22:03:25 +02:00
|
|
|
img = omi_2_reader.getImageRaw();
|
2024-05-09 01:16:08 +02:00
|
|
|
image::save_img(img, directory + "/OMI-2");
|
2024-05-08 22:03:25 +02:00
|
|
|
|
|
|
|
|
img = omi_1_reader.getImageVisible();
|
2024-05-09 01:16:08 +02:00
|
|
|
image::save_img(img, directory + "/OMI-VIS-1");
|
2024-05-08 22:03:25 +02:00
|
|
|
img = omi_2_reader.getImageVisible();
|
2024-05-09 01:16:08 +02:00
|
|
|
image::save_img(img, directory + "/OMI-VIS-2");
|
2024-05-08 22:03:25 +02:00
|
|
|
|
2025-05-23 12:30:42 +02:00
|
|
|
image::Image imageAll1 = image::make_manyimg_composite(33, 24, 792, [this](int c) { return omi_1_reader.getChannel(c); });
|
|
|
|
|
image::Image imageAll2 = image::make_manyimg_composite(33, 24, 792, [this](int c) { return omi_2_reader.getChannel(c); });
|
2024-05-09 01:16:08 +02:00
|
|
|
image::save_img(imageAll1, directory + "/OMI-ALL-1");
|
|
|
|
|
image::save_img(imageAll2, directory + "/OMI-ALL-2");
|
2022-02-28 12:51:55 +01:00
|
|
|
omi_status = DONE;
|
|
|
|
|
}
|
2022-04-26 15:07:18 +02:00
|
|
|
|
|
|
|
|
dataset.save(d_output_file_hint.substr(0, d_output_file_hint.rfind('/')));
|
2022-02-28 12:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EOSInstrumentsDecoderModule::drawUI(bool window)
|
|
|
|
|
{
|
2022-09-02 01:59:13 +02:00
|
|
|
ImGui::Begin("EOS Instruments Decoder", NULL, window ? 0 : NOWINDOW_FLAGS);
|
2022-02-28 12:51:55 +01:00
|
|
|
|
|
|
|
|
if (ImGui::BeginTable("##eosinstrumentstable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg))
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("Instrument");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
ImGui::Text("Lines / Frames");
|
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
ImGui::Text("Status");
|
|
|
|
|
|
|
|
|
|
if (d_satellite == TERRA || d_satellite == AQUA)
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("MODIS");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", modis_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(modis_status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d_satellite == AQUA)
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("AIRS");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", airs_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(airs_status);
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("AMSU A1");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", amsu_a1_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(amsu_status);
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("AMSU A2");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", amsu_a2_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(amsu_status);
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("CERES FM-3");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", ceres_fm3_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(ceres_fm3_status);
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("CERES FM-4");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", ceres_fm4_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(ceres_fm4_status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d_satellite == AURA)
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("OMI 1");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", omi_1_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(omi_status);
|
|
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
|
|
ImGui::Text("OMI 2");
|
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
2024-01-21 14:57:41 -05:00
|
|
|
ImGui::TextColored(style::theme.green, "%d", omi_2_reader.lines);
|
2022-02-28 12:51:55 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
drawStatus(omi_status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
drawProgressBar();
|
2022-02-28 12:51:55 +01:00
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 12:30:42 +02:00
|
|
|
std::string EOSInstrumentsDecoderModule::getID() { return "eos_instruments"; }
|
2022-02-28 12:51:55 +01:00
|
|
|
|
2025-05-31 20:26:47 +02:00
|
|
|
std::shared_ptr<satdump::pipeline::ProcessingModule> EOSInstrumentsDecoderModule::getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
|
2022-02-28 12:51:55 +01:00
|
|
|
{
|
|
|
|
|
return std::make_shared<EOSInstrumentsDecoderModule>(input_file, output_file_hint, parameters);
|
|
|
|
|
}
|
2025-05-23 12:30:42 +02:00
|
|
|
} // namespace instruments
|
2022-02-28 12:51:55 +01:00
|
|
|
} // namespace eos
|