コード例 #1
0
    def test_util_unified_content_string_with_dots_in_description(self):
        """
        The unified content string might have dots in the station description.

        Make sure it still works.
        """
        contents = (
            [
                'II.ABKT (Alibek, Turkmenistan)',
                'II.ALE (Alert, N.W.T., Canada)'
            ],
            [
                u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia)',
                u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia)',
                u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia)'
            ],
        )
        expected = (
            [
                'II.ABKT (Alibek, Turkmenistan)',
                'II.ALE (Alert, N.W.T., Canada)'
            ],
            [u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia) (3x)'],
        )
        for contents_, expected_ in zip(contents, expected):
            self.assertEqual(expected_, _unified_content_strings(contents_))
コード例 #2
0
ファイル: test_inventory.py プロジェクト: mbyt/obspy
 def test_util_unified_content_string(self):
     """
     Tests helper routine that compresses inventory content lists.
     """
     contents = (
         [
             u'IU.ULN (Ulaanbaatar, Mongolia)',
             u'IU.ULN (Ulaanbaatar, Mongolia)',
             u'IU.ULN (Ulaanbaatar, Mongolia)'
         ],
         [
             u'IU.ULN.00.BH1', u'IU.ULN.00.BH2', u'IU.ULN.00.BHE',
             u'IU.ULN.00.BHE', u'IU.ULN.00.BHE', u'IU.ULN.00.BHE',
             u'IU.ULN.00.BHN', u'IU.ULN.00.BHN', u'IU.ULN.00.BHN',
             u'IU.ULN.00.BHN', u'IU.ULN.00.BHZ', u'IU.ULN.00.BHZ',
             u'IU.ULN.00.BHZ', u'IU.ULN.00.BHZ', u'IU.ULN.00.BHZ',
             u'IU.ULN.00.LH1', u'IU.ULN.00.LH2', u'IU.ULN.00.LHE',
             u'IU.ULN.00.LHE', u'IU.ULN.00.LHE', u'IU.ULN.00.LHE',
             u'IU.ULN.00.LHN', u'IU.ULN.00.LHN', u'IU.ULN.00.LHN',
             u'IU.ULN.00.LHN', u'IU.ULN.00.LHZ', u'IU.ULN.00.LHZ',
             u'IU.ULN.00.LHZ', u'IU.ULN.00.LHZ', u'IU.ULN.00.LHZ',
             u'IU.ULN.00.UHE', u'IU.ULN.00.UHE', u'IU.ULN.00.UHN',
             u'IU.ULN.00.UHN', u'IU.ULN.00.UHZ', u'IU.ULN.00.UHZ',
             u'IU.ULN.00.VE1', u'IU.ULN.00.VE1', u'IU.ULN.00.VH1',
             u'IU.ULN.00.VH2', u'IU.ULN.00.VHE', u'IU.ULN.00.VHE',
             u'IU.ULN.00.VHE', u'IU.ULN.00.VHE', u'IU.ULN.00.VHN',
             u'IU.ULN.00.VHN', u'IU.ULN.00.VHN', u'IU.ULN.00.VHN',
             u'IU.ULN.00.VHZ', u'IU.ULN.00.VHZ', u'IU.ULN.00.VHZ',
             u'IU.ULN.00.VHZ', u'IU.ULN.00.VHZ', u'IU.ULN.00.VK1',
             u'IU.ULN.00.VK1', u'IU.ULN.00.VM1', u'IU.ULN.00.VM2',
             u'IU.ULN.00.VME', u'IU.ULN.00.VME', u'IU.ULN.00.VMN',
             u'IU.ULN.00.VMN', u'IU.ULN.00.VMZ', u'IU.ULN.00.VMZ',
             u'IU.ULN.00.VMZ'
         ],
     )
     expected = (
         [u'IU.ULN (Ulaanbaatar, Mongolia) (3x)'],
         [
             u'IU.ULN.00.BHZ (5x)', u'IU.ULN.00.BHN (4x)',
             u'IU.ULN.00.BHE (4x)', u'IU.ULN.00.BH1', u'IU.ULN.00.BH2',
             u'IU.ULN.00.LHZ (5x)', u'IU.ULN.00.LHN (4x)',
             u'IU.ULN.00.LHE (4x)', u'IU.ULN.00.LH1', u'IU.ULN.00.LH2',
             u'IU.ULN.00.UHZ (2x)', u'IU.ULN.00.UHN (2x)',
             u'IU.ULN.00.UHE (2x)', u'IU.ULN.00.VE1 (2x)',
             u'IU.ULN.00.VHZ (5x)', u'IU.ULN.00.VHN (4x)',
             u'IU.ULN.00.VHE (4x)', u'IU.ULN.00.VH1', u'IU.ULN.00.VH2',
             u'IU.ULN.00.VK1 (2x)', u'IU.ULN.00.VMZ (3x)',
             u'IU.ULN.00.VMN (2x)', u'IU.ULN.00.VME (2x)', u'IU.ULN.00.VM1',
             u'IU.ULN.00.VM2'
         ],
     )
     for contents_, expected_ in zip(contents, expected):
         self.assertEqual(expected_, _unified_content_strings(contents_))
コード例 #3
0
    def __str__(self):
        contents = self.get_contents()

        x = self.latitude
        y = self.longitude
        z = self.elevation
        site_count = len(self.sites)
        channel_count = len(self.channels)
        ret = (f"\tStation {self.historical_code}\n"
               f"\tStation Code: {self.code}\n"
               f"\tSite Count: {site_count}\n"
               f"\tChannel Count: {channel_count}\n"
               f"\t{self.start_date} - {self.end_date}\n"
               f"\tx: {x:.0f}, y: {y:.0f}, z: {z:.0f} m\n")

        if getattr(self, 'extra', None):
            if getattr(self.extra, 'x', None) and getattr(
                    self.extra, 'y', None):
                x = self.x
                y = self.y
                z = self.z
                ret = ("Station {station_name}\n"
                       "\tStation Code: {station_code}\n"
                       "\tChannel Count: {selected}/{total}"
                       " (Selected/Total)\n"
                       "\t{start_date} - {end_date}\n"
                       "\tEasting [x]: {x:.0f} m, Northing [y] m: {y:.0f}, "
                       "Elevation [z]: {z:.0f} m\n")

        ret = ret.format(station_name=contents["stations"][0],
                         station_code=self.code,
                         selected=self.selected_number_of_channels,
                         total=self.total_number_of_channels,
                         start_date=str(self.start_date),
                         end_date=str(self.end_date) if self.end_date else "",
                         restricted=self.restricted_status,
                         alternate_code="Alternate Code: %s " %
                         self.alternate_code if self.alternate_code else "",
                         historical_code="Historical Code: %s " %
                         self.historical_code if self.historical_code else "",
                         x=x,
                         y=y,
                         z=z)
        ret += "\tAvailable Channels:\n"
        ret += "\n".join(
            _textwrap(", ".join(_unified_content_strings(
                contents["channels"])),
                      initial_indent="\t\t",
                      subsequent_indent="\t\t",
                      expand_tabs=False))

        return ret
コード例 #4
0
ファイル: test_inventory.py プロジェクト: jmfee-usgs/obspy
 def test_util_unified_content_string(self):
     """
     Tests helper routine that compresses inventory content lists.
     """
     contents = (
         [u'IU.ULN (Ulaanbaatar, Mongolia)',
          u'IU.ULN (Ulaanbaatar, Mongolia)',
          u'IU.ULN (Ulaanbaatar, Mongolia)'],
         [u'IU.ULN.00.BH1', u'IU.ULN.00.BH2', u'IU.ULN.00.BHE',
          u'IU.ULN.00.BHE', u'IU.ULN.00.BHE', u'IU.ULN.00.BHE',
          u'IU.ULN.00.BHN', u'IU.ULN.00.BHN', u'IU.ULN.00.BHN',
          u'IU.ULN.00.BHN', u'IU.ULN.00.BHZ', u'IU.ULN.00.BHZ',
          u'IU.ULN.00.BHZ', u'IU.ULN.00.BHZ', u'IU.ULN.00.BHZ',
          u'IU.ULN.00.LH1', u'IU.ULN.00.LH2', u'IU.ULN.00.LHE',
          u'IU.ULN.00.LHE', u'IU.ULN.00.LHE', u'IU.ULN.00.LHE',
          u'IU.ULN.00.LHN', u'IU.ULN.00.LHN', u'IU.ULN.00.LHN',
          u'IU.ULN.00.LHN', u'IU.ULN.00.LHZ', u'IU.ULN.00.LHZ',
          u'IU.ULN.00.LHZ', u'IU.ULN.00.LHZ', u'IU.ULN.00.LHZ',
          u'IU.ULN.00.UHE', u'IU.ULN.00.UHE', u'IU.ULN.00.UHN',
          u'IU.ULN.00.UHN', u'IU.ULN.00.UHZ', u'IU.ULN.00.UHZ',
          u'IU.ULN.00.VE1', u'IU.ULN.00.VE1', u'IU.ULN.00.VH1',
          u'IU.ULN.00.VH2', u'IU.ULN.00.VHE', u'IU.ULN.00.VHE',
          u'IU.ULN.00.VHE', u'IU.ULN.00.VHE', u'IU.ULN.00.VHN',
          u'IU.ULN.00.VHN', u'IU.ULN.00.VHN', u'IU.ULN.00.VHN',
          u'IU.ULN.00.VHZ', u'IU.ULN.00.VHZ', u'IU.ULN.00.VHZ',
          u'IU.ULN.00.VHZ', u'IU.ULN.00.VHZ', u'IU.ULN.00.VK1',
          u'IU.ULN.00.VK1', u'IU.ULN.00.VM1', u'IU.ULN.00.VM2',
          u'IU.ULN.00.VME', u'IU.ULN.00.VME', u'IU.ULN.00.VMN',
          u'IU.ULN.00.VMN', u'IU.ULN.00.VMZ', u'IU.ULN.00.VMZ',
          u'IU.ULN.00.VMZ'],
         )
     expected = (
         [u'IU.ULN (Ulaanbaatar, Mongolia) (3x)'],
         [u'IU.ULN.00.BHZ (5x)', u'IU.ULN.00.BHN (4x)',
          u'IU.ULN.00.BHE (4x)', u'IU.ULN.00.BH1', u'IU.ULN.00.BH2',
          u'IU.ULN.00.LHZ (5x)', u'IU.ULN.00.LHN (4x)',
          u'IU.ULN.00.LHE (4x)', u'IU.ULN.00.LH1', u'IU.ULN.00.LH2',
          u'IU.ULN.00.UHZ (2x)', u'IU.ULN.00.UHN (2x)',
          u'IU.ULN.00.UHE (2x)', u'IU.ULN.00.VE1 (2x)',
          u'IU.ULN.00.VHZ (5x)', u'IU.ULN.00.VHN (4x)',
          u'IU.ULN.00.VHE (4x)', u'IU.ULN.00.VH1', u'IU.ULN.00.VH2',
          u'IU.ULN.00.VK1 (2x)', u'IU.ULN.00.VMZ (3x)',
          u'IU.ULN.00.VMN (2x)', u'IU.ULN.00.VME (2x)', u'IU.ULN.00.VM1',
          u'IU.ULN.00.VM2'],
         )
     for contents_, expected_ in zip(contents, expected):
         self.assertEqual(expected_, _unified_content_strings(contents_))
コード例 #5
0
ファイル: test_inventory.py プロジェクト: jmfee-usgs/obspy
    def test_util_unified_content_string_with_dots_in_description(self):
        """
        The unified content string might have dots in the station description.

        Make sure it still works.
        """
        contents = (
            ['II.ABKT (Alibek, Turkmenistan)',
             'II.ALE (Alert, N.W.T., Canada)'],
            [u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia)',
             u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia)',
             u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia)'],
        )
        expected = (
            ['II.ABKT (Alibek, Turkmenistan)',
             'II.ALE (Alert, N.W.T., Canada)'],
            [u'IU.ULN (Ulaanbaatar, A.B.C., Mongolia) (3x)'],
        )
        for contents_, expected_ in zip(contents, expected):
            self.assertEqual(expected_, _unified_content_strings(contents_))