from __future__ import absolute_import
from casatasks.private.casa_transition import is_CASA6
from casatools import table as tbtool
from casatasks import casalog
def concatephem(ephems=[], outputephem=''):
Concatenate the given ephemeris tables into a single output table
filling gaps with dummy rows and removing overlap rows.
Before concatenation, test that basic conditions are fulfilled:
same time grid, list of input ephemerides is ordered in time.
ephems - List of the ephemeris tables to be concatenated
outputephem - Name of the output ephemeris to be created from the concatenation
If empty, concatephem will only perform a dryrun.
hasoverlap_with_previous = []
shouldconcat_with_previous = []
canconcat_with_previous = []
stepsize_rel_tolerance = 1E-6
stepsize_abs_tolerance_d = 0.1/86400.
casalog.post('Ephemeris '+myephem+' has no rows.', 'SEVERE')
mystart = mytb.getcell('MJD',0)
myend = mytb.getcell('MJD', mynrows-1)
casalog.post('Ephemeris '+myephem+' has only one row.', 'WARN')
mystepsize = mytb.getcell('MJD',1) - mystart
stepsizes.append(mystepsize)
if os.path.exists(outputephem):
casalog.post('Output ephemeris table '+outputephem+' exists already.', 'SEVERE')
casalog.post('Ephem no., startMJD, endMJD, step size (d)', 'INFO')
for i in range(0,len(starts)):
casalog.post(str(i)+', '+str(starts[i])+', '+str(ends[i])+', '+str(stepsizes[i]), 'INFO')
for i in range(0,len(starts)):
shouldconcat_with_previous.append(False)
canconcat_with_previous.append(False)
hasoverlap_with_previous.append(False)
gap_to_previous.append(0)
if (abs(stepsizes[i] - stepsizes[i-1-backstep])/stepsizes[i] < stepsize_rel_tolerance) \
and abs(stepsizes[i] - stepsizes[i-1-backstep]) < stepsize_abs_tolerance_d:
casalog.post( 'Ephemerides '+str(i-1-backstep)+' and '+str(i)+' have same step size.', 'INFO')
if starts[i-1-backstep] <= starts[i]:
casalog.post( 'Ephemeris '+str(i-1-backstep)+' begins before '+str(i), 'INFO')
if ends[i-1-backstep] < ends[i]:
casalog.post( 'Ephemeris '+str(i-1-backstep)+' ends before '+str(i), 'INFO')
shouldconcat_with_previous[i] = True