19 #include <netinet/in.h>
28 using namespace netCDF;
29 using namespace netCDF::exceptions;
65 static constexpr
int NUM_TAPS = 201;
74 static constexpr
int MAX_NUM_HISTORY_ORBITS = 480;
80 static constexpr
double DEGtoRAD = 0.017453292519943296e0;
81 static constexpr
double RADtoDEG = 57.295779513082321e0;
83 static constexpr
int C_COEFFS = 4;
84 static constexpr
int A_COEFFS = 3;
85 static constexpr
int T_FP_LEVELS = 5;
86 static constexpr
int T_ELEC_LEVELS = 5;
88 static constexpr
unsigned char NIGHT_GRAN = 0;
89 static constexpr
unsigned char DAY_GRAN = 1;
90 static constexpr
unsigned char MIXED_GRAN = 2;
97 static constexpr
unsigned char L1B_SCAN_STATE_HA_MIRROR_B_SIDE = 0x01;
98 static constexpr
unsigned char L1B_SCAN_STATE_ELECTRONICS_SIDE = 0x02;
99 static constexpr
unsigned char L1B_SCAN_STATE_SENSOR_NIGHT_MODE = 0x04;
100 static constexpr
unsigned char L1B_SCAN_STATE_SENSOR_NOT_OPERATIONAL = 0x08;
101 static constexpr
unsigned char L1B_SCAN_STATE_NO_CALIBRATION = 0xff;
103 static constexpr
unsigned char L1B_SCAN_QUALITY_MOON_IN_SPACE_VIEW = 0x01;
104 static constexpr
unsigned char L1B_SCAN_QUALITY_NO_EV_DATA = 0x02;
105 static constexpr
unsigned char L1B_SCAN_QUALITY_SENSOR_NOT_NOMINAL = 0x04;
106 static constexpr
unsigned char L1B_SCAN_QUALITY_SCAN_SYNC_FAILURE = 0x08;
107 static constexpr
unsigned char L1B_SCAN_QUALITY_TEL_START_NOT_NOMINAL = 0x10;
108 static constexpr
unsigned char L1B_SCAN_QUALITY_BB_TEMP_NOT_NOMINAL = 0x20;
109 static constexpr
unsigned char L1B_SCAN_QUALITY_LWIR_TEMP_NOT_NOMINAL = 0x40;
112 static constexpr
long long MSECPERDAY = 86400000000ll;
119 static constexpr
short NUM_PIXEL_QUALITY_FLAGS = 4;
120 static constexpr
unsigned char L1B_PIXEL_QUALITY_GOOD = 0x00;
121 static constexpr
unsigned char L1B_PIXEL_QUALITY_SUBSTITUTE_CAL = 0x01;
122 static constexpr
unsigned char L1B_PIXEL_QUALITY_OUTOFRANGE_RAD = 0x02;
123 static constexpr
unsigned char L1B_PIXEL_QUALITY_OUTOFRANGE_RFLBT = 0x02;
124 static constexpr
unsigned char L1B_PIXEL_QUALITY_ALLSATURATION = 0x04;
125 static constexpr
unsigned char L1B_PIXEL_QUALITY_TEMP_NOT_NOMINAL = 0x08;
126 static constexpr
unsigned char L1B_PIXEL_QUALITY_LOWER_MASK = 0x0f;
127 static constexpr
unsigned char L1B_PIXEL_QUALITY_UPPER_MASK = 0xf0;
128 static constexpr
unsigned char L1B_PIXEL_QUALITY_NOT_ALLSATURATION = 0xfb;
129 static constexpr
unsigned char L1B_PIXEL_QUALITY_NOT_OUTOFRANGE = 0xfd;
132 static constexpr
short NUM_DG_PIXEL_QUALITY_FLAGS = 8;
133 static constexpr
short NUM_UADG_PIXEL_QUALITY_FLAGS = 6;
134 static constexpr
unsigned char L1B_PIXEL_QUALITY_LOW_GAIN_STATE = 0x10;
135 static constexpr
unsigned char L1B_PIXEL_QUALITY_MIXED_GAIN_STATE = 0x20;
136 static constexpr
unsigned char L1B_PIXEL_QUALITY_DG_ANOMALY = 0x40;
137 static constexpr
unsigned char L1B_PIXEL_QUALITY_SOMESATURATION = 0x80;
140 static constexpr
short NUM_DNB_PIXEL_QUALITY_FLAGS = 5;
141 static constexpr
unsigned char L1B_PIXEL_QUALITY_DNB_STRAY_LIGHT = 0x10;
144 static constexpr
short NUM_BAD_PIXEL_QUALITY_FLAGS = 5;
145 static constexpr
short BAD_PIXEL_QUAL_SHIFT = 8;
146 static constexpr
unsigned short L1B_PIXEL_QUALITY_BOWTIE = 0x0100;
147 static constexpr
unsigned short L1B_PIXEL_QUALITY_MISSING = 0x0200;
148 static constexpr
unsigned short L1B_PIXEL_QUALITY_NOCALIBRATE = 0x0400;
149 static constexpr
unsigned short L1B_PIXEL_QUALITY_DEAD_DETECTOR = 0x0800;
150 static constexpr
unsigned short L1B_PIXEL_QUALITY_NOISY_DETECTOR = 0x1000;
152 static constexpr
short TOTAL_SG_PIXEL_QUALITY_FLAGS = NUM_PIXEL_QUALITY_FLAGS + NUM_BAD_PIXEL_QUALITY_FLAGS;
153 static constexpr
short TOTAL_DG_PIXEL_QUALITY_FLAGS = NUM_DG_PIXEL_QUALITY_FLAGS + NUM_BAD_PIXEL_QUALITY_FLAGS;
154 static constexpr
short TOTAL_UADG_PIXEL_QUALITY_FLAGS = NUM_UADG_PIXEL_QUALITY_FLAGS + NUM_BAD_PIXEL_QUALITY_FLAGS;
155 static constexpr
short TOTAL_DNB_PIXEL_QUALITY_FLAGS = NUM_DNB_PIXEL_QUALITY_FLAGS + NUM_BAD_PIXEL_QUALITY_FLAGS;
158 static constexpr
unsigned char L1B_ROW_QUALITY_SUBSTITUTE_CAL = 0x01;
159 static constexpr
unsigned char L1B_ROW_QUALITY_NO_CALIBRATION = 0x02;
160 static constexpr
unsigned char L1B_ROW_QUALITY_MOON_IN_SPACE_VIEW = 0x04;
161 static constexpr
unsigned char L1B_ROW_QUALITY_DG_ANOMALY = 0x08;
162 static constexpr
unsigned char L1B_ROW_QUALITY_DEAD_DETECTOR = 0x10;
163 static constexpr
unsigned char L1B_ROW_QUALITY_BB_TEMP_NOT_NOMINAL = 0x20;
164 static constexpr
unsigned char L1B_ROW_QUALITY_LWIR_TEMP_NOT_NOMINAL = 0x40;
165 static constexpr
unsigned char L1B_ROW_QUALITY_DNB_STRAY_LIGHT = 0x80;
168 static constexpr
int MOON_IN_SV_SCANS_TO_SKIP_FORWARD = 6;
169 static constexpr
int MOON_IN_SV_SCANS_TO_SKIP_BACK = 4;
172 static constexpr
float L1B_FILL_FLOAT = -999.9f;
173 static constexpr
double L1B_FILL_DOUBLE = -999.9L;
174 static constexpr
short L1B_FILL_SHORT = -999;
175 static constexpr
unsigned short L1B_FILL_USHORT = 65535;
176 static constexpr
char L1B_FILL_BYTE = -1;
177 static constexpr
unsigned char L1B_FILL_UBYTE = 255;
187 static constexpr
float FLOAT_FILL_TEST = -999.0f;
188 static constexpr
short SHORT_FILL_TEST = -990;
189 static constexpr
char BYTE_FILL_TEST = 0;
190 static constexpr
unsigned char UBYTE_FILL_TEST = 247;
193 static constexpr
short GRANULES = 3;
196 static constexpr
float sv_filter_bw_ = 0.01;
197 static constexpr
float f_filter_bw_ = 0.005;
331 double fir_coeff_[NUM_TAPS];
373 int write_obc_data();
384 source_files_ = source;
388 return source_files_;
396 bFilters_ = bFilters;
403 std::map<std::string, VcstLutInputItem*> obcLutItems_;
415 int initialize_LUT_data();
421 int initialize_L1B_data();
429 int read_L1A_attributes(NcFile* nc_input);
437 int read_L1A_cal_data_img(NcFile* nc_input);
438 int read_L1A_cal_data_mod(NcFile* nc_input);
439 int read_L1A_cal_data_dnb(NcFile* nc_input);
447 int check_scan_state();
455 int check_scan_quality();
519 int write_global_attributes(NcFile* nc_output);
527 int write_obc_eng_data(NcFile* nc_output);
535 int write_obc_nav_data(NcFile* nc_output);
543 int write_obc_cal_data(NcFile* nc_output);
551 int write_diagnostics(NcFile* nc_output);
559 int generate_filt_coeff(
float cutoff_frequency);
568 bool isValidGranuleSequence();
576 short convert14To16bit(
short value14bit);
584 bool isPlatformLittleEndian();