Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f64638

Browse files
committed
astronomy: Fix README.md.
1 parent 03c924d commit 8f64638

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

astronomy/README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ Move to `micropython-samples` on the PC, run `rshell` and issue:
9393
```
9494
`mip` installs the following files in the `sched` directory.
9595
* `sun_moon.py`
96-
* `sun_moon_test.py` A test/demo script.
96+
* `sun_moon_test.py` A test/demo script for the above.
97+
* `moonphase.py` Determine lunar quarters and phase.
9798
After installation the `RiSet` class may be accessed with
9899
```python
99100
from sched.sun_moon import RiSet
@@ -402,6 +403,11 @@ time. Phases are calculated with respect to this datum. It may be changed using
402403
`.set_day` to enable future and past phases to be determined or to enable long
403404
running applications to track time.
404405

406+
The module is imported as follows:
407+
```python
408+
from sched.moonphase import MoonPhase
409+
```
410+
405411
## 6.1 Constructor
406412

407413
* `lto:float=0, dst = lambda x: x` Local time offset in hours to UTC (-ve is
@@ -420,7 +426,7 @@ being full. The `text` arg determines how the value is returned: as text or as
420426
function is provided to the constructor.
421427
* `phase() -> float)` Returns moon phase where 0.0 <= phase < 1.0 with 0.5 being
422428
full moon. The phase is that pertaining to the datum.
423-
* `nextphase(, text: bool = True)` This is a generator function. Each iteration
429+
* `nextphase(text: bool = True)` This is a generator function. Each iteration
424430
of the generator returns three values: the phase number, the lunation number and
425431
the datetime of the phase. The `text` arg is as per `.quarter()`, defining the
426432
format of the datetime.
@@ -435,7 +441,7 @@ per the constructor arg.
435441
## 6.3 Usage examples
436442

437443
```python
438-
from moonphase import MoonPhase
444+
from sched.moonphase import MoonPhase
439445
mp = MoonPhase() # datum is midnight last night
440446
print(f"Full moon, current lunation {mp.quarter(2)}")
441447
mp.set_day(0.5) # Adjust datum to noon today machine time
@@ -457,10 +463,11 @@ which is based on the machine clock. If the machine clock runs at a fixed offset
457463
to UTC (which is recommended), a DST function can be used to enable reported
458464
results to reflect local time.
459465

460-
A DST function takes as input a time measured in seconds since the machine epoch
461-
(as returned by `time.time()`) and returns that number adjusted for local time.
462-
The following example is for UK time, which adds one hour at 2:00 on the last
463-
Sunday in March, reverting to winter time at 2:00 on the last Sunday in October.
466+
A DST function takes as input a datetime measured in seconds since the machine
467+
epoch (as returned by `time.time()`) and returns that number adjusted for local
468+
time. The following example is for UK time, which adds one hour at 2:00 on the
469+
last Sunday in March, reverting to winter time at 2:00 on the last Sunday in
470+
October.
464471

465472
```python
466473
def uk_dst(secs_epoch: int): # Change in March (3) and Oct (10)
@@ -476,8 +483,8 @@ def uk_dst(secs_epoch: int): # Change in March (3) and Oct (10)
476483
return summer # +1 hr
477484
# We are in March or October. Find the day in month of last Sunday.
478485
ld = (wday + 31 - mday) % 7 # weekday of 31st.
479-
lsun = 31 - (1 + ld) % 7
480-
thresh = time.mktime((t[0], month, lsun, 2, 0, 0, 6, 0))
486+
lsun = 31 - (1 + ld) % 7 # Monthday of last Sunday
487+
thresh = time.mktime((t[0], month, lsun, 2, 0, 0, 6, 0)) # 2am last Sunday in month
481488
return summer if ((secs_epoch >= thresh) ^ (month == 10)) else winter
482489
```
483490

0 commit comments

Comments
 (0)