Question

I am new to PyEphem and I am trying to figure out what it can do and how it works. As I do not want to use it as a black box and blindly trust whatever figure I get, I wanted to recreate an example that is explained here.

The example calculates the azimuth and altitude of an object for a given observer on the 10th August 1998 at 23:10 UT. The following parameters are given:

RA = 16 h 41.7 min, DEC = 36 d 28 min

The observer's latitude is 52 d 30 min North and longitude 1 d 55 min West.

The correct answer according to the example (which I can recreate in Excel) is AZ = 269.14634 degrees and ALT = 49.169122 degrees.

I wrote the following code using pyephem to try to achieve the same result:

day = '1998/8/10 23:10:00'
longitude = ephem.degrees('-1.91667')
latitude = ephem.degrees('52.5')

star = ephem.FixedBody()
star._ra = '16:41:42.0'
star._dec = '36:28:00.0'

observer = ephem.Observer()
observer.date = day
observer.lon = longitude
observer.lat = latitude

star.compute(observer)

print 'Observer', observer
print 'RA', star.ra, 'DEC', star.dec
print 'AZ', star.az, 'ALT', star.alt

Running the program gives me this output:

>>> 
Observer <ephem.Observer date='1998/8/10 23:10:00' epoch='2000/1/1 12:00:00' lon=-1:55:00.0 lat=52:30:00.0 elevation=0.0m horizon=0:00:00.0 temp=15.0C pressure=1010.0mBar>
RA 16:41:39.23 DEC 36:28:33.5
AZ 269:09:54.9 ALT 49:10:57.7

The results for AZ + ALT are obviously ballpark to the example but far from identical. I am also puzzled by the fact that RA and DEC are slightly modified in the print out compared to what I entered.

If anyone can help me shed some light to why the results differ and what I can or should do to replicate the results, I would greatly appreciate it. Thanks.

EDIT: Corrected a typo pointed out in answer below. The question is still valid.

EDIT2: OK, I have read (and sort of understood) why the right ascension and declination is adjusted by PyEphem from this link. What I do not understand is if there is any way to get PyEphem to ignore adjusting for relativistic deflection, nutation and aberration of light the same way that you can make it ignore atmospheric refraction? I am assuming that the difference in Azimuth is due to the adjustment of RA and DEC but it would be nice to confirm.

Was it helpful?

Solution

The C library underlying PyEphem does not have any way to turn off deflection, aberration, or nutation — maybe because Nature does not let us turn those effects off either, but I am not sure! It does not, I will note, do those calculations for an earth-orbiting satellite, but I can't think of an easy way for you to put a satellite at an exact RA and dec above your position so that you can ask PyEphem about its location.

I am actually spending this week at DjangoCon going to talks about APIs, and thinking about how PyEphem might someday make its inner workings easier to access from Python, instead of leaving all of these interesting steps locked inside of the C code. But, until I have an alternative ready, the only way to accomplish what you want would be to open the source file circum.c and comment out these lines:

/* allow for relativistic light bending near the sun */
deflect (mjed, lam, bet, lsn, rsn, 1e10, &ra, &dec);

/* TODO: correction for annual parallax would go here */

/* correct EOD equatoreal for nutation/aberation to form apparent 
 * geocentric
 */
nut_eq(mjed, &ra, &dec);
ab_eq(mjed, lsn, &ra, &dec);

If those three calls — deflect(), nut_eq(), and ab_eq() starting at line 263 — are commented out, then you might get an answer much closer to the one produced in this article. You would apply these changes by:

  • Downloading the .tar.gz for PyEphem.
  • Extract the archive to produce files.
  • Make the edit that I suggest above.
  • Run python setup.py install to install your custom version of the software.
  • Try it out!

There might be another obstacle, if precession is somehow coming into play — you might need to set the epoch of your star object to exactly '1998/8/10 23:10:00' in that case — but try turning off the three light-effect calls first and see if that gets you closer!

OTHER TIPS

The fact that observer includes "temp=15.0C pressure=1010.0mBar" implies that the calculation will include refraction. You want to turn off refraction

as described in the help:

These apparent positions include an adjustment to simulate atmospheric refraction for the observer’s temp and presure; set the observer’s pressure to zero to ignore refraction.

You wanted to enter : RA = 16 h 41.7 min

but you entered: star._ra = '16:41.42.0'

instead of star._ra = '16:41:42.0'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top