Re: [Kinda OT] Could somebody double check this?

2003-10-17 Thread Joshua Hoblitt
> How about to refactor DateTime RD code into another
> module? There is already enough use for rd, minutes
> and seconds in other calendars to justify having a
> "base module".

I think we've been over this before haven't we?  I thought the consensus was that a 
base class would be a good idea but that DateTime.pm should be left intact.  It makes 
more sense for a base class to 'grow up' independent of DT and if it makes sense (it's 
mature, minimal performance hit for using it, etc) DT can then be refactored to use it.

-J

--


Re: [Kinda OT] Could somebody double check this?

2003-10-13 Thread Daisuke Maki
Okay, so now I've done a bit of tweaking to my solar longitude 
calculations, and I'm now off 0.99 degrees on average from Calendrical 
Calculations book (And you'll also notice an overflow problem somewhere 
in the middle)

[EMAIL PROTECTED] lib]$ perl test.pl
  Gergorian Date | R.D |  Sol-Lgtd. | Sol-Lgtd (table) |
 -586/07/25 12:00:00 | -214193 | 120.448974 | 119.47497500 |
 -168/12/06 12:00:00 |  -61387 | 255.278332 | 254.25239000 |
   70/09/25 12:00:00 |   25469 | 182.439580 | 181.43526000 |
  135/10/03 12:00:00 |   49217 | 189.669351 | 188.66209300 |
  470/01/09 12:00:00 |  171307 | 290.109198 | 289.08940300 |
  576/05/21 12:00:00 |  210155 |  60.078742 |  59.11935700 |
  694/11/11 12:00:00 |  253427 | 229.336324 | 228.31649800 |
 1943/10/08 12:00:00 |  709580 |   0.00 | 193.34789200 |
 1992/03/18 12:00:00 |  727274 | 358.150581 | 357.15126300 |
 2094/07/19 12:00:00 |  764652 | 117.398592 | 116.43930100 |
However, I found this site: http://www.moshier.net/aadoc.html.
When I ran this program and got the number for the Sun, most of my 
calculations were within 0.05 degrees difference! So now I'm trying to 
decide who to trust...

Does anybody know if there's a good table/calculator for this kind of 
numbers that I can use to check my results? I'm also looking one for 
lunar longitudes (I've written lunar_longitude() as well, but that's 
about 13 degrees off from Calendrical Calculations :(

--d




RE: [Kinda OT] Could somebody double check this?

2003-10-13 Thread Hill, Ronald

Hi Maki,

[snipped]

[Ronald Hill Wrote] 
> > This is correct, there was talk of doing this however, it 
> > is not easy. The last I heard, there was work on getting 
> > the SLA library released under the LGPL. 
> > (hopefully this will include a windows port of the library)
> > This library has all of the functions needed for lunisolar 
> > calenders.
> 
[Maki Daisuke Wrote]
> Is this going to happen anytime soon, or is it just an idea floating 
> around? If it's going to take a while, I might just go ahead 
> and take a stab at it anyway.
> 
> --d

I have no idea how long this will take. I just checked my archives
and it seems that the SLALIB is lgpl'ed (fortran version only).
The only problem with this is that not many people have a fortran compiler
for windows :(

Anyway, I think you should take a stab at it. I did at one time create
a sun position perl module ( I was working with Henry Sobotka on this)
However, I have not done any work on it for quite some time.

I hope this helps.

Ron Hill


RE: [Kinda OT] Could somebody double check this?

2003-10-13 Thread Hill, Ronald

Hi Maki,

> 
> Hi, dt-ers.
> 
> I've been lurking on this list for some time now, and so far I
> understand that while a few people have attempted, nobody has come up
> with a lunar, solar, or lunisolar calenders (at least I don't remember
> seeing it on this list).

This is correct, there was talk of doing this however, it is not easy.
The last I heard, there was work on getting the SLA library released
under the LGPL. (hopefully this will include a windows port of the library)
This library has all of the functions needed for lunisolar calenders.

Ron Hill


[Kinda OT] Could somebody double check this?

2003-10-11 Thread Daisuke Maki
Hi, dt-ers.

I've been lurking on this list for some time now, and so far I
understand that while a few people have attempted, nobody has come up
with a lunar, solar, or lunisolar calenders (at least I don't remember
seeing it on this list). And so I was just fooling around with some code
to see if I can at least start creating some of the basic building
blocks for it.

# And if somebody already has implemented this, please let me know so
# I don't waste time ;)

My first stab at it was implementing the function to get the solar
longitude at time t, from [1] p.182. I've done it, and I'm rather proud
of the fact that I actually took the time to understand all this with no
prior knowledge of astronomical calculations, but the thing is, the
results are a bit off:

[EMAIL PROTECTED] lib]$ perl test.pl
   R.D.   | Solar Longitude | Solar Longitude (from table) |
  -214193 | 119.964425 | 119.474975
   -61387 | 254.767876 | 254.252390
25469 | 181.939866 | 181.435260
49217 | 189.168174 | 188.662093
   171307 | 289.601843 | 289.089403
   210155 | 59.601590 | 59.119357
   253427 | 228.828880 | 228.316498
[EMAIL PROTECTED] lib]$

The numbers are consistently off by 0.5 degrees or so. eek.
This must be something so stupid in my code, but I've been looking at
the code for way too long. If anybody notices anything wrong, I would
appreciate it. A lot.

I have two files attatched. Astro::Sun is the module that implements the
logic, and test.pl generates the partial table from [1] p.400 (errata 285).

To whomever that might take a look at this code, I thank you very much
in advance.

--d

P.S. please don't bother too much with the module naming. That's just
temporary...

[1] Edward M. Reingold, Nachum Dershowitz
   "Calendrical Calculations (Millenium Edition)", 2nd ed.
Cambridge University Press, Cambridge, UK 2002
# REFERENCES:
# [1] Edward M. Reingold, Nachum Dershowitz
#"Calendrical Calculations (Millenium Edition)", 2nd ed.
# Cambridge University Press, Cambridge, UK 2002

package Astro::Sun;
use strict;
use DateTime;
use Math::Trig qw(deg2rad);

# I got the following from (DateTime->new(...)->utc_rd_values)[0]
use constant RD_1900_JAN_1 => 693596;
use constant RD_1810_JAN_1 => 660724;
use constant RD_MOMENT_J2000 => 730120.5;

# [1] Table 12.1 p.183 (zero-padded to align veritcally)
use constant SOLAR_LONGITUDE_ARGS => [
#  X  Y Z
# left side of table 12.1
[ 403406, 270.54861,  0.9287892 ],
[ 119433,  63.91854,  35999.4089666 ],
[   3891, 317.84300,  71998.2026100 ],
[   1721, 240.05200,  36000.3572600 ],
[350, 247.23000,  32964.4678000 ],
[314, 297.82000, 445267.1117000 ],
[242, 166.79000,  3.1008000 ],
[158,   3.5,-19.9739000 ],
[129, 182.95000,   9038.0293000 ],
[ 99,  29.8,  33718.148 ],
[ 86, 249.2,  -2280.773 ],
[ 72, 257.8,  31556.493 ],
[ 64,  69.9,   9037.750 ],
[ 38, 197.1,  -.176 ],
[ 32,  65.3,  67555.316 ],
[ 28, 341.5,  -4561.540 ],
[ 27,  98.5,   1221.655 ],
[ 24, 110.0,  31437.369 ],
[ 21, 342.6, -31931.757 ],
[ 18, 256.1,   1221.999 ],
[ 14, 242.9,  -4442.039 ],
[ 13, 151.8,119.066 ],
[ 12,  53.3, -4.578 ],
[ 10, 205.7,-39.127 ],
[ 10, 146.1,  90073.778 ],

# right side of table 12.1
[ 195207, 340.19128,  35999.1376958 ],
[ 112392, 331.26220,  35998.7287385 ],
[   2819,  86.63100,  71998.4403000 ],
[660, 310.26000,  71997.4812000 ],
[334, 260.87000,-19.441 ],
[268, 343.14000,  45036.884 ],
[234,  81.53000,  22518.4434000 ],
[132, 132.75000,  65928.9345000 ],
[114, 162.03000,   3034.7684000 ],
[ 93, 266.4,   3034.448 ],
[ 78, 157.6,  29929.992 ],
[ 68, 185.1,149.588 ],
[ 46,   8.0, 107997.405 ],
[ 37, 250.4,151.771 ],
[ 29, 162.7,  31556.080 ],
[ 27, 291.6, 107996.706 ],
[ 25, 146.7,  62894.167 ],
[ 21,   5.2,  14578.298 ],
[ 20, 230.9,  34777.243 ],
[ 17,  45.3,  62894.511 ],
[ 13, 115.2, 107997.909 ],
[ 13, 285.3,  16859.071 ],
[ 10, 126.6,  26895.292 ],
[ 10,  85.9,  12297.536 ]
];


# [1] p.19
sub _dt_to_moment
{
my $dt = shift;
my($rd, $seconds) = $dt->utc_rd_values;
($rd + $seconds / (24 * 3600));
}

# [1] p172
sub _dynamical_moment_from_dt
{
my $dt = shift;
_dt_to_moment($dt) + ephemeris_correction($dt);
}

# [1] p171 + errata 158
sub ephemeris_correction
{
my $dt = shift;

# we need a gregorian calendar, so make sure $dt is just 'DateTime'
$dt = DateTime->