Skip to content

Commit

Permalink
Merge pull request #54 from hirokawa/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
hirokawa authored Jul 15, 2024
2 parents e9348d6 + 5abdbc2 commit 14a4dde
Show file tree
Hide file tree
Showing 18 changed files with 421,220 additions and 241 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Execute Python Scripts

on:
push:
branches:
- main
- devel

jobs:
execute-scripts:
name: Execute Python Scripts
runs-on: ubuntu-latest

steps:
- name: Checkout cssrlib repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies from repository
run: pip install -r requirements.txt

- name: Install cssrlib from cloned repository
run: pip install .

- name: Execute Python scripts
run: |
cd ./src/cssrlib/test
for file in $(find . -name "*.py"); do
echo "# Execute $file"
echo "#"
python "$file" > /dev/null
echo "# ...done!"
echo "#"
echo
done
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,10 @@ Click this button for a quick demo in Google Colab

Prerequisites
=============
Additional python packages are required as prerequisites and can be installed via the following commands
Additional python packages are required as prerequisites and can be installed via the following command

```
pip install bitstruct galois crccheck pysolid
pip install notebook numpy matplotlib
```

Optionally, on linux, users can install the `cartopy` package and the `PySolid` package

```
pip install cartopy pysolid
pip install -r requirements.txt
```

If the installation of `cartopy` fails, try installing `libgeos++-dev` first.
Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bitstruct
galois
crccheck
notebook
numpy
matplotlib
cartopy
pysolid
13 changes: 10 additions & 3 deletions src/cssrlib/cssr_has.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,20 @@ def decode_head(self, msg, i, st=-1):
return head, i

def decode_cssr(self, msg, i=0):
if self.msgtype != 1: # only MT=1 defined
# Galileo HAS-SIS only defines MT=1, MT=4073 is CSSR message used in the
# Galileo HAS test dataset
#
if self.msgtype != 1 and self.msgtype != 4073:
print(f"invalid MT={self.msgtype}")
return False
# time of hour
# flags: mask,orbit,clock,clock subset,cbias,pbias,mask_id,iodset_id
self.toh, flags, res, mask_id, self.iodssr = \
bs.unpack_from('u12u6u4u5u5', msg, i)
try:
self.toh, flags, res, mask_id, self.iodssr = \
bs.unpack_from('u12u6u4u5u5', msg, i)
except:
print(f"invalid content={self.msgtype}")
return False
i += 32

if self.monlevel > 0 and self.fh is not None:
Expand Down
33 changes: 18 additions & 15 deletions src/cssrlib/cssrlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ def __init__(self):
self.inet = -1
self.inet_ref = -1
self.ng = -1
self.pbias = None
self.cbias = None
self.pbias = {}
self.cbias = {}
self.iode = None
self.dorb = None
self.dclk = None
Expand All @@ -226,6 +226,11 @@ def __init__(self):
self.sat_n = []
self.t0 = {}
self.cstat = 0 # status for receiving CSSR message
self.t0s = {}
sc_t = [sCType.CLOCK, sCType.ORBIT, sCType.CBIAS, sCType.PBIAS,
sCType.HCLOCK]
for sc in sc_t:
self.t0s[sc] = gtime_t()


class cssr:
Expand Down Expand Up @@ -444,7 +449,7 @@ def isset(self, mask, nbit, k):
return False

def set_t0(self, inet=0, sat=0, ctype=0, t=gtime_t()):
""" set reference time for correcion to check validity time """
""" set reference time for correction to check validity time """
sc_t = [sCType.CLOCK, sCType.ORBIT, sCType.CBIAS, sCType.PBIAS,
sCType.HCLOCK]

Expand Down Expand Up @@ -692,7 +697,6 @@ def decode_cssr_cbias(self, msg, i, inet=0):
self.lc[inet].cbias = {}
for k in range(nsat):
sat = self.sat_n[k]
sys, _ = sat2prn(sat)
self.lc[inet].cbias[sat] = {}
for j in range(len(self.sig_n[sat])):
rsig = self.sig_n[sat][j].toTyp(uTYP.C)
Expand All @@ -713,7 +717,6 @@ def decode_cssr_pbias(self, msg, i, inet=0):
self.lc[inet].di = {}
for k in range(nsat):
sat = self.sat_n[k]
sys, _ = sat2prn(sat)
self.lc[inet].pbias[sat] = {}
self.lc[inet].di[sat] = {}
for j in range(len(self.sig_n[sat])):
Expand Down Expand Up @@ -914,8 +917,8 @@ def decode_cssr_sinfo(self, msg, i):
def decode_cssr_comb(self, msg, i, inet=0):
"""decode MT4073,11 Orbit,Clock Combined Correction message """
head, i = self.decode_head(msg, i)
# if self.iodssr != head['iodssr']:
# return -1
if self.iodssr != head['iodssr']:
return -1
dfm = bs.unpack_from_dict('b1b1b1', ['orb', 'clk', 'net'], msg, i)
i += 3
self.flg_net = dfm['net']
Expand Down Expand Up @@ -1132,7 +1135,7 @@ def out_log(self):

if self.subtype == sCSSR.CLOCK:
self.fh.write(" {:s}\t{:s}\n".format("SatID", "dclk [m]"))
for k, sat_ in enumerate(self.lc[0].dclk.keys()):
for sat_ in self.lc[0].dclk.keys():
if np.isnan(self.lc[0].dclk[sat_]):
continue
self.fh.write(" {:s}\t{:8.4f}\n"
Expand All @@ -1143,7 +1146,7 @@ def out_log(self):
self.fh.write(" {:s}\t{:s}\t{:s}\t{:s}\t{:s}\n"
.format("SatID", "IODE", "Radial[m]",
"Along[m]", "Cross[m]"))
for k, sat_ in enumerate(self.lc[0].dorb.keys()):
for sat_ in self.lc[0].dorb.keys():
if np.isnan(self.lc[0].dorb[sat_][0]):
continue
self.fh.write(" {:s}\t{:3d}\t{:6.3f}\t{:6.3f}\t{:6.3f}\n"
Expand All @@ -1157,12 +1160,12 @@ def out_log(self):
self.fh.write(" {:s}\t{:s}\t{:s}\t{:s}\t{:s}\t{:s}\n"
.format("SatID", "IODE", "Radial[m]",
"Along[m]", "Cross[m]", "dclk[m]"))
for k, sat_ in enumerate(self.lc[0].dorb.keys()):
for sat_ in self.lc[0].dorb.keys():
if np.isnan(self.lc[0].dorb[sat_][0]) or \
np.isnan(self.lc[0].dclk[sat_]):
continue
self.fh.write(
" {:s}\t{:3d}\t{:6.3f}\t{:6.3f}\t{:6.3f}\t{:6.3f}\n"
" {:s}\t{:3d}\t{:6.3f}\t{:6.3f}\t{:6.3f}\t{:8.4f}\n"
.format(sat2id(sat_),
self.lc[0].iode[sat_],
self.lc[0].dorb[sat_][0],
Expand All @@ -1173,9 +1176,9 @@ def out_log(self):
elif self.subtype == sCSSR.CBIAS:
self.fh.write(" {:s}\t{:s}\t{:s}\t{:s}\n"
.format("SatID", "SigID", "Code Bias[m]", "..."))
for k, sat_ in enumerate(self.lc[0].cbias.keys()):
for sat_ in self.lc[0].cbias.keys():
self.fh.write(" {:s}\t".format(sat2id(sat_)))
for sig_ in range(self.lc[0].cbias[sat_].keys()):
for sig_ in self.lc[0].cbias[sat_].keys():
self.fh.write("{:s}\t{:5.2f}\t"
.format(sig_.str(),
self.lc[0].cbias[sat_][sig_]))
Expand All @@ -1184,9 +1187,9 @@ def out_log(self):
elif self.subtype == sCSSR.PBIAS:
self.fh.write(" {:s}\t{:s}\t{:s}\t{:s}\n"
.format("SatID", "SigID", "Phase Bias[m]", "..."))
for k, sat_ in enumerate(self.lc[0].pbias.keys()):
for sat_ in self.lc[0].pbias.keys():
self.fh.write(" {:s}\t".format(sat2id(sat_)))
for sig_ in range(self.lc[0].pbias[sat_].keys()):
for sig_ in self.lc[0].pbias[sat_].keys():
self.fh.write("{:s}\t{:5.2f}\t"
.format(sig_.str(),
self.lc[0].pbias[sat_][sig_]))
Expand Down
Loading

0 comments on commit 14a4dde

Please sign in to comment.