ocssw V2020
windex.c
Go to the documentation of this file.
1 #include "l12_proto.h"
2 
3 #define WAVE_INDEX_NUM 13000
4 #define WAVE_INDEX_MIN 300
5 #define WAVE_INDEX_MAX (WAVE_INDEX_MIN + WAVE_INDEX_NUM)
6 
7 static int band_index[WAVE_INDEX_NUM + 1];
8 
9 /* ---------------------------------------------------------------------------------------- */
10 /* windex_set() - load direct access wavelength index */
11 
12 /* ---------------------------------------------------------------------------------------- */
13 void bindex_set(int32_t wave[], int nwave, int dwave_vswir) {
14  int iw, iw1, iw2, i;
15  int dwave;
16 
17  for (i = 0; i < WAVE_INDEX_NUM; i++) {
18  band_index[i] = -1;
19  }
20 
21  for (iw = 0; iw < nwave; iw++) {
22  if (wave[iw] > 3000)
23  dwave = 1000;
24  else
25  dwave = dwave_vswir;
26  iw1 = MAX(wave[iw] - dwave / 2, WAVE_INDEX_MIN) - WAVE_INDEX_MIN;
27  iw2 = MIN(wave[iw] + dwave / 2, WAVE_INDEX_MAX) - WAVE_INDEX_MIN;
28  if (band_index[iw1] != -1) {
29  /* adjust for overlapping band-passes */
30  iw1 = MAX(wave[iw]-(wave[iw] - wave[iw - 1]) / 2, WAVE_INDEX_MIN) - WAVE_INDEX_MIN;
31  }
32  for (i = iw1; i <= iw2; i++) {
33  band_index[i] = iw; // eliminated bindx
34  }
35  }
36 }
37 
38 
39 /* ---------------------------------------------------------------------------------------- */
40 /* bindex_get() - retrieve direct access wavelength index */
41 
42 /* ---------------------------------------------------------------------------------------- */
43 int bindex_get(int32_t wave) {
44  if (wave >= WAVE_INDEX_MIN && wave < WAVE_INDEX_MAX)
45  return (band_index[wave - WAVE_INDEX_MIN]);
46  else
47  return (-1);
48 }
49 
50 
51 /* ---------------------------------------------------------------------------------------- */
52 /* bindex_get_555() - retrieve direct access wavelength index of band nearest to 555nm */
53 
54 /* ---------------------------------------------------------------------------------------- */
55 int bindex_get_555(void) {
56  int ib = bindex_get(547); /* note: we want 547 for MODIS, not 555, hence the order */
57 
58  if (ib < 0) ib = bindex_get(550);
59  if (ib < 0) ib = bindex_get(555);
60  if (ib < 0) ib = bindex_get(560);
61  if (ib < 0) ib = bindex_get(565);
62 
63  return (ib);
64 }
65 
66 
67 /* ---------------------------------------------------------------------------------------- */
68 /* windex() - return wavelength index of table which is closest to sensor wavelength */
69 
70 /* ---------------------------------------------------------------------------------------- */
71 int windex(float wave, float twave[], int ntwave) {
72  int iw, index;
73  float wdiff;
74  float wdiffmin = 99999.;
75 
76  for (iw = 0; iw < ntwave; iw++) {
77 
78  /* break on exact match */
79  if (twave[iw] == wave) {
80  index = iw;
81  break;
82  }
83 
84  /* look for closest */
85  wdiff = fabs(twave[iw] - wave);
86  if (wdiff < wdiffmin) {
87  wdiffmin = wdiff;
88  index = iw;
89  }
90  }
91 
92  return (index);
93 }
94 
95 int windex_(float *wave, float twave[], int *ntwave) {
96  return (windex(*wave, twave, *ntwave));
97 }
98 
99 
100 /* ---------------------------------------------------------------------------------------- */
101 /* invbindex() - invert the band index, given a wavelength index (oy vey!) */
102 
103 /* ---------------------------------------------------------------------------------------- */
104 int invbindx(int band, int32_t *bindx, int nbands) {
105  int i;
106 
107  for (i = 0; i < nbands; i++)
108  if (band == bindx[i])
109  return (i);
110 
111  return (-1);
112 }
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
#define MAX(A, B)
Definition: swl0_utils.h:26
const int bindx[3]
Definition: DbLutNetcdf.cpp:31
#define MIN(x, y)
Definition: rice.h:169
int bindex_get_555(void)
Definition: windex.c:55
int windex_(float *wave, float twave[], int *ntwave)
Definition: windex.c:95
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second band
#define WAVE_INDEX_MIN
Definition: windex.c:4
#define WAVE_INDEX_MAX
Definition: windex.c:5
int windex(float wave, float twave[], int ntwave)
Definition: windex.c:71
int32_t nbands
#define fabs(a)
Definition: misc.h:93
#define WAVE_INDEX_NUM
Definition: windex.c:3
int invbindx(int band, int32_t *bindx, int nbands)
Definition: windex.c:104
void bindex_set(int32_t wave[], int nwave, int dwave_vswir)
Definition: windex.c:13
int i
Definition: decode_rs.h:71
int bindex_get(int32_t wave)
Definition: windex.c:43