Go to the documentation of this file.
10 void get_mgiop(l2str *l2rec, l2prodstr *
p,
float prod[]) {
11 static int firstCall = 1;
12 int prodID =
p->cat_ix;
15 l1str *
l1rec = l2rec->l1rec;
16 int32 nwave =
l1rec->l1file->nbands;
23 float def_sdg[] = {0.01, 0.015, 0.02};
24 float def_eta[] = {0.0, 0.33, 0.67, 1.0};
40 static float **fit_par;
48 if (strcmp(
input->giop_aph_file,
"aph_nas"))
51 if ((aph = calloc(
npix * nwave,
sizeof (
float))) ==
NULL) {
52 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
56 if ((adg = calloc(
npix * nwave,
sizeof (
float))) ==
NULL) {
57 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
61 if ((bbp = calloc(
npix * nwave,
sizeof (
float))) ==
NULL) {
62 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
66 if ((chl = calloc(
npix,
sizeof (
double))) ==
NULL) {
67 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
72 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
77 if ((schl = calloc(
npix,
sizeof (
double))) ==
NULL) {
78 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
82 if ((snoc = calloc(
npix,
sizeof (
double))) ==
NULL) {
83 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
87 if ((sdia = calloc(
npix,
sizeof (
double))) ==
NULL) {
88 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
92 if ((nval = calloc(
npix,
sizeof (
double))) ==
NULL) {
93 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
97 if ((sbbp = calloc(
npix * nwave,
sizeof (
float))) ==
NULL) {
98 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
102 if ((sadg = calloc(
npix * nwave,
sizeof (
float))) ==
NULL) {
103 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
107 if ((saph = calloc(
npix * nwave,
sizeof (
float))) ==
NULL) {
108 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
113 printf(
"-E- %s line %d : error allocating memory for NAS.\n",
130 input->giop_iterate = 1;
135 for (ip = 0; ip <
npix; ip++) {
144 for (ibb = 0; ibb < nwave; ibb++) {
145 sbbp[ipb + ibb] = 0.0;
146 saph[ipb + ibb] = 0.0;
147 sadg[ipb + ibb] = 0.0;
148 bbp[ipb + ibb] = badval;
149 aph[ipb + ibb] = badval;
150 adg[ipb + ibb] = badval;
153 for (ipar = 0; ipar < npar; ipar++) {
154 fit_par[ip][ipar] = badval;
162 for (isdg = 0; isdg < 3; isdg++)
for (ieta = 0; ieta < 4; ieta++) {
164 input->giop_bbp_s = def_eta[ieta];
165 input->giop_adg_s = def_sdg[isdg];
175 for (ip = 0; ip <
l1rec->npix; ip++) {
177 ipb = ip * nwave + ib;
179 if (chl[ip] > 0.005 && chl[ip] < 200.0) {
184 sdia[ip] += fit_par[ip][0];
185 snoc[ip] += fit_par[ip][1];
187 sadg[ipb] += adg[ipb];
188 saph[ipb] += aph[ipb];
189 sbbp[ipb] += bbp[ipb];
191 for (ipar = 0; ipar < npar; ipar++) {
192 spar[ip][ipar] += fit_par[ip][ipar];
200 for (ip = 0; ip <
npix; ip++) {
204 if (
l1rec->mask[ip]) {
209 ipb = ip * nwave + ib;
214 prod[ip] = (
float) saph[ipb] / nval[ip];
218 prod[ip] = (
float) sadg[ipb] / nval[ip];
222 prod[ip] = (
float) sbbp[ipb] / nval[ip];
226 prod[ip] = (
float) schl[ip] / nval[ip];
230 prod[ip] = (
int) nval[ip];
234 prod[ip] = (
float)
fabs(snoc[ip] / nval[ip]) /
fabs(sdia[ip] / nval[ip]);
238 prod[ip] = (
float) spar[ip][ib] / nval[ip];
242 printf(
"-E- %s line %d : erroneous product ID %d passed to GIOP.\n",
243 __FILE__, __LINE__, prodID);
float * giop_get_aph_pointer()
float * giop_get_adg_pointer()
float * giop_get_chl_pointer()
void get_mgiop(l2str *l2rec, l2prodstr *p, float prod[])
float * giop_get_bbp_pointer()
float ** giop_get_fitpar_pointer()
void run_giop(l2str *l2rec)
float ** allocate2d_float(size_t h, size_t w)
Allocate a two-dimensional array of type float of a given size.