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

Home » Public Forums » archive » Re: Read binary data
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
Re: Read binary data [message #61372] Wed, 16 July 2008 09:21 Go to next message
xiao zhang is currently offline  xiao zhang
Messages: 81
Registered: June 2008
Member
On Jul 16, 11:13 am, Spon <christoph.b...@gmail.com> wrote:
> On Jul 16, 4:50 pm, xiao zhang <littledd...@gmail.com> wrote:
>
>> HI~ every one ~
>> I am trying to read a binary file which is 17920168 bytes and the
>> first 168 bytes of it is header infromation, The rest of it is
>> 800*800*14 two bytes integer. (like a 3 dimention array.) Can any
>> one help me to read it out ? There should not be so many zeros in it,
>> but i tried several times it still shows a lot of zero.
>> Thanks~
>
> OpenR, Lun, MyFile, /Get_Lun
> Point_Lun, Lun, 168
> MyData = Intarr(800, 800, 14, /NoZero)
> ReadU, Lun, MyData
> Free_Lun, Lun
>
> OR:
>
> MyData = Read_Binary(MyFile, Data_Type = 2, Data_Start = 168, $
> Data_Dims = [800, 800, 14])
>
> The advantage of the first method is that it's fast. The advantage of
> the second method is that if you're running into little/big endian
> issues, you can simply set the endian keyword as needed.
>
> Here's a helpful article if you're not sure:http://www.dfanning.com/tips/endian_machines.html
>
> Regards,
>
> Chris

Thank you very much I will try it~
Re: Read binary data [message #61376 is a reply to message #61372] Wed, 16 July 2008 09:13 Go to previous messageGo to next message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Jul 16, 4:50 pm, xiao zhang <littledd...@gmail.com> wrote:
> HI~ every one ~
> I am trying to read a binary file which is 17920168 bytes and the
> first 168 bytes of it is header infromation, The rest of it is
> 800*800*14 two bytes integer. (like a 3 dimention array.) Can any
> one help me to read it out ? There should not be so many zeros in it,
> but i tried several times it still shows a lot of zero.
> Thanks~

OpenR, Lun, MyFile, /Get_Lun
Point_Lun, Lun, 168
MyData = Intarr(800, 800, 14, /NoZero)
ReadU, Lun, MyData
Free_Lun, Lun

OR:

MyData = Read_Binary(MyFile, Data_Type = 2, Data_Start = 168, $
Data_Dims = [800, 800, 14])

The advantage of the first method is that it's fast. The advantage of
the second method is that if you're running into little/big endian
issues, you can simply set the endian keyword as needed.

Here's a helpful article if you're not sure:
http://www.dfanning.com/tips/endian_machines.html

Regards,

Chris
Re: Read binary data [message #61466 is a reply to message #61376] Wed, 16 July 2008 10:15 Go to previous message
mankoff is currently offline  mankoff
Messages: 131
Registered: March 2004
Senior Member
On Jul 16, 12:13 pm, Spon <christoph.b...@gmail.com> wrote:
> On Jul 16, 4:50 pm, xiao zhang <littledd...@gmail.com> wrote:
>
>> HI~ every one ~
>> I am trying to read a binary file which is 17920168 bytes and the
>> first 168 bytes of it  is header infromation, The rest of it is
>> 800*800*14  two bytes integer. (like a 3 dimention array.)  Can any
>> one help me to read it out ? There should not be so many zeros in it,
>> but i tried several times it still shows a lot of zero.
>>                                            Thanks~
>
> OpenR, Lun, MyFile, /Get_Lun
> Point_Lun, Lun, 168
> MyData = Intarr(800, 800, 14, /NoZero)
> ReadU, Lun, MyData
> Free_Lun, Lun
>
> OR:
>
> MyData = Read_Binary(MyFile, Data_Type = 2, Data_Start = 168, $
>   Data_Dims = [800, 800, 14])
>
> The advantage of the first method is that it's fast. The advantage of
> the second method is that if you're running into little/big endian
> issues, you can simply set the endian keyword as needed.
>
> Here's a helpful article if you're not sure:http://www.dfanning.com/tips/endian_machines.html
>
> Regards,
>
> Chris


The first method also lets you set an endian or swap_endian keyword on
the OPEN statement.

-k.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL 7 bookmarks
Next Topic: Save File Surprise

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

Current Time: Wed Oct 08 15:11:29 PDT 2025

Total time taken to generate the page: 0.00629 seconds