OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
atrem_corl1v3.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 NH2OMAX 60
17 #define NH2OMAXM1 (NH2OMAX-1)
18 #define FINSTMAX 100
19 #define MODELMAX 25
20 #define ABSCF_MAXLYR 19
21 #define NO3PT 5001
22 #define NO2PT 5001
23 #define NINSTRF 5000
24 #define NP_HI 300000
25 #define NP_MED 25401
26 #define NP_STD 28001
27 #define NINSTR_MAX 3001
28 #define NPSHIF 2600 //NPSHIF = NP_STD - NP_MED
29 
30 #define VSTART 0.56 //Starting wavelength for calculations
31 #define VEND 3.1
32 #define DWAVLN 1e-4
33 #define DWAVNO 0.05 //Point spacing of high res. spectra (cm-1).
34 #define DLT_MED 0.0002 // 0.2-nm medium resolution spectrum.
35 #define FACDLT 2.0 //Factor to multiply DLT by to determine the
36 //range used in the Gaussian function
37 //calculation for smoothing spectra.
38 
39 #define ATREM_O3 1
40 #define ATREM_CO2 2
41 #define ATREM_NO2 4
42 #define ATREM_CO 8
43 #define ATREM_CH4 16
44 #define ATREM_O2 32
45 #define ATREM_N2O 64
46 
47 #define RAD_DEG 57.29577951
48 #define CONST1 2.7725887 // CONST1=4.0*ln(2)=2.7725887
49 
50 //typedef float t_array[NBANDS];
51 
52 typedef struct param_table {
53  /*Number of narrow channels to form broader window and absorption channels. */
54  int32_t nb1, nb2, nb3, nb4;
55  /*number of points used in channel ratios for both the .94- and 1.14-um regions */
56  int32_t nbp94, nb1p14;
57 
58  int32_t nh2o; /* number of water vapor values */
59  int32_t nbands; /* number of spectral bands in sensor */
60  /* 3-channel ratioing
61  * parameters for bands up to the 0.94-um water vapor band [index=0,1]
62  * parameters for bands up to the 1.14-um water vapor band [index=2,3]
63  * */
64  int32_t start_ndx[4]; //ist1,ist2,ist3,ist4
65  int32_t end_ndx[4]; //ied1,ied2,ied3,ied4
66  /* 3-channel ratioing parameters for the 0.94-um water vapor band */
67  int32_t start_p94;
68  int32_t end_p94;
69  /* 3-channel ratioing parameters for the 1.14-um water vapor band */
70  int32_t start_1p14;
71  int32_t end_1p14;
72  /* Parameters for smoothing output reflectance spectra. */
73  int32_t start2;
74  int32_t end2;
75  int32_t ncv2;
76  /* number of channels of the four AVIRIS spectrometers. */
77  int32_t natot, nbtot, nctot, ndtot;
78  /* how often to recalculate geometry
79  * dogeom = 1 - every pixel
80  */
81  int32_t dogeom;
82  /* Atmospheric model number */
83  int model;
84  /* Relative weights for the four window *
85  * channels used in channel-ratioing calculations */
86  int idx450; // 450 nm wavelength index
87 
88  double wt1, wt2, wt3, wt4;
89  /*
90  * delta, delta2 - resolution, in units of nm, of input
91  * spectra and resolution of output surface reflectance
92  * spectra. If DLT2>DLT, output spectra are smoothed
93  * using a gaussian function.
94  */
95  double delta, delta2;
96  /* The "equivalent" geometrical *
97  * factor corresponding to the total slant vapor amount *
98  * VAP_SLANT_MDL and the column vapor amount CLMVAP. */
99  double g_vap_equiv; // This depends on zenith angle and lat/lon of measurement
100  float *r0p94; //ratio for the 0.94 um H2O absorption band
101  float *r1p14; //ratio for the 1.14 um H2O absorption band
102  float *finst2; // some kind of smoothing factor calculated in INIT_SPECCAL only used for AVIRIS?
103  /* TOTAL SUN-SURFACE-SENSOR PATH WATER VAPOR IN UNITS OF CM */
104  float *vaptot;
105 
106  /* total transmittances of all gases that match the *
107  * resolutions of imaging spectrometers */
108  float **trntbl;
109  float water_vapor; // returned water vapor value from get_atrem
110  int ja, jb; // indices to tran_table from get_atrem
111  float f1a, f2a, f1b, f2b; // fractions for interpolation of transmittances in tran_table from get_atrem
112 } paramstr;
113 
114 float get_atrem(float *tg_tot, float *rhot, paramstr *P);
115 int get_atrem_cor(l1str *l1rec, int32_t ip, float *rhot, float *tg_tot, float *tg_sol, float *tg_sen);
116 int init_atrem(int32_t sensorID, paramstr *P, l1str *l2rec, int32_t nbands);
117 int32_t rdatreminfo(int32_t sensorID, int32_t evalmask, const char *pname, void **pval);
118 int get_angle_limits(float **angle_limit, float **senz, float **solz, int *n_senz, int *n_solz);
119 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);
120 int32_t hunt(float *xx, int32_t n, double x, int32_t jlo);
121 int init_tpvmr(int model);
122 int getModelNum(float lat, int32_t day);
123 int32_t findMatch(float *list, int32_t nbands, float elem);
124 void channelRatio();
125 void ecdf_(float *xcdf, float *ycdf, int32_t *bin_number, float *xs, int32_t *sample_size);
126 void kdistgasabs(float *kcdf, float *abscf, float*waveno, float *wavobs, int32_t np_hi, int32_t nlayers, int32_t nbands);
127 void model_adjust();
128 void locate_pos_(float *xx, int32_t *n1, float *x1, int32_t *jj);
129 void geometry();
131 void get_abscf_data(int levels, int bands, int sds_id, char filename[FILENAME_MAX], float* abscf, char *varname);
132 void get_tpvmr(size_t layers, size_t models, int sds_id,
133  char filename[FILENAME_MAX], char *varname, float* var_a);
134 int init_tpvmr_nc(int model);
135 void tran_table();
136 void tran_smooth(float *tran_hi);
137 void tran_smooth_others();
138 
139 struct {
140  int32_t h2o, co2, o3, n2o, co, ch4, o2, no2;
141 } getinput1_;
142 
143 struct {
144  char filename[FILENAME_MAX];
145  int32_t dln;
146 } input_l2gen_;
147 
148 struct {
149  float *tg_sol, *tg_sen, *tg_solo, *tg_seno; // nbands
151 
152 struct {
153  float *tran_hi_sa[2], *tran_hi_sap1[2], *tran_hi_sb[2], *tran_hi_sbp1[2];
154 } tran_tables_;
155 
156 struct {
169 
170 } tran_tables1_;
171 
172 struct {
174  int32_t nb, nl, model, iaer; //iaer not used because call to ssssss routine commented out in fortran code
175  float v, taer55, vrto3, sno2;
176  //nb = number of atmospheric levels in model
177  //nl = nb - 1
178  //sno2 = scaling factor for no2 (builtin NO2 column amount is 5.0E+15 molecules/cm^2
179  //vrto3 = column ozone amount (atm-cm) 0.28-0.55 is typical
180  //v = visibility (km)
181  //iaer = aerosol model value
182  //taerr55 = aerosol optical depth at 550 nm
183 } getinput3_;
184 
185 struct {
186  float *wavobs, *fwhm;
187 } getinput4_;
188 
189 struct {
190  int32_t nbands, full_calc;
191  float hsurf, dlt, dlt2;
192 } getinput5_;
193 
194 struct {
196 } getinput6_;
197 
198 struct {
199  int32_t nb1, nb2, nbp94, nb3, nb4, nb1p14;
200 } getinput7_;
201 
202 struct {
203  int32_t imn, idy, iyr, ih, im, is;
204 } getinput8_;
205 
206 struct {
207  float xpss, xppp;
208 } getinput14_;
209 
210 struct {
211  float clmvap, q;
212 } model_adj1_;
213 
214 struct {
216 } model_adj2_;
217 
218 struct {
219  int32_t k_plane;
221 } model_adj3_;
222 
223 struct {
224  int32_t k_surf;
225 } model_adj4_;
226 
227 struct {
228  float *tran_hi_others; //Transmittance of high res. data(.05cm-1)
230 
231 struct {
232  int32_t nh2o;
234 
235 struct {
238 
239 struct {
240  int32_t ist1, ied1, ist2, ied2, istp94, iedp94;
242 
243 struct {
246 
247 struct {
248  float wt1, wt2, wt3, wt4;
249  int32_t ja;
251 
252 struct {
253  int32_t ncv2, ncvhf2, ncvtt2;
254  int32_t istrt2, iend2;
255  float finst2[FINSTMAX];
257 
258 struct {
259  int32_t natot, nbtot, nctot, ndtot;
261 
262 struct {
265 
266 struct {
267  int32_t *index_med;
270 
271 /* Arrays for wavelength positions and FWHM of measured imaging spectrometer
272  data and for smoothing the medium resolution spectrum (FWHM = 0.2 nm,
273  and point spacing = 0.1 nm) to match coarser resolution spectrum
274  of imaging spectrometer data
275  */
276 struct {
277  float **finstr;
278  int32_t *ncvhf;
280 
281 struct {
282  float *tran_o3_std;
284 
285 struct {
286  float *tran_no2_std;
288 
289 struct {
290  float *sh2o, *vaptot, *r0p94, *r1p14, **trntbl;
291  float **tran_kd, **diff_tran, *trntblo;
292 } tran_table1_;
293 
294 struct {
296  int32_t day;
297 } geometry1_;
298 
299 struct {
301 } geometry2_;
302 
303 struct {
305 } geometry3_;
306 
307 struct {
309 } geometry4_;
310 
311 struct {
312  float mu, mu0, ssh2o_s[2][NH2OMAX];
313 } geometry5_;
314 
315 struct {
317  float water_vapor;
318  int32_t ja, jb;
319  int32_t splitpaths;
320  float f1a, f2a, f1b, f2b;
322 
323 struct {
324  float tpvmr[81][7];
325 } tpvmr_init1_;
326 //struct {
327 // float o3cf[NO3PT];
328 //} o3cf_init1_;
329 //struct {
330 // float rno2cf[NO2PT];
331 //} no2cf_init1_;
332 
333 struct {
334  float cst1, cst2, cst3, cst4, cst5, cst6;
335  double rp94, r1p14;
336  int32_t jac, jbc;
337 } debug_atrem;
338 #endif /* SRC_ATREM_ATREM_H_ */
int32_t imn
float totlo3
int32_t end_p94
Definition: atrem.h:35
int32_t im
int32_t ndtot
Definition: atrem.h:44
float * tran_med_sap1_sol
int32_t nbtot
float f2a
struct @91 tran_tables1_
float cst1
int init_atrem(int32_t sensorID, paramstr *P, l1str *l2rec, int32_t nbands)
struct @103 init_speccal1_
int get_atrem_cor(l1str *l1rec, int32_t ip, float *rhot, float *tg_tot, float *tg_sol, float *tg_sen)
int32_t idy
float obsphi
float hp[MODELMAX]
double wt3
Definition: atrem.h:47
struct @113 init_speccal15_
struct @116 tran_table1_
float * fwhm
float f2b
int32_t nbands
Definition: atrem_corl1v3.h:59
int32_t is
int j
Definition: decode_rs.h:73
int init_tpvmr(int model)
float * tran_std_sap1_sol
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
Definition: CMakeLists.txt:7
int32_t nb3
int32_t jbc
float * wavln_med
float pp[MODELMAX]
int32_t nbp94
int32_t nb2
Definition: atrem.h:21
float vmrp[MODELMAX]
int getModelNum(float lat, int32_t day)
int32_t nctot
Definition: atrem.h:44
float * tg_solo
float ** diff_tran
float * tran_med_sap1_sen
#define FINSTMAX
Definition: atrem_corl1v3.h:18
list levels
Definition: mapgen.py:180
struct @87 getinput1_
int32_t ncv2
Definition: atrem.h:42
int32_t no2
float * tran_med_index_sa_sol
int32_t nctot
int32_t h2o
float vrto3
float * tran_std_sb_sen
int32_t day
struct @122 geometry_l2gen_
struct @112 init_speccal13_
int32_t end_1p14
Definition: atrem.h:38
float * tran_med_index_sb_sen
int32_t ied3
int32_t iaer
float wndow3
void model_adjust()
int32_t nbtot
Definition: atrem.h:44
void locate_pos_(float *xx, int32_t *n1, float *x1, int32_t *jj)
float * tran_std_sa_sen
float senzn_l2
float * tran_hi_sap1[2]
float * wavobs
float * tran_hi_sa[2]
int32_t nbp94
Definition: atrem.h:23
float wt1
float ** tran_kd
struct @104 init_speccal3_
double r1p14[TBLMAX]
Definition: atrem.h:60
read l1rec
int32_t iyr
struct @100 model_adj2_
double r0p94[TBLMAX]
Definition: atrem.h:59
int32_t natot
Definition: atrem.h:44
float t[MODELMAX]
float g_vap[MODELMAX]
float g_vap_equiv
float * tran_hi_sb[2]
struct @121 geometry5_
float vmrm[MODELMAX]
int32_t ied4
int get_angle_limits(float **angle_limit, float **senz, float **solz, int *n_senz, int *n_solz)
float * tran_med_sb_sen
struct @96 getinput7_
float go3
float * lat
float * tg_seno
int32_t full_calc
float * tran_med_index_sa_sen
struct @92 getinput3_
double wt4
Definition: atrem.h:47
int32_t ied1
float wt2
double g_vap_equiv
Definition: atrem.h:58
float * tran_no2_std
float vmr[MODELMAX]
float * tran_med_sbp1_sen
int32_t dln
struct @101 model_adj3_
float sno2
float wt4
void init_spectral_calculations()
void get_tpvmr(size_t layers, size_t models, int sds_id, char filename[FILENAME_MAX], char *varname, float *var_a)
float cst6
float ** trntbl
struct @118 geometry2_
int init_tpvmr_nc(int model)
float tm[MODELMAX]
float * vaptot
float * tg_sen
int32_t nb
float v
int32_t ncv2
int32_t k_plane
void channelRatio()
float gn2o
int32_t k_surf
float wp94c
float * tran_med_sa_sen
float * sh2o
float solaz
float clmvapp
float wndow2
float senaz_l2
int32_t ch4
int32_t nb4
Definition: atrem.h:21
double rp94
#define MODELMAX
Definition: atrem_corl1v3.h:19
float p[MODELMAX]
float mu
float go2
int32_t findMatch(float *list, int32_t nbands, float elem)
float vap_slant_mdl
int32_t istrt2
float water_vapor
int32_t start_ndx[4]
Definition: atrem.h:31
int32_t rdatreminfo(int32_t sensorID, int32_t evalmask, const char *pname, void **pval)
Definition: rdatreminfo.c:38
int32_t nb4
int32_t natot
struct @123 tpvmr_init1_
float * tran_std_sbp1_sol
void tran_smooth(float *tran_hi)
int32_t iedp94
int32_t splitpaths
int32_t nl
int32_t nh2o
struct @109 init_speccal10_
double wt1
Definition: atrem.h:47
int32_t start_1p14
Definition: atrem.h:37
float * tran_std_sbp1_sen
float * r1p14
#define NH2OMAX
Definition: atrem_corl1v3.h:16
struct @108 init_speccal8_
int32_t co
double wt2
Definition: atrem.h:47
int32_t o2
struct @99 model_adj1_
int32_t * index_med
float * tran_med_index_sap1_sol
int32_t ist4
struct @94 getinput5_
char filename[FILENAME_MAX]
int32_t ist1p14
float pm[MODELMAX]
int32_t o3
float gch4
float g_other[MODELMAX]
int32_t ih
float * wavln_med_index
struct @90 tran_tables_
double finst2[FINSTMAX]
Definition: atrem.h:61
int32_t ist1
float dp_plane
float wt3
float ** tran_med_index
int32_t ied2
float dvap_layer
struct @88 input_l2gen_
int32_t nh2o
Definition: atrem.h:25
int32_t co2
float get_atrem(float *tg_tot, float *rhot, paramstr *P)
float ** finstr
float tp[MODELMAX]
void get_abscf_data(int levels, int bands, int sds_id, char filename[FILENAME_MAX], float *abscf, char *varname)
struct @124 debug_atrem
int32_t ied1p14
float ggeom
float f1b
int32_t ist3
int32_t nb2
float * tg_sol
struct @102 model_adj4_
float dlt2
float * tran_hi_sbp1[2]
float water_vapor
Definition: atrem_corl1.h:89
float * wavln_std
float xpss
int32_t end_ndx[4]
Definition: atrem.h:32
struct @114 init_speccal16_
float solzn_l2
float * tran_med_sa_sol
float dp[MODELMAX]
float dvap_plane
int32_t nb1
int32_t ncvtt2
float dp_layer
struct @97 getinput8_
struct @119 geometry3_
void tran_table()
float ssh2o[NH2OMAX]
float * tran_med_index_sap1_sen
float h[MODELMAX]
float f1a
int32_t end2
Definition: atrem.h:41
float hsurf
float q
struct @93 getinput4_
void kdistgasabs(float *kcdf, float *abscf, float *waveno, float *wavobs, int32_t np_hi, int32_t nlayers, int32_t nbands)
struct @115 init_speccal17_
struct @110 init_speccal11_
float wndow4
float taer55
double vaptot[TBLMAX]
Definition: atrem.h:63
struct @105 init_speccal5_
int32_t hunt(float *xx, int32_t n, double x, int32_t jlo)
float mu0
int32_t istp94
void ecdf_(float *xcdf, float *ycdf, int32_t *bin_number, float *xs, int32_t *sample_size)
Definition: numerical.c:22
float finst2[FINSTMAX]
float solzni
double delta
Definition: atrem.h:54
float cst4
int32_t nbands
float * tran_med_sb_sol
float * tran_med_index_sb_sol
int32_t dogeom
Definition: atrem_corl1.h:61
float * tran_std_sb_sol
float * trntblo
int32_t ncvhf2
float clmvap
float ssh2o_s[2][NH2OMAX]
float cst5
float * tran_std_sap1_sen
int32_t nb1
Definition: atrem.h:21
int32_t n2o
int32_t nb1p14
Definition: atrem.h:23
float ** trntbl
float gco
int32_t iend2
struct @95 getinput6_
struct @106 init_speccal6_
float xppp
float w1p14c
int32_t start2
Definition: atrem.h:40
int32_t jac
float cst3
int32_t ist2
int32_t model
int32_t * ncvhf
float * r0p94
float * tran_o3_std
float tpvmr[81][7]
int32_t jb
int32_t ndtot
int i
Definition: decode_rs.h:71
float wndow1
struct @111 init_speccal12_
int32_t sensorID[MAXNFILES]
Definition: l2bin.cpp:97
void tran_smooth_others()
struct @120 geometry4_
float * tran_med_index_sbp1_sen
float dlt
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)
float obszni
float * tran_std_sa_sol
float * tran_med_sbp1_sol
int32_t nb3
Definition: atrem.h:21
struct @117 geometry1_
float cst2
struct @89 tran_table_l2gen_
float gco2
float * tran_med_index_sbp1_sol
void geometry()
float * tran_hi_others
int32_t ja
int32_t nb1p14
int32_t start_p94
Definition: atrem.h:34
double delta2
Definition: atrem.h:54
struct @98 getinput14_
struct @107 init_speccal7_