[AstroPy] Moving Ahead with Raw Image Conversion

Jim Vickroy Jim.Vickroy at noaa.gov
Tue Apr 14 14:32:31 EDT 2009

Wayne Watson wrote:
> Well, one more question about manipulation.
> rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='uint8')
> was a good device for producing this from a file:
>   array([1, 1, 1, ..., 1, 1, 1], dtype=uint8)
> a numpy array. In my program, I'm getting* the image in a string 307200 
> "characters" long. Is there a device (fromstring?) that would do this in 
> one fell swoop to get a numpy array?
> * as here: img_string=self.current_image.tostring()
Why not check for your self?

 >>> import numpy
 >>> help(numpy.fromstring)
Help on built-in function fromstring in module numpy.core.multiarray:

    fromstring(string, dtype=float, count=-1, sep='')
    Return a new 1d array initialized from raw binary or text data in


-- jv

More information about the AstroPy mailing list