OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
qaa.c File Reference
#include <stdlib.h>
#include <math.h>
#include <stdarg.h>
#include <assert.h>
#include "qaa.h"
Include dependency graph for qaa.c:

Go to the source code of this file.

Functions

int qaa_is_initialized (void)
 
int qaa_init (int i410, int i440, int i490, int i555, int i670)
 
int qaa_set_param (int param,...)
 
int qaa_v6 (int nbands, double *wavel, double *Rrs, double *aw, double *bbw, double *rrs, double *u, double *a, double *bb, unsigned char *flags)
 
int qaaf_v6 (int nbands, float *wavel, float *Rrs, float *aw, float *bbw, float *rrs, float *u, float *a, float *bb, unsigned char *flags)
 
int qaa_decomp (int nbands, double *wavel, double *rrs, double *a, double *aw, double *adg, double *aph, unsigned char *flags)
 
int qaaf_decomp (int nbands, float *wavel, float *rrs, float *a, float *aw, float *adg, float *aph, unsigned char *flags)
 

Detailed Description

Quasi-Analytic Algorithm.

Author
Paul Martinolich
Naval Research Laboratory, Stennis Space Center, MS

This code implements version 6 of the QAA algorithm which was based on the original algorithm Lee, at al (2002) "Deriving inherent optical properties from water color: A multi-band quasi-analytical algorithm for optically deep water" Applied Optics, (41) 27, 5755-5772, 2002

The version 4 update was presented as Appendix A in the paper Lee, et al (2007) "Euphotic zone depth: Its derivation and implication to ocean-color remote sensing" Journal of Geophysical Research, Vol 112, C03009, doi:10,1029/2006JC003802.

The version 5 update is available at IOCCG web site: http://www.ioccg.org/groups/Software_OCA/QAA_v5.pdf

The version 6 update is available at IOCCG web site: http://www.ioccg.org/groups/Software_OCA/QAA_v6.pdf

Additional routines are used to initialize indices and other parameters with the goal to make the code generic for use in SeaWiFS/MODIS processing as well as hyperspectral data from an ASD or PHILLS.

Likewise, the code duplicates routines for float or double type variables. The 'float' routines have an 'f' after the 'qaa' prefix.

The following code example shows a example of running the QAA algorithm on SeaWiFS data (with notes on how to run it for other sensor and using the 670nm path or chl path).

#include "qaa.h"
#define NBANDS 7
// inputs
int idx410 = 0;
int idx440 = 1;
int idx490 = 2;
int idx555 = 3;
int idx670 = 4;
// SeaWiFS wavelengths (nm)
double wl[NBANDS] = { 412, 443, 490, 555, 670 };
// SeaWiFS band-averaged pure water absorption
double aw[NBANDS] = { 0.004641, 0.007095, 0.0015267, 0.032599, 0.4456 };
// SeaWiFS band-averaged pure water backscattering coefficient
double bbw[NBANDS] = { 0.003272, 0.002421, 0.001568, 0.0009394, 0.0004261 };
double Rrs[NBANDS];
// temporary space
double u[NBANDS], buf[4*NBANDS];
// outputs
double rrs[NBANDS];
double a[NBANDS], bb[NBANDS], adg[NBANDS], aph[NBANDS];
// read input Rrs
qaa_init( idx410, idx440, idx490, idx555, idx670);
// set the S parameter (default is 0.015)
// set the aw coefficients which differ based on sensor (Step 2)
// qaa_set_param( QAA_COEFS_PARAM, -1.204, -1.229, -0.395 ); // MODIS
// qaa_set_param( QAA_COEFS_PARAM, -1.273, -1.163, -0.295 ); // MERIS
// qaa_set_param( QAA_COEFS_PARAM, -1.146, -1.366, -0.469 ); // OCM1
// qaa_set_param( QAA_COEFS_PARAM, -1.318, -1.192, -0.206 ); // OCM2
// NOTE: OCM2 has no 670 band, but 620 can be used.
// qaa_set_param( QAA_COEFS_PARAM, -1.273, -1.366, -0.469 ); // SeaWiFS (default)
// run QAA using chl reference and decompose a into adg and aph components
// NOTE: if quality flags are undesired, a NULL can be passed to ignore them.
qaa_v6( NBANDS, wl, Rrs, rrs, u, buf, a, bb, NULL, NULL, flags );
qaa_decomp( NBANDS, wl, rrs, a, adg, aph, flags );
// write out results

Definition in file qaa.c.

Function Documentation

◆ qaa_decomp()

int qaa_decomp ( int  nbands,
double *  wavel,
double *  rrs,
double *  a,
double *  aw,
double *  adg,
double *  aph,
unsigned char *  flags 
)

Quasi-Analytical Algorithm - decomposition of total absorption.

Parameters
[in]nbandsnumber of bands in spectrum
[in]wavelwavelength of spectrum (nbands)
[in]rrsbelow-water remote sensing reflectance (nbands)
[in]atotal absorption (nbands)
[in]awpure-water absorption (nbands)
[out]adggelbstuff absorption (nbands)
[out]aphphytoplankton absorption (nbands)
[out]flagsquality flags (will be modified) or NULL

This implements Table 3 of the Quasi-Analytical Algorithm. It decomposes the total absorption into phytoplankton absorption and gelbstuff absorption.

This implementation adds a consistency check based on the phytoplankton absorption at 443nm to improve the decomposition of total absorption.

Definition at line 380 of file qaa.c.

◆ qaa_init()

int qaa_init ( int  i410,
int  i440,
int  i490,
int  i555,
int  i670 
)

initalize Quasi-Analytical Algorithm v4

Parameters
[in]i4100-relative index in spectrum of 410 nm
[in]i4400-relative index in spectrum of 440 nm
[in]i4900-relative index in spectrum of 490 nm
[in]i5550-relative index in spectrum of 555 nm
[in]i6700-relative index in spectrum of 670 nm

This routine should be called to initialize various parameters that may be adjusted in the QAA algorithm or that must be known apriori. For example, the user must supply the indices for various required band numbers and whether to perform the iteration in the QAA-555 algorithm (normally yes).

Definition at line 132 of file qaa.c.

◆ qaa_is_initialized()

int qaa_is_initialized ( void  )

determine if qaa algorithm properly initialized

Returns
1 if qaa_init has been previously called; 0, otherwise

Definition at line 113 of file qaa.c.

◆ qaa_set_param()

int qaa_set_param ( int  param,
  ... 
)

set a parameter for Quasi-Analytical Algorithm

Parameters
[in]paramname of parameter

This routine should be called to initialize various parameters that may be adjusted in the QAA algorithm or that must be known apriori. For example, the user must supply the indices for various required band numbers. Optionally, the user may define there own values for some parameters, like S.

Presently the only parameter the user may set is the S value.

Definition at line 163 of file qaa.c.

◆ qaa_v6()

int qaa_v6 ( int  nbands,
double *  wavel,
double *  Rrs,
double *  aw,
double *  bbw,
double *  rrs,
double *  u,
double *  a,
double *  bb,
unsigned char *  flags 
)

Quasi-Analytical Algorithm v6.

Parameters
[in]nbandsnumber of bands in spectrum
[in]wavelwavelength of spectrum (nbands)
[in]Rrsabove-water remote sensing reflectance (nbands)
[in]awpure-water absorption (nbands)
[in]bbwpure-water back scattering (nbands)
[out]rrsbelow-water remote sensing reflectance (nbands)
[out]uratio (nbands)
[out]atotal absorption (nbands)
[out]bbbackscattering (nbands)
[out]flagsquality flags (will be modified) or NULL

This implements version 6 of the Quasi-Analytical Algorithm.

Definition at line 200 of file qaa.c.

◆ qaaf_decomp()

int qaaf_decomp ( int  nbands,
float *  wavel,
float *  rrs,
float *  a,
float *  aw,
float *  adg,
float *  aph,
unsigned char *  flags 
)

Quasi-Analytical Algorithm - decomposition of total absorption.

See also
qaa_decomp()

Definition at line 450 of file qaa.c.

◆ qaaf_v6()

int qaaf_v6 ( int  nbands,
float *  wavel,
float *  Rrs,
float *  aw,
float *  bbw,
float *  rrs,
float *  u,
float *  a,
float *  bb,
unsigned char *  flags 
)

Quasi-Analytical Algorithm v4.

See also
qaa_v6()

Definition at line 279 of file qaa.c.

int qaa_init(int i410, int i440, int i490, int i555, int i670)
initalize Quasi-Analytical Algorithm v4
Definition: qaa.c:132
@ QAA_S_PARAM
Definition: qaa.h:12
#define NULL
Definition: decode_rs.h:63
int qaa_decomp(int nbands, double *wavel, double *rrs, double *a, double *aw, double *adg, double *aph, unsigned char *flags)
Quasi-Analytical Algorithm - decomposition of total absorption.
Definition: qaa.c:380
int qaa_set_param(int param,...)
set a parameter for Quasi-Analytical Algorithm
Definition: qaa.c:163
int qaa_v6(int nbands, double *wavel, double *Rrs, double *aw, double *bbw, double *rrs, double *u, double *a, double *bb, unsigned char *flags)
Quasi-Analytical Algorithm v6.
Definition: qaa.c:200
flags
Definition: DDAlgorithm.h:22
data_t u
Definition: decode_rs.h:74
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
@ NBANDS
Definition: make_L3_v1.1.c:53