Go to the documentation of this file.
20 #define PML_FILE_ENDIAN 1
37 static int32_t refind = 0l;
38 static int32_t refind_max = 0l;
64 char fname[FILENAME_MAX];
67 int32_t t_nbands, v_len;
75 if ((tmp_str = getenv(
"OCDATAROOT")) ==
NULL) {
76 printf(
"OCDATAROOT environment variable is not defined.\n");
83 sprintf(sensor_name,
"seawifs");
88 sprintf(sensor_name,
"modis");
92 printf(
"Sensor not either SeaWiFS or MODIS and the LUTs do not exist\n");
97 sprintf(fname,
"%s/%s/iop/pml/%s", tmp_str, sensor_name,
get_cfg_s(
"gop_table", configfname));
98 if ((
table = fopen(fname,
"r")) ==
NULL) {
99 printf(
"Error opening %s\n", fname);
107 if (
nband != t_nbands) {
108 printf(
"Table band mismatch expected %d read %d\n", t_nbands,
nband);
109 printf(
"Using Geophysical Look-up Table: %s \n", fname);
114 a_w = calloc(
nband,
sizeof (
float));
115 b_w = calloc(
nband,
sizeof (
float));
127 ac[
i] = calloc(
ch_n,
sizeof (
float));
128 bc[
i] = calloc(
ch_n,
sizeof (
float));
147 as[
i] = calloc(
sp_n,
sizeof (
float));
148 bs[
i] = calloc(
sp_n,
sizeof (
float));
167 od[
i] = calloc(
od_n,
sizeof (
float));
177 created[v_len] =
'\0';
183 sprintf(fname,
"%s/%s/iop/pml/%s", tmp_str, sensor_name,
get_cfg_s(
"iop_F_head", configfname));
184 if ((
table = fopen(fname,
"r")) ==
NULL) {
185 printf(
"Error opening %s\n", fname);
193 if (
nband != t_nbands) {
194 printf(
"Table band mismatch expected %d read %d\n", t_nbands,
nband);
195 printf(
"Using IOP header Table: %s \n", fname);
199 t_lambda = calloc(
nband,
sizeof (
float));
204 if (fabsf(t_lambda[
i] -
lambda[
i]) > 15.0) {
205 printf(
"Error IOP table wavelength mismatch expected %f got %f\n",
lambda[
i], t_lambda[
i]);
234 sprintf(fname,
"%s/%s/iop/pml/%s", tmp_str, sensor_name,
get_cfg_s(
"iop_F_table", configfname));
235 if ((
table = fopen(fname,
"r")) ==
NULL) {
236 printf(
"Error opening %s\n", fname);
243 refen = (
float *) calloc((refind),
sizeof (
float));
245 fprintf(
stderr,
"load_work_tab: memory allocation failure for refen\n");
253 printf(
"IOP master table error: table too short!\n");
259 printf(
"IOP master table error: table too long!\n");
342 res = iopv[
band][(
int) ind]*(floor(ind) + 1.0 - ind) + iopv[
band][(
int) ind + 1]*(ind - floor(ind));
353 if (
u >
x[n - 1])
return n - 1;
354 for (
i = 0;
i < n;
i++) {
361 return ((
u -
x[
s]) / (
x[
s + 1] -
x[
s]) +
s);
371 if (
u >
x[n - 1])
return n - 1;
372 for (
i = 0;
i < n;
i++) {
379 if (
s == 0)
return ((
u -
x[
s]) / (
x[
s + 1] -
x[
s]) +
s);
380 return ((log(
u) - log(
x[
s])) / (log(
x[
s + 1]) - log(
x[
s])) +
s);
386 int setgeom(
float sun_theta,
float sen_theta,
float dphi) {
388 int32_t th_s_ent, th_v_ent, dphi_ent;
394 if (dphi < 0.0) dphi = dphi +
M_PI * 2.0;
395 if (dphi >
M_PI * 2.0) dphi = dphi -
M_PI * 2.0;
403 if (refind > refind_max) {
428 double ral, rah,
res;
430 if (
a > 0) al = (
int) floor(
a);
432 if (
b > 0) bl = (
int) floor(
b);
437 if ((bh > 15) || (ah > 15))
return 0.0;
454 printf(
"Call error in iop_ref (type = %d)\n", iop);
477 res =
r_ab(
geo2iop(
sp_lev,
as,
band, spm,
sp_n),
geo2iop(
sp_lev,
bs,
band, spm,
sp_n),
band);
490 res =
r_ab(
geo2iop(
ch_lev,
ac,
band, chl,
ch_n),
geo2iop(
ch_lev,
bc,
band, chl,
ch_n),
band);
double fint(double a, double b, int band)
int load_work_tab(char *configfname, int sensorID)
float sed_ref(float spm, int band)
float interp(float *x, float u, int n)
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT table(e.g. m1) to be used for interpolation. The table values will be linearly interpolated using the tables corresponding to the node times bracketing the granule time. If the granule time falls before the time of the first node or after the time of the last node
int get_cfg_i(char *tok, char *fname)
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second band
size_t fread_swap(int little_endian, void *ptr, size_t size, size_t nmemb, FILE *stream)
float geo2iop(float *levels, float *iopv[MAX_BANDS], int band, float value, int size)
int setgeom(float sun_theta, float sen_theta, float dphi)
float chl_ref(float chl, int band)
float r_ab(float a, float b, int band)
void load_config(char *configfname)
integer, parameter double
double f_ab(double a, double b, int band)
char * get_cfg_s(char *tok, char *fname)
float interp_l(float *x, float u, int n)
float iop_ref(float conc, int band, int iop)
float get_cfg_f(char *tok, char *fname)
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
int32_t sensorID[MAXNFILES]