MathGroup Archive 2010

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

Search the Archive

Re: First function debug help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106667] Re: First function debug help
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Wed, 20 Jan 2010 06:51:10 -0500 (EST)
  • References: <hj40nd$ses$1@smc.vnet.net>

Hi,

> 

> 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 ]

The problem is that your function definition works only, if month and
minute have the same value. You should use different names for them!

hth,

albert


  • Prev by Date: exporting numerical data
  • Next by Date: Re: Initialization problem in a DynamicModule
  • Previous by thread: Re: Re: First function debug help
  • Next by thread: Re: More /.{I->-1} craziness. Schools are conservative. So are