main.py 4.03 KB
Newer Older
felikskiszkurno's avatar
felikskiszkurno committed
1
2
3
4
5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan  8 10:29:00 2021

felikskiszkurno's avatar
felikskiszkurno committed
6
@author: Feliks Kiszkurno
felikskiszkurno's avatar
felikskiszkurno committed
7
8
"""

felikskiszkurno's avatar
felikskiszkurno committed
9
import slopestabilitytools.datamanagement
felikskiszkurno's avatar
felikskiszkurno committed
10
11
import slopestabilityML
import slostabcreatedata
12
13
import numpy as np
import settings
felikskiszkurno's avatar
felikskiszkurno committed
14

15
settings.init()
felikskiszkurno's avatar
felikskiszkurno committed
16

felikskiszkurno's avatar
felikskiszkurno committed
17
# Config
18
19
create_new_data = True
create_new_data_only = True
felikskiszkurno's avatar
felikskiszkurno committed
20

felikskiszkurno's avatar
felikskiszkurno committed
21
22
23
24
25
if not create_new_data:

    test_results = slopestabilitytools.datamanagement.import_tests()

else:
felikskiszkurno's avatar
felikskiszkurno committed
26

27
28
29
    # Prepare folder structure for output
    is_success = slopestabilitytools.folder_structure.create_folder_structure()

felikskiszkurno's avatar
felikskiszkurno committed
30
    # TODO Put this part into a function
felikskiszkurno's avatar
felikskiszkurno committed
31

felikskiszkurno's avatar
felikskiszkurno committed
32
    # Settings
33
    number_of_tests = 5
felikskiszkurno's avatar
felikskiszkurno committed
34
    rho_spread_factor = 1.5
felikskiszkurno's avatar
felikskiszkurno committed
35
    rho_max = 20
felikskiszkurno's avatar
felikskiszkurno committed
36
    layers_min = 1
37
    layers_max = 2
felikskiszkurno's avatar
felikskiszkurno committed
38
    min_depth = 4
39
    max_depth = 8
felikskiszkurno's avatar
felikskiszkurno committed
40

felikskiszkurno's avatar
felikskiszkurno committed
41
    # Generate parameters for tests
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    # tests_horizontal = slopestabilitytools.model_params(number_of_tests,
    #                                                     rho_spread_factor, rho_max,
    #                                                     layers_min, layers_max,
    #                                                     min_depth, max_depth)

    tests_horizontal = {'hor_01': {'layer_n': 1, 'rho_values': [[1, 5], [2, 15]], 'layers_pos': np.array([-5])},
                        'hor_02': {'layer_n': 1, 'rho_values': [[1, 5], [2, 50]], 'layers_pos': np.array([-5])},
                        'hor_03': {'layer_n': 1, 'rho_values': [[1, 15], [2, 20]], 'layers_pos': np.array([-8])},
                        'hor_04': {'layer_n': 1, 'rho_values': [[1, 5], [2, 10]], '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])},}
felikskiszkurno's avatar
felikskiszkurno committed
70

felikskiszkurno's avatar
felikskiszkurno committed
71
72
    #  Create models and invert them
    test_results = {}
felikskiszkurno's avatar
felikskiszkurno committed
73

felikskiszkurno's avatar
felikskiszkurno committed
74
    for test_name in tests_horizontal.keys():
75
76
77
        test_result_curr, test_rho_max, test_rho_min = slostabcreatedata.create_data(test_name,
                                                                                     tests_horizontal[test_name],
                                                                                     max_depth)
felikskiszkurno's avatar
felikskiszkurno committed
78
79
        test_results.update({test_name: test_result_curr})
        del test_result_curr
felikskiszkurno's avatar
felikskiszkurno committed
80

felikskiszkurno's avatar
felikskiszkurno committed
81
        # Plot and save figures
82
83
        slopestabilitytools.plot_and_save(test_name, test_results[test_name], 'Test: ' + test_name, test_rho_max,
                                          test_rho_min)
felikskiszkurno's avatar
felikskiszkurno committed
84

85
if not create_new_data_only:
86

87
    print('Running ML stuff...')
88
    ml_results = slopestabilityML.run_all_tests(test_results)
89

90
elif create_new_data_only:
91

92
    print('Done')