From fe320422798372f66afcf7eaee90c8bbfc4aa2f3 Mon Sep 17 00:00:00 2001 From: Aang23 Date: Thu, 15 Dec 2022 23:40:35 +0100 Subject: [PATCH] 3E MWTS-3 Fixes --- .../instruments/mwts3/mwts3_reader.cpp | 36 ++++++++++++------- .../projections_settings/fengyun_e_mwts3.json | 2 +- tools/proj_test/main.cpp | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/plugins/fengyun3_support/fengyun3/instruments/mwts3/mwts3_reader.cpp b/plugins/fengyun3_support/fengyun3/instruments/mwts3/mwts3_reader.cpp index e2e6eaf44..1fbf842a5 100644 --- a/plugins/fengyun3_support/fengyun3/instruments/mwts3/mwts3_reader.cpp +++ b/plugins/fengyun3_support/fengyun3/instruments/mwts3/mwts3_reader.cpp @@ -10,7 +10,7 @@ namespace fengyun3 for (int i = 0; i < 18; i++) channels[i].resize(98); - lines = 0; + lines = -1; } MWTS3Reader::~MWTS3Reader() @@ -19,6 +19,16 @@ namespace fengyun3 channels[i].clear(); } + uint16_t convert_val(uint16_t v) + { + bool sign = v >> 15; + int val = v & 0b111111111111111; + if (sign) + return val; + else + return (65536 / 2) + val; + } + void MWTS3Reader::work(ccsds::CCSDSPacket &packet) { if (packet.payload.size() < 1018) @@ -28,16 +38,20 @@ namespace fengyun3 if (marker == 1) { + double currentTime = ccsds::parseCCSDSTimeFullRaw(&packet.payload[2], 10957, 10000, 10000) + 12 * 3600; + timestamps.push_back(currentTime); + lines++; + + // Make sure we have enough room + for (int i = 0; i < 18; i++) + channels[i].resize((lines + 1) * 98); + int pos = 224 + 144 * 2; for (int i = 0; i < 14; i++) { for (int c = 0; c < 18; c++) - channels[c][lines * 98 + i] = packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]; + channels[c][lines * 98 + i] = convert_val(packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]); } - - double currentTime = ccsds::parseCCSDSTimeFullRaw(&packet.payload[2], 10957, 10000, 10000) + 12 * 3600; - timestamps.push_back(currentTime); - lines++; } else if (marker == 2) { @@ -45,7 +59,7 @@ namespace fengyun3 for (int i = 0; i < 28; i++) { for (int c = 0; c < 18; c++) - channels[c][lines * 98 + 14 + i] = packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]; + channels[c][lines * 98 + 14 + i] = convert_val(packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]); } } else if (marker == 3) @@ -54,7 +68,7 @@ namespace fengyun3 for (int i = 0; i < 28; i++) { for (int c = 0; c < 18; c++) - channels[c][lines * 98 + 42 + i] = packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]; + channels[c][lines * 98 + 42 + i] = convert_val(packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]); } } else if (marker == 4) @@ -63,13 +77,9 @@ namespace fengyun3 for (int i = 0; i < 28; i++) { for (int c = 0; c < 18; c++) - channels[c][lines * 98 + 70 + i] = packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]; + channels[c][lines * 98 + 70 + i] = convert_val(packet.payload[pos + (18 * i + c) * 2 + 0] << 8 | packet.payload[pos + (18 * i + c) * 2 + 1]); } } - - // Make sure we have enough room - for (int i = 0; i < 18; i++) - channels[i].resize((lines + 1) * 98); } image::Image MWTS3Reader::getChannel(int channel) diff --git a/resources/projections_settings/fengyun_e_mwts3.json b/resources/projections_settings/fengyun_e_mwts3.json index af20765a7..dbed87788 100644 --- a/resources/projections_settings/fengyun_e_mwts3.json +++ b/resources/projections_settings/fengyun_e_mwts3.json @@ -3,7 +3,7 @@ "scan_angle": 104, "roll_offset": -1, "pitch_offset": 0, - "yaw_offset": -5, + "yaw_offset": -0, "image_width": 98, "gcp_spacing_x": 5, "gcp_spacing_y": 5, diff --git a/tools/proj_test/main.cpp b/tools/proj_test/main.cpp index 7539a9258..63e2d2507 100644 --- a/tools/proj_test/main.cpp +++ b/tools/proj_test/main.cpp @@ -23,7 +23,7 @@ int main(int /*argc*/, char *argv[]) logger->trace("\n" + img_pro.contents.dump(4)); satdump::ImageCompositeCfg rgb_cfg; - rgb_cfg.equation = "1-ch1,1-ch1,1-ch1"; //"(ch3 * 0.4 + ch2 * 0.6) * 2.2 - 0.15, ch2 * 2.2 - 0.15, ch1 * 2.2 - 0.15"; + rgb_cfg.equation = "ch2,ch2,ch2"; //"(ch3 * 0.4 + ch2 * 0.6) * 2.2 - 0.15, ch2 * 2.2 - 0.15, ch1 * 2.2 - 0.15"; rgb_cfg.equalize = true; rgb_cfg.white_balance = true;