def test_observatory_replacement(self):
        from pint.observatory.topo_obs import TopoObs

        obsname = "nonexistent"

        TopoObs(
            obsname,
            itrf_xyz=[882589.65, -4924872.32, 3943729.348],
            overwrite=True,
            origin="Inserted for testing purposes",
        )
        obs = pint.observatory.get_observatory(obsname)
        self.assertRaises(
            ValueError,
            TopoObs,
            obsname,
            itrf_xyz=[882589.65, -4924872.32, 3943729.348],
            origin="This is a test - replacement",
        )
        obs = pint.observatory.get_observatory(obsname)
        msg = (
            "Checking that 'replacement' is not in the metadata for '%s': metadata is '%s'"
            % (obsname, obs.origin))
        assert not ("replacement" in obs.origin), msg
        TopoObs(
            obsname,
            itrf_xyz=[882589.65, -4924872.32, 3943729.348],
            origin="This is a test - replacement",
            overwrite=True,
        )
        obs = pint.observatory.get_observatory(obsname)
        msg = (
            "Checking that 'replacement' is now in the metadata for '%s': metadata is '%s'"
            % (obsname, obs.origin))
        assert "replacement" in obs.origin, msg
Exemple #2
0
    def get(cls, name):
        """Returns the Observatory instance for the specified name/alias.

        If the name has not been defined, an error will be raised.  Aside
        from the initial observatory definitions, this is in general the
        only way Observatory objects should be accessed.  Name-matching
        is case-insensitive.
        """
        # Ensure that the observatory list has been read
        # We can't do this in the import section above because this class
        # needs to exist before that file is imported.
        import pint.observatory.observatories  # noqa
        import pint.observatory.special_locations  # noqa

        if name == "":
            raise KeyError("No observatory name or code provided")

        # Be case-insensitive
        name = name.lower()
        # First see if name matches
        if name in cls._registry.keys():
            return cls._registry[name]
        # Then look for aliases
        if name in cls._alias_map.keys():
            return cls._registry[cls._alias_map[name]]
        # Then look in astropy
        log.warning(
            "Observatory name '%s' is not present in PINT observatory list; searching astropy..."
            % name)
        # the name was not found in the list of standard PINT observatories
        # see if we can it from astropy
        try:
            site_astropy = astropy.coordinates.EarthLocation.of_site(name)
        except astropy.coordinates.errors.UnknownSiteException:
            # turn it into the same error type as PINT would have returned
            raise KeyError("Observatory name '%s' is not defined" % name)

        # we need to import this here rather than up-top because of circular import issues
        from pint.observatory.topo_obs import TopoObs

        obs = TopoObs(
            name,
            itrf_xyz=[
                site_astropy.x.value, site_astropy.y.value,
                site_astropy.z.value
            ],
            # add in metadata from astropy
            origin="astropy: '%s'" % site_astropy.info.meta["source"],
        )
        # add to registry
        cls._register(obs, name)
        return cls._registry[name]

        # Nothing matched, raise an error
        raise KeyError("Observatory name '%s' is not defined" % name)
Exemple #3
0
 def test_wrong_path(self):
     # observatory clock correction path expections.
     fake_obs = TopoObs('Fake1',
                        tempo_code='?',
                        itoa_code='FK',
                        clock_fmt='tempo2',
                        clock_file='fake2gps.clk',
                        clock_dir='TEMPO2',
                        itrf_xyz=[0.00, 0.0, 0.0])
     site = get_observatory('Fake1',
                            include_gps=True,
                            include_bipm=True,
                            bipm_version='BIPM2015')
     with self.assertRaises(RuntimeError):
         _ = site.clock_corrections(self.test_time)
Exemple #4
0
 def test_no_tempo_but_tempo_clock_requested(self):
     if os.getenv('TEMPO') is not None:
         pytest.skip(
             "TEMPO evnironment variable is set, can't run this test")
     # observatory clock correction path expections.
     fake_obs = TopoObs('Fake1',
                        tempo_code='?',
                        itoa_code='FK',
                        clock_fmt='tempo',
                        clock_file='fake2gps.clk',
                        clock_dir='TEMPO',
                        itrf_xyz=[0.00, 0.0, 0.0])
     site = get_observatory('Fake1',
                            include_gps=True,
                            include_bipm=True,
                            bipm_version='BIPM2015')
     with pytest.raises(RuntimeError):
         site.clock_corrections(self.test_time)
Exemple #5
0
 def test_no_tempo2_but_tempo2_clock_requested(self):
     if os.getenv("TEMPO2") is not None:
         pytest.skip("TEMPO2 evnironment variable is set, can't run this test")
     # observatory clock correction path expections.
     fake_obs = TopoObs(
         "Fake1",
         tempo_code="?",
         itoa_code="FK",
         clock_fmt="tempo2",
         clock_file="fake2gps.clk",
         clock_dir="TEMPO2",
         itrf_xyz=[0.00, 0.0, 0.0],
     )
     site = get_observatory(
         "Fake1", include_gps=True, include_bipm=True, bipm_version="BIPM2015"
     )
     with pytest.raises(RuntimeError):
         site.clock_corrections(self.test_time)
Exemple #6
0
 def test_clock_correction_file_not_available(self):
     if os.getenv('TEMPO2') is None:
         pytest.skip(
             "TEMPO2 evnironment variable is not set, can't run this test")
     # observatory clock correction path expections.
     fake_obs = TopoObs('Fake1',
                        tempo_code='?',
                        itoa_code='FK',
                        clock_fmt='tempo2',
                        clock_file='fake2gps.clk',
                        clock_dir='TEMPO2',
                        itrf_xyz=[0.00, 0.0, 0.0])
     site = get_observatory('Fake1',
                            include_gps=True,
                            include_bipm=True,
                            bipm_version='BIPM2015')
     try:
         site.clock_corrections(self.test_time)
     except OSError as e:
         assert e.errno == 2
         assert os.path.basename(e.filename) == 'fake2gps.clk'
Exemple #7
0
 def test_clock_correction_file_not_available(self):
     if os.getenv("TEMPO2") is None:
         pytest.skip("TEMPO2 evnironment variable is not set, can't run this test")
     # observatory clock correction path expections.
     fake_obs = TopoObs(
         "Fake1",
         tempo_code="?",
         itoa_code="FK",
         clock_fmt="tempo2",
         clock_file="fake2gps.clk",
         clock_dir="TEMPO2",
         itrf_xyz=[0.00, 0.0, 0.0],
     )
     site = get_observatory(
         "Fake1", include_gps=True, include_bipm=True, bipm_version="BIPM2015"
     )
     try:
         site.clock_corrections(self.test_time)
     except (OSError, IOError) as e:
         assert e.errno == 2
         assert os.path.basename(e.filename) == "fake2gps.clk"
Exemple #8
0
    def test_observatory_replacement(self):
        from pint.observatory.topo_obs import TopoObs

        gbt = pint.observatory.get_observatory(self.pint_obsname)
        msg = "Checking that 'test' is in the metadata for '%s': metadata is '%s'" % (
            self.pint_obsname,
            gbt.origin,
        )
        assert "test" in gbt.origin, msg
        msg = (
            "This should raise an exception because we are making a replacement observatory for '%s' but overwrite=False"
            % self.pint_obsname)
        self.assertRaises(
            ValueError,
            TopoObs,
            self.pint_obsname,
            tempo_code="1",
            itoa_code="GB",
            itrf_xyz=[882589.65, -4924872.32, 3943729.348],
            origin="This is a test - replacement",
        )
        msg = (
            "Checking that 'replacement' is not in the metadata for '%s': metadata is '%s'"
            % (self.pint_obsname, gbt.origin))
        assert not ("replacement" in gbt.origin), msg
        TopoObs(
            self.pint_obsname,
            tempo_code="1",
            itoa_code="GB",
            itrf_xyz=[882589.65, -4924872.32, 3943729.348],
            origin="This is a test - replacement",
            overwrite=True,
        )
        gbt = pint.observatory.get_observatory(self.pint_obsname)
        msg = (
            "Checking that 'replacement' is now in the metadata for '%s': metadata is '%s'"
            % (self.pint_obsname, gbt.origin))
        assert "replacement" in gbt.origin, msg
Exemple #9
0
# PINT observatories.py

# This file contains the basic definitions of observatory sites for
# PINT.
from __future__ import absolute_import, print_function, division
from pint.observatory.topo_obs import TopoObs

TopoObs('gbt',          tempo_code='1', itoa_code='GB',
        itrf_xyz=[882589.65, -4924872.32, 3943729.348])
TopoObs('arecibo',      tempo_code='3', itoa_code='AO', aliases=['aoutc'],
        itrf_xyz=[2390490.0, -5564764.0, 1994727.0])
TopoObs('vla',          tempo_code='6', itoa_code='VL', aliases=['jvla'],
        itrf_xyz=[-1601192.0, -5041981.4, 3554871.4])
TopoObs('parkes',       tempo_code='7', itoa_code='PK', aliases=['pks'],
        itrf_xyz=[-4554231.5, 2816759.1, -3454036.3])
TopoObs('jodrell',      tempo_code='8', itoa_code='JB', aliases=['jbdfb', 'jbroach', 'jbafb'],
        itrf_xyz=[3822626.04, -154105.65, 5086486.04])
TopoObs('nancay',       tempo_code='f', itoa_code='NC', aliases=['ncy'],
        itrf_xyz=[4324165.81, 165927.11, 4670132.83])
TopoObs('ncyobs',       tempo_code='f', itoa_code='NC', aliases=['ncyobs'],
        itrf_xyz=[4324165.81, 165927.11, 4670132.83], clock_fmt='tempo2',
        clock_file='ncyobs2obspm.clk', clock_dir='TEMPO2')
TopoObs('effelsberg',   tempo_code='g', itoa_code='EF', aliases=['eff'],
        itrf_xyz=[4033949.5, 486989.4, 4900430.8])
TopoObs('wsrt',         tempo_code='i', itoa_code='WB',
        itrf_xyz=[3828445.659, 445223.600, 5064921.5677])
TopoObs('mwa',          tempo_code='u', itoa_code='MW',
        itrf_xyz=[-2559454.08, 5095372.14, -2849057.18])
TopoObs('lwa1',         tempo_code='x', itoa_code='LW',
        itrf_xyz=[-1602196.60, -5042313.47, 3553971.51])
TopoObs('ps1',          tempo_code='p', itoa_code='PS',
Exemple #10
0
"""Definitions for standard observatories.

These observatories are registered when this file is imported. As a result it
cannot be imported until TopoObs has successfully been imported.

"""
from __future__ import absolute_import, division, print_function

from pint.observatory.topo_obs import TopoObs

TopoObs(
    "gbt",
    tempo_code="1",
    itoa_code="GB",
    itrf_xyz=[882589.65, -4924872.32, 3943729.348],
)
TopoObs(
    "arecibo",
    tempo_code="3",
    itoa_code="AO",
    aliases=["aoutc"],
    itrf_xyz=[2390490.0, -5564764.0, 1994727.0],
)
TopoObs(
    "vla",
    tempo_code="6",
    itoa_code="VL",
    aliases=["jvla"],
    itrf_xyz=[-1601192.0, -5041981.4, 3554871.4],
)
TopoObs(
Exemple #11
0
# PINT observatories.py

# This file contains the basic definitions of observatory sites for
# PINT.
from __future__ import absolute_import, print_function, division
from pint.observatory.topo_obs import TopoObs

TopoObs('gbt',          tempo_code='1', itoa_code='GB',
        itrf_xyz=[882589.65, -4924872.32, 3943729.348])
TopoObs('arecibo',      tempo_code='3', itoa_code='AO', aliases=['aoutc'],
        itrf_xyz=[2390490.0, -5564764.0, 1994727.0])
TopoObs('vla',          tempo_code='6', itoa_code='VL', aliases=['jvla'],
        itrf_xyz=[-1601192.0, -5041981.4, 3554871.4])
TopoObs('parkes',       tempo_code='7', itoa_code='PK', aliases=['pks'],
        itrf_xyz=[-4554231.5, 2816759.1, -3454036.3])
TopoObs('jodrell',      tempo_code='8', itoa_code='JB', aliases=['jbdfb', 'jbroach', 'jbafb'],
        itrf_xyz=[3822626.04, -154105.65, 5086486.04])
TopoObs('nancay',       tempo_code='f', itoa_code='NC', aliases=['ncy'],
        itrf_xyz=[4324165.81, 165927.11, 4670132.83])
TopoObs('ncyobs', aliases=['ncyobs'],
        itrf_xyz=[4324165.81, 165927.11, 4670132.83], clock_fmt='tempo2',
        clock_file=['ncyobs2obspm.clk','obspm2gps.clk'], clock_dir='TEMPO2')
TopoObs('effelsberg',   tempo_code='g', itoa_code='EF', aliases=['eff'],
        itrf_xyz=[4033949.5, 486989.4, 4900430.8])
TopoObs('gmrt',   tempo_code='r', itoa_code='GM', clock_fmt='tempo2',
        clock_file='gmrt2gps.clk', clock_dir='TEMPO2',
        itrf_xyz=[1656342.30, 5797947.77, 2073243.16])
TopoObs('wsrt',         tempo_code='i', itoa_code='WB',
        itrf_xyz=[3828445.659, 445223.600, 5064921.5677])
TopoObs('mwa',          tempo_code='u', itoa_code='MW',
        itrf_xyz=[-2559454.08, 5095372.14, -2849057.18])
Exemple #12
0
"""Definitions for standard observatories.

These observatories are registered when this file is imported. As a result it
cannot be imported until TopoObs has successfully been imported.

"""
from pint.observatory.topo_obs import TopoObs

TopoObs(
    "gbt",
    tempo_code="1",
    itoa_code="GB",
    itrf_xyz=[882589.65, -4924872.32, 3943729.348],
    origin="This is a test",
)
TopoObs(
    "arecibo",
    tempo_code="3",
    itoa_code="AO",
    aliases=["aoutc"],
    itrf_xyz=[2390490.0, -5564764.0, 1994727.0],
)
TopoObs(
    "vla",
    tempo_code="6",
    itoa_code="VL",
    aliases=["jvla"],
    itrf_xyz=[-1601192.0, -5041981.4, 3554871.4],
)
TopoObs(
    "meerkat",
Exemple #13
0
"""Definitions for standard observatories.

These observatories are registered when this file is imported. As a result it
cannot be imported until TopoObs has successfully been imported.
"""
from pint.observatory.topo_obs import TopoObs

TopoObs(
    "gbt",
    tempo_code="1",
    itoa_code="GB",
    itrf_xyz=[882589.289, -4924872.368, 3943729.418],
    origin="""The Robert C. Byrd Green Bank Telescope.

    This data was obtained by Joe Swiggum from Ryan Lynch in 2021 September.
    """,
)
TopoObs(
    "gbt_pre_2021",
    itrf_xyz=[882589.65, -4924872.32, 3943729.348],
    origin="""The Robert C. Byrd Green Bank Telescope.

    The origin of this data is unknown but as of 2021 June 8 it agrees exactly with
    the values used by TEMPO and TEMPO2.
    """,
)
TopoObs(
    "arecibo",
    tempo_code="3",
    itoa_code="AO",
    aliases=["aoutc"],
Exemple #14
0
# PINT observatories.py

# This file contains the basic definitions of observatory sites for
# PINT.
from __future__ import absolute_import, print_function, division
from pint.observatory.topo_obs import TopoObs

TopoObs('gbt',
        tempo_code='1',
        itoa_code='GB',
        itrf_xyz=[882589.65, -4924872.32, 3943729.348])
TopoObs('arecibo',
        tempo_code='3',
        itoa_code='AO',
        aliases=['aoutc'],
        itrf_xyz=[2390490.0, -5564764.0, 1994727.0])
TopoObs('vla',
        tempo_code='6',
        itoa_code='VL',
        aliases=['jvla'],
        itrf_xyz=[-1601192.0, -5041981.4, 3554871.4])
TopoObs('parkes',
        tempo_code='7',
        itoa_code='PK',
        aliases=['pks'],
        itrf_xyz=[-4554231.5, 2816759.1, -3454036.3])
TopoObs('jodrell',
        tempo_code='8',
        itoa_code='JB',
        aliases=['jbdfb', 'jbroach', 'jbafb'],
        itrf_xyz=[3822626.04, -154105.65, 5086486.04])