0.1.26 imfit
Requires:
Synopsis Fit One Elliptical Gaussian Component on an image region(s)
Arguments
|
|
|
|
| Inputs | |
|
| imagename | | Name of the input image
|
| | | allowed: | string |
| | | Default: | |
| box | | Specify one or more box regions for the fit.
|
| | | allowed: | string |
| | | Default: | |
| region | | Image Region or name. Use viewer
|
| | | allowed: | any |
| | | Default: | variant |
| mask | | Mask to be applied to the image
|
| | | allowed: | string |
| | | Default: | |
| fixed | | Pparameters to hold fixed (not implemented).
|
| | | allowed: | any |
| | | Default: | variant |
| usecleanbeam | | Estimate the true source size.
|
| | | allowed: | bool |
| | | Default: | False |
| estfile | | Initial estimate of parameters (Not yet implemented).
|
| | | allowed: | any |
| | | Default: | variant |
| residfile | | Residual image removing fit. (Not yet implemented)
|
| | | allowed: | string |
| | | Default: | |
| |
Returns
void
Example
The task imfit will fit a selected region of an image with one
elliptical Gaussian component. Only one plane (in a spectral cube or
a Stokes Parameter) can be fit in one execution.
The boxing of the desired region is most easily done using the ’box’
parameter. However, use view/region to select one plane or stokes.
The extension to more components with interactive specifications is in
progress and other features are coming.
If usercleanbeam = F, then the fit is made to the image.
If usercleanbeam = T, then the fit is deconvolved by the clean beam
to obtain the estimate of the true component size. You should run it
in both modes to obtain both the image (undeconvolved) and convolved
component size.
imagename -- Input image name.
Default: none; Example: imagename=’ngc5921_task.im’
box -- The box regions in pixels for fitting.
Default: none (whole 2-D plane--dangerous);
Example: box=’10,10,50,50’ or two regions
box = ’10,10,30,30,40,45,55,54’
region -- region file or name.
Use the viewer, then region manager to select regions of
the image to process. Similar to box, but graphical
Or the name of a region stored with the image,
use rg.namesintable()
to retrieve the list of names. This must be used to select
one spectral line lane or one Stokes plane.
Default: none
Example: region=’myimage.im.rgn’
region=’region1’
mask -- Mask expression or file to be applied to image before fitting.
Can be used in place of region. See taskname = ’makemask’
Default: none; Example: mask=’ngc5921_mask’.
fixed -- Select which values to hold fixed and which to solve for.
Not yet implemented
Default: ’’;
Example: fixed=’xf’
Example: fixed=[’x’, ’a’]
Options: f - hold the peak flux (intensity) fixed.
x - hold the X location of the model fixed.
y - hold the Y location of the model fixed.
a - hold the major axis width fixed
b - hold the minor axis width fixed
p - hold the position angle fixed.
usecleanbeam -- Estimate the true source size by deconvolving the
fitted beam with the clean beam
Default: False; Example: usecleanbeam=True
usercleanbeam = F will produce image fit of component
(undeconvolved)
usercleanbeam = T will deconvolve the component with the
cleanbeam if possible.
estfile -- File containing an estimate of the fit
Default: none; Example: estfit=’ngc5921_estimate.im’
Not yet implemented.
residfile -- Output file containing an the residual of the fit
Default: none;
Not yet implemented.
================================
How to Obtain fitted parameters:
1. Store output in a dictionary with an arbitrary name
:
z = imfit( imagename=’cleanedImage.im’, box=’240,240,270,270’ )
2. z.getcomponent(0) will show all values for the fit, note
that they are also shown in the logger
in a nicer format
3. Here is an example of how the results are obtained
flux=z.getcomponent(0)[’flux’][’value’][0]
fluxerr=z.getcomponent(0)[’flux’][’error’][0]
ra = z.getcomponent(0)[’shape’][’direction’][’m0’][’value’]*180.0/3.14159
raerr = z.getcomponent(0)[’shape’][’direction’][’error’][’latitude’][’value’]
dec = z.getcomponent(0)[’shape’][’direction’][’m1’][’value’]*180.0/3.14159
decerr = z.getcomponent(0)[’shape’][’direction’][’error’][’longitude’][’value’]
bmaj = z.getcomponent(0)[’shape’][’majoraxis’][’value’]
etc
EXAMPLES
-------------
A fit done selecting a box region. The box values are, at the
moment, only allowed in pixel values. Boxes are specified with
the following syntax
box=[bottom-left corner (blc), top-left corner(trc)]
In this example the blc=0,10 and trc=50,51
So the coordinates of the 4 corners of the box are:
0,10 0,51 50,10 and 50,51 all in pixels
imfit( imagename=’myImage.im’, box=’0,10,50,51’ )
print ct.torecord()
Fitting in a region specified in a region file that has been
created with the CASA viewer. Do not select the "all axes" nor
the "all channels" option when saving the region file. This task
takes 2-D regions on the sky only. In this example the returned
component tool is used to display there results.
ct = imfit( imagename=’cleanedImage.im’, region=’cleanedImage.rgn’ )
print "Flux: ", ct.getflux(0)
print "Major Axis: ", ct.getshape(0)[’majoraxis’]
print "Spectrum: ", ct.getspectrum(0)
print "Full Fit info:, ct.getshape(0)
Create an estimate using on a point source and use this estimate
when fitting. This is a cumbersome process at the moment, but hope
to make it easier in the future.
This example makes use of the region manager tool, image analysis
tool, and utilities tool. These are all described in the user
reference manual.
The four basic step taken in this example are:
1. read in the region file. It’s assumed that the region file
was created with the CASA viewer’s region manager. The
regionmanager tool is used for this. "rg1" is a Python
dictionary, which is used as input in the image analysis
functions.
2. Create the estimate. Unfortuneatly the only was to create
an estimate in CASA is by using the image analysis tool.
In this example we use the findsources function. The
region from step 1 is used and we also specify a mask to use.
The findsources function returns a .
3. For better or worse the imfit task uses a Python dictionary
which reprsents a component (see component tool for details)
into an XML file. The utils tool is used to do this for us.
rg1 = rg.fromfiletorecord( ’myImage-3.rgn’)
ia.open( ’myImage’)
estimates = ia.findsources( region=rg1, mask=’mask("myImage.mask")’ )
del rg1
ia.done()
ut = utilstool.create()
ut.toxml( input=estimates, asfile=True, filename=’myImage.est’ )
del ut
default(’imfit’)
region=’myImage-3.rgn’
mask=’mask("myImage.mask")’
estfile=’myImage.est’
fixed=[’f’]
go
WARNING: This tool is still under active development. The basics
of the tool are working well, but some of the bonus features
are not. In particular the residfile, usecleanbeam and
fixed parameters are known to have some issues. The peak
values displayed have issues to, the values look suspicious
so do not trust them.
Please send any comments or questions about CASA or AIPS++
to aips2-requests@nrao.edu
Copyright © 2008 Associated Universities Inc.,
Washington, D.C.
This code is available under the terms of the GNU General Public Lincense
Home |
Contact Us |
Directories |
Site Map |
Help |
Privacy Policy |
Search
Updated daily during alpha development.