Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
Initial (NOAA) MHS and HIRS projection
Browse files Browse the repository at this point in the history
  • Loading branch information
Xerbo committed Jun 7, 2022
1 parent caab359 commit 47040a4
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 18 deletions.
34 changes: 28 additions & 6 deletions projection.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ roll = -0.08
pitch = -0.22
toffset = 0

[NOAA-18_HIRS]
fov = 52.2
yaw = 0.0
roll = 0.0
pitch = 0.0
toffset = 0
[NOAA-19_HIRS]
fov = 52.2
yaw = 0.0
roll = 0.0
pitch = 0.0
toffset = 0

# NOAA-18 MHS is dead
[NOAA-19_MHS]
fov = 50.0
yaw = 0.0
roll = 0.5
pitch = 0.0
toffset = 0.0

[MetOp-A_AVHRR]
fov = 55.2
yaw = 0.3
Expand Down Expand Up @@ -49,12 +70,19 @@ roll = 0.5
pitch = 0.0
toffset = 0.5

[Meteor-M2_MSU-MR]
fov = 55.25
yaw = 2.26
roll = 2.0
pitch = 0.0
toffset = 0.0
[Meteor-M22_MSU-MR]
fov = 55.15
yaw = 2.3
roll = -0.18
pitch = -0.1
toffset = 0

[Meteor-M22_MTVZA]
curved = true
fov = 52
Expand All @@ -63,12 +91,6 @@ roll = 0
pitch = -53.3
pitchscale = 0.9
toffset = 0
[Meteor-M2_MSU-MR]
fov = 55.25
yaw = 2.26
roll = 2.0
pitch = 0.0
toffset = 0.0

[FengYun-3C_VIRR]
fov = 55.31
Expand Down
6 changes: 4 additions & 2 deletions src/decoders/common/aip.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@

class AIPDecoder {
public:
void work(std::map<Imager, RawImage *> &images, const uint8_t *frame) {
bool work(std::map<Imager, RawImage *> &images, const uint8_t *frame) {
uint8_t mhs_status = frame[7];
if (mhs_status > 80) return;
if (mhs_status > 80) return false;

std::memcpy(&mhsline[mhs_status*50], &frame[48], 50);
if (mhs_status == 79) {
images[Imager::MHS]->push16Bit((uint16_t *)&mhsline[ 98], 0);
images[Imager::MHS]->push16Bit((uint16_t *)&mhsline[1432], 0);
images[Imager::MHS]->push16Bit((uint16_t *)&mhsline[2764], 0);
std::memset(mhsline, 0, 80*50);
return true;
}
return false;
}
private:
uint8_t mhsline[80*50];
Expand Down
6 changes: 4 additions & 2 deletions src/decoders/common/tip.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ inline bool tip_parity(const uint8_t *frame) {
return ok;
}

inline void tip_work(std::map<Imager, RawImage *> &images, const uint8_t *frame) {
inline bool tip_work(std::map<Imager, RawImage *> &images, const uint8_t *frame) {
// These are taken from the NOAA KLM Users Guide
const size_t offsets[36] = { 16, 17, 22, 23, 26, 27, 30, 31, 34, 35, 38, 39, 42, 43, 54, 55, 58, 59, 62, 63, 66, 67, 70, 71, 74, 75, 78, 79, 82, 83, 84, 85, 88, 89, 92, 93 };
const size_t channels[20] = { 1, 17, 2, 3, 13, 4, 18, 11, 19, 7, 8, 20, 10, 14, 6, 5, 15, 12, 16, 9 };
Expand All @@ -63,7 +63,7 @@ inline void tip_work(std::map<Imager, RawImage *> &images, const uint8_t *frame)
arbitrary_repack<uint16_t, 13>(packet, words, 22);

uint8_t element_number = (words[1] >> 1) & 0b111111;
if (element_number > 55) return;
if (element_number > 55) return false;

for (size_t j = 0; j < 20; j++) {
unsigned short *channel = images[Imager::HIRS]->getChannel(channels[j]-1);
Expand All @@ -78,7 +78,9 @@ inline void tip_work(std::map<Imager, RawImage *> &images, const uint8_t *frame)
// New line
if (element_number == 55) {
images[Imager::HIRS]->set_height(images[Imager::HIRS]->rows() + 1);
return true;
}
return false;
}

#endif
12 changes: 9 additions & 3 deletions src/decoders/noaa_gac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ void NOAAGACDecoder::frame_work(uint16_t *ptr) {
}

if (i < 5) {
tip_work(images, frame);
if (tip_work(images, frame)) {
timestamps[Imager::HIRS].push_back(timestamp);
}
} else {
aip_decoder.work(images, frame);
if (aip_decoder.work(images, frame)) {
timestamps[Imager::MHS].push_back(0);
timestamps[Imager::MHS].push_back(0);
timestamps[Imager::MHS].push_back(timestamp);
}
}
}

Expand All @@ -107,7 +113,7 @@ void NOAAGACDecoder::frame_work(uint16_t *ptr) {
// Parse timestamp
uint16_t days = repacked[8] >> 1;
uint32_t ms = (repacked[9] & 0b1111111) << 20 | repacked[10] << 10 | repacked[11];
double timestamp = (double)year + (double)days*86400.0 + (double)ms/1000.0;
timestamp = (double)year + (double)days*86400.0 + (double)ms/1000.0;
timestamps[Imager::AVHRR].push_back(line_ok ? timestamp : 0.0);

for (size_t i = 0; i < 3327; i++) {
Expand Down
1 change: 1 addition & 0 deletions src/decoders/noaa_gac.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class NOAAGACDecoder : public Decoder {
}
private:
ArbitraryDeframer<uint64_t, 0b101000010001011011111101011100011001110110000011110010010101, 60, 33270> deframer;
double timestamp = 0.0;

uint8_t frame[4159];
uint16_t repacked[3327];
Expand Down
20 changes: 16 additions & 4 deletions src/decoders/noaa_hrpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,21 @@ void NOAAHRPTDecoder::frame_work(uint16_t *ptr) {

uint8_t frame_type = (ptr[6] >> 7) & 0b11;
switch (frame_type) {
case 1: tip_work(images, frame); break;
case 3: aip_decoder.work(images, frame); break;
default: break;
case 1:{
if (tip_work(images, frame)) {
timestamps[Imager::HIRS].push_back(timestamp);
}
break;
}
case 3:{
if (aip_decoder.work(images, frame)) {
timestamps[Imager::MHS].push_back(0);
timestamps[Imager::MHS].push_back(0);
timestamps[Imager::MHS].push_back(timestamp);
};
break;
}
default: break;
}
}

Expand Down Expand Up @@ -110,7 +122,7 @@ void NOAAHRPTDecoder::frame_work(uint16_t *ptr) {
// Parse timestamp
uint16_t days = repacked[8] >> 1;
uint32_t ms = (repacked[9] & 0b1111111) << 20 | repacked[10] << 10 | repacked[11];
double timestamp = (double)year + (double)days*86400.0 + (double)ms/1000.0;
timestamp = (double)year + (double)days*86400.0 + (double)ms/1000.0;
if (line_ok) {
timestamps[Imager::AVHRR].push_back(timestamp);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/decoders/noaa_hrpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class NOAAHRPTDecoder : public Decoder {
uint8_t *frame;
uint16_t *repacked;
ArbitraryDeframer<uint64_t, 0b101000010001011011111101011100011001110110000011110010010101, 60, 110900> deframer;
double timestamp = 0.0;

void work(std::istream &stream);
void frame_work(uint16_t *ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void MainWindow::startDecode(std::string filename) {

for (size_t i = 1; i < filtered.size()-1; i++) {
// TODO: store seconds per line in satinfo
if ((timestamp[i-1] == 0 && timestamp[i+1] == 0) || (timestamp[i] - timestamp[i-1] < 2.5 && timestamp[i+1] - timestamp[i] < 2.5)) {
if ((timestamp[i-1] == 0 && timestamp[i+1] == 0) || (timestamp[i] - timestamp[i-1] < 10.0 && timestamp[i+1] - timestamp[i] < 10.0)) {
filtered[i] = timestamp[i];
}
}
Expand Down

0 comments on commit 47040a4

Please sign in to comment.