From sierra_mtnview at sbcglobal.net Wed Apr 1 08:00:02 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 01 Apr 2009 05:00:02 -0700 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> Message-ID: <49D35742.7050902@sbcglobal.net> An HTML attachment was scrubbed... URL: From mxhf at gmx.net Wed Apr 1 08:07:29 2009 From: mxhf at gmx.net (Maximilian Fabricius) Date: Wed, 1 Apr 2009 14:07:29 +0200 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> Message-ID: <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> yes, well Fits has science! data...so yes its a matrix :) I guess I would use pyfits to read the data matrix from the fits file and then use the imshow command from matplotlib to present it to the user. import pyfits import matplotlib as pylab hdulist = pyfits.open("YOURFITSFILE.FITS") data = hdulist[0].data # I assume its in the first extension pylab.imshow(data) pylab.show() (sorry, I did not have time to test this....) Hope that helps... Maximilian On Wed, Apr 1, 2009 at 2:05 PM, Maximilian Fabricius wrote: > Wayne, > > yes, well Fits has science! data...so yes its a matrix :) > > I guess I would use pyfits to read the data matrix from the fits file > and then use > the imshow command from matplotlib to present it to the user. > > import pyfits > import matplotlib as pylab > > hdulist = pyfits.open("YOURFITSFILE.FITS") > data = hdulist[0].data # I assume its in the first extension > > pylab.imshow(data) > pylab.show() > > (sorry, I did not have time to test this....) > > Hope that helps... > > Maximilian > > On Wed, Apr 1, 2009 at 2:00 PM, Wayne Watson > wrote: >> (I see that somehow I got off posting to the group, and sent the original of >> this thread to you. That's probably caused by the need to use Reply to All, >> which seems necessary for Python mail lists. I'm working without my contacts >> this morning, so I'm not real agile reading things. It'll be another 6 hours >> until I insert them again.) >> >> The image buried in the fits file. Isn't that part of the data section. I >> think that's what it's called. The manual seems to suggest that it's in some >> sort of matrix form. In any case, I want to display the image using PIL. It >> seems like there ought to be a way to construct a bit map image that can be >> displayed via Python's PIL. Maybe pyfits has a way.? For example in Tkinter, >> >> import Tkinter as tk >> import Image >> import ImageTk >> import ImageDraw >> import sys >> >> im = Image.open("wagon.tif") >> >> draw = ImageDraw.Draw(im) >> draw.line((0, 0) + im.size, fill=128) >> draw.line((0,0)+(20,140), fill=128) >> >> draw = ImageDraw.Draw(im) >> draw.line((0, 0) + im.size, fill=128) >> draw.line(((0,0)+(20,140)), fill=128) >> >> root = tk.Tk() >> pi = ImageTk.PhotoImage(im) >> label = tk.Label(root, image=pi) >> label.pack() >> root.mainloop() >> >> >> >> Maximilian Fabricius wrote: >> >> Wayne, >> >> I do not understand, I am sorry! What image do you mean? Is that part >> of any library that you were trying to get to run? >> >> Maximilian >> >> On Wed, Apr 1, 2009 at 12:23 AM, Wayne Watson >> wrote: >> >> >> Installation was easy. Odd though that the manual uses input.fits as an >> example but doesn't include it in the file I untarred. I see no suggestions >> on how to display the image. I guess they assume the user is going to use >> PIL. That leads me to ask what format is the image? I used pyfits to find >> the dimensions, but would expect PIL to need to know the format of the >> image. bmp? >> >> Maximilian Fabricius wrote: >> >> Hmmm you are a metor hunter then? :) >> >> Sorry, I never had to deploy my programs. I know it is a bit a pain >> to install all libraries .... >> >> But still, to install python libraries is not too difficult. >> >> Feel encouraged! I never had such a fast start with any other >> programming or scripting language. >> (I tried many ...) >> >> The only thing you need to become - maybe - familiar with is the >> handeling of arrays and the >> differences of arrays and lists. If you have done IDL before, this >> will be a piece of cake for >> you. If not...don't worry...its easy! >> >> Cheers and good luck! >> >> Maximilian >> >> On Mon, Mar 30, 2009 at 12:09 PM, Wayne Watson >> wrote: >> >> >> Thanks very much, This sounds encouraging. I guess my other worry is about >> distributing the application I'm working on. It has to do with video meteor >> observations. The users are very unfamiliar with Python, but the original >> authors of the program have made it fairly simple for the users to install. >> The include a couple of (self?) installable library files, like PIL, that >> are pretty easy for people to install. For example, >> matplotlib-0.98.1.win32-py2.5.exe. I hope this will be the case here. I'm >> pretty new to Python, and am making mods to the program, which I did not >> write. I am making progress, sometimes a bit slowly. >> >> Here's what we now use (Python 2.5): >> from Tkinter import * >> from numpy import * >> import Image >> import ImageChops >> import ImageTk >> import ImageDraw # wtw >> import time >> import string >> import binascii >> import tkMessageBox >> import tkSimpleDialog >> from pylab import plot, xlabel, ylabel, title, show, xticks, bar >> >> from tkFileDialog import asksaveasfilename, asksaveasfile >> from tkFileDialog import askopenfilename >> >> import MakeQTE >> >> import socket >> import struct >> import glob >> import bisect >> import os, os.path >> import datetime >> >> from os.path import basename, splitext >> >> Maximilian Fabricius wrote: >> >> Wayne, >> >> I have been using pyfits from STSci for about a year and a half now. >> Since then, I have made extensive use of it. I must admit that I use it >> on Linux and MaxOSX and not on Windows. Tho' on those two >> platforms it runs so smoothly and I had such a good time with it >> ?that I strongly recommend using it even >> for the most simple things that you are doing - because quite frankly - >> I would not know anything simpler than that (tried FITSIO, Java, >> IRAF+Pyraf, MIDAS+pymidas, >> IDL, LTL, ...). >> >> You do not need to dig though the whole Pyfits documentation. They have a >> very nice summary at the beginning of their document, I never read >> anything else. It >> should get you to where you want to be in 10min... >> >> I also recommend to use pyfits together with scipy. These two are really all >> you need to do sophisticated data reduction. >> >> Writing a fits file is as simple as this: >> >> import pyfits >> from scipy import * >> data = zeros([1000,1000]) >> hdu = pyfits.PrimaryHDU(data) >> hdu.writeto("youfile.fits") >> >> >> Maximilian >> >> 2009/3/30 Wayne Watson : >> >> >> I've downloaded the tar for fits from the STSci page, and untarred it. I'm >> using Win XP. Is this download applicable to Win? The STSci has a lot of >> tutorial material. Is this necessary to just using Python to write a modest >> fits file? I want to put lat/long, time, and maybe a few other parameters in >> the header, but that's about it. Of course, I want to include an image. >> >> A few months I bookmarked a web site from the U of Wash about fits and maybe >> python. It seems to be gone. Anyone know about i?. It looked like it belong >> to someone by the last name of Owens. >> -- >> >> ? ? ? ? ? ?Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> ? ? ? ? ? ? ?(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) >> >> >> ? ? ? ? ? ? ? ? ?Life is one damn thing after another." >> ? ? ? ? ? ? ? ? ? ? ?-- Mark Twain >> >> _______________________________________________ >> 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) >> >> >> ? ? ? ? ? ? ? ? ?Life is one damn thing after another." >> ? ? ? ? ? ? ? ? ? ? ?-- Mark Twain >> >> >> >> >> >> -- >> >> ? ? ? ? ? ?Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> ? ? ? ? ? ? ?(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) >> >> >> ? ? ? ? ? The Obama Administration plans to double the production >> ? ? ? ? ? in solar energy from 1% to 2% of the total energy >> ? ? ? ? ? supply in the next few years. One nuclear reaction >> ? ? ? ? ? would do the same. Heard on Bill Wattenburg, KGO-AM >> >> ? ? ? ? ? "Less than all cannot satisfy Man." -- William Blake >> >> >> >> >> >> >> -- >> >> ? ? ? ? ? ?Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> ? ? ? ? ? ? ?(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) >> >> >> ? ? ? ? ? The Obama Administration plans to double the production >> ? ? ? ? ? in solar energy from 1% to 2% of the total energy >> ? ? ? ? ? supply in the next few years. One nuclear reaction >> ? ? ? ? ? would do the same. Heard on Bill Wattenburg, KGO-AM >> >> ? ? ? ? ? "Less than all cannot satisfy Man." -- William Blake >> >> > > > > -- > -------------------------------------------------------------------- > ?Maximilian Fabricius > ?* Max Planck Institute for Extraterrestrial Physics (MPE) > ? ? Giessenbachstrasse, D-85748 Garching, Germany > ?* University Observatory Munich / ? Wendelstein Observatory > ? ? Scheinerstr. 1, D-81679 M?nchen, Germany > ?eMail: ?mxhf at mpe.mpg.de > ?Phone: ?+49 89 30000 3694 > ?FAX: ? ?+49 89 30000 3495 > ?-------------------------------------------------------------------- > -- -------------------------------------------------------------------- Maximilian Fabricius * Max Planck Institute for Extraterrestrial Physics (MPE) Giessenbachstrasse, D-85748 Garching, Germany * University Observatory Munich / Wendelstein Observatory Scheinerstr. 1, D-81679 M?nchen, Germany eMail: mxhf at mpe.mpg.de Phone: +49 89 30000 3694 FAX: +49 89 30000 3495 -------------------------------------------------------------------- From chanley at stsci.edu Wed Apr 1 08:11:42 2009 From: chanley at stsci.edu (Christopher Hanley) Date: Wed, 01 Apr 2009 08:11:42 -0400 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> Message-ID: <49D359FE.8040104@stsci.edu> Another easy way to display a data section from a FITS file is to use numdisplay and DS9. http://stsdas.stsci.edu/numdisplay/ Numdisplay will work with and ndarray from numpy. It is a one line command after the import > import numdisplay > numdisplay.display(yourArrayObject) Cheers, Chris -- Christopher Hanley Senior Systems Software Engineer Space Telescope Science Institute 3700 San Martin Drive Baltimore MD, 21218 (410) 338-4338 From sierra_mtnview at sbcglobal.net Wed Apr 1 08:28:44 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 01 Apr 2009 05:28:44 -0700 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <49D359FE.8040104@stsci.edu> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> Message-ID: <49D35DFC.1090101@sbcglobal.net> An HTML attachment was scrubbed... URL: From mxhf at gmx.net Wed Apr 1 08:38:31 2009 From: mxhf at gmx.net (Maximilian Fabricius) Date: Wed, 1 Apr 2009 14:38:31 +0200 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <49D35DFC.1090101@sbcglobal.net> References: <49D04614.60308@sbcglobal.net> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> <49D35DFC.1090101@sbcglobal.net> Message-ID: <88b277e60904010538s791016d8jd4d961086a49e617@mail.gmail.com> No, pyfits is only for the IO. No graphics. I am sure that you will be able to read a bmp file into some array and then to store it using pyfits (BTW 24Bits!?). I have never done that, though. Neat, can Numdisplay also access the xpa interface? 2009/4/1 Wayne Watson : > Ultimately, I must display it in Python. If numdisplay is it, then that'll > likely do. I would have thought pyfits would have a display method. > > At some point, I will want to convert a raw image, 640x480, of some bit > depth (8, 16, 24) to a fits format. I might need to convert jpb images to > fits too. Comments? > > Christopher Hanley wrote: > > Another easy way to display a data section from a FITS file is to use > numdisplay and DS9. > > http://stsdas.stsci.edu/numdisplay/ > > Numdisplay will work with and ndarray from numpy.? It is a one line command > after the import > >> import numdisplay >> numdisplay.display(yourArrayObject) > > Cheers, > Chris > > > > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) > > > The Obama Administration plans to double the production > in solar energy from 1% to 2% of the total energy > supply in the next few years. One nuclear reaction > would do the same. Heard on Bill Wattenburg, KGO-AM > > "Less than all cannot satisfy Man." -- William Blake > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -- -------------------------------------------------------------------- Maximilian Fabricius * Max Planck Institute for Extraterrestrial Physics (MPE) Giessenbachstrasse, D-85748 Garching, Germany * University Observatory Munich / Wendelstein Observatory Scheinerstr. 1, D-81679 M?nchen, Germany eMail: mxhf at mpe.mpg.de Phone: +49 89 30000 3694 FAX: +49 89 30000 3495 -------------------------------------------------------------------- From cohen at lpta.in2p3.fr Wed Apr 1 08:42:51 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Wed, 01 Apr 2009 14:42:51 +0200 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <49D359FE.8040104@stsci.edu> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> Message-ID: <49D3614B.3060008@lpta.in2p3.fr> I might be wrong, but I think that numdisplay is not maintained anymore, you may want to check before depending on it. Problem with matplotlib is the lack of astrophysical coordinate support, so that images will be displayed in pixel coordinates. Johann Christopher Hanley wrote: > Another easy way to display a data section from a FITS file is to use > numdisplay and DS9. > > http://stsdas.stsci.edu/numdisplay/ > > Numdisplay will work with and ndarray from numpy. It is a one line > command after the import > > > import numdisplay > > numdisplay.display(yourArrayObject) > > Cheers, > Chris > > > From stefan.schwarzburg at googlemail.com Wed Apr 1 08:48:42 2009 From: stefan.schwarzburg at googlemail.com (Stefan Schwarzburg) Date: Wed, 1 Apr 2009 14:48:42 +0200 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <88b277e60904010538s791016d8jd4d961086a49e617@mail.gmail.com> References: <49D04614.60308@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> <49D35DFC.1090101@sbcglobal.net> <88b277e60904010538s791016d8jd4d961086a49e617@mail.gmail.com> Message-ID: On Wed, Apr 1, 2009 at 14:38, Maximilian Fabricius wrote: > No, pyfits is only for the IO. No graphics. > > I am sure that you will be able to read a bmp file into > some array and then to store it using pyfits (BTW 24Bits!?). > I have never done that, though. > > Neat, can Numdisplay also access the xpa interface? > Just a few remarks: there is also pysao with a simpler to use interface: http://code.google.com/p/python-sao/ Quote: >>> import pysao # run new instance of ds9 >>> ds9 = pysao.ds9() >>> import numpy >>> im = numpy.reshape(numpy.arange(100), (10, 10)) # display 2-d array >>> ds9.view(im) >>> import pyfits >>> f = pyfits.open('test.fits') # display first extension of fits file >>> ds9.view(f[0]) # access with XPA method. >>> ds9.set('file test.fits') >>> ds9.get('file') # list available xpa commands >>> ds9.xpa_help() # help on the specific xpa command >>> ds9.xpa_help("tile") But if you prefer matplotlib, you should take a look at the kapteyn package: http://www.astro.rug.nl/software/kapteyn/ it's the only matplotlib package i know of, that can display correct wcs information. Cheers, Stefan > > > 2009/4/1 Wayne Watson : > > Ultimately, I must display it in Python. If numdisplay is it, then > that'll > > likely do. I would have thought pyfits would have a display method. > > > > At some point, I will want to convert a raw image, 640x480, of some bit > > depth (8, 16, 24) to a fits format. I might need to convert jpb images to > > fits too. Comments? > > > > Christopher Hanley wrote: > > > > Another easy way to display a data section from a FITS file is to use > > numdisplay and DS9. > > > > http://stsdas.stsci.edu/numdisplay/ > > > > Numdisplay will work with and ndarray from numpy. It is a one line > command > > after the import > > > >> import numdisplay > >> numdisplay.display(yourArrayObject) > > > > Cheers, > > Chris > > > > > > > > -- > > > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) > > > > > > The Obama Administration plans to double the production > > in solar energy from 1% to 2% of the total energy > > supply in the next few years. One nuclear reaction > > would do the same. Heard on Bill Wattenburg, KGO-AM > > > > "Less than all cannot satisfy Man." -- William Blake > > > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org > > http://mail.scipy.org/mailman/listinfo/astropy > > > > > > > > -- > -------------------------------------------------------------------- > Maximilian Fabricius > * Max Planck Institute for Extraterrestrial Physics (MPE) > Giessenbachstrasse, D-85748 Garching, Germany > * University Observatory Munich / Wendelstein Observatory > Scheinerstr. 1, D-81679 M?nchen, Germany > eMail: mxhf at mpe.mpg.de > Phone: +49 89 30000 3694 > FAX: +49 89 30000 3495 > -------------------------------------------------------------------- > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cohen at lpta.in2p3.fr Wed Apr 1 08:55:39 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Wed, 01 Apr 2009 14:55:39 +0200 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: References: <49D04614.60308@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> <49D35DFC.1090101@sbcglobal.net> <88b277e60904010538s791016d8jd4d961086a49e617@mail.gmail.com> Message-ID: <49D3644B.8060004@lpta.in2p3.fr> nice! I just installed it. Just got a few warnings: running build_ext building 'xpa' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fPIC -I/data1/sources/heasoft-6.5/i686-pc-linux-gnu-libc2.7/include/ -I/usr/include/python2.5 -c xpa.c -o build/temp.linux-i686-2.5/xpa.o xpa.c: In function ?__pyx_f_3xpa_nslookup?: xpa.c:158: warning: label ?__pyx_L3? defined but not used xpa.c:156: warning: label ?__pyx_L2? defined but not used xpa.c:100: warning: unused variable ?__pyx_v_iter? xpa.c: In function ?__pyx_f_3xpa__get?: xpa.c:204: warning: unused variable ?__pyx_v_i? xpa.c: In function ?__pyx_f_3xpa_3xpa___del__?: xpa.c:530: warning: label ?__pyx_L1? defined but not used xpa.c: In function ?__pyx_tp_new_3xpa_xpa?: xpa.c:626: warning: unused variable ?p? xpa.c: In function ?__pyx_tp_dealloc_3xpa_xpa?: xpa.c:631: warning: unused variable ?p? xpa.c: In function ?__pyx_tp_traverse_3xpa_xpa?: xpa.c:637: warning: unused variable ?p? xpa.c:636: warning: unused variable ?e? xpa.c: In function ?__pyx_tp_clear_3xpa_xpa?: xpa.c:642: warning: unused variable ?p? xpa.c: At top level: xpa.c:15: warning: ?__Pyx_UnpackItem? declared ?static? but never defined xpa.c:16: warning: ?__Pyx_EndUnpack? declared ?static? but never defined xpa.c:17: warning: ?__Pyx_PrintItem? declared ?static? but never defined xpa.c:18: warning: ?__Pyx_PrintNewline? declared ?static? but never defined xpa.c:20: warning: ?__Pyx_ReRaise? declared ?static? but never defined xpa.c:21: warning: ?__Pyx_Import? declared ?static? but never defined xpa.c:22: warning: ?__Pyx_GetExcValue? declared ?static? but never defined xpa.c:23: warning: ?__Pyx_ArgTypeTest? declared ?static? but never defined xpa.c:24: warning: ?__Pyx_TypeTest? declared ?static? but never defined xpa.c:25: warning: ?__Pyx_GetStarArgs? declared ?static? but never defined xpa.c:26: warning: ?__Pyx_WriteUnraisable? declared ?static? but never defined xpa.c:28: warning: ?__Pyx_ImportType? declared ?static? but never defined xpa.c:29: warning: ?__Pyx_SetVtable? declared ?static? but never defined xpa.c:30: warning: ?__Pyx_GetVtable? declared ?static? but never defined xpa.c:31: warning: ?__Pyx_CreateClass? declared ?static? but never defined xpa.c:34: warning: ?__Pyx_GetName? declared ?static? but never defined gcc -pthread -shared build/temp.linux-i686-2.5/xpa.o -L/data1/sources/heasoft-6.5/i686-pc-linux-gnu-libc2.7/lib -L/usr/lib -lxpa -lpython2.5 -o build/lib.linux-i686-2.5/xpa.so Stefan Schwarzburg wrote: > > > > On Wed, Apr 1, 2009 at 14:38, Maximilian Fabricius > wrote: > > No, pyfits is only for the IO. No graphics. > > I am sure that you will be able to read a bmp file into > some array and then to store it using pyfits (BTW 24Bits!?). > I have never done that, though. > > Neat, can Numdisplay also access the xpa interface? > > > Just a few remarks: > there is also pysao with a simpler to use interface: > http://code.google.com/p/python-sao/ > Quote: > >>> import pysao > > # run new instance of ds9 > >>> ds9 = pysao.ds9() > > > >>> import numpy > >>> im = numpy.reshape(numpy.arange(100), (10, 10)) > > # display 2-d array > >>> ds9.view(im) > > > > > >>> import pyfits > >>> f = pyfits.open('test.fits') > > # display first extension of fits file > >>> ds9.view(f[0]) > > > # access with XPA method. > >>> ds9.set('file test.fits') > > >>> ds9.get('file') > > > # list available xpa commands > >>> ds9.xpa_help() > > > # help on the specific xpa command > >>> ds9.xpa_help("tile") > > > But if you prefer matplotlib, you should take a look at the kapteyn > package: > http://www.astro.rug.nl/software/kapteyn/ > it's the only matplotlib package i know of, that can display correct > wcs information. > > Cheers, > Stefan > > > > > > > 2009/4/1 Wayne Watson >: > > Ultimately, I must display it in Python. If numdisplay is it, > then that'll > > likely do. I would have thought pyfits would have a display method. > > > > At some point, I will want to convert a raw image, 640x480, of > some bit > > depth (8, 16, 24) to a fits format. I might need to convert jpb > images to > > fits too. Comments? > > > > Christopher Hanley wrote: > > > > Another easy way to display a data section from a FITS file is > to use > > numdisplay and DS9. > > > > http://stsdas.stsci.edu/numdisplay/ > > > > Numdisplay will work with and ndarray from numpy. It is a one > line command > > after the import > > > >> import numdisplay > >> numdisplay.display(yourArrayObject) > > > > Cheers, > > Chris > > > > > > > > -- > > > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) > > > > > > The Obama Administration plans to double the production > > in solar energy from 1% to 2% of the total energy > > supply in the next few years. One nuclear reaction > > would do the same. Heard on Bill Wattenburg, KGO-AM > > > > "Less than all cannot satisfy Man." -- William Blake > > > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org > > http://mail.scipy.org/mailman/listinfo/astropy > > > > > > > > -- > -------------------------------------------------------------------- > Maximilian Fabricius > * Max Planck Institute for Extraterrestrial Physics (MPE) > Giessenbachstrasse, D-85748 Garching, Germany > * University Observatory Munich / Wendelstein Observatory > Scheinerstr. 1, D-81679 M?nchen, Germany > eMail: mxhf at mpe.mpg.de > Phone: +49 89 30000 3694 > FAX: +49 89 30000 3495 > -------------------------------------------------------------------- > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > > ------------------------------------------------------------------------ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From chanley at stsci.edu Wed Apr 1 09:06:09 2009 From: chanley at stsci.edu (Christopher Hanley) Date: Wed, 1 Apr 2009 09:06:09 -0400 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <49D3614B.3060008@lpta.in2p3.fr> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> <49D3614B.3060008@lpta.in2p3.fr> Message-ID: <03B148E4-F740-4F8C-A7CF-A3715D9E2929@stsci.edu> Numdisplay is still maintained here at STScI. It is released as part of out STSCI_PYTHON package. Cheers, Chris On Apr 1, 2009, at 8:42 AM, Cohen-Tanugi Johann wrote: > I might be wrong, but I think that numdisplay is not maintained > anymore, you may want to check before depending on it. Problem with > matplotlib is the lack of astrophysical coordinate support, so that > images will be displayed in pixel coordinates. > > Johann > > Christopher Hanley wrote: >> Another easy way to display a data section from a FITS file is to >> use numdisplay and DS9. >> >> http://stsdas.stsci.edu/numdisplay/ >> >> Numdisplay will work with and ndarray from numpy. It is a one line >> command after the import >> >> > import numdisplay >> > numdisplay.display(yourArrayObject) >> >> Cheers, >> Chris >> >> >> From cohen at lpta.in2p3.fr Wed Apr 1 09:12:21 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Wed, 01 Apr 2009 15:12:21 +0200 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <03B148E4-F740-4F8C-A7CF-A3715D9E2929@stsci.edu> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> <49D3614B.3060008@lpta.in2p3.fr> <03B148E4-F740-4F8C-A7CF-A3715D9E2929@stsci.edu> Message-ID: <49D36835.8020600@lpta.in2p3.fr> ok I stand corrected.... I was taking the fact that the last release was more than a year old as a sign. Sorry! J Christopher Hanley wrote: > Numdisplay is still maintained here at STScI. It is released as part > of out STSCI_PYTHON package. > > Cheers, > Chris > > On Apr 1, 2009, at 8:42 AM, Cohen-Tanugi Johann > wrote: > >> I might be wrong, but I think that numdisplay is not maintained >> anymore, you may want to check before depending on it. Problem with >> matplotlib is the lack of astrophysical coordinate support, so that >> images will be displayed in pixel coordinates. >> >> Johann >> >> Christopher Hanley wrote: >>> Another easy way to display a data section from a FITS file is to >>> use numdisplay and DS9. >>> >>> http://stsdas.stsci.edu/numdisplay/ >>> >>> Numdisplay will work with and ndarray from numpy. It is a one line >>> command after the import >>> >>> > import numdisplay >>> > numdisplay.display(yourArrayObject) >>> >>> Cheers, >>> Chris >>> >>> >>> From erwin at mpe.mpg.de Wed Apr 1 09:29:55 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Wed, 1 Apr 2009 15:29:55 +0200 Subject: [AstroPy] Getting Started with Python and FITS In-Reply-To: <49D35DFC.1090101@sbcglobal.net> References: <49D04614.60308@sbcglobal.net> <88b277e60903300039s30255dbfj73b72ba01d44928a@mail.gmail.com> <49D0A84F.4030000@sbcglobal.net> <88b277e60903301412j30b9c399yd5e5cafdf9b28a89@mail.gmail.com> <49D297E8.4090003@sbcglobal.net> <88b277e60904010035u708947a5w3fcf20983619974c@mail.gmail.com> <49D35742.7050902@sbcglobal.net> <88b277e60904010505l6062ab23w26e648115e0beb41@mail.gmail.com> <88b277e60904010507p23b19333xa1f4bca15944979a@mail.gmail.com> <49D359FE.8040104@stsci.edu> <49D35DFC.1090101@sbcglobal.net> Message-ID: <7C13EE96-ACE8-49D5-B30A-DD42A41CC368@mpe.mpg.de> On Apr 1, 2009, at 2:28 PM, Wayne Watson wrote: > Ultimately, I must display it in Python. If numdisplay is it, then > that'll likely do. I would have thought pyfits would have a display > method. > > At some point, I will want to convert a raw image, 640x480, of some > bit depth (8, 16, 24) to a fits format. I might need to convert jpb > images to fits too. Comments? Keep in mind that FITS images are (almost always, if not always) grayscale: each pixel has a single value, though the possible values can be integers (usually 16-bit or 32-bit) or floating-point. This is different from, e.g., a standard 24-bit color image, where each pixel has three values (one for red, one for green, and one for blue), and each value is an 8-bit integer. If your "raw images" are *color* ("24 bits" sounds like a color image, and JPEG images are usually 24-bit color images), then you'll have to figure out some way of separating them into their individual red, green, and blue components. Each separate component could then be saved as a separate FITS file (or, getting more complicated, a single FITS file with three data extensions). Apologies if you knew this already, but it wasn't clear from your post. cheers, Peter ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From sierra_mtnview at sbcglobal.net Mon Apr 6 01:02:12 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 05 Apr 2009 22:02:12 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter Message-ID: <49D98CD4.3090508@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Mon Apr 6 08:32:29 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Mon, 06 Apr 2009 05:32:29 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49D9BC1C.4040805@lpta.in2p3.fr> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> Message-ID: <49D9F65D.9010804@sbcglobal.net> 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 From thomas.robitaille at gmail.com Mon Apr 6 09:26:11 2009 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Mon, 6 Apr 2009 09:26:11 -0400 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49D9F65D.9010804@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> Message-ID: 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 From hodge at stsci.edu Mon Apr 6 09:53:22 2009 From: hodge at stsci.edu (Phil Hodge) Date: Mon, 06 Apr 2009 09:53:22 -0400 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49D9F65D.9010804@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> Message-ID: <49DA0952.8070709@stsci.edu> > 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. ds9 is anything but primitive, and I would recommend that you try it regardless of whatever else you use. You can use matplotlib to display a FITS image within a Python program, but you can also use numdisplay to display with ds9. Many people just use the "File" menu in ds9 and give the name of the FITS file. Phil From sierra_mtnview at sbcglobal.net Mon Apr 6 10:44:00 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Mon, 06 Apr 2009 07:44:00 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> Message-ID: <49DA1530.1060502@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Mon Apr 6 10:50:28 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Mon, 06 Apr 2009 07:50:28 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DA0952.8070709@stsci.edu> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DA0952.8070709@stsci.edu> Message-ID: <49DA16B4.6080002@sbcglobal.net> Here's a better example of what I'm after (it uses a tif file, but fits is what I want or expect to use). # fun and games import Image, ImageDraw im = Image.open("wagon.tif") draw = ImageDraw.Draw(im) draw.line((0, 0) + im.size, fill=128) draw.line((0,0),(20,140), fill=128) root.mainloop() "_show_ [in the example] is pretty primitive...", in Tkinter/PIL. The question is whether ds9 is a module that can be used within a Python program? I really do not know, but indications are that it is not. Phil Hodge wrote: >> 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. > > > ds9 is anything but primitive, and I would recommend that you try it > regardless of whatever else you use. You can use matplotlib to > display a FITS image within a Python program, but you can also use > numdisplay to display with ds9. Many people just use the "File" menu > in ds9 and give the name of the FITS file. > > Phil > -- 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 From hodge at stsci.edu Mon Apr 6 11:08:19 2009 From: hodge at stsci.edu (Phil Hodge) Date: Mon, 06 Apr 2009 11:08:19 -0400 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DA16B4.6080002@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DA0952.8070709@stsci.edu> <49DA16B4.6080002@sbcglobal.net> Message-ID: <49DA1AE3.5080902@stsci.edu> > The question is whether ds9 is a module that can be used within a Python > program? I really do not know, but indications are that it is not. ds9 is not a Python module, it's a stand-alone program that you run from Unix. However, there is an interface for displaying images to it, and the Python module numdisplay uses that interface. The advantage of ds9 is that it is so powerful. imshow in matplotlib is pretty good, though, and you may want to use matplotlib anyway for plotting. Phil From cohen at lpta.in2p3.fr Mon Apr 6 14:46:45 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Mon, 06 Apr 2009 20:46:45 +0200 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DA1AE3.5080902@stsci.edu> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DA0952.8070709@stsci.edu> <49DA16B4.6080002@sbcglobal.net> <49DA1AE3.5080902@stsci.edu> Message-ID: <49DA4E15.4080109@lpta.in2p3.fr> the main thing missing when using matplotlib is the correct use of astronomical coordinate information, and that is a pretty big plus of ds9. J Phil Hodge wrote: >> The question is whether ds9 is a module that can be used within a Python >> program? I really do not know, but indications are that it is not. >> > > > ds9 is not a Python module, it's a stand-alone program that you run from > Unix. However, there is an interface for displaying images to it, and > the Python module numdisplay uses that interface. The advantage of ds9 > is that it is so powerful. imshow in matplotlib is pretty good, though, > and you may want to use matplotlib anyway for plotting. > > Phil > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From stefan.schwarzburg at googlemail.com Tue Apr 7 02:52:55 2009 From: stefan.schwarzburg at googlemail.com (Stefan Schwarzburg) Date: Tue, 7 Apr 2009 08:52:55 +0200 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DA4E15.4080109@lpta.in2p3.fr> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DA0952.8070709@stsci.edu> <49DA16B4.6080002@sbcglobal.net> <49DA1AE3.5080902@stsci.edu> <49DA4E15.4080109@lpta.in2p3.fr> Message-ID: On Mon, Apr 6, 2009 at 20:46, Cohen-Tanugi Johann wrote: > the main thing missing when using matplotlib is the correct use of > astronomical coordinate information, and that is a pretty big plus of ds9. > J > I'm not sure if I posted this reply already to this thread, or if it was the same topic on a different thread: You can also try pysao to comminicate with ds9, the interface is nicer (although the implementation might not, I don't know). http://code.google.com/p/python-sao/ >>> import pysao # run new instance of ds9 >>> ds9 = pysao.ds9() >>> import pyfits >>> f = pyfits.open('test.fits') # display first extension of fits file >>> ds9.view(f[0]) Note also, that there is the kapteyn package which uses matplotlib (pylab) to display the data from fits files according to the wcs (World Coordinate System) contained in most fits files in the correct way. http://www.astro.rug.nl/software/kapteyn/ Cheers, Stefan > > Phil Hodge wrote: > >> The question is whether ds9 is a module that can be used within a Python > >> program? I really do not know, but indications are that it is not. > >> > > > > > > ds9 is not a Python module, it's a stand-alone program that you run from > > Unix. However, there is an interface for displaying images to it, and > > the Python module numdisplay uses that interface. The advantage of ds9 > > is that it is so powerful. imshow in matplotlib is pretty good, though, > > and you may want to use matplotlib anyway for plotting. > > > > Phil > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org > > http://mail.scipy.org/mailman/listinfo/astropy > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- Institut f?r Astronomie und Astrophysik Eberhard Karls Universit?t T?bingen Sand 1 - D-72076 T?bingen schwarz at astro.uni-tuebingen.de stefan.schwarzburg at googlemail.com Tel.: 07071/29-78605 ----------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Tue Apr 7 07:16:21 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 04:16:21 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DA0952.8070709@stsci.edu> <49DA16B4.6080002@sbcglobal.net> <49DA1AE3.5080902@stsci.edu> <49DA4E15.4080109@lpta.in2p3.fr> <49DB1D0B.3000806@sbcglobal.net> Message-ID: <49DB3605.5020204@sbcglobal.net> The simple answer is too many Python irons in the fire right now. PIL, Tkinter, and some Python apps. When I get stuck on one area, I wait for a solution, and move to another topic. I've just rotated back to FITS ( and the Pmw toolkit). I'll try DS9 out of curiosity, but I do like do some ground work first. I'm also trying not to take some mis-steps here. It's all to easy for people to misunderstand matters, and go off in unintended directions. Another reason to dive right in is that the app I'm working on works among its users pretty well, but they may not be receptive to changes I'm working (to a program I didn't write) if they have to do too many extras. For example, I do not want to complicate the install process for them. Virtually none of them is familiar with fits, although they certainly profit it by it. As another example, I wrote some simple utilities a few months ago, but no one picked up on them, since they required Python 2.5. They are stuck on version Pyton 2. 5 of the program. The sponsor even added new features to the app, but in 2.5, so there's reluctance even there. When I finish my additions to the app, I think people will clearly see it has features they need. It'll be in 2.5. I actually heard of DS9 about 3 weeks ago when my ccdsoft (Bisque product) that deals with fits as its normal format died. I needed to look at some files in fits, and someone recommended DS9. I think there's a web interactive version of it. I finally wrestled ccdsoft back into operability, and found a simpler way to deal with a fits file in the interim. I have lots of balls in the air. Cheers. Stefan Schwarzburg wrote: > > > On Tue, Apr 7, 2009 at 11:29, Wayne Watson > > > wrote: > > Thanks, but I'm not sure why people keep bringing up DS9. As I > understand it, it is a stand alone program of sorts that has no > interface with Python. It seems to me it would be like saying use > Word or Adobe Photoshop. > > > DS9 is a external program with a python interface. From the user / > programmer point of view you can not distinguish between a python ds9 > interface that has the "imshow" command and a pure python modeule that > has the "imshow" command. You can also (from that point of view) not > distinguish between a pure python module and one that is a wrapper for > a c library or something like this. > If you don't have stronger requirements, like for example a custom > python virtual machiene that can not run external programs, then I > don't see why you should care if this is an interface to a program or > if it is a interface to a module. > > By the way: have you tried it? Is there some reason why you don't like > this kind of solution? > > Cheers, > Stefan > > > > Stefan Schwarzburg wrote: >> >> >> On Mon, Apr 6, 2009 at 20:46, Cohen-Tanugi Johann >> > wrote: >> >> the main thing missing when using matplotlib is the correct >> use of >> astronomical coordinate information, and that is a pretty big >> plus of ds9. >> J >> >> >> I'm not sure if I posted this reply already to this thread, or if >> it was the same topic on a different thread: >> >> You can also try pysao to comminicate with ds9, the interface is >> nicer (although the implementation might not, I don't know). >> http://code.google.com/p/python-sao/ >> >>> import pysao >> >> # run new instance of ds9 >> >>> ds9 = pysao.ds9() >> >> >>> import pyfits >> >>> f = pyfits.open('test.fits') >> >> # display first extension of fits file >> >>> ds9.view(f[0]) >> >> >> >> Note also, that there is the kapteyn package which uses >> matplotlib (pylab) to display the data from fits files according >> to the wcs (World Coordinate System) contained in most fits files >> in the correct way. http://www.astro.rug.nl/software/kapteyn/ >> >> Cheers, >> Stefan >> >> >> >> >> Phil Hodge wrote: >> >> The question is whether ds9 is a module that can be used >> within a Python >> >> program? I really do not know, but indications are that it >> is not. >> >> >> > >> > >> > ds9 is not a Python module, it's a stand-alone program that >> you run from >> > Unix. However, there is an interface for displaying images >> to it, and >> > the Python module numdisplay uses that interface. The >> advantage of ds9 >> > is that it is so powerful. imshow in matplotlib is pretty >> good, though, >> > and you may want to use matplotlib anyway for plotting. >> > >> > Phil >> > >> > _______________________________________________ >> > AstroPy mailing list >> > AstroPy at scipy.org >> > http://mail.scipy.org/mailman/listinfo/astropy >> > >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> >> >> >> -- >> Institut f?r Astronomie und Astrophysik >> Eberhard Karls Universit?t T?bingen >> Sand 1 - D-72076 T?bingen >> schwarz at astro.uni-tuebingen.de >> >> stefan.schwarzburg at googlemail.com >> >> >> Tel.: 07071/29-78605 >> ----------------------------------------------------------------------- >> ------------------------------------------------------------------------ >> _______________________________________________ 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 > > > > > > -- > Institut f?r Astronomie und Astrophysik > Eberhard Karls Universit?t T?bingen > Sand 1 - D-72076 T?bingen > schwarz at astro.uni-tuebingen.de > stefan.schwarzburg at googlemail.com > > > Tel.: 07071/29-78605 > ----------------------------------------------------------------------- -- 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 From sierra_mtnview at sbcglobal.net Tue Apr 7 07:42:30 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 04:42:30 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> Message-ID: <49DB3C26.9040206@sbcglobal.net> An HTML attachment was scrubbed... URL: From cohen at lpta.in2p3.fr Tue Apr 7 07:44:39 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Tue, 07 Apr 2009 13:44:39 +0200 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB3C26.9040206@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> Message-ID: <49DB3CA7.9020702@lpta.in2p3.fr> 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 > 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 > From sierra_mtnview at sbcglobal.net Tue Apr 7 09:35:26 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 06:35:26 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB3CA7.9020702@lpta.in2p3.fr> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> Message-ID: <49DB569E.7020202@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Tue Apr 7 09:39:35 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 06:39:35 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB3605.5020204@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DA0952.8070709@stsci.edu> <49DA16B4.6080002@sbcglobal.net> <49DA1AE3.5080902@stsci.edu> <49DA4E15.4080109@lpta.in2p3.fr> <49DB1D0B.3000806@sbcglobal.net> <49DB3605.5020204@sbcglobal.net> Message-ID: <49DB5797.2040801@sbcglobal.net> An HTML attachment was scrubbed... URL: From tgrav at mac.com Tue Apr 7 09:39:31 2009 From: tgrav at mac.com (Tommy Grav) Date: Tue, 07 Apr 2009 09:39:31 -0400 Subject: [AstroPy] Fwd: numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter References: Message-ID: <8075638C-D45E-4DF0-9A03-AFC386C884CA@mac.com> 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 > fig = mpl.figure() > TypeError: 'module' object is not callable Tommy From cohen at lpta.in2p3.fr Tue Apr 7 10:01:05 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Tue, 07 Apr 2009 16:01:05 +0200 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB569E.7020202@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> <49DB569E.7020202@sbcglobal.net> Message-ID: <49DB5CA1.4040208@lpta.in2p3.fr> weird error msg, but in any ncase I made a mistake. Try: from matplotlib import pyplot as plt plt.figure() If this does not work, smthg is wrong with your matplotlib install and you should ask the matplotlib mailing list... HTH Johann 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 > 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 >>> 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 > From sierra_mtnview at sbcglobal.net Tue Apr 7 10:15:23 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 07:15:23 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> <49DB569E.7020202@sbcglobal.net> Message-ID: <49DB5FFB.3040406@sbcglobal.net> 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 >> 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 >>>> 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 >> 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 From sierra_mtnview at sbcglobal.net Tue Apr 7 10:52:57 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 07:52:57 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <5F91A919-83CF-415D-BC55-7BD9AE108AE9@me.com> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> <49DB569E.7020202@sbcglobal.net> <49DB5FB0.3040906@sbcglobal.net> <5F91A919-83CF-415D-BC55-7BD9AE108AE9@me.com> Message-ID: <49DB68C9.3070009@sbcglobal.net> An HTML attachment was scrubbed... URL: From cohen at lpta.in2p3.fr Tue Apr 7 11:30:58 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Tue, 07 Apr 2009 17:30:58 +0200 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB68C9.3070009@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> <49DB569E.7020202@sbcglobal.net> <49DB5FB0.3040906@sbcglobal.net> <5F91A919-83CF-415D-BC55-7BD9AE108AE9@me.com> <49DB68C9.3070009@sbcglobal.net> Message-ID: <49DB71B2.4030605@lpta.in2p3.fr> well I think that at that stage you really need to read the matplotlib manual : http://matplotlib.sourceforge.net/contents.html Johann Wayne Watson wrote: > That did it. Thanks. I'm not sure what the icons along the bottom > mean, or even the axis labels (pixels?), but there may be an idea here > worth pursuing. How designable is this plot? For example, could I > create an icon to allow the user to choose a position that I can that > read and use for a computation? Could I overlay the image and put a > transparency over it? Could I specify the background as what is in the > image, black? Could I draw on the figure, or add text to it? > > Tommy Grav wrote: >> Remove the raw_input and add >> >> plt.show() >> >> On Apr 7, 2009, at 10:14 AM, Wayne Watson wrote: >> >>> 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 >>>>> 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 >>>>>>> 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 >>>>> 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 >>> >> > > -- > 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 > From jturner at gemini.edu Tue Apr 7 12:40:12 2009 From: jturner at gemini.edu (James Turner) Date: Tue, 07 Apr 2009 12:40:12 -0400 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB3605.5020204@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DA0952.8070709@stsci.edu> <49DA16B4.6080002@sbcglobal.net> <49DA1AE3.5080902@stsci.edu> <49DA4E15.4080109@lpta.in2p3.fr> <49DB1D0B.3000806@sbcglobal.net> <49DB3605.5020204@sbcglobal.net> Message-ID: <49DB81EC.9010206@gemini.edu> > I actually heard of DS9 about 3 weeks ago when my ccdsoft (Bisque > product) that deals with fits as its normal format died. I needed to > look at some files in fits, and someone recommended DS9. I think there's > a web interactive version of it. I finally wrestled ccdsoft back into > operability, and found a simpler way to deal with a fits file in the > interim. I have lots of balls in the air. > Cheers. It is trivial to view FITS files with DS9, either with numdisplay in Python or just from the "File->Open" menu. DS9 is what most people who work with FITS files use, hence the recommendations. There are also other ways of talking to DS9 from your program (using its XPA command line utilities or the CDL C library from IRAF) if you need more sophisticated communication. There is also Ximtool, which is much the same but with a different GUI if you prefer that (I do). Cheers, James. From sierra_mtnview at sbcglobal.net Tue Apr 7 14:33:33 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 11:33:33 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB71B2.4030605@lpta.in2p3.fr> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> <49DB569E.7020202@sbcglobal.net> <49DB5FB0.3040906@sbcglobal.net> <5F91A919-83CF-415D-BC55-7BD9AE108AE9@me.com> <49DB68C9.3070009@sbcglobal.net> <49DB71B2.4030605@lpta.in2p3.fr> Message-ID: <49DB9C7D.5050809@sbcglobal.net> Sounds right. :-) 754 pages! I'll look for what I need via reading the pdf. If it's meaty enough, then I'll get it printed. I may need a huge monitor for this. :-) Cohen-Tanugi Johann wrote: > well I think that at that stage you really need to read the matplotlib > manual : http://matplotlib.sourceforge.net/contents.html > > Johann > > Wayne Watson wrote: >> That did it. Thanks. I'm not sure what the icons along the bottom >> mean, or even the axis labels (pixels?), but there may be an idea >> here worth pursuing. How designable is this plot? For example, could >> I create an icon to allow the user to choose a position that I can >> that read and use for a computation? Could I overlay the image and >> put a transparency over it? Could I specify the background as what is >> in the image, black? Could I draw on the figure, or add text to it? >> >> Tommy Grav wrote: >>> Remove the raw_input and add >>> plt.show() >>> >>> On Apr 7, 2009, at 10:14 AM, Wayne Watson wrote: >>> >>>> 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 >>>>>> 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 >>>>>>>> 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 >>>>>> 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 >>>> >>> >> >> -- >> 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 From sierra_mtnview at sbcglobal.net Tue Apr 7 14:45:40 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 11:45:40 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, , Python, PIL, and Tkinter In-Reply-To: <49DB7D1D.2020809@stsci.edu> References: <49DB7D1D.2020809@stsci.edu> Message-ID: <49DB9F54.3040607@sbcglobal.net> An HTML attachment was scrubbed... URL: From cohen at lpta.in2p3.fr Tue Apr 7 15:04:28 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Tue, 07 Apr 2009 21:04:28 +0200 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB9C7D.5050809@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> <49DB569E.7020202@sbcglobal.net> <49DB5FB0.3040906@sbcglobal.net> <5F91A919-83CF-415D-BC55-7BD9AE108AE9@me.com> <49DB68C9.3070009@sbcglobal.net> <49DB71B2.4030605@lpta.in2p3.fr> <49DB9C7D.5050809@sbcglobal.net> Message-ID: <49DBA3BC.8000908@lpta.in2p3.fr> how about just reading the html version first, browsing through the sections to check which you might need to print out? in any event, start with : http://matplotlib.sourceforge.net/users/pyplot_tutorial.html Wayne Watson wrote: > Sounds right. :-) 754 pages! I'll look for what I need via reading the > pdf. If it's meaty enough, then I'll get it printed. I may need a huge > monitor for this. :-) > > Cohen-Tanugi Johann wrote: >> well I think that at that stage you really need to read the >> matplotlib manual : http://matplotlib.sourceforge.net/contents.html >> >> Johann >> >> Wayne Watson wrote: >>> That did it. Thanks. I'm not sure what the icons along the bottom >>> mean, or even the axis labels (pixels?), but there may be an idea >>> here worth pursuing. How designable is this plot? For example, could >>> I create an icon to allow the user to choose a position that I can >>> that read and use for a computation? Could I overlay the image and >>> put a transparency over it? Could I specify the background as what >>> is in the image, black? Could I draw on the figure, or add text to it? >>> >>> Tommy Grav wrote: >>>> Remove the raw_input and add >>>> plt.show() >>>> >>>> On Apr 7, 2009, at 10:14 AM, Wayne Watson wrote: >>>> >>>>> 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 >>>>>>> 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 >>>>>>>>> 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 >>>>>>> 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 >>>>> >>>> >>> >>> -- >>> 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 >>> >> > From sierra_mtnview at sbcglobal.net Tue Apr 7 21:26:25 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 18:26:25 -0700 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DB3CA7.9020702@lpta.in2p3.fr> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> Message-ID: <49DBFD41.5060509@sbcglobal.net> Hi, now that this is solved I curious why you hit upon the namespace idea? 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 >> 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 From cohen at lpta.in2p3.fr Wed Apr 8 02:06:55 2009 From: cohen at lpta.in2p3.fr (Cohen-Tanugi Johann) Date: Wed, 08 Apr 2009 08:06:55 +0200 Subject: [AstroPy] numarray pdf 1.5 is broken. Using numdisplay, Python, PIL, and Tkinter In-Reply-To: <49DBFD41.5060509@sbcglobal.net> References: <49D98CD4.3090508@sbcglobal.net> <49D9BC1C.4040805@lpta.in2p3.fr> <49D9F65D.9010804@sbcglobal.net> <49DB3C26.9040206@sbcglobal.net> <49DB3CA7.9020702@lpta.in2p3.fr> <49DBFD41.5060509@sbcglobal.net> Message-ID: <49DC3EFF.3090901@lpta.in2p3.fr> not callable means : you cant put the () after figure..... which is senseless for plt.figure(), as this is a method. So figure must be a module in your interatctive shell, which means that there is a conflict between the matplotlib figure and another object figure which would be a module rather than a function. Johann Wayne Watson wrote: > Hi, now that this is solved I curious why you hit upon the namespace > idea? > > 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 >>> 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 >>> >> > From sierra_mtnview at sbcglobal.net Wed Apr 8 07:38:20 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 08 Apr 2009 04:38:20 -0700 Subject: [AstroPy] Data Analysis and Programming in Python Message-ID: <49DC8CAC.2040000@sbcglobal.net> Hi, Warren. I'm picking up on the part of the thread above that you branched off on here, because I'd like to highlight and clarify what I'm after without having it buried in that long thread. Well, I took a peek at the data analysis pdf file. My impression is that this is for people who want to do interactive data analysis, and probably know little about Python. What I'm doing is modifying a 2000+ line of Python code to add new features that will do analysis of meteor images. To collect images, it uses a special hardware box. Ultimately, the user sees these images in a non-standard file format, which only the app understands. I would like to, for one of many things, allow users to convert these images to fits. Suppose I do that and stop there. It _might_ be possible to convince the users to use the data analysis program. It's doubtful though, since they are pretty much neophytes. They do understand how to operate the program in the present form, which basically provides no analytic capabilities. If I can add fits and analyticd features to the program, there is a good chance they will use them. I think sending them off to the data analysis tool here would not work. Not yet anyway. To put it simply, I'm looking for some capability to add features that will allow the program to both read and write fits format files. Adding analytic capabilites is important, but not the point here. 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 got someone to respond 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) ax.imshow(image) fig.canvas.draw() plt.show() This is close to what I'm looking for. Right now I'm lacking away 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. -- 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 From sierra_mtnview at sbcglobal.net Wed Apr 8 07:50:59 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 08 Apr 2009 04:50:59 -0700 Subject: [AstroPy] Coding in Python to Read/Write a fits file. Message-ID: <49DC8FA3.2070307@sbcglobal.net> 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) ax.imshow(image) fig.canvas.draw() plt.show() 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. -- 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 From erwin at mpe.mpg.de Wed Apr 8 08:27:51 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Wed, 8 Apr 2009 14:27:51 +0200 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <49DC8FA3.2070307@sbcglobal.net> References: <49DC8FA3.2070307@sbcglobal.net> Message-ID: <4C7A0F23-5747-4C4A-AE11-BF3A577CFEAC@mpe.mpg.de> On Apr 8, 2009, at 1:50 PM, Wayne Watson wrote: [snip] > 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. > *Writing* a FITS file using pyfits is not very difficult. The bare- bones description of this is in the pyfits manual ("Create FITS Images from Scratch", on p.10, I think). Since you're working with images, you need to have the image data as a 2D numpy array (the example on p.10 uses a 1-D array). (Pyfits manual available here: http://www.stsci.edu/resources/software_hardware/pyfits ) Since you say that the existing Python code handles the "internal image format", then it must somewhere have the data in a Python data structure, perhaps as a list of lists, or perhaps as a Python array. You'll need to go into this existing code and find out what the internal format is; then you'll have some idea of how to convert it to a numpy array. It might be as simple as image_for_fits = numpy.array(image_oldformat) Since your data is 8 bit, it would make sense to use a numpy *integer* array; I believe pyfits is smart enough to save the result as an integer FITS file. The Pyfits manual also explains how to add header keywords (see the chapter on Headers). (Note that the Pyfits manual is still based on version 1.0, and so it refers to "numarray" instead of "numpy"; you should just mentally substitute "numpy" wherever you see "numarray" in the text. The manual also has problems with the chapter numbers, which don't agree between the Table of Contents and the actual main text. But this is a minor issue.) As for jpeg, gif, etc. -- you have to find some Python code that can read those formats (Python Imaging Library, perhaps?). Once they've been read in, however, you should be able to convert the resulting data structure to a numpy array, and then you can write it as a FITS file. cheers, Peter ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From sosey at stsci.edu Wed Apr 8 10:51:11 2009 From: sosey at stsci.edu (Megan Sosey) Date: Wed, 08 Apr 2009 10:51:11 -0400 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <49DC8FA3.2070307@sbcglobal.net> References: <49DC8FA3.2070307@sbcglobal.net> Message-ID: <49DCB9DF.90707@stsci.edu> Hi Wayne, something like this work for me, perhaps it will help get you closer to what you want. I attached the sample image I used. cheers, Megan ----- #!/usr/bin/env python import pyfits import numpy import Image import time image = Image.open('hs-2009-14-a-web.jpg') #image.show() xsize,ysize=image.size r,g,b=image.split() #r.show() #g.show() #b.show() rdata=r.getdata() #data is now an array of length ysize*xsize gdata=g.getdata() bdata=b.getdata() npr=numpy.reshape(rdata,(ysize,xsize)) npg=numpy.reshape(gdata,(ysize,xsize)) npb=numpy.reshape(bdata,(ysize,xsize)) red=pyfits.PrimaryHDU() red.header.update('LATOBS',"32:11:56") red.header.update('LONGOBS',"110:56") red.header.update('TIME',time.ctime()) red.data=npr red.writeto('red.fits') green=pyfits.PrimaryHDU() green.header.update('LATOBS',"32:11:56") green.header.update('LONGOBS',"110:56") green.header.update('TIME',time.ctime()) green.data=npg green.writeto('green.fits') blue=pyfits.PrimaryHDU() blue.header.update('LATOBS',"32:11:56") blue.header.update('LONGOBS',"110:56") blue.header.update('TIME',time.ctime()) blue.data=npb blue.writeto('blue.fits') ------- 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) > ax.imshow(image) > fig.canvas.draw() > plt.show() > > 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. -- Megan Sosey Science Software Branch Operations and Engineering Division Space Telescope Science Institute 3700 San Martin Drive, Baltimore MD 21218 Phone: +00.1.410.338.4365 -------------- next part -------------- A non-text attachment was scrubbed... Name: hs-2009-14-a-web.jpg Type: image/jpeg Size: 23490 bytes Desc: not available URL: From sosey at stsci.edu Wed Apr 8 11:18:03 2009 From: sosey at stsci.edu (Megan Sosey) Date: Wed, 08 Apr 2009 11:18:03 -0400 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <49DCB9DF.90707@stsci.edu> References: <49DC8FA3.2070307@sbcglobal.net> <49DCB9DF.90707@stsci.edu> Message-ID: <49DCC02B.6060209@stsci.edu> Hi Wayne, One caveat I forgot to mention, the script I sent you will transform the JPG (or gif or whatever) image into FITS images, which you can then look at in ds9 if you like, however, the data numbers are not something appropriate to do further analysis with, they are just the RGB scalings. So if you want to take the FITS images and do more science analysis on them, you'll have to rescale the data to something appropriate. cheers meg Megan Sosey wrote: > Hi Wayne, > > something like this work for me, perhaps it will help > get you closer to what you want. I attached the sample > image I used. > > > cheers, > Megan > -- Megan Sosey Science Software Branch Operations and Engineering Division Space Telescope Science Institute 3700 San Martin Drive, Baltimore MD 21218 Phone: +00.1.410.338.4365 From sierra_mtnview at sbcglobal.net Wed Apr 8 11:26:47 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 08 Apr 2009 08:26:47 -0700 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <4C7A0F23-5747-4C4A-AE11-BF3A577CFEAC@mpe.mpg.de> References: <49DC8FA3.2070307@sbcglobal.net> <4C7A0F23-5747-4C4A-AE11-BF3A577CFEAC@mpe.mpg.de> Message-ID: <49DCC237.2030009@sbcglobal.net> An HTML attachment was scrubbed... URL: From ptak at pha.jhu.edu Wed Apr 8 11:30:23 2009 From: ptak at pha.jhu.edu (Andrew Ptak) Date: Wed, 08 Apr 2009 11:30:23 -0400 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <49DCC02B.6060209@stsci.edu> References: <49DC8FA3.2070307@sbcglobal.net> <49DCB9DF.90707@stsci.edu> <49DCC02B.6060209@stsci.edu> Message-ID: <49DCC30F.8080408@pha.jhu.edu> Hello, I wouldn't trust any science analysis done on an arbitrary image that isn't in FITS (or some other scientific format). You need to be sure that flux, noise, etc. have been properly preserved and calibrated for any believable analysis. First of all, jpeg is itself a lossy compression format, but in general you don't know what smoothing, filtering, etc. might have been done to the original data to make a press release image. You might be able to get away an order-of-mag. estimate of some quantities if the amount of processing had been minimal and you are very familiar with the type of data that went into the image. Cheers, Andy Ptak Megan Sosey wrote: > Hi Wayne, > > One caveat I forgot to mention, the script > I sent you will transform the JPG (or gif or whatever) > image into FITS images, which you can then look > at in ds9 if you like, however, the data numbers are > not something appropriate to do further analysis with, > they are just the RGB scalings. So if you want to take the > FITS images and do more science analysis on them, you'll > have to rescale the data to something appropriate. > > cheers > meg > > > Megan Sosey wrote: > >> Hi Wayne, >> >> something like this work for me, perhaps it will help >> get you closer to what you want. I attached the sample >> image I used. >> >> >> cheers, >> Megan >> >> > > From sosey at stsci.edu Wed Apr 8 11:51:55 2009 From: sosey at stsci.edu (Megan Sosey) Date: Wed, 08 Apr 2009 11:51:55 -0400 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <49DCC441.7@sbcglobal.net> References: <49DC8FA3.2070307@sbcglobal.net> <49DCB9DF.90707@stsci.edu> <49DCC02B.6060209@stsci.edu> <49DCC441.7@sbcglobal.net> Message-ID: <49DCC81B.3080307@stsci.edu> I mean that once you have an image in JPG format, you've essentially lost all useful science data information. You shouldn't then take the image and do a science analysis on it. As you and Andrew mentioned, JPG is lossy as well, so there's no way to get back to the original information. There are more science software options for analyzing FITS images. If your final goal is something like getting the meteor path information out of an image, you could probably apply a scaling to the fits images which would make centroiding easier, but the absolute flux information has already been lost. With the jpeg compression, you're probably loosing useful pixels to do the centroiding as well. The best approach would be to get the original data numbers out of your hardware box, or the internal format you mentioned (if it's not already compressed), and go directly from there to FITS images. Then if you have images in multiple wavelength bands you can convert those to jpeg, gif or whatever using something of the reverse of the recipe I sent you. cheers, meg Wayne Watson wrote: > Thanks for the code. It looks helpful. > Are you saying that because a jpg file is lossy that one would need to > take that into account by rescaling in some fashion? > > Megan Sosey wrote: >> Hi Wayne, >> >> One caveat I forgot to mention, the script >> I sent you will transform the JPG (or gif or whatever) >> image into FITS images, which you can then look >> at in ds9 if you like, however, the data numbers are >> not something appropriate to do further analysis with, >> they are just the RGB scalings. So if you want to take the >> FITS images and do more science analysis on them, you'll >> have to rescale the data to something appropriate. >> >> cheers >> meg >> >> >> Megan Sosey wrote: >>> Hi Wayne, >>> >>> something like this work for me, perhaps it will help >>> get you closer to what you want. I attached the sample >>> image I used. >>> >>> >>> cheers, >>> Megan >>> >> > > -- > > 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 > > -- Megan Sosey Science Software Branch Operations and Engineering Division Space Telescope Science Institute 3700 San Martin Drive, Baltimore MD 21218 Phone: +00.1.410.338.4365 From sierra_mtnview at sbcglobal.net Wed Apr 8 13:32:27 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 08 Apr 2009 10:32:27 -0700 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <49DCC81B.3080307@stsci.edu> References: <49DC8FA3.2070307@sbcglobal.net> <49DCB9DF.90707@stsci.edu> <49DCC02B.6060209@stsci.edu> <49DCC441.7@sbcglobal.net> <49DCC81B.3080307@stsci.edu> Message-ID: <49DCDFAB.60104@sbcglobal.net> An HTML attachment was scrubbed... URL: From hack at stsci.edu Thu Apr 9 11:08:33 2009 From: hack at stsci.edu (Warren J. Hack) Date: Thu, 09 Apr 2009 11:08:33 -0400 Subject: [AstroPy] Data Analysis and Programming in Python In-Reply-To: <49DD14DD.3070706@sbcglobal.net> References: <49DC8CAC.2040000@sbcglobal.net> <49DCFD56.1040608@stsci.edu> <49DD14DD.3070706@sbcglobal.net> Message-ID: <49DE0F71.5040605@stsci.edu> Hi, I would recommend that you take a look at the 'Interactive Data Analysis' tutorial (pydatatut-2.pdf) in Chapter 1 for a much simpler discussion of numpy arrays and their available operations. http://stsdas.stsci.edu/perry/pydatatut.pdf The actual Numpy manual itself is really designed as a reference book for hard-core programmers, not necessarily a tutorial for end users. This lends to a very confusing, detail-oriented description which all but the most dedicated programmers find difficult to use when learning how to work with numpy arrays. The tutorial by Perry and Robert really tries to introduce the user to numpy arrays and how to work with them on a practical basis. My earlier suggestion regarding writing separate functions to return numpy arrays comes from reviewing Megan's example and from your interest in working with multiple image formats. Each function could take as input the name of the image and return a list of numpy arrays, with one numpy array for each color (to handle 24-bit color images as well as simple gray-scale images in the same manner). For example, import Image, numpy def jpg2array(filename): image = Image.open(filename) xsize,ysize=image.size r,g,b=image.split() rdata=r.getdata() #data is now an array of length ysize*xsize gdata=g.getdata() bdata=b.getdata() npr=numpy.reshape(rdata,(ysize,xsize)) npg=numpy.reshape(gdata,(ysize,xsize)) npb=numpy.reshape(bdata,(ysize,xsize)) return [npr,npg,npb] def write_array(array,output,**keywords): phdu = pyfits.PrimaryHDU(data=array) for kw in keywords.keys(): phdu.header.update(kw,keywords[kw]) phdu.writeto(output) filename = 'hs-2009-14-a-web.jpg' keywords = {'LATOBS':"32:11:56",'LONGOBS':"110:56",'TIME':time.ctime()} if '.jpg' in filename: arrays = jpg2array(filename) array_names = ['red.fits','green.fits','blue.fits'] elif '.hdf' in filename: arrays = hdf2array(filename) array_names = ['hdf_array.fits'] for arr,outname in zip(arrays,array_names): write_array(arr,outname,keywords) These 2 functions should allow you to read JPG images as numpy arrays and then write each array out to a separate FITS file using PyFITS. The sample I provide above reproduces what Megan suggested but using modular functions and demonstrates how to handle multiple formats in a manageable manner. All you would need to do would be define the functions you need to interpret the image formats from your hardware into numpy arrays, and plug it into this example to write it out as a FITS file. You could also pass it along to whatever plotting routine you want to use as numpy arrays as well, but at least this condenses the work of generating the numpy arrays and FITS files into a couple of manageable functions to be included in the rest of your code. Cheers, Warren Wayne Watson wrote: > Hi, a couple of things. Is there something a little more compact than > the numPy manual in its descriptions? Probably the first 2x3 example > was enough. Roughly page 19, maybe 26. It seems like the manual goes a > bit overboard. The ndarray description goes on for pages. It looks > like the whole ndarray story goes on to page 86. > > When you say write a jpg2numpy() function, it should produce what? A > numpy array? Something like this I suppose: > image = Image.open('hs-2009-14-a-web.jpg') > > #image.show() > xsize,ysize=image.size > r,g,b=image.split() > rdata=r.getdata() #data is now an array of length ysize*xsize > gdata=g.getdata() > bdata=b.getdata() > ... > > Then use fitspy to put the data into the proper places. > > I find this mail-list a bit different. It looks like posts are being > made from outside (no reference to astropy at scipy.org), or sometimes > have multiple e-mail addresses. Is there some protocol here to always > post something back the the list? Are there rules regarding text vs > html format? > > Warren J. Hack wrote: >> Hello again, >> >> I noticed that Megan (a co-worker) provided you with something that >> covers the primary aspects of your problem; namely, reading an image >> in and writing it out as a FITS file. The basic step that you need >> to sort out is simply how to convert your native data format into a >> numpy array. Megan's example shows how you can do this for jpg >> files, but it goes for any non-FITS format. I would actually >> recommend writing a separate function to perform the translation from >> each image format you want/need to support into numpy (jpg2numpy(), >> hdf2numpy(),...), then write a generic function to write out the >> numpy array(s) to FITS files. The numpy format can then be used to >> view the image directly in matplotlib or DS9 (through numdisplay) >> depending on what you need. The display through matplotlib can be >> easily integrated into another GUI if needed whereas DS9 would need >> to be started up as a separate process, with the rest of the thread >> covering how to display the data. >> >> If you need any more help, please don't hesitate to ask me directly. >> >> Cheers, >> Warren >> >> >> >> Wayne Watson wrote: >>> Hi, Warren. I'm picking up on the part of the thread above that >>> you branched off on here, because I'd like to highlight and clarify >>> what I'm after without having it buried in that long thread. >>> >>> Well, I took a peek at the data analysis pdf file. My impression is >>> that this is for people who want to do interactive data analysis, >>> and probably know little about Python. What I'm doing is modifying a >>> 2000+ line of Python code to add new features that will do analysis >>> of meteor images. To collect images, it uses a special hardware box. >>> Ultimately, the user sees these images in a non-standard file >>> format, which only the app understands. I would like to, for one >>> of many things, allow users to convert these images to fits. Suppose >>> I do that and stop there. It _might_ be possible to convince the >>> users to use the data analysis program. It's doubtful though, since >>> they are pretty much neophytes. They do understand how to operate >>> the program in the present form, which basically provides no >>> analytic capabilities. If I can add fits and analyticd features to >>> the program, there is a good chance they will use them. I think >>> sending them off to the data analysis tool here would not work. Not >>> yet anyway. >>> >>> To put it simply, I'm looking for some capability to add features >>> that will allow the program to both read and write fits format >>> files. Adding analytic capabilites is important, but not the point >>> here. 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 got >>> someone to respond 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) >>> ax.imshow(image) >>> fig.canvas.draw() >>> plt.show() >>> >>> This is close to what I'm looking for. Right now I'm lacking away 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. >>> >>> >> > > -- > 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 > -- Warren J. Hack Science Software Branch Space Telescope Science Institute 3700 San Martin Drive Baltimore MD, 21218 (410) 338-4943 From sierra_mtnview at sbcglobal.net Fri Apr 10 21:05:05 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 18:05:05 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) Message-ID: <49DFECC1.9070502@sbcglobal.net> An HTML attachment was scrubbed... URL: From chanley at stsci.edu Fri Apr 10 21:12:07 2009 From: chanley at stsci.edu (Christopher Hanley) Date: Fri, 10 Apr 2009 21:12:07 -0400 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49DFECC1.9070502@sbcglobal.net> References: <49DFECC1.9070502@sbcglobal.net> Message-ID: <49DFEE67.3030004@stsci.edu> Hey! We at STScI are always working! ;-) I'm not certain how numdisplay could have been installed in a directory not on your Python path. However, there are two things you can easily do to make this work for you. Either add numdisplay's current location to you python path or copy the numdisplay folder to the same location as your other packages (i.e. numpy, PIL, etc...). I hope this helps, Chris -- Christopher Hanley Senior Systems Software Engineer Space Telescope Science Institute 3700 San Martin Drive Baltimore MD, 21218 (410) 338-4338 Wayne Watson wrote: > (I would normally pursue this on another thread I was working with > STSci, but this problem occurred late this afternoon here on the west > coast. I think STSci folks disappeared by then, but, as it turns out, my > weekend is open. However, if I cannot get this squared away, I can > easily return to other related matters that are not impacted by numdisplay.) > > There was a mix-up earlier today when I tried to install numdisplay. The > web had an old version, 14. That was corrected and 1.5.4 is now > available. After downloading 1.5.4 and untarring it. I then drilled down to > > C:\Downloads_Programs\Python\numdisplay-1.5.4\numdisplay, > > which has the build and lib folders along with setup.py, > stcsci-dist...back.py, and stsci-dist...back.pyc. > I then entered setup.py install. All seems to have gone well. However, > when I enter import numdisplay in IDLE's >>> prompt, it objected with > "no module named numdisplay". I then tried from the Python command > prompt line (looks like a DOS prompt window) and got the same response. > > Next I tried IDLE's Path Browser, and looked under > C:\Python25\lib\site-packages. numdisplay was not listed, but numpy, > PIL, pyfits, etc. were listed. Next, drilling down to > C:\Python25\Lib\python2.5\site-packages, numdisplay was found. This > looks like the wrong place for it. Note the injection of python2.5 in > the path. > > I'm not quite sure what's wrong here. Maybe it's right and I need to try > another way. > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)**** > > "In arithemtic as in politics, the importance of one is > determined by the number of zeros behind it." -- Anon > > > > ------------------------------------------------------------------------ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From sierra_mtnview at sbcglobal.net Fri Apr 10 21:44:45 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 18:44:45 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49DFEE67.3030004@stsci.edu> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> Message-ID: <49DFF60D.2000407@sbcglobal.net> An HTML attachment was scrubbed... URL: From chanley at stsci.edu Fri Apr 10 21:49:41 2009 From: chanley at stsci.edu (Christopher Hanley) Date: Fri, 10 Apr 2009 21:49:41 -0400 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49DFF60D.2000407@sbcglobal.net> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> Message-ID: <49DFF735.6030209@stsci.edu> If the *.fit file has the same structure as your .fits file then you are fine. You need to have DS9 running prior to using numdisplay. That is the program it is looking for. If you don't have DS9 already installed you can get a Windows installation from this site: http://hea-www.harvard.edu/RD/ds9/ Cheers, Chris Wayne Watson wrote: > Hi, that's pretty humorous. I posted the msg, and mentioned that I had > some time to fill, so let's watch a movie. She was too tired, so I came > in here to find your msg. 7/7/24 for STSci! > > There's nothing like a clean simple solution. It worked. > > Now I have a slightly different problem. First, let me ask if there's a > difference between a fit and fits file? I use a commercial program (Win, > CCDSoft from The Bisque) for imaging that produces FIT files. I'm quite > sure they have the same structure as FITS. I just want to make sure > that's not a problem. Here's what's happening. > > I've imported numpy, fits, and numdisplay. I'm using the shell prompt > for Windows Python. I enter: > >>> im=pyfits.getdata('minor_pl51.fit') > That seems to work. Just a >>> response. Now I enter: > >>> numdisplay.display(im) > and get > > Traceback (most recent call last): > File "", line 1, in > numdisplay.display(im) > File > "C:\Python25\lib\python2.5\site-packages\numdisplay\__init__.py", > line 371, in display > File > "C:\Python25\lib\python2.5\site-packages\numdisplay\__init__.py", > line 180, in open > File > "C:\Python25\lib\python2.5\site-packages\numdisplay\displaydev.py", > line 670, in open > File > "C:\Python25\lib\python2.5\site-packages\numdisplay\displaydev.py", > line 195, in _open > IOError: Cannot attach to display program. Verify that one is running... > > What program? I don't think I'm running any. > > -- Christopher Hanley Senior Systems Software Engineer Space Telescope Science Institute 3700 San Martin Drive Baltimore MD, 21218 (410) 338-4338 From sierra_mtnview at sbcglobal.net Fri Apr 10 22:16:27 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 19:16:27 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49DFF735.6030209@stsci.edu> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> <49DFF735.6030209@stsci.edu> Message-ID: <49DFFD7B.1010408@sbcglobal.net> An HTML attachment was scrubbed... URL: From chanley at stsci.edu Fri Apr 10 22:36:00 2009 From: chanley at stsci.edu (Christopher Hanley) Date: Fri, 10 Apr 2009 22:36:00 -0400 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49DFFD7B.1010408@sbcglobal.net> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> <49DFF735.6030209@stsci.edu> <49DFFD7B.1010408@sbcglobal.net> Message-ID: <49E00210.70208@stsci.edu> Wayne Watson wrote: > On the other hand, if I use a Python program (usint pyfits, numpy, etc. > and no numdisplay), then I can dispense with the need to run DS9, and > use PIL and canvas from Tkinter, correct? Of course, I need to strip out > the data portions of the FITS files to do that. I think that's right, > since PIL has no knowledge of fits. > I am not the familiar with PIL and Tkinter. I expect you could probably get something like that working at the loss of the WCS information the FITS image provides and the DS9 can interpret. "Stripping" out the data of a pyfits object is trivial. Just identify the extension you wish to use data from. If you are using simple FITS files the data is probably in the primary extension. So doing something like this: import pyfits hdulist = pyfits.open("somefile.fits") data = hdulist[0].data The data object is a numpy array. I'll let people with more experience with Python GUIs and plotting take over helping you now. You are out of my area of expertise. Cheers, Chris -- Christopher Hanley Senior Systems Software Engineer Space Telescope Science Institute 3700 San Martin Drive Baltimore MD, 21218 (410) 338-4338 From sierra_mtnview at sbcglobal.net Fri Apr 10 22:41:58 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 19:41:58 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49DFF735.6030209@stsci.edu> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> <49DFF735.6030209@stsci.edu> Message-ID: <49E00376.5070508@sbcglobal.net> An HTML attachment was scrubbed... URL: From chanley at stsci.edu Fri Apr 10 22:49:32 2009 From: chanley at stsci.edu (Christopher Hanley) Date: Fri, 10 Apr 2009 22:49:32 -0400 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49E00376.5070508@sbcglobal.net> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> <49DFF735.6030209@stsci.edu> <49E00376.5070508@sbcglobal.net> Message-ID: <49E0053C.5030704@stsci.edu> Wayne Watson wrote: > I downloaded the Win exe file, and my system thinks it's a zip file. It > tells me that it has unzipped two files successfully. I don't see any, > and suspect this is really an executable file. Have I got the wrong > download? > I believe that it is a binary executable, not a zip file. I think you should just be able to download and run it. Does it have execute permission on your system? I'm not really a Windows user so I'm less familiar with the types of issues you could be running across. -- Christopher Hanley Senior Systems Software Engineer Space Telescope Science Institute 3700 San Martin Drive Baltimore MD, 21218 (410) 338-4338 From jh at physics.ucf.edu Fri Apr 10 23:38:35 2009 From: jh at physics.ucf.edu (Joe Harrington) Date: Fri, 10 Apr 2009 23:38:35 -0400 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: (astropy-request@scipy.org) References: Message-ID: > ... numdisplay... Be aware that Russell Owen's RO package contains a DS9 interface that is better than numdisplay in many respects. You can have many people on one machine each communicating with their own DS9 without special fifo setup, and the data are not interpolated in the image display, among other improvements. I am not aware of any disimprovements, but I've not dived too deeply into it. http://pypi.python.org/packages/source/R/RO/RO-2.2.10.tar.gz >From the docs... Here is a basic summary for use: import RO.DS9 import numpy ds9Win = RO.DS9.DS9Win() # show a FITS file in frame 1 ds9Win. showFITSFile("foo/test.fits") # show an array in frame 2 ds9Win.xpaset("frame 2") myArray = numpy.arange(10000).reshape([100,100]) ds9Win.showArray(myArray) --jh-- From sierra_mtnview at sbcglobal.net Fri Apr 10 23:57:08 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 20:57:08 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: References: Message-ID: <49E01514.5080508@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Sat Apr 11 00:00:31 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 21:00:31 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (MS Windows)-- w/o Captured Windows In-Reply-To: <49E0053C.5030704@stsci.edu> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> <49DFF735.6030209@stsci.edu> <49E00376.5070508@sbcglobal.net> <49E0053C.5030704@stsci.edu> Message-ID: <49E015DF.9090601@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Sat Apr 11 00:20:47 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 21:20:47 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (MS Windows) In-Reply-To: <49E015DF.9090601@sbcglobal.net> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> <49DFF735.6030209@stsci.edu> <49E00376.5070508@sbcglobal.net> <49E0053C.5030704@stsci.edu> <49E015DF.9090601@sbcglobal.net> Message-ID: <49E01A9F.7020800@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Sat Apr 11 20:03:04 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sat, 11 Apr 2009 17:03:04 -0700 Subject: [AstroPy] Page No, and Chapter Heading Problems with PyFits Manual Message-ID: <49E12FB8.2040700@sbcglobal.net> I'm looking (Subject) at the v 1.0, July 2005, manual. The TOC chapter #s and page numbers do not agree with the body of the manual. For example, Chapter 2 is used twice in the body. It looks like page numbers start over in most chapters. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)**** "In arithemtic as in politics, the importance of one is determined by the number of zeros behind it." -- Anon From chanley at stsci.edu Sat Apr 11 20:05:50 2009 From: chanley at stsci.edu (Christopher Hanley) Date: Sat, 11 Apr 2009 20:05:50 -0400 Subject: [AstroPy] Page No, and Chapter Heading Problems with PyFits Manual In-Reply-To: <49E12FB8.2040700@sbcglobal.net> References: <49E12FB8.2040700@sbcglobal.net> Message-ID: <49E1305E.6060603@stsci.edu> Wayne Watson wrote: > I'm looking (Subject) at the v 1.0, July 2005, manual. The TOC chapter > #s and page numbers do not agree with the body of the manual. For > example, Chapter 2 is used twice in the body. It looks like page numbers > start over in most chapters. There is a more update-to-date version of the PyFITS manual available here: http://incubator.stsci.edu/mediawiki/index.php/Telescopedia:PyFITS Chris -- Christopher Hanley Senior Systems Software Engineer Space Telescope Science Institute 3700 San Martin Drive Baltimore MD, 21218 (410) 338-4338 From sierra_mtnview at sbcglobal.net Sat Apr 11 20:36:21 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sat, 11 Apr 2009 17:36:21 -0700 Subject: [AstroPy] Page No, and Chapter Heading Problems with PyFits Manual In-Reply-To: <49E1305E.6060603@stsci.edu> References: <49E12FB8.2040700@sbcglobal.net> <49E1305E.6060603@stsci.edu> Message-ID: <49E13785.8030109@sbcglobal.net> I noticed a tab on that page that suggests one could create a pdf file from what is there. When I tried it, I got a msg that said there was a Latex error. Christopher Hanley wrote: > Wayne Watson wrote: >> I'm looking (Subject) at the v 1.0, July 2005, manual. The TOC >> chapter #s and page numbers do not agree with the body of the manual. >> For example, Chapter 2 is used twice in the body. It looks like page >> numbers start over in most chapters. > > There is a more update-to-date version of the PyFITS manual available > here: > > http://incubator.stsci.edu/mediawiki/index.php/Telescopedia:PyFITS > > Chris > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet "In arithemtic as in politics, the importance of one is determined by the number of zeros behind it." -- Anon From sierra_mtnview at sbcglobal.net Sat Apr 11 20:37:33 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sat, 11 Apr 2009 17:37:33 -0700 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <4C7A0F23-5747-4C4A-AE11-BF3A577CFEAC@mpe.mpg.de> References: <49DC8FA3.2070307@sbcglobal.net> <4C7A0F23-5747-4C4A-AE11-BF3A577CFEAC@mpe.mpg.de> Message-ID: <49E137CD.8000009@sbcglobal.net> I successfully produced a 640x480 one byte file from the py program, and called it sentinel_internal.raw. I'm now trying to figure out what facility that I need to get this into a fits data structure. Probably what is below will be fine, but, first though, I cannot read the .raw file. As far as I can tell, PIL, pyfits or numpy cannot do it. Let me put it another way. I do not see any description in any of the documents that I have that shows a way to do it. Comments? Peter Erwin wrote: > > On Apr 8, 2009, at 1:50 PM, Wayne Watson wrote: > > [snip] > >> 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. >> > > *Writing* a FITS file using pyfits is not very difficult. The bare-bones > description of this is in the pyfits manual ("Create FITS Images from > Scratch", > on p.10, I think). Since you're working with images, you need to have > the image > data as a 2D numpy array (the example on p.10 uses a 1-D array). > > (Pyfits manual available here: > http://www.stsci.edu/resources/software_hardware/pyfits ) > > > Since you say that the existing Python code handles the "internal image > format", then it must somewhere have the data in a Python data structure, > perhaps as a list of lists, or perhaps as a Python array. You'll need to > go into this existing code and find out what the internal format is; then > you'll have some idea of how to convert it to a numpy array. It might be > as simple as > image_for_fits = numpy.array(image_oldformat) > > Since your data is 8 bit, it would make sense to use a numpy *integer* > array; I believe pyfits is smart enough to save the result as an integer > FITS file. > > The Pyfits manual also explains how to add header keywords (see the > chapter on Headers). > > (Note that the Pyfits manual is still based on version 1.0, and so it > refers to > "numarray" instead of "numpy"; you should just mentally substitute > "numpy" > wherever you see "numarray" in the text. The manual also has problems > with > the chapter numbers, which don't agree between the Table of Contents and > the actual main text. But this is a minor issue.) > > > As for jpeg, gif, etc. -- you have to find some Python code that can > read those > formats (Python Imaging Library, perhaps?). Once they've been read > in, however, > you should be able to convert the resulting data structure to a numpy > array, > and then you can write it as a FITS file. > > cheers, > > Peter > > ============================================================= > Peter Erwin Max-Planck-Insitute for Extraterrestrial > erwin at mpe.mpg.de Physics, Giessenbachstrasse > tel. +49 (0)89 30000 3695 85748 Garching, Germany > fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin > > > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet "In arithemtic as in politics, the importance of one is determined by the number of zeros behind it." -- Anon From sierra_mtnview at sbcglobal.net Sat Apr 11 20:43:47 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sat, 11 Apr 2009 17:43:47 -0700 Subject: [AstroPy] Coding in Python to Read/Write a fits file. In-Reply-To: <49E137CD.8000009@sbcglobal.net> References: <49DC8FA3.2070307@sbcglobal.net> <4C7A0F23-5747-4C4A-AE11-BF3A577CFEAC@mpe.mpg.de> <49E137CD.8000009@sbcglobal.net> Message-ID: <49E13943.2010005@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Sun Apr 12 14:28:43 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 12 Apr 2009 11:28:43 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion Message-ID: <49E232DB.2030304@sbcglobal.net> I've pretty much gotten my 640x480 1 byte, "raw" image under control within Python Image and Python file use. I wrote a file of 307200 bytes in bytes, byte representation of characters. I couldn't see anything within pyfits or numpy that would help me do that. Now I believe I'm in a position to use pyfits to create a fits format file. The next step is to arrange the image (data) into a 640x480 array. I can do that in python, but would like to know how it can be done in numpy, for the experience. The IDA tutorial talks to making arrays, but I do not see where they work with creating an array with fresh data. Once that's done, then I should be able to work out from a reading of page 10 in the pyfits manual. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose is 5.52*10**-6 meters. That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From Jim.Vickroy at noaa.gov Mon Apr 13 11:49:29 2009 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon, 13 Apr 2009 09:49:29 -0600 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E232DB.2030304@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> Message-ID: <49E35F09.4060201@noaa.gov> Wayne Watson wrote: > I've pretty much gotten my 640x480 1 byte, "raw" image under control > within Python Image and Python file use. I wrote a file of 307200 bytes > in bytes, byte representation of characters. I couldn't see anything > within pyfits or numpy that would help me do that. Now I believe I'm in > a position to use pyfits to create a fits format file. The next step is > to arrange the image (data) into a 640x480 array. I can do that in > python, but would like to know how it can be done in numpy, for the > experience. The IDA tutorial talks to making arrays, but I do not see > where they work with creating an array with fresh data. Once that's > done, then I should be able to work out from a reading of page 10 in the > pyfits manual. > > Hello Wayne, Could you post a sample script illustrating exactly what you want to do along with some sample output showing how it is failing to do so? Are you familiar with the numpy.ndarray.reshape() procedure? -- jv From sierra_mtnview at sbcglobal.net Fri Apr 10 23:52:57 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Fri, 10 Apr 2009 20:52:57 -0700 Subject: [AstroPy] Installing numdisplay--A Problem (Windows) In-Reply-To: <49E0053C.5030704@stsci.edu> References: <49DFECC1.9070502@sbcglobal.net> <49DFEE67.3030004@stsci.edu> <49DFF60D.2000407@sbcglobal.net> <49DFF735.6030209@stsci.edu> <49E00376.5070508@sbcglobal.net> <49E0053C.5030704@stsci.edu> Message-ID: <49E01419.2080105@sbcglobal.net> An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: moz-screenshot-242.jpg Type: image/jpeg Size: 22164 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: moz-screenshot-243.jpg Type: image/jpeg Size: 27488 bytes Desc: not available URL: From sierra_mtnview at sbcglobal.net Mon Apr 13 12:38:40 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Mon, 13 Apr 2009 09:38:40 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E35F09.4060201@noaa.gov> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> Message-ID: <49E36A90.3080300@sbcglobal.net> Hi, not familiar with much of anything in numpy, then again, I'm not anxious to read through the 300+ page manual. :-) Well, let's see if I can explain this in py-talk. Here's a small program I wrote to get the raw image #import Image import string def make_array(): im_array=[] im_data=range(10) print im_data for j in range(2): row=[] for k in range(5): item=hex(int(im_data[k+j*5])) row.append(item) im_array.append(row) print im_array raw_file=open('sent_internal.raw','rb') raw_image=raw_file.read() raw_file.close() print 'info:', len(raw_image), type(raw_image) make_array() make_array, instead of working on the 307200 byte(640x480) string representing the image, is used to see if I can generate a 2x5 array like that apparently needed to represent the image to pyfits. The above produces this: info: 307200 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] <--- my fictional 2x5 image as a py list. [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] <--- the type of structure I think numarray(numpy equivalent) wants. I'm looking at page 7 of the FITS manual, and I see in the middle, hdulist[1].data. This appears to be where the data(image) goes. At the top of page 10, the steps to construct a simple fits file are shown. numarray is used. Simply put, how do I proceed from here? I've attached the 'sent_internal.raw' file. It may cause this msg to be rejected by the mail list. Jim Vickroy wrote: > Wayne Watson wrote: > >> I've pretty much gotten my 640x480 1 byte, "raw" image under control >> within Python Image and Python file use. I wrote a file of 307200 bytes >> in bytes, byte representation of characters. I couldn't see anything >> within pyfits or numpy that would help me do that. Now I believe I'm in >> a position to use pyfits to create a fits format file. The next step is >> to arrange the image (data) into a 640x480 array. I can do that in >> python, but would like to know how it can be done in numpy, for the >> experience. The IDA tutorial talks to making arrays, but I do not see >> where they work with creating an array with fresh data. Once that's >> done, then I should be able to work out from a reading of page 10 in the >> pyfits manual. >> >> >> > Hello Wayne, > > Could you post a sample script illustrating exactly what you want to do > along with some sample output showing how it is failing to do so? > > Are you familiar with the numpy.ndarray.reshape() procedure? > > -- jv > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) -------------- next part -------------- A non-text attachment was scrubbed... Name: sent_internal.raw Type: application/octet-stream Size: 307200 bytes Desc: not available URL: From erwin at mpe.mpg.de Mon Apr 13 16:17:36 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Mon, 13 Apr 2009 22:17:36 +0200 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E36A90.3080300@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> Message-ID: Hi Wayne, Pyfits will want a numpy array of integers (or floats). You can get a numpy array of either integer or floats with the numpy.array() function. Here's a short example (sort-of based on your "make_image" function), using integers: import numpy, pyfits # create a 2D integer array with 2 rows (a normal Python list-of-lists) int_array = [] for j in range(2): new_row = [] for k in range(5): new_row.append(k + j*5) int_array.append(new_row) >>> print int_array [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] # make a numpy array version of that Python list-of-lists int_array_numpy = numpy.array(int_array) >>> print int_array_numpy [[0 1 2 3 4] [5 6 7 8 9]] # save this numpy array as a FITS image (based on p.10 of the PyFits 1.0 Manual): hdu = pyfits.PrimaryHDU(int_array_numpy) # [ at this point you might optionally modify the header (e.g., add date, lat and long, etc.) ... ] # ... and save the data to file: hdu.writeto("simple_array.fits") Now, the problem is that what I've done is to create a Python array of *integers*, then converted it to numpy form. In your example code, you've created a Python array of hexadecimal-valued bytes -- which I guess is what you get reading in your "raw" image, so that's OK. But you still have to convert those '\x01', etc., values to Python integers. Since I basically never work with raw bytes or hexadecimal coding, I don't actually know how to do this... but I imagine other people on the list do. cheers, Peter On Apr 13, 2009, at 6:38 PM, Wayne Watson wrote: > Hi, not familiar with much of anything in numpy, then again, I'm not > anxious to read through the 300+ page manual. :-) > Well, let's see if I can explain this in py-talk. Here's a small > program I wrote to get the raw image > > #import Image > import string > > def make_array(): > im_array=[] > im_data=range(10) > print im_data > for j in range(2): > row=[] > for k in range(5): > item=hex(int(im_data[k+j*5])) > row.append(item) > im_array.append(row) > print im_array > > raw_file=open('sent_internal.raw','rb') > raw_image=raw_file.read() > raw_file.close() > print 'info:', len(raw_image), type(raw_image) > make_array() > > make_array, instead of working on the 307200 byte(640x480) string > representing the image, is used to see if I can generate a 2x5 array > like that apparently needed to represent the image to pyfits. The > above produces this: > info: 307200 > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] <--- my fictional 2x5 image as a py > list. > [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] <--- the type of structure I > think numarray(numpy equivalent) wants. > > I'm looking at page 7 of the FITS manual, and I see in the middle, > hdulist[1].data. This appears to be where the data(image) goes. At > the top of page 10, the steps to construct a simple fits file are > shown. numarray is used. Simply put, how do I proceed from here? > > > I've attached the 'sent_internal.raw' file. It may cause this msg to > be rejected by the mail list. > > Jim Vickroy wrote: >> Wayne Watson wrote: >> >>> I've pretty much gotten my 640x480 1 byte, "raw" image under >>> control within Python Image and Python file use. I wrote a file of >>> 307200 bytes in bytes, byte representation of characters. I >>> couldn't see anything within pyfits or numpy that would help me do >>> that. Now I believe I'm in a position to use pyfits to create a >>> fits format file. The next step is to arrange the image (data) >>> into a 640x480 array. I can do that in python, but would like to >>> know how it can be done in numpy, for the experience. The IDA >>> tutorial talks to making arrays, but I do not see where they work >>> with creating an array with fresh data. Once that's done, then I >>> should be able to work out from a reading of page 10 in the pyfits >>> manual. >>> >>> >> Hello Wayne, >> >> Could you post a sample script illustrating exactly what you want >> to do along with some sample output showing how it is failing to do >> so? >> >> Are you familiar with the numpy.ndarray.reshape() procedure? >> >> -- jv >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > -- > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet > All the neutrons, and protons in the human body > occupy a cube whose side is 5.52*10**-6 meters (tiny!). > That adds up to a 150 pound person. It's not a surprise that > we are mostly space. (Calculation by WTW) > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From Jim.Vickroy at noaa.gov Mon Apr 13 16:58:33 2009 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon, 13 Apr 2009 14:58:33 -0600 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E36A90.3080300@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> Message-ID: <49E3A779.30206@noaa.gov> Wayne Watson wrote: > Hi, not familiar with much of anything in numpy, then again, I'm not > anxious to read through the 300+ page manual. :-) > Well, let's see if I can explain this in py-talk. Here's a small > program I wrote to get the raw image > > #import Image > import string > > def make_array(): > im_array=[] > im_data=range(10) > print im_data > for j in range(2): > row=[] > for k in range(5): > item=hex(int(im_data[k+j*5])) > row.append(item) > im_array.append(row) > print im_array > > raw_file=open('sent_internal.raw','rb') > raw_image=raw_file.read() > raw_file.close() > print 'info:', len(raw_image), type(raw_image) > make_array() > > make_array, instead of working on the 307200 byte(640x480) string > representing the image, is used to see if I can generate a 2x5 array > like that apparently needed to represent the image to pyfits. The > above produces this: > info: 307200 > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] <--- my fictional 2x5 image as a py list. > [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] <--- the type of structure I > think numarray(numpy equivalent) wants. > > I'm looking at page 7 of the FITS manual, and I see in the middle, > hdulist[1].data. This appears to be where the data(image) goes. At the > top of page 10, the steps to construct a simple fits file are shown. > numarray is used. Simply put, how do I proceed from here? > > > I've attached the 'sent_internal.raw' file. It may cause this msg to > be rejected by the mail list. OK, here is a sample interactive session showing some features of numpy: >>> import numpy >>> numpy.__version__ '1.2.1' >>> data = numpy.arange(16, dtype=int) # use dtype=float, etc. as desired >>> data array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) >>> bytes = data.tostring() # equivalent of your raw data >>> bytes '\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\t\x00\x00\x00\n\x00\x00\x00\x0b\x00\x00\x00\x0c\x00\x00\x00\r\x00\x00\x00\x0e\x00\x00\x00\x0f\x00\x00\x00' >>> image = numpy.frombuffer(bytes, dtype=int) # dtype must be same as *data* above >>> image array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) >>> image = image.reshape((4,4)) array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> image HTH, -- jv > > Jim Vickroy wrote: >> Wayne Watson wrote: >> >>> I've pretty much gotten my 640x480 1 byte, "raw" image under control >>> within Python Image and Python file use. I wrote a file of 307200 >>> bytes in bytes, byte representation of characters. I couldn't see >>> anything within pyfits or numpy that would help me do that. Now I >>> believe I'm in a position to use pyfits to create a fits format >>> file. The next step is to arrange the image (data) into a 640x480 >>> array. I can do that in python, but would like to know how it can be >>> done in numpy, for the experience. The IDA tutorial talks to making >>> arrays, but I do not see where they work with creating an array with >>> fresh data. Once that's done, then I should be able to work out from >>> a reading of page 10 in the pyfits manual. >>> >>> >> Hello Wayne, >> >> Could you post a sample script illustrating exactly what you want to >> do along with some sample output showing how it is failing to do so? >> >> Are you familiar with the numpy.ndarray.reshape() procedure? >> >> -- jv >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > From erwin at mpe.mpg.de Mon Apr 13 17:04:59 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Mon, 13 Apr 2009 23:04:59 +0200 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E36A90.3080300@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> Message-ID: <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> Hi Wayne, OK, I read up a little on byte --> integer conversion, and the following seems to work (there may be a more elegant way of doing this, mind you): import struct, numpy, pyfits # struct is part of the main Python library # get raw data from .raw file: raw_file=open('sent_internal.raw','rb') raw_image=raw_file.read() raw_file.close() # convert raw data to Python list of integers (1-D): rawim_intarray = [] for x in raw_image: # convert byte to integer ('B' = treat data as single unsigned byte) newint = struct.unpack('B', x)[0] rawim_intarray.append(newint) # convert Python list of integers into numpy array of integers (note: still 1-D at this point) rawim_numpy = numpy.array(rawim_intarray) # reshape numpy array into 2D form, using our knowledge of the original image's # x and y sizes (kudos to Megan Sosey for pointing out how to do this) rawim_numpy_2d = numpy.reshape(rawim_numarray,(480, 640)) # create Pyfits header-data unit: hdu = pyfits.PrimaryHDU(rawim_numpy_2d) # (make any modifications to the header you might want to... e.g., see Megan Sosey's # email of April 8 for examples) # ... and save the data to disk as a FITS file: hdu.writeto("test.fits") That seemed to work for me... cheers, Peter On Apr 13, 2009, at 6:38 PM, Wayne Watson wrote: > Hi, not familiar with much of anything in numpy, then again, I'm not > anxious to read through the 300+ page manual. :-) > Well, let's see if I can explain this in py-talk. Here's a small > program I wrote to get the raw image > > #import Image > import string > > def make_array(): > im_array=[] > im_data=range(10) > print im_data > for j in range(2): > row=[] > for k in range(5): > item=hex(int(im_data[k+j*5])) > row.append(item) > im_array.append(row) > print im_array > > raw_file=open('sent_internal.raw','rb') > raw_image=raw_file.read() > raw_file.close() > print 'info:', len(raw_image), type(raw_image) > make_array() > > make_array, instead of working on the 307200 byte(640x480) string > representing the image, is used to see if I can generate a 2x5 array > like that apparently needed to represent the image to pyfits. The > above produces this: > info: 307200 > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] <--- my fictional 2x5 image as a py > list. > [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] <--- the type of structure I > think numarray(numpy equivalent) wants. > > I'm looking at page 7 of the FITS manual, and I see in the middle, > hdulist[1].data. This appears to be where the data(image) goes. At > the top of page 10, the steps to construct a simple fits file are > shown. numarray is used. Simply put, how do I proceed from here? > > > I've attached the 'sent_internal.raw' file. It may cause this msg to > be rejected by the mail list. > > Jim Vickroy wrote: >> Wayne Watson wrote: >> >>> I've pretty much gotten my 640x480 1 byte, "raw" image under >>> control within Python Image and Python file use. I wrote a file of >>> 307200 bytes in bytes, byte representation of characters. I >>> couldn't see anything within pyfits or numpy that would help me do >>> that. Now I believe I'm in a position to use pyfits to create a >>> fits format file. The next step is to arrange the image (data) >>> into a 640x480 array. I can do that in python, but would like to >>> know how it can be done in numpy, for the experience. The IDA >>> tutorial talks to making arrays, but I do not see where they work >>> with creating an array with fresh data. Once that's done, then I >>> should be able to work out from a reading of page 10 in the pyfits >>> manual. >>> >>> >> Hello Wayne, >> >> Could you post a sample script illustrating exactly what you want >> to do along with some sample output showing how it is failing to do >> so? >> >> Are you familiar with the numpy.ndarray.reshape() procedure? >> >> -- jv >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > -- > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet > All the neutrons, and protons in the human body > occupy a cube whose side is 5.52*10**-6 meters (tiny!). > That adds up to a 150 pound person. It's not a surprise that > we are mostly space. (Calculation by WTW) > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From peridot.faceted at gmail.com Mon Apr 13 17:32:34 2009 From: peridot.faceted at gmail.com (Anne Archibald) Date: Mon, 13 Apr 2009 17:32:34 -0400 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E36A90.3080300@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> Message-ID: 2009/4/13 Wayne Watson : > Hi, not familiar with much of anything in numpy, then again, I'm not anxious > to read through the 300+ page manual. :-) The manual is not the place to start. I'd look at several of the tutorials listed at http://www.scipy.org/Documentation . Even if their connection to what you want to do is not immediately obvious, they will give you a better idea of the easiest way to work with numerical arrays in python. > Well, let's see if I can explain this in py-talk. Here's a small program I > wrote to get the raw image > > #import Image > import string > > def make_array(): > im_array=[] > im_data=range(10) > print im_data > for j in range(2): > row=[] > for k in range(5): > item=hex(int(im_data[k+j*5])) > row.append(item) > im_array.append(row) > print im_array > > raw_file=open('sent_internal.raw','rb') > raw_image=raw_file.read() > raw_file.close() > print 'info:', len(raw_image), type(raw_image) > make_array() > > make_array, instead of working on the 307200 byte(640x480) string > representing the image, is used to see if I can generate a 2x5 array like > that apparently needed to represent the image to pyfits. The above produces > this: > info: 307200 > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] <--- my fictional 2x5 image as a py list. > [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] <--- the type of structure I think > numarray(numpy equivalent) wants. I strongly suspect that if your image is 640x480, pyfits wants a 640x480 array. Since your array is raw (unsigned?) bytes, this is fairly easy to do: # read in the file as unsigned 8-bit integers, giving a one-dimensional array array = numpy.fromfile("file.raw", dtype=numpy.uint8) # now reinterpret the same array as 640x480 array = numpy.reshape(array, (640,480)) Your most likely problem will be that the image will be mangled because you're writing it as 480x640 and reading it as 640x480; if this is what's happening you can instead do array = numpy.reshape(array, (640,480), order='FORTRAN') (The history here is that in C, an array of shape 640x480 puts the 480 elements in a column together, while FORTRAN would put the 640 elements in a row together. numpy can do either, but you have to tell it which you want. You probably want FORTRAN order.) If you also have matplotlib installed, you can try to view the output: import pylab pylab.imshow(array) pylab.show() > I'm looking at page 7 of the FITS manual, and I see in the middle, > hdulist[1].data. This appears to be where the data(image) goes. At the top > of page 10, the steps to construct a simple fits file are shown. numarray is > used. Simply put, how do I proceed from here? >From here I leave you to the people with more pyfits experience, but you will probably need to supply some metadata - date, time, lat/long, RA/Dec, field of view, some sort of brightness scale, et cetera - then hand pyfits your array. Good luck, Anne > > I've attached the 'sent_internal.raw' file. It may cause this msg to be > rejected by the mail list. > > Jim Vickroy wrote: >> >> Wayne Watson wrote: >> >>> >>> I've pretty much gotten my 640x480 1 byte, "raw" image under control >>> within Python Image and Python file use. I wrote a file of 307200 bytes in >>> bytes, byte representation of characters. I couldn't see anything within >>> pyfits or numpy that would help me do that. Now I believe I'm in a position >>> to use pyfits to create a fits format file. The next step is to arrange the >>> image (data) into a 640x480 array. I can do that in python, but would like >>> to know how it can be done in numpy, for the experience. The IDA tutorial >>> talks to making arrays, but I do not see where they work with creating an >>> array with fresh data. Once that's done, then I should be able to work out >>> from a reading of page 10 in the pyfits manual. >>> >>> >> >> Hello Wayne, >> >> Could you post a sample script illustrating exactly what you want to do >> along with some sample output showing how it is failing to do so? >> >> Are you familiar with the numpy.ndarray.reshape() procedure? >> >> -- jv >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > -- > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet > All the neutrons, and protons in the human body occupy a > cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a > 150 pound person. It's not a surprise that > we are mostly space. (Calculation by WTW) > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > From erwin at mpe.mpg.de Tue Apr 14 07:26:00 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Tue, 14 Apr 2009 13:26:00 +0200 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E410ED.4080402@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> Message-ID: <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> Hi Wayne, Anne Archibald pointed out a much more concise and elegant way to read in and convert the raw file, using a function in Numpy. So you could replace the following original code: > # get raw data from .raw file: > raw_file=open('sent_internal.raw','rb') > raw_image=raw_file.read() > raw_file.close() > > # convert raw data to Python list of integers (1-D): > rawim_intarray = [] > for x in raw_image: > # convert byte to integer ('B' = treat data as single unsigned byte) > newint = struct.unpack('B', x)[0] > rawim_intarray.append(newint) > > # convert Python list of integers into numpy array of integers > (note: still 1-D at this point) > rawim_numpy = numpy.array(rawim_intarray) with this: rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='B') [note: dtype='B' is identical to dtype=numpy.uint8, which Anne used in her example] and then continue as before. This has the added benefit of producing a smaller output file (300 KB vs 1.2 MB), since the numpy array is now explicitly in 8-bit-integer form (rather than the 32-bit-integer form that my code created), and so Pyfits will automatically save it as 8-bit integers (you can check this by looking at the header keyword BITPIX). You're right, the raw image is a sequence of (standard) 8-bit bytes. Well, all computer files are streams of bytes; the question is how to interpret them. Since you said earlier that it was supposed to be 8-bit values, the idea is then to interpret each individual byte as an unsigned "integer" value (values from 0 to 255); that's what the "dtype='B'" (or "dtype=numpy.uint8") option passed to numpy.fromfile() does. (My previous code did the same thing, but then assigned each value to a standard Python integer, which is 4 bytes long; perfectly workable, but a bit wasteful!). Anyway, when I do this, I can see an image in DS9 (a circular aperture with ragged edges and an overall horizontal gradient inside the aperture). So I'm pretty sure it's working. (I've attached a jpeg saved from DS9 to show what the image looks like.) I don't think I can help you with this "ccdsoft" program; I'm not familiar with it. If it's a Windows program, then it may expect all FITS files to end in ".fit" instead of ".fits", just because Windows traditionally expects files to have 3- letter extensions. As for overwriting an existing FITS file, try this: hdu.writeto("existing_file_name.fit", clobber=True) cheers, Peter -------------- next part -------------- A non-text attachment was scrubbed... Name: test.jpg Type: image/jpeg Size: 19595 bytes Desc: not available URL: -------------- next part -------------- On Apr 14, 2009, at 6:28 AM, Wayne Watson wrote: > Hi, Peter. It looks like I confused a few people with the hex. I had > removed it, but only after I placed the code in the msg. I was > playing with hex in the event I might need it somehow. int was fine > for my experimental purposes. > > Here's your code with a minor correction. I changed this line: > rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) > The difference is rawmin_numpy. > I added a print at the end, and threw in two lines that attempt to > put header info into the final file. Continuing below the code. > > =====================Start=============== > import struct, numpy, pyfits # struct is part of the main Python > library > > # get raw data from .raw file: > raw_file=open('sent_internal.raw','rb') > raw_image=raw_file.read() > raw_file.close() > > # convert raw data to Python list of integers (1-D): > rawim_intarray = [] > for x in raw_image: > # convert byte to integer ('B' = treat data as single unsigned byte) > newint = struct.unpack('B', x)[0] > rawim_intarray.append(newint) > > # convert Python list of integers into numpy array of integers > (note: still 1-D at this point) > rawim_numpy = numpy.array(rawim_intarray) > > # reshape numpy array into 2D form, using our knowledge of the > original image's > # x and y sizes (kudos to Megan Sosey for pointing out how to do this) > rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) > > # create Pyfits header-data unit: > hdu = pyfits.PrimaryHDU(rawim_numpy_2d) > hdu.header.update('LATOBS',"32:11:56") > hdu.header.update('LNGOBS',"120:00:00") > > # (make any modifications to the header you might want to... e.g., > see Megan Sosey's > # email of April 8 for examples) > > # ... and save the data to disk as a FITS file: > hdu.writeto("test.fits") > print "Finished. See test.fits" > ===============End code============ > > I'm not sure what the 'byte' stuff is about. It may be that it's not > needed. I think the original 'raw' file is byte oriented--rather > than int or whatever. Anyway, I don't seem to have succeeded in > getting header info into the file. Sort of. If I use DS9, I can see > the image and the fits header with what I coded into it. Here's what > I see with ds9. > > *However, with my ccdsoft program, te image is black and the header > is not the same. Whoops. Interesting. I changed the file to test.fit > instead of test.fits, and the header info is there, but the image is > still black. The dimension are the same, 640x480. I'm attaching test- > ww.fits. I just renamed my test.fits. I think I'll check with The > Bisque (ccdsoft) to see what format they produce and use for the raw > image. > Question. When I execute the program a second time, the > *hdu.writeto("test.fits") *will not write over the old file. Is > there an option to force the write? > > Well, this is all good progress. ** * > > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet > All the neutrons, and protons in the human body occupy > a cube whose side is 5.52*10**-6 meters (tiny!). That > adds up to a 150 pound person. It's not a surprise that > we are mostly space. (Calculation by WTW) ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From sierra_mtnview at sbcglobal.net Tue Apr 14 08:18:57 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 05:18:57 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> Message-ID: <49E47F31.9000007@sbcglobal.net> Hi, I'm headed back to sleep. I'll just mention the circular picture is the view of the sky from my fisheye camera. The perimeter is the horizon with trees. There are a few clouds in the sky, bands. later ... zzzzzzzzz Peter Erwin wrote: > Hi Wayne, > > Anne Archibald pointed out a much more concise and elegant way to read in > and convert the raw file, using a function in Numpy. So you could > replace the > following original code: > >> # get raw data from .raw file: >> raw_file=open('sent_internal.raw','rb') >> raw_image=raw_file.read() >> raw_file.close() >> >> # convert raw data to Python list of integers (1-D): >> rawim_intarray = [] >> for x in raw_image: >> # convert byte to integer ('B' = treat data as single unsigned byte) >> newint = struct.unpack('B', x)[0] >> rawim_intarray.append(newint) >> >> # convert Python list of integers into numpy array of integers (note: >> still 1-D at this point) >> rawim_numpy = numpy.array(rawim_intarray) > > with this: > > rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='B') > > [note: dtype='B' is identical to dtype=numpy.uint8, which Anne used in > her example] > > and then continue as before. > > This has the added benefit of producing a smaller output file (300 KB vs > 1.2 MB), since the numpy array is now explicitly in 8-bit-integer form > (rather than the 32-bit-integer form that my code created), and so > Pyfits will automatically save it as 8-bit integers (you can check this > by looking at the header keyword BITPIX). > > > You're right, the raw image is a sequence of (standard) 8-bit bytes. > Well, all > computer files are streams of bytes; the question is how to interpret > them. Since > you said earlier that it was supposed to be 8-bit values, the idea is > then to > interpret each individual byte as an unsigned "integer" value (values > from 0 to 255); > that's what the "dtype='B'" (or "dtype=numpy.uint8") option passed to > numpy.fromfile() > does. (My previous code did the same thing, but then assigned each > value to a > standard Python integer, which is 4 bytes long; perfectly workable, > but a bit > wasteful!). > > Anyway, when I do this, I can see an image in DS9 (a circular aperture > with ragged > edges and an overall horizontal gradient inside the aperture). So I'm > pretty sure > it's working. (I've attached a jpeg saved from DS9 to show what the > image looks like.) > > I don't think I can help you with this "ccdsoft" program; I'm not > familiar with it. > If it's a Windows program, then it may expect all FITS files to end in > ".fit" instead > of ".fits", just because Windows traditionally expects files to have > 3-letter extensions. > > > As for overwriting an existing FITS file, try this: > > hdu.writeto("existing_file_name.fit", clobber=True) > > cheers, > > Peter > > > > ------------------------------------------------------------------------ > > > > > On Apr 14, 2009, at 6:28 AM, Wayne Watson wrote: > >> Hi, Peter. It looks like I confused a few people with the hex. I had >> removed it, but only after I placed the code in the msg. I was >> playing with hex in the event I might need it somehow. int was fine >> for my experimental purposes. >> >> Here's your code with a minor correction. I changed this line: >> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >> The difference is rawmin_numpy. >> I added a print at the end, and threw in two lines that attempt to >> put header info into the final file. Continuing below the code. >> >> =====================Start=============== >> import struct, numpy, pyfits # struct is part of the main Python >> library >> >> # get raw data from .raw file: >> raw_file=open('sent_internal.raw','rb') >> raw_image=raw_file.read() >> raw_file.close() >> >> # convert raw data to Python list of integers (1-D): >> rawim_intarray = [] >> for x in raw_image: >> # convert byte to integer ('B' = treat data as single unsigned byte) >> newint = struct.unpack('B', x)[0] >> rawim_intarray.append(newint) >> >> # convert Python list of integers into numpy array of integers (note: >> still 1-D at this point) >> rawim_numpy = numpy.array(rawim_intarray) >> >> # reshape numpy array into 2D form, using our knowledge of the >> original image's >> # x and y sizes (kudos to Megan Sosey for pointing out how to do this) >> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >> >> # create Pyfits header-data unit: >> hdu = pyfits.PrimaryHDU(rawim_numpy_2d) >> hdu.header.update('LATOBS',"32:11:56") >> hdu.header.update('LNGOBS',"120:00:00") >> >> # (make any modifications to the header you might want to... e.g., >> see Megan Sosey's >> # email of April 8 for examples) >> >> # ... and save the data to disk as a FITS file: >> hdu.writeto("test.fits") >> print "Finished. See test.fits" >> ===============End code============ >> >> I'm not sure what the 'byte' stuff is about. It may be that it's not >> needed. I think the original 'raw' file is byte oriented--rather than >> int or whatever. Anyway, I don't seem to have succeeded in getting >> header info into the file. Sort of. If I use DS9, I can see the image >> and the fits header with what I coded into it. Here's what I see with >> ds9. >> >> *However, with my ccdsoft program, te image is black and the header >> is not the same. Whoops. Interesting. I changed the file to test.fit >> instead of test.fits, and the header info is there, but the image is >> still black. The dimension are the same, 640x480. I'm attaching >> test-ww.fits. I just renamed my test.fits. I think I'll check with >> The Bisque (ccdsoft) to see what format they produce and use for the >> raw image. >> Question. When I execute the program a second time, the >> *hdu.writeto("test.fits") *will not write over the old file. Is there >> an option to force the write? >> >> Well, this is all good progress. ** * >> >> -- >> >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >> All the neutrons, and protons in the human body occupy >> a cube whose side is 5.52*10**-6 meters (tiny!). That >> adds up to a 150 pound person. It's not a surprise that >> we are mostly space. (Calculation by WTW) > > ============================================================= > Peter Erwin Max-Planck-Insitute for Extraterrestrial > erwin at mpe.mpg.de Physics, Giessenbachstrasse > tel. +49 (0)89 30000 3695 85748 Garching, Germany > fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin > > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Tue Apr 14 11:23:28 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 08:23:28 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> Message-ID: <49E4AA70.8080302@sbcglobal.net> Howdy, I think I see the ccdsoft problem. I looked at a fit (fits) file I produced with my CCD camera using it, and it produces a uint16 (BITPIX=16). I just made the change you suggested, and the resulting file shows BITPIX=8, but CCDSoft liked it. Apparently, it objected to the 32 bit image earlier, which probably gave rise to the black image. The former way produced a file of 1,204KB, and the current file produced sized with the simple replacement produced a file of 304KB. I used dtype='uint8' instead of 'B'. Somewhere along the line I confused myself with the numarray use in the FITS manual, and apparently its look-alike notion ( as seen via arange and reshape) in numpy. Maybe they are equivalent in every respect. I was trying to figure out how to get Python to put together a 'matrix' (mathematical sense) to feed it to data, but it looks like reshape is the ticket. reshape seems missing from numarray (not mentioned in the fits manual), so maybe there is a difference. I'm not sure the pyfits manual ever showed how to make a 'matrix' and stuff it into the data portion of a FITS header (maybe that's what section 2.2.3 is about, which interestingly has the same title as 2.2.2). I think we are pretty much, successfully, done here. Allowing the meteor program I'm adding new features to be able to use FITS will be a very useful change. Some exposure to pyfits and numpy helps too from the coding aspects. Of course, if I decide to add features that allow FITS files into the program, say, for IP (img processing) work, that'll require some unraveling of the data part of the fits file for PIL/Tinter. Later though. Thanks for the help. Peter Erwin wrote: > Hi Wayne, > > Anne Archibald pointed out a much more concise and elegant way to read in > and convert the raw file, using a function in Numpy. So you could > replace the > following original code: > >> # get raw data from .raw file: >> raw_file=open('sent_internal.raw','rb') >> raw_image=raw_file.read() >> raw_file.close() >> >> # convert raw data to Python list of integers (1-D): >> rawim_intarray = [] >> for x in raw_image: >> # convert byte to integer ('B' = treat data as single unsigned byte) >> newint = struct.unpack('B', x)[0] >> rawim_intarray.append(newint) >> >> # convert Python list of integers into numpy array of integers (note: >> still 1-D at this point) >> rawim_numpy = numpy.array(rawim_intarray) > > with this: > > rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='B') > > [note: dtype='B' is identical to dtype=numpy.uint8, which Anne used in > her example] > > and then continue as before. > > This has the added benefit of producing a smaller output file (300 KB vs > 1.2 MB), since the numpy array is now explicitly in 8-bit-integer form > (rather than the 32-bit-integer form that my code created), and so > Pyfits will automatically save it as 8-bit integers (you can check this > by looking at the header keyword BITPIX). > > > You're right, the raw image is a sequence of (standard) 8-bit bytes. > Well, all > computer files are streams of bytes; the question is how to interpret > them. Since > you said earlier that it was supposed to be 8-bit values, the idea is > then to > interpret each individual byte as an unsigned "integer" value (values > from 0 to 255); > that's what the "dtype='B'" (or "dtype=numpy.uint8") option passed to > numpy.fromfile() > does. (My previous code did the same thing, but then assigned each > value to a > standard Python integer, which is 4 bytes long; perfectly workable, > but a bit > wasteful!). > > Anyway, when I do this, I can see an image in DS9 (a circular aperture > with ragged > edges and an overall horizontal gradient inside the aperture). So I'm > pretty sure > it's working. (I've attached a jpeg saved from DS9 to show what the > image looks like.) > > I don't think I can help you with this "ccdsoft" program; I'm not > familiar with it. > If it's a Windows program, then it may expect all FITS files to end in > ".fit" instead > of ".fits", just because Windows traditionally expects files to have > 3-letter extensions. > > > As for overwriting an existing FITS file, try this: > > hdu.writeto("existing_file_name.fit", clobber=True) > > cheers, > > Peter > > > > ------------------------------------------------------------------------ > > > > > On Apr 14, 2009, at 6:28 AM, Wayne Watson wrote: > >> Hi, Peter. It looks like I confused a few people with the hex. I had >> removed it, but only after I placed the code in the msg. I was >> playing with hex in the event I might need it somehow. int was fine >> for my experimental purposes. >> >> Here's your code with a minor correction. I changed this line: >> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >> The difference is rawmin_numpy. >> I added a print at the end, and threw in two lines that attempt to >> put header info into the final file. Continuing below the code. >> >> =====================Start=============== >> import struct, numpy, pyfits # struct is part of the main Python >> library >> >> # get raw data from .raw file: >> raw_file=open('sent_internal.raw','rb') >> raw_image=raw_file.read() >> raw_file.close() >> >> # convert raw data to Python list of integers (1-D): >> rawim_intarray = [] >> for x in raw_image: >> # convert byte to integer ('B' = treat data as single unsigned byte) >> newint = struct.unpack('B', x)[0] >> rawim_intarray.append(newint) >> >> # convert Python list of integers into numpy array of integers (note: >> still 1-D at this point) >> rawim_numpy = numpy.array(rawim_intarray) >> >> # reshape numpy array into 2D form, using our knowledge of the >> original image's >> # x and y sizes (kudos to Megan Sosey for pointing out how to do this) >> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >> >> # create Pyfits header-data unit: >> hdu = pyfits.PrimaryHDU(rawim_numpy_2d) >> hdu.header.update('LATOBS',"32:11:56") >> hdu.header.update('LNGOBS',"120:00:00") >> >> # (make any modifications to the header you might want to... e.g., >> see Megan Sosey's >> # email of April 8 for examples) >> >> # ... and save the data to disk as a FITS file: >> hdu.writeto("test.fits") >> print "Finished. See test.fits" >> ===============End code============ >> >> I'm not sure what the 'byte' stuff is about. It may be that it's not >> needed. I think the original 'raw' file is byte oriented--rather than >> int or whatever. Anyway, I don't seem to have succeeded in getting >> header info into the file. Sort of. If I use DS9, I can see the image >> and the fits header with what I coded into it. Here's what I see with >> ds9. >> >> *However, with my ccdsoft program, te image is black and the header >> is not the same. Whoops. Interesting. I changed the file to test.fit >> instead of test.fits, and the header info is there, but the image is >> still black. The dimension are the same, 640x480. I'm attaching >> test-ww.fits. I just renamed my test.fits. I think I'll check with >> The Bisque (ccdsoft) to see what format they produce and use for the >> raw image. >> Question. When I execute the program a second time, the >> *hdu.writeto("test.fits") *will not write over the old file. Is there >> an option to force the write? >> >> Well, this is all good progress. ** * >> >> -- >> >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >> All the neutrons, and protons in the human body occupy >> a cube whose side is 5.52*10**-6 meters (tiny!). That >> adds up to a 150 pound person. It's not a surprise that >> we are mostly space. (Calculation by WTW) > > ============================================================= > Peter Erwin Max-Planck-Insitute for Extraterrestrial > erwin at mpe.mpg.de Physics, Giessenbachstrasse > tel. +49 (0)89 30000 3695 85748 Garching, Germany > fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin > > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From Jim.Vickroy at noaa.gov Tue Apr 14 11:35:04 2009 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 14 Apr 2009 09:35:04 -0600 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4AA70.8080302@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> Message-ID: <49E4AD28.10801@noaa.gov> At the risk of stating the obvious, you should only be using numpy (not numarray). Numarray was a competing package that pyfits previously supported. Numarray is deprecated and the recent releases of pyfits have complete support for numpy. -- jv Wayne Watson wrote: > Howdy, I think I see the ccdsoft problem. I looked at a fit (fits) file > I produced with my CCD camera using it, and it produces a uint16 > (BITPIX=16). I just made the change you suggested, and the resulting > file shows BITPIX=8, but CCDSoft liked it. Apparently, it objected to > the 32 bit image earlier, which probably gave rise to the black image. > The former way produced a file of 1,204KB, and the current file produced > sized with the simple replacement produced a file of 304KB. I used > dtype='uint8' instead of 'B'. > > Somewhere along the line I confused myself with the numarray use in the > FITS manual, and apparently its look-alike notion ( as seen via arange > and reshape) in numpy. Maybe they are equivalent in every respect. I was > trying to figure out how to get Python to put together a 'matrix' > (mathematical sense) to feed it to data, but it looks like reshape is > the ticket. reshape seems missing from numarray (not mentioned in the > fits manual), so maybe there is a difference. I'm not sure the pyfits > manual ever showed how to make a 'matrix' and stuff it into the data > portion of a FITS header (maybe that's what section 2.2.3 is about, > which interestingly has the same title as 2.2.2). > > I think we are pretty much, successfully, done here. Allowing the meteor > program I'm adding new features to be able to use FITS will be a very > useful change. Some exposure to pyfits and numpy helps too from the > coding aspects. Of course, if I decide to add features that allow FITS > files into the program, say, for IP (img processing) work, that'll > require some unraveling of the data part of the fits file for > PIL/Tinter. Later though. > > Thanks for the help. > > Peter Erwin wrote: > >> Hi Wayne, >> >> Anne Archibald pointed out a much more concise and elegant way to read in >> and convert the raw file, using a function in Numpy. So you could >> replace the >> following original code: >> >> >>> # get raw data from .raw file: >>> raw_file=open('sent_internal.raw','rb') >>> raw_image=raw_file.read() >>> raw_file.close() >>> >>> # convert raw data to Python list of integers (1-D): >>> rawim_intarray = [] >>> for x in raw_image: >>> # convert byte to integer ('B' = treat data as single unsigned byte) >>> newint = struct.unpack('B', x)[0] >>> rawim_intarray.append(newint) >>> >>> # convert Python list of integers into numpy array of integers (note: >>> still 1-D at this point) >>> rawim_numpy = numpy.array(rawim_intarray) >>> >> with this: >> >> rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='B') >> >> [note: dtype='B' is identical to dtype=numpy.uint8, which Anne used in >> her example] >> >> and then continue as before. >> >> This has the added benefit of producing a smaller output file (300 KB vs >> 1.2 MB), since the numpy array is now explicitly in 8-bit-integer form >> (rather than the 32-bit-integer form that my code created), and so >> Pyfits will automatically save it as 8-bit integers (you can check this >> by looking at the header keyword BITPIX). >> >> >> You're right, the raw image is a sequence of (standard) 8-bit bytes. >> Well, all >> computer files are streams of bytes; the question is how to interpret >> them. Since >> you said earlier that it was supposed to be 8-bit values, the idea is >> then to >> interpret each individual byte as an unsigned "integer" value (values >> from 0 to 255); >> that's what the "dtype='B'" (or "dtype=numpy.uint8") option passed to >> numpy.fromfile() >> does. (My previous code did the same thing, but then assigned each >> value to a >> standard Python integer, which is 4 bytes long; perfectly workable, >> but a bit >> wasteful!). >> >> Anyway, when I do this, I can see an image in DS9 (a circular aperture >> with ragged >> edges and an overall horizontal gradient inside the aperture). So I'm >> pretty sure >> it's working. (I've attached a jpeg saved from DS9 to show what the >> image looks like.) >> >> I don't think I can help you with this "ccdsoft" program; I'm not >> familiar with it. >> If it's a Windows program, then it may expect all FITS files to end in >> ".fit" instead >> of ".fits", just because Windows traditionally expects files to have >> 3-letter extensions. >> >> >> As for overwriting an existing FITS file, try this: >> >> hdu.writeto("existing_file_name.fit", clobber=True) >> >> cheers, >> >> Peter >> >> >> >> ------------------------------------------------------------------------ >> >> >> >> >> On Apr 14, 2009, at 6:28 AM, Wayne Watson wrote: >> >> >>> Hi, Peter. It looks like I confused a few people with the hex. I had >>> removed it, but only after I placed the code in the msg. I was >>> playing with hex in the event I might need it somehow. int was fine >>> for my experimental purposes. >>> >>> Here's your code with a minor correction. I changed this line: >>> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >>> The difference is rawmin_numpy. >>> I added a print at the end, and threw in two lines that attempt to >>> put header info into the final file. Continuing below the code. >>> >>> =====================Start=============== >>> import struct, numpy, pyfits # struct is part of the main Python >>> library >>> >>> # get raw data from .raw file: >>> raw_file=open('sent_internal.raw','rb') >>> raw_image=raw_file.read() >>> raw_file.close() >>> >>> # convert raw data to Python list of integers (1-D): >>> rawim_intarray = [] >>> for x in raw_image: >>> # convert byte to integer ('B' = treat data as single unsigned byte) >>> newint = struct.unpack('B', x)[0] >>> rawim_intarray.append(newint) >>> >>> # convert Python list of integers into numpy array of integers (note: >>> still 1-D at this point) >>> rawim_numpy = numpy.array(rawim_intarray) >>> >>> # reshape numpy array into 2D form, using our knowledge of the >>> original image's >>> # x and y sizes (kudos to Megan Sosey for pointing out how to do this) >>> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >>> >>> # create Pyfits header-data unit: >>> hdu = pyfits.PrimaryHDU(rawim_numpy_2d) >>> hdu.header.update('LATOBS',"32:11:56") >>> hdu.header.update('LNGOBS',"120:00:00") >>> >>> # (make any modifications to the header you might want to... e.g., >>> see Megan Sosey's >>> # email of April 8 for examples) >>> >>> # ... and save the data to disk as a FITS file: >>> hdu.writeto("test.fits") >>> print "Finished. See test.fits" >>> ===============End code============ >>> >>> I'm not sure what the 'byte' stuff is about. It may be that it's not >>> needed. I think the original 'raw' file is byte oriented--rather than >>> int or whatever. Anyway, I don't seem to have succeeded in getting >>> header info into the file. Sort of. If I use DS9, I can see the image >>> and the fits header with what I coded into it. Here's what I see with >>> ds9. >>> >>> *However, with my ccdsoft program, te image is black and the header >>> is not the same. Whoops. Interesting. I changed the file to test.fit >>> instead of test.fits, and the header info is there, but the image is >>> still black. The dimension are the same, 640x480. I'm attaching >>> test-ww.fits. I just renamed my test.fits. I think I'll check with >>> The Bisque (ccdsoft) to see what format they produce and use for the >>> raw image. >>> Question. When I execute the program a second time, the >>> *hdu.writeto("test.fits") *will not write over the old file. Is there >>> an option to force the write? >>> >>> Well, this is all good progress. ** * >>> >>> -- >>> >>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>> >>> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >>> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >>> All the neutrons, and protons in the human body occupy >>> a cube whose side is 5.52*10**-6 meters (tiny!). That >>> adds up to a 150 pound person. It's not a surprise that >>> we are mostly space. (Calculation by WTW) >>> >> ============================================================= >> Peter Erwin Max-Planck-Insitute for Extraterrestrial >> erwin at mpe.mpg.de Physics, Giessenbachstrasse >> tel. +49 (0)89 30000 3695 85748 Garching, Germany >> fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin >> >> >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Tue Apr 14 11:49:43 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 08:49:43 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> Message-ID: <49E4B097.804@sbcglobal.net> Thanks. I see they have a tutorial. I wish it were in pdf format. I like to read from paper. It looks like the tutorial is probably painless, maybe a 30 min read. If I get desperate, I could convert it to a pdf with Acrobat. :-) I see this intriguing comment, "In addition, on this webpage, you can improve the docs!" There is mention that some of the docs are out of date. That's ripe for a soap box comment from me about the general documentation on the web. It seems writing and improving code is far more important than keeping documentation up to date. In some commercial products they seem driven by keeping up with the competition, expecting the user to ferret out new features via program Help. It happens in the non-commercial world too, but for different reasons. OK, I'll stop now. :-) Anne Archibald wrote: > 2009/4/13 Wayne Watson : > >> Hi, not familiar with much of anything in numpy, then again, I'm not anxious >> to read through the 300+ page manual. :-) >> > > The manual is not the place to start. I'd look at several of the > tutorials listed at http://www.scipy.org/Documentation . Even if their > connection to what you want to do is not immediately obvious, they > will give you a better idea of the easiest way to work with numerical > arrays in python. > > ... -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From erwin at mpe.mpg.de Tue Apr 14 11:58:23 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Tue, 14 Apr 2009 17:58:23 +0200 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4AD28.10801@noaa.gov> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> Message-ID: <2A2199FD-CD1A-4B9C-A402-72B61FDE48A8@mpe.mpg.de> A bit more background, which might explain some of the confusion: Originally, there was a package called Numeric Python, which was sometimes unofficially called "NumPy". A few years ago, some people (mostly at STScI, I think) created a modified version which they called numarray; the original versions of pyfits used this, which is why the version 1.0 manual of pyfits mentions numarray. More recently, the numarray and Numeric Python folks agreed to merge projects and create an updated package, now called numpy. All the up-to-date versions of array-using packages, including pyfits, now use numpy. (I'm probably glossing over some fine details, but I think that gives you the basic picture.) So, as Jim said, just use numpy. (Things are much less confusing now than they were a couple of years ago, when numpy was new and numarray was still being supported...) (You can still find code on the web that was written back when Numeric Python was the only thing around; *most* -- but not all -- Numeric functions, object, etc., are the same as the current numpy versions, so you can often update such code to use numpy without much trouble.) cheers, Peter On Apr 14, 2009, at 5:35 PM, Jim Vickroy wrote: > At the risk of stating the obvious, you should only be using numpy > (not numarray). Numarray was a competing package that pyfits > previously supported. Numarray is deprecated and the recent > releases of pyfits have complete support for numpy. > > -- jv > > Wayne Watson wrote: >> >> Howdy, I think I see the ccdsoft problem. I looked at a fit (fits) >> file >> I produced with my CCD camera using it, and it produces a uint16 >> (BITPIX=16). I just made the change you suggested, and the resulting >> file shows BITPIX=8, but CCDSoft liked it. Apparently, it objected to >> the 32 bit image earlier, which probably gave rise to the black >> image. >> The former way produced a file of 1,204KB, and the current file >> produced >> sized with the simple replacement produced a file of 304KB. I used >> dtype='uint8' instead of 'B'. >> >> Somewhere along the line I confused myself with the numarray use in >> the >> FITS manual, and apparently its look-alike notion ( as seen via >> arange >> and reshape) in numpy. Maybe they are equivalent in every respect. >> I was >> trying to figure out how to get Python to put together a 'matrix' >> (mathematical sense) to feed it to data, but it looks like reshape is >> the ticket. reshape seems missing from numarray (not mentioned in the >> fits manual), so maybe there is a difference. I'm not sure the pyfits >> manual ever showed how to make a 'matrix' and stuff it into the data >> portion of a FITS header (maybe that's what section 2.2.3 is about, >> which interestingly has the same title as 2.2.2). >> >> I think we are pretty much, successfully, done here. Allowing the >> meteor >> program I'm adding new features to be able to use FITS will be a very >> useful change. Some exposure to pyfits and numpy helps too from the >> coding aspects. Of course, if I decide to add features that allow >> FITS >> files into the program, say, for IP (img processing) work, that'll >> require some unraveling of the data part of the fits file for >> PIL/Tinter. Later though. >> >> Thanks for the help. >> >> Peter Erwin wrote: >> >>> Hi Wayne, >>> >>> Anne Archibald pointed out a much more concise and elegant way to >>> read in >>> and convert the raw file, using a function in Numpy. So you could >>> replace the >>> following original code: >>> >>> >>>> # get raw data from .raw file: >>>> raw_file=open('sent_internal.raw','rb') >>>> raw_image=raw_file.read() >>>> raw_file.close() >>>> >>>> # convert raw data to Python list of integers (1-D): >>>> rawim_intarray = [] >>>> for x in raw_image: >>>> # convert byte to integer ('B' = treat data as single unsigned >>>> byte) >>>> newint = struct.unpack('B', x)[0] >>>> rawim_intarray.append(newint) >>>> >>>> # convert Python list of integers into numpy array of integers >>>> (note: >>>> still 1-D at this point) >>>> rawim_numpy = numpy.array(rawim_intarray) >>>> >>> with this: >>> >>> rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='B') >>> >>> [note: dtype='B' is identical to dtype=numpy.uint8, which Anne >>> used in >>> her example] >>> >>> and then continue as before. >>> >>> This has the added benefit of producing a smaller output file (300 >>> KB vs >>> 1.2 MB), since the numpy array is now explicitly in 8-bit-integer >>> form >>> (rather than the 32-bit-integer form that my code created), and so >>> Pyfits will automatically save it as 8-bit integers (you can check >>> this >>> by looking at the header keyword BITPIX). >>> >>> >>> You're right, the raw image is a sequence of (standard) 8-bit bytes. >>> Well, all >>> computer files are streams of bytes; the question is how to >>> interpret >>> them. Since >>> you said earlier that it was supposed to be 8-bit values, the idea >>> is >>> then to >>> interpret each individual byte as an unsigned "integer" value >>> (values >>> from 0 to 255); >>> that's what the "dtype='B'" (or "dtype=numpy.uint8") option passed >>> to >>> numpy.fromfile() >>> does. (My previous code did the same thing, but then assigned each >>> value to a >>> standard Python integer, which is 4 bytes long; perfectly workable, >>> but a bit >>> wasteful!). >>> >>> Anyway, when I do this, I can see an image in DS9 (a circular >>> aperture >>> with ragged >>> edges and an overall horizontal gradient inside the aperture). So >>> I'm >>> pretty sure >>> it's working. (I've attached a jpeg saved from DS9 to show what the >>> image looks like.) >>> >>> I don't think I can help you with this "ccdsoft" program; I'm not >>> familiar with it. >>> If it's a Windows program, then it may expect all FITS files to >>> end in >>> ".fit" instead >>> of ".fits", just because Windows traditionally expects files to have >>> 3-letter extensions. >>> >>> >>> As for overwriting an existing FITS file, try this: >>> >>> hdu.writeto("existing_file_name.fit", clobber=True) >>> >>> cheers, >>> >>> Peter >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> >>> >>> >>> On Apr 14, 2009, at 6:28 AM, Wayne Watson wrote: >>> >>> >>>> Hi, Peter. It looks like I confused a few people with the hex. I >>>> had >>>> removed it, but only after I placed the code in the msg. I was >>>> playing with hex in the event I might need it somehow. int was fine >>>> for my experimental purposes. >>>> >>>> Here's your code with a minor correction. I changed this line: >>>> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >>>> The difference is rawmin_numpy. >>>> I added a print at the end, and threw in two lines that attempt to >>>> put header info into the final file. Continuing below the code. >>>> >>>> =====================Start=============== >>>> import struct, numpy, pyfits # struct is part of the main Python >>>> library >>>> >>>> # get raw data from .raw file: >>>> raw_file=open('sent_internal.raw','rb') >>>> raw_image=raw_file.read() >>>> raw_file.close() >>>> >>>> # convert raw data to Python list of integers (1-D): >>>> rawim_intarray = [] >>>> for x in raw_image: >>>> # convert byte to integer ('B' = treat data as single unsigned >>>> byte) >>>> newint = struct.unpack('B', x)[0] >>>> rawim_intarray.append(newint) >>>> >>>> # convert Python list of integers into numpy array of integers >>>> (note: >>>> still 1-D at this point) >>>> rawim_numpy = numpy.array(rawim_intarray) >>>> >>>> # reshape numpy array into 2D form, using our knowledge of the >>>> original image's >>>> # x and y sizes (kudos to Megan Sosey for pointing out how to do >>>> this) >>>> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >>>> >>>> # create Pyfits header-data unit: >>>> hdu = pyfits.PrimaryHDU(rawim_numpy_2d) >>>> hdu.header.update('LATOBS',"32:11:56") >>>> hdu.header.update('LNGOBS',"120:00:00") >>>> >>>> # (make any modifications to the header you might want to... e.g., >>>> see Megan Sosey's >>>> # email of April 8 for examples) >>>> >>>> # ... and save the data to disk as a FITS file: >>>> hdu.writeto("test.fits") >>>> print "Finished. See test.fits" >>>> ===============End code============ >>>> >>>> I'm not sure what the 'byte' stuff is about. It may be that it's >>>> not >>>> needed. I think the original 'raw' file is byte oriented--rather >>>> than >>>> int or whatever. Anyway, I don't seem to have succeeded in getting >>>> header info into the file. Sort of. If I use DS9, I can see the >>>> image >>>> and the fits header with what I coded into it. Here's what I see >>>> with >>>> ds9. >>>> >>>> *However, with my ccdsoft program, te image is black and the header >>>> is not the same. Whoops. Interesting. I changed the file to >>>> test.fit >>>> instead of test.fits, and the header info is there, but the image >>>> is >>>> still black. The dimension are the same, 640x480. I'm attaching >>>> test-ww.fits. I just renamed my test.fits. I think I'll check with >>>> The Bisque (ccdsoft) to see what format they produce and use for >>>> the >>>> raw image. >>>> Question. When I execute the program a second time, the >>>> *hdu.writeto("test.fits") *will not write over the old file. Is >>>> there >>>> an option to force the write? >>>> >>>> Well, this is all good progress. ** * >>>> >>>> -- >>>> >>>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>>> >>>> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >>>> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >>>> All the neutrons, and protons in the human body occupy >>>> a cube whose side is 5.52*10**-6 meters (tiny!). That >>>> adds up to a 150 pound person. It's not a surprise that >>>> we are mostly space. (Calculation by WTW) >>>> >>> ============================================================= >>> Peter Erwin Max-Planck-Insitute for >>> Extraterrestrial >>> erwin at mpe.mpg.de Physics, Giessenbachstrasse >>> tel. +49 (0)89 30000 3695 85748 Garching, Germany >>> fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin >>> >>> >>> >>> >> > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From jturner at gemini.edu Tue Apr 14 12:24:02 2009 From: jturner at gemini.edu (James Turner) Date: Tue, 14 Apr 2009 12:24:02 -0400 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4B097.804@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <49E4B097.804@sbcglobal.net> Message-ID: <49E4B8A2.8010703@gemini.edu> > I see this intriguing comment, "In addition, on this webpage, you can > improve the docs!" There is mention that some of the docs are out of > date. That's ripe for a soap box comment from me about the general > documentation on the web. It seems writing and improving code is far > more important than keeping documentation up to date. There has actually been a lot of work on the documentation last year, at least for NumPy. I think that comment refers to there being old copies of documents elsewhere on the Web. James. From sierra_mtnview at sbcglobal.net Tue Apr 14 13:40:13 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 10:40:13 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4AD28.10801@noaa.gov> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> Message-ID: <49E4CA7D.1040304@sbcglobal.net> Yes, that's true, but I was trying to express the confusion over leaving the pyfits manual lingering in numarray-land. Jim Vickroy wrote: > At the risk of stating the obvious, you should only be using numpy > (not numarray). Numarray was a competing package that pyfits > previously supported. Numarray is deprecated and the recent releases > of pyfits have complete support for numpy. > > -- jv > > Wayne Watson wrote: >> Howdy, I think I see the ccdsoft problem. I looked at a fit (fits) file >> I produced with my CCD camera using it, and it produces a uint16 >> (BITPIX=16). I just made the change you suggested, and the resulting >> file shows BITPIX=8, but CCDSoft liked it. Apparently, it objected to >> the 32 bit image earlier, which probably gave rise to the black image. >> The former way produced a file of 1,204KB, and the current file produced >> sized with the simple replacement produced a file of 304KB. I used >> dtype='uint8' instead of 'B'. >> >> Somewhere along the line I confused myself with the numarray use in the >> FITS manual, and apparently its look-alike notion ( as seen via arange >> and reshape) in numpy. Maybe they are equivalent in every respect. I was >> trying to figure out how to get Python to put together a 'matrix' >> (mathematical sense) to feed it to data, but it looks like reshape is >> the ticket. reshape seems missing from numarray (not mentioned in the >> fits manual), so maybe there is a difference. I'm not sure the pyfits >> manual ever showed how to make a 'matrix' and stuff it into the data >> portion of a FITS header (maybe that's what section 2.2.3 is about, >> which interestingly has the same title as 2.2.2). >> >> I think we are pretty much, successfully, done here. Allowing the meteor >> program I'm adding new features to be able to use FITS will be a very >> useful change. Some exposure to pyfits and numpy helps too from the >> coding aspects. Of course, if I decide to add features that allow FITS >> files into the program, say, for IP (img processing) work, that'll >> require some unraveling of the data part of the fits file for >> PIL/Tinter. Later though. >> >> Thanks for the help. >> >> Peter Erwin wrote: >> >>> Hi Wayne, >>> >>> Anne Archibald pointed out a much more concise and elegant way to read in >>> and convert the raw file, using a function in Numpy. So you could >>> replace the >>> following original code: >>> >>> >>>> # get raw data from .raw file: >>>> raw_file=open('sent_internal.raw','rb') >>>> raw_image=raw_file.read() >>>> raw_file.close() >>>> >>>> # convert raw data to Python list of integers (1-D): >>>> rawim_intarray = [] >>>> for x in raw_image: >>>> # convert byte to integer ('B' = treat data as single unsigned byte) >>>> newint = struct.unpack('B', x)[0] >>>> rawim_intarray.append(newint) >>>> >>>> # convert Python list of integers into numpy array of integers (note: >>>> still 1-D at this point) >>>> rawim_numpy = numpy.array(rawim_intarray) >>>> >>> with this: >>> >>> rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='B') >>> >>> [note: dtype='B' is identical to dtype=numpy.uint8, which Anne used in >>> her example] >>> >>> and then continue as before. >>> >>> This has the added benefit of producing a smaller output file (300 KB vs >>> 1.2 MB), since the numpy array is now explicitly in 8-bit-integer form >>> (rather than the 32-bit-integer form that my code created), and so >>> Pyfits will automatically save it as 8-bit integers (you can check this >>> by looking at the header keyword BITPIX). >>> >>> >>> You're right, the raw image is a sequence of (standard) 8-bit bytes. >>> Well, all >>> computer files are streams of bytes; the question is how to interpret >>> them. Since >>> you said earlier that it was supposed to be 8-bit values, the idea is >>> then to >>> interpret each individual byte as an unsigned "integer" value (values >>> from 0 to 255); >>> that's what the "dtype='B'" (or "dtype=numpy.uint8") option passed to >>> numpy.fromfile() >>> does. (My previous code did the same thing, but then assigned each >>> value to a >>> standard Python integer, which is 4 bytes long; perfectly workable, >>> but a bit >>> wasteful!). >>> >>> Anyway, when I do this, I can see an image in DS9 (a circular aperture >>> with ragged >>> edges and an overall horizontal gradient inside the aperture). So I'm >>> pretty sure >>> it's working. (I've attached a jpeg saved from DS9 to show what the >>> image looks like.) >>> >>> I don't think I can help you with this "ccdsoft" program; I'm not >>> familiar with it. >>> If it's a Windows program, then it may expect all FITS files to end in >>> ".fit" instead >>> of ".fits", just because Windows traditionally expects files to have >>> 3-letter extensions. >>> >>> >>> As for overwriting an existing FITS file, try this: >>> >>> hdu.writeto("existing_file_name.fit", clobber=True) >>> >>> cheers, >>> >>> Peter >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> >>> >>> >>> On Apr 14, 2009, at 6:28 AM, Wayne Watson wrote: >>> >>> >>>> Hi, Peter. It looks like I confused a few people with the hex. I had >>>> removed it, but only after I placed the code in the msg. I was >>>> playing with hex in the event I might need it somehow. int was fine >>>> for my experimental purposes. >>>> >>>> Here's your code with a minor correction. I changed this line: >>>> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >>>> The difference is rawmin_numpy. >>>> I added a print at the end, and threw in two lines that attempt to >>>> put header info into the final file. Continuing below the code. >>>> >>>> =====================Start=============== >>>> import struct, numpy, pyfits # struct is part of the main Python >>>> library >>>> >>>> # get raw data from .raw file: >>>> raw_file=open('sent_internal.raw','rb') >>>> raw_image=raw_file.read() >>>> raw_file.close() >>>> >>>> # convert raw data to Python list of integers (1-D): >>>> rawim_intarray = [] >>>> for x in raw_image: >>>> # convert byte to integer ('B' = treat data as single unsigned byte) >>>> newint = struct.unpack('B', x)[0] >>>> rawim_intarray.append(newint) >>>> >>>> # convert Python list of integers into numpy array of integers (note: >>>> still 1-D at this point) >>>> rawim_numpy = numpy.array(rawim_intarray) >>>> >>>> # reshape numpy array into 2D form, using our knowledge of the >>>> original image's >>>> # x and y sizes (kudos to Megan Sosey for pointing out how to do this) >>>> rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) >>>> >>>> # create Pyfits header-data unit: >>>> hdu = pyfits.PrimaryHDU(rawim_numpy_2d) >>>> hdu.header.update('LATOBS',"32:11:56") >>>> hdu.header.update('LNGOBS',"120:00:00") >>>> >>>> # (make any modifications to the header you might want to... e.g., >>>> see Megan Sosey's >>>> # email of April 8 for examples) >>>> >>>> # ... and save the data to disk as a FITS file: >>>> hdu.writeto("test.fits") >>>> print "Finished. See test.fits" >>>> ===============End code============ >>>> >>>> I'm not sure what the 'byte' stuff is about. It may be that it's not >>>> needed. I think the original 'raw' file is byte oriented--rather than >>>> int or whatever. Anyway, I don't seem to have succeeded in getting >>>> header info into the file. Sort of. If I use DS9, I can see the image >>>> and the fits header with what I coded into it. Here's what I see with >>>> ds9. >>>> >>>> *However, with my ccdsoft program, te image is black and the header >>>> is not the same. Whoops. Interesting. I changed the file to test.fit >>>> instead of test.fits, and the header info is there, but the image is >>>> still black. The dimension are the same, 640x480. I'm attaching >>>> test-ww.fits. I just renamed my test.fits. I think I'll check with >>>> The Bisque (ccdsoft) to see what format they produce and use for the >>>> raw image. >>>> Question. When I execute the program a second time, the >>>> *hdu.writeto("test.fits") *will not write over the old file. Is there >>>> an option to force the write? >>>> >>>> Well, this is all good progress. ** * >>>> >>>> -- >>>> >>>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>>> >>>> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >>>> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >>>> All the neutrons, and protons in the human body occupy >>>> a cube whose side is 5.52*10**-6 meters (tiny!). That >>>> adds up to a 150 pound person. It's not a surprise that >>>> we are mostly space. (Calculation by WTW) >>>> >>> ============================================================= >>> Peter Erwin Max-Planck-Insitute for Extraterrestrial >>> erwin at mpe.mpg.de Physics, Giessenbachstrasse >>> tel. +49 (0)89 30000 3695 85748 Garching, Germany >>> fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin >>> >>> >>> >>> >> >> > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Tue Apr 14 13:52:32 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 10:52:32 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <2A2199FD-CD1A-4B9C-A402-72B61FDE48A8@mpe.mpg.de> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> <2A2199FD-CD1A-4B9C-A402-72B61FDE48A8@mpe.mpg.de> Message-ID: <49E4CD60.4080407@sbcglobal.net> 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() -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From peridot.faceted at gmail.com Tue Apr 14 14:29:24 2009 From: peridot.faceted at gmail.com (Anne Archibald) Date: Tue, 14 Apr 2009 14:29:24 -0400 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4CD60.4080407@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> <2A2199FD-CD1A-4B9C-A402-72B61FDE48A8@mpe.mpg.de> <49E4CD60.4080407@sbcglobal.net> Message-ID: 2009/4/14 Wayne Watson : > 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() There is, yes, but if what you have is a PIL image, you can make a numpy array directly from the underlying memory: http://effbot.org/zone/pil-numpy.htm http://effbot.org/zone/pil-changes-116.htm Incidentally, if you want to do image processing on the contents of a FITS file, you might try scipy's ndimage tools. They are likely to be a better fit to the sort of tasks you want to do than PIL's image processing. There may also be more astronomical image processing libraries available (pyraf?), I haven't really looked for them. Anne From Jim.Vickroy at noaa.gov Tue Apr 14 14:32:31 2009 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 14 Apr 2009 12:32:31 -0600 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4CD60.4080407@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> <2A2199FD-CD1A-4B9C-A402-72B61FDE48A8@mpe.mpg.de> <49E4CD60.4080407@sbcglobal.net> Message-ID: <49E4D6BF.9080105@noaa.gov> 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(...) fromstring(string, dtype=float, count=-1, sep='') Return a new 1d array initialized from raw binary or text data in string. ... -- jv From perry at stsci.edu Tue Apr 14 15:27:01 2009 From: perry at stsci.edu (Perry Greenfield) Date: Tue, 14 Apr 2009 15:27:01 -0400 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4CA7D.1040304@sbcglobal.net> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> <49E4CA7D.1040304@sbcglobal.net> Message-ID: <2275FD0E-48B4-4F39-8303-5A2E1AC54896@stsci.edu> On Apr 14, 2009, at 1:40 PM, Wayne Watson wrote: > Yes, that's true, but I was trying to express the confusion over > leaving > the pyfits manual lingering in numarray-land. Yes, it's on our list of things to do in the near future. Perry From sierra_mtnview at sbcglobal.net Tue Apr 14 17:51:40 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 14:51:40 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <49E4D6BF.9080105@noaa.gov> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> <2A2199FD-CD1A-4B9C-A402-72B61FDE48A8@mpe.mpg.de> <49E4CD60.4080407@sbcglobal.net> <49E4D6BF.9080105@noaa.gov> Message-ID: <49E5056C.9050600@sbcglobal.net> That worked fine, but raised an interesting question about the all-sky image I happened to test it on. I'm going to another post for it. I should be able to post it in a 15 minutes, but it may get held for moderator approval. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Wed Apr 15 01:44:44 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 22:44:44 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> <49E410ED.4080402@sbcglobal.net> <9C04EA80-13D3-4586-A23B-EB3283350A04@mpe.mpg.de> <49E4AA70.8080302@sbcglobal.net> <49E4AD28.10801@noaa.gov> <2A2199FD-CD1A-4B9C-A402-72B61FDE48A8@mpe.mpg.de> <49E4CD60.4080407@sbcglobal.net> Message-ID: <49E5744C.50406@sbcglobal.net> Thanks. Particularly interesting was the change reference in zone. I wasn't aware of zone. It appears as though the fromstring never appeared anywhere but there. pyraf/iraf. All of this is unexplored territory to me. It looks like the things I've learned here recently plus those will keep me busy for the rest of the year. :-) Having the data files I've been working with available now in fits is opening many vistas. Maybe pyraf has some overview sampler of what it does? Since meteor work is my topic, maybe they have special capabilites for such images? I may have to stick closer to home for IP stuff though. That is, the users of the s/w may not be able to absorb iraf easily, so it still might behoove me to put a IP few features in the program in adding analytic capabilities to. Anne Archibald wrote: > 2009/4/14 Wayne Watson : > >> Well, one more question about manipulation. >> >> rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='uint8') >> >> >> ... >> > > There is, yes, but if what you have is a PIL image, you can make a > numpy array directly from the underlying memory: > http://effbot.org/zone/pil-numpy.htm > http://effbot.org/zone/pil-changes-116.htm > > Incidentally, if you want to do image processing on the contents of a > FITS file, you might try scipy's ndimage tools. They are likely to be > a better fit to the sort of tasks you want to do than PIL's image > processing. There may also be more astronomical image processing > libraries available (pyraf?), I haven't really looked for them. > > Anne > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Wed Apr 15 17:26:43 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 15 Apr 2009 14:26:43 -0700 Subject: [AstroPy] An Odd Result on an All-Sky Image--Equal Images and Bars? Message-ID: <49E65113.5010702@sbcglobal.net> (Well, I guess the moderator didn't release with two 1M fits files. I'm posting it without them. Jumping down to HERE might be best. The first part of this discusses the two files, but maybe it strikes a cord with some. The most important part might be about comparing two files. I'm attaching a small file of the barred image I discuss. I think if I keep it down to 40K, it'll pass through to the list. ) With help from posts above, I finally got a fits image from some old data I was using for test purposes. As displayed by the sentinel software, the frame was dark with the moon in the center a as small bright circle. I used a program, ccdsoft*, which displays fits images. It had much greater contrast. One could see the circular horizon, and trees along the horizon, even my house in the lower right. Neighbor's lights were visible in the lower left. That's not really anything new, but why the difference in the two images as displayed, I asked myself? I tried the image in DS9, and it showed it to be almost identical to the image displayed by sentinel. It's quite possible that ccdsoft has some auto contrast feature that was applied, but I doubt it. I saved the odd ccdsoft displayed image to a fits file. The file name ends with ...x.fits. I'm pretty sure the pixel values will be different from the other file. Is there a way to compare the two easily? This is just curiosity. HERE Perhaps more importantly here, and this I had no immediate plans of discussing here, since it was currently less important to putting in a "save to fits" ability; how does one get rid of those vertical lines (bars)? They are from the video camera working at high gain, I'm pretty sure. Dark frame subtraction doesn't help. Although removing the lines is interesting here, it gets to be important in the situation where I've stacked 256 images of the sky (which does show many stars--and noise). BTW, the unstacked image is a 1/30th sec exposure. The purpose there is to bring out dim stars. It works fine, but those lines probably won't help star identification. I would think if it can be done with this image, it could apply to the stacked images. Comments? I'm attaching two fits files. Note that in the fitss file provided that something of a coordinate system, 3 lines, is shown. That's pure experimentation from some other interests. Interestingly, in DS9, the image is upside down (neither file is the display screen of the DS9). * BTW, this is the first time these images have been available to ccdsoft or ds9. ccdsoft does have IP capabilites, and sentinel has none. As a consequence, they are seldom seen as provided by ccdsoft or any IP program. Just playing around with a few IP controls on ccdsoft was interesting. That's a real plus having IP. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) -------------- next part -------------- A non-text attachment was scrubbed... Name: BarredImage.jpg Type: image/jpeg Size: 27746 bytes Desc: not available URL: From Jim.Vickroy at noaa.gov Wed Apr 15 17:48:18 2009 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed, 15 Apr 2009 15:48:18 -0600 Subject: [AstroPy] An Odd Result on an All-Sky Image--Equal Images and Bars? In-Reply-To: <49E65113.5010702@sbcglobal.net> References: <49E65113.5010702@sbcglobal.net> Message-ID: <49E65622.7010506@noaa.gov> Wayne Watson wrote: > (Well, I guess the moderator didn't release with two 1M fits files. > I'm posting it without them. Jumping down to HERE might be best. The > first part of this discusses the two files, but maybe it strikes a > cord with some. The most important part might be about comparing two > files. I'm attaching a small file of the barred image I discuss. I > think if I keep it down to 40K, it'll pass through to the list. ) > > With help from posts above, I finally got a fits image from some old > data I was using for test purposes. As displayed by the sentinel > software, the frame was dark with the moon in the center a as small > bright circle. I used a program, ccdsoft*, which displays fits images. > It had much greater contrast. One could see the circular horizon, and > trees along the horizon, even my house in the lower right. Neighbor's > lights were visible in the lower left. That's not really anything new, > but why the difference in the two images as displayed, I asked myself? I > tried the image in DS9, and it showed it to be almost identical to the > image displayed by sentinel. > > It's quite possible that ccdsoft has some auto contrast feature that was > applied, but I doubt it. I saved the odd ccdsoft displayed image to a > fits file. The file name ends with ...x.fits. I'm pretty sure the pixel > values will be different from the other file. Is there a way to compare > the two easily? This is just curiosity. If I remember, you know how to use pyfits to load FITS files, so load the 2 files and compare (as desired) the (primary) data units (DUs) of each file. Since pyfits returns the DUs as numpy arrays (ndarray), the full power of numpy is at your disposal for the comparison. > HERE > Perhaps more importantly here, and this I had no immediate plans of > discussing here, since it was currently less important to putting in a > "save to fits" ability; how does one get rid of those vertical lines > (bars)? They are from the video camera working at high gain, I'm pretty > sure. I did not see the vertical lines in the attached jpeg, but you may want to take a look at scipy.interpolate.Rbf and or the topic of image */inpainting/* in general. -- jv > Dark frame subtraction doesn't help. Although removing the lines > is interesting here, it gets to be important in the situation where I've > stacked 256 images of the sky (which does show many stars--and noise). > BTW, the unstacked image is a 1/30th sec exposure. The purpose there is > to bring out dim stars. It works fine, but those lines probably won't > help star identification. I would think if it can be done with this > image, it could apply to the stacked images. Comments? > > I'm attaching two fits files. Note that in the fitss file provided that > something of a coordinate system, 3 lines, is shown. That's pure > experimentation from some other interests. > > Interestingly, in DS9, the image is upside down (neither file is the > display screen of the DS9). > > * BTW, this is the first time these images have been available to > ccdsoft or ds9. ccdsoft does have IP capabilites, and sentinel has none. > As a consequence, they are seldom seen as provided by ccdsoft or any IP > program. Just playing around with a few IP controls on ccdsoft was > interesting. That's a real plus having IP. > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/jpeg Size: 27746 bytes Desc: not available URL: From sierra_mtnview at sbcglobal.net Tue Apr 14 00:28:29 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Mon, 13 Apr 2009 21:28:29 -0700 Subject: [AstroPy] Moving Ahead with Raw Image Conversion In-Reply-To: <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> References: <49E232DB.2030304@sbcglobal.net> <49E35F09.4060201@noaa.gov> <49E36A90.3080300@sbcglobal.net> <15556FDE-DC8C-4176-A39F-84C8D3F40B0F@mpe.mpg.de> Message-ID: <49E410ED.4080402@sbcglobal.net> Hi, Peter. It looks like I confused a few people with the hex. I had removed it, but only after I placed the code in the msg. I was playing with hex in the event I might need it somehow. int was fine for my experimental purposes. Here's your code with a minor correction. I changed this line: rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) The difference is rawmin_numpy. I added a print at the end, and threw in two lines that attempt to put header info into the final file. Continuing below the code. =====================Start=============== import struct, numpy, pyfits # struct is part of the main Python library # get raw data from .raw file: raw_file=open('sent_internal.raw','rb') raw_image=raw_file.read() raw_file.close() # convert raw data to Python list of integers (1-D): rawim_intarray = [] for x in raw_image: # convert byte to integer ('B' = treat data as single unsigned byte) newint = struct.unpack('B', x)[0] rawim_intarray.append(newint) # convert Python list of integers into numpy array of integers (note: still 1-D at this point) rawim_numpy = numpy.array(rawim_intarray) # reshape numpy array into 2D form, using our knowledge of the original image's # x and y sizes (kudos to Megan Sosey for pointing out how to do this) rawim_numpy_2d = numpy.reshape(rawim_numpy,(480, 640)) # create Pyfits header-data unit: hdu = pyfits.PrimaryHDU(rawim_numpy_2d) hdu.header.update('LATOBS',"32:11:56") hdu.header.update('LNGOBS',"120:00:00") # (make any modifications to the header you might want to... e.g., see Megan Sosey's # email of April 8 for examples) # ... and save the data to disk as a FITS file: hdu.writeto("test.fits") print "Finished. See test.fits" ===============End code============ I'm not sure what the 'byte' stuff is about. It may be that it's not needed. I think the original 'raw' file is byte oriented--rather than int or whatever. Anyway, I don't seem to have succeeded in getting header info into the file. Sort of. If I use DS9, I can see the image and the fits header with what I coded into it. Here's what I see with ds9. *However, with my ccdsoft program, te image is black and the header is not the same. Whoops. Interesting. I changed the file to test.fit instead of test.fits, and the header info is there, but the image is still black. The dimension are the same, 640x480. I'm attaching test-ww.fits. I just renamed my test.fits. I think I'll check with The Bisque (ccdsoft) to see what format they produce and use for the raw image. Question. When I execute the program a second time, the *hdu.writeto("test.fits") *will not write over the old file. Is there an option to force the write? Well, this is all good progress. ** * -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: test-ww.fits URL: From sierra_mtnview at sbcglobal.net Tue Apr 14 18:29:39 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 14 Apr 2009 15:29:39 -0700 Subject: [AstroPy] An Odd Result on an All-Sky Image--Equal Images and Bars? Message-ID: <49E50E53.9020003@sbcglobal.net> With help from posts above, I finally got a fits image from some old data I was using for test purposes. As displayed by the sentinel software, the frame was dark with the moon in the center a as small bright circle. I used a program, ccdsoft*, which displays fits images. It had much greater contrast. One could see the circular horizon, and trees along the horizon, even my house in the lower right. Neighbor's lights were visible in the lower left. That's not really anything new, but why the difference in the two images as displayed, I asked myself? I tried the image in DS9, and it showed it to be almost identical to the image displayed by sentinel. It's quite possible that ccdsoft has some auto contrast feature that was applied, but I doubt it. I saved the odd ccdsoft displayed image to a fits file. The file name ends with ...x.fits. I'm pretty sure the pixel values will be different from the other file. Is there a way to compare the two easily? This is just curiosity. Perhaps more importantly here, and this I had no immediate plans of discussing here, since it was currently less important to putting in a "save to fits" ability; how does one get rid of those vertical lines (bars)? They are from the video camera working at high gain, I'm pretty sure. Dark frame subtraction doesn't help. Although removing the lines is interesting here, it gets to be important in the situation where I've stacked 256 images of the sky (which does show many stars--and noise). BTW, the unstacked image is a 1/30th sec exposure. The purpose there is to bring out dim stars. It works fine, but those lines probably won't help star identification. I would think if it can be done with this image, it could apply to the stacked images. Comments? I'm attaching two fits files. Note that in the fitss file provided that something of a coordinate system, 3 lines, is shown. That's pure experimentation from some other interests. Interestingly, in DS9, the image is upside down (neither file is the display screen of the DS9). * BTW, this is the first time these images have been available to ccdsoft or ds9. ccdsoft does have IP capabilites, and sentinel has none. As a consequence, they are seldom seen as provided by ccdsoft or any IP program. Just playing around with a few IP controls on ccdsoft was interesting. That's a real plus having IP. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: v20080118_212433.43x.fit URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: v20080118_212433.43.fits URL: From jtaylor2 at stsci.edu Thu Apr 16 13:14:32 2009 From: jtaylor2 at stsci.edu (jtaylor2 at stsci.edu) Date: Thu, 16 Apr 2009 13:14:32 -0400 (EDT) Subject: [AstroPy] PyFITS Version 2.1 NOW AVAILABLE Message-ID: <20090416131432.AAU10560@comet.stsci.edu> **************************************** PyFITS Version 2.1 NOW AVAILABLE **************************************** The Science Software Branch of the Space Telescope Science Institute wishes to announce the availability of version 2.1 of PyFITS. This is the first announced release since version 1.3 in February 2008 and contains a number of enhancements and bug fixes. Notable Enhancements ==================== - Support for the FITS "Tiled Image Compression Convention." (PyFITS version 2.1) This support is based on the implementation in CFITSIO version 3.13. Reference the following for convention details: http://fits.gsfc.nasa.gov/registry/tilecompression.html - New convenience functions (tdump and tcreate) for dumping the contents of a binary table HDU to a file in ASCII format and then to recreate the binary table HDU from those files. (PyFITS version 2.1) - Support the reading and writing of non-standard FITS files, including files with SIMPLE=F header cards and with non-standard XTENSION types. (PyFITS version 2.1) - New convenience functions (setval and delval) for setting the value of a single header card in a FITS file and for the deletion of a single header card in a FITS file. (PyFITS version 2.0) - Support the reading and writing of FITS files containing unsigned integer 16 data in an Image HDU that are represented as scaled integer 16 values. (PyFITS version 2.0) - Support for record-valued keyword cards as introduced in the "FITS WCS Paper IV Proposal for Representing a more General Distortion Model." (PyFITS version 1.4) Reference the following for proposal details: http://fits.gsfc.nasa.gov/fits_wcs.html - Support for file objects and file like objects to all convenience functions and class methods that take a file name. (PyFITS version 1.4) Release Notes ============= Release notes for all versions of PyFITS may be found at: http://www.stsci.edu/resources/software_hardware/pyfits/release Where to Obtain this Software ============================= PyFITS can be downloaded for the PyFITS download web site: http://www.stsci.edu/resources/software_hardware/pyfits/Download Installation instructions are available on the web site. STSCI_PYTHON Support ==================== STSCI_PYTHON v2.7 contains PyFITS version 1.4.1. The upcoming STSCI_PYTHON v2.8 release will contain PyFITS version 2.1. Array Package Support ===================== While the NUMARRAY array package is still supported at the PyFITS version 1.1 level, all updates in this release are for NUMPY only. Compatibility with NUMARRAY will be eliminated entirely after this release. As a result, you are advised to migrate to NUMPY as soon as possible, as no further support will be provided for the user of NUMARRAY. Information on making the switch to NUMPY form NUMARRAY can be found in this document: http://www.stsci.edu/resources/software_hardware/numarray/numarray2numpy.pdf From sierra_mtnview at sbcglobal.net Thu Apr 16 22:22:50 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Thu, 16 Apr 2009 19:22:50 -0700 Subject: [AstroPy] An Odd Result on an All-Sky Image--Equal Images and Bars? In-Reply-To: <49E65622.7010506@noaa.gov> References: <49E65113.5010702@sbcglobal.net> <49E65622.7010506@noaa.gov> Message-ID: <49E7E7FA.2090801@sbcglobal.net> It looks obvious to me that there are vertical bars about 3-4 pixels wide here. Light, dark, light, ... They should be wider in the image you received. I was posting these two question (other was about = files) as independent of numPy. A shot in the dark post here, which is seems more into Python and programming. Probably a better place might be the IRAS forum. Anne has suggested something like that in one of her posts. I think I'll leave the analysis to IP programs I normally use, which will likely be more useful now that I've got the unadulterated image in fits format. Rbf? Interesting suffix. There's a lot to numpy and pyfits (and IRAS), which I will leave to another time. Jim Vickroy wrote: > I did not see the vertical lines in the attached jpeg, but you may > want to take a look at scipy.interpolate.Rbf > > and or the topic of image */inpainting/* in general. > >> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> > > ------------------------------------------------------------------------ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From Jim.Vickroy at noaa.gov Fri Apr 17 12:42:35 2009 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 17 Apr 2009 10:42:35 -0600 Subject: [AstroPy] PyFITS Version 2.1 NOW AVAILABLE In-Reply-To: <20090416131432.AAU10560@comet.stsci.edu> References: <20090416131432.AAU10560@comet.stsci.edu> Message-ID: <49E8B17B.4030108@noaa.gov> Thanks to the development team for this new version. Attached is the console window output from /*setup.py install*/ on my Microsoft Windows Xp pro machine (service pack 3). Are those errors expected? Is anyone else seeing these errors on MS Windows? My configuration is: * Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] * numpy 1.2.1 -- jv jtaylor2 at stsci.edu wrote: > **************************************** > > PyFITS Version 2.1 NOW AVAILABLE > > **************************************** > > The Science Software Branch of the Space Telescope > Science Institute wishes to announce the availability > of version 2.1 of PyFITS. This is the first announced > release since version 1.3 in February 2008 and contains > a number of enhancements and bug fixes. > > > Notable Enhancements > ==================== > > - Support for the FITS "Tiled Image Compression Convention." > (PyFITS version 2.1) This support is based on the > implementation in CFITSIO version 3.13. Reference the > following for convention details: > > http://fits.gsfc.nasa.gov/registry/tilecompression.html > > - New convenience functions (tdump and tcreate) for > dumping the contents of a binary table HDU to a file > in ASCII format and then to recreate the binary table > HDU from those files. (PyFITS version 2.1) > > - Support the reading and writing of non-standard FITS > files, including files with SIMPLE=F header cards and > with non-standard XTENSION types. (PyFITS version 2.1) > > - New convenience functions (setval and delval) for > setting the value of a single header card in a FITS file > and for the deletion of a single header card in a FITS > file. (PyFITS version 2.0) > > - Support the reading and writing of FITS files containing > unsigned integer 16 data in an Image HDU that are > represented as scaled integer 16 values. > (PyFITS version 2.0) > > - Support for record-valued keyword cards as introduced in > the "FITS WCS Paper IV Proposal for Representing a more > General Distortion Model." (PyFITS version 1.4) Reference > the following for proposal details: > > http://fits.gsfc.nasa.gov/fits_wcs.html > > - Support for file objects and file like objects to all > convenience functions and class methods that take a file > name. (PyFITS version 1.4) > > > Release Notes > ============= > > Release notes for all versions of PyFITS may be found > at: > > http://www.stsci.edu/resources/software_hardware/pyfits/release > > > Where to Obtain this Software > ============================= > > PyFITS can be downloaded for the PyFITS download web site: > > http://www.stsci.edu/resources/software_hardware/pyfits/Download > > Installation instructions are available on the web site. > > > STSCI_PYTHON Support > ==================== > > STSCI_PYTHON v2.7 contains PyFITS version 1.4.1. > > The upcoming STSCI_PYTHON v2.8 release will contain > PyFITS version 2.1. > > > Array Package Support > ===================== > > While the NUMARRAY array package is still supported at > the PyFITS version 1.1 level, all updates in this > release are for NUMPY only. Compatibility with NUMARRAY > will be eliminated entirely after this release. As a > result, you are advised to migrate to NUMPY as soon as > possible, as no further support will be provided for the > user of NUMARRAY. > > Information on making the switch to NUMPY form NUMARRAY > can be found in this document: > > http://www.stsci.edu/resources/software_hardware/numarray/numarray2numpy.pdf > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: setup.py.log URL: From sierra_mtnview at sbcglobal.net Sun Apr 19 08:49:09 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 19 Apr 2009 05:49:09 -0700 Subject: [AstroPy] 3-D Graphics Tools for for Documentation, Presentations, etc. Message-ID: <49EB1DC5.8060109@sbcglobal.net> Many years ago to put together a presentation or article on celestial mechanics, spherical trig, trajectory analysis, etc. I would use a compass, ruler, and maybe a French curve to draw the figures, coordinate axes, etc. on paper. Labels would be typed onto the sheets. I would like to think that over the last decade that some modest software package might be available to do this. Does anyone know of any? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Sun Apr 19 13:04:47 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 19 Apr 2009 10:04:47 -0700 Subject: [AstroPy] 3-D Graphics Tools for for Documentation, Presentations, etc. In-Reply-To: References: <49EB1DC5.8060109@sbcglobal.net> Message-ID: <49EB59AF.1090604@sbcglobal.net> Thanks for the information. I would agree with you for a presentation, but I need it mostly this time for a paper I'm writing. I will be giving a talk, so I could use a video 3-D clip. However, in this case, it may not be useful. I'm simply trying to show three coordinate systems with the same origin. One is an image plane (x-y), and the other two are az/el, separated by an angle about the zenith. A celestial sphere needs to be shown with a few stars on it. I could go overboard with this, by rotating one of the coordinate systems around the north pole, and drawing the path of the stars on the sphere, but I'll worry about that for another time. Anne Archibald wrote: > 2009/4/19 Wayne Watson : > >> Many years ago to put together a presentation or article on celestial >> mechanics, spherical trig, trajectory analysis, etc. I would use a >> compass, ruler, and maybe a French curve to draw the figures, coordinate >> axes, etc. on paper. Labels would be typed onto the sheets. I would like >> to think that over the last decade that some modest software package >> might be available to do this. Does anyone know of any? >> > > You might try Mayavi2. It's more oriented towards 3D visualization, > but I think with appropriate options it can probably be made to do > what you're asking for. (It's also worth noting that an interactive 3D > plot can be much more informative than a single 2D projection.) > > Anne > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From rwagner at physics.ucsd.edu Sun Apr 19 16:18:02 2009 From: rwagner at physics.ucsd.edu (Rick Wagner) Date: Sun, 19 Apr 2009 13:18:02 -0700 Subject: [AstroPy] 3-D Graphics Tools for for Documentation, Presentations, etc. In-Reply-To: <49EB59AF.1090604@sbcglobal.net> References: <49EB1DC5.8060109@sbcglobal.net> <49EB59AF.1090604@sbcglobal.net> Message-ID: Hi, Have you looked at S2PLOT? It's has relatively simple interface, and includes the ability to embed 3D data in PDF's. Oh, and it has a Python wrapper, making it useful to us. http://astronomy.swin.edu.au/s2plot/ --Rick On Apr 19, 2009, at 10:04 AM, Wayne Watson wrote: > Thanks for the information. I would agree with you for a presentation, > but I need it mostly this time for a paper I'm writing. I will be > giving > a talk, so I could use a video 3-D clip. However, in this case, it may > not be useful. I'm simply trying to show three coordinate systems with > the same origin. One is an image plane (x-y), and the other two are > az/el, separated by an angle about the zenith. A celestial sphere > needs > to be shown with a few stars on it. I could go overboard with this, by > rotating one of the coordinate systems around the north pole, and > drawing the path of the stars on the sphere, but I'll worry about that > for another time. > > Anne Archibald wrote: >> 2009/4/19 Wayne Watson : >> >>> Many years ago to put together a presentation or article on >>> celestial >>> mechanics, spherical trig, trajectory analysis, etc. I would use a >>> compass, ruler, and maybe a French curve to draw the figures, >>> coordinate >>> axes, etc. on paper. Labels would be typed onto the sheets. I >>> would like >>> to think that over the last decade that some modest software package >>> might be available to do this. Does anyone know of any? >>> >> >> You might try Mayavi2. It's more oriented towards 3D visualization, >> but I think with appropriate options it can probably be made to do >> what you're asking for. (It's also worth noting that an >> interactive 3D >> plot can be much more informative than a single 2D projection.) >> >> Anne >> >> > > -- > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet > > All the neutrons, and protons in the human body occupy > a cube whose side is 5.52*10**-6 meters (tiny!). That > adds up to a 150 pound person. It's not a surprise that > we are mostly space. (Calculation by WTW) > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From sierra_mtnview at sbcglobal.net Sun Apr 19 19:33:29 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 19 Apr 2009 16:33:29 -0700 Subject: [AstroPy] 3-D Graphics Tools for for Documentation, Presentations, etc. In-Reply-To: References: <49EB1DC5.8060109@sbcglobal.net> <49EB59AF.1090604@sbcglobal.net> Message-ID: <49EBB4C9.2080308@sbcglobal.net> Thanks. I'm not familiar with it. A requirement I forgot to mention is that I be able to execute the program under Win. I'm using standard PC graphics. No Silicon Graphics machines here. :-) I edged out of *nix years ago, but may fire it up in a month or two on an older PC. About 15 years ago, I put together a program that would do the trick that I'm looking for in this instance. Rick Wagner wrote: > Hi, > > Have you looked at S2PLOT? It's has relatively simple interface, and > includes the ability to embed 3D data in PDF's. Oh, and it has a > Python wrapper, making it useful to us. > > http://astronomy.swin.edu.au/s2plot/ > > --Rick > > On Apr 19, 2009, at 10:04 AM, Wayne Watson wrote: > >> Thanks for the information. I would agree with you for a presentation, >> but I need it mostly this time for a paper I'm writing. I will be giving >> a talk, so I could use a video 3-D clip. However, in this case, it may >> not be useful. I'm simply trying to show three coordinate systems with >> the same origin. One is an image plane (x-y), and the other two are >> az/el, separated by an angle about the zenith. A celestial sphere needs >> to be shown with a few stars on it. I could go overboard with this, by >> rotating one of the coordinate systems around the north pole, and >> drawing the path of the stars on the sphere, but I'll worry about that >> for another time. >> >> Anne Archibald wrote: >>> 2009/4/19 Wayne Watson : >>> >>>> Many years ago to put together a presentation or article on celestial >>>> mechanics, spherical trig, trajectory analysis, etc. I would use a >>>> compass, ruler, and maybe a French curve to draw the figures, >>>> coordinate >>>> axes, etc. on paper. Labels would be typed onto the sheets. I would >>>> like >>>> to think that over the last decade that some modest software package >>>> might be available to do this. Does anyone know of any? >>>> >>> >>> You might try Mayavi2. It's more oriented towards 3D visualization, >>> but I think with appropriate options it can probably be made to do >>> what you're asking for. (It's also worth noting that an interactive 3D >>> plot can be much more informative than a single 2D projection.) >>> >>> Anne >>> >>> >> >> -- >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >> >> All the neutrons, and protons in the human body occupy >> a cube whose side is 5.52*10**-6 meters (tiny!). That >> adds up to a 150 pound person. It's not a surprise that >> we are mostly space. (Calculation by WTW) >> >> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Tue Apr 21 08:24:27 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 21 Apr 2009 05:24:27 -0700 Subject: [AstroPy] 3-D Graphics Tools for for Documentation, Presentations, etc. In-Reply-To: <49EB28DC.40201@physics.uwa.edu.au> References: <49EB1DC5.8060109@sbcglobal.net> <49EB28DC.40201@physics.uwa.edu.au> Message-ID: <49EDBAFB.4040209@sbcglobal.net> This looks quite good. Too bad there isn't a pdf. I only see html for docs. OK, I see the intro, 8 pages, is a pdf, but not included with the download vPython. Is there a quick way to draw simple lines? From what I see so far in the tutorials, most of them are aimed at drawing 3-d objects like balls and boxes. It seems as though everything is installed under .../site-packages/visual. Is there a mail list? Andrew Williams wrote: > Wayne Watson wrote: >> Many years ago to put together a presentation or article on celestial >> mechanics, spherical trig, trajectory analysis, etc. I would use a >> compass, ruler, and maybe a French curve to draw the figures, >> coordinate axes, etc. on paper. Labels would be typed onto the >> sheets. I would like to think that over the last decade that some >> modest software package might be available to do this. Does anyone >> know of any? >> > > VPython: > > http://www.vpython.org/ > > Andrew > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Tue Apr 21 13:00:44 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 21 Apr 2009 10:00:44 -0700 Subject: [AstroPy] 3-D Graphics Tools for for Documentation, Presentations, etc. In-Reply-To: <49EDD46D.5080705@noaa.gov> References: <49EB1DC5.8060109@sbcglobal.net> <49EB28DC.40201@physics.uwa.edu.au> <49EDBAFB.4040209@sbcglobal.net> <49EDD46D.5080705@noaa.gov> Message-ID: <49EDFBBC.2000902@sbcglobal.net> Hiding in plain sight. I've noticed a definite lack of uniformity in subscribing to mail lists. I've joined several in the last few weeks. Cygwin was the best well-hidden of the bunch. In fact, it seems as though Cygwin distribution is hidden in a maze of potentially conflicting (vendors?) interests. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From erwin at mpe.mpg.de Thu Apr 23 21:06:24 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Thu, 23 Apr 2009 21:06:24 -0400 Subject: [AstroPy] Updated telarchive (v1.5) + fetchsdss Message-ID: Hi, This is an announcement of an updated version (1.5) of my quick-and- dirty, Python-based telescope archive search tool, available here: http://www.mpe.mpg.de/~erwin/code/ (A short summary of what it does is appended below.) New features (and fixes): - Updated to work with DR7 of SDSS. - Various fixes to restore or improve counting of instruments from ESO and Subaru archives. - Updated to count XMM-Optical Monitor refereences at MAST archive and new automated telescope data at Subaru (SMOKA) archive. - More flexible command-line parsing (now requires Python 2.3 or higher). - fetchsdss overhauled to deal with DR7 interface changes: now retrieves and save individual FITS files and/or JPEG files instead of archive- generated .tar.gz file; more command-line options (e.g. specify size of JPEG images). [previous summary, updated:] "Telarchive" is a command-line program which simplifies searching various public telescope archives to see if they might have data on a particular astronomical object or part of the sky. This includes the HST and general MAST archive, as well as the ESO, UKIRT, CFHT, and AAT ground-based archives, and imaging data from Data Release 7 (DR7) of the Sloan Digital Sky Survey. The NOAO Science Archive is also included, though it has very little publically available data at this point. Recent additions are SMOKA (the archive for Subaru and several older Japanese telescopes) and the Gemini Science Archive. The Isaac Newton Group Archive is also searched, but only for data from 2001 or earlier (newer data is handled by the new archive interface, which is currently not usable by this program). The program won't *get* the data for you, of course (but see "fetchsdss" for SDSS images), or even tell you very much about it -- for that, you still need to visit the individual archive web pages. But it will save you lots of clicking and typing in web-page forms if you just want to find out if there is *any* data available. An example (searching within a 2-arcminute box centered on the planetary nebula NGC 7027; searching on coordinates directly is also possible): $ telarchive "ngc 7027" 2.0 SIMBAD (Simbad 4, France): Found object coordinates: RA = 21 07 01.593, Dec = +42 14 10.18 Searching archives for ngc 7027 (RA = 21 07 01.593, dec = +42 14 10.18), with search box = 2.0 arcmin... Sloan Digital Sky Survey (DR7) Coordinate-Search Server: No data found. UKIRT Archive: Data exists! (943 observations found) ESO Archive: No data found. ING Archive (old interface): Data exists! (577 observations found) 143 images, 391 spectra, 43 unclassified JKT -- RBS (1), FWHL (2), AGBX (102); INT -- WFC (9), PFCU (30), IDS (66), MES (17), FOS_1 (10); WHT -- TAURUS_2 (5), unknown (43), ISIS_BLUE_ARM (159), UES (58), ISIS_RED_ARM (75) NOAO Science Archive: No data found. AAT Archive: No data found. CFHT Archive: Data exists! (213 observations found) BEAR (200), GECKO (4), AOBVIS (3), AOBIR (6) Multimission Archive at STScI (MAST): No data found. HST Archive (at ESO): Data exists! (89 observations found) -- 11 WFPC2, 24 WF, 1 PC, 13 NICMOS, 3 FOC, 24 STIS, 13 FOS Gemini Science Archive: Data exists! (246 observations found) 45 imaging, 156 long-slit, 45 IFU NIRI (198), michelle (3), GMOS-N (45) SMOKA (Subaru Mitaka Okayama Kiso Archive): Data exists! (1393 observations found) 676 images and 717 spectra Subaru -- OHS/CISCO (9), Subaru -- IRCS (160), Subaru -- COMICS (504), Kiso -- 1k CCD (3), Subaru -- OHS/CISCO (29), Subaru -- IRCS (203), Subaru -- COMICS (451), Okayama -- SNG (3), Okayama -- HIDES (31) It's available as a gzipped tar file here: http://www.mpe.mpg.de/~erwin/code/ There are installation instructions/suggestions in the README file. (And feel free to email with questions or suggestions about it!) cheers, Peter ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From astropython at gmail.com Tue Apr 28 13:36:35 2009 From: astropython at gmail.com (Astronomical Python) Date: Tue, 28 Apr 2009 13:36:35 -0400 Subject: [AstroPy] First public release of APLpy Message-ID: We are pleased to announce the first public beta release of APLpy, a python module that makes it easy to interactively produce publication-quality plots of astronomical images in FITS format. More details are available at http://aplpy.sourceforge.net/ >From the front page you can sign up to the mailing list and/or the Twitter feed to be kept up-to-date on future releases. About APLpy =========== APLpy (pronounced 'apple pie') can be used to: * Interactively or non-interactively produce publication-quality plots; * Show grayscale, colorscale, and 3-color RGB images; * Overlay any number of contour and marker sets; * Dynamically hide, show, and remove contour and marker layers; * Overlay coordinate grids; * Customize the appearance of labels and ticks; * Use LaTeX to typeset labels; * Pan, zoom, and save any view as a full publication-quality plot; * Save plots as EPS, PS, PDF, SVG, or PNG files; Noting that APLpy is still in beta development, you may encounter bugs and/or missing features. If this is the case, please let us know either by emailing us at astropython at gmail.com, or by leaving a bug report or feature request in the forums at: http://apps.sourceforge.net/phpbb/aplpy Cheers, Eli Bressert and Thomas Robitaille From sierra_mtnview at sbcglobal.net Tue Apr 28 13:47:09 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 28 Apr 2009 10:47:09 -0700 Subject: [AstroPy] Google SketchUp & and Astronomy Message-ID: <49F7411D.8020601@sbcglobal.net> A week or so I asked about a graphics package that might draw conventional geometric coordinates and the like that are often found in advanced astro books. That is, the use would be for documentation, and report writing. Visual Python was suggested. I gave it a try, and it wasn't quite right. Nevertheless, a very good program. I just learned of SketchUp and watched a very impressive short video on their web site. Has anyone used this for astronomy applications? It appears to be free. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Tue Apr 28 16:24:47 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 28 Apr 2009 13:24:47 -0700 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? Message-ID: <49F7660F.1070108@sbcglobal.net> I believe in some of my exchanges on this mailing list in the last many works someone mentioned an IRAF facility akin to what is popularly called source extract. Mention was made of what could be considered a command name that somehow is used in connection with the idea. Does anyone know what that single (command) word was or where I would find the extractor topic discussed in IRAF? I just searched my sent astropy messages folder using my mail browser tool, but found nothing in messages connected with the mention of IRAF. Possibly it was on the IRAF forum, but I don't see it there. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From jturner at gemini.edu Tue Apr 28 18:40:10 2009 From: jturner at gemini.edu (James Turner) Date: Tue, 28 Apr 2009 18:40:10 -0400 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: <49F7660F.1070108@sbcglobal.net> References: <49F7660F.1070108@sbcglobal.net> Message-ID: <49F785CA.40701@gemini.edu> > I believe in some of my exchanges on this mailing list in the last many > works someone mentioned an IRAF facility akin to what is popularly > called source extract. Mention was made of what could be considered a > command name that somehow is used in connection with the idea. Does > anyone know what that single (command) word was or where I would find > the extractor topic discussed in IRAF? Is it noao.digiphot.apphot (type "help apphot")? James. From sierra_mtnview at sbcglobal.net Tue Apr 28 20:25:10 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 28 Apr 2009 17:25:10 -0700 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: <49F785CA.40701@gemini.edu> References: <49F7660F.1070108@sbcglobal.net> <49F785CA.40701@gemini.edu> Message-ID: <49F79E66.60605@sbcglobal.net> Probably not, but is what you mentioned source extraction? The idea is that you take a picture of some part of the night sky, and then turn it over to the source extractor. It twists, rescales, and turns your image every which way until it matches 10 or more corresponding objects (stars, etc.) in a photographic atlas of some sort. If it looks right, you can then extract information about those objects and maybe others. It's an astrometric tool. James Turner wrote: >> I believe in some of my exchanges on this mailing list in the last >> many works someone mentioned an IRAF facility akin to what is >> popularly called source extract. Mention was made of what could be >> considered a command name that somehow is used in connection with the >> idea. Does anyone know what that single (command) word was or where I >> would find the extractor topic discussed in IRAF? > > Is it noao.digiphot.apphot (type "help apphot")? > > James. > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From jturner at gemini.edu Tue Apr 28 20:38:31 2009 From: jturner at gemini.edu (James Turner) Date: Tue, 28 Apr 2009 20:38:31 -0400 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: <49F79E66.60605@sbcglobal.net> References: <49F7660F.1070108@sbcglobal.net> <49F785CA.40701@gemini.edu> <49F79E66.60605@sbcglobal.net> Message-ID: <49F7A187.3090604@gemini.edu> > Probably not, but is what you mentioned source extraction? The idea is > that you take a picture of some part of the night sky, and then turn it > over to the source extractor. It twists, rescales, and turns your image > every which way until it matches 10 or more corresponding objects > (stars, etc.) in a photographic atlas of some sort. If it looks right, > you can then extract information about those objects and maybe others. > It's an astrometric tool. It can identify stars in the image and do photometry (not sure whether it's any good for extended sources -- I don't do a lot of imaging). I'm not sure I'd describe source extraction and astrometry as the same thing; maybe imcoords would be better if you want to do astrometry? Others may have more expert recommendations. Either way, "help apphot" and "help imcoords" will tell you more than I can. James. > > James Turner wrote: >>> I believe in some of my exchanges on this mailing list in the last >>> many works someone mentioned an IRAF facility akin to what is >>> popularly called source extract. Mention was made of what could be >>> considered a command name that somehow is used in connection with the >>> idea. Does anyone know what that single (command) word was or where I >>> would find the extractor topic discussed in IRAF? >> >> Is it noao.digiphot.apphot (type "help apphot")? >> >> James. From rfinn at siena.edu Tue Apr 28 20:40:31 2009 From: rfinn at siena.edu (Rose Finn) Date: Tue, 28 Apr 2009 20:40:31 -0400 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: <49F79E66.60605@sbcglobal.net> References: <49F7660F.1070108@sbcglobal.net> <49F785CA.40701@gemini.edu> <49F79E66.60605@sbcglobal.net> Message-ID: I am not sure if you are referring to astrometry.net, but I think it does much of what you describe: http://astrometry.net/ Take care, Rose On Tue, Apr 28, 2009 at 8:25 PM, Wayne Watson wrote: > Probably not, but is what you mentioned source extraction? The idea is > that you take a picture of some part of the night sky, and then turn it > over to the source extractor. It twists, rescales, and turns your image > every which way until it matches 10 or more corresponding objects > (stars, etc.) in a photographic atlas of some sort. If it looks right, > you can then extract information about those objects and maybe others. > It's an astrometric tool. > > James Turner wrote: >>> I believe in some of my exchanges on this mailing list in the last >>> many works someone mentioned an IRAF facility akin to what is >>> popularly called source extract. Mention was made of what could be >>> considered a command name that somehow is used in connection with the >>> idea. Does anyone know what that single (command) word was or where I >>> would find the extractor topic discussed in IRAF? >> >> Is it noao.digiphot.apphot (type "help apphot")? >> >> James. >> > > -- > ? ? ? ? ? Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > ? ? ? ? ? ? (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > ? ? ? ? ? ? ?Obz Site: ?39? 15' 7" N, 121? 2' 32" W, 2700 feet > > ? ? ? ? ? All the neutrons, and protons in the human body occupy > ? ? ? ? ? a cube whose side is 5.52*10**-6 meters (tiny!). That > ? ? ? ? ? adds up to a 150 pound person. It's not a surprise that > ? ? ? ? ? we are mostly space. (Calculation by WTW) > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- Rose A. Finn, PhD Department of Physics Siena College Loudonville, NY (518) 782-6764 From sierra_mtnview at sbcglobal.net Tue Apr 28 20:58:52 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 28 Apr 2009 17:58:52 -0700 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: References: <49F7660F.1070108@sbcglobal.net> <49F785CA.40701@gemini.edu> <49F79E66.60605@sbcglobal.net> Message-ID: <49F7A64C.8050903@sbcglobal.net> Just IRAF. Well, I can easily get around this in a paper I'm writing by just saying that IRAF is another tool that does source extraction. BTW, who created IRAF and who supports it? I found the install pdf. Ah, NOAO. I don't have it installed, since I'm on Win. I did did install Cygwin, but never got around to installing it there. It's not something I need immediately. Rose Finn wrote: > I am not sure if you are referring to astrometry.net, but I think it > does much of what you describe: > > http://astrometry.net/ > > Take care, > Rose > > On Tue, Apr 28, 2009 at 8:25 PM, Wayne Watson > wrote: > >> Probably not, but is what you mentioned source extraction? The idea is >> that you take a picture of some part of the night sky, and then turn it >> over to the source extractor. It twists, rescales, and turns your image >> every which way until it matches 10 or more corresponding objects >> (stars, etc.) in a photographic atlas of some sort. If it looks right, >> you can then extract information about those objects and maybe others. >> It's an astrometric tool. >> >> James Turner wrote: >> >>>> I believe in some of my exchanges on this mailing list in the last >>>> many works someone mentioned an IRAF facility akin to what is >>>> popularly called source extract. Mention was made of what could be >>>> considered a command name that somehow is used in connection with the >>>> idea. Does anyone know what that single (command) word was or where I >>>> would find the extractor topic discussed in IRAF? >>>> >>> Is it noao.digiphot.apphot (type "help apphot")? >>> >>> James. >>> >>> >> -- >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >> >> All the neutrons, and protons in the human body occupy >> a cube whose side is 5.52*10**-6 meters (tiny!). That >> adds up to a 150 pound person. It's not a surprise that >> we are mostly space. (Calculation by WTW) >> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From rwagner at physics.ucsd.edu Tue Apr 28 23:07:58 2009 From: rwagner at physics.ucsd.edu (Rick Wagner) Date: Tue, 28 Apr 2009 20:07:58 -0700 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: <49F7A64C.8050903@sbcglobal.net> References: <49F7660F.1070108@sbcglobal.net> <49F785CA.40701@gemini.edu> <49F79E66.60605@sbcglobal.net> <49F7A64C.8050903@sbcglobal.net> Message-ID: Hi, Out of curiosity (and some background knowledge), I did some hunting around on the IRAF site. My original comment was going to be that SExtractor [1], is an independent tool, which "builds a catalogue of objects from an astronomical image", and is separate from IRAF [2], which is designed for image manipulation. And I was going to agree with Rose that what you were probably looking for was astrometry.net. However, what I found on the IRAF site was this entry in the FAQs: Is there an ASTROMETRY package I can use? http://tinyurl.com/dl7sly Now, what I think your looking for is the imcoords package in IRAF, which includes functions like this [3]: ccfind: Locate reference catalog objects in images ccxymatch: Match celestial and pixel coordinate lists Hope I'm close, if not, I hope this didn't take up too much of your time. --Rick [1] SExtractor - http://tinyurl.com/cbhk4r [2] IRAF - http://iraf.net [3] http://iraf.noao.edu/irafnews/apr98/irafnews.14.html > > Just IRAF. Well, I can easily get around this in a paper I'm > writing by > just saying that IRAF is another tool that does source extraction. > BTW, > who created IRAF and who supports it? I found the install pdf. > Ah, NOAO. > > I don't have it installed, since I'm on Win. I did did install Cygwin, > but never got around to installing it there. It's not something I need > immediately. > > Rose Finn wrote: >> I am not sure if you are referring to astrometry.net, but I think it >> does much of what you describe: >> >> http://astrometry.net/ >> >> Take care, >> Rose >> >> On Tue, Apr 28, 2009 at 8:25 PM, Wayne Watson >> wrote: >> >>> Probably not, but is what you mentioned source extraction? The >>> idea is >>> that you take a picture of some part of the night sky, and then >>> turn it >>> over to the source extractor. It twists, rescales, and turns your >>> image >>> every which way until it matches 10 or more corresponding objects >>> (stars, etc.) in a photographic atlas of some sort. If it looks >>> right, >>> you can then extract information about those objects and maybe >>> others. >>> It's an astrometric tool. >>> >>> James Turner wrote: >>> >>>>> I believe in some of my exchanges on this mailing list in the last >>>>> many works someone mentioned an IRAF facility akin to what is >>>>> popularly called source extract. Mention was made of what could be >>>>> considered a command name that somehow is used in connection >>>>> with the >>>>> idea. Does anyone know what that single (command) word was or >>>>> where I >>>>> would find the extractor topic discussed in IRAF? >>>>> >>>> Is it noao.digiphot.apphot (type "help apphot")? >>>> >>>> James. >>>> >>>> >>> -- >>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>> >>> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >>> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >>> >>> All the neutrons, and protons in the human body occupy >>> a cube whose side is 5.52*10**-6 meters (tiny!). That >>> adds up to a 150 pound person. It's not a surprise that >>> we are mostly space. (Calculation by WTW) >>> >>> >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org >>> http://mail.scipy.org/mailman/listinfo/astropy >>> >>> >> >> >> >> > > -- > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) > Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet > > All the neutrons, and protons in the human body occupy > a cube whose side is 5.52*10**-6 meters (tiny!). That > adds up to a 150 pound person. It's not a surprise that > we are mostly space. (Calculation by WTW) > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From dtody at nrao.edu Tue Apr 28 23:42:19 2009 From: dtody at nrao.edu (Douglas Tody) Date: Tue, 28 Apr 2009 21:42:19 -0600 (MDT) Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: References: <49F7660F.1070108@sbcglobal.net> <49F785CA.40701@gemini.edu> <49F79E66.60605@sbcglobal.net> <49F7A64C.8050903@sbcglobal.net> Message-ID: Hi - You might also want to look at ACE, although I do not know the current status of the package. See for example the paper by Valdes, 2001: http://www.adass.org/adass/proceedings/adass00/P3-01/ There are various other related packages in IRAF as well. - Doug On Tue, 28 Apr 2009, Rick Wagner wrote: > Hi, > > Out of curiosity (and some background knowledge), I did some hunting > around on the IRAF site. My original comment was going to be that > SExtractor [1], is an independent tool, which "builds a catalogue of > objects from an astronomical image", and is separate from IRAF [2], > which is designed for image manipulation. And I was going to agree > with Rose that what you were probably looking for was astrometry.net. > > However, what I found on the IRAF site was this entry in the FAQs: > Is there an ASTROMETRY package I can use? > http://tinyurl.com/dl7sly > > Now, what I think your looking for is the imcoords package in IRAF, > which includes functions like this [3]: > > ccfind: Locate reference catalog objects in images > ccxymatch: Match celestial and pixel coordinate lists > > Hope I'm close, if not, I hope this didn't take up too much of your > time. > > --Rick > > [1] SExtractor - http://tinyurl.com/cbhk4r > [2] IRAF - http://iraf.net > [3] http://iraf.noao.edu/irafnews/apr98/irafnews.14.html >> > > >> Just IRAF. Well, I can easily get around this in a paper I'm >> writing by >> just saying that IRAF is another tool that does source extraction. >> BTW, >> who created IRAF and who supports it? I found the install pdf. >> Ah, NOAO. >> >> I don't have it installed, since I'm on Win. I did did install Cygwin, >> but never got around to installing it there. It's not something I need >> immediately. >> >> Rose Finn wrote: >>> I am not sure if you are referring to astrometry.net, but I think it >>> does much of what you describe: >>> >>> http://astrometry.net/ >>> >>> Take care, >>> Rose >>> >>> On Tue, Apr 28, 2009 at 8:25 PM, Wayne Watson >>> wrote: >>> >>>> Probably not, but is what you mentioned source extraction? The >>>> idea is >>>> that you take a picture of some part of the night sky, and then >>>> turn it >>>> over to the source extractor. It twists, rescales, and turns your >>>> image >>>> every which way until it matches 10 or more corresponding objects >>>> (stars, etc.) in a photographic atlas of some sort. If it looks >>>> right, >>>> you can then extract information about those objects and maybe >>>> others. >>>> It's an astrometric tool. >>>> >>>> James Turner wrote: >>>> >>>>>> I believe in some of my exchanges on this mailing list in the last >>>>>> many works someone mentioned an IRAF facility akin to what is >>>>>> popularly called source extract. Mention was made of what could be >>>>>> considered a command name that somehow is used in connection >>>>>> with the >>>>>> idea. Does anyone know what that single (command) word was or >>>>>> where I >>>>>> would find the extractor topic discussed in IRAF? >>>>>> >>>>> Is it noao.digiphot.apphot (type "help apphot")? >>>>> >>>>> James. >>>>> >>>>> >>>> -- >>>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>>> >>>> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >>>> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >>>> >>>> All the neutrons, and protons in the human body occupy >>>> a cube whose side is 5.52*10**-6 meters (tiny!). That >>>> adds up to a 150 pound person. It's not a surprise that >>>> we are mostly space. (Calculation by WTW) >>>> >>>> >>>> _______________________________________________ >>>> AstroPy mailing list >>>> AstroPy at scipy.org >>>> http://mail.scipy.org/mailman/listinfo/astropy >>>> >>>> >>> >>> >>> >>> >> >> -- >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) >> Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet >> >> All the neutrons, and protons in the human body occupy >> a cube whose side is 5.52*10**-6 meters (tiny!). That >> adds up to a 150 pound person. It's not a surprise that >> we are mostly space. (Calculation by WTW) >> >> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From erwin at mpe.mpg.de Wed Apr 29 00:58:41 2009 From: erwin at mpe.mpg.de (Peter Erwin) Date: Wed, 29 Apr 2009 06:58:41 +0200 Subject: [AstroPy] Past Mention of Source Extractor Command in IRAF? In-Reply-To: <49F79E66.60605@sbcglobal.net> References: <49F7660F.1070108@sbcglobal.net> <49F785CA.40701@gemini.edu> <49F79E66.60605@sbcglobal.net> Message-ID: On Apr 29, 2009, at 2:25 AM, Wayne Watson wrote: > Probably not, but is what you mentioned source extraction? The idea is > that you take a picture of some part of the night sky, and then turn > it > over to the source extractor. It twists, rescales, and turns your > image > every which way until it matches 10 or more corresponding objects > (stars, etc.) in a photographic atlas of some sort. If it looks right, > you can then extract information about those objects and maybe others. > It's an astrometric tool. This sounds like a combination of two or three things: source extraction; catalog matching, and generating astrometric solutions. I can't quite tell from your description how much of each you're interested in. But here's some background: 1. Source extraction: this refers to a program which analyzes a FITS image and finds "sources" -- places that are brighter than the background, such as stars and galaxies (but hopefully not random noise spikes). It generates a table which lists each source, its position, and various measurements derived directly from the image (brightness, size, shape, orientation, etc.). It knows nothing about other atlases or catalogs; it just reports what it can measure on that particular image. Note that the position that the source extraction program reports are positions on the image in pixel coordinates (x, y). If the FITS image happens to have astrometric information in the header already (see below), then it will also calculate and report the sky coordinates (RA, Declination) for each source. The latter coordinates will be as good or bad as the astrometric information in the FITS header. A source extraction program does not do astrometry by itself at all; what it does do is generate lists of sources which can then be used in the astrometry process. As others have pointed out, there are some tasks within IRAF that will do this. There is also the standalone program SExtractor, which is designed to be run from the command line (Unix/MacOS X, or Cygwin). 2. Catalog matching: this means taking each source in the extracted catalog and identifying it with a known astronomical object, such as a star in a star catalog. Generally, this requires having good sky coordinates for the image. If you *don't* have sky coordinates for the image, then you may need to match a few objects (e.g. three or four bright stars) by hand (e.g., compare your image with a sky atlas to figure out which star is which, then copy the RA,Dec coordinates by hand). This will give you a starting list for making an initial astometry solution. From there, you can repeat the process (using the image with updated headers) and get a better astrometry solution using the full list of sources from the source extraction stage. 3. Generating an astrometry solution: this means taking a matched list of object coordinates in your image -- that is, a list of objects for which you have positions on the image (pixel coordinates x, y) *and* their correct positions on the sky (e.g., RA, Declination from a catalog) -- and then finding a general solution that maps pixel coordinates (x,y) to sky coordinates (RA, Dec). The resulting solution is then stored in the FITS header, so that other programs can read it and convert pixel coordinates (x,y) to sky coordinates (RA,Dec) automatically. There are tasks within IRAF which do this; there is also a standalone program called SCAMP (designed to work with catalogs produced by SExtractor). The astrometry.net project is intended to be a sort of all-in-one solution for Step 3, doing Steps 1 and 2 automatically along the way as needed. If it works out as planned (and it sounds like they're making progress), it will probably end up being all you (or even most of us!) ever need. I'm impressed as hell with their ambition. But at the moment it's in an alpha stage; I've never tried it, the web interface requires registering as an "alpha tester", and it looks like installing it on your own machine would require several gigabytes of disk space. In the meantime, you might also look at the programs here: http://tdc-www.harvard.edu/software/wcstools/ cheers, Peter ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)89 30000 3695 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From sierra_mtnview at sbcglobal.net Wed Apr 29 14:22:13 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 29 Apr 2009 11:22:13 -0700 Subject: [AstroPy] Video Formats in FITS? Message-ID: <49F89AD5.4050008@sbcglobal.net> When video cameras are used for astronomy, is FITS used as the format for each frame, or is there some other preferred format? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From y.copin at ipnl.in2p3.fr Thu Apr 30 13:50:10 2009 From: y.copin at ipnl.in2p3.fr (Yannick Copin) Date: Thu, 30 Apr 2009 10:50:10 -0700 Subject: [AstroPy] Video Formats in FITS? In-Reply-To: References: Message-ID: <49F9E4D2.3000403@ipnl.in2p3.fr> astropy-request at scipy.org wrote: > When video cameras are used for astronomy, is FITS used as the format > for each frame, or is there some other preferred format? I guess the standard in that case is to store the video output in a NAXIS=3 FITS cube, the 3rd dimension being the time. SAOimage ds9 (http://hea-www.harvard.edu/RD/ds9/) can play them gracefully. Cheers. -- .~. Yannick COPIN (o:>* Doctus cum libro /V\ Institut de physique nucleaire de Lyon (IN2P3-France) // \\ Lawrence Berkeley National Laboratory /( )\ aim:YnCopin icq:236931013 http://snovae.in2p3.fr/ycopin/ ^`~'^ From sierra_mtnview at sbcglobal.net Thu Apr 30 14:57:44 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Thu, 30 Apr 2009 11:57:44 -0700 Subject: [AstroPy] Version No. for IRAF Software? Message-ID: <49F9F4A8.5060108@sbcglobal.net> I'm writing a paper and wanted to cite IRAF. The editor provided this, but I need to provide the version no. Anyone know? Maybe it's just a date. Boroson, T., Tody, D. Shaw., R., Davis, L., De La Pens, M., Fitzpatrick, M., Seaman, R., Valdes, F., Zarate, N. (2009). Image Reduction and Analysis Facility (IRAF) software, _*vx.x.x.x.*_ http://iraf.noao.edu/ -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From jturner at gemini.edu Thu Apr 30 15:02:39 2009 From: jturner at gemini.edu (James Turner) Date: Thu, 30 Apr 2009 15:02:39 -0400 Subject: [AstroPy] Version No. for IRAF Software? In-Reply-To: <49F9F4A8.5060108@sbcglobal.net> References: <49F9F4A8.5060108@sbcglobal.net> Message-ID: <49F9F5CF.8050701@gemini.edu> > I'm writing a paper and wanted to cite IRAF. The editor provided this, > but I need to provide the version no. Anyone know? Maybe it's just a date. You can type "show version" in IRAF. The latest one is 2.14.1. It also tells you at the top of the message when you start the CL. James. From sierra_mtnview at sbcglobal.net Thu Apr 30 15:20:16 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Thu, 30 Apr 2009 12:20:16 -0700 Subject: [AstroPy] Version No. for IRAF Software? In-Reply-To: <49F9F5CF.8050701@gemini.edu> References: <49F9F4A8.5060108@sbcglobal.net> <49F9F5CF.8050701@gemini.edu> Message-ID: <49F9F9F0.9040102@sbcglobal.net> Thanks. I don't have access to it yet, but I know the feature I want to mention is in it. James Turner wrote: >> I'm writing a paper and wanted to cite IRAF. The editor provided this, >> but I need to provide the version no. Anyone know? Maybe it's just a >> date. > > You can type "show version" in IRAF. The latest one is 2.14.1. > It also tells you at the top of the message when you start the CL. > > James. > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW)