Simdata New Users Guide (CASA 3.2): Difference between revisions
mNo edit summary |
|||
(36 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Simulations Intro}} | {{Simulations Intro}} | ||
''A new version of this page exists for CASA 3.3: [[Simulation Guide for New Users (CASA 3.3)]].'' | |||
Remember that you need to follow this process: [[Extracting scripts from these tutorials]] to extract a casapy script from this web page. | |||
==Explanation of the guide== | ==Explanation of the guide== | ||
Line 36: | Line 40: | ||
Any parameter with a grey background is expandable. Red text shows an invalid value. Blue text shows an accepted, but not the default, value. | Any parameter with a grey background is expandable. Red text shows an invalid value. Blue text shows an accepted, but not the default, value. | ||
To get help on a given task, use "help". For instance | To get help on a given task, use "help" (to exit from help, hit the "q" key). For instance | ||
> help simdata | > help simdata | ||
Line 52: | Line 56: | ||
[[Image:NewUsersGuide.modifymodel.png|thumb|Screen shot of input parameters for "modifymodel"]] | [[Image:NewUsersGuide.modifymodel.png|thumb|Screen shot of input parameters for "modifymodel"]] | ||
Now tell simdata where to find the model (input) image and how to scale it appropriately for our purposes. Just to be safe, we'll first restore the default values of simdata and then set the 30 Doradus image as the skymodel. Setting modifymodel=True tells simdata that we will be modifying the image before simulating an ALMA observation. | Now tell simdata where to find the model (input) image and how to scale it appropriately for our purposes. Just to be safe, we'll first restore the default values of simdata and then set the 30 Doradus image as the skymodel ('''Note:''' you might need to include the path to your data set, if you are not currently in the working directory where the data set is). Setting modifymodel=True tells simdata that we will be modifying the image before simulating an ALMA observation. | ||
<source lang="python"> | |||
#Initialize simdata | |||
default simdata | |||
modifymodel = True | |||
skymodel = '30dor.fits' | |||
</source> | |||
We are using a Spitzer 8 micron image of 30 Doradus in this example, and we are going to ask simdata to modify this image in some important ways: | We are using a Spitzer 8 micron image of 30 Doradus in this example, and we are going to ask simdata to modify this image in some important ways: | ||
Line 64: | Line 71: | ||
====Angular Scale==== | ====Angular Scale==== | ||
If you open the fits image of 30 Doradus in your favorite viewer, you will see that it covers quite a large footprint on the sky, about 10' on a side. | If you open the fits image of 30 Doradus in your favorite viewer (e.g. 'viewer' in CASA), you will see that it covers quite a large footprint on the sky, about 10' on a side. We are going to tell simdata to rescale the pixels to shrink the image by roughly a factor of 15 (from 2.3" to 0.15" pixels through the 'incell' parameter) so that the model is approximately 40" on a side. This rescaled model will fit within a small mosaic of 6 pointings. Although we do this primarily for convenience in this example, a scientific motivation for this type of rescaling would be to approximate what a super-giant HII region like 30 Doradus would look like if moved from the Large Magellanic Cloud to the distance of M33 or M31. For the sake of demonstration, we will also change the coordinates of the center of the map (using the 'indirection' parameter). Units are case sensitive, please take care to enter them in verbatim, CASA will throw an error otherwise. | ||
<source lang="python"> | |||
incell = '0.15arcsec' | |||
indirection = 'J2000 10h00m00 -40d00m00' | |||
</source> | |||
====Observed Wavelength==== | ====Observed Wavelength==== | ||
Line 73: | Line 82: | ||
The model image of 30 Doradus shows the 8 micron continuum emission. ALMA does not observe at wavelengths this short, so we will tell simdata that this is actually a 230 GHz (1.3 mm) continuum map. We will also tell simdata that the observations were taken with a 2 GHz bandwidth. Although for this particular example the channel width is not a critical number, it would be very important if we were modifying a spectral cube instead of a continuum image. | The model image of 30 Doradus shows the 8 micron continuum emission. ALMA does not observe at wavelengths this short, so we will tell simdata that this is actually a 230 GHz (1.3 mm) continuum map. We will also tell simdata that the observations were taken with a 2 GHz bandwidth. Although for this particular example the channel width is not a critical number, it would be very important if we were modifying a spectral cube instead of a continuum image. | ||
<source lang="python"> | |||
incenter = '230GHz' | |||
inwidth = '2GHz' | |||
</source> | |||
====Brightness Scale==== | ====Brightness Scale==== | ||
The 8 micron emission is probably not a great | The 8 micron emission is probably not a great approximation for the millimeter emission from 30 Doradus. For a true science case, one would want to calculate what the expected 230 GHz emission would be from an object like this at the distance of about 750 kiloparsec. For the sake of simplicity, we will rescale the image so that the brightest pixel in the map has a flux density of 0.06 mJy. This number is chosen such that the extended emission is a factor of a few brighter than the expected noise in a 2 hour observation. The [https://almascience.nrao.edu/call-for-proposals/sensitivity-calculator ALMA sensitivity calculator] can be used to determine the expected noise in an observation. | ||
<source lang="python"> | |||
inbright = '0.06mJy/pixel' | |||
</source> | |||
===Defining the Mock Observations=== | ===Defining the Mock Observations=== | ||
Line 96: | Line 109: | ||
* pointingspacing | * pointingspacing | ||
The default value for "integration", 10 seconds, might be appropriate to simulate real observations. However, simdata will run much faster if the value for "integration" is increased, reducing the number of data points to be generated. In this demonstration | The default value for "integration", 10 seconds, might be appropriate to simulate real observations. However, simdata will run much faster if the value for "integration" is increased, reducing the number of data points to be generated. In this demonstration we will set it to 600 seconds. When simdata is used for scientific purposes it may be best to set "integration" to a large value at first to make sure that simdata runs as expected, and then decrease "integration" to a more realistic time for the final run. You will get a more accurate simulation with 10 second integrations than with 600 second integrations, especially in Early Science observations with a limited number of baselines. | ||
Note that the integration time is different than the total (on-source) time of the observations. The integration time, set here, is the averaging time for each data point. The total time spent on-source is set later on. Each pair of antennas will generate a number of data points equal to the total observing time divided by the integration time. | Note that the integration time is different than the total (on-source) time of the observations. The integration time, set here, is the averaging time for each data point. The total time spent on-source is set later on. Each pair of antennas will generate a number of data points equal to the total observing time divided by the integration time. | ||
Line 108: | Line 121: | ||
Finally, we will also leave "pointingspacing" to its default value (blank), which automatically sets the pointings to be half a primary beam apart, corresponding to Nyquist sampling. | Finally, we will also leave "pointingspacing" to its default value (blank), which automatically sets the pointings to be half a primary beam apart, corresponding to Nyquist sampling. | ||
<source lang="python"> | |||
integration = '600s' | |||
</source> | |||
====Antenna Positions and Total Observation Time==== | ====Antenna Positions and Total Observation Time==== | ||
Line 114: | Line 129: | ||
Now we will consider the parameters within "predict". We will keep the default values for every parameter (including "totaltime" = 7200 seconds) except "antennalist", which tells simdata the locations and sizes of each antenna in the array. We will simulate an Early Science observation, so we will first find the location where CASA has stored the ALMA configuration files. Then we will tell simdata to use the configuration file designed for Early Science. | Now we will consider the parameters within "predict". We will keep the default values for every parameter (including "totaltime" = 7200 seconds) except "antennalist", which tells simdata the locations and sizes of each antenna in the array. We will simulate an Early Science observation, so we will first find the location where CASA has stored the ALMA configuration files. Then we will tell simdata to use the configuration file designed for Early Science. | ||
<source lang="python"> | |||
#Set the path where CASA has stored the ALMA configuration files | |||
repodir = os.getenv("CASAPATH").split(' ')[0] | |||
antennalist = repodir+"/data/alma/simmos/alma.cycle0.compact.cfg" | |||
</source> | |||
The first line, run within CASA, uses a linux command to determine the path for CASA. The second line sets the "antennalist" parameter to the Early Science configuration. Other .cfg files in the same directory exist for various ALMA Full Science array configurations as well as the configuration files for other radio interferometers. | The first line, run within CASA, uses a linux command to determine the path for CASA. The second line sets the "antennalist" parameter to the Early Science configuration. Other .cfg files in the same directory exist for various ALMA Full Science array configurations as well as the configuration files for other radio interferometers. | ||
Line 151: | Line 169: | ||
To make these choices, use the following lines in CASA | To make these choices, use the following lines in CASA | ||
<source lang="python"> | |||
analyze = True | |||
showarray = True | |||
showconvolved = True | |||
showdifference = False | |||
showfidelity = False | |||
</source> | |||
====Final Check==== | ====Final Check==== | ||
[[Image:Simdata_inp_example2.png|thumb|Screen shot of "inp simdata". This screen shot reflects all inputs as they should be set according to this tutorial, before running simdata.]] | |||
Finally, check that everything looks correct. Look at the simdata inputs and compare with the screen | Finally, check that everything looks correct. Look at the simdata inputs and compare with the screen shot at the right. | ||
> inp simdata | > inp simdata | ||
Line 165: | Line 186: | ||
If everything looks promising (parameters set with unallowed values will be in red), then run simdata. | If everything looks promising (parameters set with unallowed values will be in red), then run simdata. | ||
<source lang="python"> | |||
simdata() | |||
</source> | |||
==Simdata Output Images== | ==Simdata Output Images== |
Latest revision as of 19:47, 6 October 2011
↵ Simulating Observations in CASA
A new version of this page exists for CASA 3.3: Simulation Guide for New Users (CASA 3.3).
Remember that you need to follow this process: Extracting scripts from these tutorials to extract a casapy script from this web page.
Explanation of the guide
This guide is intended to be used as an initial walk-through of how to use simdata. We will start with an image similar to something that might be observed with ALMA, and then we will show how to rescale the image and predict how it will look when observed with different antenna configurations.
We will assume only a general knowledge of interferometry and no specific knowledge of CASA.
Getting Started
The two things you need to get started are:
- The image to work with
- The current version of CASA
To get the image, download the Spitzer IRAC 8 micron image of 30 Doradus from the Simulation Inputs CASA Guide page.
To install CASA, follow the instructions given here. This guide was written for CASA version 3.2.
Using CASA
CASA is the post-processing package for ALMA and EVLA and can handle both interferometric and single dish data. Because simdata is a task within CASA, we start here with a brief introduction to some CASA basics. To learn much more about CASA, go to the CASA homepage. Walk-throughs of CASA data reduction for a variety of data sets can be found on the casaguides website.
Starting CASA
Once you have installed CASA, you can launch it by typing "casapy" at the prompt or by double-clicking on the icon, depending on your system and preferences.
Running CASA Tasks
To see a list of all available CASA tasks, at the CASA prompt type
> tasklist
To look at the inputs for an available task, use "inp". For instance
> inp simdata
Any parameter with a grey background is expandable. Red text shows an invalid value. Blue text shows an accepted, but not the default, value.
To get help on a given task, use "help" (to exit from help, hit the "q" key). For instance
> help simdata
To reset a task to its default values, use "default". For instance
> default simdata
To run a task using the current global values of its input parameters, just type its name at the CASA prompt. For instance
> simdata
It's a good idea to double-check these values (i.e., re-run "inp simdata") immediately before running a task.
Using Simdata
Getting Your Input Image Into Simdata
Now tell simdata where to find the model (input) image and how to scale it appropriately for our purposes. Just to be safe, we'll first restore the default values of simdata and then set the 30 Doradus image as the skymodel (Note: you might need to include the path to your data set, if you are not currently in the working directory where the data set is). Setting modifymodel=True tells simdata that we will be modifying the image before simulating an ALMA observation.
#Initialize simdata
default simdata
modifymodel = True
skymodel = '30dor.fits'
We are using a Spitzer 8 micron image of 30 Doradus in this example, and we are going to ask simdata to modify this image in some important ways:
- Angular scale
- Observed wavelength
- Brightness scale
Angular Scale
If you open the fits image of 30 Doradus in your favorite viewer (e.g. 'viewer' in CASA), you will see that it covers quite a large footprint on the sky, about 10' on a side. We are going to tell simdata to rescale the pixels to shrink the image by roughly a factor of 15 (from 2.3" to 0.15" pixels through the 'incell' parameter) so that the model is approximately 40" on a side. This rescaled model will fit within a small mosaic of 6 pointings. Although we do this primarily for convenience in this example, a scientific motivation for this type of rescaling would be to approximate what a super-giant HII region like 30 Doradus would look like if moved from the Large Magellanic Cloud to the distance of M33 or M31. For the sake of demonstration, we will also change the coordinates of the center of the map (using the 'indirection' parameter). Units are case sensitive, please take care to enter them in verbatim, CASA will throw an error otherwise.
incell = '0.15arcsec'
indirection = 'J2000 10h00m00 -40d00m00'
Observed Wavelength
The model image of 30 Doradus shows the 8 micron continuum emission. ALMA does not observe at wavelengths this short, so we will tell simdata that this is actually a 230 GHz (1.3 mm) continuum map. We will also tell simdata that the observations were taken with a 2 GHz bandwidth. Although for this particular example the channel width is not a critical number, it would be very important if we were modifying a spectral cube instead of a continuum image.
incenter = '230GHz'
inwidth = '2GHz'
Brightness Scale
The 8 micron emission is probably not a great approximation for the millimeter emission from 30 Doradus. For a true science case, one would want to calculate what the expected 230 GHz emission would be from an object like this at the distance of about 750 kiloparsec. For the sake of simplicity, we will rescale the image so that the brightest pixel in the map has a flux density of 0.06 mJy. This number is chosen such that the extended emission is a factor of a few brighter than the expected noise in a 2 hour observation. The ALMA sensitivity calculator can be used to determine the expected noise in an observation.
inbright = '0.06mJy/pixel'
Defining the Mock Observations
Now that simdata knows how to interpret the input image, the next step is to define the simulated observations.
Pointings and Scan Time
We will first change the parameters within "setpointings"
- integration
- direction
- mapsize
- maptype
- pointingspacing
The default value for "integration", 10 seconds, might be appropriate to simulate real observations. However, simdata will run much faster if the value for "integration" is increased, reducing the number of data points to be generated. In this demonstration we will set it to 600 seconds. When simdata is used for scientific purposes it may be best to set "integration" to a large value at first to make sure that simdata runs as expected, and then decrease "integration" to a more realistic time for the final run. You will get a more accurate simulation with 10 second integrations than with 600 second integrations, especially in Early Science observations with a limited number of baselines.
Note that the integration time is different than the total (on-source) time of the observations. The integration time, set here, is the averaging time for each data point. The total time spent on-source is set later on. Each pair of antennas will generate a number of data points equal to the total observing time divided by the integration time.
We will keep "direction" at the default (blank) value to center the observations on the model coordinates, as given in "indirection" above.
We will keep "mapsize" at the default value so that the mosaic will automatically cover the entire image. In our case, this will require a mosaic of 6 pointings (as we will see later on). One could also set an exact output image size via mapsize = ['10arcmin','10arcmin'] for example.
The mosaic default pattern "maptype" is 'hexagonal', which we will also leave unchanged.
Finally, we will also leave "pointingspacing" to its default value (blank), which automatically sets the pointings to be half a primary beam apart, corresponding to Nyquist sampling.
integration = '600s'
Antenna Positions and Total Observation Time
Now we will consider the parameters within "predict". We will keep the default values for every parameter (including "totaltime" = 7200 seconds) except "antennalist", which tells simdata the locations and sizes of each antenna in the array. We will simulate an Early Science observation, so we will first find the location where CASA has stored the ALMA configuration files. Then we will tell simdata to use the configuration file designed for Early Science.
#Set the path where CASA has stored the ALMA configuration files
repodir = os.getenv("CASAPATH").split(' ')[0]
antennalist = repodir+"/data/alma/simmos/alma.cycle0.compact.cfg"
The first line, run within CASA, uses a linux command to determine the path for CASA. The second line sets the "antennalist" parameter to the Early Science configuration. Other .cfg files in the same directory exist for various ALMA Full Science array configurations as well as the configuration files for other radio interferometers.
Most of the other parameters are not relevant for this simulation as we are not using a component list to describe the sky emission, we do not want to simulate observations of a calibrator, and we do not want to simulate single dish observations. Note that at this stage of simulation development, the time portion of the "refdate" parameter is ignored and all observations are instead centered around transit on the date specified.
Thermal Noise
For this simple simulation, we will not include any thermal noise in the observations, so we can leave "thermalnoise" at its default (blank) value.
Choosing Simdata Output Images
Now that simdata has been told how to simulate the visibilities, it is time to invert them to make an image of sky as observed with the interferometer.
Image
We would like to make a deconvolved output image, but we don't want to spend too much time optimizing the cleaning. So, all we need to do is make sure the "image" parameter is set to True (which it is by default) and leave all of its sub-parameters at their default values. Other data reduction guides describe the process of cleaning in greater detail.
For simulations intended for a proposal or scientific analysis, one would almost certainly want to choose a more appropriate cleaning threshold and define the region to be cleaned. Instructions for how to define the region to be cleaned with the "mask" parameter can be found by typing
> help clean
or by looking at the Clean CASA Guide page.
Analyze
To choose which six output images you would like simdata to create (you are limited to 6), set the parameter "analyze" to True and then pick your favorite outputs. In this example we will look at
- Locations of the antennas
- uv coverage in the 2 hour observation
- Synthesized beam (point spread function)
- Original sky model (as defined in "modifymodel")
- Convolved model (sky model convolved with the synthesized beam)
- Clean image (the sky as observed with the interferometer after deconvolution)
To make these choices, use the following lines in CASA
analyze = True
showarray = True
showconvolved = True
showdifference = False
showfidelity = False
Final Check
Finally, check that everything looks correct. Look at the simdata inputs and compare with the screen shot at the right.
> inp simdata
If everything looks promising (parameters set with unallowed values will be in red), then run simdata.
simdata()
Simdata Output Images
Simdata will display output images to your screen, partly based on your selections in "analyze". It will also produce images that you can display for yourself using the viewer tool that comes with CASA.
Figures Plotted to the Screen
When simdata is run with the parameters set as above, the images plotted to the screen are:
- The model image, rescaled as defined in "modifymodel", with the mosaic pointings as defined in "setpointings"
- Plots related to "predict", with
- Source elevation vs. time
- The positions of the antennas
- The uv coverage
- The synthesized beam (psf)
- Images of the 30 Doradus
- The original image, as defined in "modifymodel"
- The original image convolved with the psf
- The "observed" image
- The difference between the observed and original images
- The images requested in "analyze"
- The antenna plot
- The uv coverage
- The synthesized beam
- The sky model image
- The convolved sky model
- The "observed" image
The images requested in "analyze" will be the ones that stay on your screen when simdata is done, while the others will be briefly displayed and then disappear when the next set of images is plotted. If the images don't stay on your screen long enough to analyze, you can make simdata save the images as .png files with the "graphics" parameter.
> graphics = 'file'
Using Viewer
Simdata also creates several images that can be displayed with the CASA viewer tool. The viewer can be launched within CASA by typing
> viewer
Double click on the directory that contains the image files. In this example, that directory is called "sim", which is the default value of simdata's input parameter "project". You will be shown several files that you can view, including those made by CASA and the original FITS image. Some of the more important images are:
- sim.image - The simulated observations
- sim.skymodel - The input map/cube as defined in "modifymodel"
- sim.psf - The synthesized beam
- sim.residual - The difference between the sky model and the simulated observations
To display the simulated observations, first click on sim.image, then click the "raster image" button and then click "done". The image will be shown in the viewer, and clicking on the picture of the wrench in the upper left corner will allow you to alter the image in many ways, such as changing the color scale, changing the coordinate scale, and axis labels. The image to the right was created by:
- Changing "basic settings -> color map" from Rainbow 2 to Hot Metal 1
- Changing "beam ellipse -> beam style" from outline to filled
- Changing "color wedge -> display color wedge" from No to Yes
You can learn much more about the functionality of the CASA viewer by watching this instructional video.
↵ Simulating Observations in CASA
--Scott Schnee; updated for CASA 3.2 by A. Kimball, 28th April 2011
Last checked on CASA Version 3.2.0.