mommermi
mommermi

Reputation: 1052

Why won't PyEphem calculate the elevation of manually generated objects?

I have been using PyEphem for quite a while, but since a few days (maybe weeks?) ago, one of my scripts won't work anymore. The script calculates among other things the rise and set times of asteroids, which I create from orbital elements using CALLHORIZONS. I figured out that PyEphem does not properly calculate the asteroids' elevation - however, it properly calculates the elevation for the Sun.

Here is a minimal script:

import ephem
import numpy
import callhorizons 

this_target = '3552'
body = callhorizons.query(this_target)
body.set_discreteepochs(2415730.0)
body.get_elements()
this_target = body.export2pyephem()[0]

### works fine for the Sun
#this_target = ephem.Sun()

date = ephem.now()

this_target.compute(date)

obs = ephem.Observer()
obs.epoch = 2000.0
obs.lon = -111.653152/180.*numpy.pi
obs.lat = 35.184108/180.*numpy.pi
obs.elevation = 2738 # m
obs.date = date
obs.horizon = 0.

# if target is '3552', this_target.alt stays constant
for time in numpy.arange(date, date+1, 0.1):
    obs.date = time
    this_target.compute(obs)
    print time, this_target.alt, this_target.ra

### if this_target is '3552', this results in a segmentation fault
print obs.next_rising(this_target)

Using the self-defined target (3552 in this case), PyEphem won't calculate the target's elevation and hence run into a Segmentation fault when trying to derive the rise/set times of this target.

I tried installing the latest version of PyEphem (3.7.6.0), but it didn't help. Can anyone replicate (explain?) this error?

Upvotes: 1

Views: 199

Answers (2)

mommermi
mommermi

Reputation: 1052

Triggered by R. J. Mathar's answer, I looked into this again and found that the issue has disappeared. I now get the correct result using Python 2.7 and 3.5; both using PyEphem 3.7.6.0.

I would love to provide some more insight into what the problem was, but I have no idea. I am not sure if anything important changed on my system. It seems to be caused by some kind of installation issue.

Upvotes: 0

R. J. Mathar
R. J. Mathar

Reputation: 1

Given a latitude of 35 deg, the fact that this object is close to Jupiter slightly above the Ecliptic and that it has a period of 8 years, it's may be that it does never rise until approximately 2 or 3 more years have passed.

Upvotes: 0

Related Questions