geone 1.2.10__py311-none-manylinux_2_35_x86_64.whl

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.
geone/__init__.py ADDED
@@ -0,0 +1,30 @@
1
+ # import version
2
+ from ._version import __version__
3
+
4
+ # import all modules
5
+ from . import blockdata
6
+ from . import covModel
7
+ from . import customcolors
8
+ from . import deesseinterface
9
+ from . import geosclassicinterface
10
+ from . import grf
11
+ from . import img
12
+ from . import imgplot
13
+ from . import imgplot3d
14
+ from . import img
15
+ from . import multiGaussian
16
+ from . import pgs
17
+ from . import randProcess
18
+ from . import tools
19
+
20
+ # # import all modules
21
+ # import geone.blockdata
22
+ # import geone.covModel
23
+ # import geone.customcolors
24
+ # import geone.deesseinterface
25
+ # import geone.geosclassicinterface
26
+ # import geone.grf
27
+ # import geone.img
28
+ # import geone.imgplot
29
+ # import geone.imgplot3d
30
+ # import geone.multiGaussian
geone/_version.py ADDED
@@ -0,0 +1,6 @@
1
+ # Version
2
+
3
+ # major, minor, micro
4
+ version_info = (1, 2, 10)
5
+
6
+ __version__ = '.'.join(map(str, version_info))
geone/blockdata.py ADDED
@@ -0,0 +1,232 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # -------------------------------------------------------------------------
5
+ # Python module: 'blockdata.py'
6
+ # author: Julien Straubhaar
7
+ # date: feb-2018
8
+ # -------------------------------------------------------------------------
9
+
10
+ """
11
+ Module for managing block data (for deesse), and relative functions.
12
+ """
13
+
14
+ import numpy as np
15
+ import os
16
+
17
+ # ============================================================================
18
+ class BlockData(object):
19
+ """
20
+ Class defining block data for one variable (for deesse).
21
+
22
+ **Attributes**
23
+
24
+ blockDataUsage : int, default: 0
25
+ defines the usage of block data:
26
+
27
+ - `blockDataUsage=0`: no block data
28
+ - `blockDataUsage=1`: block data defined as block mean value
29
+
30
+ nblock : int, default: 0
31
+ number of block(s) (used if `blockDataUsage=1`)
32
+
33
+ nodeIndex : sequence of 2D array-like of ints with 3 columns, optional
34
+ node index in each block (used if `blockDataUsage=1`):
35
+
36
+ - `nodeIndex[i][j]`: sequence of 3 floats, \
37
+ node index in the simulation grid along x, y, z axis \
38
+ of the j-th node of the i-th block
39
+
40
+ value : sequence of floats of length `nblock`, optional
41
+ target value for each block (used if `blockDataUsage=1`)
42
+
43
+ tolerance : sequence of floats of length `nblock`, optional
44
+ tolerance for each block (used if `blockDataUsage=1`)
45
+
46
+ activatePropMin : sequence of floats of length `nblock`, optional
47
+ minimal proportion of informed nodes in the block, under which the block
48
+ data constraint is deactivated, for each block (used if `blockDataUsage=1`)
49
+
50
+ activatePropMax : sequence of floats of length `nblock`, optional
51
+ maximal proportion of informed nodes in the block, above which the block
52
+ data constraint is deactivated, for each block (used if `blockDataUsage=1`)
53
+ """
54
+ def __init__(self,
55
+ blockDataUsage=0,
56
+ nblock=0,
57
+ nodeIndex=None,
58
+ value=None,
59
+ tolerance=None,
60
+ activatePropMin=None,
61
+ activatePropMax=None):
62
+ """
63
+ Inits an instance of the class.
64
+
65
+ Parameters
66
+ ----------
67
+ blockDataUsage : int, default: 0
68
+ defines the usage of block data
69
+
70
+ nblock : int, default: 0
71
+ number of block(s)
72
+
73
+ nodeIndex : sequence of 2D array-like of ints with 3 columns, optional
74
+ node index in each block
75
+
76
+ value : sequence of floats of length nblock, optional
77
+ target value for each block
78
+
79
+ tolerance : sequence of floats of length nblock, optional
80
+ tolerance for each block
81
+
82
+ activatePropMin : sequence of floats of length nblock, optional
83
+ minimal proportion of informed nodes in the block, under which the block
84
+ data constraint is deactivated, for each block
85
+
86
+ activatePropMax : sequence of floats of length nblock, optional
87
+ maximal proportion of informed nodes in the block, above which the block
88
+ data constraint is deactivated, for each block
89
+ """
90
+ self.blockDataUsage = blockDataUsage
91
+ self.nblock = nblock
92
+ self.nodeIndex = nodeIndex
93
+
94
+ if nodeIndex is None:
95
+ self.nodeIndex = None
96
+ else:
97
+ self.nodeIndex = [np.asarray(x) for x in self.nodeIndex]
98
+
99
+ if value is None:
100
+ self.value = None
101
+ else:
102
+ self.value = np.asarray(value, dtype=float).reshape(nblock)
103
+
104
+ if tolerance is None:
105
+ self.tolerance = None
106
+ else:
107
+ self.tolerance = np.asarray(tolerance, dtype=float).reshape(nblock)
108
+
109
+ if activatePropMin is None:
110
+ self.activatePropMin = None
111
+ else:
112
+ self.activatePropMin = np.asarray(activatePropMin, dtype=float).reshape(nblock)
113
+
114
+ if activatePropMax is None:
115
+ self.activatePropMax = None
116
+ else:
117
+ self.activatePropMax = np.asarray(activatePropMax, dtype=float).reshape(nblock)
118
+
119
+ # ------------------------------------------------------------------------
120
+ # def __str__(self):
121
+ # return self.name
122
+ def __repr__(self):
123
+ # """
124
+ # Returns the string that is displayed when the instance of the class is "printed".
125
+ # """
126
+ out = '*** BlockData object ***'
127
+ out = out + '\n' + 'blockDataUsage = {0.blockDataUsage}:'.format(self)
128
+ if self.blockDataUsage == 0:
129
+ out = out + ' no block data'
130
+ elif self.blockDataUsage == 1:
131
+ out = out + ' block mean value'
132
+ else:
133
+ out = out + ' unknown'
134
+ if self.blockDataUsage == 1:
135
+ out = out + '\n' + 'nblock = {0.nblock} # number of blocks'.format(self)
136
+ out = out + '\n' + ' parameters for each block in fields'
137
+ out = out + '\n' + ' ".nodeIndex", ".value", ".tolerance", ".activatePropMin", ".activatePropMax"'
138
+ out = out + '\n' + '*****'
139
+ return out
140
+ # ------------------------------------------------------------------------
141
+ # ============================================================================
142
+
143
+ # ----------------------------------------------------------------------------
144
+ def readBlockData(filename):
145
+ """
146
+ Reads block data from a txt file.
147
+
148
+ Parameters
149
+ ----------
150
+ filename : str
151
+ name of the file
152
+
153
+ Returns
154
+ -------
155
+ bd : :class:`BlockData`
156
+ block data
157
+ """
158
+ fname = 'readBlockData'
159
+
160
+ # Check if the file exists
161
+ if not os.path.isfile(filename):
162
+ print(f'ERROR ({fname}): invalid filename ({filename})')
163
+ return None
164
+
165
+ # Open the file in read mode
166
+ with open(filename,'r') as ff:
167
+ # Read number of block (1st line)
168
+ nblock = int(ff.readline())
169
+
170
+ # Initialize fields ...
171
+ nodeIndex = []
172
+ value = np.zeros(nblock)
173
+ tolerance = np.zeros(nblock)
174
+ activatePropMin = np.zeros(nblock)
175
+ activatePropMax = np.zeros(nblock)
176
+
177
+ # Read "blocks"...
178
+ for i in range(nblock):
179
+ li = ff.readline()
180
+ t = [x for x in li.split()]
181
+ nnode = int(t[0])
182
+ value[i], tolerance[i], activatePropMin[i], activatePropMax[i] = [float(x) for x in t[1:5]]
183
+ nodeIndex.append(np.array([[int(j) for j in ff.readline().split()] for k in range(nnode)]))
184
+
185
+ # Set block data
186
+ bd = BlockData(blockDataUsage=1,
187
+ nblock=nblock,
188
+ nodeIndex=nodeIndex,
189
+ value=value,
190
+ tolerance=tolerance,
191
+ activatePropMin=activatePropMin,
192
+ activatePropMax=activatePropMax)
193
+
194
+ return bd
195
+ # ----------------------------------------------------------------------------
196
+
197
+ # ----------------------------------------------------------------------------
198
+ def writeBlockData(bd, filename, fmt='.5g'):
199
+ """
200
+ Writes block data in a txt file.
201
+
202
+ Parameters
203
+ ----------
204
+ bd : :class:`BlockData`
205
+ block data
206
+
207
+ filename : str
208
+ name of the file
209
+
210
+ fmt : str, default: '.5g'
211
+ format string for target value, tolerance and active proportion (min
212
+ and max) in the block data
213
+ """
214
+
215
+ if bd.blockDataUsage == 0:
216
+ return None
217
+
218
+ # Open the file in write binary mode
219
+ with open(filename,'wb') as ff:
220
+ # Write the number of block(s)
221
+ ff.write('{}\n'.format(bd.nblock).encode())
222
+
223
+ # Write "blocks"...
224
+ for ni, v, t, amin, amax in zip(bd.nodeIndex, bd.value,
225
+ bd.tolerance, bd.activatePropMin,
226
+ bd.activatePropMax):
227
+ ff.write('{} {:{fmt}} {:{fmt}} {:{fmt}} {:{fmt}}\n'.format(len(ni), v, t, amin, amax, fmt=fmt).encode())
228
+ np.savetxt(ff, np.asarray(ni), delimiter=' ', fmt="%g")
229
+ # ----------------------------------------------------------------------------
230
+
231
+ if __name__ == "__main__":
232
+ print("Module 'geone.blockdata'.")