Пример #1
0
def test_station_xml(tmpdir):
    """
    Tests the StationXML support.
    """
    # Most generic way to get the actual data directory.
    data_dir = os.path.join(
        os.path.dirname(
            os.path.abspath(inspect.getfile(inspect.currentframe()))), "data",
        "station_files")

    # Create a temporary directory.
    directory = str(tmpdir)

    cache_file = os.path.join(directory, "cache.sqlite")
    seed_directory = os.path.join(directory, "SEED")
    resp_directory = os.path.join(directory, "RESP")
    stationxml_directory = os.path.join(directory, "StationXML")
    os.makedirs(seed_directory)
    os.makedirs(resp_directory)
    os.makedirs(stationxml_directory)

    # Copy the StationXML file.
    shutil.copy(
        os.path.join(data_dir, "stationxml",
                     "IRIS_single_channel_with_response.xml"),
        os.path.join(stationxml_directory,
                     "IRIS_single_channel_with_response.xml"))

    # Init station cache.
    station_cache = StationCache(cache_file,
                                 directory,
                                 seed_directory,
                                 resp_directory,
                                 stationxml_directory,
                                 read_only=False)
    stations = station_cache.get_stations()
    channels = station_cache.get_channels()
    filename = station_cache.get_station_filename(
        "IU.ANMO.10.BHZ", obspy.UTCDateTime(2013, 1, 1))

    assert len(stations) == 1
    assert stations == {
        "IU.ANMO": {
            "latitude": 34.945913,
            "longitude": -106.457122
        }
    }
    assert len(channels) == 1
    assert channels == {
        "IU.ANMO.10.BHZ": [{
            "local_depth_in_m": 57.0,
            "endtime_timestamp": 19880899199,
            "elevation_in_m": 1759.0,
            "startime_timestamp": 1331626200,
            "longitude": -106.457122,
            "latitude": 34.945913
        }]
    }
    assert filename == os.path.join(stationxml_directory,
                                    "IRIS_single_channel_with_response.xml")
Пример #2
0
def test_station_xml(tmpdir):
    """
    Tests the StationXML support.
    """
    # Most generic way to get the actual data directory.
    data_dir = os.path.join(os.path.dirname(os.path.abspath(inspect.getfile(
        inspect.currentframe()))), "data", "station_files")

    # Create a temporary directory.
    directory = str(tmpdir)

    cache_file = os.path.join(directory, "cache.sqlite")
    seed_directory = os.path.join(directory, "SEED")
    resp_directory = os.path.join(directory, "RESP")
    stationxml_directory = os.path.join(directory, "StationXML")
    os.makedirs(seed_directory)
    os.makedirs(resp_directory)
    os.makedirs(stationxml_directory)

    # Copy the StationXML file.
    shutil.copy(os.path.join(data_dir, "stationxml",
                             "IRIS_single_channel_with_response.xml"),
                os.path.join(stationxml_directory,
                             "IRIS_single_channel_with_response.xml"))

    # Init station cache.
    station_cache = StationCache(cache_file, directory, seed_directory,
                                 resp_directory, stationxml_directory,
                                 read_only=False)
    stations = station_cache.get_stations()
    channels = station_cache.get_channels()
    filename = station_cache.get_station_filename(
        "IU.ANMO.10.BHZ", obspy.UTCDateTime(2013, 1, 1))

    assert len(stations) == 1
    assert stations == {"IU.ANMO": {"latitude": 34.945913,
                                    "longitude": -106.457122}}
    assert len(channels) == 1
    assert channels == {"IU.ANMO.10.BHZ": [
        {"local_depth_in_m": 57.0, "endtime_timestamp": 19880899199,
         "elevation_in_m": 1759.0, "startime_timestamp": 1331626200,
         "longitude": -106.457122, "latitude": 34.945913}]}
    assert filename == os.path.join(
        stationxml_directory, "IRIS_single_channel_with_response.xml")