Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: First function debug help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106665] Re: [mg106627] First function debug help
  • From: Herman Kuun <oomkoos1 at gmail.com>
  • Date: Wed, 20 Jan 2010 06:50:48 -0500 (EST)
  • References: <201001191013.FAA29027@smc.vnet.net>

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



-- 
Best
Herman
------------------------------- CUT -----------------------------
The 10 commandments of Network Administration ( www.newsforge.org)
I. Thou shalt make regular and complete backups
II. Thou shalt establish absolute trust in thy servers
III. Thou shalt be the first to know when something goes down
IV. Thou shalt keep server logs on everything
V. Thou shalt document complete and effective policies and procedures
VI. Thou shalt know what cable goes where
VII. Thou shalt use encryption for insecure services
VIII. Thou shalt not lose system logs when a server dies
IX. Thou shalt know the openings into your servers
X. Thou shalt not waste time doing repetitive and mundane tasks



  • Prev by Date: Re: Plotting date-time series in 3D how to handle date-time to plot
  • Next by Date: Re: Initialization problem in a DynamicModule
  • Previous by thread: First function debug help
  • Next by thread: Re: Re: First function debug help