casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
task_specfit.py
Go to the documentation of this file.
00001 
00002 ##########################################################################
00003 # task_specfit.py
00004 #
00005 # Copyright (C) 2008, 2009
00006 # Associated Universities, Inc. Washington DC, USA.
00007 #
00008 # This script is free software; you can redistribute it and/or modify it
00009 # under the terms of the GNU Library General Public License as published by
00010 # the Free Software Foundation; either version 2 of the License, or (at your
00011 # option) any later version.
00012 #
00013 # This library is distributed in the hope that it will be useful, but WITHOUT
00014 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00016 # License for more details.
00017 #
00018 # You should have received a copy of the GNU Library General Public License
00019 # along with this library; if not, write to the Free Software Foundation,
00020 # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00021 #
00022 # Correspondence concerning AIPS++ should be adressed as follows:
00023 #        Internet email: aips2-request@nrao.edu.
00024 #        Postal address: AIPS++ Project Office
00025 #                        National Radio Astronomy Observatory
00026 #                        520 Edgemont Road
00027 #                        Charlottesville, VA 22903-2475 USA
00028 #
00029 # <author>
00030 # Dave Mehringer
00031 # </author>
00032 #
00033 # <summary>
00034 # Fit 1 dimensional gaussians and/or polynomial
00035 # </summary>
00036 #
00037 # <reviewed reviwer="" date="" tests="" demos="">
00038 # </reviewed>
00039 #
00040 # <prerequisite>
00041 # <ul>
00042 #
00043 # </ul>
00044 # </prerequisite>
00045 #
00046 # <etymology>
00047 # specfit => spec(trum) fit(ter)
00048 # but in general it can be used for any image axis
00049 # </etymology>
00050 #
00051 # <synopsis>
00052 # specfit fits models to 1-d profiles. It is built on top of ia.fitprofile()
00053 # </synopsis> 
00054 #
00055 # <example>
00056 # specfit(imagename="myline.im", ngauss=2, poly=3, model="mymodel.im", multi=true, residual="myresid.im")
00057 #
00058 # </example>
00059 #
00060 # <motivation>
00061 # To make users happy, cf https://bugs.aoc.nrao.edu/browse/CAS-607
00062 # </motivation>
00063 #
00064 
00065 ###########################################################################
00066 from taskinit import *
00067 
00068 def specfit(
00069         imagename=None, box=None, region=None, chans=None,
00070         stokes=None, axis=None, mask=None, ngauss=None,
00071         poly=None, estimates=None, minpts=None, multifit=None,
00072         model=None, residual=None, amp=None, amperr=None,
00073         center=None, centererr=None, fwhm=None, fwhmerr=None,
00074         integral=None, integralerr=None, wantreturn=None,
00075         stretch=None, logresults=None, pampest=None,
00076         pcenterest=None, pfwhmest=None, pfix=None,
00077         gmncomps=None, gmampcon=None, gmcentercon=None,
00078     gmfwhmcon=None, gmampest=None, gmcenterest=None,
00079     gmfwhmest=None, gmfix=None, logfile=None, append=None,
00080     pfunc=None, goodamprange=None, goodcenterrange=None,
00081     goodfwhmrange=None, sigma=None, outsigma=None
00082 ):
00083     casalog.origin('specfit')
00084     retval = None
00085     myia = iatool()
00086     try:
00087         if (not myia.open(imagename)):
00088             raise Exception, "Cannot create image analysis tool using " + imagename
00089         retval = myia.fitprofile(
00090                         box=box, region=region, chans=chans,
00091                         stokes=stokes, axis=axis, mask=mask,
00092                         ngauss=ngauss, poly=poly,
00093                         estimates=estimates, minpts=minpts,
00094                         multifit=multifit, model=model,
00095                         residual=residual, amp=amp, amperr=amperr,
00096                         center=center, centererr=centererr,
00097                         fwhm=fwhm, fwhmerr=fwhmerr,
00098                         integral=integral, integralerr=integralerr,
00099                         stretch=stretch, logresults=logresults,
00100                         pampest=pampest, pcenterest=pcenterest,
00101                         pfwhmest=pfwhmest, pfix=pfix,
00102                         gmncomps=gmncomps, gmampcon=gmampcon,
00103                         gmcentercon=gmcentercon, gmfwhmcon=gmfwhmcon,
00104                         gmampest=gmampest, gmcenterest=gmcenterest,
00105                         gmfwhmest=gmfwhmest, gmfix=gmfix, logfile=logfile,
00106                         append=append, pfunc=pfunc, goodamprange=goodamprange,
00107                         goodcenterrange=goodcenterrange, goodfwhmrange=goodfwhmrange,
00108                         sigma=sigma, outsigma=outsigma
00109                 )
00110     except Exception, instance:
00111         casalog.post( str( '*** Error ***') + str(instance), 'SEVERE')
00112         retval = None
00113     myia.done()
00114     if (wantreturn):
00115         return retval
00116     else:
00117         if (retval):
00118            del retval
00119         return None
00120 
00121 
00122