A simple python module, wrapping pytfits+matplotlib: fits I/O + graphic/display environment

Hi,
(pls let me know if this post should be better redirected to scipy or numpy. It does relate to astropy of course...)

I am trying since some time to develop a simple module to wrap up some functionalities of pyfits and matplotlib.
The goal is to be able to manipulate FITS files (spectra, images, 3D cubes, including maybe Euro3D format for those who know what it is) and display them (plot slices, display images, etc) in a very simple way. It could be inspired from (although not a cloning of) simple functionalities found in Midas. So you can do things like

Image1.fits = Image2.fits / (Image3.fits + 3.4)

Table.fits.col1 = Table.fits.col2 * Table.fits.col4 / 2.

, or easily create a new Fits image, or table, display them by doing something like:

load("Image1.fits", scale=3, cuts=(0.,100.), center=(-1.,6.))

or alternatively:

ima = fitstab("Image1.fits")
load(ima, scale=3, cuts=(0.,100.), center=-1.,6.)

(where Image1.fits is displayed with a scaling factor of 3, with cuts as indicated, and the center of the figure corresponding to coordinates -1,6)

or

plot("Image1.fits", 0)

(plot a cut at vertical coordinate 0)

You could say then: use Midas. But Midas is clearly very limited (does not have the python built-in potential of course) and its display/plotting functions are really scarce. The fact that there is now a pyMidas available does not fill the gap since I would like to be able to run my favourite ide (ipython for the moment), and really profit from all python modularity/functions.

So the choice for an I/O with fits seems easy: "pyfits" which is a really fantastic module for dealing with FITS files.
And the choice for displaying is also not so difficult: "matplotlib" which is also an amazing module and provides paper quality figures.

My questions are then:

0/ is this a dum idea? Maybe I am missing something here, so just let me know...

1/ is there already something existing which does what I mention above?
(so a wrapper around pyfits+matplotlib). Maybe at StSci...?

2/ If I were to try to develop such a tool, it will result in a rather badly coded module: I will try my best but frankly I should be considered as a newby in python and I can sincerely say that I don't fully understand all the forum matplotlib/numpy/scipy discussions, by far... So the question is: would anybody be interested/willing to, once in a while, help me with this development?

Some could answer that using directly pyfits+matplotlib does the job. True. But if you wish to directly deal with fits and display them with some option (zooming, cuts, centering, etc) you still need to go through a number of steps which are not necessarily easy to remember (syntax, etc). Some wrapping could help quite a lot here.

Thanks for any input here.

cheers

Eric
P.S.: for the sake of completeness I could send anybody on request the very ugly looking - and unfinished modules I wrote last year in this context, when I seriously engaged in python in replacement of Midas/Iraf/Idl...

Hi,

I would like something like this too. I tried to play a little bit to implement it but unfortunatly I find an intrinsic limitation in matplotlib. It's using agg and agg can't have image bigger than 3kx3k pixels or something like this and even before this limit matplotlib take age to plot an image on screen.

Regars,

N.

Eric Emsellem wrote:

···

Hi,
(pls let me know if this post should be better redirected to scipy or numpy. It does relate to astropy of course...)

I am trying since some time to develop a simple module to wrap up some functionalities of pyfits and matplotlib.
The goal is to be able to manipulate FITS files (spectra, images, 3D cubes, including maybe Euro3D format for those who know what it is) and display them (plot slices, display images, etc) in a very simple way. It could be inspired from (although not a cloning of) simple functionalities found in Midas. So you can do things like

Image1.fits = Image2.fits / (Image3.fits + 3.4)

Table.fits.col1 = Table.fits.col2 * Table.fits.col4 / 2.

, or easily create a new Fits image, or table, display them by doing something like:

load("Image1.fits", scale=3, cuts=(0.,100.), center=(-1.,6.))

or alternatively:

ima = fitstab("Image1.fits")
load(ima, scale=3, cuts=(0.,100.), center=-1.,6.)

(where Image1.fits is displayed with a scaling factor of 3, with cuts as indicated, and the center of the figure corresponding to coordinates -1,6)

or

plot("Image1.fits", 0)

(plot a cut at vertical coordinate 0)

You could say then: use Midas. But Midas is clearly very limited (does not have the python built-in potential of course) and its display/plotting functions are really scarce. The fact that there is now a pyMidas available does not fill the gap since I would like to be able to run my favourite ide (ipython for the moment), and really profit from all python modularity/functions.

So the choice for an I/O with fits seems easy: "pyfits" which is a really fantastic module for dealing with FITS files.
And the choice for displaying is also not so difficult: "matplotlib" which is also an amazing module and provides paper quality figures.

My questions are then:

0/ is this a dum idea? Maybe I am missing something here, so just let me know...

1/ is there already something existing which does what I mention above?
(so a wrapper around pyfits+matplotlib). Maybe at StSci...?

2/ If I were to try to develop such a tool, it will result in a rather badly coded module: I will try my best but frankly I should be considered as a newby in python and I can sincerely say that I don't fully understand all the forum matplotlib/numpy/scipy discussions, by far... So the question is: would anybody be interested/willing to, once in a while, help me with this development?

Some could answer that using directly pyfits+matplotlib does the job. True. But if you wish to directly deal with fits and display them with some option (zooming, cuts, centering, etc) you still need to go through a number of steps which are not necessarily easy to remember (syntax, etc). Some wrapping could help quite a lot here.

Thanks for any input here.

cheers

Eric
P.S.: for the sake of completeness I could send anybody on request the very ugly looking - and unfinished modules I wrote last year in this context, when I seriously engaged in python in replacement of Midas/Iraf/Idl...

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

It certainly is true matplotlib has problems with really big images. But then I would ask first what you were expecting in the way of capabilities. I don't think one should expect a package to handle the automatic rescaling and resampling of very large images without substantial performance penalties. Were you looking for some simpler image display capability? Simple pixel dump the the screen (figimage comes closer to that but still does some processing). There aren't a lot of 3kx3k image displays out there yet so either you need to pan or subsample in some manner. If you can point out a reasonable capability that could handle large images, I think there would be a possibility of trying to do it at some stage. Is there a program that exists we should look to as a good example of what should be one? (Existence proofs are always a great way of convincing developers that it is possible, or at least what combination of features are worth implementing.)

Perry Greenfield

···

On May 4, 2006, at 11:28 AM, Humufr wrote:

Hi,

I would like something like this too. I tried to play a little bit to implement it but unfortunatly I find an intrinsic limitation in matplotlib. It's using agg and agg can't have image bigger than 3kx3k pixels or something like this and even before this limit matplotlib take age to plot an image on screen.

Hi,

I was just trying to see if that will be possible to use matplotlib like base to replace ds9. And someone asked me if it was possible to use matplotlib to overplot some field (it was to check if the field has been observed with different instrument) and I found this intrinsic limitation. I'm not complaining about it but Eric's question was to know if it was possible to do a wraping between pyfits and matplolib. In my experience, it's possible but not useful. I agree that 3kx3k image are not very common but 2kx2k are and in a normal system it not possible to think (at least now) to use matplotlib for image analysis.

I'm thinking that matplolib is great library believe me. I'm using it every day but I was just telling that matplotlib can't be use to replace ds9 and to be the base of an analysis tool (for two day dimensional image).

I remember a mail from you or someone from stsci about a python ds9. That will be something great clearly. ds9 is good but on linux it's became old especially du to the tk interface (no antilaliasing and probably bad default font from me). There are some other crtics I have about ds9 (user interface etc) but the tool is here and I'm very please by it but that don't means that I don't have some comments to do on it.

Regards,

N.

Perry Greenfield wrote:

···

On May 4, 2006, at 11:28 AM, Humufr wrote:

Hi,

I would like something like this too. I tried to play a little bit to implement it but unfortunatly I find an intrinsic limitation in matplotlib. It's using agg and agg can't have image bigger than 3kx3k pixels or something like this and even before this limit matplotlib take age to plot an image on screen.

It certainly is true matplotlib has problems with really big images. But then I would ask first what you were expecting in the way of capabilities. I don't think one should expect a package to handle the automatic rescaling and resampling of very large images without substantial performance penalties. Were you looking for some simpler image display capability? Simple pixel dump the the screen (figimage comes closer to that but still does some processing). There aren't a lot of 3kx3k image displays out there yet so either you need to pan or subsample in some manner. If you can point out a reasonable capability that could handle large images, I think there would be a possibility of trying to do it at some stage. Is there a program that exists we should look to as a good example of what should be one? (Existence proofs are always a great way of convincing developers that it is possible, or at least what combination of features are worth implementing.)

Perry Greenfield

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options