OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
bnd_ix_2_sen_info.c
Go to the documentation of this file.
1 #include "viirs_sim_sdr.h"
2 #include "l12_parms.h"
3 
4 int bnd_ix_2_sen_info(char *pname, void *pval)
5 /*-----------------------------------------------------------------------------
6  Program: bnd_ix_2_sen_info
7 
8  Description: augment rdsensorinfo for the F0 and lambda lists to add
9  VIIRS M9 band info into the list
10 
11  Arguments:
12  Type Name I/O Description
13  ---- ---- --- -----------
14  char * pname I parameter name to get data for
15  void * pval I/O pointer to allocated storage location to
16  hold the data
17 
18  Modification history:
19 
20  W. Robinson, SAIC 21 Oct 2008 Original development
21 
22 ----------------------------------------------------------------------------*/ {
23  static int32_t m_bnd_ix[] = {0, 1, 2, 3, 4, 5, 6, 7, -1, 8, 9, 10, 11,
24  12, 13, 14};
25  static int n_gap = 1;
26  static int32_t lam_cirrus = 1378;
27  static float f0_cirrus = 36.463;
28  int iprm, ix_in, ix_out, ibnd;
29  void *lcl_prm;
30  int *lcl_int, *out_int;
31  float *lcl_flt, *out_flt;
32  /*
33  * depending on the parm name, set an integer value
34  */
35  if (strcmp(pname, "Lambda") == 0)
36  iprm = 0;
37  else if (strcmp(pname, "Fobar") == 0)
38  iprm = 1;
39  else {
40  printf("%s, %d: parameter %s is outside values this routine can handle\n",
41  __FILE__, __LINE__, pname);
42  return 1;
43  }
44  /*
45  * get the parameter list with rdsensorinfo
46  */
47  if (rdsensorinfo(VIIRSN, 0, pname, &lcl_prm) < 0) {
48  printf("%s, %d: failure to read sensor parameter %s\n",
49  __FILE__, __LINE__, pname);
50  }
51 
52  switch (iprm) {
53  case 0: lcl_int = (int *) lcl_prm;
54  out_int = (int *) pval;
55  break;
56  case 1: lcl_flt = (float *) lcl_prm;
57  out_flt = (float *) pval;
58  break;
59  }
60  /*
61  * insert the cirrus value, moving following values up 1
62  */
63  ix_in = MAX_BND - 1 - n_gap;
64  for (ibnd = 0, ix_out = MAX_BND - 1; ibnd < MAX_BND; ibnd++, ix_out--) {
65  if (m_bnd_ix[ix_out] >= 0) {
66  switch (iprm) {
67  case 0: *(out_int + ix_out) = *(lcl_int + ix_in);
68  break;
69  case 1: *(out_flt + ix_out) = *(lcl_flt + ix_in);
70  break;
71  }
72  ix_in--;
73  } else {
74  switch (iprm) {
75  case 0: *(out_int + ix_out) = lam_cirrus;
76  break;
77  case 1: *(out_flt + ix_out) = f0_cirrus;
78  break;
79  }
80  }
81  }
82  return 0;
83 }
#define VIIRSN
Definition: sensorDefs.h:23
#define MAX_BND
Definition: viirs_sim_sdr.h:34
int bnd_ix_2_sen_info(char *pname, void *pval)
int32_t rdsensorinfo(int32_t, int32_t, const char *, void **)
Definition: rdsensorinfo.c:69