From: Canopus56 on 19 Jan 2010 05:15 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 ]
From: Canopus56 on 19 Jan 2010 05:15 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 ]
From: Herman Kuun on 20 Jan 2010 06:50 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(a)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
From: Albert Retey on 20 Jan 2010 06:50 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
From: Herman Kuun on 21 Jan 2010 04:53 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(a)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(a)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(a)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(a)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(a)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
|
Next
|
Last
Pages: 1 2 Prev: Hessian Matrix of a Numerical Defined Function Next: Contour plot with color scale |