OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
myprod.c
Go to the documentation of this file.
1 #include "l12_proto.h"
2 
3 /* ==================================================================== */
4 /* This module provides stubs for implementing user-defined algorithms. */
5 /* The products can than be output by MSL12 by specifying the name on */
6 /* the l2prod list (e.g., l2prod=chlor_a,myprod1,myprod2). Users can */
7 /* maintain this file and drop it into future MSL12 updates. BAF */
8 /* ==================================================================== */
9 
10 
11 /* --------------------------------------------------------------------- */
12 /* dummy program computes wavelength weighted integral of Rrs */
13 
14 /* --------------------------------------------------------------------- */
15 
16 void myprod1(l2str *l2rec, float prod[]) {
17  static int firstCall = 1;
18  static int32_t mask = ATMFAIL | LAND | HIGLINT | CLOUD; /* l2_flags.h */
19 
20  l1str *l1rec = l2rec->l1rec;
21 
22  int32_t npix = l1rec->npix;
23  int32_t nbands = l1rec->l1file->nbands;
24  int32_t ip, ib, ipb;
25  float sumwave;
26  float wave;
27 
28  /* arrays of pixel interlaced by band (see l2_struc.h, alloc_l2.c) */
29 
30  //float *nLw = l2rec->nLw; /* normalized water leaving radiances */
31  float *Rrs = l2rec->Rrs; /* remote sensiing reflectances */
32 
33 
34  if (firstCall) {
35 
36  /* do initializations and allocations here */
37 
38  firstCall = 0;
39  }
40 
41  for (ip = 0; ip < npix; ip++) {
42 
43  prod[ip] = 0.0;
44  sumwave = 0.0;
45 
46  /* skip masked pixels */
47  if ((l1rec->flags[ip] & mask) != 0)
48  continue;
49 
50  for (ib = 0; ib < nbands; ib++) {
51  ipb = ip * nbands + ib; /* index of band at pixel */
52  if (Rrs[ipb] > 0.0) {
53  wave = l1rec->l1file->fwave[ib];
54  prod[ip] += (Rrs[ipb] * wave);
55  sumwave += wave;
56  }
57  }
58 
59  printf("%f %f\n", prod[ip], sumwave);
60  if (sumwave > 0.0)
61  prod[ip] /= sumwave;
62  else
63  /* if you want to bin, you need a flag to indicate failure */
64  /* we use the PRODFAIL bit for general products */
65  l1rec->flags[ip] |= PRODFAIL;
66 
67  }
68  return;
69 }
70 
71 
72 
73 /* --------------------------------------------------------------------- */
74 /* put your algorithm here */
75 
76 /* --------------------------------------------------------------------- */
77 void myprod2(l2str *l2rec, float prod[]) {
78 }
79 
80 /* --------------------------------------------------------------------- */
81 /* put your algorithm here */
82 
83 /* --------------------------------------------------------------------- */
84 void myprod3(l2str *l2rec, float prod[]) {
85 }
86 
87 /* --------------------------------------------------------------------- */
88 /* put your algorithm here */
89 
90 /* --------------------------------------------------------------------- */
91 void myprod4(l2str *l2rec, float prod[]) {
92 }
93 
94 /* --------------------------------------------------------------------- */
95 /* put your algorithm here */
96 
97 /* --------------------------------------------------------------------- */
98 void myprod5(l2str *l2rec, float prod[]) {
99 }
100 
101 /* --------------------------------------------------------------------- */
102 /* put your algorithm here */
103 
104 /* --------------------------------------------------------------------- */
105 void myprod6(l2str *l2rec, float prod[]) {
106 }
107 
108 /* --------------------------------------------------------------------- */
109 /* put your algorithm here */
110 
111 /* --------------------------------------------------------------------- */
112 void myprod7(l2str *l2rec, float prod[]) {
113 }
114 
115 /* --------------------------------------------------------------------- */
116 /* put your algorithm here */
117 
118 /* --------------------------------------------------------------------- */
119 void myprod8(l2str *l2rec, float prod[]) {
120 }
121 
122 /* --------------------------------------------------------------------- */
123 /* put your algorithm here */
124 
125 /* --------------------------------------------------------------------- */
126 void myprod9(l2str *l2rec, float prod[]) {
127 }
128 
129 /* --------------------------------------------------------------------- */
130 /* put your algorithm here */
131 
132 /* --------------------------------------------------------------------- */
133 void myprod10(l2str *l2rec, float prod[]) {
134 }
135 
read l1rec
void myprod1(l2str *l2rec, float prod[])
Definition: myprod.c:16
void myprod3(l2str *l2rec, float prod[])
Definition: myprod.c:84
#define PRODFAIL
Definition: l2_flags.h:41
void myprod8(l2str *l2rec, float prod[])
Definition: myprod.c:119
void myprod4(l2str *l2rec, float prod[])
Definition: myprod.c:91
void myprod5(l2str *l2rec, float prod[])
Definition: myprod.c:98
a context in which it is NOT documented to do so subscript which cannot be easily calculated when extracting TONS attitude data from the Terra L0 files Corrected several defects in extraction of entrained ephemeris and and as HDF file for both the L1A and Geolocation enabling retrieval of South Polar DEM data Resolved Bug by changing to opent the geolocation file only after a successful read of the L1A and also by checking for fatal errors from not restoring C5 and to report how many of those high resolution values were water in the new WaterPresent SDS Added valid_range attribute to Land SeaMask Changed to bilinearly interpolate the geoid_height to remove artifacts at one degree lines Made corrections to const qualification of pointers allowed by new version of M API library Removed casts that are no longer for same not the geoid Corrected off by one error in calculation of high resolution offsets Corrected parsing of maneuver list configuration parameter Corrected to set Height SDS to fill values when geolocation when for elevation and land water mask
Definition: HISTORY.txt:114
void myprod7(l2str *l2rec, float prod[])
Definition: myprod.c:112
#define CLOUD
Definition: l2_flags.h:20
void myprod10(l2str *l2rec, float prod[])
Definition: myprod.c:133
#define LAND
Definition: l2_flags.h:12
void myprod9(l2str *l2rec, float prod[])
Definition: myprod.c:126
#define ATMFAIL
Definition: l2_flags.h:11
void myprod2(l2str *l2rec, float prod[])
Definition: myprod.c:77
int32_t nbands
#define HIGLINT
Definition: l2_flags.h:14
void myprod6(l2str *l2rec, float prod[])
Definition: myprod.c:105
int npix
Definition: get_cmp.c:27