From a2022bfa9c9f8926d8842abd22e78a919186516b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janko=20Slavi=C4=8D?= Date: Sat, 20 Jan 2024 08:16:04 +0100 Subject: [PATCH] update for reading dataset55 without soaces --- data/uff55 sample_test record10.uff | 15 ++++++++++++ pyuff/datasets/dataset_55.py | 36 +++++++++++++++-------------- tests/test_55.py | 1 + 3 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 data/uff55 sample_test record10.uff diff --git a/data/uff55 sample_test record10.uff b/data/uff55 sample_test record10.uff new file mode 100644 index 0000000..2700d49 --- /dev/null +++ b/data/uff55 sample_test record10.uff @@ -0,0 +1,15 @@ + -1 + 55 +TESTTEST:Cfg=0:C1:trans:111121 +SWP:FS= 10.00:FE= 20.00:F=0.1111:None:None:NONE:M +POMA:PF=2.55e-05:NM= 5:GF= 4.8612:MIF= 200:MPC=87.41:MPD=12.55:N:ROT=0.0000 +FR=8.9999:d=0.1111:NP=260201+Y:MG= 55.11111111:MD= 0.0379:PoMD=260201 + 999999 3 8 13 + 1 3 2 8 5 3 + 2 6 0 1 +-1.111111E-01 4.111111E+01 4.111111E+03-3.111111E+03-1.111110E+05-2.111110E+05 + 111111 + 0.000000E+00 0.000000E+00 1.111111E-01 9.111111E-02 7.111111E-03 4.111111E-03 + 60101 + 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00-4.111111E-02-1.111111E-02 + -1 diff --git a/pyuff/datasets/dataset_55.py b/pyuff/datasets/dataset_55.py index 26da18b..a20d5f8 100644 --- a/pyuff/datasets/dataset_55.py +++ b/pyuff/datasets/dataset_55.py @@ -503,36 +503,38 @@ def _extract55(block_data): ['freq', '', '', '', '', ''])) # Body split_data = ''.join(split_data[10:]) - values = np.asarray([float(str) for str in split_data.split()], 'd') + node_nums = np.asarray([int(str) for str in split_data.splitlines(True)[::2]]) + node_vals = np.array([[str[i*13:(i+1)*13] for i in range(len(str)//13) ] for str in split_data.splitlines(True)[1::2]], 'd').flatten() if dset['data_type'] == 2: # real data if dset['n_data_per_node'] == 3: - dset['node_nums'] = values[:-3:4].copy() - dset['r1'] = values[1:-2:4].copy() - dset['r2'] = values[2:-1:4].copy() - dset['r3'] = values[3::4].copy() + dset['node_nums'] = node_nums.copy() + dset['r1'] = node_vals[0::3].copy() + dset['r2'] = node_vals[1::3].copy() + dset['r3'] = node_vals[2::3].copy() else: - dset['node_nums'] = values[:-6:7].copy() - dset['r1'] = values[1:-5:7].copy() - dset['r2'] = values[2:-4:7].copy() - dset['r3'] = values[3:-3:7].copy() - dset['r4'] = values[4:-2:7].copy() - dset['r5'] = values[5:-1:7].copy() - dset['r6'] = values[6::7].copy() + dset['node_nums'] = node_nums.copy() + dset['r1'] = node_vals[0::6].copy() + dset['r2'] = node_vals[1::6].copy() + dset['r3'] = node_vals[2::6].copy() + dset['r4'] = node_vals[3::6].copy() + dset['r5'] = node_vals[4::6].copy() + dset['r6'] = node_vals[5::6].copy() elif dset['data_type'] == 5: # complex data if dset['n_data_per_node'] == 3: - dset['node_nums'] = values[:-6:7].copy() - dset['r1'] = values[1:-5:7] + 1.j * values[2:-4:7] - dset['r2'] = values[3:-3:7] + 1.j * values[4:-2:7] - dset['r3'] = values[5:-1:7] + 1.j * values[6::7] + dset['node_nums'] = node_nums.copy() + dset['r1'] = node_vals[0::6].copy() + 1.j * node_vals[1::6].copy() + dset['r2'] = node_vals[2::6].copy() + 1.j * node_vals[3::6].copy() + dset['r3'] = node_vals[4::6].copy() + 1.j * node_vals[5::6].copy() else: raise Exception('Cannot handle 6 points per node and complex data when reading data-set #55') else: raise Exception('Error reading data-set #55') except: raise Exception('Error reading data-set #55') - del values + del node_nums + del node_vals return dset diff --git a/tests/test_55.py b/tests/test_55.py index e292b6e..80192da 100644 --- a/tests/test_55.py +++ b/tests/test_55.py @@ -6,6 +6,7 @@ import pyuff def test_read_write_read_given_data(): + test_read_write_read_given_data_base('./data/uff55 sample_test record10.uff') test_read_write_read_given_data_base('./data/uff55_translation.uff') test_read_write_read_given_data_base('./data/uff55_translation_rotation.uff')