mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
Autodetect FY-3 satellite when necessary
This commit is contained in:
parent
ff29d30cc2
commit
ee14280a55
7 changed files with 206 additions and 1 deletions
|
|
@ -136,6 +136,7 @@
|
|||
}
|
||||
},
|
||||
"products": {
|
||||
"fengyun_satid": {},
|
||||
"fengyun_virr": {},
|
||||
"fengyun_erm": {},
|
||||
"fengyun_mwhs": {},
|
||||
|
|
@ -182,6 +183,7 @@
|
|||
}
|
||||
},
|
||||
"products": {
|
||||
"fengyun_satid": {},
|
||||
"fengyun_virr": {},
|
||||
"fengyun_erm": {},
|
||||
"fengyun_mwhs": {}
|
||||
|
|
@ -223,6 +225,9 @@
|
|||
}
|
||||
},
|
||||
"products": {
|
||||
"fengyun_satid": {
|
||||
"scid_hint": "51"
|
||||
},
|
||||
"fengyun_virr": {},
|
||||
"fengyun_erm": {},
|
||||
"fengyun_mwhs2": {}
|
||||
|
|
@ -268,6 +273,9 @@
|
|||
}
|
||||
},
|
||||
"products": {
|
||||
"fengyun_satid": {
|
||||
"scid_hint": "51"
|
||||
},
|
||||
"fengyun_virr": {},
|
||||
"fengyun_erm": {},
|
||||
"fengyun_mwhs2": {}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@
|
|||
}
|
||||
},
|
||||
"products": {
|
||||
"fengyun_satid": {
|
||||
"scid_hint": "52"
|
||||
},
|
||||
"fengyun_mersi2": {
|
||||
"correct_bowtie": "1"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ SATDUMP_DLL std::map<std::string, std::function<std::shared_ptr<ProcessingModule
|
|||
#include "modules/fengyun/instruments/mwri/module_fengyun_mwri.h"
|
||||
#include "modules/fengyun/instruments/mwts/module_fengyun_mwts.h"
|
||||
#include "modules/fengyun/instruments/mwhs2/module_fengyun_mwhs2.h"
|
||||
#include "modules/fengyun/module_fengyun_satid.h"
|
||||
|
||||
#include "modules/aqua/module_aqua_db_decoder.h"
|
||||
#include "modules/aqua/instruments/airs/module_aqua_airs.h"
|
||||
|
|
@ -193,6 +194,7 @@ void registerModules()
|
|||
REGISTER_MODULE(fengyun::mwri::FengyunMWRIDecoderModule);
|
||||
REGISTER_MODULE(fengyun::mwts::FengyunMWTSDecoderModule);
|
||||
REGISTER_MODULE(fengyun::mwhs2::FengyunMWHS2DecoderModule);
|
||||
REGISTER_MODULE(fengyun::satid::FengYunSatIDModule);
|
||||
|
||||
// Aqua
|
||||
REGISTER_MODULE(aqua::AquaDBDecoderModule);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#define FY3_A_SCID 49
|
||||
#define FY3_B_SCID 50
|
||||
#define FY3_C_SCID 51
|
||||
#define FY3_D_SCID 52
|
||||
|
||||
#define FY3_A_NORAD 32958
|
||||
#define FY3_B_NORAD 37214
|
||||
#define FY3_C_NORAD 39260
|
||||
#define FY3_D_NORAD 43010
|
||||
|
||||
#define FY3_ORBIT_HEIGHT 842
|
||||
|
||||
#define FY3_VIRR_SWATH 2800
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "imgui/imgui.h"
|
||||
#include "common/image/earth_curvature.h"
|
||||
#include "modules/fengyun/fengyun3.h"
|
||||
#include "nlohmann/json_utils.h"
|
||||
|
||||
#define BUFFER_SIZE 8192
|
||||
|
||||
|
|
@ -63,7 +64,21 @@ namespace fengyun
|
|||
|
||||
logger->info("Demultiplexing and deframing...");
|
||||
|
||||
std::string c10_filename = "FY3x_" + getHRPTReaderTimeStamp() + ".C10";
|
||||
// Get satellite info
|
||||
nlohmann::json satData = loadJsonFile(d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/sat_info.json");
|
||||
int scid = satData.contains("scid") > 0 ? satData["scid"].get<int>() : 0;
|
||||
|
||||
// Name the file properly
|
||||
std::string hpt_prefix = "FY3x_";
|
||||
|
||||
if (scid == FY3_A_SCID)
|
||||
hpt_prefix = "FY3A_";
|
||||
else if (scid == FY3_B_SCID)
|
||||
hpt_prefix = "FY3B_";
|
||||
else if (scid == FY3_C_SCID)
|
||||
hpt_prefix = "FY3C_";
|
||||
|
||||
std::string c10_filename = hpt_prefix + getHRPTReaderTimeStamp() + ".C10";
|
||||
std::ofstream output_hrpt_reader(directory + "/" + c10_filename, std::ios::binary);
|
||||
d_output_files.push_back(directory + "/" + c10_filename);
|
||||
|
||||
|
|
|
|||
139
src-core/modules/fengyun/module_fengyun_satid.cpp
Normal file
139
src-core/modules/fengyun/module_fengyun_satid.cpp
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
#include "module_fengyun_satid.h"
|
||||
#include <fstream>
|
||||
#include "common/ccsds/ccsds_1_0_1024/vcdu.h"
|
||||
#include "logger.h"
|
||||
#include <filesystem>
|
||||
#include "imgui/imgui.h"
|
||||
#include "common/utils.h"
|
||||
#include "fengyun3.h"
|
||||
#include "nlohmann/json_utils.h"
|
||||
|
||||
#define BUFFER_SIZE 8192
|
||||
|
||||
// Return filesize
|
||||
size_t getFilesize(std::string filepath);
|
||||
|
||||
namespace fengyun
|
||||
{
|
||||
namespace satid
|
||||
{
|
||||
FengYunSatIDModule::FengYunSatIDModule(std::string input_file, std::string output_file_hint, std::map<std::string, std::string> parameters) : ProcessingModule(input_file, output_file_hint, parameters),
|
||||
scid_hint(parameters.count("scid_hint") > 0 ? std::stoi(parameters["scid_hint"]) : -1)
|
||||
{
|
||||
}
|
||||
|
||||
void FengYunSatIDModule::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[1024];
|
||||
|
||||
logger->info("Scanning through CADUs...");
|
||||
|
||||
std::vector<uint8_t> scids;
|
||||
|
||||
while (!data_in.eof())
|
||||
{
|
||||
// Read buffer
|
||||
data_in.read((char *)&cadu, 1024);
|
||||
|
||||
// Parse this transport frame
|
||||
ccsds::ccsds_1_0_1024::VCDU vcdu = ccsds::ccsds_1_0_1024::parseVCDU(cadu);
|
||||
|
||||
if (vcdu.spacecraft_id == FY3_A_SCID ||
|
||||
vcdu.spacecraft_id == FY3_B_SCID ||
|
||||
vcdu.spacecraft_id == FY3_C_SCID ||
|
||||
vcdu.spacecraft_id == FY3_D_SCID)
|
||||
scids.push_back(vcdu.spacecraft_id);
|
||||
|
||||
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();
|
||||
|
||||
int scid = most_common(scids.begin(), scids.end());
|
||||
|
||||
logger->info("SCID " + std::to_string(scid) + " was most common.");
|
||||
|
||||
if (scid_hint > 0)
|
||||
{
|
||||
if (scid == scid_hint)
|
||||
{
|
||||
logger->debug("That matches with the provided SCID.");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger->error("Detected SCID did not match expectations! Defaulting to provided value...");
|
||||
scid = scid_hint;
|
||||
}
|
||||
}
|
||||
|
||||
std::string sat_name = "Unknown FengYun";
|
||||
|
||||
if (scid == FY3_A_SCID)
|
||||
sat_name = "FengYun-3A";
|
||||
else if (scid == FY3_B_SCID)
|
||||
sat_name = "FengYun-3B";
|
||||
else if (scid == FY3_C_SCID)
|
||||
sat_name = "FengYun-3C";
|
||||
else if (scid == FY3_D_SCID)
|
||||
sat_name = "FengYun-3D";
|
||||
|
||||
int norad = 0;
|
||||
|
||||
if (scid == FY3_A_SCID)
|
||||
norad = FY3_A_NORAD;
|
||||
else if (scid == FY3_B_SCID)
|
||||
norad = FY3_B_NORAD;
|
||||
else if (scid == FY3_C_SCID)
|
||||
norad = FY3_C_NORAD;
|
||||
else if (scid == FY3_D_SCID)
|
||||
norad = FY3_D_NORAD;
|
||||
|
||||
logger->info("This is satellite is " + sat_name + ", NORAD " + std::to_string(norad));
|
||||
|
||||
nlohmann::json jData;
|
||||
|
||||
jData["scid"] = scid;
|
||||
jData["name"] = sat_name;
|
||||
jData["norad"] = norad;
|
||||
|
||||
saveJsonFile(d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/sat_info.json", jData);
|
||||
}
|
||||
|
||||
void FengYunSatIDModule::drawUI(bool window)
|
||||
{
|
||||
ImGui::Begin("FengYun Satellite Identifier", NULL, window ? NULL : NOWINDOW_FLAGS);
|
||||
|
||||
ImGui::ProgressBar((float)progress / (float)filesize, ImVec2(ImGui::GetWindowWidth() - 10, 20 * ui_scale));
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
std::string FengYunSatIDModule::getID()
|
||||
{
|
||||
return "fengyun_satid";
|
||||
}
|
||||
|
||||
std::vector<std::string> FengYunSatIDModule::getParameters()
|
||||
{
|
||||
return {"scid_hint"};
|
||||
}
|
||||
|
||||
std::shared_ptr<ProcessingModule> FengYunSatIDModule::getInstance(std::string input_file, std::string output_file_hint, std::map<std::string, std::string> parameters)
|
||||
{
|
||||
return std::make_shared<FengYunSatIDModule>(input_file, output_file_hint, parameters);
|
||||
}
|
||||
} // namespace amsu
|
||||
} // namespace metop
|
||||
28
src-core/modules/fengyun/module_fengyun_satid.h
Normal file
28
src-core/modules/fengyun/module_fengyun_satid.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include "module.h"
|
||||
|
||||
namespace fengyun
|
||||
{
|
||||
namespace satid
|
||||
{
|
||||
class FengYunSatIDModule : public ProcessingModule
|
||||
{
|
||||
protected:
|
||||
std::atomic<size_t> filesize;
|
||||
std::atomic<size_t> progress;
|
||||
|
||||
const int scid_hint;
|
||||
|
||||
public:
|
||||
FengYunSatIDModule(std::string input_file, std::string output_file_hint, std::map<std::string, std::string> parameters);
|
||||
void process();
|
||||
void drawUI(bool window);
|
||||
|
||||
public:
|
||||
static std::string getID();
|
||||
static std::vector<std::string> getParameters();
|
||||
static std::shared_ptr<ProcessingModule> getInstance(std::string input_file, std::string output_file_hint, std::map<std::string, std::string> parameters);
|
||||
};
|
||||
} // namespace amsu
|
||||
} // namespace metop
|
||||
Loading…
Add table
Add a link
Reference in a new issue