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)
def test_srf2corners(test_srf, filename, sample_cnr_file_path): # NOTE : The testing was carried out based on the assumption that the hypocentre was correct # srf.srf2corners method calls the get_hypo method inside it, which gives the hypocentre value abs_filename = os.path.join(DIR_NAME, filename) print("abs_filename: ", abs_filename) srf.srf2corners(test_srf, cnrs=abs_filename) cmd = "diff " + sample_cnr_file_path + " " + abs_filename out, err = shared.exe(cmd) assert len(out) == 0 and len(err) == 0 utils.remove_file(abs_filename)
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)