Skip to content

Commit

Permalink
update for reading dataset55 without soaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jankoslavic committed Jan 20, 2024
1 parent 9e952df commit a2022bf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
15 changes: 15 additions & 0 deletions data/uff55 sample_test record10.uff
Original file line number Diff line number Diff line change
@@ -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
36 changes: 19 additions & 17 deletions pyuff/datasets/dataset_55.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions tests/test_55.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit a2022bf

Please sign in to comment.