mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
Basic radiation processing
This commit is contained in:
parent
c9f1daa5f5
commit
677e82c8ff
8 changed files with 112 additions and 12 deletions
|
|
@ -292,7 +292,15 @@
|
|||
},
|
||||
"sem": {
|
||||
"handler": "radiation_handler",
|
||||
"name": "SEM"
|
||||
"name": "SEM",
|
||||
"radiation_maps": {
|
||||
"ch1": {
|
||||
"channel": 1,
|
||||
"radius": 5,
|
||||
"min": 0,
|
||||
"max": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"ocm_oc2": {
|
||||
"handler": "image_handler",
|
||||
|
|
|
|||
42
src-core/products/processor/radiation_processor.cpp
Normal file
42
src-core/products/processor/radiation_processor.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include "processor.h"
|
||||
|
||||
#include "logger.h"
|
||||
#include "../radiation_products.h"
|
||||
#include "core/config.h"
|
||||
|
||||
namespace satdump
|
||||
{
|
||||
void process_radiation_products(Products *products, std::string product_path)
|
||||
{
|
||||
RadiationProducts *rad_products = (RadiationProducts *)products;
|
||||
|
||||
// Get instrument settings
|
||||
nlohmann::ordered_json instrument_viewer_settings;
|
||||
if (config::main_cfg["viewer"]["instruments"].contains(products->instrument_name))
|
||||
instrument_viewer_settings = config::main_cfg["viewer"]["instruments"][products->instrument_name];
|
||||
else
|
||||
logger->error("Unknown instrument : {:s}!", products->instrument_name);
|
||||
|
||||
// TMP
|
||||
if (instrument_viewer_settings.contains("radiation_maps"))
|
||||
{
|
||||
for (nlohmann::detail::iteration_proxy_value<nlohmann::detail::iter_impl<nlohmann::ordered_json>> compo : instrument_viewer_settings["radiation_maps"].items())
|
||||
{
|
||||
// rgb_presets.push_back({compo.key(), compo.value().get<ImageCompositeCfg>()});
|
||||
std::string initial_name = compo.key();
|
||||
std::replace(initial_name.begin(), initial_name.end(), ' ', '_');
|
||||
std::replace(initial_name.begin(), initial_name.end(), '/', '_');
|
||||
|
||||
RadiationMapCfg cfg = compo.value().get<RadiationMapCfg>();
|
||||
image::Image<uint16_t> rad_map = satdump::make_radiation_map(*rad_products, cfg);
|
||||
|
||||
std::string name = products->instrument_name +
|
||||
"_map_" +
|
||||
initial_name + ".png";
|
||||
|
||||
logger->info("Saving " + product_path + "/" + name);
|
||||
rad_map.save_png(product_path + "/" + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src-core/products/processor/radiation_processor.h
Normal file
8
src-core/products/processor/radiation_processor.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "../products.h"
|
||||
|
||||
namespace satdump
|
||||
{
|
||||
void process_radiation_products(Products *products, std::string product_path);
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#include "radiation_products.h"
|
||||
#include "core/plugin.h"
|
||||
#include "processor/image_processor.h"
|
||||
#include "processor/radiation_processor.h"
|
||||
|
||||
namespace satdump
|
||||
{
|
||||
|
|
@ -74,6 +75,7 @@ namespace satdump
|
|||
{
|
||||
products_loaders.clear();
|
||||
products_loaders.emplace("image", RegisteredProducts{PRODUCTS_LOADER_FUN(ImageProducts), process_image_products});
|
||||
products_loaders.emplace("radiation", RegisteredProducts{PRODUCTS_LOADER_FUN(RadiationProducts), process_radiation_products});
|
||||
|
||||
// Plugins!
|
||||
eventBus->fire_event<RegisterProductsEvent>({products_loaders});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "radiation_products.h"
|
||||
#include "logger.h"
|
||||
#include "common/tracking/tracking.h"
|
||||
#include "resources.h"
|
||||
|
||||
namespace satdump
|
||||
{
|
||||
|
|
@ -21,10 +22,15 @@ namespace satdump
|
|||
channel_counts = contents["counts"].get<std::vector<std::vector<int>>>();
|
||||
}
|
||||
|
||||
void make_radiation_map(RadiationProducts &products, int channel, image::Image<uint16_t> &initial_map, int radius, image::Image<uint16_t> color_lut, int min, int max)
|
||||
image::Image<uint16_t> make_radiation_map(RadiationProducts &products, RadiationMapCfg cfg, float *progress)
|
||||
{
|
||||
int img_x = initial_map.width();
|
||||
int img_y = initial_map.height();
|
||||
image::Image<uint16_t> map;
|
||||
map.load_jpeg(resources::getResourcePath("maps/nasa.jpg").c_str());
|
||||
image::Image<uint16_t> color_lut = image::LUT_jet<uint16_t>();
|
||||
|
||||
int img_x = map.width();
|
||||
int img_y = map.height();
|
||||
int channel = cfg.channel - 1;
|
||||
|
||||
int lut_size = color_lut.width();
|
||||
std::vector<double> timestamps = products.get_timestamps(channel);
|
||||
|
|
@ -33,7 +39,7 @@ namespace satdump
|
|||
|
||||
for (int samplec = 0; samplec < (int)products.channel_counts[channel].size(); samplec++)
|
||||
{
|
||||
int value = (double(products.channel_counts[channel][samplec] - min) / max) * lut_size;
|
||||
int value = (double(products.channel_counts[channel][samplec] - cfg.min) / cfg.max) * lut_size;
|
||||
|
||||
// logger->info("{:d} {:d}", products.channel_counts[channel][samplec], value);
|
||||
|
||||
|
|
@ -50,7 +56,12 @@ namespace satdump
|
|||
|
||||
uint16_t color[] = {color_lut.channel(0)[value], color_lut.channel(1)[value], color_lut.channel(2)[value]};
|
||||
|
||||
initial_map.draw_circle(image_x, image_y, radius, color, true);
|
||||
map.draw_circle(image_x, image_y, cfg.radius, color, true);
|
||||
|
||||
if (progress != nullptr)
|
||||
*progress = float(samplec) / float(products.channel_counts[channel].size());
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,5 +54,30 @@ namespace satdump
|
|||
virtual void load(std::string file);
|
||||
};
|
||||
|
||||
void make_radiation_map(RadiationProducts &products, int channel, image::Image<uint16_t> &map, int radius, image::Image<uint16_t> color_lut, int min, int max);
|
||||
// Map handling
|
||||
struct RadiationMapCfg
|
||||
{
|
||||
int channel;
|
||||
int radius;
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
|
||||
inline void to_json(nlohmann::json &j, const RadiationMapCfg &v)
|
||||
{
|
||||
j["channel"] = v.channel;
|
||||
j["radius"] = v.radius;
|
||||
j["min"] = v.min;
|
||||
j["max"] = v.max;
|
||||
}
|
||||
|
||||
inline void from_json(const nlohmann::json &j, RadiationMapCfg &v)
|
||||
{
|
||||
v.channel = j["channel"].get<int>();
|
||||
v.radius = j["radius"].get<int>();
|
||||
v.min = j["min"].get<int>();
|
||||
v.max = j["max"].get<int>();
|
||||
}
|
||||
|
||||
image::Image<uint16_t> make_radiation_map(RadiationProducts &products, RadiationMapCfg cfg, float *progress = nullptr);
|
||||
}
|
||||
|
|
@ -20,9 +20,13 @@ namespace satdump
|
|||
{
|
||||
if (selected_visualization_id == 0)
|
||||
{
|
||||
image::Image<uint16_t> map;
|
||||
map.load_jpeg(resources::getResourcePath("maps/nasa.jpg").c_str());
|
||||
make_radiation_map(*products, select_channel_image_id, map, 5, image::LUT_jet<uint16_t>(), map_min, map_max);
|
||||
|
||||
RadiationMapCfg cfg;
|
||||
cfg.channel = select_channel_image_id + 1;
|
||||
cfg.radius = 5;
|
||||
cfg.min = map_min;
|
||||
cfg.max = map_max;
|
||||
image::Image<uint16_t> map = make_radiation_map(*products, cfg);
|
||||
image_view.update(map);
|
||||
}
|
||||
else if (selected_visualization_id == 1)
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
satdump::registerProducts();
|
||||
|
||||
// satdump::process_dataset("metop_ahrpt_new/dataset.json");
|
||||
satdump::process_dataset("metop_ahrpt_new/dataset.json");
|
||||
// satdump::process_dataset("jpss_bb_test/dataset.json");
|
||||
satdump::process_dataset("m22_proj_test1/dataset.json");
|
||||
// satdump::process_dataset("m22_proj_test1/dataset.json");
|
||||
|
||||
/*
|
||||
satdump::ImageProducts img_pro;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue