Skip to content
Snippets Groups Projects
Commit 61eea945 authored by leprob001's avatar leprob001
Browse files

Demystified dmy2rd and hms2rd. Updated documentation in +convert/rafosJulianDay

parent dbee209b
No related branches found
No related tags found
No related merge requests found
function rjul = dmy2rd(day,mon,yr) function [rafosJulianDay] = dmy2rd(pDay, pMonth, pYear)
% %DMY2RD Converts the given parameters to rafos julian day.
%function rjul = dmy2rd(day,month,yr)
%
% converts (day, month, year) to RAFOS JULIAN day (rjul) % converts (day, month, year) to RAFOS JULIAN day (rjul)
% RAFOS JULIAN day = julian day (ref. to 24 nov 4713BC) - 2440000 % RAFOS JULIAN day = julian day (ref. to 24 nov 4713BC) - 2440000
% %
...@@ -11,27 +9,49 @@ function rjul = dmy2rd(day,mon,yr) ...@@ -11,27 +9,49 @@ function rjul = dmy2rd(day,mon,yr)
% and converted to RAFOS JULIAN day 20.03.91 kst % and converted to RAFOS JULIAN day 20.03.91 kst
% This routine is valid forever .... % This routine is valid forever ....
% %
% NOTE: this RAFOS JULIAN day = old ARGOS day - 6718 + 1 % NOTE: this RAFOS JULIAN day = old ARGOS day - 6718 + 1
%
% NOTE: The rafos day has been redefined, to shorten numbers.
% It has been:
% rafosJulianDay = rafosJulianDay - 2440000
% but is now:
% rafosJulianDay = rafosJulianDay - 2451545
%
% Parameters:
% pDay (int) The day.
% pMonth (int) The month.
% pYear (int) The year.
%
% Returns:
% rafosJulianDay (int) The converted rafos julian day.
%% Parameter check
if (nargin == 1) if (nargin == 1)
d = day; d = pDay;
day = d(:,1); pDay = d(:,1);
mon = d(:,2); pMonth = d(:,2);
yr = d(:,3); pYear = d(:,3);
end end
day = day(:); mon = mon(:); yr = yr(:);
gttwo = find( mon > 2 ); %% Setup variables
letwo = find( mon < 3 ); pDay = pDay(:);
mon(gttwo) = mon(gttwo) - 3; pMonth = pMonth(:);
mon(letwo) = mon(letwo) + 9; pYear = pYear(:);
yr(letwo) = yr(letwo) - 1;
%% Convert
gttwo = find( pMonth > 2 );
letwo = find( pMonth < 3 );
pMonth(gttwo) = pMonth(gttwo) - 3;
pMonth(letwo) = pMonth(letwo) + 9;
pYear(letwo) = pYear(letwo) - 1;
ic = floor( yr / 100 ); ic = floor( pYear / 100 );
iy = yr - 100*ic; iy = pYear - 100 * ic;
rjul = floor((146097*ic)/4) + floor((1461*iy)/4) + floor((153*mon+2)/5) ... rafosJulianDay = floor((146097 * ic) / 4) ...
+ day + 1721119; + floor((1461 * iy) / 4) ...
+ floor((153 * pMonth + 2) / 5) ...
+ pDay ...
+ 1721119;
% rjul = rjul - 2440000; rafosJulianDay = rafosJulianDay - 2451545;
% OB redefined rafos day, to shorten numbers \ No newline at end of file
rjul = rjul - 2451545;
\ No newline at end of file
function rd=hms2rd(h,m,s) function [rafosJulianDay] = hms2rd(pHour, pMinute, pSecond)
%HMS2RD Convert hours minutes seconds into rafos day %HMS2RD Converts hours, minutes and seconds into rafos day.
%
% Parameters:
% pHour (int) The hour.
% pMinute (int) The minute.
% pSecond (int) The second.
%
% Returns:
% rafosJulianDay (double) The converted time.
% sz=size(hms); %% Convert
% if sz(2)~=3 hours = pHour * 60 * 60;
% hms=hms'; minutes = pMinute * 60;
% end seconds = pSecond;
hours=h*60*60; dayInSeconds = 24 * 60 * 60;
minutes=m*60;
seconds=s;
dayins=24*60*60; rafosJulianDay = (hours + minutes + seconds) / dayInSeconds;
rd=(hours+minutes+seconds)/dayins; end
\ No newline at end of file
% end hms2rd
...@@ -3,6 +3,9 @@ function [ddmmyyyy] = rafosJulianDay(pRafosJulianDay) ...@@ -3,6 +3,9 @@ function [ddmmyyyy] = rafosJulianDay(pRafosJulianDay)
% %
% Parameters: % Parameters:
% pRafosJulianDay (double) The input time format. % pRafosJulianDay (double) The input time format.
%
% Returns:
% ddmmyyyy (matrix) The 1D vector, containing day month and year.
offset = 2451545; offset = 2451545;
......
...@@ -31,6 +31,9 @@ end ...@@ -31,6 +31,9 @@ end
signalLength = pFloatRfb.FLOAT.signal_length; signalLength = pFloatRfb.FLOAT.signal_length;
floatOffset = pFloatRfb.FLOAT.offset(:, 6); floatOffset = pFloatRfb.FLOAT.offset(:, 6);
if size(floatOffset, 1) == 1
floatOffset = [floatOffset; NaN];
end
schedule = pFloatRfb.FLOAT.schedule; schedule = pFloatRfb.FLOAT.schedule;
step = schedule / 24; step = schedule / 24;
cycle = pFloatRfb.FLOAT.cycle; cycle = pFloatRfb.FLOAT.cycle;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment