Go to the documentation of this file.
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]);
82 printf(
"Opening %s\n",
input->ifile[0]);
84 printf(
"-E- %s: Error reading L2 data %s.\n", argv[0],
input->ifile[0]);
88 if ((meta_l2 = (meta_l2Type *) malloc(
sizeof (meta_l2Type))) ==
NULL) {
89 printf(
"-E- %s: Error allocating memory for L2 metadata.\n", argv[0]);
94 printf(
"-E- %s: Error reading L2 metadata %s.\n", argv[0],
105 int existingSensorID;
109 void *old_client_data;
110 H5Eget_auto(H5E_DEFAULT, &old_func, &old_client_data);
113 H5Eset_auto(H5E_DEFAULT,
NULL,
NULL);
119 printf(
"-E- %s: Problem reading output file: %s\n", argv[0],
124 if (l2sensorID != existingSensorID) {
126 "-E- %s: Mixing L2 data from different sensors, %s and %s.\n",
134 H5Eset_auto(H5E_DEFAULT, old_func, old_client_data);
141 printf(
"-E- Could not open ifile=\"%s\".\n",
input->tgtfile);
146 if (l3sensorID == -1) {
150 if (l3sensorID == -1) {
151 printf(
"-E- Unknown sensor name %s\n",
166 strcpy(buf, l2_str.flagnames);
169 printf(
"-E- %s: Error reading L2 flags %s.\n", argv[0],
input->ifile[0]);
180 if ((l2prodinx = (int32_t *) malloc(nprod *
sizeof (int32_t))) ==
NULL) {
181 printf(
"-E- %s: Error allocating memory for L2 product index.\n",
187 for (
i = 0;
i < nprod;
i++) {
189 for (
j = 0;
j < l2_str.nprod;
j++) {
190 if (strcmp(l2_str.prodname[
j], l3prod) == 0) {
198 strcpy(vars1Dnames[0],
"lon");
199 strcpy(vars1Dnames[1],
"lat");
203 for (
j = 0;
j < l2_str.nprod;
j++) {
205 for (
i = 0;
i < nprod;
i++) {
206 if (strcmp(l2_str.prodname[
j], outprod[
i]) == 0) {
211 if (skip == 0 && strcmp(l2_str.prodname[
j],
"pixnum") != 0
212 && strcmp(l2_str.prodname[
j],
"mside") != 0
213 && strcmp(l2_str.prodname[
j],
"detnum") != 0
214 && strcmp(l2_str.prodname[
j],
"l2_flags") != 0
215 && strcmp(l2_str.prodname[
j],
"latitude") != 0
216 && strcmp(l2_str.prodname[
j],
"longitude") != 0) {
217 oneDprodinx[
k++] =
j;
218 strcpy(vars1Dnames[nvars1d++], l2_str.prodname[
j]);
240 printf(
"-E- %s: scan and pixel limits make no sense.\n", argv[0]);
241 printf(
" start scan = %d\n", sscan + 1);
242 printf(
" end scan = %d\n", escan + 1);
243 printf(
" start pixel = %d\n",
spix + 1);
244 printf(
" end pixel = %d\n",
epix + 1);
250 if ((
iscan % 100) == 0)
251 printf(
"Processing scan %d of %d\n",
iscan, l2_str.nrec);
254 printf(
"%s: Error reading L2 data file %s at scan %d.\n", argv[0],
255 l2_str.filename,
iscan);
260 if ((l2_str.l2_flags[ipix] & flagusemask) == 0) {
262 lat = l2_str.latitude[ipix];
263 lon = l2_str.longitude[ipix];
278 pixrec->sensorID = l2sensorID;
279 pixrec->year = l2_str.year;
280 pixrec->day = l2_str.day;
281 pixrec->msec = l2_str.msec;
282 pixrec->iscan =
iscan;
283 pixrec->mside = l2_str.mside[
iscan];
284 pixrec->detnum = l2_str.detnum[
iscan];
286 pixrec->pixnum = l2_str.pixnum[ipix];
288 pixrec->pixnum = ipix;
289 pixrec->vars1D[0] =
lon;
290 pixrec->vars1D[1] =
lat;
292 for (
j = 0;
j < nprod;
j++) {
293 pixrec->data[
j][0] = l2_str.l2_data[l2prodinx[
j]][ipix];
297 for (
j = 2;
j < nvars1d;
j++) {
298 pixrec->vars1D[
j] = l2_str.l2_data[oneDprodinx[
j]][ipix];
301 pixrecArray.push_back(pixrec);
307 npixs = pixrecArray.size();
308 printf(
"Number of pixels matched: %d\n", npixs);
310 if (npixs > 2 *
input->subsamp) {
312 npixsOut = npixs /
input->subsamp;
314 outprod, vars1Dnames, &runCounter,
BINMATCH);
315 for (
i = 0;
i < npixs;
i +=
input->subsamp) {
317 pixrec = pixrecArray[
i];
319 nvars1d, outprod, vars1Dnames,
BINMATCH);
326 printf(
"Trouble closing file %s\n",
input->ofile[0]);
329 printf(
"Number of pixels output: %d\n", npixsOut);
330 printf(
"Done processing file %s\n",
input->ofile[0]);
void setupflags(char *flagdef, char *flaguse, uint32_t *flagusemask, uint32_t *required, int *status, int32_t *BITS)
virtual L3Bin * getClosestBin(float lat, float lon)
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()
list(APPEND LIBS ${NETCDF_LIBRARIES}) find_package(GSL REQUIRED) include_directories($
int32_t openL2(const char *fname, const char *plist, l2_prod *l2_str)
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)