MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

First function debug help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106627] First function debug help
  • From: Canopus56 <canopus56 at yahoo.com>
  • Date: Tue, 19 Jan 2010 05:13:22 -0500 (EST)

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
 ]


  • Prev by Date: Re: More /.{I->-1} craziness, con brio
  • Next by Date: Re: More /.{I->-1} craziness, con brio
  • Previous by thread: Re: Re: Initialization problem in a DynamicModule
  • Next by thread: Re: First function debug help