OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
get_pft_hirata.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <math.h>
3 #include "l12_proto.h"
4 
5 float calc_microplankton_hirata(float chl) {
6  float a0 = 0.9117;
7  float a1 = -2.7330;
8  float a2 = 0.4003;
9  float x = log10(chl);
10 
11  float ans = 1.0 / (a0 + exp(a1 * x + a2));
12  if (ans > 1)
13  ans = 1;
14  if (ans < 0)
15  ans = 0;
16  return ans;
17 }
18 
19 float calc_diatoms_hirata(float chl) {
20  float a0 = 1.3272;
21  float a1 = -3.9828;
22  float a2 = 0.1953;
23  float x = log10(chl);
24 
25  float ans = 1.0 / (a0 + exp(a1 * x + a2));
26  if (ans > 1)
27  ans = 1;
28  if (ans < 0)
29  ans = 0;
30 
31  return ans;
32 }
33 
34 float calc_greenalgae_hirata(float chl) {
35  float a0 = 0.2490;
36  float a1 = -1.2621;
37  float a2 = -0.5523;
38  float x = log10(chl);
39  float y = chl;
40 
41  float ans = (a0 / y) * exp(a1 * pow(x + a2, 2));
42  if (ans > 1)
43  ans = 1;
44  if (ans < 0)
45  ans = 0;
46  return ans;
47 }
48 
49 float calc_picoplankton_hirata(float chl) {
50  float a0 = 0.1529;
51  float a1 = 1.0306;
52  float a2 = -1.5576;
53  float a3 = -1.859;
54  float a4 = 2.9954;
55  float x = log10(chl);
56 
57  float ans = -(1.0 / (a0 + exp(a1 * x + a2))) + a3 * x + a4;
58  if (ans > 1)
59  ans = 1;
60  if (ans < 0)
61  ans = 0;
62  return ans;
63 }
64 
65 float calc_prokaryotes_hirata(float chl) {
66  float a0 = 0.0067;
67  float a1 = 0.6154;
68  float a2 = -19.5190;
69  float a3 = 0.9643;
70  float a4 = 0.1027;
71  float a5 = -0.1189;
72  float a6 = 0.0626;
73  float x = log10(chl);
74  float y = chl;
75 
76  float ans = (a0 / a1 / y) * exp(((a2 * pow(x + a3, 2)) / pow(a1, 2))) + a4 * pow(x, 2) + a5 * x + a6;
77  if (ans > 1)
78  ans = 1;
79  if (ans < 0)
80  ans = 0;
81  return ans;
82 }
83 
84 float calc_prochlorococcus_hirata(float chl) {
85  float a0 = .0099;
86  float a1 = 0.6808;
87  //float a2 = -8.6276;
88  float a3 = 0.9668;
89  float a4 = 0.0074;
90  float a5 = -0.1621;
91  float a6 = 0.0436;
92  float x = log10(chl);
93  float y = chl;
94 
95  float ans = (a0 / a1 / y) * exp(((a3 * pow(x + a4, 2))) / pow(a1, 2)) + a4 * pow(x, 2) + a5 * x + a6;
96  if (ans > 1)
97  ans = 1;
98  if (ans < 0)
99  ans = 0;
100 
101  return ans;
102 }
103 
104 float calc_dinoflagellates_hirata(float chl) {
105  float ans = calc_microplankton_hirata(chl) - calc_diatoms_hirata(chl);
106  if (ans > 1)
107  ans = 1;
108  if (ans < 0)
109  ans = 0;
110 
111  return ans;
112 
113 }
114 
115 float calc_nanoplankton_hirata(float chl) {
116  float ans = 1.0 - calc_microplankton_hirata(chl) - calc_picoplankton_hirata(chl);
117  if (ans > 1)
118  ans = 1;
119  if (ans < 0)
120  ans = 0;
121 
122  return ans;
123 }
124 
125 float calc_picoeukaryotes_hirata(float chl) {
126  float ans = calc_picoplankton_hirata(chl) - calc_prokaryotes_hirata(chl);
127  if (ans > 1)
128  ans = 1;
129  if (ans < 0)
130  ans = 0;
131 
132  return ans;
133 }
134 
135 float calc_prymnesiophytes_hirata(float chl) {
136  float ans = calc_nanoplankton_hirata(chl) - calc_greenalgae_hirata(chl);
137  if (ans > 1)
138  ans = 1;
139  if (ans < 0)
140  ans = 0;
141 
142  return ans;
143 }
144 
145 void get_pft_hirata(l2str *l2rec, l2prodstr *p, float prod[]) {
146  int i;
147  l1str *l1rec = l2rec->l1rec;
148 
149  for (i = 0; i < l1rec->npix; i++) {
150  if (l2rec->chl[i] == BAD_FLT) {
151  prod[i] = BAD_FLT;
152  continue;
153  }
154 
155  switch (p->cat_ix) {
157  prod[i] = calc_microplankton_hirata(l2rec->chl[i]);
158  break;
159  case CAT_diatoms_hirata:
160  prod[i] = calc_diatoms_hirata(l2rec->chl[i]);
161  break;
163  prod[i] = calc_greenalgae_hirata(l2rec->chl[i]);
164  break;
166  prod[i] = calc_picoplankton_hirata(l2rec->chl[i]);
167  break;
169  prod[i] = calc_prokaryotes_hirata(l2rec->chl[i]);
170  break;
172  prod[i] = calc_prochlorococcus_hirata(l2rec->chl[i]);
173  break;
175  prod[i] = calc_dinoflagellates_hirata(l2rec->chl[i]);
176  break;
178  prod[i] = calc_nanoplankton_hirata(l2rec->chl[i]);
179  break;
181  prod[i] = calc_picoeukaryotes_hirata(l2rec->chl[i]);
182  break;
184  prod[i] = calc_prymnesiophytes_hirata(l2rec->chl[i]);
185  break;
186 
187  default:
188  printf("get_pft_hirata can not produce product %s\n", p->algorithm_id);
189  exit(1);
190  }
191  if (isnan(prod[i])) {
192  prod[i] = BAD_FLT;
193  l1rec->flags[i] |= PRODFAIL;
194  }
195  }
196 
197 
198 }
199 
200 /*
201 x = log(Chl-a)
202 y = Chl-a
203 Microplankton = (0.9117+exp(-2.7330x+0.4003))^-1
204 Diatoms = [1.3272 + exp (-3.9828*x + 0.1953)]^−1
205 Dinoflagellates = Microplankton-Diatoms
206 Nanplankton = 1-Microplanton-Picoplankton
207 Greenalgae = (0.2490/y) exp[-1.2621(x +-.05523)^2]
208 Prymnesiophytes = Nanoplankton-Green Algae #(Haptophytes)
209 Picoplankton = – [0.1529+ exp (1.0306 *x + -1.5576)]^−1 + -1.8597*x + 2.9954
210 Prokaryotes = (.0067 /.6154 /y) exp [-19.5190 (x + 0.9643)^2 /0.0067^2 ] + 0.1027*x^2 + -0.1189*x + 0.0626
211 Picoeukaryotes = Picoplankton-Prokaryotes
212 Prochlorococcus = (0.0099 /0.6808/y) exp [0.9668 (x + 0.0074 )^2 /0.0099^2 ]+ 0.0074*x^2 + -0.1621*x + 0.0436
213 
214  */
#define CAT_prochlorococcus_hirata
Definition: l2prod.h:296
#define CAT_prymnesiophytes_hirata
Definition: l2prod.h:300
#define CAT_picoplankton_hirata
Definition: l2prod.h:294
#define CAT_diatoms_hirata
Definition: l2prod.h:292
read l1rec
float calc_picoplankton_hirata(float chl)
float calc_diatoms_hirata(float chl)
#define PRODFAIL
Definition: l2_flags.h:41
#define CAT_microplankton_hirata
Definition: l2prod.h:291
float calc_picoeukaryotes_hirata(float chl)
float calc_nanoplankton_hirata(float chl)
float calc_dinoflagellates_hirata(float chl)
float calc_prochlorococcus_hirata(float chl)
#define CAT_nanoplankton_hirata
Definition: l2prod.h:298
#define CAT_prokaryotes_hirata
Definition: l2prod.h:295
float calc_greenalgae_hirata(float chl)
#define BAD_FLT
Definition: jplaeriallib.h:19
#define CAT_greenalgae_hirata
Definition: l2prod.h:293
float calc_prokaryotes_hirata(float chl)
void get_pft_hirata(l2str *l2rec, l2prodstr *p, float prod[])
float calc_prymnesiophytes_hirata(float chl)
#define CAT_dinoflagellates_hirata
Definition: l2prod.h:297
int i
Definition: decode_rs.h:71
float calc_microplankton_hirata(float chl)
Definition: get_pft_hirata.c:5
float p[MODELMAX]
Definition: atrem_corl1.h:131
#define CAT_picoeukaryotes_hirata
Definition: l2prod.h:299