Re: Read binary data [message #61372] |
Wed, 16 July 2008 09:21  |
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   |
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  |
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.
|
|
|