Source
from __future__ import absolute_import
import os
import re
import glob
import pylab as pl
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import table, image, imager
from casatasks import casalog, sdimaging, imregrid, immath, concat, feather
from . import sdbeamutil
from .simutil import *
tb = table( )
ia = image( )
im = imager( )
else:
from taskinit import *
from simutil import *
from sdimaging import sdimaging
from imregrid import imregrid
from immath import immath
from concat import concat
from feather import feather
import sdbeamutil
from casa_stack_manip import stack_frame_find
# the global tb, ia, and im tools are used
def simanalyze(
project=None,
image=None,
# if image==False:
imagename=None,
skymodel=None,
# else:
vis=None, modelimage=None, imsize=None, imdirection=None, cell=None,
interactive=None, niter=None, threshold=None,
weighting=None, mask=None, outertaper=None, pbcor=None, stokes=None,
featherimage=None,
# endif
analyze=None,
showuv=None, showpsf=None, showmodel=None,
showconvolved=None, showclean=None, showresidual=None, showdifference=None,
showfidelity=None,
graphics=None,
verbose=None,
overwrite=None,
dryrun=False,
logfile=None
):
#def simanalyze(project='sim', image=True, imagename='default', skymodel='', vis='default', modelimage='', imsize=[128, 128], imdirection='', cell='', interactive=False, niter=0, threshold='0.1mJy', weighting='natural', mask=[], outertaper=[''], stokes='I', featherimage='', analyze=False, showuv=True, showpsf=True, showmodel=True, showconvolved=False, showclean=True, showresidual=False, showdifference=True, showfidelity=True, graphics='both', verbose=False, overwrite=True, dryrun=False):
# Collect a list of parameter values to save inputs
in_params = locals()
casalog.origin('simanalyze')
if verbose: casalog.filter(level="DEBUG2")
if not is_CASA6:
myf = stack_frame_find( )
# create the utility object:
myutil = simutil()
if logfile:
myutil.reportfile=logfile
myutil.openreport()
if verbose: myutil.verbose = True
msg = myutil.msg
# put output in directory called "project"
fileroot = project
if not os.path.exists(fileroot):
msg(fileroot+" directory doesn't exist - the task expects to find results from creating the datasets there, like the skymodel.",priority="error")
# msg should raise an exception for priority=error
if not is_CASA6:
saveinputs = myf['saveinputs']
saveinputs('simanalyze',fileroot+"/"+project+".simanalyze.last")
# myparams=in_params)
else:
casalog.post("saveinputs not available in casatasks, skipping saving simanalyze inputs", priority='INFO')
if (not image) and (not analyze):
casalog.post("No operation to be done. Exiting from task.", "WARN")
return True
grscreen = False