Difference between revisions of "3C286 Band6Pol Imaging for CASA 4.3"

From CASA Guides
Jump to navigationJump to search
Line 315: Line 315:
 
{'blc': array([0, 0, 0, 0], dtype=int32),
 
{'blc': array([0, 0, 0, 0], dtype=int32),
 
  'blcf': '13:31:09.255, +30.30.20.460, Plinear, 2.33e+11Hz',
 
  'blcf': '13:31:09.255, +30.30.20.460, Plinear, 2.33e+11Hz',
  'flux': array([ 0.20723054]),
+
  'flux': array([ 0.21426499]),
  'max': array([ 0.05507297]),
+
  'max': array([ 0.05525938]),
 
  'maxpos': array([125, 126,  0,  0], dtype=int32),
 
  'maxpos': array([125, 126,  0,  0], dtype=int32),
 
  'maxposf': '13:31:08.288, +30.30.33.060, Plinear, 2.33e+11Hz',
 
  'maxposf': '13:31:08.288, +30.30.33.060, Plinear, 2.33e+11Hz',
  'mean': array([ 0.0001742]),
+
  'mean': array([ 0.00018011]),
  'medabsdevmed': array([  5.58975880e-05]),
+
  'medabsdevmed': array([  5.75154700e-05]),
  'median': array([ 0.00010093]),
+
  'median': array([ 0.0001056]),
  'min': array([  3.38347860e-07]),
+
  'min': array([  4.06749649e-07]),
  'minpos': array([10515,  0,  0], dtype=int32),
+
  'minpos': array([21651,  0,  0], dtype=int32),
  'minposf': '13:31:08.443, +30.30.21.960, Plinear, 2.33e+11Hz',
+
  'minposf': '13:31:07.584, +30.30.25.560, Plinear, 2.33e+11Hz',
 
  'npts': array([ 62500.]),
 
  'npts': array([ 62500.]),
  'quartile': array([ 0.00012188]),
+
  'quartile': array([ 0.00012576]),
  'rms': array([ 0.00118116]),
+
  'rms': array([ 0.00118729]),
  'sigma': array([ 0.00116825]),
+
  'sigma': array([ 0.00117356]),
  'sum': array([ 10.88734667]),
+
  'sum': array([ 11.25693699]),
  'sumsq': array([ 0.08719576]),
+
  'sumsq': array([ 0.08810332]),
 
  'trc': array([249, 249,  0,  0], dtype=int32),
 
  'trc': array([249, 249,  0,  0], dtype=int32),
 
  'trcf': '13:31:07.329, +30.30.45.360, Plinear, 2.33e+11Hz'}
 
  'trcf': '13:31:07.329, +30.30.45.360, Plinear, 2.33e+11Hz'}
  
 
CASA <2>: calstat['max'][0]                                   
 
CASA <2>: calstat['max'][0]                                   
   Out[2]: 0.055072970688343048
+
   Out[2]: 0.055259384214878082
 
</pre>
 
</pre>
  
Line 350: Line 350:
 
{'converged': array([ True], dtype=bool),
 
{'converged': array([ True], dtype=bool),
 
  'deconvolved': {'component0': {'beam': {'beamarcsec': {'major': {'unit': 'arcsec',
 
  'deconvolved': {'component0': {'beam': {'beamarcsec': {'major': {'unit': 'arcsec',
                                                                   'value': 0.9374212622642517},
+
                                                                   'value': 0.9374215006828308},
 
                                                         'minor': {'unit': 'arcsec',
 
                                                         'minor': {'unit': 'arcsec',
                                                                   'value': 0.4946170449256897},
+
                                                                   'value': 0.4946177303791046},
 
                                                         'positionangle': {'unit': 'deg',
 
                                                         'positionangle': {'unit': 'deg',
                                                                           'value': 7.585809230804443}},
+
                                                                           'value': 7.585813522338867}},
                                         'beampixels': 52.53736639405172,
+
                                         'beampixels': 52.537452563810966,
                                         'beamster': 1.2348608791161247e-11},
+
                                         'beamster': 1.2348629044872454e-11},
                                 'flux': {'error': array([ 0.0002871,  0.       ,  0.       ,  0.       ]),
+
                                 'flux': {'error': array([ 0.00029958,  0.       ,  0.       ,  0.       ]),
 
                                         'polarisation': 'Stokes',
 
                                         'polarisation': 'Stokes',
 
                                         'unit': 'Jy',
 
                                         'unit': 'Jy',
                                         'value': array([ 0.05878603,  0.        ,  0.        ,  0.        ])},
+
                                         'value': array([ 0.05915491,  0.        ,  0.        ,  0.        ])},
 
                                 'ispoint': False,
 
                                 'ispoint': False,
 
                                 'label': '',
 
                                 'label': '',
                                 'peak': {'error': 0.0029369034727939575,
+
                                 'peak': {'error': 0.0029066691780652316,
 
                                         'unit': 'Jy/beam',
 
                                         'unit': 'Jy/beam',
                                         'value': 1.081369480549404},
+
                                         'value': 1.0303086795033678},
 
                                 'shape': {'direction': {'error': {'latitude': {'unit': 'arcsec',
 
                                 'shape': {'direction': {'error': {'latitude': {'unit': 'arcsec',
                                                                               'value': 0.001472835888184062},
+
                                                                               'value': 0.001529344546156995},
 
                                                                   'longitude': {'unit': 'arcsec',
 
                                                                   'longitude': {'unit': 'arcsec',
                                                                                 'value': 0.00047528408956602243}},
+
                                                                                 'value': 0.0004948228240940263}},
 
                                                         'm0': {'unit': 'rad',
 
                                                         'm0': {'unit': 'rad',
                                                               'value': -2.7439276018133314},
+
                                                               'value': -2.7439276045840715},
 
                                                         'm1': {'unit': 'rad',
 
                                                         'm1': {'unit': 'rad',
                                                               'value': 0.5324854664907308},
+
                                                               'value': 0.5324854639759796},
 
                                                         'refer': 'J2000',
 
                                                         'refer': 'J2000',
 
                                                         'type': 'direction'},
 
                                                         'type': 'direction'},
 
                                           'majoraxis': {'unit': 'arcsec',
 
                                           'majoraxis': {'unit': 'arcsec',
                                                         'value': 0.18064574263642547},
+
                                                         'value': 0.18600598434542162},
 
                                           'majoraxiserror': {'unit': 'arcsec',
 
                                           'majoraxiserror': {'unit': 'arcsec',
                                                             'value': 0.01998078812493298},
+
                                                             'value': 0.01992867048653363},
 
                                           'minoraxis': {'unit': 'arcsec',
 
                                           'minoraxis': {'unit': 'arcsec',
                                                         'value': 0.13953275762824466},
+
                                                         'value': 0.1431202657371567},
 
                                           'minoraxiserror': {'unit': 'arcsec',
 
                                           'minoraxiserror': {'unit': 'arcsec',
                                                             'value': 0.01248591589683129},
+
                                                             'value': 0.013257769107270834},
 
                                           'positionangle': {'unit': 'deg',
 
                                           'positionangle': {'unit': 'deg',
                                                             'value': 167.22245442345886},
+
                                                             'value': 165.61288212682524},
 
                                           'positionangleerror': {'unit': 'deg',
 
                                           'positionangleerror': {'unit': 'deg',
                                                                 'value': 19.08059838829199},
+
                                                                 'value': 18.32359492104083},
 
                                           'type': 'Gaussian'},
 
                                           'type': 'Gaussian'},
 
                                 'spectrum': {'channel': 0,
 
                                 'spectrum': {'channel': 0,
Line 396: Line 396:
 
                                             'type': 'Constant'},
 
                                             'type': 'Constant'},
 
                                 'sum': {'unit': 'Jy/beam',
 
                                 'sum': {'unit': 'Jy/beam',
                                         'value': 1.585404684767127}},
+
                                         'value': 1.5916313268244267}},
 
                 'nelements': 1}
 
                 'nelements': 1}
 
[...]
 
[...]
Line 408: Line 408:
 
</source>
 
</source>
  
The flux measured in the fitted gaussian is 58.8 mJy with an error of 0.3 mJy.
+
The flux measured in the fitted gaussian is 59.1 mJy with an error of 0.3 mJy.
  
 
We now use this method to estimate the fluxes in all the Stokes images:
 
We now use this method to estimate the fluxes in all the Stokes images:
Line 464: Line 464:
 
|-
 
|-
 
| style="text-align:center;"| I   
 
| style="text-align:center;"| I   
| style="text-align:center;"| 357 mJy
+
| style="text-align:center;"| 359 mJy
| style="text-align:center;"| 1.5 mJy
+
| style="text-align:center;"| 1.6 mJy
 
|-
 
|-
 
| style="text-align:center;"| Q  
 
| style="text-align:center;"| Q  
| style="text-align:center;"| 13.06 mJy
+
| style="text-align:center;"| 13.26 mJy
| style="text-align:center;"| 0.07 mJy
+
| style="text-align:center;"| 0.08 mJy
 
|-
 
|-
 
| style="text-align:center;"| U  
 
| style="text-align:center;"| U  
| style="text-align:center;"| 57.3 mJy
+
| style="text-align:center;"| 57.6 mJy
| style="text-align:center;"| 0.2 mJy
+
| style="text-align:center;"| 0.3 mJy
 
|-
 
|-
 
| style="text-align:center;"| V  
 
| style="text-align:center;"| V  
 
| style="text-align:center;"| 0.0  
 
| style="text-align:center;"| 0.0  
| style="text-align:center;"| 0.04 mJy
+
| style="text-align:center;"| 0.05 mJy
 
|-
 
|-
 
! scope="col"| Pol int  
 
! scope="col"| Pol int  
! scope="col"| 58.8 mJy
+
! scope="col"| 59.15 mJy
! scope="col"| 0.08 mJy
+
! scope="col"| 0.09 mJy
 
|-
 
|-
 
! scope="col"| Pol ratio  
 
! scope="col"| Pol ratio  
 
! scope="col"| 0.16
 
! scope="col"| 0.16
! scope="col"| 0.0007
+
! scope="col"| 0.0008
 
|-
 
|-
 
! scope="col"| Pol angle  
 
! scope="col"| Pol angle  
! scope="col"| 38.6 deg
+
! scope="col"| 38.5 deg
! scope="col"| 0.04 deg
+
! scope="col"| 0.05 deg
  
 
|}
 
|}

Revision as of 15:04, 7 April 2015

This page is currently under construction.

DO NOT USE IT.

To navigate the CASAguides pages, visit [http://casaguides.nrao.edu/ casaguides.nrao.edu ]

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 3C286_Band6Pol_Calibration_for_CASA_4.3 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_SVpol.cal.ms. If you did not complete the Calibration portion of the guide, then you can download the calibrated uvdata by clicking on the region closest to your location:


North America

Europe

East Asia

Once there, download the file '3C286_Band6_pol_Calibrated.tgz' to obtain the calibrated uvdata.

Once the download has finished, unpack the file:

# In a terminal outside CASA
tar -xvzf 3C286_Band6_pol_Calibrated.tgz

cd 3C286_Band6_pol_Calibrated

# Start CASA
casapy

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


Full polarization imaging of the target

We will start by making a continuum image of 3C286 using clean. 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='3c286_SVpol.cal.ms', spw='', xaxis='uvwave', yaxis='amp', correlation='XX,YY',
       avgtime='1e8', avgchannel='1000', coloraxis='baseline')
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.StokesI.clean*')
clean(vis='3c286_SVpol.cal.ms',
      imagename='3c286.cal.StokesI.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      stokes='I',
      interactive=T, niter=10000)

Specifying interactive=T , the clean 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 TW Hydra casaguide 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 the first 100 iterations, using an elliptical clean box around the central source, the residuals are already noise-like, so you can stop the cleaning. You can use the viewer to look at your image.

# In CASA
viewer('3c286.cal.StokesI.clean.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.StokesI.clean.image', region='', box='10,10,90,35')
rms=(calstat['rms'][0])
print '>> rms in continuum image: '+str(rms)
calstat=imstat(imagename='3c286.cal.StokesI.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.8 mJy and the peak flux density is ~335 mJy. The dynamic range (ratio between peak and rms) is approximately 390.

For future reference, we create a png file of the continuum image:

# In CASA
os.system('rm -rf 3c286.cal.StokesI.clean.png')
imview(raster={'file': '3c286.cal.StokesI.clean.image', 'colorwedge':T,
               'range':[-0.006, 0.4], 'scaling':-2.4, 'colormap':'Rainbow 2'},
                out='3c286.cal.StokesI.clean.png')

This imview line does'nt actually make the image with the right scaling. Shall we leave it anyway, removing the scaling parameter, or should I add instructions to save the image from the viewer manually?

We now use the same tasks to obtain the stokes Q,U, and V images separately. There is also the possibility to obtain a four-channels image containing all the Stokes IQUV; however, since we will need each image separately when we construct the polarization images, we make all of them separately. The first 100 iterations will be enough also for the stokes Q, U, and V.

# In CASA
os.system('rm -rf 3c286.cal.StokesQ.clean*')
clean(vis='3c286_SVpol.cal.ms',
      imagename='3c286.cal.StokesQ.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      stokes='Q',
      interactive=T,
      niter=1000)

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


# In CASA
os.system('rm -rf 3c286.cal.StokesU.clean*')
clean(vis='3c286_SVpol.cal.ms',
      imagename='3c286.cal.StokesU.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      stokes='U',
      interactive=T,
      niter=1000)

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


# In CASA
os.system('rm -rf 3c286.cal.StokesV.clean*')
clean(vis='3c286_SVpol.cal.ms',
      imagename='3c286.cal.StokesV.clean',
      cell=['0.1arcsec'],
      imsize=[250,250],
      stokes='V',
      interactive=T,
      niter=1000)

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

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 is not assured, and these data should not be used for scientific purposes.

I Q U
rms 0.08 0.04 0.14
Peak 335 12.3 54
Dyn range 390 288 381

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_SV.POLI')
immath(outfile='3c286_SV.POLI',
       mode='poli',
       imagename=['3c286.cal.StokesQ.clean.image','3c286.cal.StokesU.clean.image'],
       sigma='0.0Jy/beam')


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

The measured rms is 0.14 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 1 mJy/beam.

# In CASA
os.system('rm -rf 3c286_SV.POLA')
immath(outfile='3c286_SV.POLA',
       mode='pola',
       imagename=['3c286.cal.StokesQ.clean.image','3c286.cal.StokesU.clean.image'],
       polithresh='0.5mJy/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_SV.RATIO')
immath(outfile='3c286_SV.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.


This is the only way I found to make a dimensionless ratio image. Is there another way?

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_SV.RATIO', mode='put', hdkey='bunit', hdvalue='')

Image visualization and analysis

Now we can view these various images using viewer. 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 the viewer.

  • Begin by loading the linear polarization image in the viewer:
# In CASA
viewer('3c286_SV.POLI')
  • Next, load the total intensity image as a contour image. In the viewer panel, hit the "Open" icon (the leftmost button in the top row of icons in the viewer). This will bring up a 'Load Data' GUI showing all images and MS in the current directory. Select the total intensity image (3c286.cal.StokesI.clean.image) and click the 'Contour Map' button on the right hand side.
  • Finally, load the polarization position angle image (3c286_SV.POLA) as a vector map.
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.4 mJy/beam (the 5 sigma level in the P image), we paste the expression

     '3c286_SV.POLA'['3c286_SV.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:

CASA<1> calstat=imstat(imagename='3c286_SV.POLI', region='')

CASA<2> calstat
  Out[1]: 
{'blc': array([0, 0, 0, 0], dtype=int32),
 'blcf': '13:31:09.255, +30.30.20.460, Plinear, 2.33e+11Hz',
 'flux': array([ 0.21426499]),
 'max': array([ 0.05525938]),
 'maxpos': array([125, 126,   0,   0], dtype=int32),
 'maxposf': '13:31:08.288, +30.30.33.060, Plinear, 2.33e+11Hz',
 'mean': array([ 0.00018011]),
 'medabsdevmed': array([  5.75154700e-05]),
 'median': array([ 0.0001056]),
 'min': array([  4.06749649e-07]),
 'minpos': array([216,  51,   0,   0], dtype=int32),
 'minposf': '13:31:07.584, +30.30.25.560, Plinear, 2.33e+11Hz',
 'npts': array([ 62500.]),
 'quartile': array([ 0.00012576]),
 'rms': array([ 0.00118729]),
 'sigma': array([ 0.00117356]),
 'sum': array([ 11.25693699]),
 'sumsq': array([ 0.08810332]),
 'trc': array([249, 249,   0,   0], dtype=int32),
 'trcf': '13:31:07.329, +30.30.45.360, Plinear, 2.33e+11Hz'}

CASA <2>: calstat['max'][0]                                   
  Out[2]: 0.055259384214878082

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

# In CASA
fit_res=imfit(imagename='3c286_SV.POLI', region='')
CASA <3>: fit_res
  Out[3]: 
{'converged': array([ True], dtype=bool),
 'deconvolved': {'component0': {'beam': {'beamarcsec': {'major': {'unit': 'arcsec',
                                                                  'value': 0.9374215006828308},
                                                        'minor': {'unit': 'arcsec',
                                                                  'value': 0.4946177303791046},
                                                        'positionangle': {'unit': 'deg',
                                                                          'value': 7.585813522338867}},
                                         'beampixels': 52.537452563810966,
                                         'beamster': 1.2348629044872454e-11},
                                'flux': {'error': array([ 0.00029958,  0.        ,  0.        ,  0.        ]),
                                         'polarisation': 'Stokes',
                                         'unit': 'Jy',
                                         'value': array([ 0.05915491,  0.        ,  0.        ,  0.        ])},
                                'ispoint': False,
                                'label': '',
                                'peak': {'error': 0.0029066691780652316,
                                         'unit': 'Jy/beam',
                                         'value': 1.0303086795033678},
                                'shape': {'direction': {'error': {'latitude': {'unit': 'arcsec',
                                                                               'value': 0.001529344546156995},
                                                                  'longitude': {'unit': 'arcsec',
                                                                                'value': 0.0004948228240940263}},
                                                        'm0': {'unit': 'rad',
                                                               'value': -2.7439276045840715},
                                                        'm1': {'unit': 'rad',
                                                               'value': 0.5324854639759796},
                                                        'refer': 'J2000',
                                                        'type': 'direction'},
                                          'majoraxis': {'unit': 'arcsec',
                                                        'value': 0.18600598434542162},
                                          'majoraxiserror': {'unit': 'arcsec',
                                                             'value': 0.01992867048653363},
                                          'minoraxis': {'unit': 'arcsec',
                                                        'value': 0.1431202657371567},
                                          'minoraxiserror': {'unit': 'arcsec',
                                                             'value': 0.013257769107270834},
                                          'positionangle': {'unit': 'deg',
                                                            'value': 165.61288212682524},
                                          'positionangleerror': {'unit': 'deg',
                                                                 'value': 18.32359492104083},
                                          'type': 'Gaussian'},
                                'spectrum': {'channel': 0,
                                             'frequency': {'m0': {'unit': 'GHz',
                                                                  'value': 233.000102969044},
                                                           'refer': 'LSRK',
                                                           'type': 'frequency'},
                                             'type': 'Constant'},
                                'sum': {'unit': 'Jy/beam',
                                        'value': 1.5916313268244267}},
                 '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 59.1 mJy with an error of 0.3 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 
fluxPI  = sqrt( fluxQ**2 + fluxU**2 )
errorPI = sqrt( (fluxQ*errorU)**2 + (fluxU*errorQ)**2 ) / fluxPI

fluxPImjy = 1000*fluxPI
errPImjy  = 1000*errorPI

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

The results are collected in the following table:

Flux err
I 359 mJy 1.6 mJy
Q 13.26 mJy 0.08 mJy
U 57.6 mJy 0.3 mJy
V 0.0 0.05 mJy
Pol int 59.15 mJy 0.09 mJy
Pol ratio 0.16 0.0008
Pol angle 38.5 deg 0.05 deg

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!).


Last checked on CASA Version 3.0.0 (r9860).