To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 16f9e927 authored by Feliks Kiszkurno's avatar Feliks Kiszkurno
Browse files

Added normalization, normalized classes, AdaBoost, KNN.

parent c62bd5c2
File mode changed from 100644 to 100755
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/data" /> <excludeFolder url="file://$MODULE_DIR$/data" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.7 (MasterEnv)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.7 (SlopeStability)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PyDocumentationSettings"> <component name="PyDocumentationSettings">
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (MasterEnv)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (SlopeStability)" project-jdk-type="Python SDK" />
</project> </project>
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -6,25 +6,17 @@ Created on Fri Jan 8 10:29:00 2021 ...@@ -6,25 +6,17 @@ Created on Fri Jan 8 10:29:00 2021
@author: Feliks Kiszkurno @author: Feliks Kiszkurno
""" """
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import slopestabilitytools
import slopestabilitytools.datamanagement import slopestabilitytools.datamanagement
import slopestabilityML import slopestabilityML
import slostabcreatedata import slostabcreatedata
import numpy as np
import settings
import pygimli as pg settings.init()
import pygimli.meshtools as mt
import pygimli.physics.ert as ert
# Config # Config
create_new_data = False create_new_data = True
create_new_data_only = False create_new_data_only = True
# Prepare folder structure for output
is_success = slopestabilitytools.folder_structure.create_folder_structure()
if not create_new_data: if not create_new_data:
...@@ -32,46 +24,69 @@ if not create_new_data: ...@@ -32,46 +24,69 @@ if not create_new_data:
else: else:
# Prepare folder structure for output
is_success = slopestabilitytools.folder_structure.create_folder_structure()
# TODO Put this part into a function # TODO Put this part into a function
# Settings # Settings
number_of_tests = 50 number_of_tests = 5
rho_spread_factor = 1.5 rho_spread_factor = 1.5
rho_max = 20 rho_max = 20
layers_min = 1 layers_min = 1
layers_max = 2 layers_max = 2
min_depth = 4 min_depth = 4
max_depth = 10 max_depth = 8
# Generate parameters for tests # Generate parameters for tests
tests_horizontal = slopestabilitytools.model_params(number_of_tests, # tests_horizontal = slopestabilitytools.model_params(number_of_tests,
rho_spread_factor, rho_max, # rho_spread_factor, rho_max,
layers_min, layers_max, # layers_min, layers_max,
min_depth, max_depth) # min_depth, max_depth)
# tests_horizontal = {'hor_1': {'layer_n': 1, 'rho_values': [[1, 5], [2, 15]], 'layers_pos': np.array([-5])}, tests_horizontal = {'hor_01': {'layer_n': 1, 'rho_values': [[1, 5], [2, 15]], 'layers_pos': np.array([-5])},
# 'hor_2': {'layer_n': 1, 'rho_values': [[1, 5], [2, 50]], 'layers_pos': np.array([-5])}, 'hor_02': {'layer_n': 1, 'rho_values': [[1, 5], [2, 50]], 'layers_pos': np.array([-5])},
# 'hor_3': {'layer_n': 1, 'rho_values': [[1, 15], [2, 20]], 'layers_pos': np.array([-8])}, 'hor_03': {'layer_n': 1, 'rho_values': [[1, 15], [2, 20]], 'layers_pos': np.array([-8])},
# 'hor_4': {'layer_n': 1, 'rho_values': [[1, 5], [2, 10]], 'layers_pos': np.array([-3])}, 'hor_04': {'layer_n': 1, 'rho_values': [[1, 5], [2, 10]], 'layers_pos': np.array([-3])},
# 'hor_5': {'layer_n': 1, 'rho_values': [[1, 5], [2, 25]], 'layers_pos': np.array([-3])}} 'hor_05': {'layer_n': 1, 'rho_values': [[1, 5], [2, 25]], 'layers_pos': np.array([-3])},
'hor_06': {'layer_n': 1, 'rho_values': [[1, 2], [2, 10]], 'layers_pos': np.array([-4])},
'hor_07': {'layer_n': 1, 'rho_values': [[1, 10], [2, 20]], 'layers_pos': np.array([-6])},
'hor_08': {'layer_n': 1, 'rho_values': [[1, 5], [2, 25]], 'layers_pos': np.array([-3])},
'hor_09': {'layer_n': 1, 'rho_values': [[1, 3], [2, 25]], 'layers_pos': np.array([-3])},
'hor_10': {'layer_n': 1, 'rho_values': [[1, 5], [2, 25]], 'layers_pos': np.array([-7])},
'hor_11': {'layer_n': 1, 'rho_values': [[1, 10], [2, 12]], 'layers_pos': np.array([-4])},
'hor_12': {'layer_n': 1, 'rho_values': [[1, 15], [2, 50]], 'layers_pos': np.array([-5])},
'hor_13': {'layer_n': 2, 'rho_values': [[1, 3], [2, 5], [3, 15]],
'layers_pos': np.array([-3, -6])},
'hor_14': {'layer_n': 2, 'rho_values': [[1, 2], [2, 4], [3, 8]],
'layers_pos': np.array([-4, -8])},
'hor_15': {'layer_n': 1, 'rho_values': [[1, 4], [2, 15], [3, 25]],
'layers_pos': np.array([-4, -8])},
'hor_16': {'layer_n': 1, 'rho_values': [[1, 5], [2, 20], [3, 50]],
'layers_pos': np.array([-4, -8])}
}
# tests_horizontal = {'hor_9': {'layer_n': 1, 'rho_values': [[1, 3], [2, 25]], 'layers_pos': np.array([-3])},}
# Create models and invert them # Create models and invert them
test_results = {} test_results = {}
for test_name in tests_horizontal.keys(): for test_name in tests_horizontal.keys():
test_result_curr, test_rho_max, test_rho_min = slostabcreatedata.create_data(test_name, tests_horizontal[test_name], max_depth) test_result_curr, test_rho_max, test_rho_min = slostabcreatedata.create_data(test_name,
tests_horizontal[test_name],
max_depth)
test_results.update({test_name: test_result_curr}) test_results.update({test_name: test_result_curr})
del test_result_curr del test_result_curr
# Plot and save figures # Plot and save figures
slopestabilitytools.plot_and_save(test_name, test_results[test_name], 'Test: ' + test_name, test_rho_max, test_rho_min) slopestabilitytools.plot_and_save(test_name, test_results[test_name], 'Test: ' + test_name, test_rho_max,
test_rho_min)
if not create_new_data_only: if not create_new_data_only:
print('Running ML stuff...')
#for test_name in test_results.keys():
#slopestabilitytools.plot_and_save(test_name, test_results[test_name], 'Test: ' + test_name)
print('Running ML stuff...')
ml_results = slopestabilityML.run_all_tests(test_results) ml_results = slopestabilityML.run_all_tests(test_results)
# svm_accuracy_score, svm_accuracy_labels = slopestabilityML.svm_run(test_results)
elif create_new_data_only: elif create_new_data_only:
print('Done') print('Done')
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 8 10:29:00 2021
@author: felikskrno
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import slopestabilitytools
import slopestabilityML
import slostabcreatedata
import pygimli as pg
import pygimli.meshtools as mt
import pygimli.physics.ert as ert
is_success = slopestabilitytools.folder_structure.create_folder_structure()
number_of_tests = 10
rho_spread_factor = 1.5
rho_max = 150
layers_min = 1
layers_max = 3
min_depth = 1
max_depth = 10
tests_horizontal = slopestabilitytools.model_params(number_of_tests,
rho_spread_factor, rho_max,
layers_min, layers_max,
min_depth, max_depth)
world_boundary_v = [-200, 0] # [right, left border] relatively to the middle
world_boundary_h = [200, -100] # [top, bottom border]
test_results = {}
test_results_grid = {}
test_input = {}
test_name = 'hor_1'
#tests_horizontal['layers_pos'][test_name] = [-5]
# INPUT MODEL - SUBSURFACE START #
world = mt.createWorld(start=world_boundary_v, end=world_boundary_h, layers=tests_horizontal['layers_pos'][test_name])#,
#marker=np.linspace(1, tests_horizontal['layer_n']['hor_1'],
# tests_horizontal['layer_n']['hor_1']))
geometry = world # +block
measurement_scheme = ert.createERTData(elecs=np.linspace(start=-45, stop=45, num=91), schemeName='dd')
for electrode in measurement_scheme.sensors():
geometry.createNode(electrode)
geometry.createNode(electrode - [0, 0.1]) # What does it do?
mesh = mt.createMesh(geometry, quality=34) # , area=2)#
resistivity_map = tests_horizontal['rho_values'][test_name] # [0]
#resistivity_map[0] = [1, 50.0]
#resistivity_map[1] = [2, 150.0]
input_model = pg.solver.parseMapToCellArray(resistivity_map, mesh) # rename to input_mesh
# INPUT MODEL - SUBSURFACE MODEL END ###
# SIMULATE ERT MEASUREMENT - START ###
mesh_pd = [] # add new mesh
data = ert.simulate(mesh, scheme=measurement_scheme, res=resistivity_map, noiseLevel=1, noiseAbs=1e-6, seed=1337)
data.remove(data['rhoa'] < 0)
# SIMULATE ERT MEASUREMENT - END ###
ert_manager = ert.ERTManager(sr=False, useBert=True, verbose=True, debug=False)
# RUN INVERSION #
k0 = pg.physics.ert.createGeometricFactors(data)
model_inverted = ert_manager.invert(data=data, lam=20, paraDX=0.25, paraMaxCellSize=5, paraDepth=10, quality=34,
zPower=0.4)
result = ert_manager.inv.model
result_array = result.array()
input_model2 = pg.interpolate(srcMesh=mesh, inVec=input_model, destPos=ert_manager.paraDomain.cellCenters())
input_model2_array = input_model2.array()
experiment_results = pd.DataFrame(data={'X': ert_manager.paraDomain.cellCenters().array()[:, 0],
'Y': ert_manager.paraDomain.cellCenters().array()[:, 1],
'Z': ert_manager.paraDomain.cellCenters().array()[:, 2],
'INM': input_model2_array,
'RES': result_array})
test_results[test_name] = experiment_results
fig, ax = plt.subplots(3)
fig.suptitle(test_name)
pg.show(ert_manager.paraDomain, input_model2, ax=ax[0])
ax[0].set_title("Model on the output mesh")
pg.show(ert_manager.paraDomain, result, ax=ax[1])
ax[1].set_title("Inverted")
pg.show(ert_manager.paraDomain, result - input_model2, ax=ax[2])
ax[2].set_title("Diff")
fig.savefig('results/figs/hor_{}_results.eps'.format(test_name))
fig.savefig('results/figs/hor_{}_results.png'.format(test_name))
fig_input, ax_input = plt.subplots(1)
pg.show(mesh, input_model, ax=ax_input)
ax_input.set_title('1 Geometry of the model')
fig_input.savefig('results/figs/hor_{}_input.eps'.format(test_name))
fig_input.savefig('results/figs/hor_{}_input.png'.format(test_name))
5.91769028468824e-02
3.77712408632849e+00
1.06250187836734e+00
1.77078717665889e+00
2.26861247353878e+00
4.20384785892980e+00
1.81775568731321e+00
1.37169240984168e+00
1.57607767304988e+00
3.75033704906075e+00
3.19286103194653e+00
1.91473293149574e+01
5.68561421778534e+00
3.17566872961147e+00
3.80293418264249e+00
5.11196454783685e-02
4.03645277649927e+00
5.22151894576825e+00
6.94908214303065e+00
5.54828474129026e+00
5.83038513108476e+00
3.42011383053834e+00
4.61725350565109e+00
8.19909186657696e+00
3.00353957071345e-02
2.69388194842656e+00
3.97172372128109e+00
5.60393524241371e+00
3.13044919681189e+00
1.84637382778798e+00
5.24803025921179e+00
3.06125531080335e+00
1.24596855577298e+01
1.35650727808529e+01
5.77565356680434e+00
2.76299602256552e+01
1.39782757418754e+01
1.74343494721201e+00
5.23595043903876e+00
1.44966445140855e+01
2.04503309338281e+01
2.46604225952471e+01
1.84596700739655e+00
1.47725328603079e+00
5.25374144113801e+00
4.82130280654159e+00
3.53959607614107e+00
1.07647671143803e+01
3.18445240448672e+00
2.57819401235214e+00
4.57206105755315e+00
1.58322188765830e+01
1.05060893460273e+01
7.23390858857545e+00
1.30844490746097e+01
1.63722460148707e+01
2.21157937696972e+01
4.08883602295726e+00
6.06911337131211e+00
5.28771044385381e+00
4.81393111383726e+00
1.58956484285794e+01
7.45949600511671e+00
7.08372075654141e+00
4.97803855343430e+00
1.48227939559368e+01
1.33200859020857e+00
1.43878205387745e+00
3.67660232409653e+00
4.40030646575661e+00
1.99250666186120e+01
3.12611536942088e+00
6.71657341317301e+00
5.49972716464462e+00
1.52706069883420e+00
1.07046740627831e+00
4.10639041040721e+00
5.20347629572084e+00
5.14246488716838e+00
3.73265762289328e+00
4.99116964956070e+00
6.70940231101851e+00
1.16868814954076e+01
6.35903547526793e+00
4.15959997403486e+00
7.33288386722587e+00
4.80144108087224e+00
3.57084387570319e+00
4.97635611213546e+00
1.15133099990814e+01
5.41356328367307e+00
6.68931567909615e+00
4.74992891643176e+00
8.42230586949967e+00
5.28397403196592e+00
1.16009051321376e+00
9.06750984262229e+00
3.76025822366830e+00
6.44436824709062e+00
1.30629305877955e+00
1.50756715179946e+01
3.64580568231627e+00
8.58313327530320e+00
1.13369307377412e+01
1.36993745786067e+01
3.75112851115101e+00
3.97661873813923e+00
1.41443447314859e+01
4.45703622415733e+00
9.23980096468772e+00
3.07624884270368e+00
4.06771202714459e+00
1.49904999550219e+01
4.16359071163158e+00
1.09014488833650e+01
4.10121178109032e+00
2.62116557553633e+00
5.26191977990141e+00
4.18201060129371e+00
4.89399679929243e+00
5.17419753694782e+00
1.85785913546906e+01
2.25034906065688e+00
1.71380068294599e+01
4.85173143269975e+00
3.28979243238158e+00
6.59362763357460e+00
3.55186062551803e+00
1.33978961702878e+01
3.77450649272092e+00
6.88060455106308e+00
7.90867952186767e+00
5.35505302342469e+00
7.16962971867014e+00
1.97285393361058e+01
1.34659341202132e+01
4.57947874934403e+00
4.81850722491657e+00
5.11528461262966e+00
7.12847046769754e+00
1.60866550249622e+01
1.34381050418608e+01
3.23528834895956e+00
3.89169189947313e+00
4.45852985665332e+00
1.11437318107330e+01
2.23393524537584e+01
7.82880800223586e+00
3.04377735162236e+00
1.30054172718843e+00
1.90063256218888e+01
1.04458742014170e+00
2.10408054932576e+01
3.56928277175989e+00
2.20046972568253e+01
1.15384572309562e+00
3.81365606147143e+00
5.21392503536011e+00
4.23423692576628e+00
8.39802968162770e+00
1.47974784325987e+01
5.06074195687696e+00
1.02619659694603e+00
1.12039882101906e+01
2.27785354663752e+01
5.92679119286382e+00
2.29876952907071e+00
1.07519577424794e+00
4.84085363031024e+00
2.24497360261150e+00
2.13005481757541e+01
4.37899039953431e+00
2.07687164595528e+01
1.06413886399969e+00
7.40085239653283e+00
5.30656102017491e+00
4.78767050973118e+00
5.15079019507780e+00
4.58725870717062e+00
1.93008510679769e+00
1.94810638535234e+01
4.47232657979806e+00
1.68193686404553e+00
1.09808087806478e+00
1.31234075142406e+01
4.38319851988414e+00
3.10290953671572e+00
1.71275029331806e+01
1.13571624755093e+00
1.79201529511390e+00
2.05852332875608e+00
6.95161255641837e+00
7.07542216165950e+00
2.82522793862655e+00
3.65055542262329e+00
5.58248462543643e+00
1.07718132148660e+01
5.29400232427257e+00
4.03587365842808e+00
7.77610447052560e+00
4.41569748504108e+00
9.64685079199137e+00
2.18102095096150e+00
2.43761914940336e+00
4.09798466507524e+00
5.73520537050569e+00
4.21086994176969e+00
6.19987399719751e+00
1.91983884045792e+00
6.22502925367316e+00
5.11360945866120e+00
3.69924953189910e+00
1.08045394714372e+01
3.26932886822018e+00
6.15946286616539e+00
5.47585840489009e+00
1.06495251700018e+01
5.29012398882994e+00
4.35672512549566e+00
6.35556147136974e+00
7.24495752479271e+00
8.99385647141148e+00
4.95410382102664e+00
3.90471153695347e+00
1.54109368176798e+00
3.49992347531886e+00
4.55876358292871e+00
7.04940813356977e+00
1.65357639050696e+00
3.73325932884866e+00
5.53195625201158e+00
1.49588166506092e+00
1.17471710456547e+01
5.99379079102163e+00
5.45382056044740e+00
7.69018148305980e+00
7.24845504050561e+00
2.27944957347257e+00
3.57835851459682e+00
6.14626662930306e+00
5.65110074752313e+00
7.49823962641445e+00
3.28048849568615e+00
3.98436378561635e+00
6.32937550501045e+00
1.60142813654956e+00
4.14858741119254e+00
2.80281959788320e+00
7.60820583503203e+00
2.98187878274222e+00
6.55535472663310e+00
5.85138724408935e+00
7.38808977260776e+00
1.96791098651251e+00
7.24536206063003e+00
3.01026741521618e+00
3.90350022128837e+00
5.33579710003152e+00
6.24700940498742e+00
6.10827606617580e+00
2.34786963329956e+00
4.89396062677324e+00
2.51351846910227e+00
4.60407868863216e+00
1.67903176818383e+00
1.05854288276199e+01
1.59721909758952e+00
4.29209341201008e+00
2.49150424985447e+00
6.33151814666055e+00
4.01869191685980e+00
2.42896618470967e+00
3.99834591563544e+00
5.92774282279918e+00
5.45140970571613e+00
6.73599388018633e+00
4.93193462496662e+00
2.48645502712745e+00
5.73009194761070e+00
1.18789550579088e+00
5.31523245264704e+00
8.14942631418363e+00
5.78654608352818e+00
5.59364407756651e+00
1.20707887920429e+00
6.21316319372822e+00
2.27419660511729e+00
2.62721666086483e+00
7.02590242315692e+00
5.77868909477983e+00
7.36514096539136e+00
1.25325090385486e+00
2.03369163866984e+00
3.50804441030478e+00
7.28915752411829e+00
6.54838399670193e+00
1.99230350443313e+00
1.99896854902797e+00
1.85103076320239e+00
9.83266227317350e+00
4.57355540141851e+00
6.10695236497387e+00
1.73409960050264e+00
1.70492951069653e+00
1.89432102163116e+00
6.16310463967899e+00
2.14420859631042e+00
5.26673992961157e+00
8.68742954686231e+00
1.58835895853733e+00
1.55081649704911e+00
7.06334835463741e+00
9.70769238547947e+00
3.73402546364368e+00
1.54110173144100e+00
6.63537383068380e+00
6.38460453564203e+00
6.20474215580182e+00
8.41197388375237e+00
5.33010397723937e+00
1.38765266858797e+00
1.55696820430244e+00
3.20739039199388e+00
7.20729978088356e+00
2.08047360208633e+00
1.23989196039808e+00
1.23897957569494e+00
6.30400874471932e+00
2.22942084170169e+00
5.24425365543621e+00
3.67314043576413e+00
5.62974321305826e+00
1.10853659997263e+01
3.45885092681184e+00
7.62199530480516e+00
1.06802582905175e+00
6.58004619838573e+00
2.22259888367054e+00
3.45661824985047e+00
7.47129903571729e+00
1.29042511404212e+00
3.08352943977738e+00
4.88805003289975e+00
1.25368829340434e+00
3.58255105812973e+00
2.81919737190403e+00