コード例 #1
0
ファイル: maps.py プロジェクト: rgrapenthin/obspy
from obspy import UTCDateTime
from obspy.core.util.base import get_basemap_version, get_cartopy_version

BASEMAP_VERSION = get_basemap_version()
if BASEMAP_VERSION:
    from mpl_toolkits.basemap import Basemap
    HAS_BASEMAP = True
    if BASEMAP_VERSION < [1, 0, 4]:
        warnings.warn("All basemap version < 1.0.4 contain a serious bug "
                      "when rendering countries and continents. ObsPy will "
                      "still work but the maps might be wrong. Please update "
                      "your basemap installation.")
else:
    HAS_BASEMAP = False

CARTOPY_VERSION = get_cartopy_version()
if CARTOPY_VERSION and CARTOPY_VERSION >= [0, 12, 0]:
    import cartopy.crs as ccrs
    import cartopy.feature as cfeature
    HAS_CARTOPY = True
else:
    HAS_CARTOPY = False

if not HAS_BASEMAP and not HAS_CARTOPY:
    msg = ("Neither basemap nor cartopy installed, map plots will not work.")
    warnings.warn(msg)

_BASEMAP_RESOLUTIONS = {
    '110m': 'l',
    '50m': 'i',
    '10m': 'f',
コード例 #2
0
ファイル: test_event.py プロジェクト: 3rdcycle/obspy
import sys
import unittest
import warnings

from obspy.core.event import (Catalog, Comment, CreationInfo, Event, Origin,
                              Pick, ResourceIdentifier, WaveformStreamID,
                              read_events)
from obspy.core.utcdatetime import UTCDateTime
from obspy.core.util.base import get_basemap_version, get_cartopy_version
from obspy.core.util.testing import ImageComparison

BASEMAP_VERSION = get_basemap_version()
if BASEMAP_VERSION:
    from matplotlib import rcParams

CARTOPY_VERSION = get_cartopy_version()
if CARTOPY_VERSION and CARTOPY_VERSION >= [0, 12, 0]:
    HAS_CARTOPY = True
else:
    HAS_CARTOPY = False


class EventTestCase(unittest.TestCase):
    """
    Test suite for obspy.core.event.Event
    """
    def setUp(self):
        # Clear the Resource Identifier dict for the tests. NEVER do this
        # otherwise.
        ResourceIdentifier._ResourceIdentifier__resource_id_weak_dict.clear()
        # Also clear the tracker.