def gps_fullpath(self): """Returns full path to the GPS-UTC clock file. Will first try PINT data dirs, then fall back on $TEMPO2/clock.""" fname = "gps2utc.clk" fullpath = runtimefile(fname) if fullpath is not None: return fullpath return os.path.join(os.getenv("TEMPO2"), "clock", fname)
def clock_fullpath(self): """Returns the full path to the clock file.""" if self.clock_dir == "PINT": if self._multiple_clock_files: return [runtimefile(f) for f in self.clock_file] return runtimefile(self.clock_file) elif self.clock_dir == "TEMPO": # Technically should read $TEMPO/tempo.cfg and get clock file # location from CLKDIR line... TEMPO_dir = os.getenv("TEMPO") if TEMPO_dir is None: raise RuntimeError("Cannot find TEMPO path from the" " enviroment.") dir = os.path.join(TEMPO_dir, "clock") elif self.clock_dir == "TEMPO2": TEMPO2_dir = os.getenv("TEMPO2") if TEMPO2_dir is None: raise RuntimeError("Cannot find TEMPO2 path from the" " enviroment.") dir = os.path.join(TEMPO2_dir, "clock") else: dir = self.clock_dir if self._multiple_clock_files: return [os.path.join(dir, f) for f in self.clock_file] return os.path.join(dir, self.clock_file)
def bipm_fullpath(self,): """Returns full path to the TAI TT(BIPM) clock file. Will first try PINT data dirs, then fall back on $TEMPO2/clock. """ fname = "tai2tt_" + self.bipm_version.lower() + ".clk" try: fullpath = runtimefile(fname) return fullpath except FileNotFoundError: try: return os.path.join(os.getenv("TEMPO2"), "clock", fname) except OSError as e: if e.errno == 2: # File not found return None else: raise