Code covered by the BSD License  

Highlights from
A MATLAB Script for Predicting Lunar Occultations

A MATLAB Script for Predicting Lunar Occultations

by

 

07 Dec 2012 (Updated )

Predict the local circumstances of lunar occultations of a planet or star.

occprint(iflag, jdutc)
function occprint(iflag, jdutc)

% print occultation conditions 

% required by occult.m

% Celestial Computing with MATLAB

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

global azimuth elevation jdsaved

% convert julian day to calendar date
% and universal time strings

[cdstr, utstr] = jd2str(jdutc);

if (iflag == 1)
    
   fprintf('\nbegin lunar occultation');
   fprintf('\n-----------------------\n\n');
   
   jdsaved = jdutc;
   
end

if (iflag == 2)
    
   fprintf('\nend lunar occultation');
   fprintf('\n---------------------\n\n');
   
end

fprintf('calendar date             ');

disp(cdstr);

fprintf('\nuniversal time            ');

disp(utstr);

fprintf('\n');

fprintf('UTC Julian date           %10.4f \n', jdutc);

% display topocentric angles and slant range

[d, m, s, azimstr] = deg2dms (azimuth);

[d, m, s, elevstr] = deg2dms (elevation);

fprintf('\nlunar azimuth angle        ');

disp(azimstr);

fprintf('\nlunar elevation angle      ');

disp(elevstr);

% determine event duration

if (iflag == 2)
    
   deltat = 24.0 * (jdutc - jdsaved);
   
   [h, m, s, hmsstr] = hrs2hms (deltat);
   
   fprintf('\n\nevent duration             ');
   
   disp(hmsstr);
   
end

Contact us