casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
task_impbcor.py
Go to the documentation of this file.
00001 
00002 ##########################################################################
00003 # task_imcollapse.py
00004 #
00005 # Copyright (C) 2008, 2009, 2010
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 # Task correct an image for primary beam attenuation.
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 # impbcor => im(age) pb(primary beam) cor(rect)
00048 # </etymology>
00049 #
00050 # <synopsis>
00051 # impbcor corrects and image for primary beam attenuation. It is built on top of ia.pbcor()
00052 # </synopsis> 
00053 #
00054 # <example>
00055 # pbcorrected_image_tool = impbcor(imagename="myim.im", pbimage="mypb.im", outfile="corrected.im", wantreturn=true)
00056 #
00057 # </example>
00058 #
00059 # <motivation>
00060 # https://bugs.aoc.nrao.edu/browse/CAS-3256
00061 # </motivation>
00062 #
00063 
00064 ###########################################################################
00065 from taskinit import *
00066 
00067 def impbcor(
00068     imagename=None, pbimage=None, outfile=None, overwrite=None,
00069     box=None, region=None, chans=None, stokes=None, mask=None,
00070     mode=None, cutoff=None, wantreturn=None, stretch=None
00071 ):
00072     casalog.origin('impbcor')
00073     retval = None
00074     myia = iatool()
00075     try:
00076         if (not myia.open(imagename)):
00077             raise Exception, "Cannot create image analysis tool using " + imagename
00078         ia_tool = myia.pbcor(
00079             pbimage=pbimage, outfile=outfile, overwrite=overwrite,
00080             box=box, region=region, chans=chans, stokes=stokes,
00081             mask=mask, mode=mode, cutoff=cutoff, stretch=stretch
00082         )
00083         if wantreturn:
00084             retval = ia_tool
00085         else:
00086             ia_tool.done()
00087             del ia_tool
00088     except Exception, instance:
00089         casalog.post( str( '*** Error ***') + str(instance), 'SEVERE')
00090     if (myia):
00091         myia.done()
00092         del myia
00093     return retval