MathGroup Archive 2010

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

Search the Archive

Re: Re: First function debug help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106693] Re: [mg106665] Re: [mg106627] First function debug help
  • From: Herman Kuun <oomkoos1 at gmail.com>
  • Date: Thu, 21 Jan 2010 04:53:19 -0500 (EST)
  • References: <201001191013.FAA29027@smc.vnet.net>

Yep. I looked-up the jDM algorithme and check what it is all about. Thx.

On Wed, Jan 20, 2010 at 8:47 PM, DrMajorBob <btreat1 at austin.rr.com> wrote:

> 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@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 at 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 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
>>>  ]
>>>
>>>
>>
>>
>>
>
> --
> DrMajorBob at yahoo.com
>



-- 
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: More /.{I->-1} craziness. Schools are conservative. So are [people]
  • Next by Date: Re: Re: Initialization problem in a DynamicModule
  • Previous by thread: Re: Re: First function debug help
  • Next by thread: Re: First function debug help