Beispiel #1
0
 def clock_fullpath(self):
     """Returns the full path to the clock file."""
     if self.clock_dir == "PINT":
         if self._multiple_clock_files:
             return [datapath(f) for f in self.clock_file]
         return datapath(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 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 = datapath(fname)
     if fullpath is not None:
         return fullpath
     return os.path.join(os.getenv("TEMPO2"), "clock", fname)
Beispiel #3
0
 def test_from_dir(self):
     path = datapath("de432s.bsp")
     a = objPosVel_wrt_SSB("earth", self.tdb_time, "de432s", path=path)
     assert a.obj == "earth"
     assert a.pos.shape == (3, 10000)
     assert a.vel.shape == (3, 10000)
     print("value {0}, path {1}".format(solar_system_ephemeris._value,
                                        path))
 def test_from_dir(self):
     path = datapath('de432s.bsp')
     a = objPosVel_wrt_SSB('earth', self.tdb_time , 'de432s', path=path)
     assert a.obj == 'earth'
     assert a.pos.shape == (3, 10000)
     assert a.vel.shape == (3, 10000)
     print("value {0}, path {1}".format(solar_system_ephemeris._value,path))
     assert solar_system_ephemeris._value == path
 def test_from_dir(self):
     path = datapath('de432s.bsp')
     a = objPosVel_wrt_SSB('earth', self.tdb_time, 'de432s', path=path)
     assert a.obj == 'earth'
     assert a.pos.shape == (3, 10000)
     assert a.vel.shape == (3, 10000)
     print("value {0}, path {1}".format(solar_system_ephemeris._value,
                                        path))
     assert solar_system_ephemeris._value == path
Beispiel #6
0
 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"
     try:
         fullpath = datapath(fname)
         return fullpath
     except FileNotFoundError:
         log.info(
             "{} not found in PINT data dirs, falling back on TEMPO2/clock directory"
             .format(fname))
         return os.path.join(os.getenv("TEMPO2"), "clock", fname)
 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"
     fullpath = datapath(fname)
     if fullpath is not None:
         return fullpath
     else:
         try:
             return os.path.join(os.getenv("TEMPO2"), "clock", fname)
         except:
             return None
Beispiel #8
0
 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 = datapath(fname)
         return fullpath
     except FileNotFoundError:
         pass
     log.info(
         "{} not found in PINT data dirs, falling back on TEMPO2/clock directory"
         .format(fname))
     return os.path.join(os.getenv("TEMPO2"), "clock", fname)
def _load_kernel_local(ephem, path):
    ephem_bsp = "%s.bsp" % ephem
    if os.path.isdir(path):
        custom_path = os.path.join(path, ephem_bsp)
    else:
        custom_path = path
    search_list = [custom_path, datapath(ephem_bsp)]
    for p in search_list:
        if os.path.exists(p):
            # .set() can accept a path to an ephemeris
            coor.solar_system_ephemeris.set(ephem)

    raise OSError("ephemeris file {} not found in any of {}".format(
        ephem, search_list))
Beispiel #10
0
    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 = datapath(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
def _load_kernel_local(ephem, path):
    ephem_bsp = "%s.bsp" % ephem
    if os.path.isdir(path):
        custom_path = os.path.join(path, ephem_bsp)
    else:
        custom_path = path
    search_list = [custom_path]
    try:
        search_list.append(datapath(ephem_bsp))
    except FileNotFoundError:
        # If not found in datapath, just continue. Error will be raised later if also not in "path"
        pass
    for p in search_list:
        if os.path.exists(p):
            # .set() can accept a path to an ephemeris
            coor.solar_system_ephemeris.set(ephem)
            log.info("Set solar system ephemeris to local file:\n\t{}".format(
                ephem))
            return
    raise FileNotFoundError("ephemeris file {} not found in any of {}".format(
        ephem, search_list))
Beispiel #12
0
astropy_version = sys.modules["astropy"].__version__


# Load obliquity data
# Assume the data file is in the ./datafile directory
def load_obliquity_file(filename):
    obliquity_data = {}
    for l in interesting_lines(lines_of(filename), comments="#"):
        if l.startswith("Obliquity of the ecliptic"):
            continue
        line = l.split()
        obliquity_data[line[0]] = float(line[1]) * u.arcsecond
    return obliquity_data


OBL = load_obliquity_file(datapath("ecliptic.dat"))


class PulsarEcliptic(coord.BaseCoordinateFrame):
    """A Pulsar Ecliptic coordinate system is defined by rotating ICRS coordinate
    about x-axis by obliquity angle. Historical, This coordinate is used by
    tempo/tempo2 for a better fitting error treatment.
    The obliquity angle values respect to time are given in the file named "ecliptic.dat"
    in the pint/datafile directory.
    Parameters
    ----------
    representation : `BaseRepresentation` or None
        A representation object or None to have no data (or use the other keywords)
    Lambda : `Angle`, optional, must be keyword
        The longitude-like angle corresponding to Sagittarius' orbit.
    Beta : `Angle`, optional, must be keyword
Beispiel #13
0
 def test_datapath(self):
     # Check that datapath of a non-existent file raises FileNotFoundError exception.
     with pytest.raises(FileNotFoundError):
         d = datapath("foobar")