gregorian_jd_tests

class contrib.misc.gregorian_jd_tests.JulianPeriodTests[source]

Bases: object

GREGORIAN_EPOCH = 1721423.5
HR(x)
JULIAN_LEAP_YEAR(year)
JULIAN_YEAR = 365.25
MEAN_TROPICAL_YEAR = 365.2421897
MN(x)
MONTHS = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
ROUNDING_PLACES = 6
SEC(x)
TEST_DATES = ((-4712, 1, 1.5), (1, 1, 1), (1, 3, 20), (2, 1, 1), (3, 1, 1), (4, 1, 1), (4, 12, 31), (5, 1, 1), (6, 1, 1), (8, 1, 1), (9, 1, 1), (100, 2, 28), (100, 2, 29), (100, 3, 1), (128, 2, 28), (128, 2, 29), (128, 3, 1), (200, 2, 28), (200, 2, 29), (200, 3, 1), (256, 2, 28), (256, 2, 29), (256, 3, 1), (300, 2, 28), (300, 2, 29), (300, 3, 1), (384, 2, 28), (384, 2, 29), (384, 3, 1), (400, 2, 28), (400, 2, 29), (400, 3, 1), (800, 1, 1), (800, 12, 31), (1200, 1, 1), (1200, 12, 31), (1300, 1, 1), (1300, 12, 31), (1400, 1, 1), (1400, 12, 31), (1500, 1, 1), (1500, 12, 31), (1582, 10, 4), (1582, 10, 5), (1582, 10, 6), (1582, 10, 7), (1582, 10, 8), (1582, 10, 9), (1582, 10, 10), (1582, 10, 11), (1582, 10, 12), (1582, 10, 13), (1582, 10, 14), (1582, 10, 15), (1844, 3, 20), (1957, 10, 4.81), (2020, 12, 7), (2020, 12, 7.1), (2020, 12, 7.25), (2020, 12, 7.49), (2020, 12, 8), (2024, 3, 20), (3004, 12, 31))
_days_in_years(y, alt=False)[source]
analyze(options)[source]

Check that Gregorian dates can be converted to a Julian Period day then back to a Gregorian dates correctly.

-a with optional -A for alternate leap year calculation.

analyze_1(options)[source]

Compare Meeus’ and my algorithms showing differences.

-1 with optional -A for alternate leap year calculation.
-S and -E are mandatory.

If the last column shows anything other than 0.0 then there are inconsistencies.

This test will display, to stderr a progress counter indicating every 500 years.

analyze_2(options)[source]

Check that any Gregorian date can be converted to a Julian Period day and then back again to a Gregorian date correctly. This only tests my algorithm.

If there is any data returned except the heading then there are errors in the conversion.

-2 with optional -A for alternate leap year calculation.
-S and -E are mandatory.

This test will display, to stderr a progress counter indicating every 500 years.

compare_leap_year_algorithms(year=None)[source]

Compare the two leap year algorithms.

If -c == 0 then all dates from 1 to 3004 are processed.
If -c == any year, then only that year is processed.

The table below shows the differences between the 4, 10, 400 and 4, 128 algorithms. Notice that the dates up to 1482-10-15 are not in sync with each other.

Year

4, 10, 400

4, 128

std

alt

100

0

1

1

128

1

0

1

200

0

1

2

256

1

0

2

300

0

1

3

384

1

0

3

500

0

1

4

512

1

0

4

600

0

1

5

640

1

0

5

700

0

1

6

768

1

0

6

896

1

0

7

900

0

1

7

1000

0

1

8

1024

1

0

8

1100

0

1

9

1152

1

0

9

1280

1

0

10

1300

0

1

10

1400

0

1

11

1408

1

0

11

1500

0

1

1536

1

0

1664

1

0

1700

0

1

1792

1

0

1800

0

1

1900

0

1

1920

1

0

2048

1

0

2100

0

1

2176

1

0

2200

0

1

2300

0

1

2304

1

0

2432

1

0

2500

0

1

2560

1

0

2600

0

1

2688

1

0

2700

0

1

2816

1

0

2900

0

1

2944

1

0

3000

0

1

consecutive_days(options)[source]

Test that the Julian Period days are consecutive. i.e. no skipping or doubling up. Should produce no output if working correctly.

-k With optional -A for alternate leap year calculation.
-S and -E are mandatory.
If -J is used then the test is for consecutive Julian Period days.
If -JM is used the test is for consecutive Julian Period days using
Meeus’ algorithm.
If -G is used the test is for consecutive Julian Period days using
my algorithm.

Some tests will display, to stderr a progress counter indicating every 500 years.

date_from_ymdhms(date: tuple) tuple[source]

Convert (year, month, day, hour, minute, second) into a (year, month, day.partial) date.

gregorian_date_from_jd_0(jd)[source]

Convert Julian day to Gregorian date using the Meeus algorithm.

gregorian_date_from_jd_1(jd, alt=False)[source]

My algorithm

jd_from_gregorian_date_0(g_date, alt=False)[source]

The JDs below are all in the Meeus Histroically correct algorithm. The alt keyword does nothing.

US Naval Observatory Julian Date page:

There are 12 years that skip a day. Pope Gregory only compensated for 10 of them. The JDs below are all in the non-proleptic historic (Meeus) algorithm and signify the beginning of the day.

Gregorian JD offsets

Valid or Invalid Day(s)

Valid Day JD

Next Valid or Invalid Day(s)

Next Valid Day JD

Offset

(100, 2, 28)

1757640.5

(100, 3, 1)

1757642.5

1

(100, 2, 29)

1757641.5

Invalid

(200, 2, 28)

1794165.5

(200, 3, 1)

1794167.5

2

(200, 2, 29)

1794166.5

Invalid

(300, 2, 28)

1830690.5

(300, 3, 1)

1830692.5

3

(300, 2, 29)

1830691.5

Invalid

(500, 2, 28)

1903740.5

(500, 3, 1)

1903742.5

4

(500, 2, 29)

1903741.5

Invalid

(600, 2, 28)

1940265.5

(600, 3, 1)

1940267.5

5

(600, 2, 29)

1940266.5

Invalid

(700, 2, 28)

1976790.5

(700, 3, 1)

1976792.5

6

(700, 2, 29)

1976791.5

Invalid

(900, 2, 28)

2049840.5

(900, 3, 1)

2049842.5

7

(900, 2, 29)

2049841.5

Invalid

(1000, 2, 28)

2086365.5

(1000, 3, 1)

2086367.5

8

(1000, 2, 29)

2086366.5

Invalid

(1100, 2, 28)

2122890.5

(1100, 3, 1)

2122892.5

9

(1100, 2, 29)

2122891.5

Invalid

(1300, 2, 28)

2195940.5

(1300, 3, 1)

2195942.5

10

(1300, 2, 29)

2195941.5

Invalid

(1400, 2, 28)

2232465.5

(1400, 3, 1)

2232467.5

11

(1400, 2, 29)

2232466.5

Invalid

(1500, 2, 28)

2268990.5

(1500, 3, 1)

2268992.5

12

(1500, 2, 29)

2268991.5

Invalid

(1582, 10, 4)

2299159.5

(1582, 10, 15)

2299160.5

(1582, 10, 5) to (1582, 10, 14)

2299160.5 to 2299169.5

Invalid

Only adjusted 10 days

(1582, 10, 15)

2299160.5

(1582, 10, 16)

2299161.5

2

jd_from_gregorian_date_1(g_date, alt=False)[source]

My algorithm

julian_day_with_ut_sunset(options)[source]

Generate a list of Julian days with ut sunset data. This must be done in the historically correct Julian day count or the sunsets will not be correct. Sunsets found on https://gml.noaa.gov/grad/solcalc/ set to UTC coordinates.

The output is used in some Badí tests.

-j with -S and -E which are mandatory.