Browse Source

Add enum for channel ID. Fix channel 3A to be near-IR as per https://nssdc.gsfc.nasa.gov/nmc/experiment/display.action?id=1998-030A-01

tags/v1.8.0
Jon Beniston 3 years ago
parent
commit
b3dd3f8ce1
3 changed files with 22 additions and 10 deletions
  1. +15
    -3
      src/apt.h
  2. +6
    -6
      src/image.c
  3. +1
    -1
      src/main.c

+ 15
- 3
src/apt.h View File

@@ -39,7 +39,7 @@ extern "C" {
#define APT_API #define APT_API
#endif #endif


// Maximum height of an APT image in number of scanlines
// Maximum height of an APT image in number of rows
#define APT_MAX_HEIGHT 3000 #define APT_MAX_HEIGHT 3000
// Width in pixels of sync // Width in pixels of sync
#define APT_SYNC_WIDTH 39 #define APT_SYNC_WIDTH 39
@@ -59,6 +59,18 @@ extern "C" {
#define APT_CHB_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH) #define APT_CHB_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH)
#define APT_TOTAL_TELE (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH) #define APT_TOTAL_TELE (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH)


// Number of rows required for apt_calibrate
#define APT_CALIBRATION_ROWS 192
// Channel ID returned by apt_calibrate
// NOAA-15: https://nssdc.gsfc.nasa.gov/nmc/experiment/display.action?id=1998-030A-01
// Channel 1: visible (0.58-0.68 um)
// Channel 2: near-IR (0.725-1.0 um)
// Channel 3A: near-IR (1.58-1.64 um)
// Channel 3B: mid-infrared (3.55-3.93 um)
// Channel 4: thermal-infrared (10.3-11.3 um)
// Channel 5: thermal-infrared (11.5-12.5 um)
typedef enum apt_channel {APT_CHANNEL_UNKNOWN, APT_CHANNEL_1, APT_CHANNEL_2, APT_CHANNEL_3A, APT_CHANNEL_4, APT_CHANNEL_5, APT_CHANNEL_3B} apt_channel_t;

// Width in elements of apt_image_t.prow arrays // Width in elements of apt_image_t.prow arrays
#define APT_PROW_WIDTH 2150 #define APT_PROW_WIDTH 2150


@@ -70,7 +82,7 @@ typedef struct {
float *prow[APT_MAX_HEIGHT]; // Row buffers float *prow[APT_MAX_HEIGHT]; // Row buffers
int nrow; // Number of rows int nrow; // Number of rows
int zenith; // Row in image where satellite reaches peak elevation int zenith; // Row in image where satellite reaches peak elevation
int chA, chB; // ID of each channel
apt_channel_t chA, chB; // ID of each channel
char name[256]; // Stripped filename char name[256]; // Stripped filename
char *palette; // Filename of palette char *palette; // Filename of palette
} apt_image_t; } apt_image_t;
@@ -84,7 +96,7 @@ int APT_API apt_getpixelrow(float *pixelv, int nrow, int *zenith, int reset, apt


void APT_API apt_histogramEqualise(float **prow, int nrow, int offset, int width); void APT_API apt_histogramEqualise(float **prow, int nrow, int offset, int width);
void APT_API apt_linearEnhance(float **prow, int nrow, int offset, int width); void APT_API apt_linearEnhance(float **prow, int nrow, int offset, int width);
int APT_API apt_calibrate(float **prow, int nrow, int offset, int width) ;
apt_channel_t APT_API apt_calibrate(float **prow, int nrow, int offset, int width) ;
void APT_API apt_denoise(float **prow, int nrow, int offset, int width); void APT_API apt_denoise(float **prow, int nrow, int offset, int width);
void APT_API apt_flipImage(apt_image_t *img, int width, int offset); void APT_API apt_flipImage(apt_image_t *img, int width, int offset);
int APT_API apt_cropNoise(apt_image_t *img); int APT_API apt_cropNoise(apt_image_t *img);


+ 6
- 6
src/image.c View File

@@ -125,7 +125,7 @@ double teleNoise(double wedges[16]){
} }


// Get telemetry data for thermal calibration // Get telemetry data for thermal calibration
int apt_calibrate(float **prow, int nrow, int offset, int width) {
apt_channel_t apt_calibrate(float **prow, int nrow, int offset, int width) {
double teleline[APT_MAX_HEIGHT] = { 0.0 }; double teleline[APT_MAX_HEIGHT] = { 0.0 };
double wedge[16]; double wedge[16];
rgparam_t regr[APT_MAX_HEIGHT/APT_FRAME_LEN + 1]; rgparam_t regr[APT_MAX_HEIGHT/APT_FRAME_LEN + 1];
@@ -133,9 +133,9 @@ int apt_calibrate(float **prow, int nrow, int offset, int width) {
int channel = -1; int channel = -1;


// The minimum rows required to decode a full frame // The minimum rows required to decode a full frame
if (nrow < 192) {
if (nrow < APT_CALIBRATION_ROWS) {
fprintf(stderr, "Telemetry decoding error, not enough rows\n"); fprintf(stderr, "Telemetry decoding error, not enough rows\n");
return 0;
return APT_CHANNEL_UNKNOWN;
} }


// Calculate average of a row of telemetry // Calculate average of a row of telemetry
@@ -170,7 +170,7 @@ int apt_calibrate(float **prow, int nrow, int offset, int width) {
// Make sure that theres at least one full frame in the image // Make sure that theres at least one full frame in the image
if (nrow < telestart + APT_FRAME_LEN) { if (nrow < telestart + APT_FRAME_LEN) {
fprintf(stderr, "Telemetry decoding error, not enough rows\n"); fprintf(stderr, "Telemetry decoding error, not enough rows\n");
return 0;
return APT_CHANNEL_UNKNOWN;
} }


// Find the least noisy frame // Find the least noisy frame
@@ -233,12 +233,12 @@ int apt_calibrate(float **prow, int nrow, int offset, int width) {


if(bestFrame == -1){ if(bestFrame == -1){
fprintf(stderr, "Something has gone very wrong, please file a bug report.\n"); fprintf(stderr, "Something has gone very wrong, please file a bug report.\n");
return 0;
return APT_CHANNEL_UNKNOWN;
} }


calibrateImage(prow, nrow, offset, width, regr[bestFrame]); calibrateImage(prow, nrow, offset, width, regr[bestFrame]);


return channel + 1;
return (apt_channel_t)(channel + 1);


} }




+ 1
- 1
src/main.c View File

@@ -124,7 +124,7 @@ static int processAudio(char *filename, options_t *opts){
char *name[7]; char *name[7];
} ch = { } ch = {
{ "?", "1", "2", "3A", "4", "5", "3B" }, { "?", "1", "2", "3A", "4", "5", "3B" },
{ "unknown", "visble", "near-infrared", "mid-infrared", "thermal-infrared", "thermal-infrared", "mid-infrared" }
{ "unknown", "visble", "near-infrared", "near-infrared", "thermal-infrared", "thermal-infrared", "mid-infrared" }
}; };


// Buffer for image channel // Buffer for image channel


Loading…
Cancel
Save