libzrod 0.1.2__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.
@@ -0,0 +1,6 @@
1
+ __pycache__
2
+ build/*
3
+ dist/*
4
+ libzrod.egg-info/*
5
+ _skbuild/*
6
+ libzrod/libzrod.cpython-311-darwin.so
@@ -0,0 +1,240 @@
1
+ cmake_minimum_required(VERSION 3.22.1)
2
+
3
+ #for building the python module. Should be similar to the one in the android project
4
+
5
+ #TODO: this file needs work
6
+
7
+ if(NOT DEFINED SKBUILD)
8
+ set(SKBUILD_PROJECT_NAME "zrod")
9
+ set(MODULE_NAME ${SKBUILD_PROJECT_NAME})
10
+ endif()
11
+
12
+
13
+ project(${SKBUILD_PROJECT_NAME})
14
+ set(MODULE_NAME ${SKBUILD_PROJECT_NAME})
15
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
16
+ #set(CMAKE_C_COMPILER /usr/bin/cc)
17
+ #set(CMAKE_CXX_COMPILER /usr/bin/c++)
18
+
19
+ set(CMAKE_CXX_STANDARD 20)
20
+
21
+ #set(CMAKE_CXX_VISIBILITY_PRESET hidden)
22
+ #set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
23
+
24
+ # Preventing writes to package registry by default
25
+ #set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY YES)
26
+
27
+
28
+
29
+
30
+ if(NOT WIN32)
31
+ string(ASCII 27 Esc)
32
+ set(ColorReset "${Esc}[m")
33
+ set(ColorBold "${Esc}[1m")
34
+ set(Red "${Esc}[31m")
35
+ set(Green "${Esc}[32m")
36
+ set(Yellow "${Esc}[33m")
37
+ set(Blue "${Esc}[34m")
38
+ set(Magenta "${Esc}[35m")
39
+ set(Cyan "${Esc}[36m")
40
+ set(White "${Esc}[37m")
41
+ set(BoldRed "${Esc}[1;31m")
42
+ set(BoldGreen "${Esc}[1;32m")
43
+ set(BoldYellow "${Esc}[1;33m")
44
+ set(BoldBlue "${Esc}[1;34m")
45
+ set(BoldMagenta "${Esc}[1;35m")
46
+ set(BoldCyan "${Esc}[1;36m")
47
+ set(BoldWhite "${Esc}[1;37m")
48
+ endif()
49
+
50
+
51
+ #use to toggle the AWS code in zrod.cpp
52
+ add_definitions(
53
+ -DUSE_AWS_SDK #TODO: this should be eliminated once the aws code is fully implemented and stable
54
+ -DJWT_DISABLE_PICOJSON
55
+ -DSQLITE_CORE
56
+ )
57
+
58
+ message(STATUS "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CMAKE PYTHON BUILD CONTENTS")
59
+
60
+
61
+ if(WIN32)
62
+ #set_target_properties(zrod PROPERTIES LINK_FLAGS "/WHOLEARCHIVE")
63
+ message(STATUS "${Red} Only building for WINDOWS ${ColorReset}")
64
+
65
+ set(INCOPENSSL_PATH c:/Users/walter/GitRepos/wansco-aws-sdk-cpp/dist/windows/Release/include)
66
+
67
+ set(INCCURL_PATH c:/Users/walter/GitRepos/wansco-aws-sdk-cpp/dist/windows/Release/include)
68
+ set(LIBCURL_PATH c:/Users/walter/GitRepos/wansco-aws-sdk-cpp/dist/windows/Release/lib)
69
+
70
+ set(INCAWS_PATH c:/Users/walter/GitRepos/wansco-aws-sdk-cpp/dist/windows/Release/include)
71
+ set(LIBAWS_PATH c:/Users/walter/GitRepos/wansco-aws-sdk-cpp/dist/windows/Release/lib)
72
+
73
+ #set(CMAKE_PREFIX_PATH "${LIBAWS_PATH}/lib/cmake")
74
+ elseif(APPLE)
75
+ message(STATUS "${Red} Only building for ARM Macs ${ColorReset}")
76
+
77
+ #TODO: move the includes to "apple" or some other folder
78
+ set(INCOPENSSL_PATH $ENV{HOME}/GitRepos/wansco-aws-sdk-cpp/dist/macosx/include)
79
+
80
+ set(INCCURL_PATH $ENV{HOME}/GitRepos/wansco-aws-sdk-cpp/dist/macosx/include)
81
+ set(LIBCURL_PATH $ENV{HOME}/GitRepos/wansco-aws-sdk-cpp/dist/macosx/lib)
82
+
83
+ set(INCAWS_PATH $ENV{HOME}/GitRepos/wansco-aws-sdk-cpp/dist/macosx/include)
84
+ set(LIBAWS_PATH $ENV{HOME}/GitRepos/wansco-aws-sdk-cpp/dist/macosx/lib)
85
+
86
+ #set(CMAKE_C_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang")
87
+ #set(CMAKE_CXX_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++")
88
+
89
+ #set(CMAKE_PREFIX_PATH "${LIBAWS_PATH}/lib/cmake")
90
+ else() #Linux
91
+ message(STATUS "${Red} Only building for Linux ${ColorReset}")
92
+
93
+ #TODO: switch this to the aws build of curl
94
+ #set(INCCURL_PATH $ENV{HOME}/GitRepos/curl/include)
95
+ #set(LIBCURL_PATH $ENV{HOME}/GitRepos/curl/artifacts/lib)
96
+
97
+ set(INCAWS_PATH $ENV{HOME}/GitRepos/wansco-aws-sdk-cpp/dist/linux/include)
98
+ set(LIBAWS_PATH $ENV{HOME}/GitRepos/wansco-aws-sdk-cpp/dist/linux/lib)
99
+
100
+ #not sure why s2n is only on linux
101
+ set(s2n_DIR "${LIBAWS_PATH}/s2n/cmake")
102
+ find_package(s2n REQUIRED)
103
+ endif()
104
+
105
+
106
+ #set(AWSSDK_ROOT_DIR "${LIBAWS_PATH}/cmake")
107
+ set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" "${LIBAWS_PATH}/cmake")
108
+
109
+ #set(CMAKE_FIND_DEBUG_MODE TRUE)
110
+ find_package(AWSSDK REQUIRED COMPONENTS s3 dynamodb cognito-identity cognito-idp)
111
+ #set(CMAKE_FIND_DEBUG_MODE FALSE)
112
+ #message(FATAL_ERROR "You did something wrong!")
113
+
114
+ #set(CMAKE_PREFIX_PATH "$ENV{HOME}/GitRepos/curl/CMake")
115
+ #find_package(curl REQUIRED)
116
+
117
+ #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
118
+
119
+ if(DEFINED SKBUILD)
120
+ message(STATUS "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxThe project is built using scikit-build")
121
+ #find_package(PythonExtensions REQUIRED)
122
+ find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
123
+ endif()
124
+
125
+
126
+
127
+ if(WIN32)
128
+ set(SRC_PATH c:/Users/walter/GitRepos/zrodapp/zrodapp/ios/zrod/cpp)
129
+ else() #everything else
130
+ #add_subdirectory($ENV{HOME}/GitRepos/zrodapp/zrodapp/ios/zrod/cpp)
131
+ set(SRC_PATH $ENV{HOME}/GitRepos/zrodapp/zrodapp/ios/zrod/cpp)
132
+ endif()
133
+
134
+
135
+ include_directories(
136
+ ${INCAWS_PATH}
137
+ ${INCOPENSSL_PATH}
138
+ ${SRC_PATH} #needed this for #include <sqlite3ext.h>
139
+ #${Python3_INCLUDE_DIRS}
140
+ )
141
+
142
+
143
+ message("==================================")
144
+ #message($ENV{HOME})
145
+ #message(${SRC_PATH})
146
+ #set(CMAKE_C_COMPILER "clang")
147
+ #set(CMAKE_CXX_COMPILER "clang++")
148
+ #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
149
+
150
+ #set(CMAKE_CXX_MODULE_STD 1)
151
+ #set(CMAKE_CXX_FLAGS "-stdlib=libc++")
152
+
153
+
154
+ find_package(ZLIB)
155
+ #find_package(CURL)
156
+ #find_package(CURL)
157
+ #find_package(openssl)
158
+ #find_package(crypto)
159
+ #find_package(aws-cpp-sdk-core CONFIG REQUIRED)
160
+ #find_package(aws-c-auth CONFIG REQUIRED)
161
+ #find_package(aws-c-common CONFIG REQUIRED)
162
+ #find_package(aws-cpp-sdk-core CONFIG REQUIRED)
163
+ #find_package(aws-crt-cpp CONFIG REQUIRED)
164
+ #find_package(aws-c-s3 CONFIG REQUIRED)
165
+ #find_package(aws-cpp-sdk-s3 CONFIG REQUIRED)
166
+ #find_package(aws-cpp-sdk-dynamodb CONFIG REQUIRED)
167
+ #find_package(aws-cpp-sdk-cognito-identity CONFIG REQUIRED)
168
+ #find_package(aws-cpp-sdk-cognito-idp CONFIG REQUIRED)
169
+
170
+
171
+ if(WIN32)
172
+ #set_target_properties(zrod PROPERTIES LINK_FLAGS "/WHOLEARCHIVE")
173
+ elseif(APPLE)
174
+ #set_target_properties(zrod PROPERTIES LINK_FLAGS "-Wl,-all_load")
175
+ else() #Linux
176
+ #set_target_properties(zrod PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
177
+ endif()
178
+ #set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
179
+
180
+
181
+ if(DEFINED SKBUILD)
182
+ #python_extension_module(libzrod)
183
+ python_add_library(${MODULE_NAME} MODULE
184
+ ${SRC_PATH}/zrod.cpp
185
+ ${SRC_PATH}/pugixml.cpp
186
+ ${SRC_PATH}/RodData.cpp
187
+ ${SRC_PATH}/PumpingUnitData.cpp
188
+ ${SRC_PATH}/awslink.cpp
189
+ ${SRC_PATH}/csv.c
190
+ ${SRC_PATH}/sqlite3.c
191
+ WITH_SOABI
192
+ ${FILENAME}
193
+ #libzrod.so
194
+ )
195
+ else()
196
+ add_library(${MODULE_NAME} SHARED
197
+ ${SRC_PATH}/zrod.cpp
198
+ ${SRC_PATH}/pugixml.cpp
199
+ ${SRC_PATH}/RodData.cpp
200
+ ${SRC_PATH}/PumpingUnitData.cpp
201
+ ${SRC_PATH}/awslink.cpp
202
+ ${SRC_PATH}/csv.c
203
+ ${SRC_PATH}/sqlite3.c
204
+ )
205
+ endif()
206
+
207
+
208
+
209
+
210
+ target_link_libraries(${MODULE_NAME} PRIVATE
211
+ -L${LIBAWS_PATH}
212
+ #aws-c-auth
213
+ #aws-c-cal
214
+ #aws-c-common
215
+ #aws-c-compression
216
+ #aws-c-event-stream
217
+ #aws-c-http
218
+ #aws-c-io
219
+ #aws-c-mqtt
220
+ #aws-c-s3
221
+ #aws-c-sdkutils
222
+ #aws-checksums
223
+
224
+ #aws-cpp-sdk-core
225
+ #aws-crt-cpp
226
+ #aws-cpp-sdk-s3
227
+
228
+ aws-cpp-sdk-dynamodb
229
+ aws-cpp-sdk-cognito-identity
230
+ aws-cpp-sdk-cognito-idp
231
+ )
232
+
233
+
234
+ #install(TARGETS zrod LIBRARY DESTINATION libzrod)
235
+ install(TARGETS ${MODULE_NAME} DESTINATION ${SKBUILD_PROJECT_NAME})
236
+
237
+
238
+ #[===[
239
+
240
+ ]===]
@@ -0,0 +1,42 @@
1
+
2
+ cd ~/GitRepos/zrodapp/pylibzrod
3
+ pip3 install .
4
+
5
+ #or
6
+ cd ~/GitRepos/zrodapp/pylibzrod
7
+ python ../nb/testme.py
8
+
9
+ python3.11 ./setup.py bdist_wheel
10
+ pip3 install ./dist/libzrod-0.1.0-cp311-cp311-macosx_15_0_arm64.whl
11
+ pip3 install ./dist/libzrod-0.1.1-py3-none-macosx_15_0_arm64.whl --force-reinstall
12
+
13
+ pip3 uninstall libzrod
14
+
15
+ pipx run build --wheel
16
+
17
+
18
+ #macos
19
+ objdump -r /Users/walter/GitRepos/wansco-aws-sdk-cpp/dist/macos/lib/libaws-cpp-sdk-dynamodb.a
20
+ nm -U /Users/walter/GitRepos/wansco-aws-sdk-cpp/dist/macos/lib/libaws-cpp-sdk-dynamodb.a | grep __ZN3Aws8DynamoDB5Model14AttributeValue4SetLERKNSt3__16vectorIN
21
+
22
+ objdump -T /home/walter/myenv/lib/python3.12/site-packages/libzrod/libzrod.cpython-312-x86_64-linux-gnu.so
23
+ strings /home/walter/myenv/lib/python3.12/site-packages/libzrod/libzrod.cpython-312-x86_64-linux-gnu.so
24
+ nm -U /home/walter/myenv/lib/python3.12/site-packages/libzrod/libzrod.cpython-312-x86_64-linux-gnu.so
25
+
26
+
27
+
28
+
29
+
30
+ python -m build
31
+ twine upload -r testpypi dist/*
32
+
33
+
34
+
35
+
36
+
37
+ crossdocker - building in crossdocker, we need to setup the directory structure:
38
+ cd /home/walter/
39
+ ln -s /work/GitRepos/
40
+ Then build wansco-aws-cpp-sdk
41
+ python3 -m build
42
+
libzrod-0.1.2/PKG-INFO ADDED
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.2
2
+ Name: libzrod
3
+ Version: 0.1.2
4
+
@@ -0,0 +1,21 @@
1
+ __all__ = [
2
+ "testme",
3
+ "TaperBase_t",
4
+ "TubingBase_t",
5
+ "WaveResult_t",
6
+ "WaveResults_t",
7
+ "WaveParams_t",
8
+ "WaveParamsReadOnly_t",
9
+ "PuApi_t",
10
+ "PuInfo_t",
11
+ "DeviationSurveyPoint_t",
12
+ "zrod",
13
+ "Logfunc"
14
+ ]
15
+ __version__ = '0.1.0'
16
+
17
+ from ._libzrod import testme
18
+
19
+ from ._libzrod import TaperBase_t, TubingBase_t, WaveResult_t, WaveResults_t, WaveParams_t, WaveParamsReadOnly_t, PuApi_t, PuInfo_t, DeviationSurveyPoint_t
20
+
21
+ from ._libzrod import zrod, Logfunc
@@ -0,0 +1,717 @@
1
+ import os
2
+ import sys
3
+ import ctypes
4
+ import numpy as np
5
+ import pathlib
6
+
7
+ if sys.platform == "win32":
8
+ libfile = "libzrod.cp313-win_amd64.pyd"
9
+ elif sys.platform == "darwin":
10
+ libfile = "libzrod.cpython-313-darwin.so"
11
+ else:
12
+ libfile = "libzrod.cpython-312-x86_64-linux-gnu.so"
13
+ #endif
14
+
15
+ libfile = pathlib.Path(__file__).parent / libfile
16
+ libzrod = ctypes.CDLL(str(libfile))
17
+
18
+
19
+ def testme():
20
+ print("libzrod testme")
21
+ #end testme()
22
+
23
+
24
+ class TaperBase_t(ctypes.Structure):
25
+ _fields_ = [
26
+ ('id', ctypes.c_char * 32),
27
+ ('L', ctypes.c_double),
28
+ ('D', ctypes.c_double),
29
+ ('W', ctypes.c_double),
30
+ ('T', ctypes.c_double),
31
+ ('E', ctypes.c_double),
32
+ ('R', ctypes.c_double)
33
+ ]
34
+ #end TaperBase_t
35
+ class TubingBase_t(ctypes.Structure):
36
+ _fields_ = [
37
+ ('L', ctypes.c_double),
38
+ ('ID', ctypes.c_double),
39
+ ('OD', ctypes.c_double),
40
+ ('weight', ctypes.c_double),
41
+ ('W', ctypes.c_double),
42
+ ('T', ctypes.c_double),
43
+ ('E', ctypes.c_double),
44
+ ('R', ctypes.c_double)
45
+ ]
46
+ #end TubingBase_t
47
+ class WaveResult_t(ctypes.Structure):
48
+ _fields_ = [
49
+ ('Rwa', ctypes.c_double),
50
+ ('Rwf', ctypes.c_double),
51
+ ('RTT', ctypes.c_double),
52
+ ('WaveVelocity', ctypes.c_double),
53
+ ('FoSKr', ctypes.c_double),
54
+ ('NNo', ctypes.c_double),
55
+ ('SKr', ctypes.c_double),
56
+ ('SL', ctypes.c_double),
57
+ ('Kr', ctypes.c_double),
58
+ ('Kt', ctypes.c_double),
59
+ ('KtUnanchored', ctypes.c_double),
60
+ ('BblPerDay100', ctypes.c_double),
61
+ ('GallonsPerStroke100', ctypes.c_double),
62
+ ('PumpStrokeGross', ctypes.c_double),
63
+ ('PumpStrokeNet', ctypes.c_double),
64
+ ('PumpStrokeMin', ctypes.c_double),
65
+ ('PumpStrokeMax', ctypes.c_double),
66
+ ('slippage', ctypes.c_double),
67
+ #//WaveRESULT_XXX
68
+ ]
69
+ #end WaveResult_t
70
+
71
+ '''
72
+ class PumpValvePointInfo_t(ctypes.Structure):
73
+ _fields_ = [
74
+ ('index', ctypes.c_int),
75
+ ('valvestate', ctypes.c_int),
76
+ ]
77
+ #end PumpValvePointInfo_t
78
+ '''
79
+
80
+ class WaveResults_t(ctypes.Structure):
81
+ _fields_ = [
82
+ ('LastExecutionTimeMs', ctypes.c_int),
83
+ ('diag', WaveResult_t),
84
+ ('pred', WaveResult_t),
85
+
86
+ #TODO: this might get moved/renamed
87
+ ('predPumpTvClosedIndex', ctypes.c_int),
88
+ ('predPumpSvOpenedIndex', ctypes.c_int),
89
+ ('predPumpSvClosedIndex', ctypes.c_int),
90
+ ('predPumpTvOpenedIndex', ctypes.c_int),
91
+
92
+ ('predCalcdFo', ctypes.c_double), #this is the Fo from the plunger, pressures and FL. The target Fo in WaveParams_t can be set manually.
93
+ ]
94
+ #end WaveResults_t
95
+
96
+ class WaveParams_t(ctypes.Structure):
97
+ _fields_ = [
98
+ ('WellDepth', ctypes.c_double),
99
+
100
+ ('diagSpm', ctypes.c_double),
101
+ ('predSpm', ctypes.c_double),
102
+
103
+ ('diagDampUp', ctypes.c_double),
104
+ ('diagDampDn', ctypes.c_double),
105
+ ('predDampUp', ctypes.c_double),
106
+ ('predDampDn', ctypes.c_double),
107
+
108
+ ('diagFluidSG', ctypes.c_double),
109
+ ('predFluidSG', ctypes.c_double),
110
+
111
+ ('diagFluidViscosity', ctypes.c_double),
112
+ ('predFluidViscosity', ctypes.c_double),
113
+
114
+ ('diagPumpPlungerDiameter', ctypes.c_double),
115
+ ('diagPumpPlungerLength', ctypes.c_double),
116
+ ('diagPumpPlungerClearance', ctypes.c_double),
117
+
118
+ ('predPumpPlungerDiameter', ctypes.c_double),
119
+ ('predPumpPlungerLength', ctypes.c_double),
120
+ ('predPumpPlungerClearance', ctypes.c_double),
121
+
122
+ ('diagTubingPressure', ctypes.c_double),
123
+ ('diagCasingPressure', ctypes.c_double),
124
+ ('predTubingPressure', ctypes.c_double),
125
+ ('predCasingPressure', ctypes.c_double),
126
+
127
+ ('diagFluidLevel', ctypes.c_double),
128
+ ('predFluidLevel', ctypes.c_double),
129
+
130
+ ('diagPumpDepth', ctypes.c_double),
131
+ ('predPumpDepth', ctypes.c_double),
132
+
133
+ ('diagAnchorDepth', ctypes.c_double),
134
+ ('predAnchorDepth', ctypes.c_double),
135
+
136
+ ('predFo', ctypes.c_double), #This is the target Fo. Ideally set by CalculateFo(), but can be set manually. If manually set, see predCalcdFo in WaveResults_t.
137
+ ('predFillage', ctypes.c_double),
138
+ ('predCompression', ctypes.c_double),
139
+
140
+ #('predCyclesToRun', ctypes.c_int),
141
+ #('predCyclesToOutput', ctypes.c_int),
142
+
143
+ ('usePumpingUnitForPosition', ctypes.c_bool),
144
+
145
+ #//WavePARAM_XXX
146
+ ]
147
+ #end WaveParams_t
148
+
149
+ class WaveParamsReadOnly_t(ctypes.Structure):
150
+ _fields_ = [
151
+ ('diagMeasM', ctypes.c_int),
152
+ ('diagUpscM', ctypes.c_int),
153
+ ('predM', ctypes.c_int),
154
+ #('diagMeasDX', ctypes.c_double),
155
+ #('diagUpscDX', ctypes.c_double),
156
+ #('predDX', ctypes.c_double),
157
+ ('diagMeasDT', ctypes.c_double),
158
+ ('diagUpscDT', ctypes.c_double),
159
+ ('predDT', ctypes.c_double),
160
+ ('diagMeasPointCount', ctypes.c_int),
161
+ ('diagUpscPointCount', ctypes.c_int),
162
+ ('predPointCount', ctypes.c_int),
163
+ ('diagStrokePeriod', ctypes.c_double),
164
+ ('predStrokePeriod', ctypes.c_double),
165
+ ]
166
+ #end WaveParamsReadOnly_t
167
+
168
+ #Default settings should be fine for most cases (i.e. you shouldnt need this except for advanced useage. Also, be ware this may change substantially between releases.)
169
+ class WaveSettings_t(ctypes.Structure):
170
+ _fields_ = [
171
+ ('useOldPredAlgorith', ctypes.c_bool), #should be set to false
172
+ #('predLimitPointCount', ctypes.c_int),
173
+ ('predNodesPerSection', ctypes.c_int),
174
+ ]
175
+ #end WaveSettings_t
176
+
177
+ class PuApi_t(ctypes.Structure):
178
+ _fields_ = [
179
+ ('Rotate', ctypes.c_int),
180
+ ('A', ctypes.c_double),
181
+ ('P', ctypes.c_double),
182
+ ('C', ctypes.c_double),
183
+ ('I', ctypes.c_double),
184
+ ('K', ctypes.c_double),
185
+ ('R', ctypes.c_double),
186
+ ('Torque', ctypes.c_double),
187
+ ('Structure', ctypes.c_double),
188
+ ('MaxStroke', ctypes.c_double),
189
+ ('Type', ctypes.c_char),
190
+ ('isDoubleReducer', ctypes.c_bool),
191
+ ('CBE', ctypes.c_double),
192
+ ('B', ctypes.c_double),
193
+ ('Tau', ctypes.c_double),
194
+ ('Cyl', ctypes.c_double),
195
+ ('CylFactor', ctypes.c_double),
196
+ ('S', ctypes.c_double),
197
+ ]
198
+ #end PuApi_t
199
+
200
+ class PuInfo_t(ctypes.Structure):
201
+ _fields_ = [
202
+ ('api', PuApi_t),
203
+ #TODO: more info about this unit like the Database key
204
+ ]
205
+ #end PuInfo_t
206
+
207
+ class DeviationSurveyPoint_t(ctypes.Structure):
208
+ _fields_ = [
209
+ ('index', ctypes.c_int),
210
+ ('md', ctypes.c_double),
211
+ ('inc', ctypes.c_double),
212
+ ('azi', ctypes.c_double),
213
+ ('x', ctypes.c_double),
214
+ ('y', ctypes.c_double),
215
+ ('z', ctypes.c_double),
216
+ ('dls', ctypes.c_double)
217
+ ]
218
+ #end DeviationSurveyPoint_t
219
+
220
+
221
+ zrodHandle = ctypes.POINTER(ctypes.c_char)
222
+ c_int_array = np.ctypeslib.ndpointer(dtype=np.int32, ndim=1, flags='C_CONTIGUOUS')
223
+ c_double_array = np.ctypeslib.ndpointer(dtype=np.float64, ndim=1, flags='C_CONTIGUOUS')
224
+
225
+ libzrod.CreateZrodObj.restype = zrodHandle
226
+ libzrod.DeleteZrodObj.argtypes = [zrodHandle]
227
+ libzrod.PrintZrodObj.argtypes = [zrodHandle]
228
+ libzrod.GetZrodVersion.argtypes = [zrodHandle, c_int_array]
229
+ try:
230
+ libzrod.DebugZrodObj.argtypes = [zrodHandle, ctypes.c_char_p]
231
+ except:
232
+ pass
233
+ #end try
234
+ clogfunc = ctypes.CFUNCTYPE(None, ctypes.c_char_p)
235
+ libzrod.SetLoggingCallback.argtypes = [zrodHandle, clogfunc]
236
+ libzrod.Login.argtypes = [zrodHandle, ctypes.c_char_p, ctypes.c_char_p]
237
+ libzrod.Login.restype = ctypes.c_bool
238
+ libzrod.Logout.argtypes = [zrodHandle]
239
+ libzrod.Logout.restype = ctypes.c_bool
240
+
241
+ libzrod.Test.argtypes = [zrodHandle]
242
+
243
+ libzrod.SaveCurrentDesign.argtypes = [zrodHandle, ctypes.c_bool]
244
+ libzrod.SaveCurrentDesign.restype = ctypes.c_bool
245
+
246
+ libzrod.FetchDesigns.argtypes = [zrodHandle, ctypes.c_bool]
247
+ libzrod.FetchDesigns.restype = ctypes.c_int
248
+
249
+ libzrod.GetDesign.argtypes = [zrodHandle, ctypes.c_char_p]
250
+ libzrod.GetDesign.restype = ctypes.c_bool
251
+
252
+ libzrod.runzrod.argtypes = [zrodHandle]
253
+
254
+ libzrod.RunDesign.argtypes = [zrodHandle]
255
+ libzrod.RunDesign.restype = ctypes.c_bool
256
+
257
+ libzrod.GetWaveResults.argtypes = [zrodHandle]
258
+ libzrod.GetWaveResults.restype = WaveResults_t
259
+
260
+ libzrod.GetWaveParamsReadOnly.argtypes = [zrodHandle]
261
+ libzrod.GetWaveParamsReadOnly.restype = WaveParamsReadOnly_t
262
+
263
+ libzrod.GetWaveParams.argtypes = [zrodHandle]
264
+ libzrod.GetWaveParams.restype = WaveParams_t
265
+ libzrod.SetWaveParams.argtypes = [zrodHandle, WaveParams_t]
266
+ libzrod.SetWaveParams.restype = ctypes.c_bool
267
+
268
+ libzrod.GetWaveSettings.argtypes = [zrodHandle]
269
+ libzrod.GetWaveSettings.restype = WaveSettings_t
270
+ libzrod.SetWaveSettings.argtypes = [zrodHandle, WaveSettings_t]
271
+ libzrod.SetWaveSettings.restype = ctypes.c_bool
272
+
273
+ libzrod.GetDeviationSurveyCount.argtypes = [zrodHandle]
274
+ libzrod.GetDeviationSurveyCount.restype = ctypes.c_int
275
+ libzrod.GetDeviationSurvey.argtypes = [zrodHandle, ctypes.c_void_p]
276
+ libzrod.GetDeviationSurvey.restype = ctypes.c_bool
277
+
278
+ #EXPORT bool SetDeviationSurvey(void * zrodptr, int count, double * md, double * inc, double * azi);
279
+ #EXPORT bool SetDeviationSurveyWithMIA(void * zrodptr, int count, double * mia);
280
+
281
+ libzrod.SetClientVersion.argtypes = [zrodHandle, ctypes.c_char_p, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int]
282
+ libzrod.SetClientVersion.restype = ctypes.c_bool
283
+
284
+ libzrod.SetWellName.argtypes = [zrodHandle, ctypes.c_char_p]
285
+ libzrod.SetWellName.restype = ctypes.c_bool
286
+ libzrod.GetWellName.argtypes = [zrodHandle]
287
+ libzrod.GetWellName.restype = ctypes.c_char_p
288
+
289
+ libzrod.LoadDyn.argtypes = [zrodHandle, ctypes.c_double, c_double_array, c_double_array, ctypes.c_int]
290
+ libzrod.LoadDyn.restype = ctypes.c_bool
291
+ libzrod.LoadDynFromFileContents.argtypes = [zrodHandle, ctypes.c_char_p]
292
+ libzrod.LoadDynFromFileContents.restype = ctypes.c_bool
293
+ libzrod.LoadDynFromFile.argtypes = [zrodHandle, ctypes.c_char_p]
294
+ libzrod.LoadDynFromFile.restype = ctypes.c_bool
295
+
296
+ libzrod.WriteDesignFile.argtypes = [zrodHandle, ctypes.c_char_p]
297
+ libzrod.WriteDesignFile.restype = ctypes.c_bool
298
+ libzrod.WriteDesignFileWithTemplate.argtypes = [zrodHandle, ctypes.c_char_p, ctypes.c_char_p]
299
+ libzrod.WriteDesignFileWithTemplate.restype = ctypes.c_bool
300
+
301
+ libzrod.ParseDesignFileContents.argtypes = [zrodHandle, ctypes.c_char_p, ctypes.c_char]
302
+ libzrod.ParseDesignFileContents.restype = ctypes.c_bool
303
+ libzrod.ParseDesignFile.argtypes = [zrodHandle, ctypes.c_char_p]
304
+ libzrod.ParseDesignFile.restype = ctypes.c_bool
305
+
306
+ libzrod.GetMeasuredDynoPointCount.argtypes = [zrodHandle]
307
+ libzrod.GetMeasuredDynoPointCount.restype = ctypes.c_int
308
+ libzrod.GetMeasuredDyno.argtypes = [zrodHandle, c_double_array, c_double_array]
309
+ libzrod.GetMeasuredDyno.restype = ctypes.c_bool
310
+ libzrod.GetMeasuredPump.argtypes = [zrodHandle, c_double_array, c_double_array]
311
+ libzrod.GetMeasuredPump.restype = ctypes.c_bool
312
+ libzrod.GetMeasuredPumpColors.argtypes = [zrodHandle, c_int_array]
313
+ libzrod.GetMeasuredPumpColors.restype = ctypes.c_bool
314
+
315
+ libzrod.GetUpscaledDynoPointCount.argtypes = [zrodHandle]
316
+ libzrod.GetUpscaledDynoPointCount.restype = ctypes.c_int
317
+ libzrod.GetUpscaledDyno.argtypes = [zrodHandle, c_double_array, c_double_array]
318
+ libzrod.GetUpscaledDyno.restype = ctypes.c_bool
319
+ libzrod.GetUpscaledPump.argtypes = [zrodHandle, c_double_array, c_double_array]
320
+ libzrod.GetUpscaledPump.restype = ctypes.c_bool
321
+ libzrod.GetUpscaledPumpColors.argtypes = [zrodHandle, c_int_array]
322
+ libzrod.GetUpscaledPumpColors.restype = ctypes.c_bool
323
+
324
+ libzrod.GetPredDynoPointCount.argtypes = [zrodHandle]
325
+ libzrod.GetPredDynoPointCount.restype = ctypes.c_int
326
+ libzrod.GetPredDyno.argtypes = [zrodHandle, c_double_array, c_double_array]
327
+ libzrod.GetPredDyno.restype = ctypes.c_bool
328
+ libzrod.GetPredPump.argtypes = [zrodHandle, c_double_array, c_double_array]
329
+ libzrod.GetPredPump.restype = ctypes.c_bool
330
+ libzrod.GetPredPumpColors.argtypes = [zrodHandle, c_int_array]
331
+ libzrod.GetPredPumpColors.restype = ctypes.c_bool
332
+
333
+ libzrod.GetIntermediateCard.argtypes = [zrodHandle, ctypes.c_int, ctypes.c_int, c_double_array, c_double_array]
334
+ libzrod.GetIntermediateCard.restype = ctypes.c_bool
335
+
336
+ libzrod.GetIntermediateTimeSlice.argtypes = [zrodHandle, ctypes.c_int, ctypes.c_int, c_double_array, c_double_array]
337
+ libzrod.GetIntermediateTimeSlice.restype = ctypes.c_bool
338
+
339
+ libzrod.GetPermissibleLoads.argtypes = [zrodHandle, c_double_array, c_double_array, ctypes.c_int, ctypes.c_double, ctypes.c_double]
340
+ libzrod.GetPermissibleLoads.restype = ctypes.c_bool
341
+
342
+ libzrod.GetMeasuredRodLoadingCount.argtypes = [zrodHandle]
343
+ libzrod.GetMeasuredRodLoadingCount.restype = ctypes.c_int
344
+ libzrod.GetUpscaledRodLoadingCount.argtypes = [zrodHandle]
345
+ libzrod.GetUpscaledRodLoadingCount.restype = ctypes.c_int
346
+ libzrod.GetPredRodLoadingCount.argtypes = [zrodHandle]
347
+ libzrod.GetPredRodLoadingCount.restype = ctypes.c_int
348
+
349
+ libzrod.GetMeasuredRodLoading.argtypes = [zrodHandle, c_double_array, c_double_array, c_double_array, c_double_array, c_double_array]
350
+ libzrod.GetMeasuredRodLoading.restype = ctypes.c_bool
351
+ libzrod.GetUpscaledRodLoading.argtypes = [zrodHandle, c_double_array, c_double_array, c_double_array, c_double_array, c_double_array]
352
+ libzrod.GetUpscaledRodLoading.restype = ctypes.c_bool
353
+ libzrod.GetPredRodLoading.argtypes = [zrodHandle, c_double_array, c_double_array, c_double_array, c_double_array, c_double_array]
354
+ libzrod.GetPredRodLoading.restype = ctypes.c_bool
355
+
356
+ libzrod.GetPuInfo.argtypes = [zrodHandle]
357
+ libzrod.GetPuInfo.restype = PuInfo_t
358
+ libzrod.SetPuInfo.argtypes = [zrodHandle, PuInfo_t]
359
+ libzrod.SetPuInfo.restype = ctypes.c_bool
360
+ libzrod.SetPuByName.argtypes = [zrodHandle, ctypes.c_char_p]
361
+ libzrod.SetPuByName.restype = ctypes.c_bool
362
+
363
+ libzrod.SetPuApi.argtypes = [zrodHandle, PuApi_t]
364
+ libzrod.SetPuApi.restype = ctypes.c_bool
365
+
366
+ libzrod.SetFourierCoeffCountPos.argtypes = [zrodHandle, ctypes.c_int]
367
+ libzrod.SetFourierCoeffCountLoad.argtypes = [zrodHandle, ctypes.c_int]
368
+
369
+ libzrod.SetPredTapers.argtypes = [zrodHandle, ctypes.c_void_p, ctypes.c_int, ctypes.c_double]
370
+ libzrod.SetPredTapers.restype = ctypes.c_bool
371
+ libzrod.SetDiagTapers.argtypes = [zrodHandle, ctypes.c_void_p, ctypes.c_int, ctypes.c_double]
372
+ libzrod.SetDiagTapers.restype = ctypes.c_bool
373
+
374
+ libzrod.SetPredTubings.argtypes = [zrodHandle, ctypes.c_void_p, ctypes.c_int]
375
+ libzrod.SetPredTubings.restype = ctypes.c_bool
376
+ libzrod.SetDiagTubings.argtypes = [zrodHandle, ctypes.c_void_p, ctypes.c_int]
377
+ libzrod.SetDiagTubings.restype = ctypes.c_bool
378
+
379
+ libzrod.CalculateFo.argtypes = [zrodHandle]
380
+ libzrod.CalculateFo.restype = ctypes.c_double
381
+
382
+ libzrod.CalculateKrToDepth.argtypes = [zrodHandle, ctypes.c_double]
383
+ libzrod.CalculateKrToDepth.restype = ctypes.c_double
384
+
385
+ '''
386
+ libzrod.CalcWaveDiagStepInit.argtypes = [zrodHandle]
387
+ libzrod.CalcWaveDiagStepInit.restype = ctypes.c_int #the size of the load & pos arrays to allocate
388
+ libzrod.CalcWaveDiagStep.argtypes = [zrodHandle, ctypes.c_int, c_double_array, c_double_array]
389
+ libzrod.CalcWaveDiagStep.restype = ctypes.c_bool
390
+ libzrod.CalcWaveDiagStepDealloc.argtypes = [zrodHandle]
391
+ libzrod.CalcWaveDiagStepDealloc.restype = ctypes.c_bool
392
+ '''
393
+
394
+
395
+
396
+
397
+ @ctypes.CFUNCTYPE(None, ctypes.c_char_p)
398
+ def Logfunc(text): print(f"Logfunc: {text.decode('utf-8')}")
399
+
400
+ class zrod:
401
+ def __new__(cls):
402
+ if(not hasattr(cls, 'instance')):
403
+ cls.instance = super(zrod, cls).__new__(cls)
404
+ else:
405
+ print("WARNING: instance already created. Using the preallocated one.")
406
+ #endif
407
+ return(cls.instance)
408
+ #end __new__()
409
+
410
+ def __init__(self):
411
+ self.instance = libzrod.CreateZrodObj()
412
+ libzrod.SetLoggingCallback(self.instance, Logfunc)
413
+ #end __init__()
414
+
415
+ def __del__(self): libzrod.DeleteZrodObj(self.instance)
416
+
417
+ def runzrod(self): libzrod.runzrod(self.instance)
418
+ def Login(self, username, password): return(libzrod.Login(self.instance, str.encode(username), str.encode(password)))
419
+ def Logout(self): return(libzrod.Logout(self.instance))
420
+ def Test(self): libzrod.Test(self.instance)
421
+ def SaveCurrentDesign(self, overwrite): return(libzrod.SaveCurrentDesign(self.instance, overwrite))
422
+ def FetchDesigns(self, fromserver): return(libzrod.FetchDesigns(self.instance, fromserver))
423
+ def GetDesign(self, designId): return(libzrod.GetDesign(self.instance, str.encode(designId)))
424
+
425
+ def DeleteZrodObj(self): print("Use pythons del THEINSTANCE")
426
+ def PrintZrodObj(self): libzrod.PrintZrodObj(self.instance)
427
+ def GetZrodVersion(self):
428
+ dest = np.empty(4, dtype=np.int32)
429
+ libzrod.GetZrodVersion(self.instance, dest)
430
+ return(dest)
431
+ #end GetZrodVersion()
432
+ def GetZrodVersionString(self):
433
+ libver = self.GetZrodVersion()
434
+ strlibver = '.'.join(map(str, libver))
435
+ return(strlibver)
436
+ #end GetZrodVersionString
437
+ def DebugZrodObj(self, filepath):
438
+ try:
439
+ if(filepath is None):
440
+ libzrod.DebugZrodObj(self.instance, filepath)
441
+ else:
442
+ libzrod.DebugZrodObj(self.instance, str.encode(filepath))
443
+ #endif
444
+ except:
445
+ print("Debug not available")
446
+ #end try
447
+ #end DebugZrodObj()
448
+
449
+ def RunDesign(self): return(libzrod.RunDesign(self.instance))
450
+ def GetWaveResults(self): return(libzrod.GetWaveResults(self.instance))
451
+ def GetWaveParams(self): return(libzrod.GetWaveParams(self.instance))
452
+ def SetWaveParams(self, newParam): return(libzrod.SetWaveParams(self.instance, newParam))
453
+ def GetWaveResults(self): return(libzrod.GetWaveResults(self.instance))
454
+ def GetWaveSettings(self): return(libzrod.GetWaveSettings(self.instance))
455
+ def SetWaveSettings(self, newSettings): return(libzrod.SetWaveSettings(self.instance, newSettings))
456
+
457
+ def GetDeviationSurveyCount(self): return(libzrod.GetDeviationSurveyCount(self.instance))
458
+ def GetDeviationSurvey(self):
459
+ surveypoints = self.GetDeviationSurveyCount()
460
+ elems = (DeviationSurveyPoint_t * surveypoints)()
461
+ libzrod.GetDeviationSurvey(self.instance, elems)
462
+ return(elems)
463
+ #end GetDeviationSurvey()
464
+
465
+ def SetClientVersion(self): return(libzrod.SetClientVersion(self.instance, str.encode("py"), 2, 0, 0, 1))
466
+ def SetWellName(self, newWellName): return(libzrod.SetWellName(self.instance, str.encode(newWellName)))
467
+ def GetWellName(self): return(libzrod.GetWellName(self.instance).decode("ascii"))
468
+
469
+ def LoadDyn(self, spm, x_array, y_array):
470
+ if(len(x_array) != len(y_array)): raise ValueError("Array sizes must match")
471
+ if(type(x_array) is not type(y_array)): raise ValueError("Array types must match")
472
+ #make sure theyre doubles
473
+ if(type(x_array) is not "np.float64"): x_array = np.array(x_array, dtype=np.float64)
474
+ if(type(y_array) is not "np.float64"): y_array = np.array(y_array, dtype=np.float64)
475
+ return(libzrod.LoadDyn(self.instance, spm, x_array, y_array, len(x_array)))
476
+ #end LoadDyn()
477
+ def LoadDynFromFileContents(self, dyntext): return(libzrod.LoadDynFromFileContents(self.instance, dyntext))
478
+ def LoadDynFromFile(self, filepath):
479
+ filepath = filepath.replace("~", os.path.expanduser('~'))
480
+ return(libzrod.LoadDynFromFile(self.instance, str.encode(filepath)))
481
+ #end LoadDynFromFile()
482
+
483
+ def LoadDynFromDAT(self, filepath):
484
+ filepath = filepath.replace("~", os.path.expanduser('~'))
485
+ print(filepath)
486
+ with open(filepath) as file:
487
+ lines = [line.rstrip() for line in file]
488
+ #end with
489
+ strokelength = lines[5]
490
+ spm = float(lines[8])
491
+ points = int(lines[9])
492
+ print(points)
493
+ load = []
494
+ pos = []
495
+ for i in range(10, 10+points):
496
+ load.append(float(lines[i]))
497
+ pos.append(float(lines[i+points]))
498
+ #end for
499
+ return(self.LoadDyn(spm, np.array(pos), np.array(load)+600))
500
+ #end LoadDynFromDAT()
501
+
502
+ def WriteDesignFile(self, filepath):
503
+ filepath = filepath.replace("~", os.path.expanduser('~'))
504
+ return(libzrod.WriteDesignFile(self.instance, str.encode(filepath)))
505
+ #end WriteDesignFile()
506
+ def WriteDesignFileWithTemplate(self, filepath, templatepath):
507
+ filepath = filepath.replace("~", os.path.expanduser('~'))
508
+ templatepath = templatepath.replace("~", os.path.expanduser('~'))
509
+ return(libzrod.WriteDesignFileWithTemplate(self.instance, str.encode(filepath), str.encode(templatepath)))
510
+ #end WriteDesignFileWithTemplate()
511
+
512
+ def ParseDesignFileContents(self, filecontents, ftype): return(libzrod.ParseDesignFileContents(self.instance, filecontents, ftype))
513
+ def ParseDesignFile(self, filepath):
514
+ filepath = filepath.replace("~", os.path.expanduser('~'))
515
+ return(libzrod.ParseDesignFile(self.instance, str.encode(filepath)))
516
+ #end ParseDesignFile()
517
+
518
+ def GetMeasuredDynoPointCount(self): return(libzrod.GetMeasuredDynoPointCount(self.instance))
519
+ def GetMeasuredDyno(self):
520
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
521
+ pointcount = waveParamsRO.diagMeasPointCount
522
+ destX = np.empty(pointcount, dtype=np.float64)
523
+ destY = np.empty(pointcount, dtype=np.float64)
524
+ libzrod.GetMeasuredDyno(self.instance, destX, destY)
525
+ return(destX, destY)
526
+ #end GetMeasuredDyno()
527
+ def GetMeasuredPump(self):
528
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
529
+ pointcount = waveParamsRO.diagMeasPointCount
530
+ destX = np.empty(pointcount, dtype=np.float64)
531
+ destY = np.empty(pointcount, dtype=np.float64)
532
+ libzrod.GetMeasuredPump(self.instance, destX, destY)
533
+ return(destX, destY)
534
+ #end GetMeasuredPump()
535
+ def GetMeasuredPumpColors(self):
536
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
537
+ pointcount = waveParamsRO.diagMeasPointCount
538
+ destC = np.empty(pointcount, dtype=np.int32)
539
+ libzrod.GetMeasuredPumpColors(self.instance, destC)
540
+ return(destC)
541
+ #end GetMeasuredPumpColors()
542
+
543
+ def SetUpscaledDynoPointCount(self, pointcount): libzrod.SetUpscaledDynoPointCount(self.instance, pointcount)
544
+ def GetUpscaledDynoPointCount(self): return(libzrod.GetUpscaledDynoPointCount(self.instance))
545
+ def GetUpscaledDyno(self):
546
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
547
+ pointcount = waveParamsRO.diagUpscPointCount
548
+ destX = np.empty(pointcount, dtype=np.float64)
549
+ destY = np.empty(pointcount, dtype=np.float64)
550
+ libzrod.GetUpscaledDyno(self.instance, destX, destY)
551
+ return(destX, destY)
552
+ #end GetUpscaledDyno()
553
+ def GetUpscaledPump(self):
554
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
555
+ pointcount = waveParamsRO.diagUpscPointCount
556
+ destX = np.empty(pointcount, dtype=np.float64)
557
+ destY = np.empty(pointcount, dtype=np.float64)
558
+ libzrod.GetUpscaledPump(self.instance, destX, destY)
559
+ return(destX, destY)
560
+ #end GetUpscaledPump()
561
+ def GetUpscaledPumpColors(self):
562
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
563
+ pointcount = waveParamsRO.diagUpscPointCount
564
+ destC = np.empty(pointcount, dtype=np.int32)
565
+ libzrod.GetUpscaledPumpColors(self.instance, destC)
566
+ return(destC)
567
+ #end GetUpscaledPumpColors()
568
+
569
+ def GetPredDynoPointCount(self): return(libzrod.GetPredDynoPointCount(self.instance))
570
+ def GetPredDyno(self):
571
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
572
+ pointcount = waveParamsRO.predPointCount
573
+ destX = np.empty(pointcount, dtype=np.float64)
574
+ destY = np.empty(pointcount, dtype=np.float64)
575
+ libzrod.GetPredDyno(self.instance, destX, destY)
576
+ return(destX, destY)
577
+ #end GetPredDyno()
578
+ def GetPredPump(self):
579
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
580
+ pointcount = waveParamsRO.predPointCount
581
+ destX = np.empty(pointcount, dtype=np.float64)
582
+ destY = np.empty(pointcount, dtype=np.float64)
583
+ libzrod.GetPredPump(self.instance, destX, destY)
584
+ return(destX, destY)
585
+ #end GetPredPump()
586
+ def GetPredPumpColors(self):
587
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
588
+ pointcount = waveParamsRO.predPointCount
589
+ destC = np.empty(pointcount, dtype=np.int32)
590
+ libzrod.GetPredPumpColors(self.instance, destC)
591
+ return(destC)
592
+ #end GetPredPumpColors()
593
+
594
+ def GetIntermediateCard(self, nodeindex, dynotype):
595
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
596
+ pointcount = 0
597
+ if(dynotype == 1): #meas
598
+ pointcount = waveParamsRO.diagMeasPointCount
599
+ elif(dynotype == 2): #upsc
600
+ pointcount = waveParamsRO.diagUpscPointCount
601
+ elif(dynotype == 3): #pred
602
+ pointcount = waveParamsRO.predPointCount
603
+ #endif
604
+ destX = np.empty(pointcount, dtype=np.float64)
605
+ destY = np.empty(pointcount, dtype=np.float64)
606
+ libzrod.GetIntermediateCard(self.instance, nodeindex, dynotype, destX, destY)
607
+ return(destX, destY)
608
+ #end GetIntermediateCard()
609
+
610
+ def GetIntermediateTimeSlice(self, TimeStep, dynotype):
611
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
612
+ nodecount = 0
613
+ if(dynotype == 1): #meas
614
+ nodecount = waveParamsRO.diagMeasM
615
+ elif(dynotype == 2): #upsc
616
+ nodecount = waveParamsRO.diagUpscM
617
+ elif(dynotype == 3): #pred
618
+ nodecount = waveParamsRO.predM
619
+ #endif
620
+ destX = np.empty(nodecount, dtype=np.float64)
621
+ destY = np.empty(nodecount, dtype=np.float64)
622
+ libzrod.GetIntermediateTimeSlice(self.instance, TimeStep, dynotype, destX, destY)
623
+ return(destX, destY)
624
+ #end GetIntermediateTimeSlice()
625
+
626
+
627
+ def SetDiagTapers(self, tapers, tapercount, fluidSG):
628
+ return(libzrod.SetDiagTapers(self.instance, tapers, tapercount, fluidSG))
629
+ #end SetDiagTapers()
630
+ def SetPredTapers(self, tapers, tapercount, fluidSG):
631
+ return(libzrod.SetPredTapers(self.instance, tapers, tapercount, fluidSG))
632
+ #end SetPredTapers()
633
+ def xSetDiagTapers(self, tapers, fluidSG):
634
+ return(libzrod.SetDiagTapers(self.instance, ctypes.byref(tapers), len(tapers), fluidSG))
635
+ #end xSetDiagTapers()
636
+ def xSetPredTapers(self, tapers, fluidSG):
637
+ return(libzrod.SetPredTapers(self.instance, ctypes.byref(tapers), len(tapers), fluidSG))
638
+ #end xSetPredTapers()
639
+
640
+ def SetDiagTubings(self, tubings, tubingcount):
641
+ return(libzrod.SetDiagTubings(self.instance, tubings, tubingcount))
642
+ #end SetDiagTubings()
643
+ def SetPredTubings(self, tubings, tubingcount):
644
+ return(libzrod.SetPredTubings(self.instance, tubings, tubingcount))
645
+ #end SetPredTubings()
646
+ def xSetDiagTubings(self, tubings):
647
+ return(libzrod.SetDiagTubings(self.instance, ctypes.byref(tubings), len(tubings)))
648
+ #end xSetDiagTubings()
649
+ def xSetPredTubings(self, tubings):
650
+ return(libzrod.SetPredTubings(self.instance, ctypes.byref(tubings), len(tubings)))
651
+ #end xSetPredTubings()
652
+
653
+ def GetPermissibleLoads(self, destX, destY, pointcount, clipmin, clipmax):
654
+ return(libzrod.GetPermissibleLoads(self.instance, destX, destY, pointcount, clipmin, clipmax))
655
+ #end GetPermissibleLoads()
656
+
657
+ def GetMeasuredRodLoadingCount(self): return(libzrod.GetMeasuredRodLoadingCount(self.instance))
658
+ def GetUpscaledRodLoadingCount(self): return(libzrod.GetUpscaledRodLoadingCount(self.instance))
659
+ def GetPredRodLoadingCount(self): return(libzrod.GetPredRodLoadingCount(self.instance))
660
+
661
+ def xGetMeasuredRodLoading(self):
662
+ pointcount = libzrod.GetMeasuredRodLoadingCount(self.instance)
663
+ destDepth = np.empty(pointcount, dtype=np.float64)
664
+ destLbsMax = np.empty(pointcount, dtype=np.float64)
665
+ destLbsMin = np.empty(pointcount, dtype=np.float64)
666
+ destPctMax = np.empty(pointcount, dtype=np.float64)
667
+ destPctMin = np.empty(pointcount, dtype=np.float64)
668
+ libzrod.GetMeasuredRodLoading(self.instance, destDepth, destLbsMax, destLbsMin, destPctMax, destPctMin)
669
+ return(destDepth, destLbsMax, destLbsMin, destPctMax, destPctMin)
670
+ #end xGetMeasuredRodLoading()
671
+ def xGetUpscaledRodLoading(self):
672
+ pointcount = libzrod.GetUpscaledRodLoadingCount(self.instance)
673
+ destDepth = np.empty(pointcount, dtype=np.float64)
674
+ destLbsMax = np.empty(pointcount, dtype=np.float64)
675
+ destLbsMin = np.empty(pointcount, dtype=np.float64)
676
+ destPctMax = np.empty(pointcount, dtype=np.float64)
677
+ destPctMin = np.empty(pointcount, dtype=np.float64)
678
+ libzrod.GetUpscaledRodLoading(self.instance, destDepth, destLbsMax, destLbsMin, destPctMax, destPctMin)
679
+ return(destDepth, destLbsMax, destLbsMin, destPctMax, destPctMin)
680
+ #end xGetUpscaledRodLoading()
681
+ def xGetPredRodLoading(self):
682
+ pointcount = libzrod.GetPredRodLoadingCount(self.instance)
683
+ destDepth = np.empty(pointcount, dtype=np.float64)
684
+ destLbsMax = np.empty(pointcount, dtype=np.float64)
685
+ destLbsMin = np.empty(pointcount, dtype=np.float64)
686
+ destPctMax = np.empty(pointcount, dtype=np.float64)
687
+ destPctMin = np.empty(pointcount, dtype=np.float64)
688
+ libzrod.GetPredRodLoading(self.instance, destDepth, destLbsMax, destLbsMin, destPctMax, destPctMin)
689
+ return(destDepth, destLbsMax, destLbsMin, destPctMax, destPctMin)
690
+ #end xGetPredRodLoading()
691
+
692
+ def GetPuInfo(self): return(libzrod.GetPuInfo(self.instance))
693
+ def SetPuInfo(self, newPuInfo): return(libzrod.SetPuInfo(self.instance, newPuInfo))
694
+ def SetPuByName(self, newpuname): return(libzrod.SetPuByName(self.instance, newpuname))
695
+ def SetPuApi(self, newPuApi): return(libzrod.SetPuApi(self.instance, newPuApi))
696
+
697
+ def SetFourierCoeffCountPos(self, count): libzrod.SetFourierCoeffCountPos(self.instance, count)
698
+ def SetFourierCoeffCountLoad(self, count): libzrod.SetFourierCoeffCountLoad(self.instance, count)
699
+
700
+ def CalculateFo(self): return(libzrod.CalculateFo(self.instance))
701
+ def CalculateKrToDepth(self, depth): return(libzrod.CalculateKrToDepth(self.instance, depth))
702
+
703
+ '''
704
+ #TODO: delete these... theyre obsolete
705
+ #for incrimental calcs. used for animations and really big datasets (or for live/realtime calcs).
706
+ def CalcWaveDiagStepInit(self): return(libzrod.CalcWaveDiagStepInit(self.instance))
707
+ def CalcWaveDiagStep(self, TimeStep):
708
+ waveParamsRO = libzrod.GetWaveParamsReadOnly(self.instance)
709
+ nodecount = waveParamsRO.diagMeasM
710
+ load = np.empty(nodecount, dtype=np.float64)
711
+ pos = np.empty(nodecount, dtype=np.float64)
712
+ result = libzrod.CalcWaveDiagStep(self.instance, TimeStep, load, pos)
713
+ return(result, load, pos)
714
+ #end CalcWaveDiagStep()
715
+ def CalcWaveDiagStepDealloc(self): return(libzrod.CalcWaveDiagStepDealloc(self.instance))
716
+ '''
717
+ #end zrod
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = [
3
+ "scikit-build-core",
4
+ "numpy",
5
+ ]
6
+ build-backend = "scikit_build_core.build"
7
+
8
+ [project]
9
+ name = "libzrod"
10
+ version = "0.1.2"
11
+
12
+ [tool.scikit-build]
13
+ cmake.build-type = "Release"
14
+ logging.level = "INFO"
15
+ build.verbose = true
16
+ install.strip = true
17
+ #messages.after-sucesss = "{green}Wheel successfully built"
18
+ wheel.py-api = "py3"
19
+ build-dir = "./build/{wheel_tag}"
20
+
21
+
22
+ #[tool.scikit-build.cmake.define]
23
+ #USE_AWS_SDK = true #TODO: this should be eliminated once the aws code is fully implemented and stable
24
+ #JWT_DISABLE_PICOJSON = true
libzrod-0.1.2/setup.py ADDED
@@ -0,0 +1,30 @@
1
+ from skbuild import setup
2
+ setup(
3
+ name="libzrod",
4
+ version="0.1.0",
5
+ description="ZROD Library",
6
+ author="Walter Phillips",
7
+ license="Commercial - Contact Me",
8
+ packages=[
9
+ "libzrod",
10
+ ],
11
+ python_requires=">=3.8",
12
+ )
13
+ '''
14
+ ${LIBAWS_PATH}/libaws-c-auth.a
15
+ ${LIBAWS_PATH}/libaws-c-cal.a
16
+ ${LIBAWS_PATH}/libaws-c-common.a
17
+ ${LIBAWS_PATH}/libaws-c-compression.a
18
+ ${LIBAWS_PATH}/libaws-c-event-stream.a
19
+ ${LIBAWS_PATH}/libaws-c-http.a
20
+ ${LIBAWS_PATH}/libaws-c-io.a
21
+ ${LIBAWS_PATH}/libaws-c-mqtt.a
22
+ ${LIBAWS_PATH}/libaws-c-s3.a
23
+ ${LIBAWS_PATH}/libaws-c-sdkutils.a
24
+ ${LIBAWS_PATH}/libaws-checksums.a
25
+ ${LIBAWS_PATH}/libaws-cpp-sdk-cognito-identity.a
26
+ ${LIBAWS_PATH}/libaws-cpp-sdk-core.a
27
+ ${LIBAWS_PATH}/libaws-cpp-sdk-dynamodb.a
28
+ ${LIBAWS_PATH}/libaws-cpp-sdk-s3.a
29
+ ${LIBAWS_PATH}/libaws-crt-cpp.a
30
+ '''