NASA Logo
Ocean Color Science Software

ocssw V2022
get_Cphyt.c
Go to the documentation of this file.
1 /*
2  * get_Cphyt.c
3  *
4  * This algorithm returns the concentration of the phytoplankton carbon (Cphyt) in mg m^-3, calculated using an
5  * empirical relationship derived from field data between analytical measurements of Cphyt and particulate
6  * backscattering coefficient.
7  *
8  * Reference:
9  * Graff, J.R., Westberry, T.K., Milligan, A.J., Brown, M.B., Dall’Olmo, G., Dongen-Vogels, V.v., Reifel, K.M., & Behrenfeld, M.J. (2015).
10  * Analytical phytoplankton carbon measurements spanning diverse ecosystems.
11  * Deep Sea Research Part I: Oceanographic Research Papers, 102, 16-25
12  *
13  * Created on: Mar 4, 2021
14  * Author: Minwei Zhang
15  */
16 
17 #include "l12_proto.h"
18 
19 void get_Cphyt(l2str *l2rec, float cphyt[])
20 {
21  float bbp_470;
22  float a1=12128., b1=0.59;
23 
24  int32_t ip;
25  int32_t ipb;
26 
27  static int32_t firstcall=1,ib443, nbands;
28  int32_t npix;
29  float *bbp,*bbp_s;
30  l1str *l1rec=l2rec->l1rec;
31 
32  if(firstcall){
33  firstcall=0;
34  ib443=bindex_get(443);
35  if (ib443 < 0) {
36  printf("get_Cphyt: incompatible sensor wavelengths (no 443 for bbp and bbp_s).\n");
37  exit(1);
38  }
39  nbands=l1rec->l1file->nbands;
40  }
41 
42  npix = l1rec->npix;
43  if (!giop_ran(l1rec->iscan)){
44  run_giop(l2rec);
45 
46  }
48  bbp_s=giop_get_bbp_s_pointer();
49  /* */
50  /* Compute desired products at each pixel */
51  /* */
52  for (ip = 0; ip < npix; ip++) {
53  cphyt[ip]=BAD_FLT;
54 
55  if(l2rec->l1rec->mask[ip] || l2rec->l1rec->solz[ip] >= SOLZNIGHT)
56  continue;
57 
58  ipb=ip*nbands+ib443;
59 
60  if(bbp[ipb]<0 || bbp[ipb]>0.15 || bbp_s[ip]<-3 || bbp_s[ip]>3)
61  continue;
62 
63  if(input->cphyt_opt==1){
64  bbp_470=bbp[ipb]*pow(443./470.,bbp_s[ip]);
65  cphyt[ip]=a1*bbp_470+b1;
66  }else if(input->cphyt_opt==2){
67  cphyt[ip]=13000.*bbp[ipb]-0.00035;
68  }else{
69  printf("get_Cphyt: unrecognized cphyt_opt=%d\n", input->cphyt_opt);
70  exit(1);
71  }
72 
73  }
74 
75 }
76 
77 
78 /* ---------------------------------------------------------------------- */
79 /* get_Cphyt_unc() computes uncertaintis for Cphyt models */
80 /* */
81 /* Author: L. McKinna (GO2Q) */
82 /* Created: Oct 2023 */
83 /* -----------------------------------------------------------------------*/
84 
85 
86 void get_Cphyt_unc(l2str *l2rec, float cphyt_unc[]) {
87 
88  float bbp_470, ubbp_470;
89  //Model coefficients
90  float a1=12128.;
91  //float b1=0.59;
92  float a2 = 13000.;
93  //float b2 = 0.00035;
94 
95  /*Uncertainties unreported. Update in next revision*/
96  float ua1 = 0.0;
97  float ub1 = 0.0;
98  float ua2 = 0.0;
99  float ub2 = 0.0;
100 
101  float dyd1, dyd2, dcda, dcdb, dcdbbp;
102 
103  int32_t ip;
104  int32_t ipb;
105  int32_t ierr;
106 
107  static int32_t firstcall=1,ib443, nbands;
108  int32_t npix;
109  float *bbp,*bbp_s, *ubbp_s;
110  l1str *l1rec=l2rec->l1rec;
111 
112 
113  if(firstcall){
114  firstcall=0;
115  ib443=bindex_get(443);
116  if (ib443 < 0) {
117  printf("get_Cphyt: incompatible sensor wavelengths (no 443 for bbp and bbp_s).\n");
118  exit(1);
119  }
120  nbands=l1rec->l1file->nbands;
121  }
122 
123  npix = l1rec->npix;
124  if (!giop_ran(l1rec->iscan)){
125  run_giop(l2rec);
126 
127  }
128  bbp=giop_get_bbp_pointer();
129  bbp_s=giop_get_bbp_s_pointer();
130  ubbp_s=giop_get_ubbp_s_pointer();
131  /* */
132  /* Compute desired products at each pixel */
133  /* */
134  for (ip = 0; ip < npix; ip++) {
135 
136  ipb = ip*nbands;
137  ierr = l1rec->npix * nbands + ipb;
138 
139  cphyt_unc[ip] = BAD_FLT;
140 
141  if(l2rec->l1rec->mask[ip] || l2rec->l1rec->solz[ip] >= SOLZNIGHT)
142  continue;
143 
144  ipb=ip*nbands+ib443;
145  ierr = npix*nbands + ipb;
146 
147  if(bbp[ipb]<0 || bbp[ipb]>0.15 || bbp_s[ip]<-3 || bbp_s[ip]>3)
148  continue;
149 
150  if(input->cphyt_opt==1){
151  bbp_470=bbp[ipb]*pow(443./470.,bbp_s[ip]);
152  dyd1 = pow(470./443.,bbp_s[ip]);
153  dyd2 = bbp_470 * log(443./470);
154  ubbp_470 = sqrt(pow(dyd1*bbp[ierr],2.) + pow(dyd2*ubbp_s[ip],2.));
155 
156  dcda = bbp_470;
157  dcdb = 0.0;
158  dcdbbp = a1;
159 
160  cphyt_unc[ip] = sqrt(pow(dcda*ua1,2.) + pow(dcdb*ub1,2.) + pow(dcdbbp*ubbp_470,2.));
161 
162  }else if(input->cphyt_opt==2){
163  dcda = bbp[ipb];
164  dcdb = 0.0;
165  dcdbbp = a2;
166 
167  cphyt_unc[ip] = sqrt(pow(dcda*ua2,2.) + pow(dcdb*ub2,2.) + pow(dcdbbp*bbp[ierr],2.));
168 
169  }else{
170  printf("get_Cphyt: unrecognized cphyt_opt=%d\n", input->cphyt_opt);
171  exit(1);
172  }
173 
174  }
175 
176 }
float * giop_get_ubbp_s_pointer()
Definition: giop.c:3809
read l1rec
void get_Cphyt(l2str *l2rec, float cphyt[])
Definition: get_Cphyt.c:19
instr * input
int giop_ran(int recnum)
Definition: giop.c:643
int bindex_get(int32_t wave)
Definition: windex.c:45
void get_Cphyt_unc(l2str *l2rec, float cphyt_unc[])
Definition: get_Cphyt.c:86
instead the metadata field ProcessingEnvinronment is filled in from the output of a call to the POSIX compliant function uname from within the L1B code A small bug in L1B_Tables an incorrect comparison of RVS coefficients for TEBs to RVS coefficients for RSBs was being made This was replaced with a comparison between TEB coefficients This error never resulted in an incorrect RVS correction but did lead to recalculating the coefficients for each detector in a thermal band even if the coefficients were the same for all detectors To reduce to overall size of the reflective LUT HDF fill values were eliminated from all LUTs previously dimensioned where and where NUM_TIMES is the number of time dependent table pieces In Preprocess a small error where the trailing dropped scan counter was incremented when the leading dropped scan counter should have been was fixed This counter is internal only and is not yet used for any chiefly to casting of were added to make it LINUX compatible Output of code run on LINUX machines displays differences of at most scaled sector incalculable values of the Emissive calibration factor b1
Definition: HISTORY.txt:576
float * giop_get_bbp_pointer()
Definition: giop.c:3782
#define SOLZNIGHT
Definition: l1.h:58
#define BAD_FLT
Definition: jplaeriallib.h:19
int32_t nbands
void run_giop(l2str *l2rec)
Definition: giop.c:2230
float * giop_get_bbp_s_pointer()
Definition: giop.c:3804
int npix
Definition: get_cmp.c:28