Go to the documentation of this file.
20 #define NBINREAD MAXPIX
21 #define FLAGMASK PRODFAIL
44 file->def_l2prod,
file->l2_prod_names);
67 if ((
l1file->Fonom = (
float*) calloc(
l1file->nbands, sizeof (
float))) ==
NULL) {
68 printf(
"-E- (%s, %d) Cannot allocate space for l1file->Fonom\n", __FILE__, __LINE__);
85 l1str*
l1rec = l2rec->l1rec;
92 for (iw = 0; iw <
nbands; iw++) {
101 for (ip = 0; ip <
l1rec->npix; ip++) {
102 l1rec->pixnum[ip] = 0;
103 l1rec->alpha[ip] = 0.0;
104 l1rec->flags[ip] = 0;
117 static filehandle
ifile;
118 static filehandle
ofile;
122 double start_time =
now();
134 char buf[FILENAME_MAX];
143 static bool atLeastOne =
false;
155 if ((strcmp(argv[
i],
"-h") == 0) || (strcmp(argv[
i],
"-help") == 0)) {
173 printf(
"-E- %s: Error parsing input parameters.\n", argv[0]);
182 strcat(proc_con,
" ");
183 strcat(proc_con, argv[
i]);
191 cout << endl <<
"The following products will be included in " <<
ofile.name
193 int32 nprods_out =
ofile.tot_prod;
195 for (iprod = 0; iprod <
ofile.tot_prod; iprod++) {
196 cout << iprod + 1 <<
" " <<
ofile.l2_prod_names[iprod] << endl;
197 strcat(prodlist_out,
ofile.l2_prod_names[iprod]);
198 if (iprod <
ofile.tot_prod - 1)
199 strcat(prodlist_out,
",");
205 const char *inputfile;
207 inputfile =
input->ifile[0];
210 int len = input_binfile->
query();
211 char *fullprodlist = (
char *) malloc(len);
212 input_binfile->
query(fullprodlist);
228 l1rec = (l1str*) malloc(
sizeof (l1str));
229 l2rec = (l2str*) malloc(
sizeof (l2str));
234 printf(
"-E- %s: Unable to allocate L1 record.\n", argv[0]);
238 printf(
"-E- %s: Unable to allocate L2 record.\n", argv[0]);
254 int32 nprods_in = input_binfile->
query(&prodlist_in);
260 "Rrs_vvv nLw_vvv Rrs_vc_vvv solz sola senz sena relaz",
"",
264 SOLZ, SOLA, SENZ, SENA, RELAZ
281 int32 have_relaz = 0;
283 if ((rrs_bindex = (int32 *) malloc(
ifile.nbands * sizeof (int32))) ==
NULL) {
284 printf(
"-E- %s: Error allocating memory to the input data array.\n",
288 if ((rrs_windex = (int32 *) malloc(
ifile.nbands * sizeof (int32))) ==
NULL) {
289 printf(
"-E- %s: Error allocating memory to the input data array.\n",
293 if ((nlw_bindex = (int32 *) malloc(
ifile.nbands * sizeof (int32))) ==
NULL) {
294 printf(
"-E- %s: Error allocating memory to the input data array.\n",
298 if ((nlw_windex = (int32 *) malloc(
ifile.nbands * sizeof (int32))) ==
NULL) {
299 printf(
"-E- %s: Error allocating memory to the input data array.\n",
304 cout << endl <<
"Checking input for desired products: " << endl;
306 for (int32 iwant = 0; iwant < nprods_wt; iwant++) {
307 for (int32 ihave = 0; ihave < nprods_in; ihave++) {
308 if (strcmp(prodlist_in[ihave], prodlist_wt[iwant]) == 0) {
309 strcat(prodstr, prodlist_in[ihave]);
310 strcat(prodstr,
",");
311 cout <<
"found " << prodlist_wt[iwant] << endl;
313 rrs_bindex[n_rrs] = iprod;
314 rrs_windex[n_rrs] = iwant;
317 }
else if (iwant < n_vvv * 2) {
318 nlw_bindex[n_nlw] = iprod;
319 nlw_windex[n_nlw] = iwant - n_vvv;
322 }
else if (iwant < n_vvv * 3) {
323 rrs_bindex[n_rrs] = iprod;
324 rrs_windex[n_rrs] = iwant - 2 * n_vvv;
328 geo_bindex[n_geo] = iprod;
329 geo_windex[n_geo] = iwant - 3 * n_vvv;
330 switch (geo_windex[n_geo]) {
354 len = strlen(prodstr);
355 prodstr[len - 1] =
'\0';
361 if ((inData = (
float **) malloc(nprods_in *
sizeof (
float *))) ==
NULL) {
362 printf(
"-E- %s: Error allocating memory to the input data array.\n",
366 if ((outData = (
float **) malloc(nprods_out *
sizeof (
float *))) ==
NULL) {
367 printf(
"-E- %s: Error allocating memory to the output data array.\n",
371 if ((tmpData = (
float **) malloc(nprods_out *
sizeof (
float *))) ==
NULL) {
372 printf(
"-E- %s: Error allocating memory to the temp data array.\n",
376 for (
i = 0;
i < nprods_in;
i++) {
377 if ((inData[
i] = (
float *) calloc(2 *
npix,
sizeof (
float))) ==
NULL) {
378 printf(
"-E- %s: Error allocating memory to the output data array.\n",
383 for (
i = 0;
i < nprods_out;
i++) {
384 if ((outData[
i] = (
float *) calloc(2 *
npix,
sizeof (
float))) ==
NULL) {
386 "-E- %s: Error allocating memory to the output data array.\n",
390 if ((tmpData[
i] = (
float *) calloc(
npix,
sizeof (
float))) ==
NULL) {
392 "-E- %s: Error allocating memory to the output data array.\n",
397 char *outMask = (
char *) calloc(
npix,
sizeof (
char));
400 input_binfile->
read(prodstr);
411 if (input_binfile->
isHDF5) {
413 }
else if (input_binfile->
isCDF4) {
420 if (strcmp(
input->oformat,
"HDF4") == 0) {
424 if (strcmp(
input->oformat,
"HDF5") == 0)
426 if (strcmp(
input->oformat,
"netCDF4") == 0)
436 char* tmpProdNames[
ofile.tot_prod];
437 for (
int i = 0;
i <
ofile.tot_prod;
i++) {
438 tmpProdNames[
i] =
ofile.l2_prod_names[
i];
445 if (
iscan % 50 == 0) {
446 int secs = (
int)
now() - start_time;
447 cout <<
"Reading row " <<
iscan <<
" of " <<
nrows <<
" after " << secs <<
" seconds" << endl;
454 int64_t beg = input_binfile->
get_beg();
463 for (
int j = 0;
j < input_binfile->
nprod();
j++) {
467 if (strcmp(prodlist_in[
j], buf) == 0) {
482 ifile.terrain_corrected = 1;
484 memset(outMask,
'\0',
npix);
495 for (ip = 0; ip <
ext; ip++) {
507 for (int32 iw = 0; iw < n_nlw; iw++) {
508 ipw = ip *
ifile.nbands + nlw_windex[iw];
509 l2rec->nLw[ipw] = inData[nlw_bindex[iw]][2 * ip] / weight;
512 for (int32 iw = 0; iw < n_rrs; iw++) {
513 ipw = ip *
ifile.nbands + rrs_windex[iw];
514 l2rec->Rrs[ipw] = inData[rrs_bindex[iw]][2 * ip] / weight;
517 l1rec->solz[ip] = 0.0;
518 l1rec->sola[ip] = 0.0;
519 l1rec->senz[ip] = 0.0;
520 l1rec->sena[ip] = 90.0;
521 l1rec->delphi[ip] = 90.0;
523 for (int32 iw = 0; iw < n_geo; iw++) {
524 switch (geo_windex[iw]) {
526 l1rec->solz[ip] = inData[geo_bindex[iw]][2 * ip] / weight;
529 l1rec->sola[ip] = inData[geo_bindex[iw]][2 * ip] / weight;
532 l1rec->senz[ip] = inData[geo_bindex[iw]][2 * ip] / weight;
535 l1rec->sena[ip] = inData[geo_bindex[iw]][2 * ip] / weight;
538 l1rec->delphi[ip] = inData[geo_bindex[iw]][2 * ip] / weight;
544 flon =
l1rec->lon[ip];
545 flat =
l1rec->lat[ip];
551 if (have_sola && have_sena && !have_relaz) {
553 if (
l1rec->delphi[ip] < -180)
554 l1rec->delphi[ip] += 360.0;
555 }
else if (!have_sola && !have_sena && have_relaz) {
556 l1rec->sena[ip] = 90.0;
559 if (
l1rec->sola[ip] < -180)
560 l1rec->sola[ip] += 360.0;
568 for (ip = 0; ip <
ext; ip++)
573 for (ip = 0; ip <
ext; ip++)
578 if (
input->iop_opt > 0 && (
input->proc_ocean != 0))
583 for (iprod = 0; iprod < nprods_out; iprod++) {
594 printf(
"-E- %s line %d: product index failure.\n", __FILE__,
605 productInfo_t *p_info;
609 printf(
"-E- product %s not found in XML product table\n",
610 ofile.l2_prod_names[iprod]);
616 strcat(units_string,
":");
617 strcat(units_string,
p->units);
621 strcat(units_string,
":");
622 strcat(units_string,
p->units);
624 if (iprod < nprods_out -1)
625 strcat(units_string,
",");
629 memcpy(tmpData[iprod], (
float *)
pbuf,
630 ext *
sizeof (
float));
634 for (ip = 0; ip <
ext; ip++) {
635 if ((tmpData[iprod][ip] ==
BAD_FLT)
648 for (ip = 0; ip <
ext; ip++) {
652 offset = bin_num - basebin;
662 for (iprod = 0; iprod < nprods_out; iprod++) {
663 outData[iprod][2 * nwrite] = tmpData[iprod][ip];
678 for (iprod = 0; iprod < nprods_out; iprod++) {
680 output_binfile->
writeSums(outData[iprod], nwrite, buf);
683 if (strcmp(
input->oformat,
"HDF5") == 0
684 || strcmp(
input->oformat,
"netCDF4") == 0)
689 output_binfile->
copymeta(1, &input_binfile);
690 if (strcmp(
input->oformat,
"netCDF4")) {
700 if (strcmp(
input->oformat,
"netCDF4") == 0) {
716 if (
input->suite[0]) {
724 if (atLeastOne ==
false) {
725 cout <<
"No valid bins to output!" << endl <<
"...seems a selected product may have resulted in 100% PRODFAIL..." << endl;
726 mainReturnCode = 110;
728 output_binfile->
close();
729 delete(output_binfile);
730 input_binfile->
close();
731 delete(input_binfile);
735 for (
i = 0;
i < nprods_in;
i++)
741 for (
i = 0;
i < nprods_out;
i++) {
754 free(
input->fctl.f[
i].kernel);
755 free(
input->gsm_aphs);
756 free(
input->gsm_aphw);
757 free(
input->giop_wave);
758 free(
input->giop_rrs_unc);
760 free(
input->vcal_nLw);
761 free(
input->vcal_Lw);
769 cout <<
"Processing Complete at " << ptime << endl << endl;
771 return (mainReturnCode);
char * ydhmsf(double dtime, char zone)
virtual int64_t get_bin_num(int kbin)=0
virtual int get_nobs(int kbin)=0
virtual void bin2latlon(int64_t bin_num, float &lat, float &lon)
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
void bindex_set(int32_t wave[], int nwave, int dwave_vswir)
void freeProductInfo(productInfo_t *info)
const char * getGCMDKeywords(const char *suite)
int msl12_input(int argc, char *argv[], const char *progName, filehandle *l1file)
virtual int readSums(float *sums, int32_t nbins_to_read, int iprod)=0
void free_l2(l2str *l2rec)
virtual void setProductList(int numProducts, char *prodNames[])
void filehandle_init(filehandle *file)
hdf_bin * openBinObject(const char *binFileName)
void load_l3file_handle(int sensorID, int filenum, filehandle *file)
virtual int create(const char *l3b_filename, int32_t nrows)=0
const char * sensorId2PlatformName(int sensorId)
void load_input_filehandle(filehandle *l1file)
This should be set to the NetCDF standard name if exists for this product Create a function that computes your product edit get_myprod c add prototype to l12_proto h add get_myprod c to L2GEN_PRODUCT_FILES in CMakeLists txt Add an entry to the output routine to call your function edit prodgen c edit function prodgen() case CAT_myprod pbuf
bool active_data_prod[MAXNVDATA]
virtual int64_t get_beg()=0
virtual int copy_binlist(int src, int dest)=0
int l2gen_usage(const char *prog)
virtual int get_nscenes(int kbin)=0
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
int32_t prodlist(int32_t sensorID, int32_t evalmask, const char *inprod, const char *defprod, char outprod[L1_MAXPROD][32])
int alloc_l2(l1str *l1rec, l2str *l2rec)
void sunangs_(int *, int *, float *, float *, float *, float *, float *)
virtual int set_weights(int offset, float weights)=0
virtual int copymeta(int32_t nfiles, Hdf::hdf_bin *input_binfile[])
productInfo_t * allocateProductInfo()
virtual int64_t get_basebin(int irow)
void get_iops(l2str *l2rec, int32_t iop_opt)
void init_l2(l2str *l2rec, int32_t nbands)
void unix2yds(double usec, short *year, short *day, double *secs)
virtual int incNumRec(int n_write)=0
virtual int writeSums(float *sums, int32_t nbins_to_write, const char *prodname)=0
int main(int argc, char *argv[])
virtual int setDataPtr(int nbins_to_read)=0
void free_l1(l1str *l1rec)
int findProductInfo(const char *productName, int sensorId, productInfo_t *info)
void init_l1(l1str *l1rec)
float get_default_chl(l2str *l2rec, float Rrs[])
virtual int get_prodname(int iprod, char *prodname)
void load_l12(l2str *l2rec)
char * getProductNameFull(productInfo_t *info)
const char * sensorId2SensorName(int sensorId)
virtual int inc_nobs(int offset, int nobs)=0
void * prodgen(l2prodstr *p, l2str *l2rec)
u5 which has been done in the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT production Changes from v6 which may affect scientific the sector rotation may actually occur during one of the scans earlier than the one where it is first reported As a the b1 values are about the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT to fill pixels affected by dead subframes with a special value Output the metadata of noisy and dead subframe Dead Subframe EV and Detector Quality Flag2 Removed the function call of Fill_Dead_Detector_SI to stop interpolating SI values for dead but also for all downstream products for science test only Changes from v5 which will affect scientific to conform to MODIS requirements Removed the Mixed option from the ScanType in the code because the L1A Scan Type is never Mixed Changed for ANSI C compliance and comments to better document the fact that when the HDF_EOS metadata is stricly the and products are off by and in the track respectively Corrected some misspelling of RCS swir_oob_sending_detector to the Reflective LUTs to enable the SWIR OOB correction detector so that if any of the sending detectors becomes noisy or non near by good detectors from the same sending band can be specified as the substitute in the new look up table Code change for adding an additional dimension of mirror side to the Band_21_b1 LUT to separate the coefficient of the two mirror sides for just like other thermal emissive so that the L1B code can calibrate Band scan to scan with mirror side dependency which leads better calibration result Changes which do not affect scientific when the EV data are not provided in this Crosstalk Correction will not be performed to the Band calibration data Changes which do not affect scientific and BB_500m in L1A Logic was added to turn off the or to spatial aggregation processes and the EV_250m_Aggr1km_RefSB and EV_500m_Aggr1km_RefSB fields were set to fill values when SDSs EV_250m and EV_500m are absent in L1A file Logic was added to skip the processing and turn off the output of the L1B QKM and HKM EV data when EV_250m and EV_500m are absent from L1A In this the new process avoids accessing and reading the and L1A EV skips and writing to the L1B and EV omits reading and subsampling SDSs from geolocation file and writing them to the L1B and omits writing metadata to L1B and EV and skips closing the L1A and L1B EV and SDSs Logic was added to turn off the L1B OBC output when the high resolution OBC SDSs are absent from L1A This is accomplished by skipping the openning the writing of metadata and the closing of the L1B OBC hdf which is Bit in the scan by scan bit QA has been changed Until now
char * unix2isodate(double dtime, char zone)
const char * sensorId2InstrumentName(int sensorId)
int windex(float wave, float twave[], int ntwave)
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
void l3gen_usage(char *prog)
virtual int set_bin_num(int offset, int64_t bin_num)=0
virtual int clear_binlist()=0
virtual int read(char *product_list)
int32_t alloc_l1(filehandle *l1file, l1str *l1rec)
int32_t rdsensorinfo(int32_t, int32_t, const char *, void **)
for(i=0;i< NROOTS;i++) s[i]
virtual int readBinIndex(int row_num_to_read)=0
virtual int readBinList(int nbins_to_read)=0
int loadl1(filehandle *l1file, l1str *l1rec)
void get_f0_thuillier_ext(int32_t wl, int32_t width, float *f0)
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 sensorID[MAXNFILES]
virtual int inc_nscenes(int offset, int nscenes)=0
virtual float get_weights(int kbin)=0
virtual int writeBinList(int32_t nbins_to_write)=0
int32_t get_l2prod_index(const l2_prod &l2, const char *prodname)