Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Number output formatting was Re: First function debug help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106697] Number output formatting was Re: First function debug help
  • From: Canopus56 <canopus56 at yahoo.com>
  • Date: Thu, 21 Jan 2010 04:54:05 -0500 (EST)

Dear Group, 
> 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 

Jumping back to my 1-18 message, any ideas on how to force the formatting of the number output of the function. 

Thanks, Kurt 

----- Original Message ----
From: Canopus56 <canopus56 at yahoo.com>
To: mathgroup at smc.vnet.net
Sent: Mon, January 18, 2010 7:13:03 PM
Subject: [mg106697] Re: First function debug help

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: Re: Convert string list to number list
  • Next by Date: Re: Re: Initialization problem in a
  • Previous by thread: Washington DC Area Mathematica Special Interest Group
  • Next by thread: Re: Number output formatting was Re: First function debug help