Go to the documentation of this file.
29 int main(
int argc,
char* argv[]) {
47 static l2_prod l2_str;
50 int32_t l2sensorID, l3sensorID;
59 std::vector<calstr*> pixrecArray;
67 if (argc == 1 || strcmp(argv[1],
"-version") == 0
68 || strcmp(argv[1],
"--version") == 0) {
79 printf(
"-E- %s: Error parsing input parameters.\n", argv[0]);
83 printf(
"Opening %s\n",
input->ifile[0]);
85 printf(
"-E- %s: Error reading L2 data %s.\n", argv[0],
input->ifile[0]);
89 if ((meta_l2 = (meta_l2Type *) malloc(
sizeof (meta_l2Type))) ==
NULL) {
90 printf(
"-E- %s: Error allocating memory for L2 metadata.\n", argv[0]);
95 printf(
"-E- %s: Error reading L2 metadata %s.\n", argv[0],
106 int existingSensorID;
110 void *old_client_data;
111 H5Eget_auto(H5E_DEFAULT, &old_func, &old_client_data);
114 H5Eset_auto(H5E_DEFAULT,
NULL,
NULL);
120 printf(
"-E- %s: Problem reading output file: %s\n", argv[0],
125 if (l2sensorID != existingSensorID) {
127 "-E- %s: Mixing L2 data from different sensors, %s and %s.\n",
135 H5Eset_auto(H5E_DEFAULT, old_func, old_client_data);
140 printf(
"-E- Could not open ifile=\"%s\".\n",
input->tgtfile);
145 if (l3sensorID == -1) {
149 if (l3sensorID == -1) {
150 printf(
"-E- Unknown sensor name %s\n",
165 strcpy(buf, l2_str.flagnames);
168 printf(
"-E- %s: Error reading L2 flags %s.\n", argv[0],
input->ifile[0]);
179 if ((l2prodinx = (int32_t *) malloc(nprod *
sizeof (int32_t))) ==
NULL) {
180 printf(
"-E- %s: Error allocating memory for L2 product index.\n",
186 for (
i = 0;
i < nprod;
i++) {
188 for (
j = 0;
j < l2_str.nprod;
j++) {
189 if (strcmp(l2_str.prodname[
j], l3prod) == 0) {
197 strcpy(vars1Dnames[0],
"lon");
198 strcpy(vars1Dnames[1],
"lat");
202 for (
j = 0;
j < l2_str.nprod;
j++) {
204 for (
i = 0;
i < nprod;
i++) {
205 if (strcmp(l2_str.prodname[
j], outprod[
i]) == 0) {
210 if (skip == 0 && strcmp(l2_str.prodname[
j],
"pixnum") != 0
211 && strcmp(l2_str.prodname[
j],
"mside") != 0
212 && strcmp(l2_str.prodname[
j],
"detnum") != 0
213 && strcmp(l2_str.prodname[
j],
"l2_flags") != 0
214 && strcmp(l2_str.prodname[
j],
"latitude") != 0
215 && strcmp(l2_str.prodname[
j],
"longitude") != 0) {
216 oneDprodinx[
k++] =
j;
217 strcpy(vars1Dnames[nvars1d++], l2_str.prodname[
j]);
239 printf(
"-E- %s: scan and pixel limits make no sense.\n", argv[0]);
240 printf(
" start scan = %d\n", sscan + 1);
241 printf(
" end scan = %d\n", escan + 1);
242 printf(
" start pixel = %d\n",
spix + 1);
243 printf(
" end pixel = %d\n",
epix + 1);
249 if ((
iscan % 100) == 0)
250 printf(
"Processing scan %d of %d\n",
iscan, l2_str.nrec);
253 printf(
"%s: Error reading L2 data file %s at scan %d.\n", argv[0],
254 l2_str.filename,
iscan);
259 if ((l2_str.l2_flags[ipix] & flagusemask) == 0) {
261 lat = l2_str.latitude[ipix];
262 lon = l2_str.longitude[ipix];
277 pixrec->sensorID = l2sensorID;
278 pixrec->year = l2_str.year;
279 pixrec->day = l2_str.day;
280 pixrec->msec = l2_str.msec;
281 pixrec->iscan =
iscan;
282 pixrec->mside = l2_str.mside[
iscan];
283 pixrec->detnum = l2_str.detnum[
iscan];
285 pixrec->pixnum = l2_str.pixnum[ipix];
287 pixrec->pixnum = ipix;
288 pixrec->vars1D[0] =
lon;
289 pixrec->vars1D[1] =
lat;
291 for (
j = 0;
j < nprod;
j++) {
292 pixrec->data[
j][0] = l2_str.l2_data[l2prodinx[
j]][ipix];
296 for (
j = 2;
j < nvars1d;
j++) {
297 pixrec->vars1D[
j] = l2_str.l2_data[oneDprodinx[
j]][ipix];
300 pixrecArray.push_back(pixrec);
306 npixs = pixrecArray.size();
307 printf(
"Number of pixels matched: %d\n", npixs);
309 if (npixs > 2 *
input->subsamp) {
311 npixsOut = npixs /
input->subsamp;
313 outprod, vars1Dnames, &runCounter,
BINMATCH);
314 for (
i = 0;
i < npixs;
i +=
input->subsamp) {
316 pixrec = pixrecArray[
i];
318 nvars1d, outprod, vars1Dnames,
BINMATCH);
325 printf(
"Trouble closing file %s\n",
input->ofile[0]);
328 printf(
"Number of pixels output: %d\n", npixsOut);
329 printf(
"Done processing file %s\n",
input->ofile[0]);
int32_t openL2(const char *fname, char *plist, l2_prod *l2_str)
virtual L3Bin * getClosestBin(float lat, float lon)
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
int instrumentPlatform2SensorId(const char *instrument, const char *platform)
idDS openDS(const char *filename)
int calfile_write(idDS ds_id, calstr *calrec, int recnum, int ydim, int xdim, int nprods, int nbands, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], caltype ctype)
int32_t readL2meta(meta_l2Type *meta_l2, int32_t ifile)
virtual bool open(const char *fileName)
int sensorName2SensorId(const char *name)
int32_t freeL2meta(meta_l2Type *meta_l2)
int32_t readL2(l2_prod *l2_str, int32_t ifile, int32_t recnum, int32_t iprod, unsigned char *scan_in_rowgroup)
int main(int argc, char *argv[])
int32_t closeL2(l2_prod *l2_str, int32_t ifile)
int readAttr(idDS ds_id, const char *nam, void *data)
virtual bool setActiveProductList(const char *prodStr)
clo_optionList_t * clo_createList()
void setupflags(char *flagdef, char *flaguse, uint32_t *flagusemask, uint32_t *required, int *status)
void clo_printUsage(clo_optionList_t *list)
void free_calrec(calstr *calrec, int nbands, int nprods)
virtual meta_l3bType * getMetaData()
float getMean(int32_t prodId=0) const
calstr * alloc_calrec(int ydim, int nbands, int nprods, int nvar1d)
const char * sensorId2SensorName(int sensorId)
virtual const char * getProdName(int prodNum) const
virtual Hdf::hdf_bin * getHdfBinObject() const
int32_t rdsensorinfo(int32_t, int32_t, const char *, void **)
int calfile_close(idDS ds_id)
float get_dem(float lat, float lon)
idDS calfile_open(char *ofile, int sensorID, int ydim, int xdim, int nprods, int nvars1d, char l2prods[L1_MAXPROD][32], char vars1Dnames[L1_MAXPROD][32], long *numExistingRecords, caltype ctype)
int32_t getNscenes() const
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int32_t freeL2(l2_prod *l2_str)