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

Home » Public Forums » archive » Re: NCDF_ATTCOPY and typecasting
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: NCDF_ATTCOPY and typecasting [message #49890 is a reply to message #49794] Fri, 18 August 2006 13:23 Go to previous message
alexzcervantes@gmail. is currently offline  alexzcervantes@gmail.
Messages: 7
Registered: July 2006
Junior Member
Here is a chunk of my code:

if(natts gt 0) then begin
FOR index = 0L, natts - 1L DO BEGIN
;----Load the attribute name in attribute name array
maf_attname = ncdf_attname(mafncid, mafvarid, index)
ncdf_attget, mafncid, mafvarid, maf_attname, attval
ncdf_attput, cdfid, l2pvarid, maf_attname, attval, /byte
ENDFOR
endif

Everything seems to work except when I have to copy over strings. When
I typecast a string to byte, I get output like this:

solar_irradiance:_FillValue = -1b ;
solar_irradiance:scale_factor = 1b ;
solar_irradiance:add_offset = 0b ;
solar_irradiance:valid_min = 0b ;
solar_irradiance:valid_max = 0b ;
solar_irradiance:long_name = 115b, 111b, 108b, 97b, 114b, 32b, 105b,
114b, 114b, 97b, 100b, 105b, 97b, 110b, 99b, 101b ;
solar_irradiance:units = 87b, 32b, 109b, 42b, 42b, 45b, 50b, 32b, 115b
;
solar_irradiance:comment = 102b, 105b, 108b, 108b, 101b, 114b, 32b,
99b, 111b, 109b, 109b, 101b, 110b, 116b ;
solar_irradiance:source = 69b, 117b, 114b, 111b, 112b, 101b, 97b, 110b,
32b, 67b, 101b, 110b, 116b, 101b, 114b, 32b, 102b, 111b, 114b, 32b,
77b, 101b, 100b, 105b, 117b, 109b, 32b, 114b, 97b, 110b, 103b, 101b,
32b, 87b, 101b, 97b, 116b, 104b, 101b, 114b, 32b, 70b, 111b, 114b,
101b, 99b, 97b, 115b, 116b, 105b, 110b, 103b, 58b, 32b, 69b, 67b, 77b,
87b, 70b ;

Thanks,
Alex


Kenneth Bowman wrote:
> In article <1155921996.121510.52270@75g2000cwc.googlegroups.com>,
> "alexzcervantes@gmail.com" <alexzcervantes@gmail.com> wrote:
>
>> Hello All,
>>
>> I am newb to NetCDF and IDL so bear with me :)
>>
>> Here's my situation:
>>
>> I am reading in a data array of type FLOAT, and creating a new NetCDF
>> file and writing the data array to the new file in type BYTE. I can do
>> this fine. However, when I try to do a ncdf_attcopy on the variable
>> attributes from the float array to my new byte array, it fails. I do
>> know that when doing a varput, the datatype of the array and its
>> attributes need to be the same.
>>
>> Does anyone know any way around this where I can maybe do a typecast
>> from float to byte using ncdf_attcopy?
>>
>> Thanks in advance,
>> Alex
>
> I have not used NCDF_ATTCOPY, but I suspect the output file needs to be in
> define mode when copying the attributes. Do you copy the attributes first, then
> exit define mode, then write the byte array?
>
> If you are changing the type of the attribute, you will have to read it with
> NCDF_ATTGET, change the type, then put it with NCDF_ATTPUT.
>
> Ken Bowman
[Message index]
 
Read Message
Read Message
Previous Topic: iplot, /xlog
Next Topic: Re: Algorithm for lat/lon searching

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

Current Time: Wed Oct 08 13:48:59 PDT 2025

Total time taken to generate the page: 0.02985 seconds