@@ -329,13 +329,28 @@ class _WWVBMinute(NamedTuple):
329
329
"""
330
330
331
331
year : int
332
+ """2-digit year within the WWVB epoch"""
333
+
332
334
days : int
335
+ """1-based day of year"""
336
+
333
337
hour : int
338
+ """UTC hour of day"""
339
+
334
340
min : int
341
+ """Minute of hour"""
342
+
335
343
dst : int
344
+ """2-bit DST code """
345
+
336
346
ut1 : int
347
+ """UT1 offset in units of 100ms, range -900 to +900ms"""
348
+
337
349
ls : bool
350
+ """Leap second warning flag"""
351
+
338
352
ly : bool
353
+ """Leap year flag"""
339
354
340
355
341
356
class WWVBMinute (_WWVBMinute ):
@@ -463,14 +478,14 @@ def as_timecode(self) -> WWVBTimecode:
463
478
"""Fill a WWVBTimecode structure representing this minute. Fills both the amplitude and phase codes."""
464
479
t = WWVBTimecode (self .minute_length ())
465
480
466
- self .fill_am_timecode (t )
467
- self .fill_pm_timecode (t )
481
+ self ._fill_am_timecode (t )
482
+ self ._fill_pm_timecode (t )
468
483
469
484
return t
470
485
471
486
@property
472
- def leap_sec (self ) -> int :
473
- """Return the 2-bit leap_sec value used by the PM code"""
487
+ def _leap_sec (self ) -> int :
488
+ """Return the 2-bit _leap_sec value used by the PM code"""
474
489
if not self .ls :
475
490
return 0
476
491
if self .ut1 < 0 :
@@ -487,7 +502,7 @@ def minute_of_century(self) -> int:
487
502
// 60
488
503
)
489
504
490
- def fill_am_timecode (self , t : WWVBTimecode ) -> None :
505
+ def _fill_am_timecode (self , t : WWVBTimecode ) -> None :
491
506
"""Fill the amplitude (AM) portion of a timecode object"""
492
507
for i in [0 , 9 , 19 , 29 , 39 , 49 ]:
493
508
t .am [i ] = AmplitudeModulation .MARK
@@ -509,7 +524,7 @@ def fill_am_timecode(self, t: WWVBTimecode) -> None:
509
524
t .am [56 ] = AmplitudeModulation (self .ls )
510
525
t ._put_am_bcd (self .dst , 57 , 58 )
511
526
512
- def fill_pm_timecode_extended (self , t : WWVBTimecode ) -> None :
527
+ def _fill_pm_timecode_extended (self , t : WWVBTimecode ) -> None :
513
528
"""During minutes 10..15 and 40..45, the amplitude signal holds 'extended information'"""
514
529
assert 10 <= self .min < 16 or 40 <= self .min < 46
515
530
minno = self .min % 10
@@ -543,14 +558,14 @@ def fill_pm_timecode_extended(self, t: WWVBTimecode) -> None:
543
558
for i in range (60 ):
544
559
t ._put_pm_bit (i , full_seq [i + offset ])
545
560
546
- def fill_pm_timecode_regular (self , t : WWVBTimecode ) -> None : # noqa: PLR0915
561
+ def _fill_pm_timecode_regular (self , t : WWVBTimecode ) -> None : # noqa: PLR0915
547
562
"""Except during minutes 10..15 and 40..45, the amplitude signal holds 'regular information'"""
548
563
t ._put_pm_bin (0 , 13 , SYNC_T )
549
564
550
565
moc = self .minute_of_century
551
- leap_sec = self .leap_sec
566
+ _leap_sec = self ._leap_sec
552
567
dst_on = self .dst
553
- dst_ls = _dst_ls_lut [dst_on | (leap_sec << 2 )]
568
+ dst_ls = _dst_ls_lut [dst_on | (_leap_sec << 2 )]
554
569
dst_next = _get_dst_next (self .as_datetime ())
555
570
t ._put_pm_bin (13 , 5 , _hamming_parity (moc ))
556
571
t ._put_pm_bit (18 , _extract_bit (moc , 25 ))
@@ -599,12 +614,12 @@ def fill_pm_timecode_regular(self, t: WWVBTimecode) -> None: # noqa: PLR0915
599
614
if len (t .phase ) > 60 :
600
615
t ._put_pm_bit (60 , PhaseModulation .ZERO )
601
616
602
- def fill_pm_timecode (self , t : WWVBTimecode ) -> None :
617
+ def _fill_pm_timecode (self , t : WWVBTimecode ) -> None :
603
618
"""Fill the phase portion of a timecode object"""
604
619
if 10 <= self .min < 16 or 40 <= self .min < 46 :
605
- self .fill_pm_timecode_extended (t )
620
+ self ._fill_pm_timecode_extended (t )
606
621
else :
607
- self .fill_pm_timecode_regular (t )
622
+ self ._fill_pm_timecode_regular (t )
608
623
609
624
def next_minute (self , newut1 : int | None = None , newls : bool | None = None ) -> WWVBMinute :
610
625
"""Return an object representing the next minute"""
@@ -745,7 +760,10 @@ class WWVBTimecode:
745
760
"""Represent the amplitude and/or phase signal, usually over 1 minute"""
746
761
747
762
am : list [AmplitudeModulation ]
763
+ """The amplitude modulation data"""
764
+
748
765
phase : list [PhaseModulation ]
766
+ """The phase modulation data"""
749
767
750
768
def __init__ (self , sz : int ) -> None :
751
769
"""Construct a WWVB timecode ``sz`` seconds long"""
@@ -881,7 +899,21 @@ def print_timecodes_json(
881
899
channel : str ,
882
900
file : TextIO ,
883
901
) -> None :
884
- """Print a range of timecodes with a header. This header is in a format understood by WWVBMinute.fromstring"""
902
+ """Print a range of timecodes in JSON format.
903
+
904
+ The result is a json array of minute data. Each minute data is an object with the following members:
905
+
906
+ * year (int)
907
+ * days (int)
908
+ * hour (int)
909
+ * minute (int)
910
+ * amplitude (string; only if channel is amplitude or both)
911
+ * phase: (string; only if channel is phase or both)
912
+
913
+ The amplitude and phase strings are of length 60 during most minutes, length 61
914
+ during a minute that includes a (positive) leap second, and theoretically
915
+ length 59 in the case of a negative leap second.
916
+ """
885
917
result = []
886
918
for _ in range (minutes ):
887
919
data : dict [str , Any ] = {
0 commit comments