@@ -306,7 +306,7 @@ def spa_python(time, latitude, longitude,
306
306
avg. yearly air temperature in degrees C.
307
307
delta_t : float, optional, default 67.0
308
308
Difference between terrestrial time and UT1.
309
- If delta_t is None, uses spa. calculate_deltat
309
+ If delta_t is None, uses :py:func:` calculate_deltat`
310
310
using time.year and time.month from pandas.DatetimeIndex.
311
311
For most simulations the default delta_t is sufficient.
312
312
*Note: delta_t = None will break code using nrel_numba,
@@ -370,7 +370,7 @@ def spa_python(time, latitude, longitude,
370
370
371
371
spa = _spa_python_import (how )
372
372
373
- delta_t = delta_t or spa . calculate_deltat (time .year , time .month )
373
+ delta_t = delta_t or calculate_deltat (time .year , time .month )
374
374
375
375
app_zenith , zenith , app_elevation , elevation , azimuth , eot = \
376
376
spa .solar_position (unixtime , lat , lon , elev , pressure , temperature ,
@@ -412,7 +412,7 @@ def sun_rise_set_transit_spa(times, latitude, longitude, how='numpy',
412
412
to machine code and run them multithreaded.
413
413
delta_t : float, optional, default 67.0
414
414
Difference between terrestrial time and UT1.
415
- If delta_t is None, uses spa. calculate_deltat
415
+ If delta_t is None, uses :py:func:` calculate_deltat`
416
416
using times.year and times.month from pandas.DatetimeIndex.
417
417
For most simulations the default delta_t is sufficient.
418
418
*Note: delta_t = None will break code using nrel_numba,
@@ -449,7 +449,7 @@ def sun_rise_set_transit_spa(times, latitude, longitude, how='numpy',
449
449
450
450
spa = _spa_python_import (how )
451
451
452
- delta_t = delta_t or spa . calculate_deltat (times .year , times .month )
452
+ delta_t = delta_t or calculate_deltat (times .year , times .month )
453
453
454
454
transit , sunrise , sunset = spa .transit_sunrise_sunset (
455
455
unixtime , lat , lon , delta_t , numthreads )
@@ -974,7 +974,7 @@ def nrel_earthsun_distance(time, how='numpy', delta_t=67.0, numthreads=4):
974
974
975
975
delta_t : float, optional, default 67.0
976
976
Difference between terrestrial time and UT1.
977
- If delta_t is None, uses spa. calculate_deltat
977
+ If delta_t is None, uses :py:func:` calculate_deltat`
978
978
using time.year and time.month from pandas.DatetimeIndex.
979
979
For most simulations the default delta_t is sufficient.
980
980
*Note: delta_t = None will break code using nrel_numba,
@@ -1005,7 +1005,7 @@ def nrel_earthsun_distance(time, how='numpy', delta_t=67.0, numthreads=4):
1005
1005
1006
1006
spa = _spa_python_import (how )
1007
1007
1008
- delta_t = delta_t or spa . calculate_deltat (time .year , time .month )
1008
+ delta_t = delta_t or calculate_deltat (time .year , time .month )
1009
1009
1010
1010
dist = spa .earthsun_distance (unixtime , delta_t , numthreads )
1011
1011
@@ -1476,3 +1476,148 @@ def sun_rise_set_transit_geometric(times, latitude, longitude, declination,
1476
1476
sunset = _local_times_from_hours_since_midnight (times , sunset_hour )
1477
1477
transit = _local_times_from_hours_since_midnight (times , transit_hour )
1478
1478
return sunrise , sunset , transit
1479
+
1480
+
1481
+ def calculate_deltat (year , month ):
1482
+ """Calculate the difference between Terrestrial Dynamical Time (TD)
1483
+ and Universal Time (UT).
1484
+
1485
+ Note: This function is not yet compatible for calculations using
1486
+ Numba.
1487
+
1488
+ Parameters
1489
+ ----------
1490
+ year : numeric
1491
+ Calendar year for which to calculate the time offset
1492
+ month : numeric
1493
+ Calendar month (1-12) for which to calculate the time offset
1494
+
1495
+ Returns
1496
+ -------
1497
+ deltat : numeric
1498
+
1499
+ References
1500
+ ----------
1501
+ .. [1] `NASA GSFC: Polynomial Expressions for Delta T (ΔT)
1502
+ <http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html>`_
1503
+ """
1504
+
1505
+ plw = 'Deltat is unknown for years before -1999 and after 3000. ' \
1506
+ 'Delta values will be calculated, but the calculations ' \
1507
+ 'are not intended to be used for these years.'
1508
+
1509
+ try :
1510
+ if np .any ((year > 3000 ) | (year < - 1999 )):
1511
+ warnings .warn (plw )
1512
+ except ValueError :
1513
+ if (year > 3000 ) | (year < - 1999 ):
1514
+ warnings .warn (plw )
1515
+ except TypeError :
1516
+ return 0
1517
+
1518
+ y = year + (month - 0.5 )/ 12
1519
+
1520
+ deltat = np .where (year < - 500 ,
1521
+
1522
+ - 20 + 32 * ((y - 1820 )/ 100 )** 2 , 0 )
1523
+
1524
+ deltat = np .where ((- 500 <= year ) & (year < 500 ),
1525
+
1526
+ 10583.6 - 1014.41 * (y / 100 )
1527
+ + 33.78311 * (y / 100 )** 2
1528
+ - 5.952053 * (y / 100 )** 3
1529
+ - 0.1798452 * (y / 100 )** 4
1530
+ + 0.022174192 * (y / 100 )** 5
1531
+ + 0.0090316521 * (y / 100 )** 6 , deltat )
1532
+
1533
+ deltat = np .where ((500 <= year ) & (year < 1600 ),
1534
+
1535
+ 1574.2 - 556.01 * ((y - 1000 )/ 100 )
1536
+ + 71.23472 * ((y - 1000 )/ 100 )** 2
1537
+ + 0.319781 * ((y - 1000 )/ 100 )** 3
1538
+ - 0.8503463 * ((y - 1000 )/ 100 )** 4
1539
+ - 0.005050998 * ((y - 1000 )/ 100 )** 5
1540
+ + 0.0083572073 * ((y - 1000 )/ 100 )** 6 , deltat )
1541
+
1542
+ deltat = np .where ((1600 <= year ) & (year < 1700 ),
1543
+
1544
+ 120 - 0.9808 * (y - 1600 )
1545
+ - 0.01532 * (y - 1600 )** 2
1546
+ + (y - 1600 )** 3 / 7129 , deltat )
1547
+
1548
+ deltat = np .where ((1700 <= year ) & (year < 1800 ),
1549
+
1550
+ 8.83 + 0.1603 * (y - 1700 )
1551
+ - 0.0059285 * (y - 1700 )** 2
1552
+ + 0.00013336 * (y - 1700 )** 3
1553
+ - (y - 1700 )** 4 / 1174000 , deltat )
1554
+
1555
+ deltat = np .where ((1800 <= year ) & (year < 1860 ),
1556
+
1557
+ 13.72 - 0.332447 * (y - 1800 )
1558
+ + 0.0068612 * (y - 1800 )** 2
1559
+ + 0.0041116 * (y - 1800 )** 3
1560
+ - 0.00037436 * (y - 1800 )** 4
1561
+ + 0.0000121272 * (y - 1800 )** 5
1562
+ - 0.0000001699 * (y - 1800 )** 6
1563
+ + 0.000000000875 * (y - 1800 )** 7 , deltat )
1564
+
1565
+ deltat = np .where ((1860 <= year ) & (year < 1900 ),
1566
+
1567
+ 7.62 + 0.5737 * (y - 1860 )
1568
+ - 0.251754 * (y - 1860 )** 2
1569
+ + 0.01680668 * (y - 1860 )** 3
1570
+ - 0.0004473624 * (y - 1860 )** 4
1571
+ + (y - 1860 )** 5 / 233174 , deltat )
1572
+
1573
+ deltat = np .where ((1900 <= year ) & (year < 1920 ),
1574
+
1575
+ - 2.79 + 1.494119 * (y - 1900 )
1576
+ - 0.0598939 * (y - 1900 )** 2
1577
+ + 0.0061966 * (y - 1900 )** 3
1578
+ - 0.000197 * (y - 1900 )** 4 , deltat )
1579
+
1580
+ deltat = np .where ((1920 <= year ) & (year < 1941 ),
1581
+
1582
+ 21.20 + 0.84493 * (y - 1920 )
1583
+ - 0.076100 * (y - 1920 )** 2
1584
+ + 0.0020936 * (y - 1920 )** 3 , deltat )
1585
+
1586
+ deltat = np .where ((1941 <= year ) & (year < 1961 ),
1587
+
1588
+ 29.07 + 0.407 * (y - 1950 )
1589
+ - (y - 1950 )** 2 / 233
1590
+ + (y - 1950 )** 3 / 2547 , deltat )
1591
+
1592
+ deltat = np .where ((1961 <= year ) & (year < 1986 ),
1593
+
1594
+ 45.45 + 1.067 * (y - 1975 )
1595
+ - (y - 1975 )** 2 / 260
1596
+ - (y - 1975 )** 3 / 718 , deltat )
1597
+
1598
+ deltat = np .where ((1986 <= year ) & (year < 2005 ),
1599
+
1600
+ 63.86 + 0.3345 * (y - 2000 )
1601
+ - 0.060374 * (y - 2000 )** 2
1602
+ + 0.0017275 * (y - 2000 )** 3
1603
+ + 0.000651814 * (y - 2000 )** 4
1604
+ + 0.00002373599 * (y - 2000 )** 5 , deltat )
1605
+
1606
+ deltat = np .where ((2005 <= year ) & (year < 2050 ),
1607
+
1608
+ 62.92 + 0.32217 * (y - 2000 )
1609
+ + 0.005589 * (y - 2000 )** 2 , deltat )
1610
+
1611
+ deltat = np .where ((2050 <= year ) & (year < 2150 ),
1612
+
1613
+ - 20 + 32 * ((y - 1820 )/ 100 )** 2
1614
+ - 0.5628 * (2150 - y ), deltat )
1615
+
1616
+ deltat = np .where (year >= 2150 ,
1617
+
1618
+ - 20 + 32 * ((y - 1820 )/ 100 )** 2 , deltat )
1619
+
1620
+ deltat = deltat .item () if np .isscalar (year ) & np .isscalar (month )\
1621
+ else deltat
1622
+
1623
+ return deltat
0 commit comments