########################################################################
#
#TASK XML> tclean -argfilter=interactive,fullsummary,outlierfile
# Copyright (C) 2024
# Associated Universities, Inc. Washington DC, USA.
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
#
# Correspondence concerning AIPS++ should be adressed as follows:
#        Internet email: aips2-request@nrao.edu.
#        Postal address: AIPS++ Project Office
#                        National Radio Astronomy Observatory
#                        520 Edgemont Road
#                        Charlottesville, VA 22903-2475 USA
#
########################################################################
##################### generated by xml-casa (v2) from {{name}}.xml
##################### {{md5}} ##############################
from __future__ import absolute_import
import numpy
from casatools.typecheck import CasaValidator as _val_ctor
_pc = _val_ctor( )
from casatools.coercetype import coerce as _coerce
from casatools.errors import create_error_string
from casatasks.private.task_logging import start_log as _start_log
from casatasks.private.task_logging import end_log as _end_log
from casatasks.private.task_logging import except_log as _except_log
from ...apps import InteractiveClean

def _iclean_t( *args, **kwargs ):
    ic = InteractiveClean( *args, **kwargs )
    return ic( )

class _iclean:
    """
{{docstring}}
    """

    _info_group_ = """{{group}}"""
    _info_desc_ = """{{desc}}"""

    def __call__( self, {{params}} ):
        schema = { {{# paramListNKW}}'{{name}}': {{schema}}, {{/ paramListNKW}} }
        doc = { {{# paramListNKW}}'{{name}}': {{name}}, {{/ paramListNKW}} }
        assert _pc.validate(doc,schema), create_error_string(_pc.errors)
        _logging_state_ = _start_log( 'iclean', [ {{# paramListNKW}}'{{name}}=' + repr(_pc.document['{{name}}']), {{/ paramListNKW}} ] )
        task_result = None
        try:
            task_result = _iclean_t( {{# paramListNKW}}{{name}}=_pc.document['{{name}}'], {{/ paramListNKW}} )
        except Exception as exc:
            _except_log('iclean', exc)
            raise
        finally:
            task_result = _end_log( _logging_state_, 'iclean', task_result )
        return task_result

iclean = _iclean( )
