Code covered by the BSD License  

Highlights from
Rise and Set of the Sun, Moon and Planets

Rise and Set of the Sun, Moon and Planets

by

 

05 Dec 2012 (Updated )

Topocentric rise and set of the Sun, Moon and planets. Source ephemeris is DE421 with NOVAS routines

gast2 (tjdh, tjdl, k)
function gst = gast2 (tjdh, tjdl, k)

% this function computes the greenwich sidereal time
% (either mean or apparent) at julian date tjdh + tjdl

% this version reads the nutation values from jpleph

% reference
% aoki, et al. (1982) astronomy and astropysics 105, 359-361

% input

%  tjdh = julian date, high-order part

%  tjdl = julian date, low-order part

%         julian date may be split at any point, but for
%         highest precision, set tjdh to be the integral part of
%         the julian date, and set tjdl to be the fractional part

%  k    = time selection code
%         set k = 0 for greenwich mean sidereal time
%         set k = 1 for greenwich apparent sidereal time

% output

%  gst = greenwich (mean or apparent) sidereal time in hours

% Celestial Computing with MATLAB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

seccon = 206264.8062470964;

t0 = 2451545;

tjd = tjdh + tjdl;
th = (tjdh - t0) / 36525;
tl = tjdl / 36525;
t = th + tl;
t2 = t * t;
t3 = t2 * t;

% for apparent sidereal time, obtain equation of the equinoxes

eqeq = 0;

if (k == 1)
   [x1, x2, eqeq, x3, x4] = etilt1(tjd);
end

st = eqeq - 6.2e-6 * t3 + 0.093104 * t2 + 67310.54841 ...
     + 8640184.812866 * tl + 3155760000 * tl ...
     + 8640184.812866 * th + 3155760000 * th;

gst = mod(st / 3600, 24);

if (gst < 0)
   gst = gst + 24;
end

Contact us