Source
xxxxxxxxxx
"""
Updated version to support the current JPL-Horizons query results as of 2013 June.
(when S-T-O is requested the current query result returns phi, PAB-LON, PAB-LAT along
with S-T-O value).
casapy functions for converting ASCII ephemerides from JPL-Horizons into
CASA tables and installing them where casapy can find them.
jplfiles_to_repository() puts it all together, so it is most likely the
function you want.
There are various utilities like convert_radec, datestr*, get_num_from_str,
mean_radius*, and construct_tablepath defined in here as well.
"""
from __future__ import absolute_import
from glob import glob
import os
import re
import sys
import scipy.special
import time # We can always use more time.
import numpy
# get is_python3 and is_CASA6
from casatasks.private.casa_transition import *
if is_CASA6:
from casatools import quanta, measures
from casatools import table as tbtool
from casatasks import casalog
_qa = quanta( )
_me = measures( )
else:
from taskinit import gentools, tbtool, qa, casalog
_me = gentools(['me'])[0]
# not really a local tool
_qa = qa
# Possible columns, as announced by their column titles.
# The data is scooped up by 'pat'. Either use ONE group named by the column
# key, or mark it as unwanted. '-' is not valid in group names.
# Leading and trailing whitespace will be taken care of later.
# Sample lines:
# Date__(UT)__HR:MN R.A.___(ICRF/J2000.0)___DEC Ob-lon Ob-lat Sl-lon Sl-lat NP.ang NP.dist r rdot delta deldot S-T-O L_s
# 2010-May-01 00:00 09 01 43.1966 +19 04 28.673 286.52 18.22 246.99 25.34 358.6230 3.44 1.661167637023 -0.5303431 1.28664311447968 15.7195833 37.3033 84.50
#
# some mod to label names and comments so that they corresponds to
# JPL-Horizons naming comvension
cols = {
'MJD': {'header': r'Date__\(UT\)__HR:MN(:)?(\w+)?(\.)?(\w+)?',
'comment': 'date',
'pat': r'(?P<MJD>\d+-\w+-\d+ \d+:\d+)'},
'RA': {'header': r'R.A._+\([^)]+',
'comment': 'Right Ascension',
'pat': r'(?P<RA>(\d+ \d+ )?\d+\.\d+)'}, # require a . for safety
'DEC': {'header': r'\)_+DEC.',
'comment': 'Declination',
'pat': r'(?P<DEC>([-+]?\d+ \d+ )?[-+]?\d+\.\d+)'},
'NP_ang': {'header': r'NP\.ang',
'comment': 'North-Pole pos. angle',
'pat': r'(?P<NP_ang>[0-9.]+|n\.a\.)',
'unit': 'deg'},
'NP_dist': {'header': r'NP\.dist',
'comment': 'North-Pole ang. distance',
'pat': r'(?P<NP_dist>[-+0-9.]+|n\.a\.)',
'unit': 'arcsec'},
'illu': {'header': r'Illu%',
#'comment': 'Illumination',
'comment': 'Illuminated fraction',
'pat': r'(?P<illu>[0-9.]+)',
'unit': r'%'},
# put back to original heading...
# TT: query result header name change (sometime in 2018)
# Ob_lon -> Obsrv_lon, Ob_lat->Obsrv_lat,
# Sl_lon -> Solar-lon, Sl_lat ->Solar-lat
#'DiskLong': {'header': r'Ob-lon',
'DiskLong': {'header': r'Obsrv-lon',
'comment': 'Sub-observer longitude',
# 'pat': r'(?P<Obs_Long>[0-9.]+|n\.a\.)',
'pat': r'(?P<DiskLong>[0-9.]+|n\.a\.)',
'unit': 'deg'},
#'DiskLat': {'header': r'Ob-lat',
'DiskLat': {'header': r'Obsrv-lat',
'comment': 'Sub-observer latitude',
# 'pat': r'(?P<Obs_Lat>[-+0-9.]+|n\.a\.)',
'pat': r'(?P<DiskLat>[-+0-9.]+|n\.a\.)',
'unit': 'deg'},
#'Sl_lon': {'header': r'Sl-lon',
'Sl_lon': {'header': r'Solar-lon',