def compute_asteroid(name, data, t, precision_radec=15, precision_azalt=120):
    R2D = 180. / pi
    o = ephem.city('Atlanta')
    o.date = t
    target = ephem.EllipticalBody()
    target._inc = data['i']
    target._Om = data['Node']
    target._om = data['Peri']
    target._a = data['a']
    target._M = data['M']
    target._epoch_M = data['Epoch'] - 2415020.0
    target._e = data['e']
    target._epoch = '2000'
    target.compute(o)
    # Pyephem use Dublin JD, ephemeride uses Modified JD!
    mjd = o.date + 15020 - 0.5
    return dict(
        name=name,
        planet=0,
        utc=mjd,
        longitude=o.lon * R2D,
        latitude=o.lat * R2D,
        ra=target.ra * R2D,
        dec=target.dec * R2D,
        alt=target.alt * R2D,
        az=target.az * R2D,
        precision_radec=precision_radec,
        precision_azalt=precision_azalt,
        klass='mpc_asteroid',
        json=dict(model_data=data),
    )
Beispiel #2
0
def _kbos_from_survey_sym_model_input_file(model_file):
    """
    Load a Survey Simulator model file as an array of ephem EllipticalBody objects.
    @param model_file:
    @return:
    """
    lines = storage.open_vos_or_local(model_file).read().split('\n')
    kbos = []
    for line in lines:
        if len(line) == 0 or line[
                0] == '#':  # skip initial column descriptors and the final blank line
            continue
        kbo = ephem.EllipticalBody()
        values = line.split()
        kbo.name = values[8]
        kbo.j = values[9]
        kbo.k = values[10]
        kbo._a = float(values[0])
        kbo._e = float(values[1])
        kbo._inc = float(values[2])
        kbo._Om = float(values[3])
        kbo._om = float(values[4])
        kbo._M = float(values[5])
        kbo._H = float(values[6])
        epoch = ephem.date(2453157.50000 - ephem.julian_date(0))
        kbo._epoch_M = epoch
        kbo._epoch = epoch
        kbos.append(kbo)
    return kbos
Beispiel #3
0
def get_pyephem_instance_for_type(target):
    """
    Constructs a pyephem body corresponding to the proper object type
    in order to perform positional calculations for the target

    :returns: FixedBody or EllipticalBody

    :raises Exception: When a target type other than sidereal or non-sidereal is supplied

    """
    if target.type == target.SIDEREAL:
        body = ephem.FixedBody()
        body._ra = Angle(str(target.ra) + 'd').to_string(unit=units.hourangle, sep=':')
        body._dec = Angle(str(target.dec) + 'd').to_string(unit=units.degree, sep=':')
        body._epoch = target.epoch if target.epoch else ephem.Date(DEFAULT_VALUES['epoch'])
        return body
    elif target.type == target.NON_SIDEREAL:
        body = ephem.EllipticalBody()
        body._inc = ephem.degrees(target.inclination) if target.inclination else 0
        body._Om = target.lng_asc_node if target.lng_asc_node else 0
        body._om = target.arg_of_perihelion if target.arg_of_perihelion else 0
        body._a = target.semimajor_axis if target.semimajor_axis else 0
        body._M = target.mean_anomaly if target.mean_anomaly else 0
        if target.ephemeris_epoch:
            epoch_M = Time(target.ephemeris_epoch, format='jd')
            epoch_M.format = 'datetime'
            body._epoch_M = ephem.Date(epoch_M.value)
        else:
            body._epoch_M = ephem.Date(DEFAULT_VALUES['epoch'])
        body._epoch = target.epoch if target.epoch else ephem.Date(DEFAULT_VALUES['epoch'])
        body._e = target.eccentricity if target.eccentricity else 0
        return body
    else:
        raise Exception("Object type is unsupported for visibility calculations")
Beispiel #4
0
def getKBOs(mpc_file, cond='a > 30'):

    f = open(mpc_file)
    lines = f.readlines()
    f.close()

    # while "------" not in lines[0]:
    # lines.pop(0)
    # lines.pop(0)
    nobj = 0
    lineCount = 0
    kbos = []
    for line in lines:
        lineCount = lineCount + 1
        if line[0] == '#' or len(
                line) < 103 or line[0:3] == '---' or line[0:3] == 'Des':
            continue
        kbo = ephem.EllipticalBody()

        try:
            if len(line[8:13].strip()):
                kbo._H = float(line[8:13])
                kbo._G = float(line[14:19])
            else:
                kbo._H = 20
                kbo._G = 0
        except:
            print line
            kbo._H = 20
            kbo._G = 0
        arc = line[127:136]
        try:
            if 'days' in arc:
                arc = int(arc.split()[0]) / 365.25
            else:
                arc = -eval(arc)
        except:
            arc = 0
        kbo._epoch_M = date_unpack(line[20:25].strip())
        kbo._M = float(line[26:35].strip())
        kbo._om = float(line[37:46].strip())
        kbo._Om = float(line[48:57].strip())
        kbo._inc = float(line[59:68].strip())
        kbo._e = float(line[70:79].strip())
        kbo._epoch = '2011/08/01'
        kbo._a = float(line[92:103].strip())
        kbo.compute()

        a = kbo._a
        q = kbo._a * (1 - kbo._e)
        H = kbo._H

        if eval(cond):
            kbo.name = desig_unpack(line[0:7].strip())
            kbos.append(kbo)

    return kbos
Beispiel #5
0
def make_object(a=1, e=0, inc=0, M=0, Omega=0, omega=0, epoch=36525, epoch_M=36525):
	"""Construct a pyephem EllipticalBody with the given parameters."""
	o = ephem.EllipticalBody()
	o._a   = a
	o._e   = e
	o._inc = inc
	o._Om  = Omega
	o._om  = omega
	o._M   = M
	o._epoch = epoch
	o._epoch_M = epoch_M
	return o
Beispiel #6
0
def synthetic_model_kbos(
        at_date=parameters.NEWMOONS[parameters.DISCOVERY_NEW_MOON],
        maglimit=24.5,
        kbotype=False,
        arrays=False):
    # # build a list of Synthetic KBOs
    print "LOADING SYNTHETIC MODEL KBOS FROM: {}".format(parameters.L7MODEL)
    kbos = []
    if arrays:  # much easier to use for plt.scatter()
        ra = []
        dist = []
        hlat = []
    lines = storage.open_vos_or_local(parameters.L7MODEL).read().split('\n')
    counter = 0
    for line in lines:
        if len(line) == 0 or line[
                0] == '#':  # skip initial column descriptors and the final blank line
            continue
        kbo = ephem.EllipticalBody()
        values = line.split()
        kbo.name = values[8]
        if kbotype and (kbo.name == kbotype) and (values[9] == '3'):
            kbo._a = float(values[0])
            kbo._e = float(values[1])
            kbo._inc = float(values[2])
            kbo._Om = float(values[3])
            kbo._om = float(values[4])
            kbo._M = float(values[5])
            kbo._H = float(values[6])
            epoch = ephem.date(2453157.50000 - ephem.julian_date(0))
            kbo._epoch_M = epoch
            kbo._epoch = epoch
            date = ephem.date(at_date)
            kbo.compute(date)
            counter += 1

            # ## only keep objects that are brighter than limit
            if (kbo.mag < maglimit):
                kbos.append(kbo)
                if arrays:
                    ra.append(kbo.ra)
                    dist.append(kbo.sun_distance)
                    hlat.append(kbo.hlat)

    print '%d synthetic model kbos brighter than %d retained from %d in L7 model'.format(
        len(kbos), maglimit, counter)
    if not arrays:
        return kbos
    else:
        return ra, dist, hlat
Beispiel #7
0
def getradec(jds, a=500.0, e=0.3, inc=30.0, niter=1000000):
    djd = jds[1] - 2415020

    observer = eph.Observer()
    observer.date = djd

    observerm1 = eph.Observer()
    observerm1.date = jds[0] - 2415020

    observerp1 = eph.Observer()
    observerp1.date = jds[2] - 2415020

    ras = []
    decs = []
    n = -1
    while n < niter:
        body = eph.EllipticalBody()
        body._inc = inc
        body._a = a
        body._e = e
        ang = sci.rand(3) * 360.0
        body._om = ang[0]
        body._Om = ang[1]
        body._M = ang[2]
        body._epoch = djd
        body._epoch_M = djd

        body.compute(observer)
        ras.append(body.a_ra * r2d)
        decs.append(body.a_dec * r2d)

        if abs(ras[-1] - 43.2) < 1 and abs(decs[-1] - 2) < 1:
            body.compute(observerm1)
            ra_m1 = body.a_ra * r2d
            dec_m1 = body.a_dec * r2d
            body.compute(observerp1)
            ra_p1 = body.a_ra * r2d
            dec_p1 = body.a_dec * r2d
            #print(ra_p1,ra_m1,dec_p1,dec_m1)

            print(ras[-1], decs[-1], body.sun_distance)
            print((ra_p1 - ras[-1]) * 3600.0 / 24,
                  (dec_p1 - decs[-1]) * 3600.0 / 24)
            print((ras[-1] - ra_m1) * 3600.0 / 24,
                  (decs[-1] - dec_m1) * 3600.0 / 24)
            print()
            return (np.array([ra_m1, ras[-1],
                              ra_p1]), np.array([dec_m1, decs[-1], dec_p1]))
        n += 1
Beispiel #8
0
def kbo(a, q, Om, om, inc, M, H):
    kbo = ephem.EllipticalBody()
    kbo.name = "test"
    kbo._epoch_M = (2018, 10, 1)
    kbo._inc = inc
    kbo._Om = Om
    kbo._om = om
    kbo._epoch = 42980.5
    kbo._G = 0.15
    kbo._M = M
    kbo._e = 1.0 - (q / a)
    kbo._a = a
    kbo._H = H
    kbo.compute(kbo._epoch)
    return kbo
Beispiel #9
0
def test_comet():
    obj = ephem.EllipticalBody()
    obj._epoch = '2000'
    obj._epoch_p = '2000'
    obj._inc = 18.7527
    obj._Om = 5.9635
    obj._om = 160.8131
    obj._e = 0.135067

    sbrtel = SubaruEphemeris()
    start_f = calendar.timegm((1999, 05, 24, 05, 00, 00, -1, -1, -1))
    end_f = calendar.timegm((1999, 05, 24, 10, 00, 00, -1, -1, -1))
    tups = sbrtel.TSCTracking(obj, start_f, end_f, 60.0)

    for tup in tups:
        print "%s %s %s %s %s\n" % tup
Beispiel #10
0
 def ellipticalBody(self, name=None):
     '''
     Packs the orbital parameters into an EllipticalBody object suitable for use by pyEphem
     '''
     DJD = 2415020  # Dublin Julian Date t=0 (used by pyephem Date object)
     b = ephem.EllipticalBody()
     if name is not None:
         b.name = name
     b._a = self.orbit_aei.a
     b._inc = self.orbit_aei.i
     b._Om = self.orbit_aei.lan
     b._om = self.orbit_aei.aop
     b._e = self.orbit_aei.e
     b._epoch = ephem.date('2000/01/01')  # J2000
     b._M = self.mean_anomaly()  # mean anomaly from perihelion (deg)
     b._epoch_M = ephem.date(orbfit.cvar.jd0 -
                             DJD)  # date for measurement of mean anomaly _M
     return b
Beispiel #11
0
    def make_ephem_object(elements):

        e = {}
        if elements['Elements']['Eccentricity'] < 1:
            e = ephem.EllipticalBody()

        e.name = elements['name']
        e._inc = elements['Elements']['Inclination']
        e._Om = elements['Elements']['LAAN']
        e._om = elements['Elements']['Argument_of_Periapsis']
        e._a = elements['Elements']['Semimajor_Axis']
        e._e = elements['Elements']['Eccentricity']
        e._M = elements['Elements']['Mean_Anomaly']
        epoch_date = elements['Elements']['Epoch'] - 2415020  # JD to DJD

        e._epoch_M = ephem.Date(epoch_date)
        e._epoch = ephem.Date('2000/1/1')

        return e
Beispiel #12
0
    def LoadObject(self, des):
        '''
         Input: asteroid Designation (des).
         Output: Return pyephem class with asteroid ephemeris for any date or observer.
      '''

        ast = ephem.EllipticalBody()
        '''
      EllipticalBody elements:

       _inc — Inclination (°)
       _Om — Longitude of ascending node (°)
       _om — Argument of perihelion (°)
       _a — Mean distance from sun (AU)
       _M — Mean anomaly from the perihelion (°)
       _epoch_M — Date for measurement _M
       _size — Angular size (arcseconds at 1 AU)
       _e — Eccentricity
       _epoch — Epoch for _inc, _Om, and _om
       _H, _G — Parameters for the H/G magnitude model
       _g, _k — Parameters for the g/k magnitude model
      '''

        # Reading
        H, G, epoch_M, M, argper, node, i, e, n, a = self.asteroid[des]

        # Asteroid Parameters
        ast._H, ast._G, ast._M, ast._om, ast._Om, ast._inc, ast._e, ast._a = map(
            float, [H, G, M, argper, node, i, e, a])
        ast._epoch_M = str(convert_date(epoch_M))
        #print ast._H, ast._G, ast._M, ast._om, ast._Om, ast._inc, ast._e, ast._a
        #print convert_date(epoch_M)

        # Constants
        ast._epoch = str("2000/1/1 12:00:00")

        return ast
Beispiel #13
0
def build_kbos(model):
    lons = []
    lats = []
    dist = []
    kbos = []
    for m in model:
        kbo = ephem.EllipticalBody()
        kbo.name = m['name']
        kbo._a = m['a']
        kbo._e = m['e']
        kbo._epoch = 2000.0
        kbo._epoch_M = 2000.0
        kbo._M = m['M']
        kbo._om = m['omega']
        kbo._Om = m['Omega']
        kbo._inc = m['i']
        kbo._H = m['H']
        kbo._epoch = (time.Time(m['epoch'], format='mjd') -
                      ephem_day_0).to('day').value
        kbo._epoch_M = (time.Time(m['epoch_M'], format='mjd') -
                        ephem_day_0).to('day').value
        kbo.compute()
        lons.append(kbo.hlon)
        lats.append(kbo.hlat)
        dist.append(kbo.sun_distance)
        kbos.append(kbo)
    model['hlon'] = numpy.array(lons) * units.radian
    model['hlat'] = numpy.array(lats) * units.radian
    model['dist'] = numpy.array(dist) * units.au
    model['kbo'] = numpy.array(kbos)
    coords = coordinates.SkyCoord(model['hlon'],
                                  model['hlat'],
                                  frame='heliocentrictrueecliptic',
                                  distance=model['dist'])
    model['coordinate'] = coords
    return
Beispiel #14
0
## build a list of Synthetic KBOs that will be in the discovery fields.
print("LOADING SYNTHETIC MODEL KBOS FROM: {}".format(L7MODEL))
ra = []
dec = []
kbos = []
lines = storage.open_vos_or_local(L7MODEL).read().split('\n')

# Look for synthetic KBOs that are in the field on this date.
discovery_date = ephem.date(newMoons[DISCOVERY_NEW_MOON])
plot_date = ephem.date(newMoons[PLOT_FIELD_EPOCH])

for line in lines:
    if len(line) == 0 or line[
            0] == '#':  # skip initial column descriptors and the final blank line
        continue
    kbo = ephem.EllipticalBody()
    values = line.split()
    kbo._a = float(values[0])
    kbo._e = float(values[1])
    kbo._inc = float(values[2])
    kbo._Om = float(values[3])
    kbo._om = float(values[4])
    kbo._M = float(values[5])
    kbo._H = float(values[6])
    epoch = ephem.date(2453157.50000 - ephem.julian_date(0))
    kbo._epoch_M = epoch
    kbo._epoch = epoch
    kbo.name = values[8]
    kbo.compute(discovery_date)

    kbo_ra = math.degrees(kbo.ra)
Beispiel #15
0
#Packages
import math
from datetime import datetime
import ephem

#Define a home location for the observer - in this case, Seattle, WA (USA)
home = ephem.Observer()
home.lon = '-122.349'  # +E
home.lat = '47.67459'  # +N
home.elevation = 66  # meters
home.horizon = '-0:34'  #US Naval Observatory refraction correction of 34 degrees below horizon
home.date = datetime.utcnow()

# Create a body by defining orbital elements for object for an elliptical orbit
apollo = ephem.EllipticalBody()
'''
Definition of EllipticalBody elements

_inc — Inclination (°)
_Om — Longitude of ascending node (°)
_om — Argument of perihelion (°)
_a — Mean distance from sun (AU)
_M — Mean anomaly from the perihelion (°)
_epoch_M — Date for measurement _M
_size — Angular size (arcseconds at 1 AU)
_e — Eccentricity
_epoch — Epoch for _inc, _Om, and _om
_H, _G — Parameters for the H/G magnitude model
_g, _k — Parameters for the g/k magnitude model
'''
Beispiel #16
0
    def _plot(self):
        """Draw the actual plot.
        """

        w = self
        kbos = self.kbos
        re_string = w.FilterVar.get()
        vlist = []
        for name in kbos:
            if not re.search(re_string, name):
                continue
            vlist.append(name)
            fill = None
            is_colossos_target = False
            for cname in colossos:
                if cname in name:
                    is_colossos_target = True
                    print "ColOSSOS: ", cname
                    break
            is_terminated = False
            for cname in tracking_termination:
                if cname in name:
                    is_terminated = True
                    print "Terminated", cname
                    break
            is_double = False
            for cname in doubles:
                if cname in name:
                    is_double = True
                    print 'Needs double:', cname
                    break
            if type(kbos[name]) == type(ephem.EllipticalBody()):
                try:
                    kbos[name].compute(w.date.get())
                except Exception as e:
                    logging.error(
                        "Failed to compute KBO position. {}".format(name))
                    continue
                ra = kbos[name].ra
                dec = kbos[name].dec
                a = math.radians(10.0 / 3600.0)
                b = a
                ang = 0.0
                point_size = 2
                yoffset = +10
                xoffset = +10
            elif isinstance(kbos[name], orbfit.Orbfit):
                yoffset = -10
                xoffset = -10
                kbo = kbos[name]
                start_date = mpc.Time(w.date.get(), scale='utc').jd
                trail_mid_point = 0
                for days in range(trail_mid_point * 2 + 1):
                    point_size = days == trail_mid_point and 5 or 1
                    today = mpc.Time(start_date - trail_mid_point + days,
                                     scale='utc',
                                     format='jd')
                    kbo.predict(today, 568)
                    ra = kbo.coordinate.ra.radian
                    dec = kbo.coordinate.dec.radian
                    a = math.radians(kbo.dra / 3600.0)
                    b = math.radians(kbo.ddec / 3600.0)
                    ang = math.radians(kbo.pa)
                    lost = False
                    if a > math.radians(0.3):
                        lost = True

                fill_colour = lost and "red" or "green"
                fill_colour = is_double and "magenta" or fill_colour
                fill_colour = is_colossos_target and "blue" or fill_colour
                point_colour = is_terminated and "red" or "yellow"
                w.create_point(ra,
                               dec,
                               size=point_size,
                               color=point_colour,
                               fill=fill_colour)
                if w.show_ellipse.get() == 1 and days == trail_mid_point:
                    if a < math.radians(5.0):
                        w.create_ellipse(ra, dec, a, b, ang)
                    if w.show_labels.get() == 1:
                        w.label(ra, dec, name, offset=[xoffset, yoffset])
            else:
                ra = kbos[name]['RA']
                dec = kbos[name]['DEC']
                w.create_point(ra, dec, size=6, color='cyan')
                w.label(ra, dec, name, offset=[-15, +15])

        vlist.sort()
        for v in vlist:
            w.objList.insert(END, v)
        w.plot_pointings()
Beispiel #17
0
if __name__ == "__main__":

    with open('kbos_to_plant.dat') as han:
        data = han.readlines()
    kbos = []
    for i in range(len(data)):
        o = []
        s = data[i].split()
        for j in range(3, len(s)):
            o.append(float(s[j]))
        kbos.append(o)
    kbos = np.array(kbos)

    bodies = []
    for i in range(len(kbos)):
        kbo = eph.EllipticalBody()
        (a, e, inc, a0, a1, a2, djdM, djd, H, m) = kbos[i]
        kbo._a = a
        kbo._e = e
        kbo._inc = inc
        kbo._M = a0
        kbo._Om = a1
        kbo._om = a2
        kbo._epoch_M = djdM
        kbo._epoch = djd
        bodies.append(kbo)
        del kbo

    observer = eph.Observer()
    observer.lon = '204:31:40.1'
    observer.lat = '19:49:34.0'
	aznum,altnum = "B"+str(i),"C"+str(i)
	az,alt = sheet[aznum].value,sheet[altnum].value
	sinD = sin(radians(alt))*sin(radians(latitude))+cos(radians(alt))*cos(radians(latitude))*cos(radians(az))
	dec = degrees(asin(sinD))
	sinH = -(sin(radians(az))*cos(radians(alt)))/cos(radians(dec))
	H = degrees(asin(sinH))
	ra = longitude-H
	dec -= 23.5
	sheet[aznum],sheet[altnum] = ra,dec
	sheet['F'+str(i)] = sheet['F'+str(i)].value + vMin
	vx,vz = sheet['E'+str(i)].value,sheet['G'+str(i)].value
	sheet['E'+str(i)] = (vx*cos(radians(theta)))-(vz*sin(radians(theta)))
	sheet['G'+str(i)] = (vx*sin(radians(theta)))+(vz*cos(radians(theta)))
	someX,someY,someZ = getVal(ra,dec,sheet['F'+str(i)].value)
	vx,vy,vz = sheet['E'+str(i)].value,sheet['F'+str(i)].value,sheet['G'+str(i)].value
	x = ephem.EllipticalBody(ephem.Date('2018/01/05'))
	x._a, x._e, x._inc, x._Om, x._om, x._M = param([someX,someY,someZ], [vx,vy,vz])
	bodies[sheet["A"+str(i)].value] = x
wb.save(filename='Input_data/newdata3.xlsx')

startDate = ephem.Date('2018/01/05')
endDate = ephem.Date('2023/01/05')
currentDate = startDate

for tag in allTags:
	while currentDate < endDate:
		value = modifier(bodies[tag],currentDate)
		# print value
		if value < minDist[tag][0]:
			minDist[tag] = (value,ephem.Date(currentDate))
		currentDate += 1
Beispiel #19
0
def main():
    f = open('/Users/kavelaarsj/MPCORB.DAT')
    #f=open('schwamb_orbits.dat')
    lines = f.readlines()
    f.close()

    import ephem, sys
    kbo = ephem.EllipticalBody()
    line = lines.pop(0)
    while (line[0:3] != "---"):
        line = lines.pop(0)

    lines.append(line)
    nobj = 0
    lineCount = 0
    for line in lines:
        lineCount = lineCount + 1
        if lineCount % 1000 == 0:
            sys.stderr.write("# Line: %d \n" % (lineCount))
        if line[0] == '#' or len(line) < 103 or line[0:3] == '---':
            #sys.stderr.write(line)
            continue

        if len(line[8:13].strip()):
            kbo._H = float(line[8:13])
            kbo._G = float(line[14:19])
        else:
            kbo._H = 20
            kbo._G = 0
        arc = line[127:136]
        try:
            if 'days' in arc:
                arc = int(arc.split()[0]) / 365.25
            else:
                dt = -eval(arc)
        except:
            sys.stderr.write(
                "Error parsing the arc length value: {}".format(arc))
            continue
        kbo._epoch_M = date_unpack(line[20:25].strip())
        kbo._M = float(line[26:35].strip())
        kbo._om = float(line[37:46].strip())
        kbo._Om = float(line[48:57].strip())
        kbo._inc = float(line[59:68].strip())
        kbo._e = float(line[70:79].strip())
        kbo._epoch = '2017/09/04'
        kbo._a = float(line[92:103].strip())
        try:
            U = int(line[105])
            nobs = int(line[117:122])
            last_obs = Time("{}-{}-{}".format(line[194:198], line[198:200],
                                              line[200:202]))
        except:
            print line
            U = 9
            nobs = 3
            last_obs = Time("2017-01-01")
        pU = uncertainty[U]
        pU = (current_time - last_obs.jd) * U / 365.25
        #print last_obs, U, uncertainty[U], pU
        a = kbo._a
        e = kbo._e
        H = kbo._H
        i = kbo._inc
        kbo.compute(ephem.date('2011/12/22'))
        kbo.name = desig_unpack(line[0:7].strip())
        T_J = (5.2 / a) + 2.0 * math.sqrt((1 - e**2) * (a / 5.2)) * math.cos(i)
        if eval(cond):
            if line[0] == 'P' or line[0] == 'T':
                # Ignore the PLS and T (?) astroid surveys.
                continue
            #try :
            kbo.name = desig_unpack(line[0:7].strip())
            #except :
            #   sys.stderr.write(line[0:7].strip())
            #nobj = nobj+1
            print "%20s %5.1f %5.1f %5.1f %f %f %f" % (kbo.name.replace(
                " ", "_"), a, e, math.degrees(i), H, math.degrees(
                    kbo.ra), math.degrees(kbo.dec))
            for column in columns:
                out_data[column].append(eval(column))
            print "%20s %5.1f %5.1f %5.1f %f %f %f" % (kbo.name.replace(
                " ", "_"), a, e, math.degrees(i), H, math.degrees(
                    kbo.ra), math.degrees(kbo.dec))
            # print "%20s %5.1f %5.1f %5.3f %5.1f %5.1f %5.1f %5.1f %s %s" % (kbo.name,H ,a,e,a*(1-e),i*57.3,kbo.sun_distance,kbo.mag,kbo.ra,kbo.dec)
            # print "grep \"%s\" schwamb_T2.dat" % ( kbo.name)
            # print math.degrees(kbo._Om)
            # print "# ",kbo.sun_distance, kbo._a, kbo._e, kbo._inc, kbo._a, kbo.sun_distance
            # print "%10.5f,%10.5f,%-20s,%10.2f,%10.2f" % ( math.degrees(kbo.ra),math.degrees(kbo.dec),"'"+kbo.name+"'", kbo._a, kbo.sun_distance)
            # print H,kbo._a, kbo._e, math.degrees(kbo._inc), kbo.sun_distance,a*(1-e),a*(1+e), kbo.name.replace(" ","_")
            # print kbo.writedb()

    ascii.write(out_data, 'mpcread.dat', names=columns)