Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/local/bin/python # encoding: utf-8 *Generate Ephemerides using the `ephem` command from the Orbfit5.0 fork*
:Author: David Young
:Date Created: September 28, 2017 """ ################# GLOBAL IMPORTS ####################
cmd): """generate one orbfit ephemeris
**Key Arguments:** - ``cmd`` -- the command to execute [cmd, object]
**Return:** - ``results`` -- the single ephemeris results """ results = [] for c in cmd: p = Popen(c[0], stdout=PIPE, stderr=PIPE, shell=True) stdout, stderr = p.communicate()
if len(stderr) and len(stderr.split()) != 15: print stderr, len(stderr.split()) return None elif "!!WARNING! WARNING! WARNING! WARNING!!" in stdout: print "%(stdout)s was not found in astorb.dat" % locals() return None
# SPLIT RESULTS INTO LIST OF DICTIONARIES r = stdout.strip().split("\n") keys = r[0].strip().split(',') lines = r[1:] for l in lines: # CREATE DICTIONARY FROM KEYS AND VALUES values = l.strip().split(',') for k, v in zip(keys, values): v = v.strip().replace("/", "") try: v = float(v) except: pass result = dict(zip(keys, values)) result["object_name"] = c[1] results.append(result) return results
log, objectId, mjd, settings, obscode=500, verbose=False, astorbPath=False): """Given a known solar-system object ID (human-readable name or MPC number but *NOT* an MPC packed format) or list of names and one or more specific epochs, return the calculated ephemerides
**Key Arguments:** - ``log`` -- logger - ``objectId`` -- human-readable name, MPC number or solar-system object name, or list of names - ``mjd`` -- a single MJD, or a list MJDs to generate an ephemeris for - ``settings`` -- the settings dictionary for rockfinder - ``obscode`` -- the observatory code for the ephemeris generation. Default **500** (geocentric) - ``verbose`` -- return extra information with each ephemeris - ``astorbPath`` -- override the default path to astorb.dat orbital elements file
**Return:** - ``resultList`` -- a list of ordered dictionaries containing the returned ephemerides
**Usage:**
To generate a an ephemeris for a single epoch run,using ATLAS Haleakala as your observatory:
.. code-block:: python
from rockfinder import orbfit_ephemeris eph = orbfit_ephemeris( log=log, objectId=1, obscode="T05" mjd=57916., )
or to generate an ephemeris for multiple epochs:
.. code-block:: python
from rockfinder import orbfit_ephemeris eph = orbfit_ephemeris( log=log, objectId="ceres", mjd=[57916.1,57917.234,57956.34523] verbose=True )
Note by passing `verbose=True` the essential ephemeris data is supplimented with some extra data
It's also possible to pass in an array of object IDs:
.. code-block:: python
from rockfinder import orbfit_ephemeris eph = orbfit_ephemeris( log=log, objectId=[1,5,03547,"Shikoku"], mjd=[57916.1,57917.234,57956.34523] )
And finally you override the default path to astorb.dat orbital elements file by passing in a custom path (useful for passing in a trimmed orbital elements database):
.. code-block:: python
from rockfinder import orbfit_ephemeris eph = orbfit_ephemeris( log=log, objectId=[1,5,03547,"Shikoku"], mjd=[57916.1,57917.234,57956.34523], astorbPath="/path/to/astorb.dat" )
"""
# MAKE SURE MJDs ARE IN A LIST else: mjdList = mjd
objectList = [objectId] else:
cmd = """%(ephem)s %(obscode)s %(m)s "%(o)s" """ % locals() else:
cmd += " '%(astorbPath)s'" % locals()
"""Yield successive n-sized chunks from l."""
# BATCH INTO 10s
# DEFINE AN INPUT ARRAY inputArray=cmdList)
"phase_angle", "obscode", "sun_obs_target_angle", "galactic_latitude", "ra_arcsec_per_hour", "dec_arcsec_per_hour"] else: order = ["object_name", "mjd", "ra_deg", "dec_deg", "apparent_mag", "observer_distance", "heliocentric_distance", "phase_angle"]
# ORDER THE RESULTS continue
# xt-class-method |