Calculate Python PyEphem azimuth and altitude

I'm new to PyEphem, and I'm trying to figure out what it can do and how it works. Since I do not want to use it as a black box and blindly trust any figure that I get, I wanted to recreate the example explained here .

An example calculates the azimuth and height of an object for a given observer on August 10, 1998 at 23:10 UT. The following options are listed:

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

The latitude of the observer 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): AZ = 269.144634 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 result:

 >>> 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 approximate, for example, but far from identical. I am also puzzled by the fact that RA and DEC are slightly changed in the printout compared to what I entered.

If someone can help me shed light on why the results are different, and what I can or should do to reproduce the results, I would really appreciate it. Thanks.

EDIT : fixed the typo indicated in the answer below. The question remains valid.

EDIT2 : Well, I read (and sort of figured out) why PyEphem is setting up the correct ascent and declination from this link . I don’t understand if there is a way to make PyEphem ignore the correction of relativistic deflection, nutation and light aberration in the same way as you can make it ignore atmospheric refraction? I assume that the difference in azimuth is due to the adjustment of RA and DEC, but it would be nice to confirm.

+4
source share
3 answers

The C library underlying PyEphem does not have the ability to disable rejection, aberration, or nutation - perhaps because Nature does not allow us to disable these effects, but I'm not sure! I will not note that these calculations are for a terrestrial orbiting satellite, but I cannot think of a simple way to set the satellite to an exact RA and lower it above your position so that you can ask PyEphem about its location.

I'm really going to talk about the API this week at DjangoCon, and think about how PyEphem can someday make its internal work more accessible with Python, instead of leaving all these interesting steps locked inside C code. But for now, there will be no ready-made alternative for me, the only way to accomplish what you want is to open the source circum.c file and comment on 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 these three calls - deflect() , nut_eq() and ab_eq() , starting at line 263, are commented out, then you can get the answer much closer to the one that was created in this article. You must apply these changes:

  • Download .tar.gz for PyEphem.
  • Extract the archive to create the files.
  • Do the editing I suggest above.
  • Run python setup.py install to install your own version of the software.
  • Give it a try!

Another obstacle may arise if the precession somehow enters the game - you may need to set the epoch of your star object to exactly '1998/8/10 23:10:00' in this case - but first try disabling the three calls to the light effect and see if it helps you any closer!

+2
source

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

as described in help :

These apparent positions include adjustments to simulate atmospheric refraction for observers pace and pressure; set observers pressure to zero to ignore refraction.

+2
source

You want 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 '

+1
source

Source: https://habr.com/ru/post/1432302/


All Articles