def test_read_returns_array_time_dimension_first(): filename = r"tests/testdata/HD2D.dfsu" dfs = dfsu() (data, t, names) = dfs.read(filename, item_numbers=[3]) assert data[0].shape == (9, 884)
def test_read_all_items_returns_all_items_and_names(): filename = r"tests/testdata/HD2D.dfsu" dfs = dfsu() (data, t, names) = dfs.read(filename) assert len(data) == 4 assert len(names) == 4
def test_read_single_item_returns_single_item(): filename = r"tests/testdata/HD2D.dfsu" dfs = dfsu() (data, t, names) = dfs.read(filename, item_numbers=[3]) assert len(data) == 1 assert len(names) == 1
def test_read_single_time_step_outside_bounds_fails(): filename = r"tests/testdata/HD2D.dfsu" dfs = dfsu() with pytest.raises(Exception): (data, t, names) = dfs.read(filename, item_numbers=[0,3 ], time_steps=[100])
def test_read_single_time_step(): filename = r"tests/testdata/HD2D.dfsu" dfs = dfsu() (data, t, names) = dfs.read(filename, item_numbers=[0, 3], time_steps=[1]) assert len(t) == 1 assert data[0].shape[0] == 1
def test_read_selected_item_returns_correct_items(): filename = r"tests/testdata/HD2D.dfsu" dfs = dfsu() (data, t, names) = dfs.read(filename, item_numbers=[0, 3]) assert len(data) == 2 assert len(names) == 2 assert names[0] == "Surface elevation" assert names[1] == "Current speed"
def dfsu_reading(): dfs = dfsu.dfsu() (data_list, time, names) = dfs.read("kq_ngaplut_py.dfsu") ec = dfs.get_element_coords() f = open("ec", "w") for data in ec: f.write(str(data[0]) + '\t' + str(data[1])) f.write("\n") f.close() print("np.shape(data_list)") print(np.shape(data_list)) print(data_list) print(len(data_list)) data_list = np.array(data_list) print(len(data_list)) print(data_list) index = 0 for i in data_list: # print(len(i)) # print (i) # print("names[index]") # print(names[index]) for idx in range(len(time)): filename = "DFSU_ouputFiles\\" + names[index] + "_" + str( idx) + ".csv" f = open(filename, "w") f.write('Element' + ',' + names[index] + ',' + 'X' + ',' + 'Y') f.write("\n") for count, data in enumerate(i[:, idx]): # f.write(str(count) +',' + str(data) + ',' + str(ec[count, 0]) + ',' + str(ec[count, 1])) f.write( str(ec[count, 0]) + ',' + str(ec[count, 1]) + ',' + str(data)) f.write("\n") f.close() index = index + 1