Advanced ALMA DataReduction Workshop- CASA simulation Takuma Izumi (NAOJ)
On behalf of EA-ARC
ALMA Advanced Data Reduction Workshop
March 21, 2024

Photo credit: ALMA (ESO/NAOJ/NRAO)/ J. Guarda (ALMA)Why simulating ALMA observations?
● Investigate the feasibility of your program.
● Determine the optimal configuration to observe what you want to see.
● Improve the quality of your proposal.
(inclination angle = 75° = Circinus galaxy’s value)

(a)

(b)

← From Cycle 7 ALMA
proposal (PI = T. Izumi).
Input model = Hydrodynamic
simulation (multiphase gas)
+ post-processed radiativetransfer.
→ CASA simulation

Figure 6: Simulated channel maps of the circumnuclear (a) CO(3–2) and (b) [CI](1–0) emission of
the Circinus galaxy based on our fountain model (Izumi et al. 2018). The resolution of these maps
is set to 2 pc, to be compared with the proposed observations. The [CI](1–0) map clearly shows thevertically-extended component due to atomic outflows and failed winds. A total gas mass of 2 × 106 M⊙
is assumed based on our Cycle 4 work. The insets show the original 0.25 pc resolution simulation maps.

CASA Installation● Install recent CASA (latest ver = 6.6.3)
https://casa.nrao.edu/casa_obtaining.shtml● (I will mainly use ver 6.1.1 in this WS...)● Please make sure it works!
○○

Open a terminal window> casaYou could see:
1. Command Line Prompt

2. Logger WindowDownload the Script●●- Create_Gauss+PS.py- Simobserve_Gauss+PS.py- Simanalyze_Gauss+PS.py- Simalma_Gauss+PS.py- Circinus_CO32_i80_phi000.fits- Circinus_HCO+32_i90_phi105.fits- Circinus_CI10_i80_phi000.fits- Sim_Circinus_CO32.py

Download from the workshop website○ https://www2.nao.ac.jp/~eaarc/DATARED/lecture.html
Array Configuration Files (Cycle 11 files will be available soon)○ https://almascience.nao.ac.jp/tools/casa-simulator○ simmos directory under your data/alma/ (incl. ATCA, VLA, PdBI, SMA, ngVLA)

ALMA Cycle10 Technical Handbook

CASA Basics● Information: https://casadocs.readthedocs.io/en/stable/● Community Examples > Simulation in CASA:
https://casadocs.readthedocs.io/en/v6.2.0/examples/community/simulation_sc
ript_demo.html#Command Line● Backend in c++● interface in python← string← math← python command← shell command← back to shell

CASA Tasks● taskhelp← category

Today’s tasks (simulation, visualization, imaging)← optional

How to Use CASA
●
●
●
●
●
●

Get help : help taskname
Input parameters : inp taskname
Reset parameters : default(taskname)
Execute the task : go
Run script : execfile(“script.py”)
Exit casa : exit

Note for Proposals● Only values from the ALMA Sensitivity Calculator (in OT) should be used toestimate exposure time in ALMA proposals. - DO NOT QUOTE THE
SIMULATED VALUES (e.g. noise level) for your Technical Justification!
● CASA simulations make use of representative antenna configurations (asindicated in the config files), but the actual configuration could differ
somewhat in real observations.
● Simulation is a tool, not a requirement.
→ But this would make your proposals/papers more compelling, hopefully.

CASA Simulation (example)● You can easily find out relevant info on the web…
● Information:○

General introduction
https://casadocs.readthedocs.io/en/v6.4.3/notebooks/simulation.html○

Tutorial Example
https://casaguides.nrao.edu/index.php/Simulating_Observations_in_CASA_5.4
https://casaguides.nrao.edu/index.php?title=Simulation_Guide_Component_Lists_(CASA_5.4)○

simalma Tutorial
https://casaguides.nrao.edu/index.php?title=Simalma_(CASA_6.1.1)

Structure of CASA simulation
simalma
Input image model
simobserve●●Generate visibility
simanalyze (tclean)
Transforme to images
Image check/analysis
Display images●Image format○ FITS○ CASA image
Image dimensions○ 2D in → 2D out○ 3D (cube) in → 3D (cube) out
Image type○ theoretical model (noise free; you canadd noise component)○ previous observation (with actual noise)Input model (example; need to check)
Input model of your source●

Assuming that you know your object’s
○
○
○

●
●
RA, Dec●●

Angular size
Brightness distribution
Coodinates

Projected image in format of CASA
image (*.image) or *.fits fileMust have appropriate dimensions (2Dmap, 3D cube (+Stokes))
In unit of Jy pixel–1 (K should beconverted; shown later)
Coordinates should be appropriately
given in the header

Step 1 : Create your modelExample 1: Create Gaussian + Point Sources model● Must be done before simulating observations (e.g., simobserve, simalma)● Script: Create_Gauss+PointSources.py↓ Reference article

Note: cl = casatools.componentlist (https://casadocs.readthedocs.io/en/latest/api/tt/casatools.componentlist.html),
ia = casatools.image (https://casadocs.readthedocs.io/en/latest/api/tt/casatools.image.html#casatools.image),qa = casatools.quanta (https://casadocs.readthedocs.io/en/v6.5.4/api/tt/casatools.quanta.html)← Define the center.

← Create a Gaussian component.

← Add point sources for fun.

Example 1: Create Gaussian + Point Sources model← Set an empty CASA image(canvas that you will work on; you will add comp later).

Stokes← At this moment, there is no
meaningful coordinates,
reference position, increments inthis empty image. This is just a“canvas”.
You can use ia.summary to getthe header info.
↑↑ We then have to tell CASA
about these values!!

Example 1: Create Gaussian + Point Sources model← Setup the empty image byadding, e.g., units of the axes,increments, reference values.

← Here I set 1.875 GHz for the spectral increment (i.e., continuum)← Put the above values to the image header! cs.torecord() returns the contents stored in thecoordsys as casa’s record (=parameter). ia.setcoordsys replaces the coordinate system in theimage.

← Header is now updated.

coordsys (operation on coordinate systems):
https://casadocs.readthedocs.io/en/stable/api/tt/casatools.coordsys.html
qa (operation on units and quantities):
https://casadocs.readthedocs.io/en/v6.5.4/api/tt/casatools.quanta.html

Example 1: Create Gaussian + Point Sources model← Define the brightness unit (should be Jy/pixel)← Put the model (sky) components to theimage! “ia.modify” applies a model of thesky to the image. You can either “add”(subtract False) or “subtract”.

↑ Export the image file to a FITS format. Note that you can simobserve this image file directly as well.

ia (operations on images):
https://casadocs.readthedocs.io/en/stable/api/tt/casatools.image.html

Check the output image!
Modify the displayed flux range
Flux unit = Jy per pixel

Please carefully check whether the output models are exactly what you intended to create!

Step 2 : Observe your model

Observe the Gaussian + Point Sources model● CASA task: simobserve○

https://casa.nrao.edu/casadocs/casa-6.1.0/global-task-list/task_simobserve/about

Observe the Gaussian + Point Sources model● Script: Simobserve_Gauss+PS.py● Please view and edit as you like.
← Reference article○inbright: peak brightness in Jy/pixel, or ' ‘ (blank) if unchanged
Note: unchanged will take the numerical values of your input image model and assume they are in Jy/pix,even if it says some other unit in the header

Observe the Gaussian + Point Sources model↑ Outputs are stored here!

Outputs of this simulation● Output

Siumulated/resultant visibility withnoise (will be used for tclean)

Source Elvs. time→← Antennaposition← Map pattern← PSFUVcoverage →Step 3 : Map your observation

Imaging the Gaussian + Point Sources Data
● CASA task: simanalyze (~tclean)○

https://casa.nrao.edu/casadocs/casa-6.1.0/global-task-list/task_simanalyze/aboutImaging the Gaussian + Point Sources Data
● Script: Simanalyze_Gauss+PS.py● Please view and edit as you like.

Our input model
has 0.1”/pix scale● weighting○○natural/briggs/uniform
Only robust = +0.5 is available for Briggs…

Imaging the Gaussian + Point Sources Data
● Script: Simanalyze_Gauss+PS.py● Please view and edit as you like.

Resultant image with noise, after tclean.

Imaging the Gaussian + Point Sources Data
● Script: Simanalyze_Gauss+PS.py● Please view and edit as you like.
← Final image that you wantImaging the Gaussian + Point Sources Data
● Some relevant outputs

Model

Convolved

CLEANedResidualPSF

Model

difference

fidelity

uv-coverage

CLEANedStep 3’ : Map your observation 2

Observe and Imaging the Gaussian + Point Sources● CASA task: simalma (simobserve + simanalyze in one run)○https://casa.nrao.edu/casadocs/casa-6.1.0/global-task-list/task_simalma/about
Both individual and combined MS can be analyzed if you specify
multiple configurations (e.g., C-4, C-8, ACA).

Observe and Imaging the Gaussian + Point Sources● Script: Simalma_Gauss+PS.py● Please view and edit as you like.

For the tclean process, only Briggs withrobust = 0.5 is available…If you want to do
more detailed analysis, please use tclean!
We can use 12m, 7m, and TP simultaneously
For TP imaging, skymodel should be larger than 2.5 × primary beam

Observe and Imaging the Gaussian + Point Sources↑ Output files are stored here.

Observe and Imaging the Gaussian + Point Sources● OutputACA data

● You can add TP data if you want.

12m data

Combined data

Observe and Imaging the Gaussian + Point Sources● Output: ACA seems to better recover the spatially extended component
From simobserve + simanalyze (12m only).
C-5 config, briggs weighting. ton = 3600 sec

From simalma. Briggs with Robust = 0.5.
C-5 config (12m) 3600 sec + ACA 7200 sec

Elevation (º)

Note — Hourangle

uv coverage

PSF

hourangle='transit', totaltime='20min'

hourangle='–3h', totaltime='20min'

Elevation (º)

Note — Totaltime

uv coverage

PSF

hourangle='transit', totaltime='1min'hourangle='transit', totaltime='4h'

Hour angle and total observing time change uv-coverage a lot

Note — Configuration
Elevation (º)

Antenna position
C-3 (Cycle 8)

C-6

200 kλ1000 kλ–200 kλ–1000 kλ–200 kλ200 kλ–1000 kλ1000 kλNote — Configuration

Skymodel

C-3

C-6

C-3+C-6

Tips — Parameters● On-source time and hourangle change uv-coverage dramatically○

Explore parameters● If simulations do not work:
○
○
○
○
○

Check input parameters
Do manual CLEAN with interactive=True
Is the source too big? Need mosaic?
uv-plane not well sampled?
Need to add ACA 7-m array/TP observations?

● Better to compare simanalyze and tclean results for a sanity checkTips — Use of Observing Tool (OT)
● Use OT to check necessary configurations that you need to map well yoursource○○○○

Largest angular scale
Angular resulsolution
Mosaicking
Exploring time

● Go back to simulation (iterative process)Tips — When You Use ALMA Simulations● Change parameters to learn/explore○

Find anything? Let us know, CASA team wants to receive any feedback!

● Use these simulation tools to see, for example,○○

What configuration is needed to cover your source when it is extended.
If ALMA is able to map/resolve complicated structures of your source● Use OT to get technical numbers for you observations like observing time,
angular resolution, etc.
○Simulation tools are not to estimate them but to see effects/mapping ability of ALMAobservations

For the advanced hands-on session● Multiphase gas observations (Izumiet al. 2023) toward the Circinus
galaxy (nearby AGN, D = 4.2 Mpc)
● Our team tried to make a hydromodel of multiphase gas that well
explains the structure + dynamics ofthis AGN.

Red = CO(3-2)
Blue = [CI](1-0)
Green = HCN(3-2)
Magenta = H36α

Credit: ALMA (ESO/NAOJ/NRAO), T.Izumi et al.

For the advanced hands-on session●Circumnuclear Disk of the Circinus galaxy (S.Baba et al. 2024; Hands-on)
Image type: 3D theoretical model (hydro simulation + postprocessed radiativetransfer w/o noise) → See details in https://arxiv.org/abs/2403.10593■ CO(3-2) @Band 7■ HCO+(3-2) @Band 6,■ [CI](1-0) @Band 8○ Task: simobserve + simanalyze (to better understand what you are doing)→ But you can make simalma script by yourself, of course.
○ Purpose:■ Check how using different configurations affects the resultant image (structure,fidelity, etc)○

● This model is created for the Circinus galaxy.
○○The pixel scale is 0.25 parsec (= 0.01227”; this info is already stored in the header).
The flux unit is Kelvin (this is also already stored in the header).

For the advanced hands-on session

Use this value later to re-scale the max value.
Note: we need “Jy/pixel” value/unit for the input model.
Just to set the config

For the advanced hands-on session
The part of “simobserve”

For the advanced hands-on session
The part of “simanalyze”

For the advanced hands-on session

CO(3-2) mom0; C-6 config.

→ I’d like to see higher resolution images