comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » HDF_SD_ADDDATA error attempting to copy variable from one HDF file to another
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
HDF_SD_ADDDATA error attempting to copy variable from one HDF file to another [message #94699] Mon, 28 August 2017 08:35 Go to next message
BLesht is currently offline  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.
Re: HDF_SD_ADDDATA error attempting to copy variable from one HDF file to another [message #94700 is a reply to message #94699] Mon, 28 August 2017 11:43 Go to previous message
BLesht is currently offline  BLesht
Messages: 89
Registered: March 2007
Member
I'm a bit surprised by how few questions/answers there have been in this forum related to HDF file processing. That being said, the problem I asked about below turns out not to be a problem at all - a simple case of programmer error. I was identified the wrong HDF file for modification and the explanation of the error was basically that the file I wanted to write although existing (so it didn't trigger an error when I tried to open it) wasn't the one I could write to.


On Monday, August 28, 2017 at 10:35:42 AM UTC-5, Barry Lesht wrote:
> 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.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL Python Bridge
Next Topic: bug with min/max and non-finite values

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 05:15:01 PDT 2025

Total time taken to generate the page: 0.00520 seconds