OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
mod_artifact.c
Go to the documentation of this file.
1 #include "viirs_sim_sdr.h"
2 #include <math.h>
3 
4 int mod_artifact(ctl_struc *ctl, in_rec_struc *in_rec)
5 /*-----------------------------------------------------------------------------
6  Program: mod_artifact.c
7 
8  Description: control all the artifact addition in this routine
9 
10  Arguments:
11  Type Name I/O Description
12  ---- ---- --- -----------
13  ctl_struc * ctl I input controls
14  in_rec_struc * in_rec I/O controls for input record reading
15 
16  Modification history:
17 
18  W. Robinson, SAIC 29 Apr 2010 Original development
19 
20 ----------------------------------------------------------------------------*/ {
21  int ibnd, ilin, ipix;
22  float *val_ptr;
23  /*
24  * Near Field Response, stray light artifact section
25  */
26  if (ctl->stray_opt == 1)
27  if (viirs_straylt(ctl, in_rec, 0) != 0)
28  return 1;
29  /*
30  * Optical Cross Talk section
31  */
32  if (ctl->oxt_mode == 1)
33  if (viirs_oxt(ctl, in_rec) != 0)
34  return 1;
35  /*
36  * Noise artifact is added here
37  */
38  if (ctl->noise_mode == 1)
39  if (viirs_noise(ctl, in_rec, 0) != 0)
40  return 1;
41  /*
42  * Electronic crosstalk needs to be applied to the dark-corrected counts,
43  * so the total rads must be de-calibrated first to apply this artifact
44  * and then calibrated again. Also, if the effects of different cal and
45  * de-cal or integerization errors of counts id needed, this branch can
46  * be run through. Possibly in the future, dn values could be returned
47  */
48  if (ctl->count_cal_opt > 0) {
49  /*
50  * NOTE that earlier, the de-cal and cal gain and rvs files
51  * would be set based on their existance in the inputs
52  *
53  * call the de-calibration step
54  */
55  if (viirs_decal(ctl, in_rec) != 0) return 1;
56 
57  /*
58  * The dn's are either the dark subtracted (dn) or non-subtracted (DN)
59  * based on input controls.
60  * this step will go through and integerize the dn values
61  *
62  * I take the best case - where the integer dn is nearest to the actual
63  * value
64  */
65  if (ctl->count_cal_opt == 2) {
66  for (ibnd = 0; ibnd < in_rec->nbnd; ibnd++)
67  for (ilin = 0; ilin < in_rec->ndet_scan; ilin++)
68  for (ipix = 0; ipix < in_rec->npix; ipix++) {
69  val_ptr = in_rec->dn[ibnd] + ipix + in_rec->npix * ilin;
70  *val_ptr = floorf(*val_ptr + 0.5);
71  }
72  }
73  /*
74  * The electronic crosstalk will be applied to the dn, gain information
75  */
76  if (ctl->ext_opt == 1)
77  if (viirs_ext(ctl, in_rec) != 0)
78  return 1;
79  /*
80  * Lastly, the dn values will get calibrated again, not necessarily
81  * with the same calibration values
82  */
83  if (viirs_cal(ctl, in_rec) != 0) return 1;
84  }
85  return 0;
86 }
int viirs_noise(ctl_struc *ctl, in_rec_struc *in_rec, int noise_stop)
Definition: viirs_noise.c:9
int viirs_ext(ctl_struc *ctl, in_rec_struc *in_rec)
Definition: viirs_ext.c:5
int mod_artifact(ctl_struc *ctl, in_rec_struc *in_rec)
Definition: mod_artifact.c:4
int viirs_decal(ctl_struc *ctl, in_rec_struc *in_rec)
Definition: viirs_decal.c:4
int viirs_cal(ctl_struc *ctl, in_rec_struc *in_rec)
Definition: viirs_cal.c:4
int viirs_straylt(ctl_struc *, in_rec_struc *, int)
Definition: viirs_straylt.c:7
int viirs_oxt(ctl_struc *ctl, in_rec_struc *in_rec)
Definition: viirs_oxt.c:9