Source
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import ctsys
def write_history(myms, vis, tname, param_names, param_vals, myclog=None, debug=False):
"""
Update vis with the parameters that task tname was called with.
myms - an ms tool instance
vis - the MS to write to.
tname - name of the calling task.
param_names - list of parameter names.
param_vals - list of parameter values (in the same order as param_names).
myclog - a casalog instance (optional)
debug - Turns on debugging print statements on errors if True.
Example:
The end of split does
In python 2.x:
param_names = split.func_code.co_varnames[:split.func_code.co_argcount]
param_vals = [eval(p) for p in param_names] # Must be done in the task.
In python 3.x:
vars = locals( )
param_names = split.__code__.co_varnames[:split.__code__.co_argcount]
param_vals = [vars[p] for p in param_names] # Must be done in the task.
write_history(myms, outputvis, 'split', param_names, param_vals,
casalog),
which appends, e.g.,
vis = 'TWHydra_CO3_2.ms'
outputvis = 'scan9.ms'
datacolumn = 'data'
field = ''
spw = ''
width = 1
antenna = ''
timebin = '0s'
timerange = ''
scan = '9'
intent = ''
array = ''
uvrange = ''
correlation = ''
keepflags = True
to the HISTORY of outputvis.
"""
if not hasattr(myms, 'writehistory'):
if debug:
myclog.post("write_history(myms, %s, %s): myms is not an ms tool" % (vis, tname), 'WARN')
return False
retval = True
isopen = False
try:
if not myclog and hasattr(casalog, 'post'):
myclog = casalog
except Exception:
# There's no logger to complain to, and I don't want to exit
# just because of that.
pass