55 Specification Issue 1.0, 2024
66
77[2] Quasi-Zenith Satellite System Interface Specification
8- DCX Service (IS-QZSS-DCX-001 ), 2024
8+ DCX Service (IS-QZSS-DCX-003 ), March, 2025
99
1010[3] Quasi-Zenith Satellite System Interface Specification
11- DC Report Service (IS-QZSS-DCR-013 ), 2024
11+ DC Report Service (IS-QZSS-DCR-014 ), April, 2025
1212
1313@author Rui Hirokawa
1414
1515"""
1616
1717import bitstruct as bs
1818from cssrlib .gnss import time2str , epoch2time , time2epoch , timeadd , \
19- time2gpst , gpst2time
19+ time2gpst , gpst2time , utc2gpst
2020from enum import IntEnum
2121import json
2222import numpy as np
@@ -691,9 +691,14 @@ def decode_jma_marine(self, msg, i):
691691
692692 def decode (self , msg , i ):
693693 """ decode DC-report messages """
694+
694695 self .rc , self .dc = bs .unpack_from ('u3u4' , msg , i )
695696 i += 7
696697
698+ if self .dc not in self .dc_m_t .keys () or \
699+ self .rc not in self .rc_m_t .keys ():
700+ return - 1
701+
697702 if self .monlevel > 0 :
698703 print (f"[DCR] { self .rc_m_t [self .rc ]} { self .dc_m_t [self .dc ]} " )
699704
@@ -739,7 +744,7 @@ def __init__(self, bdir='../data/ewss/camf/', year=0):
739744 self .pref_t = json .load (fh )
740745
741746 # JIS X0402
742- self .mc_t = pd .read_csv (bdir + '000323625.csv' , encoding = 'sjis ' )
747+ self .mc_t = pd .read_csv (bdir + '000323625.csv' , encoding = 'utf-8 ' )
743748
744749 self .bdir = bdir
745750 self .city_t = None
@@ -1070,10 +1075,6 @@ def decode_ext(self, msg, i):
10701075
10711076 # for Japan
10721077 if self .pid == 1 : # L-Alert
1073- if self .city_t is None :
1074- with open (self .bdir + 'City_list.json' , 'r' ,
1075- encoding = 'utf-8' ) as fh :
1076- self .city_t = json .load (fh )
10771078
10781079 # EX1 target area code
10791080 # EX2 Evacuate Direction Type
@@ -1092,18 +1093,26 @@ def decode_ext(self, msg, i):
10921093 ex5 , ex6 , ex7 , vn = bs .unpack_from ('u5u5u7u6' , msg , i )
10931094 i += 23
10941095
1095- pref_code = '{:02d}' .format (ex1 // 1000 )
1096- city_code = '{:03d}' .format (ex1 % 1000 )
1096+ v = self .mc_t [self .mc_t ['tiiki-code' ] == ex1 ]
10971097
10981098 if ex1 == 0 :
10991099 return i
11001100
1101- name = ''
1102- for city in self .city_t ['cities' ]:
1103- if city ['pref_code' ] == pref_code and \
1104- city ['city_code' ] == city_code :
1105- name = city ['name' ]
1106- break
1101+ if len (v ) > 0 :
1102+ pref = v ['ken-name' ].item ()
1103+
1104+ if v ['sityouson-name1' ].isna ().item ():
1105+ if v ['sityouson-name2' ].isna ().item ():
1106+ if v ['sityouson-name3' ].isna ().item ():
1107+ city = None
1108+ else :
1109+ city = v ['sityouson-name3' ].item ()
1110+ else :
1111+ city = v ['sityouson-name2' ].item ()
1112+ else :
1113+ city = v ['sityouson-name1' ].item ()
1114+
1115+ name = pref + city
11071116
11081117 if len (name ) == 0 :
11091118 return i
@@ -1205,28 +1214,25 @@ def decode(self, msg, i):
12051214 self .severity = self .severity_t [sev ]
12061215
12071216 # 3.3 Hazard Chronology (beginning of hazard)
1217+
12081218 wn , tow , dur = bs .unpack_from ('u1u14u2' , msg , i )
12091219 i += 17
12101220
12111221 # wn: 0:current week, 1: next week
12121222 # tow: 1:mon 00:00, 2:mon 00:01, 3:mon 00:02
12131223 # .. sun 23:59
1214- dow_ = (tow - 1 ) // 1440
1215- min_ = (tow - 1 ) % 1440
1216- hour_ = min_ // 60
1217- min_ -= hour_ * 60
1218-
1219- week , tow = time2gpst (self .time )
1224+ week , _ = time2gpst (self .time )
12201225 week += wn
1221- tow_ = dow_ * 86400 + hour_ * 3600 + min_ * 60
12221226
1223- # harzrd onset (UTC)
1224- self .th = gpst2time (week , tow_ )
1227+ tow = (tow - 1 )* 60 + 86400 # sec from sun
1228+ if tow >= 604800 :
1229+ tow -= 604800
1230+ week += 1
12251231
1232+ # harzrd onset (UTC)
1233+ self .th = gpst2time (week , tow )
12261234 self .epoch = time2epoch (self .th )
12271235
1228- # self.epoch = [wn, dow_, hour_, min_]
1229-
12301236 # duration (A8) : 0:unknown,1:<6h,2:6h<=d<12h,3:12h<=d<24h
12311237 self .duration = self .duration_t [dur ]
12321238
0 commit comments