Merge PROBA Decoders. Cleanup still to be done

This commit is contained in:
Aang23 2022-04-01 12:51:36 +02:00
parent c7dee6e695
commit e904fcd2e8
15 changed files with 307 additions and 489 deletions

View file

@ -42,7 +42,8 @@
}
},
"products": {
"proba_chris": {
"proba_instruments": {
"satellite": "proba1",
"composites_low": {
"RGB-080502": {
"channels": [
@ -179,7 +180,9 @@
}
},
"products": {
"proba_swap": {}
"proba_instruments": {
"satellite": "proba2"
}
}
}
},

View file

@ -2,9 +2,7 @@
#include "logger.h"
#include "core/module.h"
#include "proba/instruments/swap/module_proba_swap.h"
#include "proba/instruments/chris/module_proba_chris.h"
#include "proba/instruments/hrc/module_proba_hrc.h"
#include "proba/module_proba_instruments.h"
class ProbaSupport : public satdump::Plugin
{
@ -21,9 +19,7 @@ public:
static void registerPluginsHandler(const RegisterModulesEvent &evt)
{
REGISTER_MODULE_EXTERNAL(evt.modules_registry, proba::swap::ProbaSWAPDecoderModule);
REGISTER_MODULE_EXTERNAL(evt.modules_registry, proba::chris::ProbaCHRISDecoderModule);
REGISTER_MODULE_EXTERNAL(evt.modules_registry, proba::hrc::ProbaHRCDecoderModule);
REGISTER_MODULE_EXTERNAL(evt.modules_registry, proba::instruments::PROBAInstrumentsDecoderModule);
}
};

View file

@ -4,6 +4,7 @@
#include <map>
#include "logger.h"
#include "common/image/composite.h"
#include "common/utils.h"
#define ALL_MODE 2
#define WATER_MODE 3
@ -11,26 +12,6 @@
#define CHLOROPHYL_MODE 3
#define LAND_ALL_MODE 100 // Never seen yet...
#define WRITE_IMAGE_LOCAL(image, path) \
image.save_png(std::string(path).c_str()); \
all_images.push_back(path);
template <class InputIt, class T = typename std::iterator_traits<InputIt>::value_type>
T most_common(InputIt begin, InputIt end)
{
std::map<T, int> counts;
for (InputIt it = begin; it != end; ++it)
{
if (counts.find(*it) != counts.end())
++counts[*it];
else
counts[*it] = 1;
}
return std::max_element(counts.begin(), counts.end(), [](const std::pair<T, int> &pair1, const std::pair<T, int> &pair2)
{ return pair1.second < pair2.second; })
->first;
}
namespace proba
{
namespace chris
@ -41,7 +22,7 @@ namespace proba
output_folder = outputfolder;
}
CHRISImageParser::CHRISImageParser(int &count, std::string &outputfolder, std::vector<std::string> &a_images) : count_ref(count), all_images(a_images)
CHRISImageParser::CHRISImageParser(int &count, std::string &outputfolder) : count_ref(count)
{
tempChannelBuffer = new unsigned short[748 * 12096];
mode = 0;
@ -64,10 +45,10 @@ namespace proba
int tx_mode = (packet.payload[2] & 0b00000011) << 2 | packet.payload[3] >> 6;
//logger->info("CH " << channel_marker );
//logger->info("CNT " << count_marker );
//logger->info("MODE " << mode_marker );
//logger->info("TMD " << tx_mode );
// logger->info("CH " << channel_marker );
// logger->info("CNT " << count_marker );
// logger->info("MODE " << mode_marker );
// logger->info("TMD " << tx_mode );
int posb = 16;
@ -162,13 +143,13 @@ namespace proba
int channel_marker = (packet.payload[8 - 6] % (int)pow(2, 3)) << 1 | packet.payload[9 - 6] >> 7;
//logger->info("CH " << channel_marker );
// logger->info("CH " << channel_marker );
// Start new image
if (imageParsers.find(channel_marker) == imageParsers.end())
{
logger->info("Found new CHRIS image! Marker " + std::to_string(channel_marker));
imageParsers.insert(std::pair<int, std::shared_ptr<CHRISImageParser>>(channel_marker, std::make_shared<CHRISImageParser>(count, output_folder, all_images)));
imageParsers.insert(std::pair<int, std::shared_ptr<CHRISImageParser>>(channel_marker, std::make_shared<CHRISImageParser>(count, output_folder)));
imageParsers[channel_marker]->composites_all = composites_all;
imageParsers[channel_marker]->composites_low = composites_low;
}
@ -182,8 +163,8 @@ namespace proba
{
logger->info("Finished CHRIS image! Saving as CHRIS-" + std::to_string(count_ref) + ".png. Mode " + getModeName(mode));
image::Image<uint16_t> img = image::Image<uint16_t>(tempChannelBuffer, current_width, current_height, 1);
img.normalize();
WRITE_IMAGE_LOCAL(img, output_folder + "/CHRIS-" + std::to_string(count_ref) + ".png");
// img.normalize();
img.save_png(output_folder + "/CHRIS-" + std::to_string(count_ref) + ".png");
if (mode == ALL_MODE)
writeAllCompos(img);
@ -231,7 +212,7 @@ namespace proba
expression,
compositeDef);
WRITE_IMAGE_LOCAL(compositeImage, output_folder + "/" + name + ".png");
compositeImage.save_png(output_folder + "/" + name + ".png");
}
}
@ -263,7 +244,7 @@ namespace proba
expression,
compositeDef);
WRITE_IMAGE_LOCAL(compositeImage, output_folder + "/" + name + ".png");
compositeImage.save_png(output_folder + "/" + name + ".png");
}
}

View file

@ -23,15 +23,13 @@ namespace proba
int frame_count;
std::string output_folder;
std::vector<std::string> &all_images;
private:
void writeHighResCompos(image::Image<uint16_t> &img);
void writeAllCompos(image::Image<uint16_t> &img);
std::string getModeName(int mode);
public:
CHRISImageParser(int &count, std::string &outputfolder, std::vector<std::string> &a_images);
CHRISImageParser(int &count, std::string &outputfolder);
~CHRISImageParser();
void save();
void work(ccsds::CCSDSPacket &packet, int &ch);
@ -43,16 +41,16 @@ namespace proba
class CHRISReader
{
private:
int count;
std::map<int, std::shared_ptr<CHRISImageParser>> imageParsers;
std::string output_folder;
public:
std::vector<std::string> all_images;
CHRISReader(std::string &outputfolder);
void work(ccsds::CCSDSPacket &packet);
void save();
int count;
nlohmann::json composites_all;
nlohmann::json composites_low;
};

View file

@ -1,119 +0,0 @@
#include "module_proba_chris.h"
#include <fstream>
#include "chris_reader.h"
#include "common/ccsds/ccsds_1_0_proba/demuxer.h"
#include "common/ccsds/ccsds_1_0_proba/vcdu.h"
#include "logger.h"
#include <filesystem>
#include "imgui/imgui.h"
// Return filesize
size_t getFilesize(std::string filepath);
namespace proba
{
namespace chris
{
ProbaCHRISDecoderModule::ProbaCHRISDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters) : ProcessingModule(input_file, output_file_hint, parameters)
{
}
void ProbaCHRISDecoderModule::process()
{
filesize = getFilesize(d_input_file);
std::ifstream data_in(d_input_file, std::ios::binary);
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/CHRIS";
if (!std::filesystem::exists(directory))
std::filesystem::create_directory(directory);
logger->info("Using input frames " + d_input_file);
logger->info("Decoding to " + directory);
time_t lastTime = 0;
uint8_t buffer[1279];
// CCSDS Demuxer
ccsds::ccsds_1_0_proba::Demuxer ccsdsDemuxer(1103, false);
CHRISReader chris_reader(directory);
chris_reader.composites_all = d_parameters["composites_all"];
chris_reader.composites_low = d_parameters["composites_low"];
logger->info("Demultiplexing and deframing...");
while (!data_in.eof())
{
// Read buffer
data_in.read((char *)buffer, 1279);
int vcid = ccsds::ccsds_1_0_proba::parseVCDU(buffer).vcid;
if (vcid == 1)
{
std::vector<ccsds::CCSDSPacket> pkts = ccsdsDemuxer.work(buffer);
if (pkts.size() > 0)
{
for (ccsds::CCSDSPacket pkt : pkts)
{
if (pkt.header.apid == 2047)
continue;
if (pkt.header.apid == 0)
{
int mode_marker = pkt.payload[9] & 0x03;
if (mode_marker != 1)
chris_reader.work(pkt);
//if (pkt.payload.size() >= 11538)
// data_out.write((char *)pkt.payload.data(), 11538);
}
}
}
}
progress = data_in.tellg();
if (time(NULL) % 10 == 0 && lastTime != time(NULL))
{
lastTime = time(NULL);
logger->info("Progress " + std::to_string(round(((float)progress / (float)filesize) * 1000.0f) / 10.0f) + "%");
}
}
data_in.close();
chris_reader.save();
d_output_files = chris_reader.all_images;
}
void ProbaCHRISDecoderModule::drawUI(bool window)
{
ImGui::Begin("Proba-1 CHRIS Decoder", NULL, window ? NULL : NOWINDOW_FLAGS);
ImGui::ProgressBar((float)progress / (float)filesize, ImVec2(ImGui::GetWindowWidth() - 10, 20 * ui_scale));
ImGui::End();
}
std::string ProbaCHRISDecoderModule::getID()
{
return "proba_chris";
}
std::vector<std::string> ProbaCHRISDecoderModule::getParameters()
{
return {};
}
std::shared_ptr<ProcessingModule> ProbaCHRISDecoderModule::getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
{
return std::make_shared<ProbaCHRISDecoderModule>(input_file, output_file_hint, parameters);
}
} // namespace chris
} // namespace proba

View file

@ -1,27 +0,0 @@
#pragma once
#include "core/module.h"
namespace proba
{
namespace chris
{
class ProbaCHRISDecoderModule : public ProcessingModule
{
protected:
std::atomic<size_t> filesize;
std::atomic<size_t> progress;
public:
ProbaCHRISDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
void process();
void drawUI(bool window);
public:
static std::string getID();
virtual std::string getIDM() { return getID(); };
static std::vector<std::string> getParameters();
static std::shared_ptr<ProcessingModule> getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
};
} // namespace avhrr
} // namespace noaa

View file

@ -1,11 +1,5 @@
#include "hrc_reader.h"
#include <fstream>
#include <iostream>
#include <map>
#define WRITE_IMAGE_LOCAL(image, path) \
image.save_png(std::string(path).c_str()); \
all_images.push_back(path);
#include "logger.h"
namespace proba
{
@ -75,14 +69,14 @@ namespace proba
{
if (frame_count != 0)
{
std::cout << "Finished HRC image! Saving as HRC-" + std::to_string(count) + ".png" << std::endl;
logger->info("Finished HRC image! Saving as HRC-" + std::to_string(count) + ".png");
image::Image<uint16_t> img = image::Image<uint16_t>(tempChannelBuffer, 1072, 1072, 1);
img.save_png(output_folder + "/HRC-" + std::to_string(count) + ".png");
img.normalize();
WRITE_IMAGE_LOCAL(img, output_folder + "/HRC-" + std::to_string(count) + ".png");
img.equalize();
WRITE_IMAGE_LOCAL(img, output_folder + "/HRC-" + std::to_string(count) + "-EQU.png");
img.save_png(output_folder + "/HRC-" + std::to_string(count) + "-EQU.png");
std::fill(&tempChannelBuffer[0], &tempChannelBuffer[748 * 12096], 0);
std::fill(&tempChannelBuffer[0], &tempChannelBuffer[74800 * 12096], 0);
count++;
}
}

View file

@ -13,14 +13,16 @@ namespace proba
{
private:
unsigned short *tempChannelBuffer;
int count;
int frame_count;
std::string output_folder;
public:
std::vector<std::string> all_images;
HRCReader(std::string &outputfolder);
~HRCReader();
int count;
void save();
void work(ccsds::CCSDSPacket &packet);
};

View file

@ -1,116 +0,0 @@
#include "module_proba_hrc.h"
#include <fstream>
#include "hrc_reader.h"
#include "common/ccsds/ccsds_1_0_proba/demuxer.h"
#include "common/ccsds/ccsds_1_0_proba/vcdu.h"
#include "logger.h"
#include <filesystem>
#include "imgui/imgui.h"
// Return filesize
size_t getFilesize(std::string filepath);
namespace proba
{
namespace hrc
{
ProbaHRCDecoderModule::ProbaHRCDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters) : ProcessingModule(input_file, output_file_hint, parameters)
{
}
void ProbaHRCDecoderModule::process()
{
filesize = getFilesize(d_input_file);
std::ifstream data_in(d_input_file, std::ios::binary);
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/HRC";
if (!std::filesystem::exists(directory))
std::filesystem::create_directory(directory);
logger->info("Using input frames " + d_input_file);
logger->info("Decoding to " + directory);
time_t lastTime = 0;
uint8_t buffer[1279];
// CCSDS Demuxer
ccsds::ccsds_1_0_proba::Demuxer ccsdsDemuxer(1103, false);
HRCReader hrc_reader(directory);
logger->info("Demultiplexing and deframing...");
while (!data_in.eof())
{
// Read buffer
data_in.read((char *)buffer, 1279);
int vcid = ccsds::ccsds_1_0_proba::parseVCDU(buffer).vcid;
if (vcid == 1)
{
std::vector<ccsds::CCSDSPacket> pkts = ccsdsDemuxer.work(buffer);
if (pkts.size() > 0)
{
for (ccsds::CCSDSPacket pkt : pkts)
{
if (pkt.header.apid == 2047)
continue;
if (pkt.header.apid == 0)
{
int mode_marker = pkt.payload[9] & 0x03;
if (mode_marker == 1)
hrc_reader.work(pkt);
//if (pkt.payload.size() >= 11538)
// data_out.write((char *)pkt.payload.data(), 11538);
}
}
}
}
progress = data_in.tellg();
if (time(NULL) % 10 == 0 && lastTime != time(NULL))
{
lastTime = time(NULL);
logger->info("Progress " + std::to_string(round(((float)progress / (float)filesize) * 1000.0f) / 10.0f) + "%");
}
}
data_in.close();
hrc_reader.save();
d_output_files = hrc_reader.all_images;
}
void ProbaHRCDecoderModule::drawUI(bool window)
{
ImGui::Begin("Proba-1 HRC Decoder", NULL, window ? NULL : NOWINDOW_FLAGS);
ImGui::ProgressBar((float)progress / (float)filesize, ImVec2(ImGui::GetWindowWidth() - 10, 20 * ui_scale));
ImGui::End();
}
std::string ProbaHRCDecoderModule::getID()
{
return "proba_hrc";
}
std::vector<std::string> ProbaHRCDecoderModule::getParameters()
{
return {};
}
std::shared_ptr<ProcessingModule> ProbaHRCDecoderModule::getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
{
return std::make_shared<ProbaHRCDecoderModule>(input_file, output_file_hint, parameters);
}
} // namespace hrc
} // namespace proba

View file

@ -1,27 +0,0 @@
#pragma once
#include "core/module.h"
namespace proba
{
namespace hrc
{
class ProbaHRCDecoderModule : public ProcessingModule
{
protected:
std::atomic<size_t> filesize;
std::atomic<size_t> progress;
public:
ProbaHRCDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
void process();
void drawUI(bool window);
public:
static std::string getID();
virtual std::string getIDM() { return getID(); };
static std::vector<std::string> getParameters();
static std::shared_ptr<ProcessingModule> getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
};
} // namespace hrc
} // namespace proba

View file

@ -1,115 +0,0 @@
#include "module_proba_swap.h"
#include <fstream>
#include "swap_reader.h"
#include "common/ccsds/ccsds_1_0_proba/demuxer.h"
#include "common/ccsds/ccsds_1_0_proba/vcdu.h"
#include "logger.h"
#include <filesystem>
#include "imgui/imgui.h"
#define WRITE_IMAGE_LOCAL(image, path) \
image.save_png(std::string(path).c_str()); \
all_images.push_back(path);
// Return filesize
size_t getFilesize(std::string filepath);
namespace proba
{
namespace swap
{
ProbaSWAPDecoderModule::ProbaSWAPDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters) : ProcessingModule(input_file, output_file_hint, parameters)
{
}
void ProbaSWAPDecoderModule::process()
{
filesize = getFilesize(d_input_file);
std::ifstream data_in(d_input_file, std::ios::binary);
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/SWAP";
if (!std::filesystem::exists(directory))
std::filesystem::create_directory(directory);
logger->info("Using input frames " + d_input_file);
logger->info("Decoding to " + directory);
time_t lastTime = 0;
uint8_t buffer[1279];
// CCSDS Demuxer
ccsds::ccsds_1_0_proba::Demuxer ccsdsDemuxer(1103, false);
SWAPReader swap_reader(directory);
logger->info("Demultiplexing and deframing...");
while (!data_in.eof())
{
// Read buffer
data_in.read((char *)buffer, 1279);
int vcid = ccsds::ccsds_1_0_proba::parseVCDU(buffer).vcid;
if (vcid == 3)
{
std::vector<ccsds::CCSDSPacket> pkts = ccsdsDemuxer.work(buffer);
if (pkts.size() > 0)
{
for (ccsds::CCSDSPacket pkt : pkts)
{
if (pkt.header.apid == 2047)
continue;
if (pkt.header.apid == 20)
{
swap_reader.work(pkt);
}
}
}
}
progress = data_in.tellg();
if (time(NULL) % 10 == 0 && lastTime != time(NULL))
{
lastTime = time(NULL);
logger->info("Progress " + std::to_string(round(((float)progress / (float)filesize) * 1000.0f) / 10.0f) + "%");
}
}
data_in.close();
swap_reader.save();
d_output_files = swap_reader.all_images;
}
void ProbaSWAPDecoderModule::drawUI(bool window)
{
ImGui::Begin("Proba-2 SWAP Decoder", NULL, window ? NULL : NOWINDOW_FLAGS);
ImGui::ProgressBar((float)progress / (float)filesize, ImVec2(ImGui::GetWindowWidth() - 10, 20 * ui_scale));
ImGui::End();
}
std::string ProbaSWAPDecoderModule::getID()
{
return "proba_swap";
}
std::vector<std::string> ProbaSWAPDecoderModule::getParameters()
{
return {};
}
std::shared_ptr<ProcessingModule> ProbaSWAPDecoderModule::getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
{
return std::make_shared<ProbaSWAPDecoderModule>(input_file, output_file_hint, parameters);
}
} // namespace swap
} // namespace proba

View file

@ -1,27 +0,0 @@
#pragma once
#include "core/module.h"
namespace proba
{
namespace swap
{
class ProbaSWAPDecoderModule : public ProcessingModule
{
protected:
std::atomic<size_t> filesize;
std::atomic<size_t> progress;
public:
ProbaSWAPDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
void process();
void drawUI(bool window);
public:
static std::string getID();
virtual std::string getIDM() { return getID(); };
static std::vector<std::string> getParameters();
static std::shared_ptr<ProcessingModule> getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
};
} // namespace avhrr
} // namespace noaa

View file

@ -11,13 +11,15 @@ namespace proba
class SWAPReader
{
private:
int count;
std::map<time_t, std::pair<int, std::pair<std::string, std::vector<uint8_t>>>> currentOuts;
std::string output_folder;
public:
std::vector<std::string> all_images;
SWAPReader(std::string &outputfolder);
int count;
void work(ccsds::CCSDSPacket &packet);
void save();
};

View file

@ -0,0 +1,224 @@
#include "module_proba_instruments.h"
#include <fstream>
#include "common/ccsds/ccsds_1_0_proba/vcdu.h"
#include "logger.h"
#include <filesystem>
#include "imgui/imgui.h"
#include "common/utils.h"
#include "common/image/bowtie.h"
#include "common/ccsds/ccsds_1_0_proba/demuxer.h"
#include "products/products.h"
namespace proba
{
namespace instruments
{
PROBAInstrumentsDecoderModule::PROBAInstrumentsDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
: ProcessingModule(input_file, output_file_hint, parameters)
{
if (parameters["satellite"] == "proba1")
d_satellite = PROBA_1;
else if (parameters["satellite"] == "proba2")
d_satellite = PROBA_2;
else if (parameters["satellite"] == "probaV")
d_satellite = PROBA_V;
else
throw std::runtime_error("Proba Instruments Decoder : Proba satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");
// Init readers
if (d_satellite == PROBA_1)
{
std::string chris_directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/CHRIS";
std::string hrc_directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/HRC";
if (!std::filesystem::exists(chris_directory))
std::filesystem::create_directory(chris_directory);
if (!std::filesystem::exists(hrc_directory))
std::filesystem::create_directory(hrc_directory);
chris_reader = std::make_unique<chris::CHRISReader>(chris_directory);
hrc_reader = std::make_unique<hrc::HRCReader>(hrc_directory);
chris_reader->composites_all = d_parameters["composites_all"];
chris_reader->composites_low = d_parameters["composites_low"];
}
else if (d_satellite == PROBA_2)
{
std::string swap_directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/SWAP";
if (!std::filesystem::exists(swap_directory))
std::filesystem::create_directory(swap_directory);
swap_reader = std::make_unique<swap::SWAPReader>(swap_directory);
}
}
void PROBAInstrumentsDecoderModule::process()
{
filesize = getFilesize(d_input_file);
std::ifstream data_in(d_input_file, std::ios::binary);
logger->info("Using input frames " + d_input_file);
time_t lastTime = 0;
uint8_t cadu[1279];
// Demuxers
ccsds::ccsds_1_0_proba::Demuxer demuxer_vcid1(1103, false);
ccsds::ccsds_1_0_proba::Demuxer demuxer_vcid3(1103, false);
while (!data_in.eof())
{
// Read buffer
data_in.read((char *)&cadu, 1279);
// Parse this transport frame
ccsds::ccsds_1_0_proba::VCDU vcdu = ccsds::ccsds_1_0_proba::parseVCDU(cadu);
if (vcdu.vcid == 1) // Replay VCID
{
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid1.work(cadu);
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
{
if (d_satellite == PROBA_1)
{
if (pkt.header.apid == 0)
{
int mode_marker = pkt.payload[9] & 0x03;
if (mode_marker == 1)
hrc_reader->work(pkt);
else
chris_reader->work(pkt);
}
}
}
}
else if (vcdu.vcid == 3) // SWAP VCID
{
std::vector<ccsds::CCSDSPacket> ccsdsFrames = demuxer_vcid3.work(cadu);
for (ccsds::CCSDSPacket &pkt : ccsdsFrames)
{
if (d_satellite == PROBA_2)
if (pkt.header.apid == 20)
swap_reader->work(pkt);
}
}
progress = data_in.tellg();
if (time(NULL) % 10 == 0 && lastTime != time(NULL))
{
lastTime = time(NULL);
logger->info("Progress " + std::to_string(round(((float)progress / (float)filesize) * 1000.0f) / 10.0f) + "%");
}
}
data_in.close();
// CHRIS
if (d_satellite == PROBA_1)
{
chris_status = SAVING;
logger->info("----------- CHRIS");
logger->info("Images : {:d}", chris_reader->count);
chris_reader->save();
chris_status = DONE;
}
// HRC
if (d_satellite == PROBA_1)
{
hrc_status = SAVING;
logger->info("----------- HRC");
logger->info("Images : {:d}", hrc_reader->count);
hrc_reader->save();
hrc_status = DONE;
}
// HRC
if (d_satellite == PROBA_2)
{
swap_status = SAVING;
logger->info("----------- SWAP");
logger->info("Images : {:d}", swap_reader->count);
swap_reader->save();
swap_status = DONE;
}
}
void PROBAInstrumentsDecoderModule::drawUI(bool window)
{
ImGui::Begin("Proba Instruments Decoder", NULL, window ? NULL : NOWINDOW_FLAGS);
if (ImGui::BeginTable("##probainstrumentstable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg))
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("Instrument");
ImGui::TableSetColumnIndex(1);
ImGui::Text("Images / Frames");
ImGui::TableSetColumnIndex(2);
ImGui::Text("Status");
if (d_satellite == PROBA_1)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("CHRIS");
ImGui::TableSetColumnIndex(1);
ImGui::TextColored(ImColor(0, 255, 0), "%d", chris_reader->count);
ImGui::TableSetColumnIndex(2);
drawStatus(chris_status);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("HRC");
ImGui::TableSetColumnIndex(1);
ImGui::TextColored(ImColor(0, 255, 0), "%d", hrc_reader->count);
ImGui::TableSetColumnIndex(2);
drawStatus(hrc_status);
}
if (d_satellite == PROBA_2)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("SWAP");
ImGui::TableSetColumnIndex(1);
ImGui::TextColored(ImColor(0, 255, 0), "%d", swap_reader->count);
ImGui::TableSetColumnIndex(2);
drawStatus(swap_status);
}
ImGui::EndTable();
}
ImGui::ProgressBar((float)progress / (float)filesize, ImVec2(ImGui::GetWindowWidth() - 10, 20 * ui_scale));
ImGui::End();
}
std::string PROBAInstrumentsDecoderModule::getID()
{
return "proba_instruments";
}
std::vector<std::string> PROBAInstrumentsDecoderModule::getParameters()
{
return {};
}
std::shared_ptr<ProcessingModule> PROBAInstrumentsDecoderModule::getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
{
return std::make_shared<PROBAInstrumentsDecoderModule>(input_file, output_file_hint, parameters);
}
} // namespace amsu
} // namespace metop

View file

@ -0,0 +1,49 @@
#pragma once
#include "core/module.h"
#include "instruments/chris/chris_reader.h"
#include "instruments/hrc/hrc_reader.h"
#include "instruments/swap/swap_reader.h"
namespace proba
{
namespace instruments
{
class PROBAInstrumentsDecoderModule : public ProcessingModule
{
protected:
enum proba_sat_t
{
PROBA_1,
PROBA_2,
PROBA_V,
};
proba_sat_t d_satellite;
std::atomic<size_t> filesize;
std::atomic<size_t> progress;
// Readers
std::unique_ptr<chris::CHRISReader> chris_reader;
std::unique_ptr<hrc::HRCReader> hrc_reader;
std::unique_ptr<swap::SWAPReader> swap_reader;
// Statuses
instrument_status_t chris_status = DECODING;
instrument_status_t hrc_status = DECODING;
instrument_status_t swap_status = DECODING;
public:
PROBAInstrumentsDecoderModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
void process();
void drawUI(bool window);
public:
static std::string getID();
virtual std::string getIDM() { return getID(); };
static std::vector<std::string> getParameters();
static std::shared_ptr<ProcessingModule> getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters);
};
} // namespace amsu
} // namespace metop