8 char *
core_g_nm[] = {
"VIIRS-MOD-GEO-TC",
"VIIRS-M1-SDR",
9 "VIIRS-M2-SDR",
"VIIRS-M3-SDR",
"VIIRS-M4-SDR",
"VIIRS-M5-SDR",
10 "VIIRS-M6-SDR",
"VIIRS-M7-SDR",
"VIIRS-M8-SDR",
"VIIRS-M9-SDR",
11 "VIIRS-M10-SDR",
"VIIRS-M11-SDR",
"VIIRS-M12-SDR",
"VIIRS-M13-SDR",
12 "VIIRS-M14-SDR",
"VIIRS-M15-SDR",
"VIIRS-M16-SDR"};
14 int init_sdr(ctl_struc *ctl, sdr_info_struc *sdr_info, in_rec_struc *in_rec,
15 out_rec_struc *out_rec)
35 h5io_str dat1_g_id, dat2_g_id;
36 char out_file[500], grp_nam[50], *sdr_base;
38 char lcl_out_bnd_typ[] = {0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0};
39 char lcl_meas_typ[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
43 for (isdr = 0; isdr <
MAX_BND; isdr++) {
44 out_rec->out_bnd_typ[isdr] = lcl_out_bnd_typ[isdr];
45 out_rec->meas_typ[isdr] = lcl_meas_typ[isdr];
50 in_rec->ll_lims[0] = 99.;
51 in_rec->ll_lims[1] = -99.;
52 in_rec->ll_lims[2] = 200.;
53 in_rec->ll_lims[3] = -200.;
54 in_rec->ll_lims[4] = 200.;
55 in_rec->ll_lims[5] = -200.;
61 out_rec->nbnd = in_rec->nbnd;
62 out_rec->npix = in_rec->npix;
63 out_rec->nlin = in_rec->nlin;
64 out_rec->nscan = in_rec->nscan;
65 out_rec->scn_fmt = in_rec->scn_fmt;
66 out_rec->margin[0] = in_rec->margin[0];
67 out_rec->margin[1] = in_rec->margin[1];
68 out_rec->ndet_scan = in_rec->ndet_scan;
70 if (ctl->out_scn_fmt == 0) {
73 out_rec->nlin = in_rec->nscan *
NDET;
74 out_rec->margin[0] = 0;
75 out_rec->margin[1] = 0;
76 out_rec->ndet_scan =
NDET;
77 }
else if (ctl->out_scn_fmt == 1) {
78 out_rec->margin[0] = 0;
79 out_rec->margin[1] = 0;
80 out_rec->ndet_scan =
NDET;
81 out_rec->nlin = in_rec->nscan *
NDET;
83 if (in_rec->scn_fmt == 0) {
85 "%s, %d: Warning - requested output format (%d) of unaggregated\n",
86 __FILE__, __LINE__, in_rec->scn_fmt);
87 printf(
" will default to input scan format of aggregated\n");
98 for (isdr = 0; isdr < in_rec->nbnd + 1; isdr++) {
103 if (
gen_sdr_fname(isdr, ctl->out_loc, sdr_info, ctl->fname_opt,
105 printf(
"%s, %d: Unable to generate output file for sdr index %d\n\n",
106 __FILE__, __LINE__, isdr);
110 strcpy(sdr_info->sdr_files[isdr], sdr_base);
112 &(out_rec->sdr_fid[isdr])) != 0) {
113 printf(
"%s, %d: Unable to open output geo file: \n%s\n\n",
114 __FILE__, __LINE__, out_file);
117 if (
init_sdr_top(isdr, sdr_info, out_rec) != 0)
return 1;
121 if (
h5io_mk_grp(&(out_rec->sdr_fid[isdr]),
"All_Data",
122 &(out_rec->sdr_dat_gid[0][isdr])) != 0) {
123 printf(
"%s, %d - could not create data group: All_Data\n",
127 sprintf(grp_nam,
"%s_All",
core_g_nm[isdr]);
128 if (
h5io_mk_grp(&(out_rec->sdr_dat_gid[0][isdr]), grp_nam,
129 &(out_rec->sdr_dat_gid[1][isdr])) != 0) {
130 printf(
"%s, %d - could not create data group: %s\n",
131 __FILE__, __LINE__, grp_nam);
141 if (ctl->count_cal_opt != 0) {
142 if ((in_rec->dn[ isdr - 1 ] = (
float *)
143 malloc(in_rec->ndet_scan * in_rec->npix * sizeof (
float)))
145 printf(
"%s, %d: Error, allocation of dn storage failed\n",
150 if ((in_rec->gain_bit[ isdr - 1 ] = (
unsigned char *)
151 calloc(in_rec->ndet_scan * in_rec->npix, sizeof (
unsigned char)))
154 "%s, %d: Error, allocation of count gain bit storage failed\n",
158 if ((in_rec->dn_sat[ isdr - 1 ] = (
char *)
159 calloc(in_rec->ndet_scan * in_rec->npix, sizeof (
char)))
162 "%s, %d: Error, allocation of dn saturation storage failed\n",
166 if (
init_bnd_data(isdr - 1, sdr_info, in_rec, out_rec) != 0)
return 1;
172 "Data_Products", &dat1_g_id) != 0) {
173 printf(
"%s, %d - could not create data group: Data_Products\n",
178 printf(
"%s, %d - could not create data group: %s\n",
187 if (
init_sdr_agg(isdr, &dat2_g_id, sdr_info) != 0)
return 1;
188 if (
init_sdr_gran(isdr, &dat2_g_id, sdr_info, out_rec) != 0)
return 1;
193 printf(
"%s, %d - could not close dat2_g_id\n", __FILE__, __LINE__);
197 printf(
"%s, %d - could not close dat1_g_id\n", __FILE__, __LINE__);
207 int init_sdr_top(
int isdr, sdr_info_struc *sdr_info, out_rec_struc *out_rec)
228 int i, n_attr = 13, dims_1_1[] = {1, 1}, len_geo;
229 int dims_1[] = {1}, dims_2[] = {2};
230 char geo_name[150], *bloc =
".";
231 int16_t lcl_scn_fmt, lcl_margin[2], lcl_ndet_scan;
232 int32_t lcl_npix, lcl_nlin;
235 len_geo = strlen(geo_name);
237 h5attr_struc
attrs[] = {
238 { 1, 1,
"Distributor", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
239 (
void *) (sdr_info->origin)},
240 { 1, 1,
"Instrument_Short_Name", H5T_NATIVE_CHAR, 6, 2, dims_1_1,
242 { 1, 1,
"Mission_Name", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
244 { 1, 1,
"N_Dataset_Source", H5T_NATIVE_CHAR, 5, 2, dims_1_1,
246 { 1, 1,
"N_GEO_Ref", H5T_NATIVE_CHAR, len_geo, 2, dims_1_1,
248 { 1, 1,
"N_HDF_Creation_Date", H5T_NATIVE_CHAR, 9, 2, dims_1_1,
249 (
void *) sdr_info->cre_date},
250 { 1, 1,
"N_HDF_Creation_Time", H5T_NATIVE_CHAR, 14, 2, dims_1_1,
251 (
void *) sdr_info->cre_time},
252 { 1, 1,
"Platform_Short_Name", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
254 { 0, 0,
"Data Scan Format", H5T_STD_I16BE, 0, 1, dims_1,
255 (
void *) &lcl_scn_fmt},
256 { 0, 0,
"Scan Margin (track, scan)", H5T_STD_I16BE, 0, 1, dims_2,
257 (
void *) lcl_margin},
258 { 0, 0,
"Pixels per Scan Line", H5T_STD_I32BE, 0, 1, dims_1,
260 { 0, 0,
"Number of Scan Lines", H5T_STD_I32BE, 0, 1, dims_1,
262 { 0, 0,
"Number of Detectors per Scan", H5T_STD_I16BE, 0, 1, dims_1,
263 (
void *) &lcl_ndet_scan}
268 if (isdr == 0)
attrs[4].express = 0;
272 if (out_rec->scn_fmt != 0) {
273 for (
i = 0;
i < 5;
i++)
274 attrs[
i + 8 ].express = 1;
275 lcl_scn_fmt = (int16_t) out_rec->scn_fmt;
276 lcl_margin[0] = (int16_t) out_rec->margin[0];
277 lcl_margin[1] = (int16_t) out_rec->margin[1];
278 lcl_npix = (int32_t) out_rec->npix;
279 lcl_nlin = (int32_t) out_rec->nlin;
280 lcl_ndet_scan = (int16_t) out_rec->ndet_scan;
286 printf(
"%s, %d: Could not write top attributes\n", __FILE__, __LINE__);
293 out_rec_struc *out_rec)
314 h5io_str ds_id, in_ds_id, *gid;
315 int dim_siz[2], dim_siz2[2], *arr_int,
i;
319 unsigned char *uchar_data;
323 gid = &(out_rec->sdr_dat_gid[1][0]);
328 dim_siz[0] = out_rec->nlin;
329 dim_siz[1] = out_rec->npix;
331 if ((flt_data = (
float *) malloc(out_rec->npix * out_rec->nlin *
332 sizeof (
float))) ==
NULL) {
333 printf(
"%s, %d: Could not allocate local float buffer\n",
338 for (
i = 0;
i < out_rec->nlin * out_rec->npix;
i++)
340 if (
h5io_mk_ds(gid,
"Height", H5T_IEEE_F32BE, 2, dim_siz,
342 printf(
"%s, %d: Could not do h5io_mk_ds for Height\n",
346 if (
h5io_wr_ds(&ds_id, (
void *) flt_data) != 0) {
347 printf(
"%s, %d: Could not write to Height\n", __FILE__, __LINE__);
351 printf(
"%s, %d: Could not close Height\n", __FILE__, __LINE__);
360 &(in_rec->geo_dat_id[0])) != 0) {
361 printf(
"%s, %d: Could not do h5io_set_ds for latitude\n",
366 dim_siz[0] = out_rec->nlin;
367 dim_siz[1] = out_rec->npix;
368 if (
h5io_mk_ds(gid,
"Latitude", H5T_IEEE_F32BE, 2, dim_siz,
369 &(out_rec->geo_dat_id[0])) != 0) {
370 printf(
"%s, %d: Could not do h5io_mk_ds for Latitude\n",
379 if ((in_rec->lat = (
float *) malloc(in_rec->npix * in_rec->ndet_scan *
380 sizeof (
float))) ==
NULL) {
381 printf(
"%s, %d: Could not allocate space for lat data transfer buffer\n",
385 out_rec->lat = in_rec->lat;
390 &(in_rec->geo_dat_id[1])) != 0) {
391 printf(
"%s, %d: Could not do h5io_set_ds for longitude\n",
396 if (
h5io_mk_ds(gid,
"Longitude", H5T_IEEE_F32BE, 2, dim_siz,
397 &(out_rec->geo_dat_id[1])) != 0) {
398 printf(
"%s, %d: Could not do h5io_mk_ds for Longitude\n",
403 if ((in_rec->lon = (
float *) malloc(in_rec->npix * in_rec->ndet_scan *
404 sizeof (
float))) ==
NULL) {
405 printf(
"%s, %d: Could not allocate space for lon data transfer buffer\n",
409 out_rec->lon = in_rec->lon;
414 llon_data = (
int64 *) calloc(out_rec->nscan, sizeof (
int64));
415 dim_siz2[0] = out_rec->nscan;
416 if (
h5io_mk_ds(gid,
"MidTime", H5T_STD_I64BE, 1, dim_siz2, &ds_id)
418 printf(
"%s, %d: Could not do h5io_mk_ds for MidTime\n",
422 if (
h5io_wr_ds(&ds_id, (
void *) llon_data) != 0) {
423 printf(
"%s, %d: Could not write to MidTime\n", __FILE__, __LINE__);
427 printf(
"%s, %d: Could not close MidTime\n", __FILE__, __LINE__);
434 uchar_data = (
unsigned char *) malloc(out_rec->nscan *
435 sizeof (
unsigned char));
438 if (
h5io_mk_ds(gid,
"ModeGran", H5T_STD_U8BE, 1, dim_siz2, &ds_id)
440 printf(
"%s, %d: Could not do h5io_mk_ds for ModeGran\n",
444 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
445 printf(
"%s, %d: Could not write to ModeGran\n", __FILE__, __LINE__);
449 printf(
"%s, %d: Could not close ModeGran\n", __FILE__, __LINE__);
456 uchar_data = (
unsigned char *) malloc(out_rec->nscan *
457 sizeof (
unsigned char));
458 for (
i = 0;
i < out_rec->nscan;
i++)
459 *(uchar_data +
i) = 1;
460 dim_siz2[0] = out_rec->nscan;
461 if (
h5io_mk_ds(gid,
"ModeScan", H5T_STD_U8BE, 1, dim_siz2, &ds_id)
463 printf(
"%s, %d: Could not do h5io_mk_ds for ModeScan\n",
467 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
468 printf(
"%s, %d: Could not write to ModeScan\n", __FILE__, __LINE__);
472 printf(
"%s, %d: Could not close ModeScan\n", __FILE__, __LINE__);
479 arr_int = (
int *) malloc(
sizeof (
int));
480 *arr_int = out_rec->nscan;
482 if (
h5io_mk_ds(gid,
"NumberOfScans", H5T_STD_I32BE, 1, dim_siz2, &ds_id)
484 printf(
"%s, %d: Could not do h5io_mk_ds for NumberOfScans\n",
488 if (
h5io_wr_ds(&ds_id, (
void *) arr_int) != 0) {
489 printf(
"%s, %d: Could not write to NumberOfScans\n", __FILE__, __LINE__);
493 printf(
"%s, %d: Could not close NumberOfScans\n", __FILE__, __LINE__);
500 uchar_data = (
unsigned char *) malloc(3 *
sizeof (
unsigned char));
501 for (
i = 0;
i < 3;
i++)
502 *(uchar_data +
i) = 0;
504 if (
h5io_mk_ds(gid,
"PadByte1", H5T_STD_U8BE, 1, dim_siz2, &ds_id)
506 printf(
"%s, %d: Could not do h5io_mk_ds for PadByte\n",
510 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
511 printf(
"%s, %d: Could not write to PadByte\n", __FILE__, __LINE__);
515 printf(
"%s, %d: Could not close PadByte\n", __FILE__, __LINE__);
523 uchar_data = (
unsigned char *) malloc(out_rec->nscan *
524 sizeof (
unsigned char));
525 for (
i = 0;
i < out_rec->nscan;
i++)
526 *(uchar_data +
i) = 0;
527 dim_siz2[0] = out_rec->nscan;
528 if (
h5io_mk_ds(gid,
"QF1_SCAN_VIIRSSDRGEO", H5T_STD_U8BE, 1,
529 dim_siz2, &ds_id) != 0) {
530 printf(
"%s, %d: Could not do h5io_mk_ds for QF1_SCAN_VIIRSSDRGEO\n",
534 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
535 printf(
"%s, %d: Could not write to QF1_SCAN_VIIRSSDRGEO\n",
540 printf(
"%s, %d: Could not close QF1_SCAN_VIIRSSDRGEO\n",
549 uchar_data = (
unsigned char *) calloc(out_rec->npix * out_rec->nlin,
550 sizeof (
unsigned char));
551 if (
h5io_mk_ds(gid,
"QF2_VIIRSSDRGEO", H5T_STD_U8BE, 2, dim_siz, &ds_id)
553 printf(
"%s, %d: Could not do h5io_mk_ds for QF2_VIIRSSDRGEO\n",
557 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
558 printf(
"%s, %d: Could not write to QF2_VIIRSSDRGEO\n",
563 printf(
"%s, %d: Could not close QF2_VIIRSSDRGEO\n", __FILE__, __LINE__);
571 for (
i = 0;
i < out_rec->nscan * 3;
i++)
572 *(flt_data +
i) = *(sdr_info->geo_att +
i) * 3600.;
574 free(sdr_info->geo_att);
575 dim_siz2[0] = out_rec->nscan;
577 if (
h5io_mk_ds(gid,
"SCAttitude", H5T_IEEE_F32BE, 2, dim_siz2,
579 printf(
"%s, %d: Could not do h5io_mk_ds for SCAttitude\n",
583 if (
h5io_wr_ds(&ds_id, (
void *) flt_data) != 0) {
584 printf(
"%s, %d: Could not write to SCAttitude\n", __FILE__, __LINE__);
588 printf(
"%s, %d: Could not close SCAttitude\n", __FILE__, __LINE__);
594 for (
i = 0;
i < out_rec->nscan * 3;
i++)
595 *(flt_data +
i) = *(sdr_info->geo_pos +
i) * 1000.;
597 free(sdr_info->geo_pos);
598 dim_siz2[0] = out_rec->nscan;
600 if (
h5io_mk_ds(gid,
"SCPosition", H5T_IEEE_F32BE, 2, dim_siz2,
602 printf(
"%s, %d: Could not do h5io_mk_ds for SCPosition\n",
606 if (
h5io_wr_ds(&ds_id, (
void *) flt_data) != 0) {
607 printf(
"%s, %d: Could not write to SCPosition\n", __FILE__, __LINE__);
611 printf(
"%s, %d: Could not close SCPosition\n", __FILE__, __LINE__);
617 for (
i = 0;
i < out_rec->nscan;
i++)
618 *(flt_data +
i) = 0.;
619 dim_siz2[0] = out_rec->nscan;
620 if (
h5io_mk_ds(gid,
"SCSolarAzimuthAngle", H5T_IEEE_F32BE, 1, dim_siz2,
622 printf(
"%s, %d: Could not do h5io_mk_ds for SCSolarAzimuthAngle\n",
626 if (
h5io_wr_ds(&ds_id, (
void *) flt_data) != 0) {
627 printf(
"%s, %d: Could not write to SCSolarAzimuthAngle\n",
632 printf(
"%s, %d: Could not close SCSolarAzimuthAngle\n",
639 for (
i = 0;
i < out_rec->nscan;
i++)
640 *(flt_data +
i) = 0.;
641 dim_siz2[0] = out_rec->nscan;
642 if (
h5io_mk_ds(gid,
"SCSolarZenithAngle", H5T_IEEE_F32BE, 1, dim_siz2,
644 printf(
"%s, %d: Could not do h5io_mk_ds for SCSolarZenithAngle\n",
648 if (
h5io_wr_ds(&ds_id, (
void *) flt_data) != 0) {
649 printf(
"%s, %d: Could not write to SCSolarZenithAngle\n",
654 printf(
"%s, %d: Could not close SCSolarZenithAngle\n",
661 dim_siz2[0] = out_rec->nscan;
663 for (
i = 0;
i < out_rec->nscan * 3;
i++)
664 *(flt_data +
i) = *(sdr_info->geo_vel +
i) * 1000.;
666 free(sdr_info->geo_vel);
667 if (
h5io_mk_ds(gid,
"SCVelocity", H5T_IEEE_F32BE, 2, dim_siz2,
669 printf(
"%s, %d: Could not do h5io_mk_ds for SCVelocity\n",
673 if (
h5io_wr_ds(&ds_id, (
void *) flt_data) != 0) {
674 printf(
"%s, %d: Could not write to SCVelocity\n", __FILE__, __LINE__);
678 printf(
"%s, %d: Could not close SCVelocity\n", __FILE__, __LINE__);
685 &(in_rec->geo_dat_id[2])) != 0) {
686 printf(
"%s, %d: Could not do h5io_set_ds for sena\n", __FILE__, __LINE__);
690 if (
h5io_mk_ds(gid,
"SatelliteAzimuthAngle", H5T_IEEE_F32BE, 2,
691 dim_siz, &(out_rec->geo_dat_id[2])) != 0) {
692 printf(
"%s, %d: Could not do h5io_mk_ds for SatelliteAzimuthAngle\n",
697 if ((in_rec->sena = (
float *) malloc(in_rec->npix * in_rec->ndet_scan *
698 sizeof (
float))) ==
NULL) {
700 "%s, %d: Could not allocate transfer buffer for SatelliteAzimuthAngle\n",
704 out_rec->sena = in_rec->sena;
709 for (
i = 0;
i < out_rec->npix * out_rec->nlin;
i++)
710 *(flt_data +
i) = 0.;
711 if (
h5io_mk_ds(gid,
"SatelliteRange", H5T_IEEE_F32BE, 2, dim_siz, &ds_id)
713 printf(
"%s, %d: Could not do h5io_mk_ds for SatelliteRange\n",
717 if (
h5io_wr_ds(&ds_id, (
void *) flt_data) != 0) {
718 printf(
"%s, %d: Could not write to SatelliteRange\n", __FILE__, __LINE__);
722 printf(
"%s, %d: Could not close SatelliteRange\n", __FILE__, __LINE__);
729 &(in_rec->geo_dat_id[3])) != 0) {
730 printf(
"%s, %d: Could not do h5io_set_ds for senz\n", __FILE__, __LINE__);
734 if (
h5io_mk_ds(gid,
"SatelliteZenithAngle", H5T_IEEE_F32BE, 2,
735 dim_siz, &(out_rec->geo_dat_id[3])) != 0) {
736 printf(
"%s, %d: Could not do h5io_mk_ds for SatelliteZenithAngle\n",
741 if ((in_rec->senz = (
float *) malloc(in_rec->npix * in_rec->ndet_scan *
742 sizeof (
float))) ==
NULL) {
744 "%s, %d: Could not allocate transfer buffer for SatelliteZenithAngle\n",
748 out_rec->senz = in_rec->senz;
753 &(in_rec->geo_dat_id[4])) != 0) {
754 printf(
"%s, %d: Could not do h5io_set_ds on sola\n", __FILE__, __LINE__);
758 if (
h5io_mk_ds(gid,
"SolarAzimuthAngle", H5T_IEEE_F32BE, 2, dim_siz,
759 &(out_rec->geo_dat_id[4])) != 0) {
760 printf(
"%s, %d: Could not do h5io_mk_ds for SolarAzimuthAngle\n",
765 if ((in_rec->solz = (
float *) malloc(in_rec->npix * in_rec->ndet_scan *
766 sizeof (
float))) ==
NULL) {
768 "%s, %d: Could not allocate transfer buffer for SolarAzimuthAngle\n",
772 out_rec->solz = in_rec->solz;
777 &(in_rec->geo_dat_id[5])) != 0) {
778 printf(
"%s, %d: Could not do h5io_set_ds on solz\n", __FILE__, __LINE__);
782 if (
h5io_mk_ds(gid,
"SolarZenithAngle", H5T_IEEE_F32BE, 2, dim_siz,
783 &(out_rec->geo_dat_id[5])) != 0) {
784 printf(
"%s, %d: Could not do h5io_mk_ds for SolarZenithAngle\n",
789 if ((in_rec->sola = (
float *) malloc(in_rec->npix * in_rec->ndet_scan *
790 sizeof (
float))) ==
NULL) {
791 printf(
"%s, %d: Could not allocate transfer buffer for SolarZenithAngle\n",
795 out_rec->sola = in_rec->sola;
799 dbl_data = (
double *) malloc(out_rec->nscan * sizeof (
double));
800 if (
h5io_set_ds(&(in_rec->geo_fid),
"time", &in_ds_id) != 0) {
801 printf(
"%s, %d: Could not do h5io_set_ds for time\n", __FILE__, __LINE__);
804 if (
h5io_rd_ds(&in_ds_id, (
void *) dbl_data) != 0) {
805 printf(
"%s, %d: Could not read time\n", __FILE__, __LINE__);
809 printf(
"%s, %d: Could not close time\n", __FILE__, __LINE__);
813 llon_data = (
int64 *) malloc(out_rec->nscan * sizeof (
int64));
814 for (
i = 0;
i < out_rec->nscan;
i++)
815 *(llon_data +
i) = sdr_info->t58_day +
816 (
int64) (*(dbl_data +
i) * 1e6);
817 dim_siz2[0] = out_rec->nscan;
818 if (
h5io_mk_ds(gid,
"StartTime", H5T_STD_I64BE, 1, dim_siz2, &ds_id)
820 printf(
"%s, %d: Could not do h5io_mk_ds for StartTime\n",
824 if (
h5io_wr_ds(&ds_id, (
void *) llon_data) != 0) {
825 printf(
"%s, %d: Could not write StartTime\n", __FILE__, __LINE__);
829 printf(
"%s, %d: Could not close StartTime\n", __FILE__, __LINE__);
838 out_rec_struc *out_rec)
860 h5io_str ds_id, *gid;
861 int dim_siz[2], dim_siz2[2], *arr_int,
i, isdr, iret;
862 static unsigned char m_side = 0;
863 unsigned char *uchar_data;
864 unsigned int *uint32_data;
865 float rad_fac[2], refl_fac[2];
872 static float lcl_scale[] = {0.0112657, 0.0125841, 1., 1., 1., 0.000752209,
873 1., 0.00302196, 0.00141331, 0.00130450, 0.000582661, 5.17344e-05,
874 1., 0.000321547, 0.000313153, 0.000265539};
875 static float lcl_offset[] = {-0.21, -0.2, 0., 0., 0., -0.09, 0., -0.14,
876 -0.09, -0.04, -0.02, 0., 0., -0.03, -0.02, -0.02};
877 static float lcl_scale_ref[] = {2.28913e-05, 2.28913e-05, 2.28913e-05,
878 2.28913e-05, 2.28913e-05, 2.28913e-05, 2.28913e-05, 2.28913e-05,
879 2.28913e-05, 2.28913e-05, 2.28913e-05, 0.00251805, 1., 0.00373892,
880 0.00412044, 0.00425779};
881 static float lcl_offset_ref[] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
882 0., 203., 0., 120., 111., 103.};
888 gid = &(out_rec->sdr_dat_gid[1][isdr]);
893 uchar_data = (
unsigned char *) malloc(out_rec->nscan *
894 sizeof (
unsigned char));
897 if (
h5io_mk_ds(gid,
"ModeGran", H5T_STD_U8BE, 1, dim_siz2, &ds_id)
899 printf(
"%s, %d: Could not do h5io_mk_ds for ModeGran\n",
903 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
904 printf(
"%s, %d: Could not write to ModeGran\n", __FILE__, __LINE__);
908 printf(
"%s, %d: Could not close ModeGran\n", __FILE__, __LINE__);
915 uchar_data = (
unsigned char *) malloc(out_rec->nscan *
916 sizeof (
unsigned char));
917 for (
i = 0;
i < out_rec->nscan;
i++)
918 *(uchar_data +
i) = 1;
919 dim_siz2[0] = out_rec->nscan;
920 if (
h5io_mk_ds(gid,
"ModeScan", H5T_STD_U8BE, 1, dim_siz2, &ds_id)
922 printf(
"%s, %d: Could not do h5io_mk_ds for ModeScan\n",
926 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
927 printf(
"%s, %d: Could not write to ModeScan\n", __FILE__, __LINE__);
931 printf(
"%s, %d: Could not close ModeScan\n", __FILE__, __LINE__);
938 arr_int = (
int *) malloc(out_rec->nscan * sizeof (
int));
939 for (
i = 0;
i < out_rec->nscan;
i++)
941 dim_siz2[0] = out_rec->nscan;
942 if (
h5io_mk_ds(gid,
"NumberOfBadChecksums", H5T_STD_I32BE, 1,
943 dim_siz2, &ds_id) != 0) {
944 printf(
"%s, %d: Could not do h5io_mk_ds for NumberOfBadChecksums\n",
948 if (
h5io_wr_ds(&ds_id, (
void *) arr_int) != 0) {
949 printf(
"%s, %d: Could not write to NumberOfBadChecksums\n",
954 printf(
"%s, %d: Could not close NumberOfBadChecksums\n",
962 arr_int = (
int *) malloc(out_rec->nscan * sizeof (
int));
963 for (
i = 0;
i < out_rec->nscan;
i++)
965 dim_siz2[0] = out_rec->nscan;
966 if (
h5io_mk_ds(gid,
"NumberOfDiscardedPackets", H5T_STD_I32BE, 1,
967 dim_siz2, &ds_id) != 0) {
968 printf(
"%s, %d: Could not do h5io_mk_ds for NumberOfDiscardedPackets\n",
972 if (
h5io_wr_ds(&ds_id, (
void *) arr_int) != 0) {
973 printf(
"%s, %d: Could not write to NumberOfDiscardedPackets\n",
978 printf(
"%s, %d: Could not close NumberOfDiscardedPackets\n",
986 arr_int = (
int *) malloc(out_rec->nscan * sizeof (
int));
987 for (
i = 0;
i < out_rec->nscan;
i++)
989 dim_siz2[0] = out_rec->nscan;
990 if (
h5io_mk_ds(gid,
"NumberOfMissingPkts", H5T_STD_I32BE, 1,
991 dim_siz2, &ds_id) != 0) {
992 printf(
"%s, %d: Could not do h5io_mk_ds for NumberOfMissingPkts\n",
996 if (
h5io_wr_ds(&ds_id, (
void *) arr_int) != 0) {
997 printf(
"%s, %d: Could not write to NumberOfMissingPkts\n",
1002 printf(
"%s, %d: Could not close NumberOfMissingPkts\n",
1003 __FILE__, __LINE__);
1010 arr_int = (
int *) malloc(
sizeof (
int));
1011 *arr_int = out_rec->nscan;
1013 if (
h5io_mk_ds(gid,
"NumberOfScans", H5T_STD_I32BE, 1, dim_siz, &ds_id)
1015 printf(
"%s, %d: Could not do h5io_mk_ds for NumberOfScans\n",
1016 __FILE__, __LINE__);
1019 if (
h5io_wr_ds(&ds_id, (
void *) arr_int) != 0) {
1020 printf(
"%s, %d: Could not write to NumberOfScans\n", __FILE__, __LINE__);
1024 printf(
"%s, %d: Could not close NumberOfScans\n", __FILE__, __LINE__);
1031 uchar_data = (
unsigned char *) malloc(3 *
sizeof (
unsigned char));
1032 for (
i = 0;
i < 3;
i++)
1033 *(uchar_data +
i) = 0;
1035 if (
h5io_mk_ds(gid,
"PadByte1", H5T_STD_U8BE, 1, dim_siz, &ds_id)
1037 printf(
"%s, %d: Could not do h5io_mk_ds for PadByte1\n",
1038 __FILE__, __LINE__);
1041 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
1042 printf(
"%s, %d: Could not write to PadByte1\n", __FILE__, __LINE__);
1046 printf(
"%s, %d: Could not close PadByte1\n", __FILE__, __LINE__);
1054 dim_siz[0] = out_rec->nlin;
1055 dim_siz[1] = out_rec->npix;
1056 if (
h5io_mk_ds(gid,
"QF1_VIIRSMBANDSDR", H5T_STD_U8BE, 2, dim_siz,
1057 &(out_rec->qual1_m_id[ibnd])) != 0) {
1058 printf(
"%s, %d: Could not do h5io_mk_ds for QF1_VIIRSMBANDSDR\n",
1059 __FILE__, __LINE__);
1065 if ((out_rec->qual1_m[ibnd] = (
unsigned char *)
1066 calloc(out_rec->npix * out_rec->ndet_scan, sizeof (
unsigned char)))
1068 printf(
"%s, %d: Could not allocate space for qual1_m output for band %d\n",
1069 __FILE__, __LINE__, ibnd);
1076 uchar_data = (
unsigned char *) calloc(out_rec->nscan,
1077 sizeof (
unsigned char));
1078 for (
i = 0;
i < out_rec->nscan;
i++) {
1079 *(uchar_data +
i) = m_side;
1080 m_side = 1 - m_side;
1081 *(sdr_info->ham_side +
i) = m_side;
1083 dim_siz[0] = out_rec->nscan;
1084 if (
h5io_mk_ds(gid,
"QF2_SCAN_SDR", H5T_STD_U8BE, 1, dim_siz, &ds_id)
1086 printf(
"%s, %d: Could not do h5io_mk_ds for QF2_SCAN_SDR\n",
1087 __FILE__, __LINE__);
1090 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
1091 printf(
"%s, %d: Could not write to QF2_SCAN_SDR\n", __FILE__, __LINE__);
1095 printf(
"%s, %d: Could not close QF2_SCAN_SDR\n", __FILE__, __LINE__);
1102 dim_siz[0] = out_rec->nscan;
1104 uint32_data = (
unsigned int *)
1105 calloc(dim_siz[0] * dim_siz[1],
sizeof (
unsigned int));
1106 if (
h5io_mk_ds(gid,
"QF3_SCAN_RDR", H5T_STD_U32BE, 2, dim_siz, &ds_id)
1108 printf(
"%s, %d: Could not do h5io_mk_ds for QF3_SCAN_RDR\n",
1109 __FILE__, __LINE__);
1112 if (
h5io_wr_ds(&ds_id, (
void *) uint32_data) != 0) {
1113 printf(
"%s, %d: Could not write to QF3_SCAN_RDR\n", __FILE__, __LINE__);
1117 printf(
"%s, %d: Could not close QF3_SCAN_RDR\n", __FILE__, __LINE__);
1124 uchar_data = (
unsigned char *) calloc(out_rec->nlin,
1125 sizeof (
unsigned char));
1126 dim_siz2[0] = out_rec->nlin;
1127 if (
h5io_mk_ds(gid,
"QF4_SCAN_SDR", H5T_STD_U8BE, 1, dim_siz2, &ds_id)
1129 printf(
"%s, %d: Could not do h5io_mk_ds for QF4_SCAN_SDR\n",
1130 __FILE__, __LINE__);
1133 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
1134 printf(
"%s, %d: Could not write to QF4_SCAN_SDR\n", __FILE__, __LINE__);
1138 printf(
"%s, %d: Could not close QF4_SCAN_SDR\n", __FILE__, __LINE__);
1145 uchar_data = (
unsigned char *) calloc(out_rec->ndet_scan,
1146 sizeof (
unsigned char));
1147 dim_siz2[0] = out_rec->ndet_scan;
1148 if (
h5io_mk_ds(gid,
"QF5_GRAN_BADDETECTOR", H5T_STD_U8BE, 1, dim_siz2,
1150 printf(
"%s, %d: Could not do h5io_mk_ds for QF5_GRAN_BADDETECTOR\n",
1151 __FILE__, __LINE__);
1154 if (
h5io_wr_ds(&ds_id, (
void *) uchar_data) != 0) {
1155 printf(
"%s, %d: Could not write to QF5_GRAN_BADDETECTOR\n",
1156 __FILE__, __LINE__);
1160 printf(
"%s, %d: Could not close QF5_GRAN_BADDETECTOR\n",
1161 __FILE__, __LINE__);
1168 dim_siz[0] = out_rec->nlin;
1169 dim_siz[1] = out_rec->npix;
1182 if (out_rec->out_bnd_typ[ibnd] == 0)
1183 iret =
h5io_mk_ds(gid,
"Radiance", H5T_STD_U16BE, 2, dim_siz,
1184 &(out_rec->bnd_dat_id[0][ibnd]));
1186 iret =
h5io_mk_ds(gid,
"Radiance", H5T_IEEE_F32BE, 2, dim_siz,
1187 &(out_rec->bnd_dat_id[0][ibnd]));
1189 printf(
"%s, %d: Could not do h5io_mk_ds for Radiance\n",
1190 __FILE__, __LINE__);
1197 if ((in_rec->bnd_lt[ibnd] = (
float *)
1198 malloc(in_rec->npix * in_rec->ndet_scan * sizeof (
float)))
1201 "%s, %d: Could not allocate space for radiance data transfer buffer\n",
1202 __FILE__, __LINE__);
1206 out_rec->bnd_lt[ibnd] = in_rec->bnd_lt[ibnd];
1210 if ((in_rec->bnd_q[ibnd] = (
unsigned char *)
1211 malloc(in_rec->npix * in_rec->ndet_scan * sizeof (
unsigned char)))
1214 "%s, %d: Could not allocate space for output radiance flag buffer\n",
1215 __FILE__, __LINE__);
1218 out_rec->bnd_q[ibnd] = in_rec->bnd_q[ibnd];
1235 if (out_rec->out_bnd_typ[ibnd] == 0) {
1254 out_rec->scale[ibnd] = lcl_scale[ibnd];
1255 out_rec->offset[ibnd] = lcl_offset[ibnd];
1257 out_rec->scale[ibnd] = 1.;
1258 out_rec->offset[ibnd] = 0.;
1260 rad_fac[0] = out_rec->scale[ibnd];
1261 rad_fac[1] = out_rec->offset[ibnd];
1262 if (
h5io_mk_ds(gid,
"RadianceFactors", H5T_IEEE_F32BE, 1, dim_siz, &ds_id)
1264 printf(
"%s, %d: Could not do h5io_mk_ds for RadianceFactors\n",
1265 __FILE__, __LINE__);
1268 if (
h5io_wr_ds(&ds_id, (
void *) rad_fac) != 0) {
1269 printf(
"%s, %d: Could not write to RadianceFactors\n",
1270 __FILE__, __LINE__);
1274 printf(
"%s, %d: Could not close RadianceFactors\n", __FILE__, __LINE__);
1277 if (out_rec->meas_typ[ibnd] == 0) {
1281 dim_siz[0] = out_rec->nlin;
1282 dim_siz[1] = out_rec->npix;
1283 if (
h5io_mk_ds(gid,
"Reflectance", H5T_STD_U16BE, 2, dim_siz,
1284 &(out_rec->bnd_dat_id[1][ibnd])) != 0) {
1285 printf(
"%s, %d: Could not do h5io_mk_ds for Latitude\n",
1286 __FILE__, __LINE__);
1300 out_rec->refl_scale[ibnd] = lcl_scale_ref[ibnd];
1301 out_rec->refl_offset[ibnd] = lcl_offset_ref[ibnd];
1302 refl_fac[0] = out_rec->refl_scale[ibnd];
1303 refl_fac[1] = out_rec->refl_offset[ibnd];
1304 if (
h5io_mk_ds(gid,
"ReflectanceFactors", H5T_IEEE_F32BE, 1,
1305 dim_siz, &ds_id) != 0) {
1306 printf(
"%s, %d: Could not do h5io_mk_ds for ReflectanceFactors\n",
1307 __FILE__, __LINE__);
1310 if (
h5io_wr_ds(&ds_id, (
void *) refl_fac) != 0) {
1311 printf(
"%s, %d: Could not write to ReflectanceFactors\n",
1312 __FILE__, __LINE__);
1316 printf(
"%s, %d: Could not close ReflectanceFactors\n",
1317 __FILE__, __LINE__);
1324 dim_siz[0] = out_rec->nlin;
1325 dim_siz[1] = out_rec->npix;
1330 if (out_rec->out_bnd_typ[ibnd] == 0)
1331 iret =
h5io_mk_ds(gid,
"BrightnessTemperature", H5T_STD_U16BE, 2,
1332 dim_siz, &(out_rec->bnd_dat_id[1][ibnd]));
1334 iret =
h5io_mk_ds(gid,
"BrightnessTemperature", H5T_IEEE_F32BE, 2,
1335 dim_siz, &(out_rec->bnd_dat_id[1][ibnd]));
1337 printf(
"%s, %d: Could not do h5io_mk_ds for BrightnessTemperature\n",
1338 __FILE__, __LINE__);
1354 if (out_rec->out_bnd_typ[ibnd] == 0) {
1359 out_rec->refl_scale[ibnd] = lcl_scale_ref[ibnd];
1360 out_rec->refl_offset[ibnd] = lcl_offset_ref[ibnd];
1362 out_rec->refl_scale[ibnd] = 1.;
1363 out_rec->refl_offset[ibnd] = 0.;
1365 rad_fac[0] = out_rec->refl_scale[ibnd];
1366 rad_fac[1] = out_rec->refl_offset[ibnd];
1367 if (
h5io_mk_ds(gid,
"BrightnessTemperatureFactors", H5T_IEEE_F32BE,
1368 1, dim_siz, &ds_id) != 0) {
1370 "%s, %d: Could not do h5io_mk_ds for BrightnessTemperatureFactors\n",
1371 __FILE__, __LINE__);
1374 if (
h5io_wr_ds(&ds_id, (
void *) rad_fac) != 0) {
1375 printf(
"%s, %d: Could not write to BrightnessTemperatureFactors\n",
1376 __FILE__, __LINE__);
1380 printf(
"%s, %d: Could not close BrightnessTemperatureFactors\n",
1381 __FILE__, __LINE__);
1407 int n_attr = 7, dims_1_1[] = {1, 1};
1409 char op_mode[] =
"NPP Normal Operations, VIIRS Operational";
1410 int len_op_mode, len_domain;
1412 len_op_mode = strlen(op_mode);
1413 len_domain = strlen(sdr_info->domain);
1416 h5attr_struc
attrs[] = {
1417 { 1, 1,
"Instrument_Short_name", H5T_NATIVE_CHAR, 6, 2, dims_1_1,
1419 { 1, 1,
"N_Anc_Type_Tasked", H5T_NATIVE_CHAR, 9, 2, dims_1_1,
1420 (
void *)
"Official"},
1421 { 1, 1,
"N_Collection_Short_Name", H5T_NATIVE_CHAR, 17, 2, dims_1_1,
1423 { 1, 1,
"N_Dataset_Type_Tag", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
1425 { 0, 0,
"N_Instrument_Flight_SW_Version", H5T_STD_I32BE, 0, 2, dims_1_1,
1427 { 1, 1,
"N_Processing_Domain", H5T_NATIVE_CHAR, len_domain, 2, dims_1_1,
1428 (
void *) sdr_info->domain},
1429 { 1, 1,
"Operation_Mode", H5T_NATIVE_CHAR, len_op_mode, 2, dims_1_1,
1438 attrs[1].express = 0;
1440 attrs[3].data = (
void *)
"SDR";
1442 attrs[4].express = 1;
1448 printf(
"%s, %d: Could not write data prod attributes\n",
1449 __FILE__, __LINE__);
1476 int n_attr = 9, dims_1_1[] = {1, 1};
1480 h5attr_struc
attrs[] = {
1481 { 1, 1,
"AggregateBeginningDate", H5T_NATIVE_CHAR, 9, 2, dims_1_1,
1482 (
void *) sdr_info->st_date},
1483 { 1, 1,
"AggregateBeginningGranuleID", H5T_NATIVE_CHAR, 16, 2, dims_1_1,
1484 (
void *)
"NPP001212012151"},
1485 { 1, 0,
"AggregateBeginningOrbitNumber", H5T_STD_U64BE, 0, 2, dims_1_1,
1487 { 1, 1,
"AggregateBeginningTime", H5T_NATIVE_CHAR, 15, 2, dims_1_1,
1488 (
void *) sdr_info->st_time},
1489 { 1, 1,
"AggregateEndingDate", H5T_NATIVE_CHAR, 9, 2, dims_1_1,
1490 (
void *) sdr_info->en_date},
1491 { 1, 1,
"AggregateEndingGranuleID", H5T_NATIVE_CHAR, 16, 2, dims_1_1,
1492 (
void *)
"NPP001212012151"},
1493 { 1, 0,
"AggregateEndingOrbitNumber", H5T_STD_U64BE, 0, 2, dims_1_1,
1495 { 1, 1,
"AggregateEndingTime", H5T_NATIVE_CHAR, 15, 2, dims_1_1,
1496 (
void *) sdr_info->en_time},
1497 { 1, 0,
"AggregateNumberGranules", H5T_STD_I32BE, 0, 2, dims_1_1,
1504 int dim_siz[2], *arr_int;
1508 arr_int = (
int *) malloc(
sizeof (
int));
1511 sprintf(grp_name,
"%s_Aggr",
core_g_nm[isdr]);
1512 if (
h5io_mk_ds(gid, grp_name, H5T_NATIVE_INT, 1,
1513 dim_siz, &ds_id) != 0) {
1514 printf(
"%s, %d: Could not do h5io_mk_ds for grp VIIRS-MOD-GEO-TC_Aggr\n",
1515 __FILE__, __LINE__);
1518 if (
h5io_wr_ds(&ds_id, (
void *) arr_int) != 0) {
1519 printf(
"%s, %d: Could not write to VIIRS-MOD-GEO-TC_Aggr\n",
1520 __FILE__, __LINE__);
1529 "%s, %d: Could not write top attributes for VIIRS-MOD-GEO-TC_Aggr\n",
1530 __FILE__, __LINE__);
1534 printf(
"%s, %d: Could not close VIIRS-MOD-GEO-TC_Aggr\n",
1535 __FILE__, __LINE__);
1541 int init_sdr_gran(
int isdr, h5io_str *gid, sdr_info_struc *sdr_info, out_rec_struc *out_rec)
1563 int n_attr = 49, dims_1_1[] = {1, 1}, len_str,
i;
1564 int dims_8_1[] = {8, 1}, dims_9_1[] = {9, 1};
1565 int dims_2_1[] = {2, 1}, dims_anc[] = {19, 1}, dims_aux[] = {5, 1};
1566 int qual_sum_val[2];
1567 float g_ring_lat[8], g_ring_lon[8], gran_bdy[4], nadir_bdy[4];
1570 char char33_9[33 * 9], band_id[4], char_100_49[100 * 49 ], grp_nam[100];
1571 char gran_vers[10] =
"A1M", doc_ref[10] =
"N/A";
1572 char *sw_vers =
"viirs_sim_sdr_v0.0", gran_id[16];
1573 char qual_sum_name[ 26 * 2 ], char_anc[ 19 * 106 ], char_aux[ 5 * 106];
1574 unsigned char asc_dec = 0;
1576 len_str = strlen(sw_vers);
1577 sprintf(gran_id,
"V%8.8s%6.6s", sdr_info->st_date, sdr_info->st_time);
1578 h5attr_struc
attrs[] = {
1579 { 1, 0,
"Ascending/Descending_Indicator", H5T_NATIVE_UCHAR, 0, 2, dims_1_1,
1581 { 0, 1,
"Band_ID", H5T_NATIVE_CHAR, 2, 2, dims_1_1,
1583 { 1, 1,
"Beginning_Date", H5T_NATIVE_CHAR, 9, 2, dims_1_1,
1584 (
void *) sdr_info->st_date},
1585 { 1, 1,
"Beginning_Time", H5T_NATIVE_CHAR, 15, 2, dims_1_1,
1586 (
void *) sdr_info->st_time},
1587 { 0, 0,
"East_Bounding_Coordinate", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1589 { 1, 1,
"Ending_Date", H5T_NATIVE_CHAR, 9, 2, dims_1_1,
1590 (
void *) sdr_info->en_date},
1591 { 1, 1,
"Ending_Time", H5T_NATIVE_CHAR, 15, 2, dims_1_1,
1592 (
void *) sdr_info->en_time},
1593 { 1, 0,
"G-Ring-Latitude", H5T_IEEE_F32BE, 0, 2, dims_8_1,
1594 (
void *) g_ring_lat},
1595 { 1, 0,
"G-Ring-Longitude", H5T_IEEE_F32BE, 0, 2, dims_8_1,
1596 (
void *) g_ring_lon},
1597 { 1, 1,
"N_Algorithm_Version", H5T_NATIVE_CHAR, 8, 2, dims_1_1,
1599 { 1, 1,
"N_Anc_Filename", H5T_NATIVE_CHAR, 106, 2, dims_anc,
1601 { 1, 1,
"N_Aux_Filename", H5T_NATIVE_CHAR, 106, 2, dims_aux,
1603 { 1, 0,
"N_Beginning_Orbit_Number", H5T_STD_U64BE, 0, 2, dims_1_1,
1605 { 1, 0,
"N_Beginning_Time_IET", H5T_STD_U64BE, 0, 1, dims_1_1,
1606 (
void *) &(sdr_info->st_58_t)},
1607 { 1, 1,
"N_Creation_Date", H5T_NATIVE_CHAR, 9, 2, dims_1_1,
1608 (
void *) sdr_info->cre_date},
1609 { 1, 1,
"N_Creation_Time", H5T_NATIVE_CHAR, 15, 2, dims_1_1,
1610 (
void *) sdr_info->cre_time},
1611 { 1, 0,
"N_Ending_Time_IET", H5T_STD_U64BE, 0, 1, dims_1_1,
1612 (
void *) &(sdr_info->en_58_t)},
1613 { 0, 1,
"N_Graceful_Degradation", H5T_NATIVE_CHAR, 3, 2, dims_1_1,
1615 { 1, 1,
"N_Granule_ID", H5T_NATIVE_CHAR, 15, 2, dims_1_1,
1618 { 1, 1,
"N_Granule_Status", H5T_NATIVE_CHAR, 5, 2, dims_1_1,
1620 { 1, 1,
"N_Granule_Version", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
1621 (
void *) gran_vers},
1622 { 1, 1,
"N_Input_Prod", H5T_NATIVE_CHAR, 33, 2, dims_9_1,
1624 { 1, 1,
"N_LEOA_Flag", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
1626 { 1, 0,
"N_Nadir_Latitude_Max", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1627 (
void *) (nadir_bdy + 2)},
1628 { 1, 0,
"N_Nadir_Latitude_Min", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1629 (
void *) (nadir_bdy + 3)},
1630 { 1, 0,
"N_Nadir_Longitude_Max", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1631 (
void *) nadir_bdy},
1632 { 1, 0,
"N_Nadir_Longitude_Min", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1633 (
void *) (nadir_bdy + 1)},
1634 { 1, 1,
"N_NPOES_Document_Ref", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
1636 { 1, 0,
"N_Number_Of_Scans", H5T_STD_I32BE, 0, 2, dims_1_1,
1637 (
void *) &(out_rec->nscan)},
1638 { 0, 0,
"N_Percent_Erroneous_Data", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1640 { 0, 0,
"N_Percent_Missing_Data", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1642 { 0, 0,
"N_Percent_Not_Applicable_Data", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1644 { 1, 1,
"N_Quality_Summary_Names", H5T_NATIVE_CHAR, 26, 2, dims_2_1,
1645 (
void *) qual_sum_name},
1646 { 1, 0,
"N_Quality_Summary_Values", H5T_STD_I32BE, 0, 2, dims_2_1,
1647 (
void *) qual_sum_val},
1648 { 1, 1,
"N_Reference_ID", H5T_NATIVE_CHAR, 10, 2, dims_1_1,
1649 (
void *)
"Who_Cares"},
1650 { 0, 0,
"N_Satellite/Local_Azimuth_Angle_Max", H5T_IEEE_F32BE, 0, 2,
1651 dims_1_1, (
void *) &fill},
1652 { 0, 0,
"N_Satellite/Local_Azimuth_Angle_Min", H5T_IEEE_F32BE, 0, 2,
1653 dims_1_1, (
void *) &fill},
1654 { 0, 0,
"N_Satellite/Local_Zenith_Angle_Max", H5T_IEEE_F32BE, 0, 2,
1655 dims_1_1, (
void *) &fill},
1656 { 0, 0,
"N_Satellite/Local_Zenith_Angle_Min", H5T_IEEE_F32BE, 0, 2,
1657 dims_1_1, (
void *) &fill},
1658 { 1, 1,
"N_Software_Version", H5T_NATIVE_CHAR, len_str, 2, dims_1_1,
1660 { 0, 0,
"N_Solar_Azimuth_Angle_Max", H5T_IEEE_F32BE, 0, 2,
1661 dims_1_1, (
void *) &fill},
1662 { 0, 0,
"N_Solar_Azimuth_Angle_Min", H5T_IEEE_F32BE, 0, 2,
1663 dims_1_1, (
void *) &fill},
1664 { 0, 0,
"N_Solar_Zenith_Angle_Max", H5T_IEEE_F32BE, 0, 2,
1665 dims_1_1, (
void *) &fill},
1666 { 0, 0,
"N_Solar_Zenith_Angle_Min", H5T_IEEE_F32BE, 0, 2,
1667 dims_1_1, (
void *) &fill},
1668 { 1, 1,
"N_Spacecraft_Maneuver", H5T_NATIVE_CHAR, 18, 2, dims_1_1,
1669 (
void *)
"Normal Operations"},
1670 { 0, 0,
"North_Bounding_Coordinate", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1671 (
void *) (gran_bdy + 2)},
1672 { 0, 0,
"South_Bounding_Coordinate", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1673 (
void *) (gran_bdy + 3)},
1674 { 0, 0,
"West_Bounding_Coordinate", H5T_IEEE_F32BE, 0, 2, dims_1_1,
1675 (
void *) (gran_bdy + 1)},
1676 { 1, 1,
"N_Day_Night_Flag", H5T_NATIVE_CHAR, 4, 2, dims_1_1,
1683 int dim_siz[2], *arr_int;
1687 for (
i = 0;
i < 8;
i++) {
1688 *(g_ring_lat +
i) = (
float)
i * 2.5;
1689 *(g_ring_lon +
i) = (
float)
i * 25;
1694 for (
i = 0;
i < 9;
i++)
1695 sprintf((char33_9 + (
i * 33)),
"Input_prod_#_%d",
i);
1700 for (
i = 0;
i < n_attr;
i++)
1702 sprintf(band_id,
"M%d", isdr);
1704 for (
i = 0;
i < 49;
i++)
1705 sprintf((char_100_49 + (
i * 100)),
"Aux file #%d",
i);
1706 for (
i = 0;
i < 4;
i++) {
1707 *(gran_bdy +
i) = 0.;
1708 *(nadir_bdy +
i) = 0.;
1715 for (
i = 0;
i < 2;
i++) {
1716 sprintf((qual_sum_name + (
i * 26)),
"qual sum name %d",
i);
1717 *(qual_sum_val +
i) =
i;
1722 for (
i = 0;
i < 19;
i++)
1723 sprintf((char_anc + (
i * 106)),
"Anc file # %d",
i);
1724 for (
i = 0;
i < 5;
i++)
1725 sprintf((char_aux + (
i * 106)),
"Aux file # %d",
i);
1729 arr_int = (
int *) malloc(
sizeof (
int));
1732 sprintf(grp_nam,
"%s_Gran_0",
core_g_nm[isdr]);
1733 if (
h5io_mk_ds(gid, grp_nam, H5T_NATIVE_INT, 1,
1734 dim_siz, &ds_id) != 0) {
1735 printf(
"%s, %d: Could not do h5io_mk_ds for VIIRS-MOD-GEO-TC_Gran_0\n",
1736 __FILE__, __LINE__);
1739 if (
h5io_wr_ds(&ds_id, (
void *) arr_int) != 0) {
1740 printf(
"%s, %d: Could not write to VIIRS-MOD-GEO-TC_Gran_0\n",
1741 __FILE__, __LINE__);
1750 "%s %d: Could not write top attributes for VIIRS-MOD-GEO-TC_Gran_0\n",
1751 __FILE__, __LINE__);
1755 printf(
"%s %d: Could not close VIIRS-MOD-GEO-TC_Gran_0\n",
1756 __FILE__, __LINE__);