Create a Template
Step 1: Get the ms file of the observation you want to mimic.
Download the continuum of Elias 24 (0.8GB). This file contains all the infortmation of the observation, including antenna, visibilities, times, etc.
Step 2: Create a folder for your template.
Go to you SIMIO directory, and open your templates folder. Create an empty folder with the name of your template. In this case, the template will be called Elias24.
Step 3: Create sub folders and scripts.
Create 3 empty folders, named "images", "msfiles" and "uvtables". Additionally, create 2 empty scripts named "template_casa_handling.py" and "template_info.py". In this example the template is Elias24, therefore the templates will be called: "Elias24_casa_handling.py" and "Elias24_info.py".
Move the ms file downloaded in step 1 into the folder "msfiles", and extract the ms file from the .tgz.
Step 4: Template information.
The file "template_info.py", in this case "Elias24_info.py", contains important information to generate the images for this template. You also can copy/paste the info file of another template and replace the numbers with the ones of your template.
Source Geometry: Obtained from Huang et al. (DSHARP II, 2018). You can add a spatial offset if needed, and the inclination and position angle must be input in degrees. The ms file of Elias 27 has a phase center different from the center of the source, but we will change that in the next step. Therefore, we set dRa and dDec to 0.
Sky info: Here you should write the coordinates of the source center, in J2000 epoch. The coordinate we chose for Elias 24 is peak brightness pixel. The parameter temp_semimaj is the radial extent of the source in arcsec. This parameter is used to create the mask to generate its images.
Clean info: This parameters are needed to generate the template images. The robust parameters controls the weight that is given to the baselines. In this case, we know the original study was made on images generated with a robust parameter of 0.0 (Andrews et al. DSHARP I, 2021). The cellsize should be around 7x to 10x smaller than the beam size, and the image size should be big enough such that we can estimate the noise level with an annulus around the source.
Step 5.1: Open CASA to prepare ms file.
Generally speaking, high angular resolution observations of disks can result in very heavy ms files. In SIMIO, we are mainly interested in checking the observability of your model under the uv-coverage of a template observation, therefore we can reduce the ms files volume by averaging in frequency and time, without considerably modifying the uv-coverage. The goal of this step is to reduce the data volume of the original observation, thus speeding up all the upcoming processes.
Open CASA in your terminal, from the folder /home/path_to_simio/simio/templates/Elias24/ . From this location, we will call the CASA analysis utils, and also the SIMIO scripts to extract uvtables and generate images.
Set the name of the template as prefix, and create the name for the template measurement set. Execute the task listobs on the downloaded ms file.
Step 5.2: Check the ms file
Here I show a small part of the information given by listobs. Here you can see that the visibilities of Elias 24 are stored in the ms file in 16 spectral windows (numbered from 0 to 15). We will average each spectral window to only 1 channel, and we will also average in time to 24s. This is an aggressive averaging, but it is ok for our comparison goal.
Step 5.3: Split to average
We start by removing previous ms files, just in case. Then, we split the original ms file we downloaded into 3 different ms files. The first ms file contains the spectral windows (spws) with 4 channels per spw, the second ms file contains the spws with 8 channels, and the third with 16 channels. In each split, we combine those channels into 1, and we also average in time.
This step can also be done with mstransform.
Step 5.4: Concatenate
Now we take those 3 ms files, and we concatenate them into only 1 file. To save memory, we remove the intermediate auxiliary files.
When checking the new file with listobs, you will see that each spw has only 1 channel.
Step 5.5: Shift phase-center
The phase center of this observation is not in the center of the disk (you can confirm this downloading the continuum fits file form the DSHARP data release webpage).
We will move the phase center of the visibilities to match the location of the peak emission of the disk. This should be a good approximation for the disk center.
It is not mandatory to change the phase-center, and you can skip this step in your own templates.
Step 6.1: Image your template
Use the task tclean_wrapper to image the averaged ms file. Here you have the freedom to set the CLEAN parameters by yourself, but you should use the info script parameters (same cellsize, imsize, robust).
The parameter smallscalebias will force CLEAN to prefer the bigger scales before cleaning with point sources. The gain=0.05 and cyclefactor=1.75 are for more conservative iterations.
We will clean until we reach 4 sigma, such that afterwards we can apply the JvM correction.
Step 6.2: CLEAN
The CLEAN interactive viewer should look like this, with the mask already set. Press the green arrow iteratively, or press the blue arrow and wait until its finished.
Be patient. This step will take a long time.
Step 6.3: Estimate SNR and apply JvM correction
You have succesfully generated the images. Execute the estimate_SNR function and the JvM correction yo your newly created images. This will give you the angular resolution of your images, and the noise information.
Check your JvM corrected image with the CASA viewer task. Here we have changed the brightness scale.
Step 6.4: Export your images to fits files
Use the task exportfits to export your newly created images to fits files.
Here I show an example to save the JvM corrected image, the non JvM corrected image, the residuals, the CLEAN model, and the PSF.
Step 7: Write the uvtables in .txt
Execute the following piece of code to extract the uvtable of your ms file. You only need to change 1 line of this code: The name of the template, which I highlighted in bold.
The uvtable size will be printed after being concatenated.
# 93M uvtables/Elias24_uvtable.txt
Step 8: That's it!
That's all! your template is now ready to be used as a SIMIO template. The images of the template are stored in the images folder, the averaged ms file is in msfiles, and the visibilities are un the uvtables folder, in txt format.
You can now delete all the .log and .last files that were created by CASA.