pyuff 2.5.4__tar.gz → 2.5.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyuff-2.5.4 → pyuff-2.5.6}/PKG-INFO +2 -2
- {pyuff-2.5.4 → pyuff-2.5.6}/README.rst +1 -1
- {pyuff-2.5.4 → pyuff-2.5.6}/pyproject.toml +1 -1
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/__init__.py +1 -1
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/__init__.py +2 -0
- pyuff-2.5.6/pyuff/datasets/dataset_18.py +182 -0
- pyuff-2.5.6/pyuff/datasets/dataset_2400.py +208 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/pyuff.py +11 -4
- pyuff-2.5.4/pyuff/datasets/dataset_18.py +0 -87
- {pyuff-2.5.4 → pyuff-2.5.6}/.gitignore +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/LICENSE +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_15.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_151.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_164.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_1858.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_2411.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_2412.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_2414.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_2420.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_2429.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_2467.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_55.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_58.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/datasets/dataset_82.py +0 -0
- {pyuff-2.5.4 → pyuff-2.5.6}/pyuff/tools.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyuff
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.6
|
|
4
4
|
Summary: UFF (Universal File Format) read/write.
|
|
5
5
|
Project-URL: homepage, https://github.com/ladisk/pyuff
|
|
6
6
|
Project-URL: documentation, https://pyuff.readthedocs.io/en/latest/
|
|
@@ -36,7 +36,7 @@ Universal File Format read and write
|
|
|
36
36
|
------------------------------------
|
|
37
37
|
This module defines an UFF class to manipulate with the UFF (Universal File Format) files.
|
|
38
38
|
|
|
39
|
-
Read from and write of data-set types **15, 55, 58, 58b, 82, 151, 164, 1858, 2411, 2412, 2414, 2420, 2429, 2467** are supported.
|
|
39
|
+
Read from and write of data-set types **15, 55, 58, 58b, 82, 151, 164, 1858, 2400, 2411, 2412, 2414, 2420, 2429, 2467** are supported.
|
|
40
40
|
|
|
41
41
|
Check out the `documentation <https://pyuff.readthedocs.io/en/latest/index.html>`_.
|
|
42
42
|
|
|
@@ -7,7 +7,7 @@ Universal File Format read and write
|
|
|
7
7
|
------------------------------------
|
|
8
8
|
This module defines an UFF class to manipulate with the UFF (Universal File Format) files.
|
|
9
9
|
|
|
10
|
-
Read from and write of data-set types **15, 55, 58, 58b, 82, 151, 164, 1858, 2411, 2412, 2414, 2420, 2429, 2467** are supported.
|
|
10
|
+
Read from and write of data-set types **15, 55, 58, 58b, 82, 151, 164, 1858, 2400, 2411, 2412, 2414, 2420, 2429, 2467** are supported.
|
|
11
11
|
|
|
12
12
|
Check out the `documentation <https://pyuff.readthedocs.io/en/latest/index.html>`_.
|
|
13
13
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pyuff"
|
|
7
|
-
version = "2.5.
|
|
7
|
+
version = "2.5.6"
|
|
8
8
|
authors = [{name = "Primož Čermelj, Janko Slavič", email = "janko.slavic@fs.uni-lj.si"}]
|
|
9
9
|
maintainers = [{name = "Janko Slavič et al.", email = "janko.slavic@fs.uni-lj.si"}]
|
|
10
10
|
license = "MIT"
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from .dataset_15 import prepare_15
|
|
2
|
+
from .dataset_18 import prepare_18
|
|
2
3
|
from .dataset_55 import prepare_55
|
|
3
4
|
from .dataset_58 import prepare_58
|
|
4
5
|
from .dataset_82 import prepare_82
|
|
5
6
|
from .dataset_151 import prepare_151
|
|
6
7
|
from .dataset_164 import prepare_164
|
|
7
8
|
from .dataset_1858 import prepare_1858
|
|
9
|
+
from .dataset_2400 import prepare_2400
|
|
8
10
|
from .dataset_2411 import prepare_2411
|
|
9
11
|
from .dataset_2412 import prepare_2412
|
|
10
12
|
from .dataset_2414 import prepare_2414
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from ..tools import _opt_fields, _parse_header_line, check_dict_for_none
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_structure_18(raw=False):
|
|
7
|
+
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
|
|
8
|
+
out = """
|
|
9
|
+
Universal Dataset Number: 18
|
|
10
|
+
|
|
11
|
+
Name: Coordinate Systems
|
|
12
|
+
-----------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
Record 1: FORMAT(5I10)
|
|
15
|
+
Field 1 -- coordinate system number
|
|
16
|
+
Field 2 -- coordinate system type
|
|
17
|
+
Field 3 -- reference coordinate system number
|
|
18
|
+
Field 4 -- color
|
|
19
|
+
Field 5 -- method of definition
|
|
20
|
+
= 1 - origin, +x axis, +xz plane
|
|
21
|
+
|
|
22
|
+
Record 2: FORMAT(20A2)
|
|
23
|
+
Field 1 -- coordinate system name
|
|
24
|
+
|
|
25
|
+
Record 3: FORMAT(1P6E13.5)
|
|
26
|
+
Total of 9 coordinate system definition parameters.
|
|
27
|
+
Fields 1-3 -- origin of new system specified in
|
|
28
|
+
reference system
|
|
29
|
+
Fields 4-6 -- point on +x axis of the new system
|
|
30
|
+
specified in reference system
|
|
31
|
+
Fields 7-9 -- point on +xz plane of the new system
|
|
32
|
+
specified in reference system
|
|
33
|
+
|
|
34
|
+
Records 1 thru 3 are repeated for each coordinate system in the model.
|
|
35
|
+
|
|
36
|
+
-----------------------------------------------------------------
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
if raw:
|
|
40
|
+
return out
|
|
41
|
+
else:
|
|
42
|
+
print(out)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _write18(fh, dset):
|
|
46
|
+
"""Writes dset data - data-set 18 - to an open file fh."""
|
|
47
|
+
try:
|
|
48
|
+
n = len(dset['cs_num'])
|
|
49
|
+
dset = _opt_fields(dset, {
|
|
50
|
+
'cs_type': np.zeros(n, dtype=int),
|
|
51
|
+
'color': np.zeros(n, dtype=int),
|
|
52
|
+
'method': np.ones(n, dtype=int),
|
|
53
|
+
'cs_name': [''] * n,
|
|
54
|
+
})
|
|
55
|
+
fh.write('%6i\n%6i%74s\n' % (-1, 18, ' '))
|
|
56
|
+
for i in range(n):
|
|
57
|
+
fh.write('%10i%10i%10i%10i%10i\n' % (
|
|
58
|
+
int(dset['cs_num'][i]),
|
|
59
|
+
int(dset['cs_type'][i]),
|
|
60
|
+
int(dset['ref_cs_num'][i]),
|
|
61
|
+
int(dset['color'][i]),
|
|
62
|
+
int(dset['method'][i])))
|
|
63
|
+
fh.write('%-40s\n' % dset['cs_name'][i])
|
|
64
|
+
fh.write('%13.5e%13.5e%13.5e%13.5e%13.5e%13.5e\n' % (
|
|
65
|
+
dset['ref_o'][i][0], dset['ref_o'][i][1], dset['ref_o'][i][2],
|
|
66
|
+
dset['x_point'][i][0], dset['x_point'][i][1], dset['x_point'][i][2]))
|
|
67
|
+
fh.write('%13.5e%13.5e%13.5e\n' % (
|
|
68
|
+
dset['xz_point'][i][0], dset['xz_point'][i][1], dset['xz_point'][i][2]))
|
|
69
|
+
fh.write('%6i\n' % -1)
|
|
70
|
+
except KeyError as msg:
|
|
71
|
+
raise Exception('The required key \'' + msg.args[0] + '\' not present when writing data-set #18')
|
|
72
|
+
except:
|
|
73
|
+
raise Exception('Error writing data-set #18')
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _extract18(block_data):
|
|
77
|
+
'''Extract local CS definitions -- data-set 18.'''
|
|
78
|
+
dset = {'type': 18}
|
|
79
|
+
try:
|
|
80
|
+
split_data = block_data.splitlines()
|
|
81
|
+
|
|
82
|
+
# -- Get Record 1
|
|
83
|
+
rec_1 = np.array(list(map(float, ''.join(split_data[2::4]).split())))
|
|
84
|
+
|
|
85
|
+
dset['cs_num'] = rec_1[::5]
|
|
86
|
+
dset['cs_type'] = rec_1[1::5]
|
|
87
|
+
dset['ref_cs_num'] = rec_1[2::5]
|
|
88
|
+
dset['color'] = rec_1[3::5]
|
|
89
|
+
dset['method'] = rec_1[4::5]
|
|
90
|
+
|
|
91
|
+
# -- Get Record 2
|
|
92
|
+
dset['cs_name'] = [s.strip() for s in split_data[3::4]]
|
|
93
|
+
|
|
94
|
+
# -- Get Record 31 and 32
|
|
95
|
+
# ... these are the origins of cs defined in ref
|
|
96
|
+
line_data = ''.join(split_data[4::4])
|
|
97
|
+
rec_31 = [float(line_data[i * 13:(i + 1) * 13]) for i in range(int(len(line_data) / 13))]
|
|
98
|
+
dset['ref_o'] = np.vstack((np.array(rec_31[::6]),
|
|
99
|
+
np.array(rec_31[1::6]),
|
|
100
|
+
np.array(rec_31[2::6]))).transpose()
|
|
101
|
+
|
|
102
|
+
# ... these are points on the x axis of cs defined in ref
|
|
103
|
+
dset['x_point'] = np.vstack((np.array(rec_31[3::6]),
|
|
104
|
+
np.array(rec_31[4::6]),
|
|
105
|
+
np.array(rec_31[5::6]))).transpose()
|
|
106
|
+
|
|
107
|
+
# ... these are the points on the xz plane
|
|
108
|
+
line_data = ''.join(split_data[5::4])
|
|
109
|
+
rec_32 = [float(line_data[i * 13:(i + 1) * 13]) for i in range(int(len(line_data) / 13))]
|
|
110
|
+
dset['xz_point'] = np.vstack((np.array(rec_32[::3]),
|
|
111
|
+
np.array(rec_32[1::3]),
|
|
112
|
+
np.array(rec_32[2::3]))).transpose()
|
|
113
|
+
except:
|
|
114
|
+
raise Exception('Error reading data-set #18')
|
|
115
|
+
return dset
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def prepare_18(
|
|
119
|
+
cs_num=None,
|
|
120
|
+
cs_type=None,
|
|
121
|
+
ref_cs_num=None,
|
|
122
|
+
color=None,
|
|
123
|
+
method=None,
|
|
124
|
+
cs_name=None,
|
|
125
|
+
ref_o=None,
|
|
126
|
+
x_point=None,
|
|
127
|
+
xz_point=None,
|
|
128
|
+
return_full_dict=False):
|
|
129
|
+
"""Name: Coordinate Systems
|
|
130
|
+
|
|
131
|
+
R-Record, F-Field
|
|
132
|
+
|
|
133
|
+
:param cs_num: R1 F1, Coordinate system number (array of int)
|
|
134
|
+
:param cs_type: R1 F2, Coordinate system type (array of int)
|
|
135
|
+
:param ref_cs_num: R1 F3, Reference coordinate system number (array of int)
|
|
136
|
+
:param color: R1 F4, Color (array of int)
|
|
137
|
+
:param method: R1 F5, Method of definition (array of int, 1=origin+x+xz)
|
|
138
|
+
:param cs_name: R2 F1, Coordinate system name (list of str)
|
|
139
|
+
:param ref_o: R3 F1-3, Origin of new system in reference system (Nx3 array)
|
|
140
|
+
:param x_point: R3 F4-6, Point on +x axis in reference system (Nx3 array)
|
|
141
|
+
:param xz_point: R3 F7-9, Point on +xz plane in reference system (Nx3 array)
|
|
142
|
+
:param return_full_dict: If True full dict with all keys is returned, else only specified arguments are included
|
|
143
|
+
|
|
144
|
+
**Test prepare_18**
|
|
145
|
+
|
|
146
|
+
>>> import pyuff
|
|
147
|
+
>>> import os
|
|
148
|
+
>>> save_to_file = 'test_pyuff'
|
|
149
|
+
>>> dataset = pyuff.prepare_18(
|
|
150
|
+
>>> cs_num=[1, 2],
|
|
151
|
+
>>> cs_type=[0, 0],
|
|
152
|
+
>>> ref_cs_num=[0, 0],
|
|
153
|
+
>>> color=[1, 1],
|
|
154
|
+
>>> method=[1, 1],
|
|
155
|
+
>>> cs_name=['CS1', 'CS2'],
|
|
156
|
+
>>> ref_o=[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]],
|
|
157
|
+
>>> x_point=[[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]],
|
|
158
|
+
>>> xz_point=[[0.0, 0.0, 1.0], [1.0, 0.0, 1.0]])
|
|
159
|
+
>>> if save_to_file:
|
|
160
|
+
>>> if os.path.exists(save_to_file):
|
|
161
|
+
>>> os.remove(save_to_file)
|
|
162
|
+
>>> uffwrite = pyuff.UFF(save_to_file)
|
|
163
|
+
>>> uffwrite._write_set(dataset, 'add')
|
|
164
|
+
>>> dataset
|
|
165
|
+
"""
|
|
166
|
+
dataset = {
|
|
167
|
+
'type': 18,
|
|
168
|
+
'cs_num': cs_num,
|
|
169
|
+
'cs_type': cs_type,
|
|
170
|
+
'ref_cs_num': ref_cs_num,
|
|
171
|
+
'color': color,
|
|
172
|
+
'method': method,
|
|
173
|
+
'cs_name': cs_name,
|
|
174
|
+
'ref_o': ref_o,
|
|
175
|
+
'x_point': x_point,
|
|
176
|
+
'xz_point': xz_point,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if return_full_dict is False:
|
|
180
|
+
dataset = check_dict_for_none(dataset)
|
|
181
|
+
|
|
182
|
+
return dataset
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from ..tools import _opt_fields, _parse_header_line, check_dict_for_none
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_structure_2400(raw=False):
|
|
7
|
+
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
|
|
8
|
+
out = """
|
|
9
|
+
Universal Dataset Number: 2400
|
|
10
|
+
|
|
11
|
+
Name: Model Header
|
|
12
|
+
-----------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
Record 1: FORMAT(I12,2I6,I12)
|
|
15
|
+
Field 1 -- model UID
|
|
16
|
+
Field 2 -- entity type
|
|
17
|
+
Field 3 -- entity subtype
|
|
18
|
+
Field 4 -- version number
|
|
19
|
+
Record 2: FORMAT(40A2)
|
|
20
|
+
Field 1 -- entity name
|
|
21
|
+
Record 3: FORMAT(40A2)
|
|
22
|
+
Field 1 -- part number
|
|
23
|
+
Record 4: FORMAT(32I2)
|
|
24
|
+
Field 1 -- status mask (32 values)
|
|
25
|
+
Record 5: FORMAT(10A1,10A1,3I12)
|
|
26
|
+
Field 1 -- date (DD-MMM-YY)
|
|
27
|
+
Field 2 -- time (HH:MM:SS)
|
|
28
|
+
Field 3 -- IDM version ID
|
|
29
|
+
Field 4 -- IDM item ID
|
|
30
|
+
Field 5 -- primary parent UID
|
|
31
|
+
Record 6: FORMAT(I12)
|
|
32
|
+
Field 1 -- optimization switches
|
|
33
|
+
=0 geometry OFF, analysis OFF
|
|
34
|
+
=1 geometry ON, analysis OFF
|
|
35
|
+
=2 geometry OFF, analysis ON
|
|
36
|
+
=3 geometry ON, analysis ON
|
|
37
|
+
|
|
38
|
+
-----------------------------------------------------------------
|
|
39
|
+
"""
|
|
40
|
+
if raw:
|
|
41
|
+
return out
|
|
42
|
+
else:
|
|
43
|
+
print(out)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _write2400(fh, dset):
|
|
47
|
+
"""Writes dset data - data-set 2400 - to an open file fh."""
|
|
48
|
+
try:
|
|
49
|
+
dset = _opt_fields(dset, {
|
|
50
|
+
'model_uid': 0,
|
|
51
|
+
'entity_type': 0,
|
|
52
|
+
'entity_subtype': 0,
|
|
53
|
+
'version_number': 0,
|
|
54
|
+
'entity_name': '',
|
|
55
|
+
'part_number': '',
|
|
56
|
+
'status_mask': [0] * 32,
|
|
57
|
+
'date': '',
|
|
58
|
+
'time': '',
|
|
59
|
+
'idm_version_id': 0,
|
|
60
|
+
'idm_item_id': 0,
|
|
61
|
+
'primary_parent_uid': 0,
|
|
62
|
+
'optimization_switches': 0,
|
|
63
|
+
})
|
|
64
|
+
fh.write('%6i\n%6i%74s\n' % (-1, 2400, ' '))
|
|
65
|
+
fh.write('%12i%6i%6i%12i\n' % (dset['model_uid'], dset['entity_type'],
|
|
66
|
+
dset['entity_subtype'], dset['version_number']))
|
|
67
|
+
fh.write('%-80s\n' % dset['entity_name'])
|
|
68
|
+
fh.write('%-80s\n' % dset['part_number'])
|
|
69
|
+
fh.write('%s\n' % ''.join(['%2i' % v for v in dset['status_mask']]))
|
|
70
|
+
fh.write('%-10s%-10s%12i%12i%12i\n' % (dset['date'], dset['time'],
|
|
71
|
+
dset['idm_version_id'], dset['idm_item_id'],
|
|
72
|
+
dset['primary_parent_uid']))
|
|
73
|
+
fh.write('%12i\n' % dset['optimization_switches'])
|
|
74
|
+
fh.write('%6i\n' % -1)
|
|
75
|
+
except KeyError as msg:
|
|
76
|
+
raise Exception('The required key \'' + msg.args[0] + '\' not present when writing data-set #2400')
|
|
77
|
+
except:
|
|
78
|
+
raise Exception('Error writing data-set #2400')
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _extract2400(block_data):
|
|
82
|
+
"""Extract dset data - data-set 2400."""
|
|
83
|
+
dset = {'type': 2400}
|
|
84
|
+
try:
|
|
85
|
+
split_data = block_data.splitlines(True)
|
|
86
|
+
dset.update(_parse_header_line(split_data[2], 4, [12, 6, 6, 12], [2, 2, 2, 2],
|
|
87
|
+
['model_uid', 'entity_type', 'entity_subtype', 'version_number']))
|
|
88
|
+
dset.update(_parse_header_line(split_data[3], 1, [80], [1], ['entity_name']))
|
|
89
|
+
dset.update(_parse_header_line(split_data[4], 1, [80], [1], ['part_number']))
|
|
90
|
+
# Record 4: 32 consecutive I2 fields
|
|
91
|
+
status_line = split_data[5]
|
|
92
|
+
dset['status_mask'] = [int(status_line[i*2:(i*2)+2]) for i in range(32)]
|
|
93
|
+
dset.update(_parse_header_line(split_data[6], 5, [10, 10, 12, 12, 12], [1, 1, 2, 2, 2],
|
|
94
|
+
['date', 'time', 'idm_version_id', 'idm_item_id', 'primary_parent_uid']))
|
|
95
|
+
dset.update(_parse_header_line(split_data[7], 1, [12], [2], ['optimization_switches']))
|
|
96
|
+
except:
|
|
97
|
+
raise Exception('Error reading data-set #2400')
|
|
98
|
+
return dset
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def prepare_2400(
|
|
102
|
+
model_uid=None,
|
|
103
|
+
entity_type=None,
|
|
104
|
+
entity_subtype=None,
|
|
105
|
+
version_number=None,
|
|
106
|
+
entity_name=None,
|
|
107
|
+
part_number=None,
|
|
108
|
+
status_mask=None,
|
|
109
|
+
date=None,
|
|
110
|
+
time=None,
|
|
111
|
+
idm_version_id=None,
|
|
112
|
+
idm_item_id=None,
|
|
113
|
+
primary_parent_uid=None,
|
|
114
|
+
optimization_switches=None,
|
|
115
|
+
return_full_dict=False):
|
|
116
|
+
"""Name: Model Header
|
|
117
|
+
|
|
118
|
+
R-Record, F-Field
|
|
119
|
+
|
|
120
|
+
:param model_uid: R1 F1, Model UID
|
|
121
|
+
:param entity_type: R1 F2, Entity type
|
|
122
|
+
:param entity_subtype: R1 F3, Entity subtype
|
|
123
|
+
:param version_number: R1 F4, Version number
|
|
124
|
+
:param entity_name: R2 F1, Entity name
|
|
125
|
+
:param part_number: R3 F1, Part number
|
|
126
|
+
:param status_mask: R4 F1, Status mask (list of 32 integers)
|
|
127
|
+
:param date: R5 F1, Date (DD-MMM-YY)
|
|
128
|
+
:param time: R5 F2, Time (HH:MM:SS)
|
|
129
|
+
:param idm_version_id: R5 F3, IDM version ID
|
|
130
|
+
:param idm_item_id: R5 F4, IDM item ID
|
|
131
|
+
:param primary_parent_uid: R5 F5, Primary parent UID
|
|
132
|
+
:param optimization_switches: R6 F1, Optimization switches
|
|
133
|
+
:param return_full_dict: If True full dict with all keys is returned, else only specified arguments are included
|
|
134
|
+
|
|
135
|
+
**Test prepare_2400**
|
|
136
|
+
|
|
137
|
+
>>> import pyuff
|
|
138
|
+
>>> import os
|
|
139
|
+
>>> save_to_file = 'test_pyuff'
|
|
140
|
+
>>> dataset = pyuff.prepare_2400(
|
|
141
|
+
>>> model_uid=1,
|
|
142
|
+
>>> entity_type=7,
|
|
143
|
+
>>> entity_subtype=-1,
|
|
144
|
+
>>> version_number=0,
|
|
145
|
+
>>> entity_name='MyModel',
|
|
146
|
+
>>> part_number='PART-001',
|
|
147
|
+
>>> status_mask=[0]*32,
|
|
148
|
+
>>> date='27-FEB-26',
|
|
149
|
+
>>> time='12:00:00',
|
|
150
|
+
>>> idm_version_id=0,
|
|
151
|
+
>>> idm_item_id=0,
|
|
152
|
+
>>> primary_parent_uid=0,
|
|
153
|
+
>>> optimization_switches=0)
|
|
154
|
+
>>> if save_to_file:
|
|
155
|
+
>>> if os.path.exists(save_to_file):
|
|
156
|
+
>>> os.remove(save_to_file)
|
|
157
|
+
>>> uffwrite = pyuff.UFF(save_to_file)
|
|
158
|
+
>>> uffwrite._write_set(dataset, 'add')
|
|
159
|
+
>>> dataset
|
|
160
|
+
"""
|
|
161
|
+
if np.array(model_uid).dtype != int and model_uid != None:
|
|
162
|
+
raise TypeError('model_uid must be integer')
|
|
163
|
+
if np.array(entity_type).dtype != int and entity_type != None:
|
|
164
|
+
raise TypeError('entity_type must be integer')
|
|
165
|
+
if np.array(entity_subtype).dtype != int and entity_subtype != None:
|
|
166
|
+
raise TypeError('entity_subtype must be integer')
|
|
167
|
+
if np.array(version_number).dtype != int and version_number != None:
|
|
168
|
+
raise TypeError('version_number must be integer')
|
|
169
|
+
if type(entity_name) != str and entity_name != None:
|
|
170
|
+
raise TypeError('entity_name must be string')
|
|
171
|
+
if type(part_number) != str and part_number != None:
|
|
172
|
+
raise TypeError('part_number must be string')
|
|
173
|
+
if status_mask != None and (not hasattr(status_mask, '__len__') or len(status_mask) != 32):
|
|
174
|
+
raise ValueError('status_mask must be a list of 32 integers')
|
|
175
|
+
if type(date) != str and date != None:
|
|
176
|
+
raise TypeError('date must be string')
|
|
177
|
+
if type(time) != str and time != None:
|
|
178
|
+
raise TypeError('time must be string')
|
|
179
|
+
if np.array(idm_version_id).dtype != int and idm_version_id != None:
|
|
180
|
+
raise TypeError('idm_version_id must be integer')
|
|
181
|
+
if np.array(idm_item_id).dtype != int and idm_item_id != None:
|
|
182
|
+
raise TypeError('idm_item_id must be integer')
|
|
183
|
+
if np.array(primary_parent_uid).dtype != int and primary_parent_uid != None:
|
|
184
|
+
raise TypeError('primary_parent_uid must be integer')
|
|
185
|
+
if np.array(optimization_switches).dtype != int and optimization_switches != None:
|
|
186
|
+
raise TypeError('optimization_switches must be integer')
|
|
187
|
+
|
|
188
|
+
dataset = {
|
|
189
|
+
'type': 2400,
|
|
190
|
+
'model_uid': model_uid,
|
|
191
|
+
'entity_type': entity_type,
|
|
192
|
+
'entity_subtype': entity_subtype,
|
|
193
|
+
'version_number': version_number,
|
|
194
|
+
'entity_name': entity_name,
|
|
195
|
+
'part_number': part_number,
|
|
196
|
+
'status_mask': status_mask,
|
|
197
|
+
'date': date,
|
|
198
|
+
'time': time,
|
|
199
|
+
'idm_version_id': idm_version_id,
|
|
200
|
+
'idm_item_id': idm_item_id,
|
|
201
|
+
'primary_parent_uid': primary_parent_uid,
|
|
202
|
+
'optimization_switches': optimization_switches,
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if return_full_dict is False:
|
|
206
|
+
dataset = check_dict_for_none(dataset)
|
|
207
|
+
|
|
208
|
+
return dataset
|
|
@@ -7,7 +7,7 @@ This module defines an UFF class to manipulate with the
|
|
|
7
7
|
UFF (Universal File Format) files, i.e., to read from and write
|
|
8
8
|
to UFF files. Among the variety of UFF formats, only some of the
|
|
9
9
|
formats (data-set types) frequently used in structural dynamics
|
|
10
|
-
are supported: **15, 55, 58, 58b, 82, 151, 164, 2411, 2412, 2414, 2420, 2429, 2467**
|
|
10
|
+
are supported: **15, 55, 58, 58b, 82, 151, 164, 1858, 2400, 2411, 2412, 2414, 2420, 2429, 2467**
|
|
11
11
|
Data-set **58b** is actually a hybrid format [1]_ where the signal is written in the
|
|
12
12
|
binary form, while the header-part is slightly different from 58 but still in the
|
|
13
13
|
ascii format.
|
|
@@ -47,13 +47,14 @@ warnings.simplefilter("default")
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
from .datasets.dataset_15 import _write15, _extract15, get_structure_15
|
|
50
|
-
from .datasets.dataset_18 import _extract18, get_structure_18
|
|
50
|
+
from .datasets.dataset_18 import _write18, _extract18, get_structure_18
|
|
51
51
|
from .datasets.dataset_55 import _write55, _extract55, get_structure_55
|
|
52
52
|
from .datasets.dataset_58 import _write58, _extract58, get_structure_58, fix_58b
|
|
53
53
|
from .datasets.dataset_82 import _write82, _extract82, get_structure_82
|
|
54
54
|
from .datasets.dataset_151 import _write151, _extract151, get_structure_151
|
|
55
55
|
from .datasets.dataset_164 import _write164, _extract164, get_structure_164
|
|
56
56
|
from .datasets.dataset_1858 import _write1858, _extract1858, get_structure_1858
|
|
57
|
+
from .datasets.dataset_2400 import _write2400, _extract2400, get_structure_2400
|
|
57
58
|
from .datasets.dataset_2411 import _write2411, _extract2411, get_structure_2411
|
|
58
59
|
from .datasets.dataset_2412 import _write2412, _extract2412, get_structure_2412
|
|
59
60
|
from .datasets.dataset_2414 import _write2414, _extract2414, get_structure_2414
|
|
@@ -61,7 +62,7 @@ from .datasets.dataset_2420 import _write2420, _extract2420, get_structure_2420
|
|
|
61
62
|
from .datasets.dataset_2429 import _write2429, _extract2429, get_structure_2429
|
|
62
63
|
from .datasets.dataset_2467 import _write2467, _extract2467, get_structure_2467
|
|
63
64
|
|
|
64
|
-
_SUPPORTED_SETS = ['15', '55', '58', '58b', '82', '151', '164', '1858', '2411', '2412', '2414', '2420', '2429', '2467']
|
|
65
|
+
_SUPPORTED_SETS = ['15', '18', '55', '58', '58b', '82', '151', '164', '1858', '2400', '2411', '2412', '2414', '2420', '2429', '2467']
|
|
65
66
|
|
|
66
67
|
|
|
67
68
|
class UFF:
|
|
@@ -366,7 +367,7 @@ class UFF:
|
|
|
366
367
|
if self._set_types[int(n)] == 15:
|
|
367
368
|
dset = _extract15(block_data)
|
|
368
369
|
elif self._set_types[int(n)] == 18:
|
|
369
|
-
dset = _extract18(block_data)
|
|
370
|
+
dset = _extract18(block_data)
|
|
370
371
|
elif self._set_types[int(n)] == 55:
|
|
371
372
|
dset = _extract55(block_data)
|
|
372
373
|
elif self._set_types[int(n)] == 58:
|
|
@@ -379,6 +380,8 @@ class UFF:
|
|
|
379
380
|
dset = _extract164(block_data)
|
|
380
381
|
elif self._set_types[int(n)] == 1858:
|
|
381
382
|
dset = _extract1858(block_data)
|
|
383
|
+
elif self._set_types[int(n)] == 2400:
|
|
384
|
+
dset = _extract2400(block_data)
|
|
382
385
|
elif self._set_types[int(n)] == 2411:
|
|
383
386
|
dset = _extract2411(block_data) # TEMP ADD
|
|
384
387
|
elif self._set_types[int(n)] == 2412:
|
|
@@ -440,6 +443,8 @@ class UFF:
|
|
|
440
443
|
|
|
441
444
|
if set_type == 15:
|
|
442
445
|
_write15(fh, dset)
|
|
446
|
+
elif set_type == 18:
|
|
447
|
+
_write18(fh, dset)
|
|
443
448
|
elif set_type == 55:
|
|
444
449
|
_write55(fh, dset)
|
|
445
450
|
elif set_type == 58:
|
|
@@ -452,6 +457,8 @@ class UFF:
|
|
|
452
457
|
_write164(fh, dset)
|
|
453
458
|
elif set_type == 1858:
|
|
454
459
|
_write1858(fh, dset)
|
|
460
|
+
elif set_type == 2400:
|
|
461
|
+
_write2400(fh, dset)
|
|
455
462
|
elif set_type == 2411:
|
|
456
463
|
_write2411(fh, dset)
|
|
457
464
|
elif set_type == 2412:
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
|
|
3
|
-
from ..tools import _opt_fields, _parse_header_line
|
|
4
|
-
|
|
5
|
-
def get_structure_18(raw=False):
|
|
6
|
-
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
|
|
7
|
-
out = """
|
|
8
|
-
Universal Dataset Number: 18
|
|
9
|
-
|
|
10
|
-
Name: Coordinate Systems
|
|
11
|
-
-----------------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
Record 1: FORMAT(5I10)
|
|
14
|
-
Field 1 -- coordinate system number
|
|
15
|
-
Field 2 -- coordinate system type
|
|
16
|
-
Field 3 -- reference coordinate system number
|
|
17
|
-
Field 4 -- color
|
|
18
|
-
Field 5 -- method of definition
|
|
19
|
-
= 1 - origin, +x axis, +xz plane
|
|
20
|
-
|
|
21
|
-
Record 2: FORMAT(20A2)
|
|
22
|
-
Field 1 -- coordinate system name
|
|
23
|
-
|
|
24
|
-
Record 3: FORMAT(1P6E13.5)
|
|
25
|
-
Total of 9 coordinate system definition parameters.
|
|
26
|
-
Fields 1-3 -- origin of new system specified in
|
|
27
|
-
reference system
|
|
28
|
-
Fields 4-6 -- point on +x axis of the new system
|
|
29
|
-
specified in reference system
|
|
30
|
-
Fields 7-9 -- point on +xz plane of the new system
|
|
31
|
-
specified in reference system
|
|
32
|
-
|
|
33
|
-
Records 1 thru 3 are repeated for each coordinate system in the model.
|
|
34
|
-
|
|
35
|
-
-----------------------------------------------------------------
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
if raw:
|
|
39
|
-
return out
|
|
40
|
-
else:
|
|
41
|
-
print(out)
|
|
42
|
-
|
|
43
|
-
def _extract18(block_data):
|
|
44
|
-
'''Extract local CS definitions -- data-set 18.'''
|
|
45
|
-
dset = {'type': 18}
|
|
46
|
-
try:
|
|
47
|
-
split_data = block_data.splitlines()
|
|
48
|
-
|
|
49
|
-
# -- Get Record 1
|
|
50
|
-
rec_1 = np.array(list(map(float, ''.join(split_data[2::4]).split())))
|
|
51
|
-
|
|
52
|
-
dset['cs_num'] = rec_1[::5]
|
|
53
|
-
# removed - clutter
|
|
54
|
-
# dset['cs_type'] = rec_1[1::5]
|
|
55
|
-
dset['ref_cs_num'] = rec_1[2::5]
|
|
56
|
-
# left out here are the parameters color and definition type
|
|
57
|
-
|
|
58
|
-
# -- Get Record 2
|
|
59
|
-
# removed because clutter
|
|
60
|
-
# dset['cs_name'] = split_data[3::4]
|
|
61
|
-
|
|
62
|
-
# -- Get Record 31 and 32
|
|
63
|
-
# ... these are the origins of cs defined in ref
|
|
64
|
-
# rec_31 = np.array(list(map(float, ''.join(split_data[4::4]).split())))
|
|
65
|
-
line_data = ''.join(split_data[4::4])
|
|
66
|
-
rec_31 = [float(line_data[i * 13:(i + 1) * 13]) for i in range(int(len(line_data) / 13))]
|
|
67
|
-
dset['ref_o'] = np.vstack((np.array(rec_31[::6]),
|
|
68
|
-
np.array(rec_31[1::6]),
|
|
69
|
-
np.array(rec_31[2::6]))).transpose()
|
|
70
|
-
|
|
71
|
-
# ... these are points on the x axis of cs defined in ref
|
|
72
|
-
dset['x_point'] = np.vstack((np.array(rec_31[3::6]),
|
|
73
|
-
np.array(rec_31[4::6]),
|
|
74
|
-
np.array(rec_31[5::6]))).transpose()
|
|
75
|
-
|
|
76
|
-
# ... these are the points on the xz plane
|
|
77
|
-
line_data = ''.join(split_data[5::4])
|
|
78
|
-
rec_32 = [float(line_data[i * 13:(i + 1) * 13]) for i in range(int(len(line_data) / 13))]
|
|
79
|
-
# rec_32 = np.array(list(map(float, ''.join(split_data[5::4]).split())))
|
|
80
|
-
dset['xz_point'] = np.vstack((np.array(rec_32[::3]),
|
|
81
|
-
np.array(rec_32[1::3]),
|
|
82
|
-
np.array(rec_32[2::3]))).transpose()
|
|
83
|
-
except:
|
|
84
|
-
raise Exception('Error reading data-set #18')
|
|
85
|
-
return dset
|
|
86
|
-
|
|
87
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|