Skip to content

Commit

Permalink
Misc helpers (#139)
Browse files Browse the repository at this point in the history
* misc helper

* rm line

* save file name too
  • Loading branch information
haraschax authored Mar 16, 2023
1 parent 8463fe8 commit 719c79a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion laika/astro_dog.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def _select_valid_temporal_items(item_dict, time, cache):
result[prn] = obj
return result

def get_all_ephem_prns(self):
return set(self.orbits.keys()).union(set(self.navs.keys())).union(set(self.qcom_polys.keys()))

def get_navs(self, time):
if time not in self.navs_fetched_times:
self.get_nav_data(time)
Expand Down Expand Up @@ -270,7 +273,7 @@ def get_tgd_from_nav(self, prn, time):
return eph.get_tgd()
return None

def get_sat_info(self, prn, time):
def get_eph(self, prn, time):
if get_constellation(prn) not in self.valid_const:
return None
eph = None
Expand All @@ -280,6 +283,10 @@ def get_sat_info(self, prn, time):
eph = self.get_nav(prn, time)
if not eph and self.use_qcom_poly:
eph = self.get_qcom_poly(prn, time)
return eph

def get_sat_info(self, prn, time):
eph = self.get_eph(prn, time)
if eph:
return eph.get_sat_info(time)
return None
Expand Down
3 changes: 2 additions & 1 deletion laika/ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__(self, prn: str, epoch: GPSTime, eph_type: EphemerisType, healthy: b
self.healthy = healthy
self.max_time_diff = max_time_diff
self.file_epoch = file_epoch
self.file_name = file_name
self.file_source = '' if file_name is None else file_name.split('/')[-1][:3] # File source for the ephemeris (e.g. igu, igr, Sta)

def valid(self, time):
Expand Down Expand Up @@ -499,4 +500,4 @@ def parse_qcom_ephem(qcom_poly, current_week):
poly_data['clock'] = [1e-3*data.other[3], 1e-3*data.other[2], 1e-3*data.other[1], 1e-3*data.other[0]]
poly_data['deg'] = 3
poly_data['deg_t'] = 3
return PolyEphemeris(prn, poly_data, epoch, ephem_type=EphemerisType.QCOM_POLY, max_time_diff=180)
return PolyEphemeris(prn, poly_data, epoch, ephem_type=EphemerisType.QCOM_POLY, max_time_diff=180, file_name='qcom')
3 changes: 2 additions & 1 deletion laika/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ def get_closest(time, candidates, recv_pos=None):
default=None,
)


def get_constellation(prn: str):
identifier = prn[0]
constellation = ConstellationId.from_rinex_char(identifier)
if constellation is not None:
return constellation.name
return None

def get_sv_id(prn: str):
return int(prn[1:])

def get_constellation_and_sv_id(nmea_id):
for c, ranges in CONSTELLATION_TO_NMEA_RANGES.items():
Expand Down

0 comments on commit 719c79a

Please sign in to comment.