Source
ss_setjy.solar_system_fd(source_name=src, MJDs=mjds, frequencies=infreqs, observatory=observatory, casalog=self._casalog)
# setjy helper functions
import os
import sys
import shutil
import numpy
from casatasks import casalog as default_casalog
from casatools import quanta, ms, table, componentlist, measures, calibrater, msmetadata
from collections import OrderedDict as odict
class ss_setjy_helper:
def __init__(self,imtool, vis, casalog=None):
self.im = imtool
self.vis = vis
if not casalog:
casalog = default_casalog
self._casalog = casalog
def setSolarObjectJy(self,field,spw,scalebychan, timerange,observation, scan, intent, useephemdir, usescratch=False):
"""
Set flux density of a solar system object using Bryan Butler's new
python model calculation code.
A single time stamp (first time stamp of MS after selections are applied) is
currently used per execution. For flux observation done in a long time span
may need to run multiple setjy with selections by time range (or scans).
"""
#retval = True
output = {}
cleanupcomps = True # leave generated cl files
qa = quanta()
myms = ms( )
mytb = table( )
mycl = componentlist( )
myme = measures( )
mycb = calibrater( )
mymsmd = msmetadata( )
# prepare parameters need to pass to the Bryan's code
# make ms selections
# get source name
# get time ranges
# get spwused and get frequency ranges
sel={}
sel['field']=field
sel['spw']=spw
sel['timerange']=timerange
sel['observation']=str(observation)
sel['scan']=scan
sel['scanintent']=intent
measframes=['REST','LSRK','LSRD','BARY','GEO','TOPO','GALACTO','LGROUP','CMB']
myms.open(self.vis)
myms.msselect(sel,False)
scansummary=myms.getscansummary()
nscan=len(scansummary.keys())
selectedids=myms.msselectedindices()
fieldids=selectedids['field']
obsids=selectedids['observationid']
myms.close()
mytb.open(os.path.join(self.vis,'OBSERVATION'))
if len(obsids)==0:
getrow=0
else:
getrow=obsids[0]
observatory=mytb.getcell('TELESCOPE_NAME',getrow)
mytb.close()
mytb.open(os.path.join(self.vis,'FIELD'))
colnames = mytb.colnames()
if len(fieldids)==0:
fieldids = range(mytb.nrows())
# frame reference for field position
phdir_info=mytb.getcolkeyword("PHASE_DIR","MEASINFO")
if 'Ref' in phdir_info:
fieldref=phdir_info['Ref']
elif 'TabRefTypes' in phdir_info:
colnames=mytb.colnames()
for col in colnames:
if col=='PhaseDir_Ref':
fieldrefind=mytb.getcell(col,fieldids[0])
fieldref=phdir_info['TabRefTypes'][fieldrefind]
else:
fieldref=''
srcnames={}
fielddirs={}
ftimes={}
ephemid={}
for fid in fieldids: