Skip to content

Commit b3e7680

Browse files
authored
Merge pull request #85 from ladisk/update_55_spaces
ENH: update for reading dataset55 without soaces
2 parents 9e952df + a2022bf commit b3e7680

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

data/uff55 sample_test record10.uff

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-1
2+
55
3+
TESTTEST:Cfg=0:C1:trans:111121
4+
SWP:FS= 10.00:FE= 20.00:F=0.1111:None:None:NONE:M
5+
POMA:PF=2.55e-05:NM= 5:GF= 4.8612:MIF= 200:MPC=87.41:MPD=12.55:N:ROT=0.0000
6+
FR=8.9999:d=0.1111:NP=260201+Y:MG= 55.11111111:MD= 0.0379:PoMD=260201
7+
999999 3 8 13
8+
1 3 2 8 5 3
9+
2 6 0 1
10+
-1.111111E-01 4.111111E+01 4.111111E+03-3.111111E+03-1.111110E+05-2.111110E+05
11+
111111
12+
0.000000E+00 0.000000E+00 1.111111E-01 9.111111E-02 7.111111E-03 4.111111E-03
13+
60101
14+
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00-4.111111E-02-1.111111E-02
15+
-1

pyuff/datasets/dataset_55.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -503,36 +503,38 @@ def _extract55(block_data):
503503
['freq', '', '', '', '', '']))
504504
# Body
505505
split_data = ''.join(split_data[10:])
506-
values = np.asarray([float(str) for str in split_data.split()], 'd')
506+
node_nums = np.asarray([int(str) for str in split_data.splitlines(True)[::2]])
507+
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()
507508
if dset['data_type'] == 2:
508509
# real data
509510
if dset['n_data_per_node'] == 3:
510-
dset['node_nums'] = values[:-3:4].copy()
511-
dset['r1'] = values[1:-2:4].copy()
512-
dset['r2'] = values[2:-1:4].copy()
513-
dset['r3'] = values[3::4].copy()
511+
dset['node_nums'] = node_nums.copy()
512+
dset['r1'] = node_vals[0::3].copy()
513+
dset['r2'] = node_vals[1::3].copy()
514+
dset['r3'] = node_vals[2::3].copy()
514515
else:
515-
dset['node_nums'] = values[:-6:7].copy()
516-
dset['r1'] = values[1:-5:7].copy()
517-
dset['r2'] = values[2:-4:7].copy()
518-
dset['r3'] = values[3:-3:7].copy()
519-
dset['r4'] = values[4:-2:7].copy()
520-
dset['r5'] = values[5:-1:7].copy()
521-
dset['r6'] = values[6::7].copy()
516+
dset['node_nums'] = node_nums.copy()
517+
dset['r1'] = node_vals[0::6].copy()
518+
dset['r2'] = node_vals[1::6].copy()
519+
dset['r3'] = node_vals[2::6].copy()
520+
dset['r4'] = node_vals[3::6].copy()
521+
dset['r5'] = node_vals[4::6].copy()
522+
dset['r6'] = node_vals[5::6].copy()
522523
elif dset['data_type'] == 5:
523524
# complex data
524525
if dset['n_data_per_node'] == 3:
525-
dset['node_nums'] = values[:-6:7].copy()
526-
dset['r1'] = values[1:-5:7] + 1.j * values[2:-4:7]
527-
dset['r2'] = values[3:-3:7] + 1.j * values[4:-2:7]
528-
dset['r3'] = values[5:-1:7] + 1.j * values[6::7]
526+
dset['node_nums'] = node_nums.copy()
527+
dset['r1'] = node_vals[0::6].copy() + 1.j * node_vals[1::6].copy()
528+
dset['r2'] = node_vals[2::6].copy() + 1.j * node_vals[3::6].copy()
529+
dset['r3'] = node_vals[4::6].copy() + 1.j * node_vals[5::6].copy()
529530
else:
530531
raise Exception('Cannot handle 6 points per node and complex data when reading data-set #55')
531532
else:
532533
raise Exception('Error reading data-set #55')
533534
except:
534535
raise Exception('Error reading data-set #55')
535-
del values
536+
del node_nums
537+
del node_vals
536538
return dset
537539

538540

tests/test_55.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pyuff
77

88
def test_read_write_read_given_data():
9+
test_read_write_read_given_data_base('./data/uff55 sample_test record10.uff')
910
test_read_write_read_given_data_base('./data/uff55_translation.uff')
1011
test_read_write_read_given_data_base('./data/uff55_translation_rotation.uff')
1112

0 commit comments

Comments
 (0)