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