HDF_SD_ADDDATA error attempting to copy variable from one HDF file to another [message #94699] |
Mon, 28 August 2017 08:35  |
BLesht
Messages: 89 Registered: March 2007
|
Member |
|
|
I have two existing HDF files. I want to copy a variable from one and add it to the other. I thought this would be pretty straightforward, but I'm getting an error "Unable to write the specified HDF-SD slice" from the HDF_SD_ADDDATA step. Here is the relevant part of the code I'm using:
f1id = HDF_OPEN(fullL1A, /READ) ; Open the L1A file read only
sd1id = HDF_SD_START(fullL1A, /READ) ; Open the SD dataset read only
;
f2id = HDF_OPEN(inL2, /WRITE) ; Open the L2 file for writing
sd2id = HDF_SD_START(inL2, /RDWR) ; Open the L2 SD read/write
;
;
indx1 = HDF_SD_NAMETOINDEX(sd1id, 'ntilts') ; Find the L1A ntilts SD
sdvi1 = HDF_SD_SELECT(sd1id, indx1) ; Get the dataset ID
;
HDF_SD_GETDATA, sdvi1, ntilts ; Get the data
HDF_SD_GETINFO, sdvi1, DIMS=dims1, $ ; Get the information for ntilts
NATTS=numAttrs1, $
NAME=name1, $
TYPE=type1, $
/NOREVERSE
; Create the ntilts SD in the L2 file
newL2SD1 = HDF_SD_CREATE(sd2id, 'ntilts', [dims1], /LONG)
; Add the ntilts data to the L2 file
HDF_SD_ADDDATA, newL2SD1, ntilts
HDF_SD_ENDACCESS, newL2SD1 ; Close the L2 ntilts SD
HDF_SD_ENDACCESS, sdvi1 ; Close the L1 ntilts SD
HDF_SD_END, sd1id ; End the SD interface
HDF_CLOSE, f1id ; Close the file
;
HDF_SD_END, sd2id
HDF_CLOSE, f2id ; Close the file
I have checked the values of ntilts, etc. when they are retrieved from the L1A (source) file and they are correct. I also have checked the permissions on the file to which I want to add the data and they are correct.
Perhaps I've missed a step or am approaching this incorrectly. I'd appreciate any ideas about fixing or additional troubleshooting. Thanks.
|
|
|