Re: export to HDF [message #71403 is a reply to message #71321] |
Wed, 16 June 2010 12:19  |
MarioIncandenza
Messages: 231 Registered: February 2005
|
Senior Member |
|
|
Hassan,
The solution you will end up with will look a lot like creating a new
HDF file, even if you populate it mostly with information from the
parent file. If the file has many SDS, this can be rather tedious, but
assuming you have a bunch of files to process, it's the way to go.
This is the call sequence for creating and populating an HDF. NOTE:
This does NOT use HDF_OPEN() or HDF_CLOSE. It needs a better
programmer than I to explain why, but this is complete sequence, the
result of trial and error:
SDinterface_id = HDF_SD_START(<<outfile>>, /CREATE)
title=<<"TITLE OF NEW HDF FILE">>
HDF_SD_ATTRSET, SDinterface_id, 'TITLE',title
; create SDS in HDF file
for isds=0,nsds-1 do begin
SDdataset_id =
HDF_SD_CREATE(SDinterface_id,<<SDS_NAME>>,<<SDS_DIMS>>,hdf_type= <<datatypes_idl2hdf[SDS_TYPE]>>)
HDF_SD_ADDDATA,SDdataset_id,<<SDS_DATA>>
HDF_SD_ENDACCESS, SDdataset_id
endfor
;; shut it down
HDF_SD_END, SDinterface_id
You will need, for each SDS:
SDS_NAME
SDS_DIMS = SIZE(SDS,/DIM)
SDS_TYPE = DATATYPES_IDL2HDF[SIZE(SDS,/TYPE)]; see NOTE
SDS_DATA
NOTE: This array converts between the output of SIZE and the data type
codes used by the HDF interface. See the help for more details:
DATATYPES_IDL2HDF=[-1,21,22,24,5,6,-1,-1,-1,-1,-1,-1,23,25,2 6,27]
Hope this helps,
--Edward H.
|
|
|