Go to the documentation of this file.
17 static int32_t num_bands;
18 static uint idx_modis_band_11 = -1;
19 static uint idx_modis_band_1 = -1;
20 static int idx_red_min =
BAD_INT;
21 static int idx_red_max =
BAD_INT;
22 static int idx_grn_min =
BAD_INT;
23 static int idx_grn_max =
BAD_INT;
36 double rhos_grn = -0.0;
37 double rhos_red = 0.0;
38 int32_t num_pixels =
l1rec->npix;
40 for (int32_t idx_pixel = 0; idx_pixel < num_pixels; idx_pixel++) {
42 int32_t idx_band =
l1rec->l1file->nbands * idx_pixel;
45 uint grn_width = idx_grn_max - idx_grn_min + 1;
46 uint red_width = idx_red_max - idx_red_min + 1;
47 float *start_of_rhos_grn = &
l1rec->rhos[idx_band + idx_grn_min];
48 float *start_of_rhos_red = &
l1rec->rhos[idx_band + idx_red_min];
53 rhos_grn =
l1rec->rhos[idx_band + idx_modis_band_11];
54 rhos_red =
l1rec->rhos[idx_band + idx_modis_band_1];
57 double rhos_values[] = {rhos_grn, rhos_red};
58 double pixel_elevation =
l1rec->dem[idx_pixel];
60 size_t len_rhos_vals =
sizeof(rhos_values) /
sizeof(rhos_values[0]);
61 if (
invalid_pixel(pixel_elevation, landmask, rhos_values, len_rhos_vals)) {
66 double cci_value = (rhos_grn - rhos_red) / (rhos_grn + rhos_red);
74 num_bands =
l1rec->l1file->nbands;
76 static bool first_call =
true;
88 printf(
"CCI requires bands near 555 and 645 nm\n");
95 if (idx_modis_band_11 < 0 || idx_modis_band_1 < 0) {
96 printf(
"CCI requires bands near 555 and 645 nm\n");
const int32_t modis_b11_min
float average_rhos_values(float rhos_values[], size_t length)
Get the average of rho_s values from a hyperspectral measurement to approximate a multi-band measurem...
void get_cci(l1str *l1rec, float cci[])
const int32_t modis_b11_max
void calculate_cci(l1str *l1rec, float cci[])
int bindex_get(int32_t wave)
bool invalid_pixel(double pixel_elevation, double pixel_mask, double rhos_values[], int len_rhos_values)
Check pixel attributes for validity.
#define DEFAULT_BAND_INDEX
bool instrument_is_hyperspectral(int32_t num_bands)
float clamp(float pixel_value, int minimum, int maximum)
Clamp the value of a pixel between minval and maxval.