ACA Simulation (CASA 5.4) v2: Difference between revisions

From CASA Guides
Jump to navigationJump to search
 
(15 intermediate revisions by the same user not shown)
Line 44: Line 44:


====Simulate 12m interferometric observation====
====Simulate 12m interferometric observation====
[[Image:M51c.ALMA_0.5arcsec.skymodel.png|thumb|hexagonal mosaic overplotted on sky model]]
[[Image:M51c.alma.cycle6.3.skymodel.png|thumb|12m array hexagonal mosaic overplotted on sky model]]


We'll begin by simulating the observation as seen by the main 12 m ALMA array.  We'll have {{simobserve}} calculate a hexagonal mosaic of pointings.
We'll begin by simulating the observation as seen by the main 12 m ALMA array.  We'll have {{simobserve}} calculate a hexagonal mosaic of pointings following what the ALMA-OT would calculate.


The interface for {{simobserve}} provides an <tt>integration</tt> parameter, which is the dwell time at each pointing in the mosaic.  We'll set that to 10 s.  A real observation might dwell on each pointing for ~20 s and record 3 sets of visibilities (i.e. 6 s integration time) for each pointing.  {{simobserve}} does not currently offer a capability to reproduce this behaviour exactly, but the difference in UV coverage should be very minor between the real observation and the simulated one.  You could try setting <tt>integration</tt> to ~20 s, which would more closely match the dwell time for some real observations.
The interface for {{simobserve}} provides an <tt>integration</tt> parameter, which is the dwell time at each pointing in the mosaic.  We'll set that to 10 s.  A real observation might dwell on each pointing for ~20 s and record 3 sets of visibilities (i.e. 6 s integration time) for each pointing.  {{simobserve}} does not currently offer a capability to reproduce this behaviour exactly, but the difference in UV coverage should be very minor between the real observation and the simulated one.  You could try setting <tt>integration</tt> to ~20 s, which would more closely match the dwell time for some real observations.
Line 55: Line 55:
integration        =  "10s"
integration        =  "10s"
mapsize            =  "1arcmin"
mapsize            =  "1arcmin"
maptype            =  "hex"
maptype            =  "ALMA-OT"
pointingspacing    =  ""      # this could also be specified in angular size ("9arcsec") or in units of the primary beam ("0.5PB")
pointingspacing    =  ""      # this could also be specified in angular size ("9arcsec") or in units of the primary beam ("0.5PB")
</source>  
</source>  


=====Calculate Visibilities=====
=====Calculate Visibilities=====
When you provide a desired resolution in the <tt>antennalist</tt> parameter, {{simobserve}} will determine what array configuration to use.
You can either set the specific configuration to use in your simulation with the '''antennalist''' parameter to obtain the resolution you want, or you can also provide the array name and desired resolution (i.e., 'ALMA;0.5arcsec').
When you provide a desired resolution in the antennalist parameter, {{simobserve}} will determine what array configuration to use. For ALMA, however, {{simobserve}} may select a configuration that is not
in the current array schedule. We recommend using the ALMA OT to estimate what configuration your observations are likely to use, or selecting a configuration from the current configuration schedule.
Here is a [[Antenna_Configurations_Models_in_CASA_Cycle6| list of configuration files available in CASA 5.4]]. For this simulation, we would like to achieve an angular resolution of 0.5" at 330 GHz. This can be achieved
with the ALMA Cycle 6 C43-3 configuration. We also set a total time of 30 minutes on-source:
 
<source lang="python">
<source lang="python">
obsmode            =  "int"
obsmode            =  "int"
antennalist        =  "ALMA;0.5arcsec"
antennalist        =  "alma.cycle6.3.cfg"
totaltime          =  "1800s"
totaltime          =  "30min"
</source>
</source>


We set the precipitable water vapor to 0.6 mm to represent observations in nominal weather at 330 GHz. The simulation will add noise to the data based on this setting.
We set the precipitable water vapor to 0.9 mm to represent observations in nominal (3rd octile) weather at 330 GHz. The simulation will add noise to the data based on this setting. In general, however, we strongly recommend using the
ALMA [https://almascience.nrao.edu/proposing/sensitivity-calculator| sensitivity calculator] to determine the required observing time. For CASA 5.4 in particular, {{simobserve}} uses Tsys values for the ALMA receiver bands that are larger than the true values,
increasing the observing time needed to achieve a given sensitivity. This will be updated in a future release.
<source lang="python">
<source lang="python">
user_pwv=0.6
user_pwv=0.9
</source>
</source>


Line 78: Line 86:
simobserve()
simobserve()
</source>
</source>


----
----


====Simulate 12m total power observation====
====Simulate 7m ACA observation====
[[Image:M51c.aca.tp.skymodel.png|thumb|rectangular map overplotted on sky model]]
[[Image:M51c.aca.cycle6.skymodel.png|thumb|hexagonal map overplotted on sky model]]
 
Next we'll simulate a total power raster map of the same area, on a square grid.  CASA simulation tools can not simulate
true on-the-fly mapping (with smearing on timescales smaller than an integration time), but a square grid with a short integration time will provide a very accurate approximation.


By virtue of CASA's global parameters, we already have project and image world coordinate system parameters set correctly.
Next we'll add an ACA mosaic, with its larger primary beam. Again, we'll let {{simobserve}} calculate the pointing spacings in a hexagonal pattern. Here, we set '''maptype''' to "ALMA-OT" to match the extent and number of pointings the
ALMA OT would use in a proposed observation of this size.  


We need to change the mapping parameters to specify a square region a bit larger than the interferometric map.
<source lang="python">
<source lang="python">
integration        =  "10s"
integration        =  "10s"
mapsize            =  "1.3arcmin"
mapsize            =  "1arcmin"
maptype            =  "hex"
maptype            =  "ALMA-OT"
pointingspacing    =  ""
</source>  
</source>  


We'll observe on a different day.  This doesn't really matter, but if you choose to simulate two different 12m ALMA configurations and combine them, you will have issues concatenating the datasets if they are simulated on the same day with the same antenna names. So, it's a good habit to change the day. We also set the integration time
When a project requires ALMA observations with one or more 12m array configurations, 7m array, and/or TP observations, the time required for each array varies by array configuration to achieve the correct sensitivity in all arrays/observations.
Specific time ratios can be found in Table 7.4 of the ALMA Technical Handbook (see the latest version [https://almascience.nrao.edu/proposing/documents-and-tools/latest/documents-and-tools/ here]).
In this case, since we are using the Cycle 6 C43-3 configuration for the 12m observations, Table 7.4 shows that we require a total time for the 7m array observations that is 2.4 times the 12m observation duration, or 72 minutes.
 
Note that you can also specify an integral number of times to repeat the mosaic by setting '''totaltime''' to an integer string without units. To ensure you have the correct total time, however, you will need to check the number of pointings
{{simobserve}} uses for the 7m array using {{listobs}} (in this case, 17), and then use your integration time to set the number of mosaic repeats.


<source lang="python">
<source lang="python">
obsmode            = "sd"
obsmode            = "int"
sdantlist          = "aca.tp.cfg"
refdate            = "2012/12/02"
sdant              = 0
antennalist        =  "aca.cycle6.cfg"
refdate            = "2012/12/01"
totaltime          =  "72min"
totaltime          =  "123min"
</source>
</source>


Line 114: Line 125:
----
----


====Simulate 7m ACA observation====
====Simulate 12m total power observation====
[[Image:M51c.aca.i.skymodel.png|thumb|hexagonal map overplotted on sky model]]
[[Image:M51c.aca.tp.cycle6.skymodel.png|thumb|rectangular map overplotted on sky model]]
 
Next we'll simulate a total power raster map of the same area, on a square grid.  ALMA TP observations are done on-the-fly. CASA simulation tools can not simulate
true on-the-fly mapping (with smearing on timescales smaller than an integration time), but a square grid with a short integration time will provide a very accurate approximation.


Next we'll add an ACA mosaic, with its larger primary beam. Again, we'll let [[simobserve]] calculate the pointing spacings:
By virtue of CASA's global parameters, we already have project and image world coordinate system parameters set correctly.


We need to change the mapping parameters to specify a square region a bit larger than the interferometric map.
<source lang="python">
<source lang="python">
integration        =  "10s"
integration        =  "10s"
mapsize            =  "1arcmin"
mapsize            =  "1.3arcmin"
maptype            =  "hex"
maptype            =  "square"
pointingspacing    =  ""
</source>  
</source>  


We can specify an integral number of times to repeat the mosaic by setting <tt>totaltime</tt> to an integer string without units.
We'll observe on a different day.  This doesn't really matter, but if you choose to simulate two different 12m ALMA configurations and combine them, you will have issues concatenating the datasets if
they are simulated on the same day with the same antenna names. So, it's a good habit to change the day. We also set the integration time based on the time ratios discussed above.  


<source lang="python">
<source lang="python">
obsmode            = "int"
obsmode            = "sd"
refdate            = "2012/12/02"
sdantlist          = "aca.tp.cfg"
antennalist        =  "aca.cycle6.cfg"
sdant              = 0
totaltime          =  "3"
refdate            = "2012/12/01"
totaltime          =  "123min"
</source>
</source>


Line 140: Line 156:
simobserve()
simobserve()
</source>
</source>


----
----
Line 153: Line 170:
If given a total power and interferometric measurement set, {{simanalyze}} will automatically create the total power image,  
If given a total power and interferometric measurement set, {{simanalyze}} will automatically create the total power image,  
then use it as a model and deconvolve the interferometric image.
then use it as a model and deconvolve the interferometric image.
Note that we need to set '''niter''' to a number greater than 0 for {{simanalyze}} to clean the data. We have also set a reasonable threshold value for the dataset.


<font color="red">
<font color="red">
Line 158: Line 177:


====First image total power and ACA with total power as a model====
====First image total power and ACA with total power as a model====
[[Image:M51c.aca.i.analysis.casa5.4.png|thumb|Total power combined (with relatively low weight) with ACA]]
[[Image:M51c.aca.cycle6.noisy.analysis.png|thumb|Total power combined (with relatively low weight) with ACA]]


<source lang="python">
<source lang="python">
default("simanalyze")
default("simanalyze")
project            =  "m51c"
project            =  "m51c"
vis                =  '$project.aca.i.ms,$project.aca.tp.sd.ms'   
vis                =  '$project.aca.cycle6.noisy.ms,$project.aca.tp.noisy.sd.ms'   
imsize            =  [512,512]
imsize            =  [512,512]
cell              =  '0.2arcsec'
cell              =  '0.2arcsec'
analyze            = True
threshold          = '30mJy'
showpsf            = False
niter              = 10000
showresidual      = False
pbcor              = True
showconvolved      = True
analyze            = True
showuv            = True
showpsf            = False
showmodel          = True
showconvolved      = True
showclean          = True
showresidual      = False
showdifference    = True
verbose            = True
showfidelity      = True
simanalyze()
simanalyze()
</source>
</source>


====Next add the 12m interferometric data====
====Next add the 12m interferometric data====
[[Image:M51c.ALMA_0.5arcsec.analysis.casa5.4.png|thumb|TP+ACA combined (with relatively low weight) with 12m ALMA]]
[[Image:M51c.alma.cycle6.3.noisy.analysis.png|thumb|TP+ACA combined (with relatively low weight) with 12m ALMA]]
Here we explicitly have to set the ''modelimage'' to the result from the previous run.
Here we explicitly have to set the ''modelimage'' to the result from the previous run.


Line 180: Line 208:
default("simanalyze")
default("simanalyze")
project            =  "m51c"
project            =  "m51c"
vis                =  '$project.ALMA_0.5arcsec.ms'
vis                =  '$project.alma.cycle6.3.noisy.ms'
imsize            =  [512,512]
imsize            =  [600,600]
cell              =  '0.1arcsec'
cell              =  '0.1arcsec'
modelimage        =  "$project.aca.i.image"
modelimage        =  "$project.aca.cycle6.noisy.feather.image"
analyze            = True
threshold          = '30mJy'
showpsf            = False
niter              = 10000
showresidual      = False
pbcor              = True
showconvolved      = True
analyze            = True
showuv            = True
showpsf            = False
showmodel          = True
showconvolved      = True
showclean          = True
showresidual      = False
showdifference    = True
verbose            = True
showfidelity      = True
simanalyze()
simanalyze()
</source>
</source>

Latest revision as of 12:07, 8 May 2019


To create a script of the Python code on this page see Extracting scripts from these tutorials.

ALMA 12m + ACA + Total Power

We can simulate ALMA observations that use the main array of 12 m antennas augmented by the ACA and Total Power antennas by generating simulated observations for each component separately, and then combining the Measurement Sets in simanalyze. This technique is general and can be used to simulate observations using multiple 12 m array configurations, as well. Total power observations can be simulated either in an independent run of simobserve, or along with an interferometric simulation. Note that if you simulate total power and an interferometric observation simultaneously with simobserve, they must have the same set of pointing centers and the same integration and total time, which is probably not realistic. (For example it is generally recommended to observe a larger area by 1/2 primary beam in total power mode to combine with a 12 m ALMA mosaic).

Set simobserve as current task

Reset all parameters to default, and then set the project name to m51c

# Set simobserve to default parameters
default("simobserve")
# Our project name will be m51c, and all simulation products will be placed in a subdirectory m51c/
project="m51c"
Specify sky model image

We'll use an Halpha image of M51 as a model of the sky, for this example. The curl command will copy the file from a URL and rename it.

# Model sky = Halpha image of M51 
os.system('curl https://casaguides.nrao.edu/images/3/3f/M51ha.fits.txt -f -o M51ha.fits')
skymodel         =  "M51ha.fits"

Note that simobserve will not modify your original input image. Rather, it will make a copy m51c/m51c.skymodel.

We will override most of the parameters in the Halpha FITS image to make the image more suitable to a sub-millimeter ALMA observation. We will:

  • place the source in the southern hemisphere with the indirection parameter,
  • set the pixel size to 0.1arcsec, to simulate an observation of a galaxy that is smaller in angular size. (M51 itself would require a quite large mosaic, and in any case we'd like the input model pixels to be significantly smaller than the synthesized beam.)
  • set the peak brightness to 0.004 Jy/pixel
  • set the frequency to 330GHz, and since it's a 2D image we'll set the single "channel" width to be 50MHz, and peak brightness of 0.004 Jy/pixel. These parameters are plausible for observing a sub-mm emission line in a galaxy.
# Set model image parameters:
indirection="J2000 23h59m59.96s -34d59m59.50s"
incell="0.1arcsec"
inbright="0.004"
incenter="330.076GHz"
inwidth="50MHz"

Simulate 12m interferometric observation

12m array hexagonal mosaic overplotted on sky model

We'll begin by simulating the observation as seen by the main 12 m ALMA array. We'll have simobserve calculate a hexagonal mosaic of pointings following what the ALMA-OT would calculate.

The interface for simobserve provides an integration parameter, which is the dwell time at each pointing in the mosaic. We'll set that to 10 s. A real observation might dwell on each pointing for ~20 s and record 3 sets of visibilities (i.e. 6 s integration time) for each pointing. simobserve does not currently offer a capability to reproduce this behaviour exactly, but the difference in UV coverage should be very minor between the real observation and the simulated one. You could try setting integration to ~20 s, which would more closely match the dwell time for some real observations.

# have simobserve calculate mosaic pointing locations:
setpointings       =  True
integration        =  "10s"
mapsize            =  "1arcmin"
maptype            =  "ALMA-OT"
pointingspacing    =  ""      # this could also be specified in angular size ("9arcsec") or in units of the primary beam ("0.5PB")
Calculate Visibilities

You can either set the specific configuration to use in your simulation with the antennalist parameter to obtain the resolution you want, or you can also provide the array name and desired resolution (i.e., 'ALMA;0.5arcsec'). When you provide a desired resolution in the antennalist parameter, simobserve will determine what array configuration to use. For ALMA, however, simobserve may select a configuration that is not in the current array schedule. We recommend using the ALMA OT to estimate what configuration your observations are likely to use, or selecting a configuration from the current configuration schedule. Here is a list of configuration files available in CASA 5.4. For this simulation, we would like to achieve an angular resolution of 0.5" at 330 GHz. This can be achieved with the ALMA Cycle 6 C43-3 configuration. We also set a total time of 30 minutes on-source:

obsmode            =  "int"
antennalist        =  "alma.cycle6.3.cfg"
totaltime          =  "30min"

We set the precipitable water vapor to 0.9 mm to represent observations in nominal (3rd octile) weather at 330 GHz. The simulation will add noise to the data based on this setting. In general, however, we strongly recommend using the ALMA sensitivity calculator to determine the required observing time. For CASA 5.4 in particular, simobserve uses Tsys values for the ALMA receiver bands that are larger than the true values, increasing the observing time needed to achieve a given sensitivity. This will be updated in a future release.

user_pwv=0.9

Run simobserve, displaying graphics to the screen and also writing graphics output to files that can be found in the project directory, m51c.

graphics           =  "both"
simobserve()



Simulate 7m ACA observation

hexagonal map overplotted on sky model

Next we'll add an ACA mosaic, with its larger primary beam. Again, we'll let simobserve calculate the pointing spacings in a hexagonal pattern. Here, we set maptype to "ALMA-OT" to match the extent and number of pointings the ALMA OT would use in a proposed observation of this size.

integration        =  "10s"
mapsize            =  "1arcmin"
maptype            =  "ALMA-OT"
pointingspacing    =  ""

When a project requires ALMA observations with one or more 12m array configurations, 7m array, and/or TP observations, the time required for each array varies by array configuration to achieve the correct sensitivity in all arrays/observations. Specific time ratios can be found in Table 7.4 of the ALMA Technical Handbook (see the latest version here). In this case, since we are using the Cycle 6 C43-3 configuration for the 12m observations, Table 7.4 shows that we require a total time for the 7m array observations that is 2.4 times the 12m observation duration, or 72 minutes.

Note that you can also specify an integral number of times to repeat the mosaic by setting totaltime to an integer string without units. To ensure you have the correct total time, however, you will need to check the number of pointings simobserve uses for the 7m array using listobs (in this case, 17), and then use your integration time to set the number of mosaic repeats.

obsmode            = "int"
refdate            = "2012/12/02"
antennalist        =  "aca.cycle6.cfg"
totaltime          =  "72min"

Run simobserve, displaying graphics to screen and to files.

simobserve()

Simulate 12m total power observation

rectangular map overplotted on sky model

Next we'll simulate a total power raster map of the same area, on a square grid. ALMA TP observations are done on-the-fly. CASA simulation tools can not simulate true on-the-fly mapping (with smearing on timescales smaller than an integration time), but a square grid with a short integration time will provide a very accurate approximation.

By virtue of CASA's global parameters, we already have project and image world coordinate system parameters set correctly.

We need to change the mapping parameters to specify a square region a bit larger than the interferometric map.

integration        =  "10s"
mapsize            =  "1.3arcmin"
maptype            =  "square"

We'll observe on a different day. This doesn't really matter, but if you choose to simulate two different 12m ALMA configurations and combine them, you will have issues concatenating the datasets if they are simulated on the same day with the same antenna names. So, it's a good habit to change the day. We also set the integration time based on the time ratios discussed above.

obsmode            = "sd"
sdantlist          = "aca.tp.cfg"
sdant              = 0
refdate            = "2012/12/01"
totaltime          =  "123min"

Run simobserve, displaying graphics to screen and to files.

simobserve()



Deconvolve the visibilities back into an image

Next we use simanalyze to combine the three measurement sets and create a single image.

There are many ways to do this, and you may wish to discuss options with scientists at your ARC. In this example we will use the total power image as a model when deconvolving the ACA image, and then use the result as a model when deconvolving the 12m interferometric image. This method tends to give low weight to the large spatial scales, but is simple to illustrate.

It's possible to get better results if one used multiscale clean in the tclean task (again using the lower resolution image as a model when deconvolving the higher resolution one). An alternative would be to create an image independently from each dataset, and then use the CASA feather task to combine them entirely in the image plane.

If given a total power and interferometric measurement set, simanalyze will automatically create the total power image, then use it as a model and deconvolve the interferometric image.

Note that we need to set niter to a number greater than 0 for simanalyze to clean the data. We have also set a reasonable threshold value for the dataset.

If you decide to concatenate the two measurement sets and image all visibilities simultaneously, it is critical that the relative weights be set between the two different interferometric arrays. Simulated data has weights=1, since the thermal noise is generated uniformly per baseline. However, in reality the 7m baselines have lower sensitivity than the 12m baselines, and their weights must be decreased by that sensitivity ratio. simalma uses the visweightscale parameter of concat to apply that lower weight of (7./12)**2 to the 7m visibilities. If you wish to combine data manually, you must do this step yourself. (See simalma guide.)

First image total power and ACA with total power as a model

Total power combined (with relatively low weight) with ACA
default("simanalyze")
project            =  "m51c"
vis                =  '$project.aca.cycle6.noisy.ms,$project.aca.tp.noisy.sd.ms'  
imsize             =  [512,512]
cell               =  '0.2arcsec'
threshold          = '30mJy'
niter              = 10000
pbcor              = True
analyze            = True
showuv             = True
showpsf            = False
showmodel          = True
showconvolved      = True
showclean          = True
showresidual       = False
showdifference     = True
verbose            = True
showfidelity       = True
simanalyze()

Next add the 12m interferometric data

TP+ACA combined (with relatively low weight) with 12m ALMA

Here we explicitly have to set the modelimage to the result from the previous run.

default("simanalyze")
project            =  "m51c"
vis                =  '$project.alma.cycle6.3.noisy.ms'
imsize             =  [600,600]
cell               =  '0.1arcsec'
modelimage         =  "$project.aca.cycle6.noisy.feather.image"
threshold          = '30mJy'
niter              = 10000
pbcor              = True
analyze            = True
showuv             = True
showpsf            = False
showmodel          = True
showconvolved      = True
showclean          = True
showresidual       = False
showdifference     = True
verbose            = True
showfidelity       = True
simanalyze()