OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
Calibrate_Viirs.cpp
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * NAME: Calibrate_Viirs_Driver.cpp
4  *
5  * DESCRIPTION: Application to read in L1A file, perform calibration, and
6  * write out results in short format.
7  *
8  *
9  * REFERENCES:
10  *
11  * REVISION HISTORY:
12  * DATE: PR# AUTHOR Description
13  * -------- ------ -------- -----------------
14  * 12-01-2014 S. Anderson
15  *
16  * NOTES (MISCELLANEOUS) SECTION:
17  * none
18  *
19  **************************************************************************/
20 #include "calibrate_viirs.h"
21 
22 #include <iostream>
23 #include <libgen.h>
24 #include <VcstViirsCal.h>
25 #include <VcstParamsReader.h>
26 #include <VcstCmnConsts.h>
27 #include <genutils.h>
28 
29 //-----------------------------------------------------------------------------
30 //
31 // Main Function
32 //
33 //-----------------------------------------------------------------------------
34 
35 int main(int argc, char* argv[]) {
36  int status = VCST_SUCCESS;
37 
40 
41  //char softwareVersion[200];
42  //sprintf(softwareVersion, "%d.%d.%d-r%d", L3MAPGEN_VERSION_MAJOR,
43  //L3MAPGEN_VERSION_MINOR, L3MAPGEN_VERSION_PATCH_LEVEL, SVN_REVISION);
45  if (argc == 1) {
47  exit(1);
48  }
50 
51  if (clo_getBool(list, "verbose"))
52  want_verbose = 1;
53  else
54  want_verbose = 0;
55 
56  VcstViirsCal* vcstCal = new VcstViirsCal();
57  vcstCal->history_ = VL1_get_history(argc, argv);
58 
59  vector<string> sourcesList;
60  sourcesList.push_back("static_lut_file");
61  sourcesList.push_back("rsb_dynamic_lut_file");
62  sourcesList.push_back("dnb_dynamic_lut_file");
63  sourcesList.push_back("straylight_lut_file");
64  sourcesList.push_back("cmn_lut_file");
65  sourcesList.push_back("polar_wander_file");
66  vcstCal->source_files_ = VL1_get_source(sourcesList);
67 
68  bool bRad = clo_getBool(list, "radiance");
69  bool bFilt = clo_getBool(list, "filters");
70  bool bLunar = clo_getBool(list, "lunar");
71  bool bCdg = !VL1_get_group(VIIRS_L1B_CDG).empty();
72 
73  status = vcstCal->initialize(bRad, bFilt, bCdg, bLunar);
74  if (status != VCST_SUCCESS) {
75  std::cerr << "Main:: Calibration initialization failure" << std::endl;
76  exit(EXIT_FAILURE);
77  }
78 
79  status = vcstCal->calibrate(ALL_BANDS);
80  if (status != VCST_SUCCESS) {
81  std::cerr << "Main:: Calibration processing failure for " << argv[1]
82  << std::endl;
83  exit(EXIT_FAILURE);
84  }
85 
86  std::cerr << "Main:: Calibration complete for " << VL1_get_option("ifile")
87  << std::endl;
88 
89  delete vcstCal;
90 
91  return (status);
92 }
93 
@ ALL_BANDS
const int VCST_SUCCESS
Definition: VcstCmnConsts.h:46
int status
Definition: l1_czcs_hdf.c:32
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
Definition: CMakeLists.txt:7
void clo_setEnablePositionOptions(int val)
Definition: clo.c:1685
std::string VL1_get_source(std::vector< std::string > sourcesList)
void calibrate_viirs_init_options(clo_optionList_t *list, const char *softwareVersion)
void calibrate_viirs_read_options(clo_optionList_t *list, int argc, char *argv[])
std::string VL1_get_history(int argc, char *argv[])
clo_optionList_t * clo_createList()
Definition: clo.c:532
void clo_printUsage(clo_optionList_t *list)
Definition: clo.c:1988
int want_verbose
std::string VL1_get_group(const std::string &group)
int main(int argc, char *argv[])
string history_
Definition: VcstViirsCal.h:35
const std::string VIIRS_L1B_CDG
string source_files_
Definition: VcstViirsCal.h:36
int clo_getBool(clo_optionList_t *list, const char *key)
Definition: clo.c:1375
std::string VL1_get_option(const std::string &name)
int calibrate(VIIRS_CATEGORY_ENUM bands)
int initialize(bool bRad, bool bFilt, bool bCDG, bool bLunar)