/*/ ============================================================================= // atmcor.h // ATMOSPHERIC CORRECTION PROGRAM for ADEOS2/GLI // 1999/2/12 Fukushima Lab.(c) // School of High-Technology for Human Walfare // Tokai University // Programed by Mitsuhiro Toratani // Special thanks Tabata // modified for ver.2 on 2004/05/24 // ============================================================================= */ #include #include #include #include #define MODIS 0 /* 0: GLI data; 1: MODIS-converted GLI-format data */ #define NUM_CH 21 /* number of GLI channels used for OTSK1A */ #define BAND1 0 /* 380nm */ #define BAND2 1 /* 400nm */ #define BAND3 2 /* 412nm */ #define BAND4 3 /* 443nm */ #define BAND5 4 /* 460nm */ #define BAND6 5 /* 490nm */ #define BAND7 6 /* 520nm */ #define BAND8 7 /* 545nm */ #define BAND9 8 /* 565nm */ #define BAND10 9 /* 625nm */ #define BAND11 10 /* 666nm */ #define BAND12 11 /* 680nm for ocean */ #define BAND13 12 /* 678nm */ #define BAND14 13 /* 710nm for ocean */ #define BAND15 14 /* 710nm */ #define BAND16 15 /* 749nm for ocean */ #define BAND17 16 /* 763nm */ #define BAND18 17 /* 865nm for ocean */ #define BAND19 18 /* 865nm */ #define BAND24 19 /* 1050nm */ #define BAND26 20 /* 1240nm */ #define NIR_BAND_S BAND13 #define NIR_BAND_L BAND19 /* for atmospheric correction option */ #define ALT_OPT 1 /* 0: use BAND16 & BAND18 only (STD); 1: use NIR_BAND_S & NIR_BAND_L only (ALT); 2: use BAND13 & BAND19 when BAND16 or BAND18 saturated (S_SW); 3: use weighted averaging between BAND16 & BAND13 / BAND18 & BAND19 (W_SW) */ #define SG_CORR 1 /* 1: with sunglint correction; -1: without sunglint correction */ #define WC_CORR -1 /* 1: with whitecap correction(not implemented here); -1: without whitecap correction */ #define MAX_ITER 10 /* 1: without iteration; 10: with up to 10 iterations */ #define DAT_CONV 1 /* 1: nLw converted to unsigned short; -1: nLw converted to float */ #define SEA_WINDS 1 /* 1: use SeaWinds data -1: use JMA data */ #define AER_TRN 1 /* 1: use lookup tabel of aerosol transmittance -1: not use */ /* For in-water algorithm & flags */ #define NN_OPT 0 /* 1: use T&T Neural network algorithm for SS; 0: use GLI in-water algorithm */ /* 2: use T&T Neural network algorithm for all CHLA, SS, CDOM */ #define CALP6 0 /* 1: use CALP6 algorithm 0: use OC4 algorithm */ #define YES 1 #define NO 0 #define ON 1 #define OFF -1 #define NUM_BITS 32 #define LUTDIR "../LUT" #define NL_ETOPO 2160 #define NP_ETOPO 4320 #define NL_SWINDS 720 #define NP_SWINDS 1440 #define BLOCK_SZ 180 /* number of lines for block reading from Level_1B data */ #define SATU_B16 1.2 /* saturation level of band 16 */ #define SATU_B18 0.8 /* saturation level of band 18 */ #define WINDOW_SIZE 3 /* for near-cloud flag */ #define TH_SOL_ZENITH 0.5 /* cos(60.0degree) */ #define TH_SAT_ZENITH 0.5 /* cos(60.0degree) */ #define TH_LOW_NLW 0.2 /* nLw[545]<-->BAND8 */ #define TH_HIGH_TAU_A 0.8 #define NUM_MODEL 9 #define NUM_ANGLE 1801 #define NUM_THETA0 45 /* number of sun zenith angle */ #define NUM_THETA 41 /* number of satellite zenith angle */ #define NUM_TAU_COEF 5 #define NUM_TRN_COEF 3 #define THETA 24 #define THETA0 24 #define dPHI 46 #define NUM_WS 16 #define NUM_TH0 10 #define NUM_TH 9 #define NUM_DPH 8 #define THETA_TRN 35 #define SUB 10 #define ANG 360 #define TSUB 1000 #define MAXCHAR 512 #define PI 3.14159265358979323846 /* PI */ #define DTOR(x) (3.14159265358979323846/180.0)*(x) /* degree to radian */ #define RTOD(x) (180.0/3.14159265358979323846)*(x) /* radian to degree */ #define sqr(x) ((x)*(x)) /* squre of x */ #define P0 1013.25 /* standard pressure (hPa) */ #define TBD 1.0 static double WAVE[NUM_CH] = { /* 380.0, 400.0, 412.0, 443.0, 460.0, 490.0, 520.0, 545.0, 565.0, 625.0, 666.0, 680.0, 678.0, 710.0, 711.0, 749.0, 763.0, 865.0, 866.0, 1050.0, 1240.0 */ 381.090, 399.980, 412.530, 442.590, 459.480, 489.660, 519.350, 544.060, 564.920, 625.080, 666.940, 680.200, 678.567, 710.523, 710.109, 748.971, 762.060, 866.070, 865.690,1048.643,1240.961 }; static int band[NUM_CH] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 24, 26 }; /* static int out_band[17] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 18, 19, 20 }; */ static int out_band[16] = { BAND1, BAND2, BAND3, BAND4, BAND5, BAND6, BAND7, BAND8, BAND9, BAND10, BAND11, BAND12, BAND13, BAND14, BAND19, BAND19 /* output Band19 both nLw and La */ }; /* Mean solar irradiance weighted by GLI response function F0 [mW/cm^2/micron], NASDA 2003/02/21 */ static double F0bar[NUM_CH] = { 1.09570E+02,1.54034E+02,1.71457E+02,1.88580E+02,2.08204E+02, 1.93979E+02,1.79252E+02,1.85803E+02,1.78899E+02,1.65120E+02, 1.52247E+02,1.47472E+02,1.47901E+02,1.39402E+02,1.39624E+02, 1.27412E+02,1.24887E+02,9.56023E+01,9.56757E+01,6.54572E+01, 4.54842E+01}; /* Ozone specific absorption coefficient Koz [DU^-1], RESTEC 2003/02/21 */ static double k_oz[NUM_CH] = { 6.31612e-08,2.03379e-08,7.66708e-07,3.65622e-06,8.46420e-06, 2.29386e-05,4.78868e-05,8.10874e-05,1.14647e-04,9.79685e-05, 4.80841e-05,3.77982e-05,3.87799e-05,2.03970e-05,2.05623e-05, 1.02611e-05,7.72529e-06,2.07481e-08,1.46150e-08,0.00000e+00, 0.00000e+00}; /* Rayleigh optical thickness at standard prssure, RESTEC 2003/02/21 */ static double tau_m0[NUM_CH] = { 4.30612e-01,3.52036e-01,3.09485e-01,2.31444e-01,1.98360e-01, 1.52826e-01,1.20163e-01,9.93958e-02,8.53045e-02,5.67148e-02, 4.36584e-02,4.03395e-02,4.06544e-02,3.37995e-02,3.38793e-02, 2.73681e-02,2.55270e-02,1.53235e-02,1.53440e-02,7.14740e-03, 3.67117e-03}; /* Refractive index of sea water */ static double mm[NUM_CH] = { 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34}; /* Vicarious calibration coefficients, to be modified after launch */ static double NUM[2][NUM_CH] = { /* offset coef by 20030929 */ {1.00000,1.00000,1.00000,1.08300,1.07300,1.02176,1.03744, 1.02221,1.07276,0.99888,1.00527,1.00736,1.00294,1.00000, 1.00000,1.00145,1.0000,0.98439,1.00081,0.89079,0.90446}, {-0.0000,-0.0000,-0.0000,-0.6825,-0.9471,-0.4934,-1.0205, -1.1501,-1.0699,-0.9306,-0.8100,-0.7536,-0.5735,-0.0000, -0.0000,-0.6231,-0.0000,-0.3051,-0.3140,-0.1355,-0.0933} }; /* vicarious calibration coeficients scan-angle dependencies */ static double VCTBL[NUM_CH][8] = { {1.2710e+00,-8.1485e-03,1.5360e-04,-1.5212e-06,0,0,0,0}, {1.1988e+00,-7.5594e-03,1.6726e-04,-1.3973e-06,0,0,0,0}, {1.0978e+00,-7.0384e-03,1.6558e-04,-1.3462e-06,0,0,0,0}, {1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,0} }; /* Water-vapor correction coefficients, Global ch19-0.312W/m^2/sr/um 20030929 */ static double cp[2][NUM_CH] = { {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.896718, 0.935092, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.000893, 0.000874, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} }; /* information datas of image (get_inform) */ typedef struct { int year, month, day, msec, /* date & time */ jday; /* Julian date */ int gain[NUM_CH]; /* gain */ float tilt; /* tilt angle */ }INFORM; /* information datas after ingesting (get_head) */ typedef struct { int line_s, /* start line */ column_s, /* start column */ skip_rate_v, /* vertical skip rate */ skip_rate_h, /* horizontal skip rate */ column, /* size of columns */ line; /* size of lines */ } HEADER; /* pixel location datas (get_pix_loc) */ typedef struct { float lat, /* latitude */ lon; /* longitude */ } POINT; typedef struct { double costh[NUM_CH], /* satelite zenath angle */ costh0, /* sun zenath angle */ dph[NUM_CH]; /* satellite azimuth angle - sun azimuth angle */ } THPH; typedef struct { THPH thph; double scat_ang[NUM_CH][2]; /* scattering angle */ } S_GEO;