Einstein-Face (CASA 3.2): Difference between revisions

From CASA Guides
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
'''Simulations using non-science images: the face of Einstein
'''Simulations using non-science images: the face of Einstein
'''
'''
Simdata can be used to simulate any digitized image. In this example, we use the face of Albert Einstein.
Simdata can be used to simulate any digitized image. In this example, we use the face of Albert Einstein.


Line 28: Line 29:


[[File:Gimp_save.jpg]]
[[File:Gimp_save.jpg]]
'''Step 3:''' check your file
Read your file into e.g. [http://hea-www.harvard.edu/RD/ds9/ ds9]to check that a valid FITS file has been produced. You can
also examine the pixel values to examine the scaling of the image. In this case,
Einstein's forehead has pixel values around 230 and the background around 40, so there
is plenty of contrast. You can also examine the image header in ds9. Under the "File"
menu, select "Display FITS Header" and examine the output. Make sure that SIMPLE = T, NAXIS=2 and
check BITPIX. In this case, BITPIX=8, which is not valid for reading into CASA, so we need to
change that at the next step.
FITS header produced by GIMP:
SIMPLE  =                    T
                                               
BITPIX  =                    8
                                                 
NAXIS  =                    2 
                                               
NAXIS1  =                  300
                                               
NAXIS2  =                  327 
                                               
BZERO  =            0.000000 
                                               
BSCALE  =            1.000000 
                                               
DATAMIN =            0.000000 
                                               
DATAMAX =          255.000000                                                 
                                                                               
HISTORY THIS FITS FILE WAS GENERATED BY GIMP USING FITSRW                     
                                                                               
COMMENT FitsRW is (C) Peter Kirchgessner (peter@kirchgessner.net), but available
COMMENT under the GNU general public licence.                                 
COMMENT For sources see http://www.kirchgessner.net                           
                                                                               
COMMENT Image type within GIMP: GIMP_GRAY_IMAGE                               
                                                                               
END                                                                           
'''Step 4''' Add FITS header keywords and change the format
At this stage, we need to perform some manipulations on the FITS file to get it readable by CASA.
For convenience, we are also adding a WCS at this point (though this can also be done in simdata).
This routine is written in IDL, using the [http://idlastro.gsfc.nasa.gov/ IDL astronomy library],
but similar manipulations can be carried out in IRAF, or using the python PyWCS and PyFITS libraries,
available from the [http://www.astropython.org/ astropython project].
The IDL code performs the following manipulations:
1) Reads in the FITS file as a 2D array, trims it to 300x300 pixels and converts it to real, 300x300x1 array
(the third dimension is added for generality to allow the construction of an image cube, it is
not actually necessary in this particular case). The image is also divided by 200000 to give it
an approximately realistic scaling in Jy/pixel (again, not actually necessary).
2) Creates header keywords corresponding to the axis types (CTYPE1,2,3) values at the
reference pixels (CRVAL1,2,3), the reference pixel positions (CRPIX1,2,3) and the axis
increments (CDELT1,2,3), and the epoch (EPOCH).
3) Writes out the modified FITS file as "twodmodel.fits"

Revision as of 17:09, 9 February 2011

Simulations using non-science images: the face of Einstein

Simdata can be used to simulate any digitized image. In this example, we use the face of Albert Einstein.

Step 1: obtain your image. Typically from the internet.

Einstein.jpg

In this case, it is a jpg file.

Step 2: Convert your image to FITS

Various software programs have conversion to FITS enabled. The (GIMP) was used in this case. A handy list of FITS conversion programs is maintained by GSFC here

For the GIMP, start up the software

>gimp &

and in the main window select "Open" from the "File" menu.

The image will open up in a new window, you can use the GIMP to modify the image (adjust contrast, colormap etc).

Then, select "Save as" from the "File" menu in the window containing the image, and hit "Select File Type" in the dialog box to bring up the file type options, and select "Flexible Image Transport System". Pick a name for your file ending in .fits

Gimp save.jpg

Step 3: check your file

Read your file into e.g. ds9to check that a valid FITS file has been produced. You can also examine the pixel values to examine the scaling of the image. In this case, Einstein's forehead has pixel values around 230 and the background around 40, so there is plenty of contrast. You can also examine the image header in ds9. Under the "File" menu, select "Display FITS Header" and examine the output. Make sure that SIMPLE = T, NAXIS=2 and check BITPIX. In this case, BITPIX=8, which is not valid for reading into CASA, so we need to change that at the next step.

FITS header produced by GIMP:

SIMPLE = T

BITPIX = 8

NAXIS = 2

NAXIS1 = 300

NAXIS2 = 327

BZERO = 0.000000

BSCALE = 1.000000

DATAMIN = 0.000000

DATAMAX = 255.000000

HISTORY THIS FITS FILE WAS GENERATED BY GIMP USING FITSRW

COMMENT FitsRW is (C) Peter Kirchgessner (peter@kirchgessner.net), but available COMMENT under the GNU general public licence. COMMENT For sources see http://www.kirchgessner.net

COMMENT Image type within GIMP: GIMP_GRAY_IMAGE

END

Step 4 Add FITS header keywords and change the format

At this stage, we need to perform some manipulations on the FITS file to get it readable by CASA. For convenience, we are also adding a WCS at this point (though this can also be done in simdata). This routine is written in IDL, using the IDL astronomy library, but similar manipulations can be carried out in IRAF, or using the python PyWCS and PyFITS libraries, available from the astropython project.

The IDL code performs the following manipulations:

1) Reads in the FITS file as a 2D array, trims it to 300x300 pixels and converts it to real, 300x300x1 array (the third dimension is added for generality to allow the construction of an image cube, it is not actually necessary in this particular case). The image is also divided by 200000 to give it an approximately realistic scaling in Jy/pixel (again, not actually necessary).

2) Creates header keywords corresponding to the axis types (CTYPE1,2,3) values at the reference pixels (CRVAL1,2,3), the reference pixel positions (CRPIX1,2,3) and the axis increments (CDELT1,2,3), and the epoch (EPOCH).

3) Writes out the modified FITS file as "twodmodel.fits"