OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
loadl1.c
Go to the documentation of this file.
1 /* =========================================================== */
2 /* Module loadl1.c */
3 /* */
4 /* Functions to fill a level-1b file with precomputed */
5 /* atmospheric and masking data. */
6 /* */
7 /* Note: due to filtering capabilities of MSl12, it can not be */
8 /* assumed that the same l1rec pointer will be passed in later */
9 /* calls to this function, so all fields must be reloaded. In */
10 /* addition, it is possible for MSl12 to process a L1B file */
11 /* containing data from different time periods, so earth-sun */
12 /* distance can not be assumed to be constant. */
13 /* */
14 /* Written By: */
15 /* */
16 /* B. A. Franz */
17 /* SAIC General Sciences Corp. */
18 /* NASA/SIMBIOS Project */
19 /* February 1999 */
20 /* */
21 /* Perturbed By: */
22 /* E.Karakoylu (SAIC) */
23 /* Summer 2015 */
24 /* =========================================================== */
25 
26 #include <stdio.h>
27 #include "l12_proto.h"
28 #include "smi_climatology.h"
29 #include "read_pixel_anc_file.h"
30 #include <libnav.h>
31 #include <xcal.h>
32 #include <smile.h>
33 
34 // noise option ------------//
35 #include <gsl/gsl_rng.h>
36 #include <gsl/gsl_randist.h>
37 #include <sys/time.h>
38 //--------------------------//
39 
40 unsigned long int random_seed() {
41  /* Seed generator for gsl. */
42  struct timeval tv;
43  gettimeofday(&tv, 0);
44  return (tv.tv_sec + tv.tv_usec);
45 }
46 
47 float make_noise(float sigma) {
48  unsigned long randSeed = random_seed();
49  float noise;
50  gsl_rng *rng;
51  rng = gsl_rng_alloc(gsl_rng_mt19937);
52  gsl_rng_set(rng, randSeed);
53  noise = gsl_ran_gaussian(rng, sigma);
54  gsl_rng_free(rng);
55  return (noise);
56 }
57 
58 float noise_model_hmodisa(float lt, int32_t iw, float snr_mult) {
59  /*
60  Noise coefficients entered in order: {C0,C1} such that C0 + C1 * lt
61  If iw corresponds 667 or 678 and snr_mult = 42 then coefficients for
62  667H and 678H are used. These are stored in the same order but in
63  an alternative array
64  */
65  static int firstpassperband = 0;
66 
67  float sigma, noise, snr, scaled_lt;
68  float ltSnrFitCoef[16][2] = {
69  {/*412:C0,C1*/0.05499859, 0.00008340},
70  {/*443:*/0.02939470, 0.00009380},
71  {/*469:*/0.11931482, 0.00008195},
72  {/*488:*/0.01927545, 0.00009450},
73  {/*531:*/0.01397522, 0.00010040},
74  {/*547:*/0.01139088, 0.00016480},
75  {/*555*/0.08769538, 0.00007000},
76  {/*645:*/0.10406925, 0.00008533},
77  {/*667L*/0.00496291, 0.00014050},
78  {/*678L*/0.00427147, 0.00013160},
79  {/*748*/0.00416994, 0.00021250},
80  {/*859*/0.04055895, 0.00019755},
81  {/*869*/0.00312263, 0.00018600},
82  {/*1240*/0.07877732, 0.00049940},
83  {/*1640*/0.26743281, 0.01044864},
84  {/*2130*/0.00628912, 0.00021160}
85  };
86  scaled_lt = lt;
87  noise = ltSnrFitCoef[iw][0] + ltSnrFitCoef[iw][1] * scaled_lt;
88  snr = scaled_lt * snr_mult / noise; //noise model based on
89  sigma = 1 / snr;
90  if (firstpassperband == iw) {
91  printf("Band: %d - Lt=%f - Sigma=%f\n", iw, lt, sigma);
92  firstpassperband++;
93  }
94  return sigma;
95 }
96 
97 float noise_model_swf(float lt, int32_t iw, float snr_mult) {
98 
99  static int firstpassperband = 0;
100  float sigma;
101  int i, fitPolyOrder = 4;
102  float snr = 0;
103  float ltSnrFitCoef[8][5] = {
104  {-8.28726301e-03, 3.85425664e-01, -9.10776926e+00, 1.65881862e+02, 4.54351582e-01},
105  {-1.21871258e-02, 5.21579320e-01, -1.14574109e+01, 1.96509056e+02, 4.18921861e-01},
106  {-2.99068165e-02, 1.05225457e-00, -1.90591166e+01, 2.66343986e+02, 6.67187489e-01},
107  {-5.68939986e-02, 1.67950509e-00, -2.56915149e+01, 3.05832773e+02, 9.34468454e-01},
108  {-1.31635902e-01, 3.09617393e-00, -3.73473556e+01, 3.52394751e+02, 3.54105899e-01},
109  {-8.65458303e-01, 1.18857306e+01, -8.37771886e+01, 4.64496430e+02, 4.14633422e-02},
110  {-4.96827099e+00, 4.50239057e+01, -2.10425126e+02, 7.75862055e+02, 5.18893137e-02},
111  {-1.30487418e+01, 9.35407901e+01, -3.40988182e+02, 9.43414239e+02, 7.84956550e-01}
112  };
113  /* Unused 2018-08-28 G. Fireman
114  float sigmaLim[8][2] = {
115  {0.00088, 0.059},
116  {0.00078, 0.05012},
117  {0.00073, 0.03689},
118  {0.00074, 0.03199},
119  {0.0008, 0.05593},
120  {0.00108, 0.04337},
121  {0.00093, 0.0261},
122  {0.00109, 0.02123}
123  };
124  */
125 
126 
127  for (i = 0; i < fitPolyOrder; i++)
128  snr += ltSnrFitCoef[iw][i] * pow(lt, (fitPolyOrder - i));
129  snr += ltSnrFitCoef[iw][fitPolyOrder];
130  snr *= snr_mult;
131  sigma = 1 / snr;
132  if (firstpassperband == iw) {
133  printf("Band: %d - Lt=%f - Sigma=%f\n", iw, lt, sigma);
134  firstpassperband++;
135  }
136  return sigma;
137 }
138 
139 float get_Lt_noise(float lt, int32_t iw, int32_t sensorID, float snr_fac) {
140 
141  float sigma;
142  float noise;
143 
144  switch (sensorID) {
145 
146  case SEAWIFS:
147  sigma = noise_model_swf(lt, iw, snr_fac);
148  break;
149 
150  case MODISA:
151  sigma = noise_model_hmodisa(lt, iw, snr_fac);
152  break;
153  default:
154  printf("-E-: %s line %d: Sensor not supported.\n", __FILE__, __LINE__);
155  exit(1);
156  break;
157  }
158 
159  noise = make_noise(sigma);
160  return noise;
161 }
162 
163 /*
164 float get_ws_noise(float ws_unc, float input_factor){
165  static int printPass = 0;
166 
167  float noise, sigma;
168  if (input_factor == 0.0)
169  sigma = fabs(ws_unc/2);
170  else if (input_factor > 0.0)
171  sigma = input_factor;
172  else
173  sigma = 0;
174  noise = make_noise(sigma);
175  if ((printPass % 1000000) == 0){
176  printf("WSNOISE=>%d: ws_unc=%f --ws_noise_flag=%f --sigma=%f --noise=%f \n",
177  printPass, ws_unc, input_factor, sigma, noise);
178  printPass += 1000000;
179  }
180  return noise;
181 }
182  */
183 
184 float get_anc_noise(float anc_unc, float anc_data, float inp_factor, char anc_name[20]) {
185  static int printPass = 0;
186 
187  float noise, sigma = 0;
188  if (inp_factor == 0.0)
189  sigma = fabs(anc_unc / anc_data / sqrt(2));
190  else if (inp_factor > 0.0)
191  sigma = fabs(inp_factor * anc_unc / anc_data / sqrt(2));
192  noise = make_noise(sigma);
193  if ((printPass % 1000000) == 0) {
194  printf("ANCNOISE=>%d: anc_name=%s|-|anc_unc=%f|-|anc_data=%f|-|inp-fac=%f|-|sigma=%f|-|noise=%f \n",
195  printPass, anc_name, anc_unc, anc_data, inp_factor, sigma, noise);
196  printPass += 1000000;
197  }
198  return noise;
199 }
200 
201 int loadl1(filehandle *l1file, l1str *l1rec) {
202  static double radeg = RADEG;
203  static int32_t sensorID = -999;
204  static float *aw;
205  static float *bbw;
206  int navfail_cnt = 0;
207 
208  int32_t ip, ipb, ib, iw, ix;
209  double esdist;
210  int32_t nbands = l1rec->l1file->nbands;
211 
212  double *rvs;
213  double temp;
214  float lt_noise = input->add_lt_noise;
215  float ws_noise = input->add_ws_noise;
216  float wd_noise = input->add_wd_noise;
217  float mw_noise = input->add_mw_noise;
218  float zw_noise = input->add_zw_noise;
219  float rh_noise = input->add_rh_noise;
220  float pr_noise = input->add_pr_noise;
221  float wv_noise = input->add_wv_noise;
222  float oz_noise = input->add_oz_noise;
223  float no2_tropo_noise = input->add_no2_tropo_noise;
224  float no2_strat_noise = input->add_no2_strat_noise;
225  float noise_factor;
226  float snr_factor;
227  static int firstpassperband = 0;
228  int16_t year, day;
229  double sec;
230  unix2yds(l1rec->scantime, &year, &day, &sec);
231 
232  if (sensorID != l1file->sensorID) {
233 
234  sensorID = l1file->sensorID;
235  aw = l1file->aw;
236  bbw = l1file->bbw;
237 
238 
239  printf("Loading land mask information from %s\n", input->land);
240  if (land_mask_init() != 0) {
241  printf("-E- %s : Unable to initialize land mask\n", __FILE__);
242  exit(1);
243  }
244 
245  printf("Loading DEM information from %s\n", input->demfile);
246  if (input->dem_auxfile[0])
247  printf("Loading auxiliary elevation file from %s\n", input->dem_auxfile);
248  if (dem_init() != 0) {
249  printf("-E- %s : Unable to initialize DEM \n", __FILE__);
250  exit(1);
251  }
252 
253  printf("Loading ice mask file from %s\n", input->icefile);
254  if (ice_mask_init(input->icefile, (int) year,
255  (int) day, input->ice_threshold) != 0) {
256  printf("-E- %s : Unable to initialize ice mask\n", __FILE__);
257  exit(1);
258  }
259 
260  }
261 
262  /* Get correction for Earth-Sun distance and apply to Fo */
263  int32_t yr = (int32_t) year;
264  int32_t dy = (int32_t) day;
265  int32_t ms = (int32_t) (sec * 1.e3);
266  esdist = esdist_(&yr, &dy, &ms);
267  l1rec->fsol = pow(1.0 / esdist, 2);
268 
269  for (iw = 0; iw < nbands; iw++) {
270  l1rec->Fo[iw] = l1file->Fobar[iw] * l1rec->fsol;
271  }
272 
273  /* Apply vicarious cross-calibration gains */
274 
275  for (ix = 0; ix < l1_input->xcal_nwave; ix++) {
276  if ((l1_input->xcal_opt[ix] & XCALRVS) != 0) {
277  if ((ib = bindex_get(l1_input->xcal_wave[ix])) < 0) {
278  printf("-E- %s line %d: xcal wavelength %f does not match sensor\n",
279  __FILE__, __LINE__, l1_input->xcal_wave[ix]);
280  exit(1);
281  };
282  rvs = get_xcal(l1rec, XRVS, l1file->iwave[ib]);
283 
284  for (ip = 0; ip < l1rec->npix; ip++) {
285  ipb = ip * nbands + ib;
286  if (rvs == 0x0) {
287  l1rec->Lt[ipb] = -999.0;
288  continue;
289  }
290  if (l1rec->Lt[ipb] > 0.0 && l1rec->Lt[ipb] < 1000.0)
291  l1rec->Lt[ipb] /= rvs[ip];
292  }
293  }
294  }
295 
296  for (ip = 0; ip < l1rec->npix; ip++) {
297  /* Apply vicarious calibration */
298 
299  for (iw = 0; iw < nbands; iw++) {
300  ipb = ip * nbands + iw;
301 
302  if (l1rec->Lt[ipb] > 0.0 && l1rec->Lt[ipb] < 1000.0) {
303  l1rec->Lt[ipb] *= l1_input->gain[iw];
304  l1rec->Lt[ipb] += l1_input->offset [iw];
305  }
306  }
307 
308  /*** Geolocation-based lookups ***/
309  if (!l1rec->navfail[ip]) {
310 
311  /* Enforce longitude convention */
312  if (l1rec->lon[ip] < -180.)
313  l1rec->lon[ip] += 360.0;
314 
315  else if (l1rec->lon[ip] > 180.0)
316  l1rec->lon[ip] -= 360.0;
317 
318  l1rec->dem[ip] = get_dem(l1rec->lat[ip], l1rec->lon[ip]);
319  /* Get terrain height */
320  if (input->proc_land) {
321  if (get_height(l1rec, ip,
322  l1file->terrain_corrected) != 0) {
323  printf("-E- %s line %d: Error getting terrain height.\n",
324  __FILE__, __LINE__);
325  return (1);
326  }
327  } else
328  l1rec->height[ip] = 0.0;
329 
330  /* Set land, bathymetry and ice flags */
331  if (input->proc_ocean != 2 &&
332  l1file->format != FT_L3BIN ) {
333  if( land_bath_mask(l1rec,ip) )
334  printf("-E- %s line %d: Error setting land and bathymetry masks.\n",
335  __FILE__, __LINE__);
336  }
337 
338  if (!l1rec->land[ip] &&
339  ice_mask(l1rec->lon[ip], l1rec->lat[ip]) != 0) {
340  l1rec->ice[ip] = ON;
341  }
342  } else {
343  navfail_cnt++;
344  }
345  /*** end Geolocation-based lookups ***/
346 
347  /* Set sea surface temperature and salinity, and seawater optical properties */
348  for (iw = 0; iw < nbands; iw++) {
349  ipb = ip * nbands + iw;
350  l1rec->sw_n [ipb] = 1.334;
351  // center band
352  l1rec->sw_a [ipb] = aw_spectra(l1file->fwave[iw], BANDW);
353  l1rec->sw_bb[ipb] = bbw_spectra(l1file->fwave[iw], BANDW);
354  // band-averaged
355  l1rec->sw_a_avg [ipb] = aw [iw];
356  l1rec->sw_bb_avg[ipb] = bbw[iw];
357  }
358 
359  l1rec->sstref[ip] = BAD_FLT;
360  l1rec->sssref[ip] = BAD_FLT;
361 
362  if (!l1rec->land[ip]) {
363  float bbw_fac;
364  l1rec->sstref[ip] = get_sstref(input->sstreftype, input->sstfile, l1rec, ip);
365  l1rec->sssref[ip] = get_sssref(input->sssfile, l1rec->lon[ip], l1rec->lat[ip], (int) day);
366  if (l1rec->sstref[ip] > BAD_FLT && l1rec->sssref[ip] > BAD_FLT && input->seawater_opt > 0) {
367  for (iw = 0; iw < nbands; iw++) {
368  ipb = ip * nbands + iw;
369  l1rec->sw_n [ipb] = seawater_nsw(l1file->fwave[iw], l1rec->sstref[ip], l1rec->sssref[ip], NULL);
370  // scale bbw based on ratio of center-band model results for actual sea state versus
371  // conditions of Morel measurements used to derive center and band-averaged bbw
372  bbw_fac = seawater_bb(l1file->fwave[iw], l1rec->sstref[ip], l1rec->sssref[ip], 0.039) / seawater_bb(l1file->fwave[iw], 20.0, 38.4, 0.039);
373  l1rec->sw_bb[ipb] *= bbw_fac;
374  l1rec->sw_bb_avg[ipb] *= bbw_fac;
375  }
376  }
377  }
379 
380  /* Compute relative azimuth */
381  /* CLASS AVHRR files contain relative azimuth so don't overwrite it */
382  if (sensorID != AVHRR) {
383  l1rec->delphi[ip] = l1rec->sena[ip] - 180.0 - l1rec->sola[ip];
384  }
385  if (l1rec->delphi[ip] < -180.)
386  l1rec->delphi[ip] += 360.0;
387  else if (l1rec->delphi[ip] > 180.0)
388  l1rec->delphi[ip] -= 360.0;
389 
390  /* Precompute frequently used trig relations */
391  l1rec->csolz[ip] = cos(l1rec->solz[ip] / radeg);
392  l1rec->csenz[ip] = cos(l1rec->senz[ip] / radeg);
393 
394  /* Scattering angle */
395  temp = sqrt((1.0 - l1rec->csenz[ip] * l1rec->csenz[ip])*(1.0 - l1rec->csolz[ip] * l1rec->csolz[ip]))
396  * cos(l1rec->delphi[ip] / radeg);
397  l1rec->scattang[ip] = acos(MAX(-l1rec->csenz[ip] * l1rec->csolz[ip] + temp, -1.0)) * radeg;
398 
399  }
400  /* get derived quantities for band-dependent view angles */
401  if (l1rec->geom_per_band != NULL)
403 
404  /* add ancillary data */
405  // the navfail_cnt test is a kludge to prevent processing failures for scans that are entirely invalid.
406  if (navfail_cnt != l1rec->npix) {
407  if (setanc(l1rec) != 0)
408  return (1);
409  }
410 
411  if (input->pixel_anc_file[0])
412  read_pixel_anc_file(input->pixel_anc_file, l1rec);
413 
414  if (input->windspeed > -999)
415  for (ip = 0; ip < l1rec->npix; ip++)
416  l1rec->ws[ip] = input->windspeed;
417  if (input->windangle > -999)
418  for (ip = 0; ip < l1rec->npix; ip++)
419  l1rec->wd[ip] = input->windangle;
420  if (input->pressure > -999)
421  for (ip = 0; ip < l1rec->npix; ip++)
422  l1rec->pr[ip] = input->pressure;
423  if (input->ozone > -999)
424  for (ip = 0; ip < l1rec->npix; ip++)
425  l1rec->oz[ip] = input->ozone;
426  if (input->watervapor > -999)
427  for (ip = 0; ip < l1rec->npix; ip++)
428  l1rec->wv[ip] = input->watervapor;
429  if (input->relhumid > -999)
430  for (ip = 0; ip < l1rec->npix; ip++)
431  l1rec->rh[ip] = input->relhumid;
432 
433  /* SWIM bathymetry */
434  // for (ip = 0; ip < l1rec->npix; ip++)
435  // if (!l1rec->navfail[ip])
436  // l1rec->dem[ip] = get_elev(l1rec->lat[ip], l1rec->lon[ip]);
437 
438  /* add atmospheric cnomponents that do not depend on Lt */
439  for (ip = 0; ip < l1rec->npix; ip++) {
440 
441  /* -------------------------------------------------------- */
442  /* Monte-Carlo and Other Uncertainty Processes */
443  /* -------------------------------------------------------- */
444 
445  if (ws_noise >= 0) {
446  char name[] = "ws_noise";
447  noise_factor = get_anc_noise(l1rec->ws_unc[ip], l1rec->ws[ip], ws_noise, name);
448  l1rec->ws[ip] *= (1 + noise_factor);
449  }
450  if (wd_noise >= 0) {
451  char name[] = "wd_noise";
452  noise_factor = get_anc_noise(l1rec->wd_unc[ip], l1rec->wd[ip], wd_noise, name);
453  l1rec->wd[ip] *= (1 + noise_factor);
454  }
455  if (mw_noise >= 0) {
456  char name[] = "mw_noise";
457  noise_factor = get_anc_noise(l1rec->mw_unc[ip], l1rec->mw[ip], mw_noise, name);
458  l1rec->mw[ip] *= (1 + noise_factor);
459  }
460  if (zw_noise >= 0) {
461  char name[] = "zw_noise";
462  noise_factor = get_anc_noise(l1rec->zw_unc[ip], l1rec->zw[ip], zw_noise, name);
463  l1rec->zw[ip] *= (1 + noise_factor);
464  }
465  if (rh_noise >= 0) {
466  char name[] = "rh_noise";
467  noise_factor = get_anc_noise(l1rec->rh_unc[ip], l1rec->rh[ip], rh_noise, name);
468  l1rec->rh[ip] *= (1 + noise_factor);
469  }
470  if (pr_noise >= 0) {
471  char name[] = "pr_noise";
472  noise_factor = get_anc_noise(l1rec->pr_unc[ip], l1rec->pr[ip], pr_noise, name);
473  l1rec->pr[ip] *= (1 + noise_factor);
474  }
475  if (wv_noise >= 0) {
476  char name[] = "wv_noise";
477  noise_factor = get_anc_noise(l1rec->wv_unc[ip], l1rec->wv[ip], wv_noise, name);
478  l1rec->wv[ip] *= (1 + noise_factor);
479  }
480  if (oz_noise >= 0) {
481  char name[] = "oz_noise";
482  noise_factor = get_anc_noise(l1rec->oz_unc[ip], l1rec->oz[ip], oz_noise, name);
483  l1rec->oz[ip] *= (1 + noise_factor);
484  }
485  if (no2_tropo_noise >= 0) {
486  char name[] = "no2_tropo_noise";
487  noise_factor = get_anc_noise(l1rec->no2_tropo_unc[ip], l1rec->no2_tropo[ip], no2_tropo_noise, name);
488  l1rec->no2_tropo[ip] *= (1 + noise_factor);
489  }
490  if (no2_strat_noise >= 0) {
491  char name[] = "no2_strat_noise";
492  noise_factor = get_anc_noise(l1rec->no2_strat_unc[ip], l1rec->no2_strat[ip], no2_strat_noise, name);
493  l1rec->no2_strat[ip] *= (1 + noise_factor);
494  }
495 
496  if (lt_noise) {
497  for (iw = 0; iw < nbands; iw++) {
498  ipb = ip * nbands + iw;
499  snr_factor = input->lt_noise_scale[iw];
500  if (snr_factor < 0)
501  noise_factor = 0;
502  else
503  noise_factor = get_Lt_noise(l1rec->Lt[ipb], iw, sensorID, snr_factor);
504  l1rec->Lt[ipb] *= (1 + noise_factor);
505  if (input->bias_frac[iw] > 0.0) {
506  l1rec->Lt[ipb] *= (1 + input->bias_frac[iw]);
507  if (firstpassperband == iw) {
508  if (iw == 0)
509  printf("-------Bias settings-------\n");
510  printf("Band: %d - Bias frac: %.3f\n", iw, input->bias_frac[iw]);
511  firstpassperband++;
512  }
513  }
514  }
515  }
516 
517  if (l1rec->is_l2){
518  // l1rec->Lt is actually Rrs, so skip atmo, etc
519  } else {
520  /* ------------------------------------------------ */
521  /* Ocean processing */
522  /* ------------------------------------------------ */
523  if ((input->proc_ocean != 0) && !l1rec->land[ip] && !l1rec->navfail[ip]) {
524 
525  atmocor1(l1rec, ip);
526 
527  /* set polarization correction */
528  polcor(l1rec, ip);
529 
530  /* add surface reflectance */
531  get_rhos(l1rec, ip);
532 
533  /* assign uncertainty on Lt if not already set by sensor-specific i/o */
534  for (iw = 0; iw < nbands; iw++) {
535  ipb = ip * nbands + iw;
536  if (l1rec->Lt_unc[ipb] < BAD_FLT + 1) {
537 
538  l1rec->Lt_unc[ipb] = (l1rec->Lt[ipb] - l1rec->Lr[ipb]) * input->gain_unc[iw];
539  }
540  }
541  }
542  /* ------------------------------------------------ */
543  /* Land Processing */
544  /* ------------------------------------------------ */
545  else if (input->proc_land && l1rec->land[ip] && !l1rec->navfail[ip]) {
546  atmocor1_land(l1rec, ip);
547  get_rhos(l1rec, ip);
548  }
549  /* ------------------------------------------------ */
550  /* General Processing */
551  /* ------------------------------------------------ */
552  else {
553  for (ib = 0; ib < nbands; ib++) {
554  ipb = ip * nbands + ib;
555  l1rec->Lr [ipb] = 0.0;
556  l1rec->t_sol [ipb] = 1.0;
557  l1rec->t_sen [ipb] = 1.0;
558  l1rec->tg_sol[ipb] = 1.0;
559  l1rec->tg_sen[ipb] = 1.0;
560  l1rec->t_o2 [ipb] = 1.0;
561  l1rec->t_h2o [ipb] = 1.0;
562  l1rec->polcor [ipb] = 1.0;
563  }
564  }
565  }
566 
567  }
568  /* set masks and flags */
569  if (setflags(l1rec) == 0)
570  return (1);
571 
572  setflagbits_l1(1, l1rec, -1);
573 
574  return (0);
575 }
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
#define MAX(A, B)
Definition: swl0_utils.h:26
int32_t day
float get_sstref(short reftyp, char *file, l1str *l1rec, int32_t ip)
Definition: sstref.c:1592
#define AVHRR
Definition: sensorDefs.h:15
int get_height(l1str *l1rec, int32_t ip, int terrain_corrected)
Definition: get_height.c:31
int loadl1(filehandle *l1file, l1str *l1rec)
Definition: loadl1.c:201
#define NULL
Definition: decode_rs.h:63
#define XCALRVS
Definition: l1.h:85
int dem_init()
Definition: read_mask.c:43
read l1rec
int geom_per_band_deriv(l1str *l1rec)
Definition: geom_per_band.c:51
#define XRVS
Definition: xcal.h:10
int setanc(l1str *l1rec)
Definition: setanc.c:563
double esdist_(int32_t *year, int32_t *day, int32_t *msec)
void polcor(l1str *l1rec, int32_t ip)
Definition: polcor.c:16
#define ON
Definition: l1.h:43
unsigned long int random_seed()
Definition: loadl1.c:40
instr * input
character(len=1000) if
Definition: names.f90:13
float noise_model_hmodisa(float lt, int32_t iw, float snr_mult)
Definition: loadl1.c:58
int land_mask_init()
Definition: read_mask.c:23
int bindex_get(int32_t wave)
Definition: windex.c:45
void atmocor1(l1str *l1rec, int32_t ip)
Definition: atmocor1.c:38
float seawater_nsw(float wave, float sst, float sss, float *dnswds)
Definition: seawater.c:8
int ice_mask_init(char *file, int year, int day, float threshold)
Definition: ice_mask.c:900
float get_sssref(char *file, float lon, float lat, int day)
Definition: sssref.c:360
int land_bath_mask(l1str *l1rec, int32_t ip)
Definition: read_mask.c:125
float noise_model_swf(float lt, int32_t iw, float snr_mult)
Definition: loadl1.c:97
float aw_spectra(int32_t wl, int32_t width)
l1_input_t * l1_input
Definition: l1_options.c:9
float bbw_spectra(int32_t wl, int32_t width)
int get_rhos(l1str *l1rec, int32_t ip)
Definition: get_rhos.c:23
int atmocor1_land(l1str *l1rec, int32_t ip)
Definition: atmocor1_land.c:16
char ice_mask(float lon, float lat)
Definition: ice_mask.c:993
void unix2yds(double usec, short *year, short *day, double *secs)
#define RADEG
Definition: czcs_ctl_pt.c:5
double * get_xcal(l1str *l1rec, int type, int wave)
Definition: xcal.c:33
#define BAD_FLT
Definition: jplaeriallib.h:19
int32_t nbands
#define fabs(a)
Definition: misc.h:93
float make_noise(float sigma)
Definition: loadl1.c:47
real *8 function esdist(iyr, iday, msec)
Definition: esdist.f:3
int setflags(l1str *l1rec)
Definition: setflags_l1.c:16
void setflagbits_l1(int level, l1str *l1rec, int32_t ipix)
Definition: setflags_l1.c:129
#define BANDW
Definition: l1.h:52
for(i=0;i< NROOTS;i++) s[i]
Definition: decode_rs.h:85
void read_pixel_anc_file(char *filename, l1str *l1rec)
float get_anc_noise(float anc_unc, float anc_data, float inp_factor, char anc_name[20])
Definition: loadl1.c:184
float get_Lt_noise(float lt, int32_t iw, int32_t sensorID, float snr_fac)
Definition: loadl1.c:139
float get_dem(float lat, float lon)
Definition: read_mask.c:112
#define SEAWIFS
Definition: sensorDefs.h:12
int i
Definition: decode_rs.h:71
int32_t sensorID[MAXNFILES]
Definition: l2bin.cpp:97
#define MODISA
Definition: sensorDefs.h:19
float seawater_bb(float wave, float sst, float sss, double delta)
Definition: seawater.c:176
@ FT_L3BIN
Definition: filetype.h:24
void seawater_set(l1str *l1rec)
Definition: seawater_get.c:8