Commit 4538bef
ENH: geometric calculations for sunrise, sunset, and transit (#583)
* add analytical methods from Frank Vignola's book for sunrise, sunset, and sun transit times
* ENH: remove test data file for sunrise/sunset/transit
* use hardcoded values for 10-20 expected values
* remove DIRNAME, etc
* make stickler happy
* no rst markup in numpydoc parameters
* add references to duffie/beckman and Frank Vignola
* get pytz timezone info first so it's not weird
* add returns to docstring
* ENH: PERF: use numpy instead of loop to improve performance
* add one-liners to explain helpers
* remove import os from test
* ENH: use ducktyping to handle different versions of pandas
* if old pandas change tz directly, and hours is already a numpy array
* if new pandas then use tz_localize to strip tz, and change hours from
Float64Index to numpy array
* move operator to end to match existing style in pvlib
* ducktype hours if Float64index or not, convert datetime64[D] to ns before adding
* ENH: use "geometric" instead of "analytical"
* change name in solarposition.py and test_solarposition.py
* enforce that hours is a numpy array in _hours instead of in _times
* add more useful comments, separate into steps to explain process
* ENH: use more verbose, meaningful names for helpers _hours and _times
* change _hours to _hour_angle_to_hours
* change _times to _local_times_from_hours_since_midnite
* fix typos in warning circular orbit
* fix reference numbers
* clarify sign conventions for latitude and longitude
* remove EXPECTED_ANALYTICAL_SUNRISE_SUNSET_TRANSIT
* instead use a test pytest.fixture with a few dates like the ephem and
spa.c test
* stickler - missing whitespace after comma in list
* use np.asarray to ensure consistent return
* remove try-except, doesn't work anyway, wait for pandas >=0.15.0
* also remove utcoffset(), unreliable with pandas dataframes, only really
works with scalar datetimes and timestamps
* instead use tz_localise(None) to get naive, but still local time, and
subtract the localized time, to get a sequence of timezones
* reuse expected_rise_set_spa test fixture
* remove geometric expected sunrise/sunset/transite test fixture
* check abs tolerance between geometric and spa are less than max absolute
error difference which is typically 4-6 minutes for sunrise/sunset, and
about 10-40 seconds for transite
* move _times_to_hours to solarposition, and use the same approach as
other hour/time conversions, use pandas>= tz_localize(None) or normalize
to get the local, naive times, and time at previous midnight, then convert
to np.int64, and then convert to hours from nanoseconds
* since fixture is a dataframe, get column, convert to MST timezone, before
calling _times_to_hours(<pd.DatetimeIndex>)
* get times from expected_rise_set_spa.index
* get lat/lon from golden_mst test_fixture
* stickler
* ENH: update what's new and api.rst
* wrap long lines, link to issues
* add constant NS_PER_HR and substiture for (3600. * 1.e9)
* change arg name to hourangle avoid shadowing function hour_angle()
* fix spelling in _local_times_from_hours_since_midnight()
* use normalize() and astype(np.int64) instead of
naive_times.astype('datetime64[D]').astype('datetim64[ns]') and
midnight_times + (hours*NS_PER_HR).astype('timedelta64[ns]') for
stability and consistency with other hour/times conversion functions
* stickler - line break before operator
* group sunrise/sunset enhancements together, separate iotools
* change private func name to be more descriptive
* _times_to_hours -> _times_to_hours_after_local_midnight
* change corresponding usage in test_solarposition.py and wrap some
long lines
* in docstring specify that times should be localized to the timzeone
of the lat/lon args in hour_angle() and sunrise_sunset_transit_geometric()
* change arg in solar_azimuth_analytical() and solar_zenith_analytical()
from hour_angle -> hourangle to avoid shadowing func name hour_angle()
from outer scope and remove redundant parentheses from return
* TST: change name to test_sunrise_sunset_transit_geometric
* change description to say "geometric" vs. analytical
* improve description of _local_times_from_hours_since_midnight to be
more specific by adding "hours since midnight"1 parent 5ee82b1 commit 4538bef
File tree
4 files changed
+172
-22
lines changed- docs/sphinx/source
- whatsnew
- pvlib
- test
4 files changed
+172
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
1175 | 1177 | | |
1176 | 1178 | | |
1177 | 1179 | | |
1178 | | - | |
| 1180 | + | |
1179 | 1181 | | |
1180 | 1182 | | |
1181 | 1183 | | |
| |||
1184 | 1186 | | |
1185 | 1187 | | |
1186 | 1188 | | |
1187 | | - | |
| 1189 | + | |
1188 | 1190 | | |
1189 | 1191 | | |
1190 | 1192 | | |
| |||
1240 | 1242 | | |
1241 | 1243 | | |
1242 | 1244 | | |
1243 | | - | |
| 1245 | + | |
1244 | 1246 | | |
1245 | | - | |
| 1247 | + | |
1246 | 1248 | | |
1247 | 1249 | | |
1248 | | - | |
| 1250 | + | |
1249 | 1251 | | |
1250 | 1252 | | |
1251 | 1253 | | |
| |||
1257 | 1259 | | |
1258 | 1260 | | |
1259 | 1261 | | |
1260 | | - | |
| 1262 | + | |
1261 | 1263 | | |
1262 | 1264 | | |
1263 | 1265 | | |
| |||
1288 | 1290 | | |
1289 | 1291 | | |
1290 | 1292 | | |
1291 | | - | |
| 1293 | + | |
1292 | 1294 | | |
1293 | 1295 | | |
1294 | 1296 | | |
| |||
1300 | 1302 | | |
1301 | 1303 | | |
1302 | 1304 | | |
1303 | | - | |
| 1305 | + | |
| 1306 | + | |
1304 | 1307 | | |
1305 | 1308 | | |
1306 | 1309 | | |
| |||
1329 | 1332 | | |
1330 | 1333 | | |
1331 | 1334 | | |
1332 | | - | |
| 1335 | + | |
1333 | 1336 | | |
1334 | 1337 | | |
1335 | 1338 | | |
1336 | 1339 | | |
1337 | 1340 | | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
537 | 539 | | |
538 | 540 | | |
539 | 541 | | |
| |||
690 | 692 | | |
691 | 693 | | |
692 | 694 | | |
693 | | - | |
694 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
695 | 698 | | |
696 | 699 | | |
697 | 700 | | |
| |||
718 | 721 | | |
719 | 722 | | |
720 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
0 commit comments