PDA

View Full Version : PSF FITS file



Jean Tate
2012-Aug-03, 09:01 PM
Does anyone know how to create a FITS image file?

I'm using GALFIT (http://users.obs.carnegiescience.edu/peng/work/galfit/galfit.html) to model some SDSS galaxies. A key input is a PSF image, in FITS format:

Item D – Convolution PSF: The observed PSF image, in FITS format, is required only if one wants to convolve a model with the PSF ...

Yep, that's what I want to do.

I can easily find plenty of stars near the galaxy I want to model, and so can model these with GALFIT (they almost circular (axis ratio ~0.95) Sérsic profiles, with n = 0.7 +/-0.05, effective radii = 1.6 +/-0.05 pix). But I have no idea how to turn either the image of a nice SDSS star into a PSF FITS (of the kind GALFIT is happy with, as input), or to create a PSF FITS from an almost circular (axis ratio 0.95) Sérsic profile, with n = 0.7, and effective radius 1.6 pix.

There's some history, over at the Galaxy Zoo forum (here (http://www.galaxyzooforum.org/index.php?topic=280174.0)); I'm asking my question here because no one there has responded (I cannot believe that no zooite knows how to do this!)

ngc3314
2012-Aug-03, 09:49 PM
How did I miss this over at GZ??? Ahh, I blame that week when my office was dismantled for duct replacement. My story and I'm sticking to it.

Anyway - do you have C or Python (or F77, C++...) on that machine? There are libraries for each of those (among others) to write FITS files from data arrays. If you have IRAF running, you can make a FITS file of a subimage:
imcopy SDSSimage.fits[201:220,315:335] PSFfile.fits
for example. If there is a nonzero sky background to subtract, you would use something like
imarith SDSSimage.fits[201:220,315:335] - 1023.4 PSFfile.fits

(IRAF also has a way to make a FITS file from a list of numbers in a text file - wtextimage).

StupendousMan
2012-Aug-04, 05:20 AM
If a simple integer image will do,
try reading this:

http://stupendous.rit.edu/richmond/answers/fits.howto

You can find source code to programs which
can create simple FITS images at:


http://stupendous.rit.edu/tass/software/xvista/index.html

Jean Tate
2012-Aug-05, 04:01 PM
Thanks to both of you.

Jean Tate
2012-Aug-12, 03:25 PM
UPDATE: a package called PyFITS (http://www.stsci.edu/institute/software_hardware/pyfits) may be downloaded from the Space Telescope Science Institute website: "PyFITS provides an interface to FITS formatted files in the Python scripting language and PyRAF, the Python-based interface to IRAF. It is useful both for interactive data analysis and for writing analysis scripts in Python using FITS files as either input or output."

You need to have Python installed, and also numpy, and you need to be familiar with Python.

parejkoj
2012-Aug-13, 08:01 AM
Please post if you have questions about pyfits: I use it frequently.

Jean Tate
2012-Aug-13, 06:16 PM
Please post if you have questions about pyfits: I use it frequently.
8)

Are you a zooite?

I've been asking about this sort of stuff over there, but often don't get answers. :(

Anyways, I'm on PAGE 1, the PyFITS Users Guide Quick Tutorial (http://packages.python.org/pyfits/users_guide/users_tutorial.html). Right at the beginning is a para on opening an existing FITS file, which introduces the PyFITS HDUList object ("which is a Python-like list, consisting of HDU objects"). Which is very cool! 8)

But HDUList is written with 4 caps (and 3 lower-case), yet the examples given use all lower-case! WHY? ??? Small thing, but annoying.

Deeper: suppose I create a numpy object, scidata, which is the image data from a particular FITS (just like in the Quick Tutorial). The QT gives an example of converting image data from counts to flux. I don't really follow it; is "scidata \*= photflam / exptime" numpy-speak?

Anyway, if I have the residual image data from GALFIT (which has a dtype of float32), in scidata, and want to replace the value of every '<0' pixel with 0.0, how could I do that using the kind of array manipulation shown in this QT example (yeah, I need to go learn numpy)?

Help much appreciated! :-*

Jean Tate
2012-Aug-13, 11:41 PM
Anyway, if I have the residual image data from GALFIT (which has a dtype of float32), in scidata, and want to replace the value of every '<0' pixel with 0.0, how could I do that using the kind of array manipulation shown in this QT example (yeah, I need to go learn numpy)?

>>> scidata[scidata<0] = 0

If the dtype is float32, int16 (or whatever) will be converted to float32, so this^ will do the same thing as this (with fewer keystrokes):

>>> scidata[scidata<0.0] = 0.0

From the Image Data (http://packages.python.org/pyfits/users_guide/users_image.html) section.

Jean Tate
2012-Aug-15, 09:45 PM
I'd like to, once again, say THANK YOU, to ngc3314, StupendousMan, and parejkoj! :) :-*

StupendousMan, while I didn't actually use the code, I did use your material to write, from scratch (in Python), code which produced a toy FITS file. By doing a 'worked example', I was able to understand better what a FITS file actually is, and, therefore something about how really cool tools like PyFITS must work.

ngc3314, I don't have IRAF (it's on my "To Do" list, but I honestly don't know when I'll get to it); does it give me anything that I can't have with Python (plus numpy, plus PyFITS, etc)?

parejkoj, you may live to regret that offer ;) Just wait till I really get going ... :D

matt.o
2012-Aug-15, 10:07 PM
You may want to look into pyraf -- it combines python and iraf so you get the best of both worlds.