[AstroPy] Coding in Python to Read/Write a fits file.
sosey at stsci.edu
Wed Apr 8 10:51:11 EDT 2009
something like this work for me, perhaps it will help
get you closer to what you want. I attached the sample
image I used.
image = Image.open('hs-2009-14-a-web.jpg')
rdata=r.getdata() #data is now an array of length ysize*xsize
Wayne Watson wrote:
> I'm trying to focus on a part of the thread above ("Getting Started
> ...."), so that it isn't lost in that very long thread and is simpler to
> deal with. It appears that, at least, one can use pyfits to read fits
> files, and one can embed this code in a Python program. I posted the
> coding aspects of doing this in a thread above, and finally someone
> responded with code that looks like:
> from matplotlib import pyplot as plt
> import pyfits
> image = pyfits.getdata('mpl51.fits')
> fig = plt.figure()
> ax = fig.add_subplot(111)
> This is close to what I'm looking for. That is, executable Python code,
> and not interactive code one enters line by line. Right now I'm lacking
> a way to read, say, a jpg, fits, or gif file, and convert it to fits.
> I'm also lacking a way to convert the internal image format to fits. The
> latter is very important. The internal format is simple. An image
> 640x480 pixels and 8-bits deep, b/w. jpg, etc. is already done for
> writing the internal file. For fits files, I'd like to write very
> simple headers that have, say, lat/long of observer, a time stamp, and
> some other assorted items.
> Items like plotting, manipulating (IP, for example) and displaying are
> secondary to the need to write a fits file from the internal file.
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
3700 San Martin Drive, Baltimore MD 21218
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 23490 bytes
Desc: not available
More information about the AstroPy