def test_assign_receiver_points():
    rec_counts, _ = ww.calculate_receiver_window_counts(windows)

    def _assert(_points):
        for p in _points:
            if p.tag == "II.AAK..BHZ":
                npt.assert_almost_equal(p.latitude, 0.0)
                npt.assert_almost_equal(p.longitude, 0.0)
            elif p.tag == "II.ABKT..BHZ":
                npt.assert_almost_equal(p.latitude, 0.0)
                npt.assert_almost_equal(p.longitude, 120.0)
            elif p.tag == "IU.BCD..BHZ":
                npt.assert_almost_equal(p.latitude, 0.0)
                npt.assert_almost_equal(p.longitude, -120.0)

    points = ww.assign_receiver_to_points(rec_counts["BHZ"], stations)
    assert len(points) == 3
    _assert(points)

    points = ww.assign_receiver_to_points(rec_counts["BHR"], stations)
    assert len(points) == 3
    _assert(points)

    points = ww.assign_receiver_to_points(rec_counts["BHT"], stations)
    assert len(points) == 2
    _assert(points)
Beispiel #2
0
def test_assign_receiver_points():
    rec_counts, _ = ww.calculate_receiver_window_counts(windows)

    def _assert(_points):
        for p in _points:
            if p.tag == "II.AAK..BHZ":
                npt.assert_almost_equal(p.latitude, 0.0)
                npt.assert_almost_equal(p.longitude, 0.0)
            elif p.tag == "II.ABKT..BHZ":
                npt.assert_almost_equal(p.latitude, 0.0)
                npt.assert_almost_equal(p.longitude, 120.0)
            elif p.tag == "IU.BCD..BHZ":
                npt.assert_almost_equal(p.latitude, 0.0)
                npt.assert_almost_equal(p.longitude, -120.0)

    points = ww.assign_receiver_to_points(rec_counts["BHZ"], stations)
    assert len(points) == 3
    _assert(points)

    points = ww.assign_receiver_to_points(rec_counts["BHR"], stations)
    assert len(points) == 3
    _assert(points)

    points = ww.assign_receiver_to_points(rec_counts["BHT"], stations)
    assert len(points) == 2
    _assert(points)
def test_get_receiver_weights():
    center = SpherePoint(0, 0, tag="source")

    rec_counts, _ = ww.calculate_receiver_window_counts(windows)

    points = ww.assign_receiver_to_points(rec_counts["BHZ"], stations)
    ref_distance, cond_number = ww.get_receiver_weights(
        "BHZ", center, points, 0.35, plot=False)
    for p in points:
        npt.assert_almost_equal(p.weight, 1.0)
    npt.assert_almost_equal(cond_number, 1.0)

    points = ww.assign_receiver_to_points(rec_counts["BHT"], stations)
    ref_distance, cond_number = ww.get_receiver_weights(
        "BHZ", center, points, 0.35, plot=False)
    for p in points:
        npt.assert_almost_equal(p.weight, 1.0)
    npt.assert_almost_equal(cond_number, 1.0)
Beispiel #4
0
def test_get_receiver_weights():
    center = SpherePoint(0, 0, tag="source")

    rec_counts, _ = ww.calculate_receiver_window_counts(windows)

    points = ww.assign_receiver_to_points(rec_counts["BHZ"], stations)
    ref_distance, cond_number = ww.get_receiver_weights(
        "BHZ", center, points, 0.35, plot=False)
    for p in points:
        npt.assert_almost_equal(p.weight, 1.0)
    npt.assert_almost_equal(cond_number, 1.0)

    points = ww.assign_receiver_to_points(rec_counts["BHT"], stations)
    ref_distance, cond_number = ww.get_receiver_weights(
        "BHZ", center, points, 0.35, plot=False)
    for p in points:
        npt.assert_almost_equal(p.weight, 1.0)
    npt.assert_almost_equal(cond_number, 1.0)
def test_normalize_receiver_weights():
    rec_counts, cat_wcounts = ww.calculate_receiver_window_counts(windows)

    comp = "BHZ"
    channels = list(rec_counts[comp].keys())
    channels.sort()
    points = ww.assign_receiver_to_points(channels, stations)
    weights = ww.normalize_receiver_weights(points, rec_counts[comp])
    assert len(weights) == 3
    for v in weights.values():
        npt.assert_almost_equal(v, 1.0)

    points[0].weight = 0.5
    points[1].weight = 0.75
    points[2].weight = 1.0
    weights = ww.normalize_receiver_weights(points, rec_counts[comp])
    assert len(weights) == 3
    npt.assert_almost_equal(weights["II.AAK..BHZ"], 0.625)
    npt.assert_almost_equal(weights["II.ABKT..BHZ"], 0.9375)
    npt.assert_almost_equal(weights["IU.BCD..BHZ"], 1.25)
Beispiel #6
0
def test_normalize_receiver_weights():
    rec_counts, cat_wcounts = ww.calculate_receiver_window_counts(windows)

    comp = "BHZ"
    channels = rec_counts[comp].keys()
    channels.sort()
    points = ww.assign_receiver_to_points(channels, stations)
    weights = ww.normalize_receiver_weights(points, rec_counts[comp])
    assert len(weights) == 3
    for v in weights.itervalues():
        npt.assert_almost_equal(v, 1.0)

    points[0].weight = 0.5
    points[1].weight = 0.75
    points[2].weight = 1.0
    weights = ww.normalize_receiver_weights(points, rec_counts[comp])
    assert len(weights) == 3
    npt.assert_almost_equal(weights["II.AAK..BHZ"], 0.625)
    npt.assert_almost_equal(weights["II.ABKT..BHZ"], 0.9375)
    npt.assert_almost_equal(weights["IU.BCD..BHZ"], 1.25)