def test_process_reverse_polarity():
    """algorithm_test.AdjustedAlgorithm_test.test_process()

    Check adjusted data processing versus files generated from
    original script. Tests reverse polarity martix.
    """
    # load adjusted data transform matrix and pier correction
    a = adj(
        statefile="etc/adjusted/adjbou_state_HE_.json",
        inchannels=["H", "E"],
        outchannels=["H", "E"],
    )

    # load boulder May 20 files from /etc/ directory
    with open("etc/adjusted/BOU202005vmin.min") as f:
        raw = i2.IAGA2002Factory().parse_string(f.read())
    with open("etc/adjusted/BOU202005adj.min") as f:
        expected = i2.IAGA2002Factory().parse_string(f.read())

    # process he(raw) channels with loaded transform
    adjusted = a.process(raw)

    # compare channels from adjusted and expected streams
    assert_almost_equal(
        actual=adjusted.select(channel="H")[0].data,
        desired=expected.select(channel="H")[0].data,
        decimal=2,
    )
    assert_almost_equal(
        actual=adjusted.select(channel="E")[0].data,
        desired=expected.select(channel="E")[0].data,
        decimal=2,
    )
def test_construct():
    """algorithm_test.AdjustedAlgorithm_test.test_construct()"""
    # load adjusted data transform matrix and pier correction
    a = adj(statefile="etc/adjusted/adjbou_state_.json")

    assert_almost_equal(actual=a.matrix[0, 0], desired=9.83427577e-01, decimal=6)

    assert_equal(actual=a.pier_correction, desired=-22)
예제 #3
0
def test_construct():
    """algorithm_test.AdjustedAlgorithm_test.test_construct()
    """
    matrix = None
    pier_correction = None
    # load adjusted data transform matrix and pier correction
    a = adj(matrix, pier_correction, "etc/adjusted/adjbou_state_.json")

    assert_almost_equal(a.matrix[0, 0], 9.83427577e-01, 6)

    assert_equal(a.pier_correction, -22)
def test_construct():
    """algorithm_test.AdjustedAlgorithm_test.test_construct()
    """
    matrix = None
    pier_correction = None
    # load adjusted data transform matrix and pier correction
    a = adj(matrix, pier_correction, 'etc/adjusted/adjbou_state_.json')

    assert_almost_equals(a.matrix[0, 0], 9.83427577e-01, 6)

    assert_equals(a.pier_correction, -22)
def test_construct():
    """
    path to
    """
    matrix = None
    pier_correction = None
    # load adjusted data transform matrix and pier correction
    a = adj(matrix, pier_correction, 'etc/adjusted/adjbou_state_.json')

    assert_almost_equals(a.matrix[0, 0], 9.83427577e-01, 6)

    assert_equals(a.pier_correction, -22)
def test_process_XYZF():
    """algorithm_test.AdjustedAlgorithm_test.test_process()

    Check adjusted data processing versus files generated from
    original script
    """
    # load adjusted data transform matrix and pier correction
    a = adj(statefile="etc/adjusted/adjbou_state_.json")

    # load boulder Jan 16 files from /etc/ directory
    with open("etc/adjusted/BOU201601vmin.min") as f:
        raw = i2.IAGA2002Factory().parse_string(f.read())
    with open("etc/adjusted/BOU201601adj.min") as f:
        expected = i2.IAGA2002Factory().parse_string(f.read())

    # process hezf (raw) channels with loaded transform
    adjusted = a.process(raw)

    # compare channels from adjusted and expected streams
    assert_almost_equal(
        actual=adjusted.select(channel="X")[0].data,
        desired=expected.select(channel="X")[0].data,
        decimal=2,
    )
    assert_almost_equal(
        actual=adjusted.select(channel="Y")[0].data,
        desired=expected.select(channel="Y")[0].data,
        decimal=2,
    )
    assert_almost_equal(
        actual=adjusted.select(channel="Z")[0].data,
        desired=expected.select(channel="Z")[0].data,
        decimal=2,
    )
    assert_almost_equal(
        actual=adjusted.select(channel="F")[0].data,
        desired=expected.select(channel="F")[0].data,
        decimal=2,
    )
def test_process():
    """algorithm_test.AdjustedAlgorithm_test.test_process()

    Check adjusted data processing versus files generated from
    original script
    """
    matrix = None
    pier_correction = None
    # load adjusted data transform matrix and pier correction
    a = adj(matrix, pier_correction, 'etc/adjusted/adjbou_state_.json')

    # load boulder Jan 16 files from /etc/ directory
    hezf_iaga2002_file = open('etc/adjusted/BOU201601vmin.min')
    hezf_iaga2002_string = hezf_iaga2002_file.read()
    xyzf_iaga2002_file = open('etc/adjusted/BOU201601adj.min')
    xyzf_iaga2002_string = xyzf_iaga2002_file.read()
    factory = i2.IAGA2002Factory()
    hezf = factory.parse_string(hezf_iaga2002_string)
    xyzf = factory.parse_string(xyzf_iaga2002_string)

    # process hezf (raw) channels with loaded transform
    adj_bou = a.process(hezf)

    # unpack channels from loaded adjusted data file
    x = xyzf.select(channel='X')[0]
    y = xyzf.select(channel='Y')[0]
    z = xyzf.select(channel='Z')[0]
    f = xyzf.select(channel='F')[0]
    # unpack channels from adjusted processing of raw data
    x_adj = adj_bou.select(channel='X')[0]
    y_adj = adj_bou.select(channel='Y')[0]
    z_adj = adj_bou.select(channel='Z')[0]
    f_adj = adj_bou.select(channel='F')[0]

    for r in range(hezf[0].data.size):
        assert_almost_equals(x.data[r], x_adj.data[r], 1)
        assert_almost_equals(y.data[r], y_adj.data[r], 1)
        assert_almost_equals(z.data[r], z_adj.data[r], 1)
        assert_almost_equals(f.data[r], f_adj.data[r], 1)