Пример #1
0
def test_pgv(mmi, pgvout, mmiout, sample_pgv, sample_mmi):
    files_to_del = []
    if pgvout:
        pgvout = os.path.join(TMP_DIR_NAME, pgvout)
        files_to_del.append(pgvout)
    if mmiout:
        mmiout = os.path.join(TMP_DIR_NAME, mmiout)
        files_to_del.append(mmiout)

    xyts_test_output_array = OBJ_XYTS.pgv(mmi=mmi, pgvout=pgvout, mmiout=mmiout)

    if pgvout:
        sample_pgv_array = np.fromfile(sample_pgv, dtype="3<f4")
        test_pgvout_array = np.fromfile(pgvout, dtype="3<f4")
        utils.compare_np_array(sample_pgv_array, test_pgvout_array)
        if mmiout:
            sample_mmi_array = np.fromfile(sample_mmi, dtype="3<f4")
            test_mmiout_array = np.fromfile(mmiout, dtype="3<f4")
            utils.compare_np_array(sample_mmi_array, test_mmiout_array)
    else:
        if not mmi:
            sample_pgv_array = np.fromfile(sample_pgv, dtype="3<f4")
            utils.compare_np_array(sample_pgv_array, xyts_test_output_array)
        elif mmiout == None:
            pgv, mmi = xyts_test_output_array
            sample_pgv_array = np.fromfile(sample_pgv, dtype="3<f4")
            utils.compare_np_array(sample_pgv_array, pgv)
            sample_mmi_array = np.fromfile(sample_mmi, dtype="3<f4")
            utils.compare_np_array(sample_mmi_array, mmi)

    for f in files_to_del:
        utils.remove_file(f)
Пример #2
0
def test_srf2llv_py(test_srf, sample_out_array):
    sample_array = np.fromfile(sample_out_array, dtype="3<f4")
    out_array_list = srf.srf2llv_py(test_srf)
    print("Adsfafsaf", out_array_list)
    out_array = out_array_list[0]
    # out_array[0] += 1 # Use this, if you want to test for a fail case, by changing a value in the out_array
    for array in out_array_list[1:]:
        out_array = np.concatenate([out_array, array])
    print("first out array", out_array)
    utils.compare_np_array(sample_array, out_array)
Пример #3
0
def test_tslice_get(step, comp, test_outfile, sample_outfile):
    files_to_del = []
    if test_outfile:
        test_outfile = os.path.join(TMP_DIR_NAME, test_outfile)
        sample_outfile = os.path.join(SAMPLE_OUT_DIR_PATH, sample_outfile)
        test_tslice_output_array = OBJ_XYTS.tslice_get(step, comp, test_outfile)
        sample_array = np.fromfile(sample_outfile, dtype="3<f4")
        if test_tslice_output_array:
            utils.compare_np_array(sample_array, test_tslice_output_array)
        else:
            test_outfile_array = np.fromfile(test_outfile, dtype="3<f4")
            utils.compare_np_array(sample_array, test_outfile_array)
            files_to_del.append(test_outfile)
    for f in files_to_del:
        utils.remove_file(f)
Пример #4
0
def test_corners(gmt_format, expected_corners):
    computed_corners = OBJ_XYTS.corners(gmt_format=gmt_format)
    if gmt_format:
        utils.compare_np_array(
            np.array(computed_corners[0]), np.array(expected_corners[0])
        )
        cc = np.array([x.split() for x in computed_corners[1].split("\n")], dtype=float)
        ec = np.array([x.split() for x in expected_corners[1].split("\n")], dtype=float)
        utils.compare_np_array(cc, ec)

    else:
        utils.compare_np_array(np.array(computed_corners), np.array(expected_corners))
Пример #5
0
def test_srf2llv(test_srf, sample_out_array):
    sample_array = np.fromfile(sample_out_array, dtype="3<f4")
    out_array = srf.srf2llv(test_srf)
    utils.compare_np_array(sample_array, out_array)
Пример #6
0
def test_wgs_nztm2000x(test_lonlat, output_points):
    test_points = geo.wgs_nztm2000x(test_lonlat)
    sample_output_points = np.array(output_points)
    utils.compare_np_array(test_points, sample_output_points)