Commit 92903664 authored by Feliks Kiszkurno's avatar Feliks Kiszkurno
Browse files

Added option to read test configurations from csv file

parent db3ee5b0
/.~lock.tests_run.ods#
/.~lock*
......@@ -3,6 +3,7 @@
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/data" />
<excludeFolder url="file://$MODULE_DIR$/.idea/dataSources" />
</content>
<orderEntry type="jdk" jdkName="Python 3.7 (SlopeStability)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
......
,,,
NAME,LAYER_N,RHO,POS
Hor1_01,1,5,0
Hor1_01,1,15,-1
Hor1_02,1,5,0
Hor1_02,1,15,-2
Hor1_03,1,5,0
Hor1_03,1,15,-3
Hor1_04,1,5,0
Hor1_04,1,15,-4
Hor1_05,1,5,0
Hor1_05,1,15,-5
Hor1_06,1,5,0
Hor1_06,1,15,-6
Hor1_07,1,5,0
Hor1_07,1,15,-7
Hor1_08,1,5,0
Hor1_08,1,15,-8
Hor1_09,1,5,0
Hor1_09,1,15,-9
Hor1_10,1,5,0
Hor1_10,1,15,-10
......@@ -10,6 +10,7 @@ import slopestabilitytools.datamanagement
import slopestabilitytools
import slopestabilityML
import slostabcreatedata
import os.path
import numpy as np
import settings
import test_definitions
......@@ -17,8 +18,8 @@ import test_definitions
settings.init()
test_definitions.init()
# Config
create_new_data = False # set to True if you need to reassign the classes
create_new_data_only = False # set to False in order to run ML classifications
create_new_data = True # set to True if you need to reassign the classes
create_new_data_only = True # set to False in order to run ML classifications
reassign_classes = False; class_type = 'norm'
# Load existing data instead of creating new one.
......@@ -55,7 +56,8 @@ else:
# layers_min, layers_max,
# min_depth, max_depth)
tests_horizontal = test_definitions.test_definitions
#tests_horizontal = test_definitions.test_definitions
tests_horizontal = slostabcreatedata.read_test_parameters(os.path.abspath(os.path.join(os.getcwd()) + '/' + 'TestDefinitions/hor_1layer_varying_depth.csv'))
# tests_horizontal = {'hor_11': {'layer_n': 1, 'rho_values': [[1, 10], [2, 12]], 'layers_pos': np.array([-4])}}
......
{
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import os.path\n",
"import numpy as np\n",
"import slostabcreatedata"
]
},
{
"cell_type": "code",
"execution_count": 16,
"outputs": [],
"source": [
"params = pd.read_csv(os.path.abspath(os.path.join(os.getcwd(), os.pardir)) + '/' + 'TestDefinitions/hor_1layer_varying_depth.csv', header=1)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 18,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n",
"5\n",
"15\n"
]
}
],
"source": [
"test_definitions = {}\n",
"test_names = params['NAME'].unique()\n",
"\n",
"for name in test_names:\n",
" params_temp = params[params['NAME'] == name]\n",
" rho_list = []\n",
" position = []\n",
" layer_id = 1\n",
" for i, row in params_temp.iterrows():\n",
" rho_list.append([layer_id, row['RHO']])\n",
" layer_id += 1\n",
" if row['POS'] is not 0:\n",
" position = position.append(row['POS'])\n",
" print(row['RHO'])\n",
" test_definitions[name] = {'layer_n': row['LAYER_N'], 'rho_values': rho_list, 'layer_pos': np.array(position)}\n",
"\n",
"#'hor1_01': {'layer_n': 1, 'rho_values': [[1, 5], [2, 15]], 'layers_pos': np.array([-5])}"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
\ No newline at end of file
......@@ -9,4 +9,5 @@ Created on 15.01.2021
from .create_data import create_data
from .test_parameters import test_parameters
from .clip_data import clip_data
\ No newline at end of file
from .clip_data import clip_data
from .read_test_parameters import read_test_parameters
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 14.04.2021
@author: Feliks Kiszkurno
"""
import pandas as pd
import numpy as np
def read_test_parameters(path_to_file):
params = pd.read_csv(path_to_file, header=1)
test_definitions = {}
test_names = params['NAME'].unique()
for name in test_names:
params_temp = params[params['NAME'] == name]
rho_list = []
position = []
layer_id = 1
for i, row in params_temp.iterrows():
rho_list.append([layer_id, row['RHO']])
layer_id += 1
if row['POS'] is not 0:
position.append(row['POS'])
print(row['RHO'])
test_definitions[name] = {'layer_n': row['LAYER_N'], 'rho_values': rho_list, 'layers_pos': np.array(position)}
return test_definitions
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment