MathGroup Archive 2010

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

Search the Archive

Re: First function debug help

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

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
 ]


      


  • Prev by Date: Re: Convert string list to number list
  • Next by Date: Re: More /.{I->-1} craziness. Schools are conservative. So are
  • Previous by thread: Re: Re: First function debug help
  • Next by thread: Re: Re: First function debug help