13 #include "InternalErr.h"
23 #define SIGNED_BYTE_TO_INT32 1
26 HDFEOS2Array_RealField::read ()
29 BESDEBUG(
"h4",
"Coming to HDFEOS2_Array_RealField read "<<endl);
31 string check_pass_fileid_key_str=
"H4.EnablePassFileID";
32 bool check_pass_fileid_key =
false;
46 nelms = format_constraint (&offset[0], &step[0], &count[0]);
49 vector<int32>offset32;
50 offset32.resize(rank);
57 for (
int i = 0; i < rank; i++) {
58 offset32[i] = (int32) offset[i];
59 count32[i] = (int32) count[i];
60 step32[i] = (int32) step[i];
64 int32 (*openfunc) (
char *, intn);
65 intn (*closefunc) (int32);
66 int32 (*attachfunc) (int32,
char *);
67 intn (*detachfunc) (int32);
68 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
69 intn (*readfieldfunc) (int32,
char *, int32 *, int32 *, int32 *,
void *);
71 intn (*attrinfofunc) (int32,
char *, int32 *, int32 *);
72 intn (*readattrfunc) (int32,
char *,
void*);
75 if (swathname ==
"") {
78 attachfunc = GDattach;
79 detachfunc = GDdetach;
80 fieldinfofunc = GDfieldinfo;
81 readfieldfunc = GDreadfield;
82 datasetname = gridname;
84 attrinfofunc = GDattrinfo;
85 readattrfunc = GDreadattr;
87 else if (gridname ==
"") {
90 attachfunc = SWattach;
91 detachfunc = SWdetach;
92 fieldinfofunc = SWfieldinfo;
93 readfieldfunc = SWreadfield;
94 datasetname = swathname;
96 attrinfofunc = SWattrinfo;
97 readattrfunc = SWreadattr;
100 throw InternalErr (__FILE__, __LINE__,
"It should be either grid or swath.");
106 if (
true == isgeofile ||
false == check_pass_fileid_key) {
109 gfid = openfunc (const_cast < char *>(filename.c_str ()), DFACC_READ);
112 eherr <<
"File " << filename.c_str () <<
" cannot be open.";
113 throw InternalErr (__FILE__, __LINE__, eherr.str ());
122 gridid = attachfunc (gfid, const_cast < char *>(datasetname.c_str ()));
126 eherr <<
"Grid/Swath " << datasetname.c_str () <<
" cannot be attached.";
127 throw InternalErr (__FILE__, __LINE__, eherr.str ());
130 string check_disable_scale_comp_key =
"H4.DisableScaleOffsetComp";
131 bool turn_on_disable_scale_comp_key=
false;
134 bool is_modis_l1b =
false;
135 if(
"MODIS_SWATH_Type_L1B" == swathname)
138 bool is_modis_vip =
false;
139 if (
"VIP_CMG_GRID" == gridname)
142 bool field_is_vdata =
false;
153 char tmp_dimlist[1024];
154 int32 tmp_dims[rank];
155 int32 field_dtype = 0;
158 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
159 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
165 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
166 throw InternalErr (__FILE__, __LINE__, eherr.str ());
170 field_is_vdata =
true;
174 bool has_Key_attr =
false;
176 if (
false == field_is_vdata) {
181 if (
true == isgeofile ||
false == check_pass_fileid_key) {
183 sdfileid = SDstart(const_cast < char *>(filename.c_str ()), DFACC_READ);
185 if (FAIL == sdfileid) {
189 eherr <<
"Cannot Start the SD interface for the file " << filename <<endl;
197 sdsindex = SDnametoindex(sdfileid, fieldname.c_str());
198 if (FAIL == sdsindex) {
202 eherr <<
"Cannot obtain the index of " << fieldname;
203 throw InternalErr (__FILE__, __LINE__, eherr.str ());
206 sdsid = SDselect(sdfileid, sdsindex);
211 eherr <<
"Cannot obtain the SDS ID of " << fieldname;
212 throw InternalErr (__FILE__, __LINE__, eherr.str ());
221 if(SDfindattr(sdsid,
"Key")!=FAIL)
226 if (
true == isgeofile ||
false == check_pass_fileid_key)
232 if((
false == is_modis_l1b) && (
false == is_modis_vip)
233 &&(
false == has_Key_attr) && (
true == turn_on_disable_scale_comp_key))
234 write_dap_data_disable_scale_comp(gridid,nelms,&offset32[0],&count32[0],&step32[0]);
236 write_dap_data_scale_comp(gridid,nelms,offset32,count32,step32);
245 r = detachfunc (gridid);
249 eherr <<
"Grid/Swath " << datasetname.c_str () <<
" cannot be detached.";
250 throw InternalErr (__FILE__, __LINE__, eherr.str ());
254 if(
true == isgeofile ||
false == check_pass_fileid_key) {
255 r = closefunc (gfid);
258 eherr <<
"Grid/Swath " << filename.c_str () <<
" cannot be closed.";
259 throw InternalErr (__FILE__, __LINE__, eherr.str ());
267 HDFEOS2Array_RealField::write_dap_data_scale_comp(int32 gridid,
269 vector<int32>& offset32,
270 vector<int32>& count32,
271 vector<int32>& step32) {
275 "coming to HDFEOS2Array_RealField write_dap_data_scale_comp "
278 string check_pass_fileid_key_str=
"H4.EnablePassFileID";
279 bool check_pass_fileid_key =
false;
283 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
284 intn (*readfieldfunc) (int32,
char *, int32 *, int32 *, int32 *,
void *);
286 intn (*attrinfofunc) (int32,
char *, int32 *, int32 *);
287 intn (*readattrfunc) (int32,
char *,
void*);
289 if (swathname ==
"") {
290 fieldinfofunc = GDfieldinfo;
291 readfieldfunc = GDreadfield;
293 attrinfofunc = GDattrinfo;
294 readattrfunc = GDreadattr;
296 else if (gridname ==
"") {
297 fieldinfofunc = SWfieldinfo;
298 readfieldfunc = SWreadfield;
300 attrinfofunc = SWattrinfo;
301 readattrfunc = SWreadattr;
304 throw InternalErr (__FILE__, __LINE__,
"It should be either grid or swath.");
308 char tmp_dimlist[1024];
311 int32 tmp_dims[rank];
314 int32 field_dtype = 0;
321 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
322 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
326 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
327 throw InternalErr (__FILE__, __LINE__, eherr.str ());
337 float *reflectance_offsets =
NULL;
338 float *reflectance_scales =
NULL;
339 float *radiance_offsets =
NULL;
340 float *radiance_scales =
NULL;
343 int32 attr_dtype = 0;
346 int32 temp_attrcount = 0;
349 int32 num_eles_of_an_attr = 0;
352 int32 cf_modl1b_rr_attrindex = 0;
355 int32 cf_modl1b_rr_attrindex2 = 0;
358 int32 cf_vr_attrindex = 0;
361 int32 cf_fv_attrindex = 0;
364 int32 scale_factor_attr_index = 0;
367 int32 add_offset_attr_index = 0;
373 float field_offset = 0;
379 float orig_valid_min = 0;
382 float orig_valid_max = 0;
389 bool has_Key_attr =
false;
394 bool field_is_vdata =
false;
407 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
408 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
411 eherr <<
"Field " << fieldname.c_str ()
412 <<
" information cannot be obtained.";
413 throw InternalErr (__FILE__, __LINE__, eherr.str ());
417 field_is_vdata =
true;
421 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
422 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
426 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
427 throw InternalErr (__FILE__, __LINE__, eherr.str ());
430 cerr<<
"tmp_rank is "<<tmp_rank <<endl;
441 if(
false == field_is_vdata) {
443 char attrname[H4_MAX_NC_NAME + 1];
444 vector<char> attrbuf;
447 if(
false == isgeofile ||
false == check_pass_fileid_key)
450 sdfileid = SDstart(const_cast < char *>(filename.c_str ()), DFACC_READ);
451 if (FAIL == sdfileid) {
453 eherr <<
"Cannot Start the SD interface for the file "
455 throw InternalErr (__FILE__, __LINE__, eherr.str ());
461 sdsindex = SDnametoindex(sdfileid, fieldname.c_str());
462 if (FAIL == sdsindex) {
463 if(
true == isgeofile ||
false == check_pass_fileid_key)
466 eherr <<
"Cannot obtain the index of " << fieldname;
467 throw InternalErr (__FILE__, __LINE__, eherr.str ());
470 sdsid = SDselect(sdfileid, sdsindex);
472 if (
true == isgeofile ||
false == check_pass_fileid_key)
475 eherr <<
"Cannot obtain the SDS ID of " << fieldname;
476 throw InternalErr (__FILE__, __LINE__, eherr.str ());
480 char attrname[H4_MAX_NC_NAME + 1];
481 vector<char> attrbuf, attrbuf2;
488 cf_general_attrindex = SDfindattr(sdsid,
"radiance_scales");
489 cf_general_attrindex2 = SDfindattr(sdsid,
"radiance_offsets");
492 if(cf_general_attrindex!=FAIL && cf_general_attrindex2!=FAIL)
495 ret = SDattrinfo(sdsid, cf_general_attrindex, attrname, &attr_dtype, &temp_attrcount);
499 if(
true == isgeofile)
502 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
503 throw InternalErr (__FILE__, __LINE__, eherr.str ());
506 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
507 ret = SDreadattr(sdsid, cf_general_attrindex, (VOIDP)&attrbuf[0]);
510 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
512 if (
true == isgeofile)
515 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
516 throw InternalErr (__FILE__, __LINE__, eherr.str ());
518 ret = SDattrinfo(sdsid, cf_general_attrindex2, attrname, &attr_dtype, &temp_attrcount);
521 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
523 if(
true == isgeofile)
526 eherr <<
"Attribute 'radiance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
527 throw InternalErr (__FILE__, __LINE__, eherr.str ());
530 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
531 ret = SDreadattr(sdsid, cf_general_attrindex2, (VOIDP)&attrbuf2[0]);
534 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
536 if(
true == isgeofile)
539 eherr <<
"Attribute 'radiance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
540 throw InternalErr (__FILE__, __LINE__, eherr.str ());
547 #define GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
550 CAST *ptr = (CAST*)&attrbuf[0]; \
551 CAST *ptr2 = (CAST*)&attrbuf2[0]; \
552 radiance_scales = new float[temp_attrcount]; \
553 radiance_offsets = new float[temp_attrcount]; \
554 for(int l=0; l<temp_attrcount; l++) \
556 radiance_scales[l] = ptr[l]; \
557 radiance_offsets[l] = ptr2[l]; \
561 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float);
562 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double);
564 #undef GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES
565 num_eles_of_an_attr = temp_attrcount;
569 cf_general_attrindex = SDfindattr(sdsid,
"reflectance_scales");
570 cf_general_attrindex2 = SDfindattr(sdsid,
"reflectance_offsets");
571 if(cf_general_attrindex!=FAIL && cf_general_attrindex2!=FAIL)
574 ret = SDattrinfo(sdsid, cf_general_attrindex, attrname, &attr_dtype, &temp_attrcount);
577 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
579 if(
true == isgeofile)
582 eherr <<
"Attribute 'reflectance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
583 throw InternalErr (__FILE__, __LINE__, eherr.str ());
586 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
587 ret = SDreadattr(sdsid, cf_general_attrindex, (VOIDP)&attrbuf[0]);
590 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
592 if(
true == isgeofile)
595 eherr <<
"Attribute 'reflectance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
596 throw InternalErr (__FILE__, __LINE__, eherr.str ());
599 ret = SDattrinfo(sdsid, cf_general_attrindex2, attrname, &attr_dtype, &temp_attrcount);
602 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
604 if(
true == isgeofile)
607 eherr <<
"Attribute 'reflectance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
608 throw InternalErr (__FILE__, __LINE__, eherr.str ());
611 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
612 ret = SDreadattr(sdsid, cf_general_attrindex2, (VOIDP)&attrbuf2[0]);
615 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
617 if(
true == isgeofile)
620 eherr <<
"Attribute 'reflectance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
621 throw InternalErr (__FILE__, __LINE__, eherr.str ());
625 #define GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
628 CAST *ptr = (CAST*)&attrbuf[0]; \
629 CAST *ptr2 = (CAST*)&attrbuf2[0]; \
630 reflectance_scales = new float[temp_attrcount]; \
631 reflectance_offsets = new float[temp_attrcount]; \
632 for(int l=0; l<temp_attrcount; l++) \
634 reflectance_scales[l] = ptr[l]; \
635 reflectance_offsets[l] = ptr2[l]; \
639 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float);
640 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double);
642 #undef GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES
643 num_eles_of_an_attr = temp_attrcount;
648 scale_factor_attr_index = SDfindattr(sdsid,
"scale_factor");
649 if(scale_factor_attr_index!=FAIL)
652 ret = SDattrinfo(sdsid, scale_factor_attr_index, attrname,
653 &attr_dtype, &temp_attrcount);
657 if(
true == isgeofile ||
false == check_pass_fileid_key)
660 eherr <<
"Attribute 'scale_factor' in "
661 << fieldname.c_str () <<
" cannot be obtained.";
662 throw InternalErr (__FILE__, __LINE__, eherr.str ());
665 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
666 ret = SDreadattr(sdsid, scale_factor_attr_index, (VOIDP)&attrbuf[0]);
670 if(
true == isgeofile ||
false == check_pass_fileid_key)
674 eherr <<
"Attribute 'scale_factor' in "
675 << fieldname.c_str () <<
" cannot be obtained.";
676 throw InternalErr (__FILE__, __LINE__, eherr.str ());
681 #define GET_SCALE_FACTOR_ATTR_VALUE(TYPE, CAST) \
684 CAST tmpvalue = *(CAST*)&attrbuf[0]; \
685 scale = (float)tmpvalue; \
688 GET_SCALE_FACTOR_ATTR_VALUE(INT8, int8);
689 GET_SCALE_FACTOR_ATTR_VALUE(CHAR,int8);
690 GET_SCALE_FACTOR_ATTR_VALUE(UINT8, uint8);
691 GET_SCALE_FACTOR_ATTR_VALUE(UCHAR,uint8);
692 GET_SCALE_FACTOR_ATTR_VALUE(INT16, int16);
693 GET_SCALE_FACTOR_ATTR_VALUE(UINT16, uint16);
694 GET_SCALE_FACTOR_ATTR_VALUE(INT32, int32);
695 GET_SCALE_FACTOR_ATTR_VALUE(UINT32, uint32);
696 GET_SCALE_FACTOR_ATTR_VALUE(FLOAT32,
float);
697 GET_SCALE_FACTOR_ATTR_VALUE(FLOAT64,
double);
700 #undef GET_SCALE_FACTOR_ATTR_VALUE
704 add_offset_attr_index = SDfindattr(sdsid,
"add_offset");
705 if(add_offset_attr_index!=FAIL)
708 ret = SDattrinfo(sdsid, add_offset_attr_index, attrname,
709 &attr_dtype, &temp_attrcount);
713 if(
true == isgeofile ||
false == check_pass_fileid_key)
717 eherr <<
"Attribute 'add_offset' in " << fieldname.c_str ()
718 <<
" cannot be obtained.";
719 throw InternalErr (__FILE__, __LINE__, eherr.str ());
722 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
723 ret = SDreadattr(sdsid, add_offset_attr_index, (VOIDP)&attrbuf[0]);
727 if(
true == isgeofile ||
false == check_pass_fileid_key)
731 eherr <<
"Attribute 'add_offset' in " << fieldname.c_str ()
732 <<
" cannot be obtained.";
733 throw InternalErr (__FILE__, __LINE__, eherr.str ());
738 #define GET_ADD_OFFSET_ATTR_VALUE(TYPE, CAST) \
741 CAST tmpvalue = *(CAST*)&attrbuf[0]; \
742 field_offset = (float)tmpvalue; \
745 GET_ADD_OFFSET_ATTR_VALUE(INT8, int8);
746 GET_ADD_OFFSET_ATTR_VALUE(CHAR,int8);
747 GET_ADD_OFFSET_ATTR_VALUE(UINT8, uint8);
748 GET_ADD_OFFSET_ATTR_VALUE(UCHAR,uint8);
749 GET_ADD_OFFSET_ATTR_VALUE(INT16, int16);
750 GET_ADD_OFFSET_ATTR_VALUE(UINT16, uint16);
751 GET_ADD_OFFSET_ATTR_VALUE(INT32, int32);
752 GET_ADD_OFFSET_ATTR_VALUE(UINT32, uint32);
753 GET_ADD_OFFSET_ATTR_VALUE(FLOAT32,
float);
754 GET_ADD_OFFSET_ATTR_VALUE(FLOAT64,
double);
756 #undef GET_ADD_OFFSET_ATTR_VALUE
760 cf_fv_attrindex = SDfindattr(sdsid,
"_FillValue");
761 if(cf_fv_attrindex!=FAIL)
764 ret = SDattrinfo(sdsid, cf_fv_attrindex, attrname, &attr_dtype, &temp_attrcount);
768 if(
true == isgeofile ||
false == check_pass_fileid_key)
772 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
773 <<
" cannot be obtained.";
774 throw InternalErr (__FILE__, __LINE__, eherr.str ());
777 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
778 ret = SDreadattr(sdsid, cf_fv_attrindex, (VOIDP)&attrbuf[0]);
782 if(
true == isgeofile ||
false == check_pass_fileid_key)
786 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
787 <<
" cannot be obtained.";
788 throw InternalErr (__FILE__, __LINE__, eherr.str ());
793 #define GET_FILLVALUE_ATTR_VALUE(TYPE, CAST) \
796 CAST tmpvalue = *(CAST*)&attrbuf[0]; \
797 fillvalue = (float)tmpvalue; \
800 GET_FILLVALUE_ATTR_VALUE(INT8, int8);
801 GET_FILLVALUE_ATTR_VALUE(CHAR, int8);
802 GET_FILLVALUE_ATTR_VALUE(INT16, int16);
803 GET_FILLVALUE_ATTR_VALUE(INT32, int32);
804 GET_FILLVALUE_ATTR_VALUE(UINT8, uint8);
805 GET_FILLVALUE_ATTR_VALUE(UCHAR, uint8);
806 GET_FILLVALUE_ATTR_VALUE(UINT16, uint16);
807 GET_FILLVALUE_ATTR_VALUE(UINT32, uint32);
809 #undef GET_FILLVALUE_ATTR_VALUE
815 cf_vr_attrindex = SDfindattr(sdsid,
"valid_range");
816 if(cf_vr_attrindex!=FAIL)
819 ret = SDattrinfo(sdsid, cf_vr_attrindex, attrname, &attr_dtype, &temp_attrcount);
823 if(
true == isgeofile ||
false == check_pass_fileid_key)
827 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
828 <<
" cannot be obtained.";
829 throw InternalErr (__FILE__, __LINE__, eherr.str ());
832 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
833 ret = SDreadattr(sdsid, cf_vr_attrindex, (VOIDP)&attrbuf[0]);
837 if(
true == isgeofile ||
false == check_pass_fileid_key)
841 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
842 <<
" cannot be obtained.";
843 throw InternalErr (__FILE__, __LINE__, eherr.str ());
847 string attrbuf_str(attrbuf.begin(),attrbuf.end());
855 size_t found = attrbuf_str.find_first_of(
",");
856 size_t found_from_end = attrbuf_str.find_last_of(
",");
858 if (string::npos == found){
860 if(
true == isgeofile ||
false == check_pass_fileid_key)
862 throw InternalErr(__FILE__,__LINE__,
"should find the separator ,");
864 if (found != found_from_end){
866 if(
true == isgeofile ||
false == check_pass_fileid_key)
868 throw InternalErr(__FILE__,__LINE__,
869 "Only one separator , should be available.");
875 orig_valid_min = atof((attrbuf_str.substr(0,found)).c_str());
876 orig_valid_max = atof((attrbuf_str.substr(found+1)).c_str());
890 if (temp_attrcount >2) {
892 size_t found = attrbuf_str.find_first_of(
",");
893 size_t found_from_end = attrbuf_str.find_last_of(
",");
895 if (string::npos == found){
897 if(
true == isgeofile ||
false == check_pass_fileid_key)
899 throw InternalErr(__FILE__,__LINE__,
"should find the separator ,");
901 if (found != found_from_end){
903 if(
true == isgeofile ||
false == check_pass_fileid_key)
905 throw InternalErr(__FILE__,__LINE__,
906 "Only one separator , should be available.");
912 orig_valid_min = atof((attrbuf_str.substr(0,found)).c_str());
913 orig_valid_max = atof((attrbuf_str.substr(found+1)).c_str());
916 else if (2 == temp_attrcount) {
917 orig_valid_min = (float)attrbuf[0];
918 orig_valid_max = (float)attrbuf[1];
922 if(
true == isgeofile ||
false == check_pass_fileid_key)
924 throw InternalErr(__FILE__,__LINE__,
925 "The number of attribute count should be greater than 1.");
934 if (temp_attrcount != 2) {
936 if(
true == isgeofile ||
false == check_pass_fileid_key)
939 throw InternalErr(__FILE__,__LINE__,
940 "The number of attribute count should be 2 for the DFNT_UINT8 type.");
943 unsigned char* temp_valid_range = (
unsigned char *)&attrbuf[0];
944 orig_valid_min = (float)(temp_valid_range[0]);
945 orig_valid_max = (float)(temp_valid_range[1]);
951 if (temp_attrcount != 2) {
953 if(
true == isgeofile ||
false == check_pass_fileid_key)
956 throw InternalErr(__FILE__,__LINE__,
957 "The number of attribute count should be 2 for the DFNT_INT16 type.");
960 short* temp_valid_range = (
short *)&attrbuf[0];
961 orig_valid_min = (float)(temp_valid_range[0]);
962 orig_valid_max = (float)(temp_valid_range[1]);
968 if (temp_attrcount != 2) {
970 if(
true == isgeofile ||
false == check_pass_fileid_key)
973 throw InternalErr(__FILE__,__LINE__,
974 "The number of attribute count should be 2 for the DFNT_UINT16 type.");
977 unsigned short* temp_valid_range = (
unsigned short *)&attrbuf[0];
978 orig_valid_min = (float)(temp_valid_range[0]);
979 orig_valid_max = (float)(temp_valid_range[1]);
985 if (temp_attrcount != 2) {
987 if(
true == isgeofile ||
false == check_pass_fileid_key)
990 throw InternalErr(__FILE__,__LINE__,
991 "The number of attribute count should be 2 for the DFNT_INT32 type.");
994 int* temp_valid_range = (
int *)&attrbuf[0];
995 orig_valid_min = (float)(temp_valid_range[0]);
996 orig_valid_max = (float)(temp_valid_range[1]);
1002 if (temp_attrcount != 2) {
1004 if(
true == isgeofile ||
false == check_pass_fileid_key)
1007 throw InternalErr(__FILE__,__LINE__,
1008 "The number of attribute count should be 2 for the DFNT_UINT32 type.");
1011 unsigned int* temp_valid_range = (
unsigned int *)&attrbuf[0];
1012 orig_valid_min = (float)(temp_valid_range[0]);
1013 orig_valid_max = (float)(temp_valid_range[1]);
1019 if (temp_attrcount != 2) {
1021 if(
true == isgeofile ||
false == check_pass_fileid_key)
1024 throw InternalErr(__FILE__,__LINE__,
1025 "The number of attribute count should be 2 for the DFNT_FLOAT32 type.");
1028 float* temp_valid_range = (
float *)&attrbuf[0];
1029 orig_valid_min = temp_valid_range[0];
1030 orig_valid_max = temp_valid_range[1];
1036 if (temp_attrcount != 2){
1038 if(
true == isgeofile ||
false == check_pass_fileid_key)
1041 throw InternalErr(__FILE__,__LINE__,
1042 "The number of attribute count should be 2 for the DFNT_FLOAT64 type.");
1044 double* temp_valid_range = (
double *)&attrbuf[0];
1051 orig_valid_min = temp_valid_range[0];
1052 orig_valid_max = temp_valid_range[1];
1057 if(
true == isgeofile ||
false == check_pass_fileid_key)
1059 throw InternalErr(__FILE__,__LINE__,
"Unsupported data type.");
1069 int32 cf_mod_key_attrindex = SUCCEED;
1070 cf_mod_key_attrindex = SDfindattr(sdsid,
"Key");
1071 if(cf_mod_key_attrindex !=FAIL) {
1072 has_Key_attr =
true;
1076 vector<char> attrbuf2;
1084 cf_modl1b_rr_attrindex = SDfindattr(sdsid,
"radiance_scales");
1085 cf_modl1b_rr_attrindex2 = SDfindattr(sdsid,
"radiance_offsets");
1088 if(cf_modl1b_rr_attrindex!=FAIL && cf_modl1b_rr_attrindex2!=FAIL)
1091 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex, attrname,
1092 &attr_dtype, &temp_attrcount);
1096 if(
true == isgeofile ||
false == check_pass_fileid_key)
1098 ostringstream eherr;
1099 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str ()
1100 <<
" cannot be obtained.";
1101 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1104 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1105 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex, (VOIDP)&attrbuf[0]);
1109 if (
true == isgeofile ||
false == check_pass_fileid_key)
1111 ostringstream eherr;
1112 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str ()
1113 <<
" cannot be obtained.";
1114 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1116 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex2, attrname,
1117 &attr_dtype, &temp_attrcount);
1121 if(
true == isgeofile ||
false == check_pass_fileid_key)
1123 ostringstream eherr;
1124 eherr <<
"Attribute 'radiance_offsets' in "
1125 << fieldname.c_str () <<
" cannot be obtained.";
1126 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1129 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1130 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex2, (VOIDP)&attrbuf2[0]);
1134 if(
true == isgeofile ||
false == check_pass_fileid_key)
1136 ostringstream eherr;
1137 eherr <<
"Attribute 'radiance_offsets' in "
1138 << fieldname.c_str () <<
" cannot be obtained.";
1139 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1147 #define GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
1150 CAST *ptr = (CAST*)&attrbuf[0]; \
1151 CAST *ptr2 = (CAST*)&attrbuf2[0]; \
1152 radiance_scales = new float[temp_attrcount]; \
1153 radiance_offsets = new float[temp_attrcount]; \
1154 for(int l=0; l<temp_attrcount; l++) \
1156 radiance_scales[l] = ptr[l]; \
1157 radiance_offsets[l] = ptr2[l]; \
1161 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float);
1162 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double);
1164 #undef GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES
1166 num_eles_of_an_attr = temp_attrcount;
1171 cf_modl1b_rr_attrindex = SDfindattr(sdsid,
"reflectance_scales");
1172 cf_modl1b_rr_attrindex2 = SDfindattr(sdsid,
"reflectance_offsets");
1173 if(cf_modl1b_rr_attrindex!=FAIL && cf_modl1b_rr_attrindex2!=FAIL)
1176 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex, attrname,
1177 &attr_dtype, &temp_attrcount);
1180 release_mod1b_res(reflectance_scales,reflectance_offsets,
1181 radiance_scales,radiance_offsets);
1183 if(
true == isgeofile ||
false == check_pass_fileid_key)
1185 ostringstream eherr;
1186 eherr <<
"Attribute 'reflectance_scales' in "
1187 << fieldname.c_str () <<
" cannot be obtained.";
1188 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1191 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1192 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex, (VOIDP)&attrbuf[0]);
1195 release_mod1b_res(reflectance_scales,reflectance_offsets,
1196 radiance_scales,radiance_offsets);
1198 if(
true == isgeofile ||
false == check_pass_fileid_key)
1200 ostringstream eherr;
1201 eherr <<
"Attribute 'reflectance_scales' in "
1202 << fieldname.c_str () <<
" cannot be obtained.";
1203 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1206 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex2, attrname,
1207 &attr_dtype, &temp_attrcount);
1210 release_mod1b_res(reflectance_scales,reflectance_offsets,
1211 radiance_scales,radiance_offsets);
1213 if(
true == isgeofile ||
false == check_pass_fileid_key)
1215 ostringstream eherr;
1216 eherr <<
"Attribute 'reflectance_offsets' in "
1217 << fieldname.c_str () <<
" cannot be obtained.";
1218 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1221 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1222 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex2, (VOIDP)&attrbuf2[0]);
1225 release_mod1b_res(reflectance_scales,reflectance_offsets,
1226 radiance_scales,radiance_offsets);
1228 if(
true == isgeofile ||
false == check_pass_fileid_key)
1230 ostringstream eherr;
1231 eherr <<
"Attribute 'reflectance_offsets' in "
1232 << fieldname.c_str () <<
" cannot be obtained.";
1233 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1237 #define GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
1240 CAST *ptr = (CAST*)&attrbuf[0]; \
1241 CAST *ptr2 = (CAST*)&attrbuf2[0]; \
1242 reflectance_scales = new float[temp_attrcount]; \
1243 reflectance_offsets = new float[temp_attrcount]; \
1244 for(int l=0; l<temp_attrcount; l++) \
1246 reflectance_scales[l] = ptr[l]; \
1247 reflectance_offsets[l] = ptr2[l]; \
1251 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float);
1252 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double);
1254 #undef GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES
1255 num_eles_of_an_attr = temp_attrcount;
1261 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
1262 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
1264 ostringstream eherr;
1266 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
1267 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1270 cerr<<
"tmp_rank 3 is "<<tmp_rank <<endl;
1276 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
1277 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
1279 ostringstream eherr;
1281 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
1282 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1285 cerr<<
"tmp_rank 4 is "<<tmp_rank <<endl;
1288 BESDEBUG(
"h4",
"scale is "<<scale <<endl);
1289 BESDEBUG(
"h4",
"offset is "<<field_offset <<endl);
1290 BESDEBUG(
"h4",
"fillvalue is "<<fillvalue <<endl);
1328 bool need_change_scale =
true;
1331 string temp_filename;
1332 if (filename.find(
"#") != string::npos)
1333 temp_filename =filename.substr(filename.find_last_of(
"#") + 1);
1335 temp_filename = filename.substr(filename.find_last_of(
"/") +1);
1337 if ((temp_filename.size() >5) && ((temp_filename.compare(0,5,
"MOD09") == 0)
1338 ||(temp_filename.compare(0,5,
"MYD09") == 0))) {
1339 if ((fieldname.size() >5) && fieldname.compare(0,5,
"Range") == 0)
1340 need_change_scale =
false;
1343 if(
true == need_change_scale) {
1346 <<
"The field " << fieldname <<
" scale factor is "
1347 << scale <<
" ."<<endl
1348 <<
" But the original scale factor type is MODIS_MUL_SCALE or MODIS_EQ_SCALE. "
1350 <<
" Now change it to MODIS_DIV_SCALE. "<<endl;
1358 (*
BESLog::TheLog())<<
"The field " << fieldname <<
" scale factor is "
1359 << scale <<
" ."<<endl
1360 <<
" But the original scale factor type is MODIS_DIV_SCALE. "
1362 <<
" Now change it to MODIS_MUL_SCALE. "<<endl;
1366 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
1368 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
1370 ostringstream eherr;
1372 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
1373 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1376 cerr<<
"tmp_rank 2 is "<<tmp_rank <<endl;
1615 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
1617 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
1619 ostringstream eherr;
1621 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
1622 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1625 cerr<<
"tmp_rank again is "<<tmp_rank <<endl;
1627 switch (field_dtype) {
1633 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1634 &offset32[0], &step32[0], &count32[0], &val[0]);
1636 release_mod1b_res(reflectance_scales,reflectance_offsets,
1637 radiance_scales,radiance_offsets);
1638 ostringstream eherr;
1639 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1640 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1643 #ifndef SIGNED_BYTE_TO_INT32
1644 RECALCULATE(int8*, dods_byte*, &val[0]);
1648 vector<int32>newval;
1649 newval.resize(nelms);
1651 for (
int counter = 0; counter < nelms; counter++)
1652 newval[counter] = (int32) (val[counter]);
1654 RECALCULATE(int32*, dods_int32*, &newval[0]);
1665 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1666 &offset32[0], &step32[0], &count32[0], &val[0]);
1668 release_mod1b_res(reflectance_scales,reflectance_offsets,
1669 radiance_scales,radiance_offsets);
1670 ostringstream eherr;
1672 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1673 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1676 RECALCULATE(uint8*, dods_byte*, &val[0]);
1685 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1686 &offset32[0], &step32[0], &count32[0], &val[0]);
1690 release_mod1b_res(reflectance_scales,reflectance_offsets,
1691 radiance_scales,radiance_offsets);
1692 ostringstream eherr;
1694 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1695 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1697 RECALCULATE(int16*, dods_int16*, &val[0]);
1706 cerr<<
"gridid is "<<gridid <<endl;
1708 char tmp_dimlist[1024];
1709 int32 tmp_dims[rank];
1710 int32 field_dtype = 0;
1713 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
1714 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
1716 ostringstream eherr;
1718 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
1719 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1723 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1724 &offset32[0], &step32[0], &count32[0], &val[0]);
1726 release_mod1b_res(reflectance_scales,reflectance_offsets,
1727 radiance_scales,radiance_offsets);
1728 ostringstream eherr;
1730 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1731 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1734 RECALCULATE(uint16*, dods_uint16*, &val[0]);
1742 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1743 &offset32[0], &step32[0], &count32[0], &val[0]);
1746 release_mod1b_res(reflectance_scales,reflectance_offsets,
1747 radiance_scales,radiance_offsets);
1748 ostringstream eherr;
1750 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1751 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1754 RECALCULATE(int32*, dods_int32*, &val[0]);
1762 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1763 &offset32[0], &step32[0], &count32[0], &val[0]);
1766 release_mod1b_res(reflectance_scales,reflectance_offsets,
1767 radiance_scales,radiance_offsets);
1768 ostringstream eherr;
1770 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1771 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1774 RECALCULATE(uint32*, dods_uint32*, &val[0]);
1782 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1783 &offset32[0], &step32[0], &count32[0], &val[0]);
1786 release_mod1b_res(reflectance_scales,reflectance_offsets,
1787 radiance_scales,radiance_offsets);
1788 ostringstream eherr;
1790 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1791 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1795 RECALCULATE(float32*, dods_float32*, &val[0]);
1803 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1804 &offset32[0], &step32[0], &count32[0], &val[0]);
1807 release_mod1b_res(reflectance_scales,reflectance_offsets,
1808 radiance_scales,radiance_offsets);
1809 ostringstream eherr;
1811 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1812 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1814 set_value ((dods_float64 *) &val[0], nelms);
1818 release_mod1b_res(reflectance_scales,reflectance_offsets,
1819 radiance_scales,radiance_offsets);
1820 InternalErr (__FILE__, __LINE__,
"unsupported data type.");
1823 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
1825 if(reflectance_scales!=
NULL)
1827 delete[] reflectance_offsets;
1828 delete[] reflectance_scales;
1831 if(radiance_scales!=
NULL)
1833 delete[] radiance_offsets;
1834 delete[] radiance_scales;
1840 if (
true == isgeofile ||
false == check_pass_fileid_key)
1849 HDFEOS2Array_RealField::write_dap_data_disable_scale_comp(int32 gridid,
1857 "Coming to HDFEOS2_Array_RealField: write_dap_data_disable_scale_comp"
1861 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
1862 intn (*readfieldfunc) (int32,
char *, int32 *, int32 *, int32 *,
void *);
1864 intn (*attrinfofunc) (int32,
char *, int32 *, int32 *);
1865 intn (*readattrfunc) (int32,
char *,
void*);
1867 if (swathname ==
"") {
1868 fieldinfofunc = GDfieldinfo;
1869 readfieldfunc = GDreadfield;
1871 attrinfofunc = GDattrinfo;
1872 readattrfunc = GDreadattr;
1874 else if (gridname ==
"") {
1875 fieldinfofunc = SWfieldinfo;
1876 readfieldfunc = SWreadfield;
1878 attrinfofunc = SWattrinfo;
1879 readattrfunc = SWreadattr;
1882 throw InternalErr (__FILE__, __LINE__,
"It should be either grid or swath.");
1888 char tmp_dimlist[1024];
1891 int32 tmp_dims[rank];
1894 int32 field_dtype = 0;
1901 r = fieldinfofunc (gridid, const_cast < char *>(fieldname.c_str ()),
1902 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
1904 ostringstream eherr;
1905 eherr <<
"Field " << fieldname.c_str ()
1906 <<
" information cannot be obtained.";
1907 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1911 switch (field_dtype) {
1916 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1917 offset32, step32, count32, &val[0]);
1919 ostringstream eherr;
1920 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1921 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1924 #ifndef SIGNED_BYTE_TO_INT32
1925 set_value((dods_byte*)&val[0],nelms);
1928 vector<int32>newval;
1929 newval.resize(nelms);
1931 for (
int counter = 0; counter < nelms; counter++)
1932 newval[counter] = (int32) (val[counter]);
1935 set_value((dods_int32*)&newval[0],nelms);
1945 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1946 offset32, step32, count32, &val[0]);
1949 ostringstream eherr;
1950 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1951 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1955 set_value((dods_byte*)&val[0],nelms);
1963 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1964 offset32, step32, count32, &val[0]);
1967 ostringstream eherr;
1968 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1969 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1972 set_value((dods_int16*)&val[0],nelms);
1979 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1980 offset32, step32, count32, &val[0]);
1982 ostringstream eherr;
1983 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1984 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1988 set_value((dods_uint16*)&val[0],nelms);
1995 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
1996 offset32, step32, count32, &val[0]);
1998 ostringstream eherr;
1999 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
2000 throw InternalErr (__FILE__, __LINE__, eherr.str ());
2004 set_value((dods_int32*)&val[0],nelms);
2011 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
2012 offset32, step32, count32, &val[0]);
2014 ostringstream eherr;
2015 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
2016 throw InternalErr (__FILE__, __LINE__, eherr.str ());
2020 set_value((dods_uint32*)&val[0],nelms);
2027 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
2028 offset32, step32, count32, &val[0]);
2030 ostringstream eherr;
2031 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
2032 throw InternalErr (__FILE__, __LINE__, eherr.str ());
2037 set_value((dods_float32*)&val[0],nelms);
2044 r = readfieldfunc (gridid, const_cast < char *>(fieldname.c_str ()),
2045 offset32, step32, count32, &val[0]);
2047 ostringstream eherr;
2048 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
2049 throw InternalErr (__FILE__, __LINE__, eherr.str ());
2051 set_value ((dods_float64 *) &val[0], nelms);
2055 InternalErr (__FILE__, __LINE__,
"unsupported data type.");
2060 r = detachfunc (gridid);
2063 ostringstream eherr;
2065 eherr <<
"Grid/Swath " << datasetname.c_str () <<
" cannot be detached.";
2066 throw InternalErr (__FILE__, __LINE__, eherr.str ());
2070 r = closefunc (gfid);
2072 ostringstream eherr;
2074 eherr <<
"Grid/Swath " << filename.c_str () <<
" cannot be closed.";
2075 throw InternalErr (__FILE__, __LINE__, eherr.str ());
2085 HDFEOS2Array_RealField::format_constraint (
int *offset,
int *step,
int *count)
2090 Dim_iter p = dim_begin ();
2092 while (p != dim_end ()) {
2094 int start = dimension_start (p,
true);
2095 int stride = dimension_stride (p,
true);
2096 int stop = dimension_stop (p,
true);
2100 if (stride < 0 || start < 0 || stop < 0 || start > stop) {
2103 oss <<
"Array/Grid hyperslab indices are bad: [" << start <<
2104 ":" << stride <<
":" << stop <<
"]";
2105 throw Error (malformed_expr, oss.str ());
2109 if (start == 0 && stop == 0 && stride == 0) {
2110 start = dimension_start (p,
false);
2111 stride = dimension_stride (p,
false);
2112 stop = dimension_stop (p,
false);
2117 count[id] = ((stop - start) / stride) + 1;
2121 "=format_constraint():"
2122 <<
"id=" <<
id <<
" offset=" << offset[
id]
2123 <<
" step=" << step[
id]
2124 <<
" count=" << count[
id]
2136 string check_pass_fileid_key_str=
"H4.EnablePassFileID";
2137 bool check_pass_fileid_key =
false;
2141 if(
true == isgeofile ||
false == check_pass_fileid_key) {
2157 void HDFEOS2Array_RealField::release_mod1b_res(
float*ref_scale,
2162 if(ref_scale !=
NULL)
2164 if(ref_offset !=
NULL)
2165 delete[] ref_offset;
2166 if(rad_scale !=
NULL)
2168 if(rad_offset !=
NULL)
2169 delete[] rad_offset;
void close_fileid(hid_t fid)
closes HDF5 file reffered by fid.
static bool check_beskeys(const std::string &key)
Check the BES key. This function will check a BES key specified at the file h4.conf.in. If the key's value is either true or yes. The handler claims to find a key and will do some operations. Otherwise, will do different operations. For example, One may find a line H4.EnableCF=true at h4.conf.in. That means, the HDF4 handler will handle the HDF4 files by following CF conventions.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream