Results 1 to 10 of 10

Thread: PSF FITS file

  1. #1
    Join Date
    Feb 2010
    Posts
    149

    PSF FITS file

    Does anyone know how to create a FITS image file?

    I'm using GALFIT to model some SDSS galaxies. A key input is a PSF image, in FITS format:
    Quote Originally Posted by GALFIT User's Manual
    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); I'm asking my question here because no one there has responded (I cannot believe that no zooite knows how to do this!)

  2. #2
    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).

  3. #3
    Join Date
    Sep 2006
    Posts
    1,247
    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/softw...sta/index.html

  4. #4
    Join Date
    Feb 2010
    Posts
    149
    Thanks to both of you.

  5. #5
    Join Date
    Feb 2010
    Posts
    149
    UPDATE: a package called 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.

  6. #6
    Please post if you have questions about pyfits: I use it frequently.

  7. #7
    Join Date
    Feb 2010
    Posts
    149
    Quote Originally Posted by parejkoj View Post
    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. 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! :-*

  8. #8
    Join Date
    Feb 2010
    Posts
    149
    Quote Originally Posted by Jean Tate View Post
    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 section.

  9. #9
    Join Date
    Feb 2010
    Posts
    149
    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 ...

  10. #10
    Join Date
    Aug 2006
    Posts
    319
    You may want to look into pyraf -- it combines python and iraf so you get the best of both worlds.

Similar Threads

  1. FITS files
    By Extrasolar in forum Space/Astronomy Questions and Answers
    Replies: 7
    Last Post: 2012-Mar-04, 11:02 AM
  2. Registax and FITS images
    By winensky in forum Astronomical Observing, Equipment and Accessories
    Replies: 10
    Last Post: 2008-Mar-17, 10:48 AM
  3. FITS Image File
    By Himanshu Raj in forum Astrophotography
    Replies: 2
    Last Post: 2008-Jan-13, 08:20 PM
  4. The ATM the fits into a TOE
    By bishadi in forum Against the Mainstream
    Replies: 1
    Last Post: 2007-Sep-14, 06:22 PM
  5. FITS software for Mac/PCs?
    By ToSeek in forum Space/Astronomy Questions and Answers
    Replies: 3
    Last Post: 2007-Mar-02, 06:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •