from __future__ import absolute_import
from casatasks.private.casa_transition import *
from casatools import image, regionmanager
from casatasks import casalog
from .ialib import write_image_history
from ialib import write_image_history
imagename, linefile, contfile, fitorder,
region, box, chans, stokes
casalog.origin('imcontsub')
if ( len( linefile ) > 0 ):
if ( os.path.exists( linefile ) ):
raise ValueError('Error: file ' + linefile
+' already exists, please delete before continuing.',\
casalog.post("The linefile parameter is empty, consequently the"
+" spectral line image will NOT be\nsaved on disk.", \
if ( len( contfile ) > 0 ):
if ( os.path.exists( contfile ) ):
raise ValueError('Error: Unable to continue file '+contfile\
+' already exists, please delete before continuing.')
casalog.post("The contfile parameter is empty, consequently the"
+" continuum image will NOT be\nsaved on disk.", \
mycsys = _myia.coordsys()
if isinstance(box, list):
box = ', '.join([str(b) for b in box])
csys=mycsys.torecord(), shape=_myia.shape(),
box=box, stokes=stokes, stokescontrol="f",
if chans != None and len(chans) > 0:
channels = myrg.selectedchannels(chans, _myia.shape())
lineim = _myia.continuumsub(
outline=linefile, outcont=contfile, region=reg,
channels=channels, fitorder=fitorder,
raise Exception("ia.continuumsub did not complete successfully")
param_names = imcontsub.__code__.co_varnames[:imcontsub.__code__.co_argcount]
param_vals = [vars[p] for p in param_names]
param_vals = [eval(p) for p in param_names]
for x in [lineim, contfile]:
x, sys._getframe().f_code.co_name,
param_names, param_vals, casalog
except Exception as instance:
casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN')