From: DrMajorBob on
Actually, BOTH functions fail, and for the same reason, nothing to do with
h.

Since m_ is used twice in each function signature, once for months and
again for minutes, the functions only work when months = seconds. A couple
of examples:

julianDayModified[y_, m_, d_, h_, m_,
s_] := (b =
2 - IntegerPart[y/100] + IntegerPart[IntegerPart[y/100]/4];
f = d + (h/24) + (m/(24*60)) + (s/(24*3600));
jd = IntegerPart[(365.25*(y + 4716))] +
IntegerPart[(30.6001*(m + 1))] + d + b - 1524.5;
mjd = jd - 2400000.5;
mjd)
julianDayModified[2010, 1, 1, 12, 0, 0]

julianDayModified[2010, 1, 1, 12, 0, 0]

(no evaluation, because no match)

julianDayModified[2010, 1, 1, 12, 1, 0]

55195.

Instead, try something like:

Clear(a)julianDayModified
julianDayModified[y_, month_, d_, h_, minute_,
s_] := (b =
2 - IntegerPart[y/100] + IntegerPart[IntegerPart[y/100]/4];
f = d + (h/24) + (minute/(24*60)) + (s/(24*3600));
jd = IntegerPart[(365.25*(y + 4716))] +
IntegerPart[(30.6001*(month + 1))] + d + b - 1524.5;
mjd = jd - 2400000.5;
mjd)

Bobby

On Wed, 20 Jan 2010 05:50:48 -0600, Herman Kuun <oomkoos1(a)gmail.com> wrote:

> The hour input 'h_' is not used in the defined function.
>
> Substitute
> d = d + ((m * 60 )/ ( 24 * 60 )) + ((s * 3600)/(24 * 3600));
> with
> f = d + (h/24) + (m/(24*60)) + (s/(24*3600));
>
> Also try make it a habit to start your own variable and function
> definitions
> in lower case. Mathematica uses upper case exclusively. Save you lots of
> frustration in the future.
>
> This will calculate corectly:
> ------------------------------------------------------------------------------------------------------------
>
> julianDayModified[y_, m_, d_, h_, m_, s_] := (
>
> b = 2 - IntegerPart[y/100] + IntegerPart[IntegerPart[y/100]/4];
>
> f = d + (h/24) + (m/(24*60)) + (s/(24*3600));
>
> jd = IntegerPart[(365.25*(y + 4716))] +
> IntegerPart[(30.6001*(m + 1))] + d + b - 1524.5;
>
> mjd = jd - 2400000.5;
>
> mjd
>
> )
>
> julianDayModified[2010, 1, 1, 12, 0, 0]
>
> 55164.
>
> ---------------------------------------------------------------------------------------------------------------
> Best
> Herman
>
> On Tue, Jan 19, 2010 at 12:13 PM, Canopus56 <canopus56(a)yahoo.com> wrote:
>
>> I took a stab at writing my first function - converting a system
>> formatted
>> list date into a Modified Julian Day. The function appears to be
>> written
>> properly, but does not return anything.
>>
>> Any help in debugging it would be appreciated.
>>
>> Ideally, I would like to send a date-time list in the form
>> {y,m,d,h,m,s} to
>> the function and have the Julian Day returned.
>>
>> Thanks for your help - Kurt
>>
>> (* This function computes the Modified Julian Day from a \
>> system formatted date. Domain is restricted to Greogorian dates. \
>> Source: Meeus. 1998. Chap. 7. Astronomical Alogrithms. *)
>> (* fractionalize the day value *)
>>
>> JulianDayModified[y_, m_, d_, h_, m_, s_] := (
>> B = 2 - IntegerPart[y/100] + IntegerPart[IntegerPart[y/100]/4];
>> d = d + ((m * 60 )/ ( 24 * 60 )) + ((s * 3600)/(24 * 3600));
>> JD = IntegerPart[(365.25*(y + 4716))] +
>> IntegerPart[(30.6001*(m + 1 ))] + d + b - 1524.5;
>> MJD = JD - 2400000.5;
>> MJD
>> )
>>
>> JulianDayModified[2010, 1, 1, 12, 0, 0]
>>
>> Returns the string "
>> JulianDayModified[2010, 1, 1, 12, 0, 0]"
>>
>> and not the computed date
>>
>> Also tried it this way with the Module statement with no change in the
>> result:
>>
>> JulianDayModified[y_, m_, d_, h_, m_, s_] := Module[{B, JD, MJD},
>> B = 2 - IntegerPart[y/100] + IntegerPart[IntegerPart[y/100]/4];
>> d = d + ((m*60)/(24*60)) + ((s*3600)/(24*3600));
>> JD = IntegerPart[(365.25*(y + 4716))] +
>> IntegerPart[(30.6001*(m + 1))] + d + b - 1524.5;
>> MJD = JD - 2400000.5;
>> MJD
>> ]
>>
>
>
>


--
DrMajorBob(a)yahoo.com

From: DrMajorBob on
JulianDayNumber[{2006, 1, 21, 15, 22, 36}]
AccountingForm[%, 10]

2.45376*10^6

2453755.141

Bobby

On Tue, 19 Jan 2010 04:13:47 -0600, Canopus56 <canopus56(a)yahoo.com> wrote:

> Please disregard the prior message. I was able to debug the function and
> get it running by applying a little more brain power. The final
> functions are appended.
>
> I could use some help in coaxing the JulianDayNumber output from an
> exponential form, e.g. -
>
> 2.43612*10^6
>
> into the form:
>
> 2436116.31
>
> Thanks again for all your help.
>
> - Kurt
>
>
> JulianDayNumber[{y_, m_, d_, h_, mins_, s_}] := Module[
> {b, f, JD, MJD},
> (* This function computes the Modified Julian Day from a system \
> formatted date. Domain is restricted to Greogorian dates. Source:
> Meeus. 1998. Chap. 7. Astronomical Alogrithms. p.
> 61. Test data is for launch of Sputnik on {1957,10,4,19,26,
> 24} which should yield JD2436116 .31 *)
> b = 2 - IntegerPart[y/100] + IntegerPart[IntegerPart[y/100]/4];
> (* fractionalize the day value *)
> f = d + (h/24) + (mins / ( 24 * 60 )) + (s /(24 * 3600));
> JD = IntegerPart[(365.25 *(y + 4716))] +
> IntegerPart[(30.6001*(m + 1))] + f + b - 1524.5;
> MJD = JD - 2400000.5;
> (* NumberForm[JD,{15,10}] *)
> JD
> ]
>
> JulianDayModified[{y_, m_, d_, h_, mins_, s_}] := Module[
> {b, f, JD, MJD},
> (* This function computes the Modified Julian Day from a system \
> formatted date. Domain is restricted to Greogorian dates. Source:
> Meeus. 1998. Chap. 7. Astronomical Alogrithms. p.
> 61. Test data is for launch of Sputnik on {1957,10,4,19,26,
> 24} which should yield MJD36115 .81 *)
> b = 2 - IntegerPart[y/100] + IntegerPart[IntegerPart[y/100]/4];
> (* fractionalize the day value *)
> f = d + (h/24) + (mins / ( 24 * 60 )) + (s /(24 * 3600));
> JD = IntegerPart[(365.25 *(y + 4716))] +
> IntegerPart[(30.6001*(m + 1))] + f + b - 1524.5;
> MJD = JD - 2400000.5;
> (* NumberForm[MJD,{15,5}] *)
> MJD
> ]
>
>
>


--
DrMajorBob(a)yahoo.com