I am rather new to python programming so please be a big simple with your answer.
I have a .raw file which is 2b/2b complex short int format. Its actually a 2-D raster file. I want to read and seperate both real and complex parts. Lets say the raster is [MxN] size.
Please let me know if question is not clear.
Cheers
N
You could do it with the
structmodule. Here’s a simple example based on the file formatting information you mentioned in a comment:This will return a list of complex-number lists, as can be seen in this output from a trivial test I ran:
Both the real and imaginary parts of complex numbers in Python are usually represented as a pair of machine-level double precision floating point numbers.
You could also use the
arraymodule. Here’s the same thing using it:As you can see, they’re very similar, so it’s not clear there’s a big advantage to using one over the other. I suspect the
arraybased version might be faster, but that would have to be determined by actually timing it with some real data to be able to say with any certainty.