pyuff 2.5.5__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.5 → pyuff-2.5.6}/PKG-INFO +1 -1
- {pyuff-2.5.5 → pyuff-2.5.6}/pyproject.toml +1 -1
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/__init__.py +1 -1
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/__init__.py +1 -0
- pyuff-2.5.6/pyuff/datasets/dataset_18.py +182 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/pyuff.py +5 -3
- pyuff-2.5.5/pyuff/datasets/dataset_18.py +0 -87
- {pyuff-2.5.5 → pyuff-2.5.6}/.gitignore +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/LICENSE +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/README.rst +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_15.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_151.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_164.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_1858.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_2400.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_2411.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_2412.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_2414.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_2420.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_2429.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_2467.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_55.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_58.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/datasets/dataset_82.py +0 -0
- {pyuff-2.5.5 → pyuff-2.5.6}/pyuff/tools.py +0 -0
|
@@ -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"
|
|
@@ -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
|
|
@@ -47,7 +47,7 @@ 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
|
|
@@ -62,7 +62,7 @@ from .datasets.dataset_2420 import _write2420, _extract2420, get_structure_2420
|
|
|
62
62
|
from .datasets.dataset_2429 import _write2429, _extract2429, get_structure_2429
|
|
63
63
|
from .datasets.dataset_2467 import _write2467, _extract2467, get_structure_2467
|
|
64
64
|
|
|
65
|
-
_SUPPORTED_SETS = ['15', '55', '58', '58b', '82', '151', '164', '1858', '2400', '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']
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
class UFF:
|
|
@@ -367,7 +367,7 @@ class UFF:
|
|
|
367
367
|
if self._set_types[int(n)] == 15:
|
|
368
368
|
dset = _extract15(block_data)
|
|
369
369
|
elif self._set_types[int(n)] == 18:
|
|
370
|
-
dset = _extract18(block_data)
|
|
370
|
+
dset = _extract18(block_data)
|
|
371
371
|
elif self._set_types[int(n)] == 55:
|
|
372
372
|
dset = _extract55(block_data)
|
|
373
373
|
elif self._set_types[int(n)] == 58:
|
|
@@ -443,6 +443,8 @@ class UFF:
|
|
|
443
443
|
|
|
444
444
|
if set_type == 15:
|
|
445
445
|
_write15(fh, dset)
|
|
446
|
+
elif set_type == 18:
|
|
447
|
+
_write18(fh, dset)
|
|
446
448
|
elif set_type == 55:
|
|
447
449
|
_write55(fh, dset)
|
|
448
450
|
elif set_type == 58:
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|