casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
task_imcollapse.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 to collapse an image along a specified axis,
00035 # computing a specified aggregate function of pixels along that axis
00036 # </summary>
00037 #
00038 # <reviewed reviwer="" date="" tests="" demos="">
00039 # </reviewed>
00040 #
00041 # <prerequisite>
00042 # <ul>
00043 #
00044 # </ul>
00045 # </prerequisite>
00046 #
00047 # <etymology>
00048 # imtrans => im(age) collapse
00049 # </etymology>
00050 #
00051 # <synopsis>
00052 # imtrans collapses an image along a specified axis. It is built on top of ia.collapse()
00053 # </synopsis> 
00054 #
00055 # <example>
00056 # collapsed_image_tool = imcollapse(imagename="myim.im", outfile="collapsed.im", axis=2, function="variance", wantreturn=true)
00057 #
00058 # </example>
00059 #
00060 # <motivation>
00061 # To make users happy (https://bugs.aoc.nrao.edu/browse/CAS-1222)
00062 # and associated casacore class is prereq for specfit work
00063 # </motivation>
00064 #
00065 
00066 ###########################################################################
00067 from taskinit import *
00068 
00069 def imcollapse(
00070     imagename=None, function=None, axes=None, outfile=None, box=None,
00071     region=None, chans=None, stokes=None, mask=None, wantreturn=None,
00072     overwrite=None, stretch=None
00073 ):
00074     casalog.origin('imcollapse')
00075     retval = None
00076     myia = iatool()
00077     try:
00078         if (not myia.open(imagename)):
00079             raise Exception, "Cannot create image analysis tool using " + imagename
00080         ia_tool = myia.collapse(
00081             function, axes, outfile, region, box, chans,
00082             stokes, mask, overwrite, stretch
00083         )
00084         if wantreturn:
00085             retval = ia_tool
00086         else:
00087             ia_tool.done()
00088     except Exception, instance:
00089         casalog.post( str( '*** Error ***') + str(instance), 'SEVERE')
00090     if (myia):
00091         myia.done()
00092     return retval