Go to the documentation of this file.
24 static int PMLRecNum = -1;
53 atot = (
float*) calloc(
npix*
nbands,
sizeof (
float));
54 aph = (
float*) calloc(
npix*
nbands,
sizeof (
float));
55 adg = (
float*) calloc(
npix*
nbands,
sizeof (
float));
56 bb = (
float*) calloc(
npix*
nbands,
sizeof (
float));
57 bbp = (
float*) calloc(
npix*
nbands,
sizeof (
float));
60 static float* alloc_bandsf(int32_t
nbands,
float *nbarray) {
61 if ((nbarray = (
float *) calloc(
nbands,
sizeof (
float))) ==
NULL) {
62 printf(
"-E- : Error allocating float memory in get_pml\n");
68 static double* alloc_bandsd(int32_t
nbands,
double *nbarray) {
69 if ((nbarray = (
double *) calloc(
nbands,
sizeof (
double))) ==
NULL) {
70 printf(
"-E- : Error allocating double memory in get_pml\n");
78 char configfname[FILENAME_MAX];
80 static int firstCall = 1;
88 static double *bb_pml;
89 static double *bbp_pml;
90 static double *adg_pml;
91 static double *aph_pml;
97 l1str *
l1rec = l2rec->l1rec;
102 buf = alloc_bandsf(4 *
nbands, buf);
104 rho_w = alloc_bandsd(
nbands, rho_w);
105 a_pml = alloc_bandsd(
nbands, a_pml);
106 bb_pml = alloc_bandsd(
nbands, bb_pml);
107 bbp_pml = alloc_bandsd(
nbands, bbp_pml);
108 adg_pml = alloc_bandsd(
nbands, adg_pml);
109 aph_pml = alloc_bandsd(
nbands, aph_pml);
114 if ((aw = (
float *) calloc(
nbands + 1,
sizeof (
float))) ==
NULL) {
115 printf(
"-E- : Error allocating memory to aw in get_pml\n");
118 if ((bbw = (
float *) calloc(
nbands + 1,
sizeof (
float))) ==
NULL) {
119 printf(
"-E- : Error allocating memory to bbw in get_pmln");
124 if ((tmp_str = getenv(
"OCDATAROOT")) ==
NULL) {
125 printf(
"OCDATAROOT environment variable is not defined.\n");
128 strcpy(configfname, tmp_str);
129 strcat(configfname,
"/common/pml.cfg");
130 printf(
"Loading PML IOP model config file: %s\n", configfname);
146 if (iw531 > 0 && iw510 < 0) {
147 printf(
"PML IOP model using MODIS eps_a slopes\n");
151 if (iw410 < 0 || iw440 < 0 || iw490 < 0 || iw510 < 0 || iw555 < 0) {
152 printf(
"-E- %s line %d: PML model requires bands near 410, 440, 490, 510 and 555nm\n",
158 for (ib = 0; ib <
nbands; ib++) {
163 for (ib = 0; ib <
nbands; ib++) {
165 bbw[ib] =
l1file->bbw[ib];
170 pml_init(1, iw410, iw440, iw490, iw510, iw555, iw670, aw, bbw);
174 for (ip = 0; ip <
l1rec->npix; ip++) {
182 for (ib = 0; ib <
nbands; ib++) {
196 if (!
l1rec->mask[ip]) {
201 for (ib = 0; ib <
nbands; ib++) {
202 Rrs[ib] = l2rec->Rrs[ipb + ib];
215 for (ib = 0; ib <
nbands; ib++) {
219 if (isfinite(bb_pml[ib]) &&
result != 1) {
220 bbp[ipb] = bb_pml[ib];
221 bb [ipb] = bb_pml[ib] + bbw[ib];
228 if (isfinite(a_pml[ib]) &&
result != 1)
229 atot[ipb] = a_pml[ib] + aw[ib];
235 if (isfinite(adg_pml[ib]) &&
result != 2)
236 adg[ipb] = adg_pml[ib];
242 if (isfinite(aph_pml[ib]) &&
result != 2)
243 aph[ipb] = aph_pml[ib];
252 PMLRecNum =
l1rec->iscan;
268 void get_pml(l2str *l2rec, l2prodstr *
p,
float prod[]) {
269 int band =
p->prod_ix;
270 int prodID =
p->cat_ix;
273 if (!
pml_ran(l2rec->l1rec->iscan))
276 for (ip = 0; ip < l2rec->l1rec->npix; ip++) {
278 ipb = ip * l2rec->l1rec->l1file->nbands +
band;
283 prod[ip] = (
float) atot[ipb];
287 prod[ip] = (
float) adg[ipb];
291 prod[ip] = (
float) aph[ipb];
295 prod[ip] = (
float) bb[ipb];
299 prod[ip] = (
float) bbp[ipb];
303 printf(
"-E- %s line %d : erroneous product ID %d passed to get_pml().\n",
304 __FILE__, __LINE__, prodID);
315 int32_t
nbands = l2rec->l1rec->l1file->nbands;
317 if (!
pml_ran(l2rec->l1rec->iscan))
320 for (ip = 0; ip < l2rec->l1rec->npix; ip++)
321 for (ib = 0; ib <
nbands; ib++) {
323 l2rec->a [ipb] = (
float) atot[ipb];
324 l2rec->bb[ipb] = (
float) bb [ipb];
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
int load_work_tab(char *configfname, int sensorID)
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
int pml_init(int iter8, int i410, int i440, int i490, int i510, int i555, int i670, float *awptr, float *bbwptr)
int bindex_get(int32_t wave)
void get_pml(l2str *l2rec, l2prodstr *p, float prod[])
float aw_spectra(int32_t wl, int32_t width)
float bbw_spectra(int32_t wl, int32_t width)
void load_config(char *configfname)
int pml_is_initialized(void)
int iop_model(double rho_w[], float sun_theta, float sen_theta, float dphi, double a[], double bbp[], double ady[], double ap[], int MODIS, int CASEII)
void run_pml(l2str *l2rec)
void iops_pml(l2str *l2rec)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
void alloc_pml(int32_t npix, int32_t nbands)