Skip to content

Commit 3d157be

Browse files
committed
- optimized by eliminating frequent update of sun position, antTx position. (suggested by mfinneman)
1 parent e25ac89 commit 3d157be

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

src/cssrlib/gnss.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from datetime import datetime, timezone
1010
import bitstruct as bs
1111
import yaml
12-
12+
from numba import njit
1313

1414
gpst0 = [1980, 1, 6, 0, 0, 0] # GPS system time reference
1515
gst0 = [1999, 8, 22, 0, 0, 0] # Galileo system time reference
@@ -951,6 +951,9 @@ def __init__(self, nf=2):
951951

952952
# number of satellite (observed, calculated, corrected)
953953
self.nsat = [0, 0, 0]
954+
955+
self.t_rsun = None # reference time of rsun
956+
self.rsun = None # placeholder of sun position
954957

955958

956959
def epoch2time(ep):
@@ -1208,7 +1211,7 @@ def prn2sat(sys, prn):
12081211
sat = 0
12091212
return sat
12101213

1211-
1214+
@njit
12121215
def sat2prn(sat):
12131216
""" convert sat to sys+prn """
12141217
if sat > uGNSS.MAXSAT:

src/cssrlib/peph.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def antModelTx(nav, e, sigs, sat, time, rs, sig0=None):
795795

796796
# Rotation matrix from satellite antenna frame to ECEF frame [ex, ey, ez]
797797
#
798-
A = orb2ecef(time, rs)
798+
A = orb2ecef(time, rs, nav.rsun)
799799
ez = A[2, :]
800800

801801
# Zenith angle and zenith angle grid
@@ -1124,14 +1124,14 @@ def utc2gmst(t: gtime_t, ut1_utc):
11241124
return np.fmod(gmst, 86400.0)*np.pi/43200.0 # 0 <= gmst <= 2*PI
11251125

11261126

1127-
def orb2ecef(time, rs):
1127+
def orb2ecef(time, rs, rsun=None):
11281128
"""
11291129
Rotation matrix from satellite antenna frame to ECEF frame assuming
11301130
standard yaw attitude law
11311131
"""
11321132

1133-
erpv = np.zeros(5)
1134-
rsun, _, _ = sunmoonpos(gpst2utc(time), erpv, True)
1133+
if rsun is None:
1134+
rsun, _, _ = sunmoonpos(gpst2utc(time), np.zeros(5), True)
11351135
r = -rs
11361136
ez = r/np.linalg.norm(r)
11371137
r = rsun-rs

src/cssrlib/ppp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,12 @@ def shapiro(rsat, rrcv):
274274
return corr
275275

276276

277-
def windupcorr(time, rs, vs, rr, phw, full=False):
277+
def windupcorr(time, rs, vs, rr, rsun, phw, full=False):
278278
""" calculate windup correction """
279279
ek = vnorm(rr-rs)
280280
if full:
281281
# Satellite antenna frame unit vectors assuming standard yaw attitude law
282282
#
283-
rsun, _, _ = sunmoonpos(gpst2utc(time))
284283
r = -rs
285284
ezs = r/np.linalg.norm(r)
286285
r = rsun-rs
@@ -443,7 +442,8 @@ def tidedispIERS2010(tutc, pos, erpv=None):
443442
tn = timeadd(tgps_, k*300)
444443
eph = findeph(nav.eph, tn, sat)
445444
rs_, vs_, dts = eph2pos(tn, eph, True)
446-
phw_ = windupcorr(tn, rs_, vs_, rr_, phw_)
445+
rsun_, _, _ = sunmoonpos(gpst2utc(tn))
446+
phw_ = windupcorr(tn, rs_, vs_, rr_, rsun_, phw_)
447447
t[k] = timediff(tn, tgps_)
448448
ph_[k] = phw_
449449
d[k] = shapiro(rs_, rr_)

src/cssrlib/pppssr.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from cssrlib.gnss import ecef2pos, tropmodel, geodist, satazel, uTideModel
1010
from cssrlib.gnss import time2str, timediff, gpst2utc, tropmapf
1111
from cssrlib.gnss import trop_model_tbl, iono_model_tbl, default_config
12-
from cssrlib.ppp import tidedisp, tidedispIERS2010, shapiro, windupcorr
12+
from cssrlib.ppp import tidedisp, tidedispIERS2010, shapiro, windupcorr, sunmoonpos
1313
from cssrlib.peph import antModelRx, antModelTx
1414
from cssrlib.cssrlib import sCType
1515
from cssrlib.cssrlib import sCSSRTYPE as sc
@@ -656,7 +656,8 @@ def zdres(self, obs, cs, bsx, rs, vs, dts, rr, rtype=1):
656656
if self.nav.phw_opt > 0:
657657
phw_mode = (False if self.nav.phw_opt == 2 else True)
658658
self.nav.phw[sat-1] = windupcorr(obs.t, rs[i, :], vs[i, :],
659-
rr_, self.nav.phw[sat-1],
659+
rr_, self.nav.rsun,
660+
self.nav.phw[sat-1],
660661
full=phw_mode)
661662

662663
# cycle -> m
@@ -738,11 +739,11 @@ def zdres(self, obs, cs, bsx, rs, vs, dts, rr, rtype=1):
738739
sc.RTCM3_SSR,
739740
sc.BDS_PPP,
740741
sc.PVS_PPP):
741-
742-
antsPR = antModelTx(self.nav, e[i, :], sigsPR,
743-
sat, obs.t, rs[i, :], sig0)
744-
antsCP = antModelTx(self.nav, e[i, :], sigsCP,
745-
sat, obs.t, rs[i, :], sig0)
742+
743+
ants = antModelTx(self.nav, e[i, :], (sigsPR + sigsCP),
744+
sat, obs.t, rs[i, :], sig0)
745+
antsPR = ants[0:len(sigsPR)]
746+
antsCP = ants[len(sigsPR):]
746747

747748
else:
748749

@@ -1390,6 +1391,13 @@ def process(self, obs, cs=None, orb=None, bsx=None, obsb=None):
13901391

13911392
self.nav.nsat[0] = len(obs.sat)
13921393

1394+
# sun position is updated every 1sec
1395+
if (self.nav.rsun is None) or \
1396+
(np.abs(timediff(self.nav.t_rsun,obs.t))>=1.0):
1397+
self.nav.rsun, _, _ = sunmoonpos(gpst2utc(obs.t))
1398+
self.nav.t_rsun = obs.t
1399+
1400+
13931401
# GNSS satellite positions, velocities and clock offsets
13941402
# for all satellite in RINEX observations
13951403
#

0 commit comments

Comments
 (0)