ocssw V2020
atrem_corl1.h
Go to the documentation of this file.
1 /*
2  * atrem.h
3  *
4  * Created on: Feb 11, 2015
5  * Author: rhealy
6  */
7 
8 #ifndef SRC_ATREM_ATREM_H_
9 #define SRC_ATREM_ATREM_H_
10 #include <stdint.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <timeutils.h>
14 #include "l12_proto.h"
15 
16 #define NBANDS 1024 /* maximum number of bands */
17 #define NH2OMAX 60
18 #define NH2OMAXM1 (NH2OMAX-1)
19 #define FINSTMAX 100
20 #define MODELMAX 25
21 
22 #define ATREM_O3 1
23 #define ATREM_CO2 2
24 #define ATREM_NO2 4
25 #define ATREM_CO 8
26 #define ATREM_CH4 16
27 #define ATREM_O2 32
28 #define ATREM_N2O 64
29 
30 typedef float t_array[NBANDS];
31 
32 typedef struct param_table {
33  /*Number of narrow channels to form broader window and absorption channels. */
34  int32_t nb1, nb2, nb3, nb4;
35  /*number of points used in channel ratios for both the .94- and 1.14-um regions */
36  int32_t nbp94, nb1p14;
37 
38  int32_t nh2o; /* number of water vapor values */
39  int32_t nobs; /* number of spectral observations - this should be nbands? number of channels? */
40  /* 3-channel ratioing
41  * parameters for bands up to the 0.94-um water vapor band [index=0,1]
42  * parameters for bands up to the 1.14-um water vapor band [index=2,3]
43  * */
44  int32_t start_ndx[4]; //ist1,ist2,ist3,ist4
45  int32_t end_ndx[4]; //ied1,ied2,ied3,ied4
46  /* 3-channel ratioing parameters for the 0.94-um water vapor band */
47  int32_t start_p94;
48  int32_t end_p94;
49  /* 3-channel ratioing parameters for the 1.14-um water vapor band */
50  int32_t start_1p14;
51  int32_t end_1p14;
52  /* Parameters for smoothing output reflectance spectra. */
53  int32_t start2;
54  int32_t end2;
55  int32_t ncv2;
56  /* number of channels of the four AVIRIS spectrometers. */
57  int32_t natot, nbtot, nctot, ndtot;
58  /* how often to recalculate geometry
59  * dogeom = 1 - every pixel
60  */
61  int32_t dogeom;
62  /* Atmospheric model number */
63  int model;
64  /* Relative weights for the four window *
65  * channels used in channel-ratioing calculations */
66  int idx450; // 450 nm wavelength index
67 
68  double wt1, wt2, wt3, wt4;
69  /*
70  * delta, delta2 - resolution, in units of nm, of input
71  * spectra and resolution of output surface reflectance
72  * spectra. If DLT2>DLT, output spectra are smoothed
73  * using a gaussian function.
74  */
75  double delta, delta2;
76  /* The "equivalent" geometrical *
77  * factor corresponding to the total slant vapor amount *
78  * VAP_SLANT_MDL and the column vapor amount CLMVAP. */
79  double g_vap_equiv; // This depends on zenith angle and lat/lon of measurement
80  float *r0p94; //ratio for the 0.94 um H2O absorption band
81  float *r1p14; //ratio for the 1.14 um H2O absorption band
82  float *finst2; // some kind of smoothing factor calculated in INIT_SPECCAL only used for AVIRIS?
83  /* TOTAL SUN-SURFACE-SENSOR PATH WATER VAPOR IN UNITS OF CM */
84  float *vaptot;
85 
86  /* total transmittances of all gases that match the *
87  * resolutions of imaging spectrometers */
88  t_array *trntbl;
89  float water_vapor; // returned water vapor value from get_atrem
90  int ja, jb; // indices to tran_table from get_atrem
91  float f1a, f2a, f1b, f2b; // fractions for interpolation of transmittances in tran_table from get_atrem
92 } paramstr;
93 
94 float get_atrem(float *tg_tot, float *rhot, paramstr *P);
95 int get_atrem_cor(int32_t sensorID, l1str *l2rec, int32_t ip, float *rhot, float *tg_tot, float *tg_sol, float *tg_sen);
96 int init_atrem(int32_t sensorID, paramstr *P, l1str *l2rec, int32_t nbands);
97 int32_t rdatreminfo(int32_t sensorID, int32_t evalmask, const char *pname, void **pval);
98 int get_angle_limits(float **angle_limit, float **senz, float **solz, int *n_senz, int *n_solz);
99 float get_current_angle_limit(float insenz, float insolz, int *i, int *j, float **anglelimit, float senz[], float solz[], int n_senz, int n_solz);
100 int32_t hunt(float *xx, int32_t n, double x, int32_t jlo);
101 int init_tpvmr(int model);
102 int getModelNum(float lat, int32_t day);
103 int findMatch_(float *list, int *nobs, float *elem);
104 void channelRatio_();
105 void ecdf_(float *xcdf, float *ycdf, int32_t *bin_number, float *xs, int32_t *sample_size);
106 void kdistgasabs_(float *kcdf, float *abscf, float*waveno, float *wavobs, int32_t *np_hi, int32_t *nlayers, int32_t *nwave);
107 void model_adjust();
108 void locate_pos_(float *xx, int32_t *n1, float *x1, int32_t *jj);
109 
110 extern void get_input_();
111 extern void model_adj_();
112 extern void geometry_();
113 extern void init_speccal_();
114 //extern void solar_irr_pc_();
115 extern void tran_table_();
116 
117 extern struct {
118  int32_t h2o, co2, o3, n2o, co, ch4, o2, no2;
119 } getinput1_;
120 
121 extern struct {
122  char filename[FILENAME_MAX];
123  int32_t dln;
124 } input_l2gen_;
125 
126 extern struct {
129 
130 extern struct {
132  int32_t nb, nl, model, iaer; //iaer not used because call to ssssss routine commented out in fortran code
133  float v, taer55, vrto3, sno2;
134  //nb = number of atmospheric levels in model
135  //nl = nb - 1
136  //sno2 = scaling factor for no2 (builtin NO2 column amount is 5.0E+15 molecules/cm^2
137  //vrto3 = column ozone amount (atm-cm) 0.28-0.55 is typical
138  //v = visibility (km)
139  //iaer = aerosol model value
140  //taerr55 = aerosol optical depth at 550 nm
141 } getinput3_;
142 
143 extern struct {
145 } getinput4_;
146 
147 extern struct {
148  int32_t nobs, full_calc;
149  float hsurf, dlt, dlt2;
150 } getinput5_;
151 
152 extern struct {
154 } getinput6_;
155 
156 extern struct {
157  int32_t nb1, nb2, nbp94, nb3, nb4, nb1p14;
158 } getinput7_;
159 
160 extern struct {
161  int32_t imn, idy, iyr, ih, im, is;
162 } getinput8_;
163 
164 extern struct {
165  float xpss, xppp;
166 } getinput14_;
167 
168 extern struct {
169  float clmvap, q;
170 } model_adj1_;
171 
172 extern struct {
174 } model_adj2_;
175 
176 extern struct {
177  int32_t k_plane;
179 } model_adj3_;
180 
181 extern struct {
182  int32_t k_surf;
183 } model_adj4_;
184 
185 extern struct {
186  int32_t nh2o;
188 
189 extern struct {
190  int32_t ist1, ied1, ist2, ied2, istp94, iedp94;
192 
193 extern struct {
196 
197 extern struct {
198  float wt1, wt2, wt3, wt4;
199  int32_t ja;
201 
202 extern struct {
203  float ncv2, ncvhf2, ncvtt2;
204  int32_t istrt2, iend2;
205  float finst2[FINSTMAX];
207 
208 extern struct {
209  int32_t natot, nbtot, nctot, ndtot;
211 
212 extern struct {
214 } tran_table1_;
215 
216 extern struct {
218 } geometry3_;
219 
220 extern struct {
222 } geometry4_;
223 
224 extern struct {
226  float water_vapor;
227  int ja, jb;
229  float f1a, f2a, f1b, f2b;
231 
232 extern struct {
233  float tpvmr[81][7];
234 } tpvmr_init1_;
235 
236 struct {
237  float cst1, cst2, cst3, cst4, cst5, cst6;
238  double rp94, r1p14;
239  int32_t jac, jbc;
240 } debug_atrem;
241 #endif /* SRC_ATREM_ATREM_H_ */
float clmvapp
Definition: atrem_corl1.h:178
float get_current_angle_limit(float insenz, float insolz, int *i, int *j, float **anglelimit, float senz[], float solz[], int n_senz, int n_solz)
int32_t end_p94
Definition: atrem.h:35
float tg_seno[NBANDS]
Definition: atrem_corl1.h:127
float tg_sen[NBANDS]
Definition: atrem_corl1.h:127
int32_t ndtot
Definition: atrem.h:44
float f1a
Definition: atrem_corl1.h:229
void ecdf_(float *xcdf, float *ycdf, int32_t *bin_number, float *xs, int32_t *sample_size)
Definition: numerical.c:22
int32_t imn
Definition: atrem_corl1.h:161
float f1b
Definition: atrem_corl1.h:229
int32_t jbc
Definition: atrem_corl1.h:239
float dlt2
Definition: atrem_corl1.h:149
int32_t co
Definition: atrem_corl1.h:118
double wt3
Definition: atrem.h:47
struct @25 getinput4_
void get_input_()
#define NBANDS
Definition: atrem_corl1.h:16
int j
Definition: decode_rs.h:73
void init_speccal_()
int32_t day
float dvap_layer
Definition: atrem_corl1.h:178
float solzn_l2
Definition: atrem_corl1.h:225
float r0p94[NH2OMAX]
Definition: atrem_corl1.h:213
int32_t full_calc
Definition: atrem_corl1.h:148
int splitpaths
Definition: atrem_corl1.h:228
struct @24 getinput3_
float dp_layer
Definition: atrem_corl1.h:178
struct @22 input_l2gen_
int32_t ndtot
Definition: atrem_corl1.h:209
int32_t nb2
Definition: atrem_corl1.h:157
int32_t nl
Definition: atrem_corl1.h:132
int32_t nb2
Definition: atrem.h:21
int32_t ist1p14
Definition: atrem_corl1.h:194
struct @31 model_adj1_
int32_t o3
Definition: atrem_corl1.h:118
int32_t nctot
Definition: atrem.h:44
float taer55
Definition: atrem_corl1.h:133
int32_t nbtot
Definition: atrem_corl1.h:209
int32_t ncv2
Definition: atrem.h:42
float wndow4
Definition: atrem_corl1.h:153
float hp[MODELMAX]
Definition: atrem_corl1.h:173
int32_t co2
Definition: atrem_corl1.h:118
int32_t nh2o
Definition: atrem_corl1.h:186
int32_t end_1p14
Definition: atrem.h:38
void locate_pos_(float *xx, int32_t *n1, float *x1, int32_t *jj)
int32_t ied1p14
Definition: atrem_corl1.h:194
int32_t nbtot
Definition: atrem.h:44
float sno2
Definition: atrem_corl1.h:133
int32_t nbp94
Definition: atrem.h:23
float v
Definition: atrem_corl1.h:133
double r1p14[TBLMAX]
Definition: atrem.h:60
float wndow1
Definition: atrem_corl1.h:153
float wndow2
Definition: atrem_corl1.h:153
double r0p94[TBLMAX]
Definition: atrem.h:59
int32_t natot
Definition: atrem.h:44
float g_other[MODELMAX]
Definition: atrem_corl1.h:217
int32_t nb4
Definition: atrem_corl1.h:157
int32_t nb1
Definition: atrem_corl1.h:157
list(APPEND LIBS ${NETCDF_LIBRARIES}) list(APPEND LIBS $
Definition: CMakeLists.txt:9
struct @36 init_speccal6_
float h[MODELMAX]
Definition: atrem_corl1.h:131
float * lat
float hsurf
Definition: atrem_corl1.h:149
double wt4
Definition: atrem.h:47
int findMatch_(float *list, int *nobs, float *elem)
double g_vap_equiv
Definition: atrem.h:58
float q
Definition: atrem_corl1.h:169
float cst5
Definition: atrem_corl1.h:237
float xpss
Definition: atrem_corl1.h:165
struct @46 debug_atrem
float cst3
Definition: atrem_corl1.h:237
int32_t istp94
Definition: atrem_corl1.h:190
int32_t nb3
Definition: atrem_corl1.h:157
float fwhm[NBANDS]
Definition: atrem_corl1.h:144
int32_t ied4
Definition: atrem_corl1.h:194
struct @30 getinput14_
float vrto3
Definition: atrem_corl1.h:133
void model_adj_()
float clmvap
Definition: atrem_corl1.h:169
struct @41 tran_table1_
float tp[MODELMAX]
Definition: atrem_corl1.h:173
struct @40 init_speccal11_
float wt2
Definition: atrem_corl1.h:198
int32_t dln
Definition: atrem_corl1.h:123
int32_t jac
Definition: atrem_corl1.h:239
int32_t im
Definition: atrem_corl1.h:161
int32_t nctot
Definition: atrem_corl1.h:209
#define MODELMAX
Definition: atrem_corl1.h:20
float ncvhf2
Definition: atrem_corl1.h:203
int32_t h2o
Definition: atrem_corl1.h:118
int get_angle_limits(float **angle_limit, float **senz, float **solz, int *n_senz, int *n_solz)
int jb
Definition: atrem_corl1.h:227
float dp_plane
Definition: atrem_corl1.h:178
float water_vapor
Definition: atrem_corl1.h:226
int32_t ist3
Definition: atrem_corl1.h:194
float cst1
Definition: atrem_corl1.h:237
int32_t istrt2
Definition: atrem_corl1.h:204
struct @28 getinput7_
int32_t nb4
Definition: atrem.h:21
int32_t start_ndx[4]
Definition: atrem.h:31
float vap_slant_mdl
Definition: atrem_corl1.h:221
int32_t nobs
Definition: atrem_corl1.h:148
int32_t ied3
Definition: atrem_corl1.h:194
float senaz_l2
Definition: atrem_corl1.h:225
double rp94
Definition: atrem_corl1.h:238
float g_vap_equiv
Definition: atrem_corl1.h:217
int32_t no2
Definition: atrem_corl1.h:118
float f2a
Definition: atrem_corl1.h:229
double wt1
Definition: atrem.h:47
float senzn_l2
Definition: atrem_corl1.h:225
int32_t start_1p14
Definition: atrem.h:37
#define NH2OMAX
Definition: atrem_corl1.h:17
float g_vap[MODELMAX]
Definition: atrem_corl1.h:217
struct @21 getinput1_
struct @35 init_speccal3_
double wt2
Definition: atrem.h:47
int32_t ied2
Definition: atrem_corl1.h:190
struct @33 model_adj3_
struct @26 getinput5_
int32_t iend2
Definition: atrem_corl1.h:204
void model_adjust()
float wt1
Definition: atrem_corl1.h:198
float vmrp[MODELMAX]
Definition: atrem_corl1.h:173
float tg_sol[NBANDS]
Definition: atrem_corl1.h:127
int get_atrem_cor(int32_t sensorID, l1str *l2rec, int32_t ip, float *rhot, float *tg_tot, float *tg_sol, float *tg_sen)
float pp[MODELMAX]
Definition: atrem_corl1.h:173
float dlt
Definition: atrem_corl1.h:149
float wt3
Definition: atrem_corl1.h:198
struct @34 model_adj4_
int32_t ja
Definition: atrem_corl1.h:199
double trntbl[TBLMAX][NBANDS]
Definition: atrem.h:66
int32_t hunt(float *xx, int32_t n, double x, int32_t jlo)
double finst2[FINSTMAX]
Definition: atrem.h:61
struct @37 init_speccal7_
int32_t iedp94
Definition: atrem_corl1.h:190
void geometry_()
void kdistgasabs_(float *kcdf, float *abscf, float *waveno, float *wavobs, int32_t *np_hi, int32_t *nlayers, int32_t *nwave)
float w1p14c
Definition: atrem_corl1.h:153
int32_t nh2o
Definition: atrem.h:25
int32_t ist4
Definition: atrem_corl1.h:194
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
float cst6
Definition: atrem_corl1.h:237
int32_t o2
Definition: atrem_corl1.h:118
float r1p14[NH2OMAX]
Definition: atrem_corl1.h:213
int32_t iaer
Definition: atrem_corl1.h:132
int32_t nobs
Definition: atrem.h:26
int32_t ih
Definition: atrem_corl1.h:161
float water_vapor
Definition: atrem_corl1.h:89
float trntbl[NH2OMAX][NBANDS]
Definition: atrem_corl1.h:213
int32_t nb1p14
Definition: atrem_corl1.h:157
int32_t end_ndx[4]
Definition: atrem.h:32
float get_atrem(float *tg_tot, float *rhot, paramstr *P)
struct @43 geometry4_
float wp94c
Definition: atrem_corl1.h:153
void channelRatio_()
float dvap_plane
Definition: atrem_corl1.h:178
int32_t natot
Definition: atrem_corl1.h:209
int32_t nbp94
Definition: atrem_corl1.h:157
#define FINSTMAX
Definition: atrem_corl1.h:19
float ncvtt2
Definition: atrem_corl1.h:203
int32_t end2
Definition: atrem.h:41
double vaptot[TBLMAX]
Definition: atrem.h:63
struct @44 geometry_l2gen_
double delta
Definition: atrem.h:54
int32_t nbands
float t_array[NBANDS]
Definition: atrem_corl1.h:30
struct @27 getinput6_
int32_t k_plane
Definition: atrem_corl1.h:177
float cst4
Definition: atrem_corl1.h:237
int32_t dogeom
Definition: atrem_corl1.h:61
float vmr[MODELMAX]
Definition: atrem_corl1.h:131
struct @32 model_adj2_
float xppp
Definition: atrem_corl1.h:165
float sh2o
Definition: atrem_corl1.h:213
struct @38 init_speccal8_
int32_t nb1
Definition: atrem.h:21
int32_t nb1p14
Definition: atrem.h:23
int32_t ch4
Definition: atrem_corl1.h:118
float wavobs[NBANDS]
Definition: atrem_corl1.h:144
struct @45 tpvmr_init1_
float cst2
Definition: atrem_corl1.h:237
struct @23 tran_table_l2gen_
float wndow3
Definition: atrem_corl1.h:153
int32_t rdatreminfo(int32_t sensorID, int32_t evalmask, const char *pname, void **pval)
Definition: rdatreminfo.c:38
int32_t model
Definition: atrem_corl1.h:132
float ncv2
Definition: atrem_corl1.h:203
int32_t start2
Definition: atrem.h:40
int getModelNum(float lat, int32_t day)
int32_t ied1
Definition: atrem_corl1.h:190
struct @42 geometry3_
float vaptot[NH2OMAX]
Definition: atrem_corl1.h:213
struct @29 getinput8_
int32_t ist1
Definition: atrem_corl1.h:190
int32_t idy
Definition: atrem_corl1.h:161
float finst2[FINSTMAX]
Definition: atrem_corl1.h:205
int i
Definition: decode_rs.h:71
float wt4
Definition: atrem_corl1.h:198
int32_t sensorID[MAXNFILES]
Definition: l2bin.cpp:95
float t[MODELMAX]
Definition: atrem_corl1.h:131
int32_t iyr
Definition: atrem_corl1.h:161
int32_t k_surf
Definition: atrem_corl1.h:182
int init_atrem(int32_t sensorID, paramstr *P, l1str *l2rec, int32_t nbands)
int32_t is
Definition: atrem_corl1.h:161
int32_t nb3
Definition: atrem.h:21
float p[MODELMAX]
Definition: atrem_corl1.h:131
float tg_solo[NBANDS]
Definition: atrem_corl1.h:127
int init_tpvmr(int model)
struct @39 init_speccal10_
float f2b
Definition: atrem_corl1.h:229
int32_t nb
Definition: atrem_corl1.h:132
int32_t n2o
Definition: atrem_corl1.h:118
int32_t ist2
Definition: atrem_corl1.h:190
int32_t start_p94
Definition: atrem.h:34
void tran_table_()
double delta2
Definition: atrem.h:54
float tpvmr[81][7]
Definition: atrem_corl1.h:233