supressing messages [message #16334] |
Wed, 21 July 1999 00:00  |
Mark Rehbein
Messages: 8 Registered: January 1999
|
Junior Member |
|
|
Hi,
I use IDL5.2 on Solaris2.6 Sun machine.
My program uses the HDF file routines including HDF_SD_ATTRFIND.
usage: attribute_index=HDF_SD_ATTRFIND(SDS_ID, 'attribute_name')
if the specified attribute is not found then -1 is returned....fair
enough
If I call the HDF_SD_ATTRFIND and the attribute is not found I get -1
returned but also a message is directed to the screen which says
"%HDF_SD_ATTRFIND: Unable to find the HDF-SD attribute."
I want to suppress this message so that it doesn't appear on my screen.
I've looked through my manuals and the tips at dfanning.com but couldn't
find and reference to this sort of thing.
Any help would be appreciated.
Thanks
mark
mrehbein@aims.gov.au
|
|
|
|
Re: supressing messages [message #16413 is a reply to message #16334] |
Thu, 22 July 1999 00:00  |
Mark Rehbein
Messages: 8 Registered: January 1999
|
Junior Member |
|
|
Liam Gumley wrote:
> Mark Rehbein wrote:
>> I use IDL5.2 on Solaris2.6 Sun machine.
>> My program uses the HDF file routines including HDF_SD_ATTRFIND.
>>
>> usage: attribute_index=HDF_SD_ATTRFIND(SDS_ID, 'attribute_name')
>>
>> if the specified attribute is not found then -1 is returned....fair
>> enough
>>
>> If I call the HDF_SD_ATTRFIND and the attribute is not found I get -1
>> returned but also a message is directed to the screen which says
>>
>> "%HDF_SD_ATTRFIND: Unable to find the HDF-SD attribute."
>>
>> I want to suppress this message so that it doesn't appear on my screen.
>>
>> I've looked through my manuals and the tips at dfanning.com but couldn't
>> find and reference to this sort of thing.
>
> To get around this problem, you should first scan the SDS to see what
> attribute names are available. Let's say you want to get the attribute
> 'scale_factor' if it exists:
>
> ;---cut here---
>
> ;- Get the number of attributes
>
> hdf_sd_getinfo, sds_id, natt=natt
>
> ;- Get the name of each attribute
>
> if natt gt 0 then begin
> att_names = strarr(natt)
> for i = 0, natt - 1 do begin
> hdf_sd_attrinfo, sds_id, i, name=name
> att_names[i] = name
> endfor
> endif
>
> ;- If the requested attribute was found, get it's value
>
> requested_name = 'scale_factor'
> if natt gt 0 then begin
> index = where(att_names eq requested_name, count)
> if count gt 0 then begin
> att_id = hdf_sd_attrfind(sds_id, requested_name)
> hdf_sd_attrinfo, sds_id, att_id, data=requested_value
> endif
> endif
> if n_elements(requested_value) gt 0 then begin
> help, requested_value
> print, requested_value
> endif
>
> ;---cut here---
>
> This method is used in my general purpose HDF SDS reader procedure
> SDS_READ, which is available at
> http://cimss.ssec.wisc.edu/~gumley/sds_read.html
>
> Cheers,
> Liam.
>
> --
> Liam E. Gumley
> Space Science and Engineering Center, UW-Madison
> http://cimss.ssec.wisc.edu/~gumley
Thanks Liam,
I checked out your SDS_READ application. It looks good and will probably use
it for exploring my HDF's.
cheers
mark
|
|
|
Re: supressing messages [message #16414 is a reply to message #16334] |
Thu, 22 July 1999 00:00  |
Mark Rehbein
Messages: 8 Registered: January 1999
|
Junior Member |
|
|
David Fanning wrote:
> Mark Rehbein (mrehbein@aims.gov.au) writes:
>
>> If I call the HDF_SD_ATTRFIND and the attribute is not found I get -1
>> returned but also a message is directed to the screen which says
>>
>> "%HDF_SD_ATTRFIND: Unable to find the HDF-SD attribute."
>>
>> I want to suppress this message so that it doesn't appear on my screen.
>
> You could try setting !Quiet=0 just before the call. (Be sure
> to set it back again when you are done with the call, or IDL
> will seem awfully quiet.) I'm going to guess this won't work
> and that you won't have much control over this, but it's worth
> a try.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Thanks David,
Your idea did work, however !quiet=1 needs to be set before the call (not
!quiet=0).
cheers
mark
|
|
|
Re: supressing messages [message #16421 is a reply to message #16334] |
Wed, 21 July 1999 00:00  |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
Mark Rehbein wrote:
> I use IDL5.2 on Solaris2.6 Sun machine.
> My program uses the HDF file routines including HDF_SD_ATTRFIND.
>
> usage: attribute_index=HDF_SD_ATTRFIND(SDS_ID, 'attribute_name')
>
> if the specified attribute is not found then -1 is returned....fair
> enough
>
> If I call the HDF_SD_ATTRFIND and the attribute is not found I get -1
> returned but also a message is directed to the screen which says
>
> "%HDF_SD_ATTRFIND: Unable to find the HDF-SD attribute."
>
> I want to suppress this message so that it doesn't appear on my screen.
>
> I've looked through my manuals and the tips at dfanning.com but couldn't
> find and reference to this sort of thing.
To get around this problem, you should first scan the SDS to see what
attribute names are available. Let's say you want to get the attribute
'scale_factor' if it exists:
;---cut here---
;- Get the number of attributes
hdf_sd_getinfo, sds_id, natt=natt
;- Get the name of each attribute
if natt gt 0 then begin
att_names = strarr(natt)
for i = 0, natt - 1 do begin
hdf_sd_attrinfo, sds_id, i, name=name
att_names[i] = name
endfor
endif
;- If the requested attribute was found, get it's value
requested_name = 'scale_factor'
if natt gt 0 then begin
index = where(att_names eq requested_name, count)
if count gt 0 then begin
att_id = hdf_sd_attrfind(sds_id, requested_name)
hdf_sd_attrinfo, sds_id, att_id, data=requested_value
endif
endif
if n_elements(requested_value) gt 0 then begin
help, requested_value
print, requested_value
endif
;---cut here---
This method is used in my general purpose HDF SDS reader procedure
SDS_READ, which is available at
http://cimss.ssec.wisc.edu/~gumley/sds_read.html
Cheers,
Liam.
--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
|
|
|