Source
raise ValueError("fluxtable %s exists. Please specify a different name. Or set append=True, to append the results to the table." % fluxtable)
from __future__ import absolute_import
import os
# get is_CASA6 and is_python3
from casatasks.private.casa_transition import *
if is_CASA6:
from casatools import calibrater, ms
from casatasks import casalog
from .mstools import write_history
else:
from taskinit import *
from mstools import write_history
calibrater = cbtool
ms = mstool
def writeResultsHistory(myms, vis, mycasalog, indict):
"""
write returned output of fluxscale to HISTORY subtable of the parent ms
"""
isOpen = False
try:
myms.open(vis)
isOpen = True
mainkeys = indict.keys()
spwids = indict['spwID']
freqs = indict['freq']
msg0 = "Fluxscale results *****"
myms.writehistory(message=msg0, origin='fluxscale')
for ky in mainkeys:
try:
fieldid = int(ky)
except:
fieldid = None
if fieldid!=None:
fdict = indict[ky]
fname = fdict['fieldName']
fitF = fdict['fitFluxd']
fitFerr = fdict['fitFluxdErr']
fitRefFreq = fdict['fitRefFreq']
spix = fdict['spidx']
spixerr = fdict['spidxerr']
msg1 = fname+"(field id="+ky+") "
myms.writehistory(message=msg1, origin='fluxscale')
for ispw in spwids:
strspw = str(ispw)
spwfdict = fdict[strspw]
flux = spwfdict['fluxd']
fluxerr = spwfdict['fluxdErr']
freq = freqs[ispw]
fvalbase = 1.0
funit=''
if freq>1.e9:
fvalbase = 1.e9
funit = 'GHz'
elif freq>1.e6:
fvalbase = 1.e6
funit = 'MHz'
elif freq>1.e3:
fvalbase = 1.e3
funit = 'kHz'