[AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter

Wayne Watson sierra_mtnview at sbcglobal.net
Tue Apr 7 10:15:23 EDT 2009


Well, that got rid of the error, but I see no image. fig was misspelled, 
and I corrected that. Program stopped at raw_input with prompt. Add 
raw_input. I checked the fits image with ccdsoft, and it looks fine.

    from matplotlib import pyplot as plt
    import pyfits

    image = pyfits.getdata('mpl51.fits')

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.imshow(image)
    fig.canvas.draw()
    raw_input("Bye")



Tommy Grav wrote:
> try
>
> from matplotlib import pyplot as plt
>
> fig = plt.figure()
>
>
> On Apr 7, 2009, at 9:35 AM, Wayne Watson wrote:
>
>> Same result.
>>
>>     import matplotlib as mpl
>>     import pyfits
>>
>>     image = pyfits.getdata('mpl51.fits')
>>
>>     fig = mpl.figure()
>>     ax = fix.add_subplot(111)
>>     ax.imshow(image)
>>     fig.canvas.draw()
>>
>> Traceback (most recent call last):
>>   File 
>> "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/sentuser/fun-pyfits.py", 
>> line 6, in <module>
>>     fig = mpl.figure()
>> TypeError: 'module' object is not callable
>>
>> Cohen-Tanugi Johann wrote:
>>> looks like you have a conflict of namespace.
>>> Do
>>> import matplotlib as mpl
>>>
>>> and then
>>> mpl.figure()
>>>
>>> Johann
>>>
>>> Wayne Watson wrote:
>>>> This balked at the fig= line
>>>>
>>>>     ntuser/fun-pyfits.py", line 6, in <module>
>>>>         fig = figure()
>>>>     TypeError: 'module' object is not callable
>>>>
>>>> I'm using image = pyfits.getdata('mpl51.fits'), and that's OK.
>>>>
>>>> Thomas Robitaille wrote:
>>>>> Have you tried matplotlib? For example:
>>>>>
>>>>> from matplotlib import figure
>>>>> import pyfits
>>>>>
>>>>> image = pyfits.getdata('lena.fits')
>>>>>
>>>>> fig = figure()
>>>>> ax = fix.add_subplot(111)
>>>>> ax.imshow(image)
>>>>> fig.canvas.draw()
>>>>>
>>>>> You can use matplotlib to do interactive stuff. If you really want 
>>>>> to use Tkinter to display FITS images, I can send you an example.
>>>>>
>>>>> Best,
>>>>>
>>>>> Thomas
>>>>>
>>>>> On 6 Apr 2009, at 08:32, Wayne Watson wrote:
>>>>>
>>>>>> Hi, it must be than that the version of the pyfits user manual I 
>>>>>> found
>>>>>> is out of date, since it talks about numarray.
>>>>>> I just wanted to confirm that I understood the role of ds9, which 
>>>>>> is as
>>>>>> you essentially wrote, is a program and not a python module.
>>>>>> I just found the numpy manual, Dec. 7, 2006, by Oliphant. Is that 
>>>>>> the
>>>>>> current one? It mentions fits once, and image about 5 times 
>>>>>> (mostly as
>>>>>> what seems to be a module). Here are a few lines from the manual:
>>>>>>
>>>>>>    • nd image –> scipy.ndimage
>>>>>>    • convolve –> scipy.stsci.convolve
>>>>>>    • image –> scipy.stsci.image
>>>>>>    If you don’t want to install all of scipy, you can grab just 
>>>>>> these
>>>>>>    packages from SVN
>>>>>>    using
>>>>>>
>>>>>>
>>>>>> imshow is not found in it. The manual is close to 350 pages. I 
>>>>>> certainly
>>>>>> don't want to print it if it doesn't meet my needs. To put it in 
>>>>>> terms
>>>>>> of Python, consider:
>>>>>>
>>>>>> import Image
>>>>>> im = Image.open("lena.ppm")
>>>>>> print im.format, im.size, im.mode
>>>>>> im.show()
>>>>>>
>>>>>> I'm looking for a capability somewhat like that above for fits, 
>>>>>> and not
>>>>>> ppm. show is pretty primitive, but the the idea is that I want this
>>>>>> little program to display lena.fits.
>>>>>>
>>>>>>
>>>>>> Cohen-Tanugi Johann wrote:
>>>>>>> hi Wayne, I am not sure I understand your request, but :
>>>>>>> 1) numarray is obsolete, use numpy.
>>>>>>> 2) ds9 is meant to display fits image, it has nothing to do with
>>>>>>> internet AFAIK. You also have FV from HEASARC.
>>>>>>> 3) if you need to just visualize a fits image as an array, you have
>>>>>>> several possibilities in numpy : imshow, pcolor, etc.... check the
>>>>>>> user(s guide.
>>>>>>>
>>>>>>> HTH,
>>>>>>> Johann
>>>>>>>
>>>>>>> Wayne Watson wrote:
>>>>>>>> I tried downloading the numarray from the web and Acrobat 
>>>>>>>> burped. It
>>>>>>>> came up with an error. Where is the official site for it?
>>>>>>>>
>>>>>>>> It appears to display a fits image one must either use 
>>>>>>>> numdisplay or
>>>>>>>> some combo of numarray and Python's PIL and a GUI like Tkinter. I
>>>>>>>> really want to use Python in such a manner if it is possible. From
>>>>>>>> what little I know about DS9, it is an internet viewer.
>>>>>>>> -- 
>>>>>>>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>>>>>>>>
>>>>>>>> (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
>>>>>>>>
>>>>>>>> "Less than all cannot satisfy Man." -- William Blake
>>>>>>>> ------------------------------------------------------------------------ 
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> AstroPy mailing list
>>>>>>>> AstroPy at scipy.org
>>>>>>>> http://mail.scipy.org/mailman/listinfo/astropy
>>>>>>>
>>>>>>
>>>>>> -- 
>>>>>>
>>>>>>           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>>>>>>
>>>>>>             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
>>>>>>
>>>>>>          "Less than all cannot satisfy Man." -- William Blake
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> AstroPy mailing list
>>>>>> AstroPy at scipy.org
>>>>>> http://mail.scipy.org/mailman/listinfo/astropy
>>>>>
>>>>>
>>>>
>>>> -- 
>>>>            Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>>>>
>>>>              (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
>>>>
>>>>           "Less than all cannot satisfy Man." -- William Blake
>>>>           
>>>> ------------------------------------------------------------------------ 
>>>>
>>>>
>>>> _______________________________________________
>>>> AstroPy mailing list
>>>> AstroPy at scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/astropy
>>>>   
>>>
>>
>> -- 
>>            Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>>
>>              (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****
>>
>>           "Less than all cannot satisfy Man." -- William Blake
>>           
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org <mailto:AstroPy at scipy.org>
>> http://mail.scipy.org/mailman/listinfo/astropy
>

-- 

           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****

          "Less than all cannot satisfy Man." -- William Blake
          





More information about the AstroPy mailing list