Astronomical package for Euler

[ Root ]

Contents

Overview and obtaining Euler

[ Top ]

Euler is an interactive 'expression evaluator' that operates in a Notepad style window under Windows 95 and other Microsoft 32 bit operating systems, as well as Unix. Euler is written and actively maintained by Dr Rene Grothmann.

I have contributed a simple 'package' of basic astronomical functions for use with Euler. This package provides functions to calculate apparent positions of the Moon, Sun and major planets using routines of 5 to 10 arcsecond accuracy and simple corrections for nutation and aberration, as well as calculating topocentric positions and the altitude and azimuth. Physical ephermerides for the Moon and major planets will be added in the future, as will rising and setting phenomena.

Euler is obtained as a ZIP file from the following Web site

http://mathsrv.ku-eichstaett.de/MGF/homes/grothmann/euler/euler.html

When you expand the ZIP file, there is a folder called Docs that contains Dr Grothmann's documentation for Euler. I would suggest you work through the Introduction, Basics and Expressions and Matrices sections before using the astronomical functions.

Downloading and installing astronomical functions

[ Top ]

I have hacked together some astronomical functions from books by Meeus, Duffett-Smith and Montenbruck and Pfleger. These functions are collected togther in a Euler 'program file' called astro.e.

To make these functions available to Euler, you should

You can edit the configuration file euler.cfg so that astro.e loads each time you start Euler - see the Euler manual for details.

Using the astronomical functions

[ Top ]

The best way to illustrate the use of the astro.e functions is to describe a typical interactive session. In this session we will:-

The transcript of the session is reproduced below. You type commands after the prompt '>', and the response appears on the next line indented by about 4 spaces. Equatorial coordinates are returned in a vector consisting of the RA in degrees, the declination in degrees, and the distance of the object in either a.u. (or in Km for the Moon).

>load astro

-----------------------------------------------------
   Astronomical functions 1999-08-18
   Type 'help astro(RETURN)' for list of functions
-----------------------------------------------------

>help astro
function astro ()
## Astronomical functions taken from
## Jean Meeus - 'Astronomical Algorithms'
## Montenbruck and Pfleger - 'Astronomy on the Personal Computer'
## Duffett-Smith - 'Practical astronomy with your calculator'
## other sources.
## For information on a function named fred, type 'help fred'.
##
## day        jday     gst      nutation
## hmercury   hvenus   hearth   hmars     hjupiter
## mercury    venus    sun      mars      jupiter
## gmer       gven              gmar      gjup
## gmoon      amoon    moon     tmoon
## equatorial apparent mean     altaz     raltaz
## cart       sph
## table
## ddegrees   dsin     dcos     dtan      dasin     dacos    datan    datan2
## brum       reekie   settle
##
>help tmoon
function tmoon (day,station)
## returns: topcentric equatorial coordinates of Moon
##   given: TD instant in 'day'
##          'station' - vector lat, long, height (m), temp (C),
##          and pressure (mB) of observing location
>now = day(1999, 8, 11, 10, 17)
     -143.072
>psun = sun(now)
      140.754       15.3374       1.01358
>gmoon = moon(now)
      140.429       15.9114        373195
>here = [-1.9167, 52.5, 120, 17, 1011 ]
      -1.9167          52.5           120            17          1011
>pmoon = tmoon(now, here)
      140.729       15.3036        368556
>pmoon - gmoon
     0.300715      -0.60774      -4639.18
>psun - pmoon
    0.0243673     0.0337465       -368555
>sunbrum = altaz(now, here, psun)
      137.411       46.3381       1.01358
>moonbrum = altaz(now, here, pmoon)
      137.463       46.3176        368556
>sunbrum-moonbrum
   -0.0516406     0.0204827       -368555
>

To recalculate all the quantities for a different time, just

Note that Euler will not automatically recalculate when the value of variables defined earlier is changed - you have to press return each time to force recalculation.

This ability to set up a series of commands and then change parameters and recalculate new answers makes 'trial and error' calculations for astronomical configurations possible. The next logical move is to combine the calculation sequence into a function in its own right.

Adding your own functions

[ Top ]

Functions can be defined at the Euler prompt and saved in 'notepad' files for re-use. You can also write functions with an ordinary text editor and save collections of functions as 'programs' with the file extension .e. See the Euler manual for syntax, examples and details.

You can just add the code for your astronomical functions to astro.e - if you crack moonrise and set from any latitude, I'd like a copy!

Below is the code for the day function that converts from a date in UT (strictly dynamical time) to the number of days since J2000.

function day(y, m, d, h, min)
## returns the days since J2000.0 number assuming the Gregorian calendar
## after 1582 Oct 4th given the year, month, day, hour and minute
## This method is modified from Duffett-Smith Calculator page 7
## Negative years CE are numbered according to the astronomical
## convention - i.e. calendrical year 1 BC is year zero in this function
greg = y*10000 + m*100 + d;
if m == 1 || m == 2;
	y = y - 1;
	m = m + 12;
endif;
if greg > 15821004;
   a = floor(y/100);
   b = 2 - a  + floor(a/4);
else;
   b = 0;
endif;
c = floor(365.25 * y);
d1 = floor(30.6001 * (m + 1));
return b + c + d1 -730550.5 + d + (h+min/60)/24;
endfunction

As you can see, the overall format of the function is similar to a function in QBASIC or most other languages. The boolean operators for use in 'if' statements are similar to those of C. If you omit a semicolon at the end of each line, the value of that line will be echoed to the Euler window when the function is called.

[ Root ]


Last Modified 18th August 1999
Keith Burnett