[SciPy-user] dtype

Maik Trömel maik.troemel at maitro.net
Tue Jun 13 07:32:04 EDT 2006


Hello,

thanks for help. Now it works. Is there a posibility to make a byteswap 
while reading in with "fromstring". Or do I have to make it with 
"arrh.byteswap()"?

Greetings
Maik


Robert Kern wrote:

>Maik Trömel wrote:
>  
>
>>Hello list,
>>
>>i've got a question concerning datatypes.
>>I'm importing a file filled with Data with the lenght of 2 bytes via
>>
>>arrh = numpy.fromstring(radFile, dtype = 'S2', count = 900*900)
>>
>>Now I want to convert the data via
>>
>>value = ord(arr[n][m][0]) * 256 + ord(arr[n][m][1])
>>
>>But if the value in the array is NULL i get an Error:
>>
>>IndexError: string index out of range
>>    
>>
>
>(A) In order for us to help you debug some code, you need to distill it down to
>the smallest code that actually displays the error, and then provide us the
>actual code.
>
>(B) In this case, there's a better way. See below.
>
>  
>
>>So I think I have to choose another dtype. But I don't have any idea 
>>which one.
>>Probably someone has an idea.
>>    
>>
>
>arrh = numpy.fromstring(radFile, dtype=numpy.int16, count=900*900)
>
>You don't need to do any other conversions. You may have to pay attention to
>byteswapping depending on the endianness of your platform, though.
>
>  
>




More information about the SciPy-User mailing list