Einstein-Face (CASA 3.2): Difference between revisions

From CASA Guides
Jump to navigationJump to search
Mlacy (talk | contribs)
No edit summary
Ahale (talk | contribs)
No edit summary
 
(44 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Simulations Intro}}
''A new version of this page exists for CASA 3.3: [[Einstein-Face (CASA 3.3)]].''
'''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. These toy models can be particularly useful for examining the effects of varying uv-coverage on image fidelity if the "truth" model is a familiar object or image. In this example (which is on page 13 of the [http://almatelescope.ca/ALMA-ESPrimer.pdf ALMA Early Science Primer])we use the face of Albert Einstein.


'''Step 1:''' obtain your image. Typically from the internet.
In this example, we grabbed a JPG image of Einstein's face from the internet.  Simdata likes input images in fits format, so we used Gimp to convert the file.  (Instructions to [[Convert jpg to fits]].)  The original image is shown below. You can grab the converted fits file here from the [http://casaguides.nrao.edu/index.php?title=Sim_Inputs Simulation Inputs CASA Guide page].


[[File:Einstein.jpg]]
[[File:Einstein.jpg]]


In this case, it is a jpg file.
'''Prepare inputs for simdata'''


'''Step 2:''' Convert your image to FITS
Start with the 10min full science observation. Inputs to simdata are given below. The integration time
is set much longer than realistic (300s, compared to 1-10s in practice) to speed the computation. The map spacing is set to ensure that only one pointing is observed. The image scale is chosen to ensure good sampling of the beam, and the observation is pointed near the Chandra Deep Field South:


Various software programs have conversion to FITS enabled. The ([http://www.gimp.org GIMP]) was used in this case.
<source lang="python">
A handy list of FITS conversion programs is maintained by GSFC [http://fits.gsfc.nasa.gov/fits_viewer.html here]


For the GIMP, start up the software
default 'simdata'
project = 'fs_cfg8_10m'  # Full science, configuration 08, 10 minutes
modifymodel = T
skymodel = 'Einstein.fits'
indirection = 'J2000 03h30m00 -28d00m00'
incell = '0.043arcsec'
incenter = '245GHz'
inwidth = '2GHz'
setpointings = T
integration = '300s'
mapsize = ['1arcmin','1arcmin']
maptype = 'hexagonal'
pointingspacing = '1arcmin'
predict = T
graphics = 'both'
</source>


>gimp &
Antenna configuration:
 
ALMA antenna configuration files are stored in a directory that depends on your CASA installation.  
and in the main window select "Open" from the "File" menu.
To be sure of finding them, identify the CASAPATH variable using the os.getenv command, and pick
 
the configuration you want. Details on configuration choices are given in the
The image will open up in a new window, you can use the GIMP to modify
M51 simulation guide [http://casaguides.nrao.edu/index.php?title=M51_at_z_%3D_0.1_and_z_%3D_0.3].
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, e.g. einstein.fits
 
[[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. 
<source lang="python">
                               
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
repodir=os.getenv("CASAPATH").split(' ')[0]
antennalist        =  repodir+"/data/alma/simmos/alma.out08.cfg"
totaltime = '600s'
thermalnoise = ""
image = T
vis = '$project.ms'
imsize = [300,300]
cell = '0.043arcsec'
niter = 2000
weighting = 'natural'
analyze=F
overwrite=T
simdata
</source>


At this stage, we need to perform some manipulations on the FITS file to get it readable by CASA.
The output image should have a synthesized beam of 0.62"x0.56" and look something like:
For convenience, we are also adding a WCS at this point (though this can also be done in simdata).
[[File:einstein_fs_cfg8_10min.gif]]
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 script is in [[File:Make_2dimage.pro.txt]] (remove the .txt from the filename before using).
Now we repeat for an 1hr observation:


IDL>make_2dimage,'einstein.fits',0,299,27,326
<source lang="python">
tget simdata
project = 'fs_cfg8_1hr' # Full science, configuration 08, 1 hour
totaltime = '3600s'
simdata
</source>


The IDL code performs the following manipulations:
Which should look something like: [[File:einstein_fs_cfg8_1hr.gif]]


1) Reads in the FITS file as a 2D array, trims it to 300x300 pixels and converts it to real, 300x300x1 array
Finally, two Early Science simulations, using the extended configuration. One 10min simulation:
(the third dimension is added for generality to allow the construction of an image cube, it is
not actually necessary in this particular case).


2) Creates header keywords corresponding to the axis types (CTYPE1,2,3) values at the
<source lang="python">
reference pixels (CRVAL1,2,3), the reference pixel positions (CRPIX1,2,3) and the axis
tget simdata
increments (CDELT1,2,3), and the epoch (EPOCH).
project = 'es_extended_10m'
antennalist = repodir+"/data/alma/simmos/alma.cycle0.extended.cfg"
totaltime = '600s'
simdata
</source>


3) Writes out the modified FITS file as "twodmodel.fits"
which looks like this: [[File:einstein_es_extended_10min.gif]]


'''Step 5''' Start CASA and prepare inputs for simdata
and a 4hr simulation:


>casapy
<source lang="python">
tget simdata
project = 'es_extended_4hr'
totaltime = '14400s'
simdata
</source>


>task 'simdata'
which looks like this: [[File:einstein_es_extended_4hr.gif]]


>modifymodel = F
'''Further experiments:'''


>skymodel = 'twodmodel.fits'
Some more things to try:


>setpointings = T
An 8hr observation shows the improvement obtained by obtaining fuller uv-coverage in the full science array:
<source lang="python">
tget simdata
antennalist = repodir+"/data/alma/simmos/alma.out08.cfg"
project = 'fs_cfg8_8hr'
totaltime = '28800s'
simdata
</source>


>integration = 300s
Which should look something like: [[File:einstein_fs_cfg8_8hr.gif]]


>mapsize = ['1arcmin','1arcmin']
An attempt to make a higher resolution image shows what happens when short spacings are missing in the configuration.
Configuration 16 has a 0.17x0.15 beam, still better than Nyquist sampling of the model image (which has 0.043" pixels).
However, the lack of short spacings in the configuration leads to poorly sampled structure on large spatial scales. In practice, one
would need to combine these observations with a set in a more compact configuration (such as 8) to sample both the large
and small spatial structures.


>maptype = 'hexagonal'
<source lang="python">
 
tget simdata
>pointingspacing = '1arcmin'
antennalist = repodir+"/data/alma/simmos/alma.out16.cfg"
 
project = 'fs_cfg16_1hr'
>predict = T
totaltime = '3600s'
 
simdata
Antennalist:
</source>
ALMA antenna configuration files are stored in a directory that depends on your CASA installation
to be sure of finding them, identify the CASAPATH variable using the os.getenv command, and pick
the configuration you want. Details on configuration choices are given in the
[[M51_at_z_%3D_0.1_and_z_%3D_0.3] M51 simulation guide]


>repodir=os.getenv("CASAPATH").split(' ')[0]
The result is: [[File:einstein_fs_cfg16_1hr.gif]]


>antennalist        =  repodir+"/data/alma/simmos/alma.out02.cfg"
{{Simulations Intro}}

Latest revision as of 20:07, 21 October 2011

Simulating Observations in CASA

A new version of this page exists for CASA 3.3: Einstein-Face (CASA 3.3).

Simulations using non-science images: the face of Einstein

Simdata can be used to simulate any digitized image. These toy models can be particularly useful for examining the effects of varying uv-coverage on image fidelity if the "truth" model is a familiar object or image. In this example (which is on page 13 of the ALMA Early Science Primer)we use the face of Albert Einstein.

In this example, we grabbed a JPG image of Einstein's face from the internet. Simdata likes input images in fits format, so we used Gimp to convert the file. (Instructions to Convert jpg to fits.) The original image is shown below. You can grab the converted fits file here from the Simulation Inputs CASA Guide page.

Prepare inputs for simdata

Start with the 10min full science observation. Inputs to simdata are given below. The integration time is set much longer than realistic (300s, compared to 1-10s in practice) to speed the computation. The map spacing is set to ensure that only one pointing is observed. The image scale is chosen to ensure good sampling of the beam, and the observation is pointed near the Chandra Deep Field South:

default 'simdata'
project = 'fs_cfg8_10m'  # Full science, configuration 08, 10 minutes
modifymodel = T
skymodel = 'Einstein.fits'
indirection = 'J2000 03h30m00 -28d00m00'
incell = '0.043arcsec'
incenter = '245GHz'
inwidth = '2GHz'
setpointings = T
integration = '300s'
mapsize = ['1arcmin','1arcmin']
maptype = 'hexagonal'
pointingspacing = '1arcmin'
predict = T
graphics = 'both'

Antenna configuration: ALMA antenna configuration files are stored in a directory that depends on your CASA installation. To be sure of finding them, identify the CASAPATH variable using the os.getenv command, and pick the configuration you want. Details on configuration choices are given in the M51 simulation guide [1].


repodir=os.getenv("CASAPATH").split(' ')[0]
antennalist        =  repodir+"/data/alma/simmos/alma.out08.cfg"
totaltime = '600s'
thermalnoise = ""
image = T
vis = '$project.ms'
imsize = [300,300]
cell = '0.043arcsec'
niter = 2000
weighting = 'natural'
analyze=F
overwrite=T
simdata

The output image should have a synthesized beam of 0.62"x0.56" and look something like:

Now we repeat for an 1hr observation:

tget simdata
project = 'fs_cfg8_1hr'  # Full science, configuration 08, 1 hour
totaltime = '3600s'
simdata

Which should look something like:

Finally, two Early Science simulations, using the extended configuration. One 10min simulation:

tget simdata
project = 'es_extended_10m'
antennalist = repodir+"/data/alma/simmos/alma.cycle0.extended.cfg"
totaltime = '600s'
simdata

which looks like this:

and a 4hr simulation:

tget simdata
project = 'es_extended_4hr'
totaltime = '14400s'
simdata

which looks like this:

Further experiments:

Some more things to try:

An 8hr observation shows the improvement obtained by obtaining fuller uv-coverage in the full science array:

tget simdata
antennalist = repodir+"/data/alma/simmos/alma.out08.cfg"
project = 'fs_cfg8_8hr'
totaltime = '28800s'
simdata

Which should look something like:

An attempt to make a higher resolution image shows what happens when short spacings are missing in the configuration. Configuration 16 has a 0.17x0.15 beam, still better than Nyquist sampling of the model image (which has 0.043" pixels). However, the lack of short spacings in the configuration leads to poorly sampled structure on large spatial scales. In practice, one would need to combine these observations with a set in a more compact configuration (such as 8) to sample both the large and small spatial structures.

tget simdata
antennalist = repodir+"/data/alma/simmos/alma.out16.cfg"
project = 'fs_cfg16_1hr'
totaltime = '3600s'
simdata

The result is:

Simulating Observations in CASA