from __future__ import absolute_import
import os
import shutil
import numpy
import copy
import time
from casatasks.private.casa_transition import *
if is_CASA6:
from casatasks import casalog
from casatasks.private.imagerhelpers.imager_base import PySynthesisImager
from casatasks.private.imagerhelpers.imager_parallel_continuum import PyParallelContSynthesisImager
from casatasks.private.imagerhelpers.imager_parallel_cube import PyParallelCubeSynthesisImager
from casatasks.private.imagerhelpers.input_parameters import ImagerParameters
from .cleanhelper import write_tclean_history, get_func_params
from .sdint_helper import *
from casatools import table
from casatools import synthesisimager,synthesisutils
else:
from taskinit import *
from tasks import *
from imagerhelpers.imager_base import PySynthesisImager
from imagerhelpers.imager_parallel_continuum import PyParallelContSynthesisImager
from imagerhelpers.imager_parallel_cube import PyParallelCubeSynthesisImager
from imagerhelpers.input_parameters import ImagerParameters
from cleanhelper import write_tclean_history, get_func_params
from sdint_helper import *
table=casac.table
synthesisimager=casac.synthesisimager
synthesisutils=casac.synthesisutils
try:
if is_CASA6:
from casampi.MPIEnvironment import MPIEnvironment
from casampi import MPIInterface
else:
from mpi4casa.MPIEnvironment import MPIEnvironment
from mpi4casa import MPIInterface
mpi_available = True
except ImportError:
mpi_available = False
sdintlib = SDINT_helper()
synu = synthesisutils()
def setup_imagerObj(paramList=None):
"""
setup imaging parameters
"""
defaultconstructor = False
if paramList!=None:
if not isinstance(paramList, ImagerParameters):
raise RuntimeError("Internal Error: invalid paramList")
else:
defaultconstructor = True
if defaultconstructor:
return PySynthesisImager
else:
return PySynthesisImager(params=paramList)
def setup_imager(imagename, specmode,calcres,calpsf,inparams):
"""
Setup cube imaging for major cycles.
- Do initialization
- and run a major cycle
"""
locparams = copy.deepcopy(inparams)
locparams['imagename']=imagename
locparams['specmode']='cube'
locparams['niter']=0
locparams['deconvolver']='hogbom'