# Source code for casatools.linearmosaic

```
#
# stub class definition file for docstring parsing
#
[docs]class linearmosaic:
"""
combining images in a weighted fashion
The ``linearmosaic`` tool (``lm``) provides a toolkit for stitching images in a weighted fashion.
The default linear mosaic equation is defined by Equation (6) in Cornwell, Holdaway et al (Astronomy and Astrophysics, Vol. 271, p. 697 (1993)).
.. math:: I^{lm}(\theta)={{\sum\_p A\_p(\theta)(I\_p(\theta)A\_p(\theta))w\_p}\over{\sum\_p A\_p^2(\theta)w\_p}}
where :math:`A\_p(\theta)` is the primary beam (PB) of a given pointing :math:`p`, :math:`w\_p` is a sensitivity weight and the image of that pointing is :math:`I\_p(\theta)`; the linear mosaic being :math:`I^{lm}(\theta)`
"""
[docs] def defineoutputimage(self, nx=128, ny=-1, cellx='1.0', celly='', imagecenter='0', outputimage='', outputweight=''):
"""
Define the direction axes output image parameters. The output image will get the same number of spectral and polarization planes as the input images. This function create a fresh new output image. If an image of the same name exist on disk it will be erased. The spectral and polarization part of the image will be identical to the images that are being mosaiced.
The output image will by default be flux correct and the weight image will be :math:`{\sum\_p A\_p^2(\theta)}` where the primary beam is :math:`A\_p(\theta)`
.. rubric:: Parameters
- ``nx (int=128)`` - Total number of spatial pixels in x
- ``ny (int=-1)`` - Total number of spatial pixels in y
- ``cellx (variant='1.0')`` - Cellsize in x (e.g. '1arcsec')
- ``celly (variant='')`` - Cellsize in y (e.g. '1arcsec')
- ``imagecenter (variant='0')`` - Direction of phase center as a diretion measure
- ``outputimage (string='')`` - output image name
- ``outputweight (string='')`` - output weight image name
.. rubric:: Returns
``bool``
.. rubric:: Examples
::
lm.defineoutputimage(nx=3000, cellx='3arcsec', imagecenter='19h13m13.469 4d50m09.649', outputimage='test.linmos', outputweight='test.weightlinmos')
"""
pass
[docs] def setoutputimage(self, outputimage='', outputweight='', imageweighttype=1, weighttype=1):
"""
Use this function if the mosaicing is to be done onto a previous mosaic or image. For now the stokes and spectral characteristic of the images to be mosaic and the output image has to be similar (i.e the user has to regrid them prior to linearmosaic if necessary). The weightimage represents the sensitivity image of the image (for example the weighted primary beam coverage of a mosaic)
``imageweighttype`` parameter:
If the image is of the type that has been normalized to be flux correct then the imageweighttype should 0. If the image has been apodized by a primary beam then imageweighttype should be 1 and if the image is multiplied by :math:`PB^2` then it should be 2.
``weighttype`` parameter: This should be 1 if the weight image is the sum of Primary beams or equivalent and it should be 2 if it is the sum of of :math:`PB^2`
.. rubric:: Parameters
- ``outputimage (string='')`` - Existing mosaic imagename
- ``outputweight (string='')`` - Existing weight image for mosaic
- ``imageweighttype (int=1)`` - what kind of weight was already applied to image \n 0: flux correct \n 1: Primary beam equivalent weight \n 2: $PB^2$ equivalent weight \n
- ``weighttype (int=1)`` - what kind of weight is weight image \n 1: Primary beam equivalent weight \n 2: $PB^2$ equivalent \n
.. rubric:: Returns
``bool``
.. rubric:: Examples
::
lm.setoutputimage(outputimage='testoo.linmos', outputweight='testoo.linmos.weight', imageweightype=0, weighttype=2)
"""
pass
[docs] def saultweightimage(self, outputimage='', fracpeak=0.1):
"""
"Sault weighted" image is one which is more pleasant to view (without high noise at the edges of mosaic images), it is flux correct upto a where the beam coverage becomes low and is tapered off onwards just to keep the noise from rising in the overall image(see Eq[2] from Sault, Staveley-Smith and Brouw (1996), Astron. Astrophys. Suppl, 120, 375)
.. rubric:: Parameters
- ``outputimage (string='')`` - Name of image to create the Sault-Weighted image
- ``fracpeak (double=0.1)`` - Upto what fraction of peak of coverage should the image be flux correct
.. rubric:: Returns
``bool``
.. rubric:: Examples
::
lm.defineoutputimage(nx=3000, cellx='3arcsec', imagecenter='19h13m13.469 4d50m09.649', outputimage='test.linmos')
lm.makemosaic(images=['FIELD_31/img.image', 'FIELD_33/img.image'], weightimages=['FIELD_31/img.pb', 'FIELD_33/img.pb'])
###the above will make a flux correct mosaic of the 2 images in a flux correct fashion in test.linmos
#Now make a Sault weighted image to use in the viewer
lm.saultweightimage('test_sault.linmos')
"""
pass
[docs] def setlinmostype(self, linmostype='optimal'):
"""
Use this function if the mosaicing is to be done using a non optimal weighting mode.
For now ``optimal`` (which is the default) follows this equation
.. math:: I^{lm}(\theta)={{\sum\_p A\_p(\theta)(I\_p(\theta)A\_p(\theta))w\_p}\over{\sum\_p A\_p^2(\theta)w\_p}}
And ``pbweight`` follows this one
.. math:: I^{lm}(\theta)={{\sum\_p (I\_p(\theta)A\_p(\theta))w\_p}\over{\sum\_p A\_p(\theta)w\_p}}
where :math:`A\_p(\theta)` is the primary beam (PB) of a given pointing :math:`p`, :math:`w\_p` is a sensitivity weight and the image of that pointing is :math:`I\_p(\theta)`; the linear mosaic being :math:`I^{lm}(\theta)` For now :math:`w\_p=1`
.. rubric:: Parameters
- ``linmostype (string='optimal')`` - Type of weighting for linear mosaic
.. rubric:: Returns
``bool``
"""
pass
[docs] def makemosaic(self, images='', weightimages='', imageweighttype=1, weighttype=1):
"""
Put the list of images onto the mosaic image using the weight images
.. rubric:: Parameters
- ``images (variant='')`` - Name of images to mosaic
- ``weightimages (variant='')`` - Name of images to mosaic
- ``imageweighttype (int=1)`` - what kind of weight is already applied to image \n 0: flux correct \n 1: Primary beam equivalent weight \n 2: PB^2 equivalent \n
- ``weighttype (int=1)`` - what kind of weight image it is \n 1: Primary beam equivalent weight \n 2: PB^2 equivalent \n
.. rubric:: Returns
``bool``
.. rubric:: Examples
::
lm.defineoutputimage(nx=3000, cellx='3arcsec', imagecenter='19h13m13.469 4d50m09.649', outputimage='test.linmos')
###make a mosaic of two fields
lm.makemosaic(images=['FIELD_31/img.image', 'FIELD_33/img.image'], weightimages=['FIELD_31/img.pb', 'FIELD_33/img.pb'])
####now we have another submosaic (which is flux corrected) we want to add to this mosaic
lm.makemosaic(images='submosaic.image', weightimages='submosaic.flux', imageweighttype=0, weighttype=1)
"""
pass
```