Source
casalog.post('Conversion in situ was not possible. Restoring original ephemeris ...', 'INFO')
import glob
import os
from casatools import table, measures, quanta, ms
from casatasks import casalog
# Conversion of TOPO ephemerides to GEO (ICRS)
#
# Example:
# import recipes.ephemerides.convertephem as ce
# ce.convert2geo('titan.ms', 'Titan')
#
# will find the ephemeris attached to field "Titan" in the MS "titan.ms"
# and convert RA, Dec, and RadVel to the geocentric ref frame (ICRS)
def converttopoephem2geo(tablename='', outtablename='', overwrite=True):
"""
converttopoephem2geo
Convert the given topo ephemeris table to the geocentric ref frame.
Converted are the RA, DEC, and RadVel columns only
tablename -- name of the TOPO frame ephemeris table (in canonical CASA format)
outtablename -- name of the output GEO frame ephemeris table
"""
if type(tablename)!=str or tablename=='':
casalog.post('Invalid parameter tablename', 'WARN')
return False
if type(outtablename)!=str or outtablename=='':
casalog.post('Invalid parameter outtablename', 'WARN')
return False
#convert RA, DEC, and RadVel
tbt = table()
met = measures()
qat = quanta()
tbt.open(tablename)
ra = tbt.getcol('RA')
dec = tbt.getcol('DEC')
radvel = tbt.getcol('RadVel')
radvelunit = 'km/s'
tmpkw = tbt.getcolkeywords('RadVel')
if 'UNIT' in tmpkw:
radvelunit = tmpkw['UNIT']
elif 'QuantumUnits' in tmpkw:
radvelunit = tmpkw['QuantumUnits'][0]
else:
casalog.post('Cannot determine units of radial velocity column. Assuming km/s.', 'WARN')
mjd = tbt.getcol('MJD')
kw = tbt.getkeywords()
tbt.close()
geodist = kw['GeoDist'] # (km above reference ellipsoid)
geolat = kw['GeoLat'] # (deg)
geolong = kw['GeoLong'] # (deg)