OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
sensorInfo.c
Go to the documentation of this file.
1 #include <sensorInfo.h>
2 
3 #include <stddef.h>
4 #include <strings.h>
5 #include <stdlib.h>
6 
7 #include <genutils.h>
8 
9 // sensor name indexed by sensorId
10 static const char* sensorName[] = {
11  "SeaWiFS",
12  "MOS",
13  "OCTS",
14  "AVHRR",
15  "OSMI",
16  "CZCS",
17  "MODIST",
18  "MODISA",
19  "OCM1",
20  "OCM2",
21  "MERIS",
22  "VIIRSN",
23  "OCRVC",
24  "HICO",
25  "GOCI",
26  "OLIL8",
27  "Aquarius",
28  "OCIA",
29  "AVIRIS",
30  "PRISM",
31  "OLCIS3A",
32  "SGLI",
33  "MSIS2A",
34  "L5TM",
35  "L7ETMP",
36  "VIIRSJ1",
37  "MSIS2B",
38  "HAWKEYE",
39  "MISR",
40  "OLCIS3B",
41  "OCI",
42  "OCIS",
43  "VIIRSJ2",
44  "OLIL9",
45  "SPEXONE",
46  "HARP2",
47  "HARP"
48 };
49 
50 // instrument name indexed by sensorId
51 static const char *instrumentName[] = {
52  "SeaWiFS",
53  "MOS",
54  "OCTS",
55  "AVHRR",
56  "OSMI",
57  "CZCS",
58  "MODIS",
59  "MODIS",
60  "OCM",
61  "OCM-2",
62  "MERIS",
63  "VIIRS",
64  "OCRVC",
65  "HICO",
66  "GOCI",
67  "OLI",
68  "Aquarius",
69  "OCIA",
70  "AVIRIS",
71  "PRISM",
72  "OLCI",
73  "SGLI",
74  "MSI",
75  "L5TM",
76  "L7ETMP",
77  "VIIRS",
78  "MSI",
79  "HAWKEYE",
80  "MISR",
81  "OLCI",
82  "OCI",
83  "OCIS",
84  "VIIRS",
85  "OLI",
86  "SPEXONE",
87  "HARP2",
88  "HARP"
89 };
90 
91 
92 // platform name indexed by sensorId
93 static const char *platformName[] = {
94  "Orbview-2",
95  "IRS-P3",
96  "ADEOS",
97  "AVHRR",
98  "KOMPSAT",
99  "Nimbus-7",
100  "Terra",
101  "Aqua",
102  "IRS-P4",
103  "Oceansat-2",
104  "Envisat",
105  "Suomi-NPP",
106  "OCRVC",
107  "ISS",
108  "COMS",
109  "Landsat-8",
110  "SAC-D",
111  "PACE",
112  "AVIRIS",
113  "PRISM",
114  "Sentinel-3A",
115  "GCOM_C",
116  "Sentinel-2A",
117  "L5TM",
118  "L7ETMP",
119  "JPSS-1",
120  "Sentinel-2B",
121  "Seahawk1",
122  "Terra",
123  "Sentinel-3B",
124  "PACE",
125  "PACE",
126  "JPSS-2",
127  "Landsat-9",
128  "PACE",
129  "PACE",
130  "Air-HARP"
131 };
132 
133 // sensor directory indexed by sensorId
134 static const char *sensorDir[] = {
135  "seawifs",
136  "mos",
137  "octs",
138  "avhrr",
139  "osmi",
140  "czcs",
141  "modis",
142  "modis",
143  "ocm1",
144  "ocm2",
145  "meris",
146  "viirs",
147  "ocrvc",
148  "hico",
149  "goci",
150  "oli",
151  "aquarius",
152  "ocia",
153  "aviris",
154  "prism",
155  "olci",
156  "sgli",
157  "msi",
158  "l5tm",
159  "l7etmp",
160  "viirs",
161  "msi",
162  "hawkeye",
163  "misr",
164  "olci",
165  "oci",
166  "ocis",
167  "viirs",
168  "oli",
169  "spexone",
170  "harp2",
171  "harp"
172 };
173 
174 // subsensor directory indexed by subsensorId
175 static const char *subsensorDir[] = {
176  "gac",
177  "lac",
178  "terra",
179  "aqua",
180  "npp",
181  "j1",
182  "s2a",
183  "s2b",
184  "s3a",
185  "s3b",
186  "j2",
187  "l8",
188  "l9"
189 };
190 
191 
198 const char* sensorId2SensorName(int sensorId) {
199  if(sensorId < 0)
200  return NULL;
201  if(sensorId >= SENSOR_NUM)
202  return NULL;
203  return sensorName[sensorId];
204 }
205 
212 const char* sensorId2InstrumentName(int sensorId) {
213  if(sensorId < 0)
214  return NULL;
215  if(sensorId >= SENSOR_NUM)
216  return NULL;
217  return instrumentName[sensorId];
218 }
219 
226 const char* sensorId2PlatformName(int sensorId) {
227  if(sensorId < 0)
228  return NULL;
229  if(sensorId >= SENSOR_NUM)
230  return NULL;
231  return platformName[sensorId];
232 }
233 
240 const char* sensorId2SensorDir(int sensorId) {
241  if(sensorId < 0)
242  return NULL;
243  if(sensorId >= SENSOR_NUM)
244  return NULL;
245  return sensorDir[sensorId];
246 }
247 
254 const char* subsensorId2SubsensorDir(int subsensorId) {
255  if(subsensorId < 0)
256  return NULL;
257  if(subsensorId >= SENSOR_NUM)
258  return NULL;
259  return subsensorDir[subsensorId];
260 }
261 
268 int sensorName2SensorId(const char* name) {
269  int i;
270 
271  if(name == NULL)
272  return -1;
273 
274  // convert the number if an int was sent in
275  if (isValidInt(name)) {
276  i = atoi(name);
277  if (i >= 0 && i < SENSOR_NUM) {
278  return i;
279  }
280  }
281 
282  if (strcasecmp(name, "hmodisa") == 0)
283  return MODISA;
284  if (strcasecmp(name, "hmodist") == 0)
285  return MODIST;
286 
287  for (i = 0; i < SENSOR_NUM; i++) {
288  if (strcasecmp(sensorName[i], name) == 0)
289  return i;
290  }
291 
292  return -1;
293 }
294 
302 int instrumentPlatform2SensorId(const char* instrument, const char* platform) {
303  int i;
304 
305  if(instrument == NULL || platform == NULL)
306  return -1;
307 
308  for (i = 0; i < SENSOR_NUM; i++) {
309  if (strcasecmp(instrumentName[i], instrument) == 0)
310  if (strcasestr(platform, platformName[i]))
311  return i;
312  }
313 
314  return -1;
315 }
316 
322 int sensorId2SubsensorId(int sensorId) {
323  switch(sensorId) {
324  case MODIST:
325  return MODIS_TERRA;
326  case MODISA:
327  return MODIS_AQUA;
328  case VIIRSN:
329  return VIIRS_NPP;
330  case VIIRSJ1:
331  return VIIRS_J1;
332  case MSIS2A:
333  return MSI_S2A;
334  case MSIS2B:
335  return MSI_S2B;
336  case OLCIS3A:
337  return OLCI_S3A;
338  case OLCIS3B:
339  return OLCI_S3B;
340  case VIIRSJ2:
341  return VIIRS_J2;
342  case OLIL8:
343  return OLI_L8;
344  case OLIL9:
345  return OLI_L9;
346  default:
347  return -1;
348  }
349 }
350 
357 const char* instrumentPlatform2SensorName(const char* instrument, const char* platform) {
359 }
const char * sensorId2SensorDir(int sensorId)
Definition: sensorInfo.c:240
#define OLCIS3A
Definition: sensorDefs.h:32
#define MODIS_AQUA
Definition: sensorDefs.h:58
int instrumentPlatform2SensorId(const char *instrument, const char *platform)
Definition: sensorInfo.c:302
#define MSI_S2B
Definition: sensorDefs.h:62
#define MSIS2B
Definition: sensorDefs.h:38
#define NULL
Definition: decode_rs.h:63
#define OLIL9
Definition: sensorDefs.h:45
#define VIIRSN
Definition: sensorDefs.h:23
#define MSI_S2A
Definition: sensorDefs.h:61
int isValidInt(const char *str)
Definition: isValidInt.c:9
int sensorName2SensorId(const char *name)
Definition: sensorInfo.c:268
const char * sensorId2PlatformName(int sensorId)
Definition: sensorInfo.c:226
#define MODIST
Definition: sensorDefs.h:18
int sensorId2SubsensorId(int sensorId)
Definition: sensorInfo.c:322
#define VIIRS_NPP
Definition: sensorDefs.h:59
#define OLIL8
Definition: sensorDefs.h:27
#define OLI_L8
Definition: sensorDefs.h:66
#define OLI_L9
Definition: sensorDefs.h:67
#define VIIRS_J1
Definition: sensorDefs.h:60
#define MSIS2A
Definition: sensorDefs.h:34
#define MODIS_TERRA
Definition: sensorDefs.h:57
const char * sensorId2SensorName(int sensorId)
Definition: sensorInfo.c:198
const char * sensorId2InstrumentName(int sensorId)
Definition: sensorInfo.c:212
#define VIIRSJ2
Definition: sensorDefs.h:44
const char * subsensorId2SubsensorDir(int subsensorId)
Definition: sensorInfo.c:254
#define OLCIS3B
Definition: sensorDefs.h:41
#define VIIRS_J2
Definition: sensorDefs.h:65
int i
Definition: decode_rs.h:71
#define SENSOR_NUM
const char * instrumentPlatform2SensorName(const char *instrument, const char *platform)
Definition: sensorInfo.c:357
#define MODISA
Definition: sensorDefs.h:19
#define VIIRSJ1
Definition: sensorDefs.h:37
#define OLCI_S3A
Definition: sensorDefs.h:63
#define OLCI_S3B
Definition: sensorDefs.h:64