3C286 Band6Pol Imaging for CASA 6.6.1: Difference between revisions

From CASA Guides
Jump to navigationJump to search
mNo edit summary
Line 3: Line 3:
==Overview==
==Overview==


This portion of the '''[[3C286_Polarization]]''' CASA Guide will cover the imaging of the  
This portion of the '''[[3C286 Polarization]]''' CASA Guide will cover the imaging of the  
total power and polarized emission. Details of the ALMA observations are provided at '''[[3C286_Polarization]]'''.
total power and polarized emission.


This guide picks up where the '''[[3C286_Band6Pol_Calibration]]''' section left off: right after running the CASA task {{split_6.6.1}} to split off the science target from the rest of the measurement set following calibration.  If you completed the Calibration section of the guide, then you can continue where you left off, with 3c286_Band6.pol.cal.ms.   
This guide picks up where the '''[[3C286 Band6Pol Calibration | Calibration]]''' section left off: right after running the CASA task {{split_6.6.1}} to split off the science target from the rest of the measurement set following calibration.  If you completed the Calibration section of the guide, then you can continue where you left off, with ''3c286_Band6.pol.cal.ms''.   


If you did not complete the Calibration portion of the guide, then you can instead download the file 3C286_Band6_CalibratedData.tgz (the calibrated uv data) from [[3C286_Polarization#Obtaining the Data]]'''.
If you did not complete the Calibration portion of the guide, then you can instead download the file ''3C286_Band6_CalibratedData.tgz'' (the calibrated uv data) from [[3C286 Polarization#Obtaining the Data | Obtaining the Data]]'''.


Once the download has finished, unpack the file:
Once the download has finished, unpack the file:
Line 22: Line 22:
</source>
</source>


After that, you should have 3c286_Band6.pol.cal.ms in your working directory.
After that, you should have ''3c286_Band6.pol.cal.ms'' in your working directory.


==Full polarization imaging of the target==
==Full polarization imaging of the target==

Revision as of 21:43, 18 September 2024


Overview

This portion of the 3C286 Polarization CASA Guide will cover the imaging of the total power and polarized emission.

This guide picks up where the Calibration section left off: right after running the CASA task split to split off the science target from the rest of the measurement set following calibration. If you completed the Calibration section of the guide, then you can continue where you left off, with 3c286_Band6.pol.cal.ms.

If you did not complete the Calibration portion of the guide, then you can instead download the file 3C286_Band6_CalibratedData.tgz (the calibrated uv data) from Obtaining the Data.

Once the download has finished, unpack the file:

# in bash
# In a terminal outside CASA
tar -xvzf 3C286_Band6_CalibratedData.tgz

cd 3C286_Band6_CalibratedData

# Start CASA
casa

After that, you should have 3c286_Band6.pol.cal.ms in your working directory.

Full polarization imaging of the target

We will start by making a continuum full Stokes image of 3C286 using tclean. We first define the dataset we will use in all the following steps:

# In CASA
vis='3c286_Band6.pol.cal.ms'

Before starting the cleaning, it makes sense to check if the emission is resolved or not by plotting amplitude as a function of uv-distance. The higher amplitudes at shorter uv-distances suggest that the source is slightly resolved.

# In CASA
plotms(vis, spw='', xaxis='uvwave', yaxis='amp', correlation='XX,YY',
       avgtime='1e8', avgchannel='1000', coloraxis='baseline',showgui=True)
Amplitude vs. uv-distance. The source seems to be slightly resolved.

This plot also helps us defining the cellsize needed for the task clean. From the plot we see that the longest baseline is 500 kilo wavelength. This means that the maximum resolution can be approximately 1/500000*206265 arcsec = 0.4 arcsec. We will use a cellsize=0.1, to oversample the beam sufficiently. The FWHM of the primary beam of ALMA in Band 6 is about 25 arcsec, and we want to image out to at least that extent, so we will use imsize=250.


# In CASA

os.system('rm -rf 3c286.cal.StokesIQUV_noselfcal.clean*')
tclean(vis,
      imagename='3c286.cal.StokesIQUV_noselfcal.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      deconvolver='clarkstokes',
      stokes='IQUV',
      interactive=True, 
      weighting='briggs',
      robust=0.5,
      niter=500,
      pbcor=True,
      savemodel='modelcolumn')

Specifying interactive=True , the tclean task brings up a viewer to show the residual clean image, clean masks can be defined, and when the residuals are noise-like, the cleaning process can be interrupted, hiting the red X symbol. Please note that the cleaning will not start without any active mask (to activate a mask you need to double click inside the region). See First Look at Imaging guide for further details on the interactive use of clean.

Finally, note that we delete any previous versions of the output images before proceeding with the clean command. This is important, because if images with the supplied root name already exist, CASA will clean those further instead of producing new output images.

After around 500 iterations, using an elliptical clean box around the central source, the residuals are already noise-like, so you can stop the cleaning.

To view your newly cleaned image, You should start

This guide features CARTA, the “Cube Analysis and Rendering Tool for Astronomy,” which is the new NRAO visualization tool for images and cubes. The CASA viewer (imview) has not been maintained for a few years and will be removed from future versions of CASA. We strongly recommend using CARTA, as it provides a much more efficient, stable, and feature rich user experience. A comparison of the CASA viewer and CARTA, as well as instructions on how to use CARTA at NRAO, is provided in the CARTA section of the CASA docs.

to view the image. If using NRAO machines, you can open a new terminal tab, cd to the working directory, then type:

    # in terminal
    carta --no_browser

Copy the output URL into a browser to view your CARTA session. Select and load <name.image> to look at your image.

Total intensity image of 3C286

We will determine some statistics for the image using the task imstat (some details are given below):

# In CASA
calstat=imstat(imagename='3c286.cal.StokesIQUV_noselfcal.clean.image', stokes='I', region='', box='10,10,90,35')
rms=(calstat['rms'][0])
print('>> rms in continuum image: '+str(rms))
calstat=imstat(imagename='3c286.cal.StokesIQUV_noselfcal.clean.image', region='')
peak=(calstat['max'][0])
print('>> Peak in continuum image: '+str(peak))
print('>> Dynamic range in continuum image: '+str(peak/rms))

This tells us that the rms of this image is 0.9 mJy and the peak flux density is ~324 mJy. The dynamic range (ratio between peak and rms) is approximately 295.

The mask you drew for the clean has been saved in your working directory as a file "3c286.cal.StokesIQUV_noselfcal.clean.mask". If you want to use it in the following self-calibration you should rename it. If you downloaded the calibrated data you have already a file mask, named 3c286_StokesIQUV_selfcal.mask.

To rename the file:

# In CASA
os.system('cp -r 3c286.cal.StokesIQUV_noselfcal.clean.mask 3c286_StokesIQUV_selfcal.mask')


Self-calibration

The quality of the image can be improved by applying the self-calibration to the uv data, see Antennae guide for details on this technique.

The task tclean has automatically saved a model in the header of the measurement set, we use it to self-calibrate through the task gaincal:

# In CASA
os.system('rm -rf 3c286_IQUV.G1p')
gaincal(vis,
        caltable='3c286_IQUV.G1p',
        solint='300s',
        refantmode='strict',
        refant='DV23',minblperant=4,
        calmode='p',minsnr=4)

The critical parameters in this setup are solint and calmode. We will force the reference antenna to remain constant with the reantmode='strict'. We want to calculate phase solutions only so we use calmode=p and we start using solint=300s, which means averaging 30 visibilities in the solution calculation. It is usually best to start with a large solint and then go down to the integration time if the S/N of the data permits.

To check the quality of the solutions we obtained, we plot the gains for each antenna, as function of time:

# In CASA
plotms(vis='3c286_IQUV.G1p',xaxis='time',yaxis='phase',iteraxis='antenna',coloraxis='spw',showgui=True)


Now we apply those solutions to the uv data:

# In CASA

applycal(vis,
         field='',
         gaintable=['3c286_IQUV.G1p'],calwt=False)

and make a new image:

# In CASA

os.system('rm -rf 3c286.cal.StokesIQUV_selfcal1.clean*')
tclean(vis,
      imagename='3c286.cal.StokesIQUV_selfcal1.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      deconvolver='clarkstokes',
      stokes='IQUV',
      mask= '3c286_StokesIQUV_selfcal.mask',
      weighting='briggs',
      robust=0.5,
      interactive=True,
      pbcor=True,
      niter=1000,
      savemodel='modelcolumn')

calstat=imstat(imagename='3c286.cal.StokesIQUV_selfcal1.clean.image', stokes='I', region='', box='10,10,90,35')
rms=(calstat['rms'][0])
print('>> rms in continuum image: '+str(rms))
calstat=imstat(imagename='3c286.cal.StokesIQUV_selfcal1.clean.image', region='')
peak=(calstat['max'][0])
print('>> Peak in continuum image: '+str(peak))
print('>> Dynamic range in continuum image: '+str(peak/rms))

The rms of this new image is 0.31 mJy/beam, lower than the value measured in the first image (0.9 mJy/beam). We run a second self-calibration, decreasing to 30 sec the solint, apply it to the data, and image it again:

# In CASA
os.system('rm -rf 3c286_IQUV.G2p')
gaincal(vis,
        caltable='3c286_IQUV.G2p',
        solint='30s',refantmode='strict',
        refant='DV23',minblperant=4,
        calmode='p',minsnr=4)

plotms(vis='3c286_IQUV.G2p',xaxis='time',yaxis='phase',iteraxis='antenna',coloraxis='spw',showgui=True)

applycal(vis,
         field='',
         gaintable=['3c286_IQUV.G2p'],calwt=False)

os.system('rm -rf 3c286.cal.StokesIQUV_selfcal2.clean*')
tclean(vis,
      imagename='3c286.cal.StokesIQUV_selfcal2.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      deconvolver='clarkstokes',
      stokes='IQUV',
      mask= '3c286_StokesIQUV_selfcal.mask',
      interactive=True,
      weighting='briggs',
      robust=0.5,
      pbcor=True,
      niter=1000,
      savemodel='modelcolumn')

You can notice when the first residual image appears that some residual central emission is evident. Continue the cleaning, by using the green continue button, until the residual image appears as much as possible noise like. In this example we stop the clean after 2 cycles, and we check the image statistics.

# In CASA
calstat=imstat(imagename='3c286.cal.StokesIQUV_selfcal2.clean.image', stokes='I', region='', box='10,10,90,35')
rms=(calstat['rms'][0])
print('>> rms in continuum image: '+str(rms))
calstat=imstat(imagename='3c286.cal.StokesIQUV_selfcal2.clean.image', region='')
peak=(calstat['max'][0])
print('>> Peak in continuum image: '+str(peak))
print('>> Dynamic range in continuum image: '+str(peak/rms))


The rms level in this new image is ~0.2 mJy/beam. This level can be improved by a last run of selfcalibration, this time solving for both amplitude and phase.

# In CASA
os.system('rm -rf 3c286_IQUV.Gap')
gaincal(vis,
        caltable='3c286_IQUV.Gap',
        solint='30s',gaintable=['3c286_IQUV.G2p'],
        refant='DV23',minblperant=4,refantmode='strict',
        calmode='ap',minsnr=4)

plotms(vis='3c286_IQUV.Gap',xaxis='time',yaxis='amp',iteraxis='antenna',coloraxis='spw',showgui=True)

applycal(vis,
         field='',
         gaintable=['3c286_IQUV.G2p','3c286_IQUV.Gap'],calwt=False)

os.system('rm -rf 3c286.cal.StokesIQUV_selfcal_ap.clean*')
tclean(vis,
      imagename='3c286.cal.StokesIQUV_selfcal_ap.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      deconvolver='clarkstokes',
      stokes='IQUV',
      mask= '3c286_StokesIQUV_selfcal.mask',
      interactive=True, 
      weighting='briggs',
      robust=0.5,
      pbcor=True,
      niter=1000,
      savemodel='modelcolumn')

This time the first residual map shows a new bright extended component which was completely hidden by the noise in the previous images. We add a clean box around it and proceed with the clean. After 1000 cycles we stop and check the statistics of the image:

# In CASA
calstat=imstat(imagename='3c286.cal.StokesIQUV_selfcal_ap.clean.image', stokes='I', region='', box='10,10,90,35')
rms=(calstat['rms'][0])
print('>> rms in continuum image: '+str(rms))
calstat=imstat(imagename='3c286.cal.StokesIQUV_selfcal_ap.clean.image', region='')
peak=(calstat['max'][0])
print('>> Peak in continuum image: '+str(peak))
print('>> Dynamic range in continuum image: '+str(peak/rms))

The rms is 0.11 mJy and the peak of the image is 359 mJy, leading to a dynamic range of 3291.

We can consider this result satisfying and stop the self-calibration.

Stokes images

We can extract the Stokes Q, U, and V images from the selfcalibrated image, using the taks immath:

# In CASA
os.system('rm -rf 3c286.cal.StokesI.clean.image*')
immath(imagename='3c286.cal.StokesIQUV_selfcal_ap.clean.image',outfile='3c286.cal.StokesI.clean.image',expr='IM0',stokes='I')
os.system('rm -rf 3c286.cal.StokesQ.clean.image*')
immath(imagename='3c286.cal.StokesIQUV_selfcal_ap.clean.image',outfile='3c286.cal.StokesQ.clean.image',expr='IM0',stokes='Q')
os.system('rm -rf 3c286.cal.StokesU.clean.image*')
immath(imagename='3c286.cal.StokesIQUV_selfcal_ap.clean.image',outfile='3c286.cal.StokesU.clean.image',expr='IM0',stokes='U')
os.system('rm -rf 3c286.cal.StokesV.clean.image*')
immath(imagename='3c286.cal.StokesIQUV_selfcal_ap.clean.image',outfile='3c286.cal.StokesV.clean.image',expr='IM0',stokes='V')

We measure the statistic in each emage, using the task imstat:

# In CASA

I_rms=(imstat(imagename='3c286.cal.StokesI.clean.image', region='', box='10,10,90,35')['rms'][0])
I_peak=(imstat(imagename='3c286.cal.StokesI.clean.image', region='')['max'][0])
Q_rms=(imstat(imagename='3c286.cal.StokesQ.clean.image', region='', box='10,10,90,35')['rms'][0])
Q_peak=(imstat(imagename='3c286.cal.StokesQ.clean.image', region='')['max'][0])
U_rms=(imstat(imagename='3c286.cal.StokesU.clean.image', region='', box='10,10,90,35')['rms'][0])
U_peak=(imstat(imagename='3c286.cal.StokesU.clean.image', region='')['max'][0])

print(I_rms, I_peak, Q_rms, Q_peak, U_rms, U_peak)


The results of the measurements for the I, Q, and U images are reported in the table below. All flux densities are reported in mJy/beam.

The results obtained from the V image are not reported in the table, since at this time the quality and accuracy of the circular polarization data are still undergoing verification. Results from the V image are therefore not recommended for scientific purposes at this time.

I Q U
rms 0.193 0.030 0.054
Peak 334 12.3 53.8
Dyn range 1733 410 996

Constructing Polarization Intensity and Angle Images

We have now produced the images for all the four Stokes parameters: I, Q, U, and V. Stokes Q and U describe the linear polarization and V describes the circular polarization. Specifically, Q describes the amount of linear polarization aligned with a given axis, and U describes the amount of linear polarization at a 45 deg angle to that axis. The V parameter describes the amount of circular polarization, with the sign (positive or negative) describing the sense of the circular polarization (right- or left-hand circularly polarized).

In general, few celestial sources are expected to show circular polarization, with the notable exception of masers. Terrestrial and satellite sources are often highly circularly polarized. The V image is therefore often worth forming because any V emission could be indicative of unflagged RFI within the data (or problems with the calibration!).

Because the Q and U images both describe the amount of linear polarization, it is more common to work with a linear polarization intensity image, [math]\displaystyle{ P = \sqrt{Q^2 +U^2} }[/math]. We can also calculate the polarization position angle [math]\displaystyle{ \chi = 0.5 arctan U/Q }[/math].

The relevant task is immath; for specific examples of polarization image processing see Polarization Manipulation.

To form the linear polarization image, we combine the Q and U images using the mode='poli' option of immath.

# In CASA
os.system('rm -rf 3c286_Band6.POLI')
immath(outfile='3c286_Band6.POLI',
       mode='poli',
       imagename=['3c286.cal.StokesQ.clean.image','3c286.cal.StokesU.clean.image'],
       sigma='0.0Jy/beam')


# In CASA
calstat=imstat(imagename='3c286_Band6.POLI', region='', box='10,10,90,35')
rms=(calstat['rms'][0])
print(rms)

The measured rms is 0.050 mJy/beam.

To form the polarization position angle image we combine again the Q and U images using the mode='pola' option of immath. The Q and U images can be listed in either order. To avoid displaying the position angle of noise, we can use the polithresh parameter to set a threshold intensity of the linear polarization above which we wish to calculate the polarization angle. An appropriate level here might be the 5σ level of the polarization image, about 0.2 mJy/beam.

# In CASA
os.system('rm -rf 3c286_Band6.POLA')
immath(outfile='3c286_Band6.POLA',
       mode='pola',
       imagename=['3c286.cal.StokesQ.clean.image','3c286.cal.StokesU.clean.image'],
       polithresh='0.2mJy/beam')

If desired, it is also possible to form the fractional linear polarization image, defined as P/I.

# In CASA
os.system('rm -rf 3c286_Band6.RATIO')
immath(outfile='3c286_Band6.RATIO',
       mode='evalexpr',
       imagename=['3c286.cal.StokesI.clean.image','3c286.cal.StokesQ.clean.image','3c286.cal.StokesU.clean.image'],
       expr='sqrt((IM1^2+IM2^2)/IM0[IM0>5e-3]^2)')

Since the total intensity image can (and hopefully does) approach zero in regions free of source emission, dividing by the total intensity can produce very high pixel values in these regions. We therefore wish to restrict our fractional polarization image to regions containing real emission, which we do by setting a threshold in the total intensity image, which in this case corresponds to five times the noise level in the Stokes I image. The computation of the polarized intensity is specified in the previous command by

       expr='sqrt((IM1^2+IM2^2)/IM0[IM0>5e-3]^2)'

with the expression in square brackets setting the threshold in IM0 (the total intensity image). Note that IM0, IM1 and IM2 correspond to the three files listed in the imagename array, in that order. In this case, the order in which the different images are specified is critical.

In order to have a dimensionless value for the ratio image, we now modify the keyword bunit in the header of the file:

# In CASA
imhead('3c286_Band6.RATIO', mode='put', hdkey='bunit', hdvalue='')

Image visualization and analysis

Now we can view these various images using

This guide features CARTA, the “Cube Analysis and Rendering Tool for Astronomy,” which is the new NRAO visualization tool for images and cubes. The CASA viewer (imview) has not been maintained for a few years and will be removed from future versions of CASA. We strongly recommend using CARTA, as it provides a much more efficient, stable, and feature rich user experience. A comparison of the CASA viewer and CARTA, as well as instructions on how to use CARTA at NRAO, is provided in the CARTA section of the CASA docs.

. It is instructive to display the I, P, and [math]\displaystyle{ \chi }[/math] images (total intensity, total linearly polarized intensity, and polarization position angle) together, to show how the polarized emission relates to the total intensity, and how the magnetic field is structured. We can do this using CARTA.

  • Begin by loading the linear polarization image in CARTA:
  • Next, polarization position angle image (3c286_Band6.POLA) as a vector map. In the CARTA panel, hit the "File" then "Append Image". This will bring up a 'File Browser' GUI showing all images and MS in the current directory. Navigatge to your image and select the polarization position angle image (3c286_Band6.POLA).
  • Select the vector overlay icon from the top of the window. Set the Data Source as the *.POLA image, set the angular source as the current image, and set the intensity source to none. Finally click on the apply button at the bottom of the vector overlay configuration window.
Full-polarization image of 3C286

While we set the polithresh parameter when we created the position angle ([math]\displaystyle{ \chi }[/math]) image, a digression here is instructive in the use of LEL Expressions. Had we not set this parameter, the position angle would have been derived for all pixels within the full IQUV image cube. There is only polarized emission from a limited subset of pixels within this image. Therefore, to avoid plotting vectors corresponding to the position angle of pure noise, we now wish to select only the regions where the polarized intensity is brighter than some threshold value. To do this, we use an LEL (Lattice Expression Language) Expression in the 'Load Data' GUI. For our chosen threshold of 0.2 mJy/beam (the 5 sigma level in the P image), we paste the expression

     '3c286_Band6.POLA'['3c286_Band6.POLI'>0.001]

into the LEL Expression box in the GUI, and click the 'Vector Map' button. This would load the vectors only for regions where P>1 mJy/beam.

To optimize the display for ease of interpretation we click the wrench icon to open a 'Data Display Options' GUI. This will have 3 tabs, corresponding to the three images loaded. We can change the image color map and transfer function, the contour levels and color, and the the vector spacing and color.

For the polarization angle vector it is also possible to add a rotation. The polarization position angle as calculated is the electric vector position angle (EVPA). If we are interested in the orientation of the magnetic field, then for an optically thin source the magnetic field orientation is perpendicular to the EVPA, so we must rotate the vectors by 90 degrees. Select the vector image tab in the 'Data Display Options' GUI (labeled as the LEL expression we entered in the Load Data GUI) and enter 90 in the Extra rotation box. If the vectors appear too densely packed on the image, change the spacing of the vectors by setting X-increment and Y-increment to a larger value.

To get quantitative information from the images, we can either use the task imstat (we already used it above) or the task imfit. The task imstat returns the statistics in a Python dictionary, from which we can read what we need in a Python variable. In this example we extract the peak value:

# In CASA
calstat=imstat(imagename='3c286_Band6.POLI', region='')
print(calstat)
calstat['max'][0]

The output saved in calstat is pasted below.

{'blc': array([0, 0, 0, 0]), 
 'blcf': '13:31:09.255, +30.30.20.460, Plinear, 2.3301e+11Hz',
 'flux': array([0.14085003]),
 'max': array([0.05526536]), 'maxpos': array([125, 126,   0,   0]),
 'maxposf': '13:31:08.288, +30.30.33.060, Plinear, 2.3301e+11Hz',
 'mean': array([7.8467172e-05]),
 'medabsdevmed': array([1.71810989e-05]),
 'median': array([4.27724954e-05]),
 'min': array([7.90703183e-08]),
 'minpos': array([28, 87,  0,  0]),
 'minposf': '13:31:09.039, +30.30.29.160, Plinear, 2.3301e+11Hz',
 'npts': array([62500.]), 'q1': array([2.72247598e-05]), 'q3': array([6.23603555e-05]), 'quartile': array([3.51355957e-05]),
 'rms': array([0.00094099]), 'sigma': array([0.00093772]),
 'sum': array([4.90419825]), 'sumsq': array([0.05534188]),
 'trc': array([249, 249,   0,   0]),
 'trcf': '13:31:07.329, +30.30.45.360, Plinear, 2.3301e+11Hz'}


calstat['max'][0]=0.055265363305807114

The task imfit finds one or more elliptical gaussian components on an image region.

# In CASA
fit_res=imfit(imagename='3c286_Band6.POLI', region='')
print(fit_res)

The output saved in fit_res is pasted below.


{'converged': array([ True]),
 'deconvolved': {'component0': {'flux': {'error': array([9.44862054e-05, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]),
 'polarisation': 'Stokes',
 'unit': 'Jy',
 'value': array([0.05640328, 0.        , 0.        , 0.        ])},
 'ispoint': True, 'label': '',
 'shape': {'direction': {'error': {'latitude': {'unit': 'arcsec',
 'value': 0.00040183003218277044},
 'longitude': {'unit': 'arcsec', 'value': 0.00012498417606069957}},
 'm0': {'unit': 'rad', 'value': -2.7439276433976794},
 'm1': {'unit': 'rad', 'value': 0.532485497843355},
 'refer': 'J2000', 'type': 'direction'},
 'type': 'Point'},
 'spectrum': {'channel': 0,
 'frequency': {'m0': {'unit': 'GHz', 'value': 233.00995157526424},
 'refer': 'LSRK',
 'type': 'frequency'},
 'type': 'Constant'},
 'sum': {'unit': 'Jy/beam', 'value': 1.001404955983162}},
 'nelements': 1},
 'pixelsperarcsec': array([10., 10.]),
 'results': {'component0': {'beam': {'beamarcsec': {'major': {'unit': 'arcsec',
 'value': 0.7631725072860718},
 'minor': {'unit': 'arcsec',
 'value': 0.4026465117931366},
 'positionangle': {'unit': 'deg', 'value': 8.341339111328125}},
 'beampixels': 34.818581831598614,
 'beamster': 8.183909381307055e-12},
 'flux': {'error': array([9.44862054e-05, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]),
 'polarisation': 'Stokes',
 'unit': 'Jy',
 'value': array([0.05640328, 0.        , 0.        , 0.        ])},
 'ispoint': True,
 'label': '',
 'peak': {'error': 5.0942046375170774e-05,
 'unit': 'Jy/beam',
 'value': 0.05616799016487879},
 'pixelcoords': array([125.21729508, 125.58042049]),
 'shape': {'direction': {'error': {'latitude': {'unit': 'arcsec',
 'value': 0.00040183003218277044},
 'longitude': {'unit': 'arcsec', 'value': 0.00012498417606069957}},
 'm0': {'unit': 'rad', 'value': -2.7439276433976794},
 'm1': {'unit': 'rad', 'value': 0.532485497843355},
 'refer': 'J2000',
 'type': 'direction'},
 'majoraxis': {'unit': 'arcsec', 'value': 0.764893494058789},
 'majoraxiserror': {'unit': 'arcsec', 'value': 0.0009546133974881486},
 'minoraxis': {'unit': 'arcsec', 'value': 0.40342347102453774},
 'minoraxiserror': {'unit': 'arcsec', 'value': 0.0002658946562409573},
 'positionangle': {'unit': 'deg', 'value': 7.910498993465549},
 'positionangleerror': {'unit': 'deg', 'value': 0.03902251323677755}, 'type': 'Gaussian'},
 'spectrum': {'channel': 0, 'frequency': {'m0': {'unit': 'GHz', 'value': 233.00995157526424},
 'refer': 'LSRK', 'type': 'frequency'},
 'type': 'Constant'},
 'sum': {'unit': 'Jy/beam', 'value': 1.001404955983162}}, 'nelements': 1}}

To extract the flux and its error, we can read them from CASA in Python variables:

# In CASA
fluxPI=fit_res['results']['component0']['flux']['value'][0]
errorPI=fit_res['results']['component0']['flux']['error'][0]

The flux measured in the fitted gaussian is 60.7 mJy with an error of 0.096 mJy.

We now use this method to estimate the fluxes in all the Stokes images:

# In CASA

# First we run imfit 
resI=imfit(imagename = '3c286.cal.StokesI.clean.image', box = '110,110,145,145')
resQ=imfit(imagename = '3c286.cal.StokesQ.clean.image', box = '110,110,145,145')
resU=imfit(imagename = '3c286.cal.StokesU.clean.image', box = '110,110,145,145')
resV=imfit(imagename = '3c286.cal.StokesV.clean.image', box = '110,110,145,145')
 
# and then we extract the flux and error values for each Stokes

fluxI=resI['results']['component0']['flux']['value'][0]
errorI=resI['results']['component0']['flux']['error'][0]

fluxQ=resQ['results']['component0']['flux']['value'][1]
errorQ=resQ['results']['component0']['flux']['error'][1]

fluxU=resU['results']['component0']['flux']['value'][2]
errorU=resU['results']['component0']['flux']['error'][2]
 
fluxV=resV['results']['component0']['flux']['value'][3]
errorV=resV['results']['component0']['flux']['error'][3]

Now we use these values to compute polarization intensity, angle and ratio, and their errors:

# In CASA 
import math

fluxPI  = math.sqrt( fluxQ**2 + fluxU**2 )
errorPI = math.sqrt( (fluxQ*errorQ)**2 + (fluxU*errorU)**2 ) / fluxPI

fluxPImjy = 1000*fluxPI
errPImjy  = 1000*errorPI

polRatio = fluxPI / fluxI
errPRat  = polRatio * math.sqrt( (errorPI/fluxPI)**2 + (errorI/fluxI)**2 )
  
polAngle = 0.5 * math.degrees( math.atan2(fluxU,fluxQ) )
errPA    = 0.5 * math.degrees( math.sqrt( (fluxQ*errorU)**2 + (fluxU*errorQ)**2 ) / fluxPI**2 )

The results are collected in the following table:

Flux err
I (mJy) 342 0.64
Q (mJy) 12.8 0.054
U (mJy) 54.9 0.16
Pol int (mJy) 56.4 0.123
P (%) 16.4 0.46
χ (deg) 38.44 0.030


As you can see, the polarization intensity computed from the Q and U fluxes is the same as the one extracted from the polarization image (as it should be!).

Note that the uncertainties quoted above are purely statistical. The systematic errors will be larger, and include (but are not limited to) any net bias in the position angle of the linear feeds in the antennas, the details of different observations (at what parallactic angles, etc.), and other data quality variations (including source structure). We conservatively estimate the position angle uncertainty to be ± 2º.

And now, a quick comparison with previous results from IRAM and CARMA.

Agudo et al. (2012) presented the results of single-dish millimeter measurements of 3C286 with the IRAM 30 m Telescope. Their observations at 1 mm (229 GHz) and 3 mm (86 GHz) produced the following results:

1 mm 3 mm
P (%) 14.4 ± 1.8 13.5 ± 0.3
χ (deg) 33.1 ± 5.7 37.3 ± 0.8

Hull & Plambeck 2015 (JAI) and CARMA Memo 64 report interferometric polarization data of 3C286 taken with CARMA at 1 mm (225 GHz). Their results are as follows:

1 mm
χ (deg) 39.2 ± 1.0

Export images in fits format

To get all images in fits format you need to use the task exportfits.

You can add the parameters imagename (the input image) and fitsimage (the name of the output image) one by one or you can run a python cycle over all the images:

# In CASA 
import glob

imagenames=glob.glob("*image") 

for name in imagenames:
    exportfits(imagename=name, fitsimage=name+'.fits')

Most recently updated for CASA Version 6.6.1 using Python 3.8