Commit 037fb6d5 authored by Feliks Kiszkurno's avatar Feliks Kiszkurno
Browse files

Bug fixes

parent 55f4c496
......@@ -19,13 +19,12 @@ import test_definitions
settings.init()
# Config
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
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
reassign_classes = False; class_type = 'norm'
param_path = os.path.abspath(os.path.join(os.getcwd()) + '/' + 'TestDefinitions/multilayer_1_2_3_4.csv')
param_path = os.path.abspath(os.path.join(os.getcwd()) + '/' + 'TestDefinitions/hor_1layer_varying_depth_lambda_zweight_ergänzung.csv')
test_definitions.init(path=param_path)
test_definitions.init(path=param_path)
# Load existing data instead of creating new one.
print('start')
if not create_new_data:
......
......@@ -27,6 +27,9 @@ def init():
# Include depth
settings['depth'] = True # True - include depth, False - ignore depth
# Classifiers
settings['optimize_ml'] = True
# Paths
settings['results_folder'] = 'results'
settings['data_folder'] = settings['results_folder'] + '/data/'
......
......@@ -90,6 +90,43 @@ def run_classification(test_training, test_prediction, test_results, clf, clf_na
y_pred_grid = gridded_data['class']
depth_all = np.zeros(y_pred_grid.shape[0])
depth_all_correct = np.ones(y_pred_grid.shape[0]) * test_definitions.test_parameters[name]['layers_pos'][0]
result_grid_rolled = np.roll(y_pred_grid, -1, axis=0)
y_pred_grid_deri = y_pred_grid - result_grid_rolled
y_pred_grid_deri[-1, :] = 0
# interface_id = []
# interface_n = []
# interface_depth = []
# for column in y_pred_grid_deri.T:
# indexes = list(np.where(column != 0))
# if indexes[0].size == 1: # Only one interface detected
# print('a')
# interface_n.append(len(indexes[0]))
# interface_id.append(indexes)
# interface_depth.append(yi[indexes])
# else: # Multiple potential interfaces detected
# print('b')
# indexes_temp = []
# depths_temp = []
# indexes_copy = indexes
# all_too_thin_layers_removed = False
# while all_too_thin_layers_removed is False:
# all_too_thin_layers_removed = True
# if isinstance(indexes_copy[0], int) is False:
# for index_id in range(indexes_copy[0].size-1):
# diff = yi[indexes[0][index_id+1]] - yi[indexes[0][index_id]]
# if abs(diff) <= 1:
# indexes_temp.append(int(round((indexes[0][index_id+1]+indexes[0][index_id])/2)))
# all_too_thin_layers_removed = False
# else:
# indexes_temp.append(indexes[0][index_id])
# if abs(yi[indexes[0][-1]] - yi[indexes[0][-2]]) >= 1:
# indexes_temp.append(indexes[0][-1])
# indexes_copy = indexes_temp
# indexes_temp = []
# interface_n.append(len(indexes_copy))
# interface_id.append(indexes_copy)
# interface_depth.append(yi[indexes_copy])
# interface_number = np.bincount(interface_n).argmax()
for column_id in range(y_pred_grid.shape[0]):
# if len(np.unique(y_pred_grid[:,column_id])) is not 2:
depth_id = np.array(np.where(y_pred_grid[:, column_id] == 4))
......
......@@ -52,7 +52,7 @@ def plot_and_save(test_name, test_result, plot_title, rho_max, rho_min):
# TODO: Move plotting to a function for plotting a, b and a-b
cb = []
fig, _ax = plt.subplots(nrows=3, ncols=1)
fig, _ax = plt.subplots(nrows=2, ncols=2)
ax = _ax.flatten()
fig.suptitle(plot_title)
......@@ -85,25 +85,34 @@ def plot_and_save(test_name, test_result, plot_title, rho_max, rho_min):
cb[2].locator = tick_locator
cb[2].update_ticks()
fig.tight_layout()
slopestabilitytools.save_plot(fig, test_name, '_in_inv_diff')
# Plot coverage
cb_cov = []
fig_cov, ax_cov = plt.subplots(nrows=1, ncols=1)
fig.suptitle(plot_title+' coverage')
im0 = ax_cov.scatter(x, y, c=sen)
#im0 = ax_cov.contourf(xi, yi, cov_i)
ax_cov.set_title(plot_title+' coverage')
ax_cov = slopestabilitytools.set_labels(ax_cov)
cb_cov = plt.colorbar(im0, ax=ax_cov, label='Coverage') # , shrink=0.9)
im3 = ax[3].scatter(x, y, c=sen)
# im0 = ax_cov.contourf(xi, yi, cov_i)
ax[3].set_title(plot_title + ' coverage')
ax[3] = slopestabilitytools.set_labels(ax[3])
cb_cov = plt.colorbar(im3, ax=ax[3], label='Coverage') # , shrink=0.9)
tick_locator = ticker.MaxNLocator(nbins=4)
cb_cov.locator = tick_locator
cb_cov.update_ticks()
fig_cov.tight_layout()
slopestabilitytools.save_plot(fig_cov, test_name, '_cov')
fig.tight_layout()
slopestabilitytools.save_plot(fig, test_name, '_in_inv_diff')
# Plot coverage
# cb_cov = []
# fig_cov, ax_cov = plt.subplots(nrows=1, ncols=1)
#
# fig.suptitle(plot_title+' coverage')
#
# im0 = ax_cov.scatter(x, y, c=sen)
# #im0 = ax_cov.contourf(xi, yi, cov_i)
# ax_cov.set_title(plot_title+' coverage')
# ax_cov = slopestabilitytools.set_labels(ax_cov)
# cb_cov = plt.colorbar(im0, ax=ax_cov, label='Coverage') # , shrink=0.9)
# tick_locator = ticker.MaxNLocator(nbins=4)
# cb_cov.locator = tick_locator
# cb_cov.update_ticks()
#
# fig_cov.tight_layout()
# slopestabilitytools.save_plot(fig_cov, test_name, '_cov')
return
......@@ -98,7 +98,7 @@ def create_data(test_name, test_config, max_depth, *, lambda_param=20, z_weight=
array_max = np.max(input_model2_array)
array_min = np.min(input_model2_array)
result_array = slostabcreatedata.clip_data(result_array, array_max, array_min)
input_model2_array_norm = np.log(input_model2_array)
input_model2_array_norm = np.log10(input_model2_array)
# input_model2_array_norm = slopestabilitytools.normalize(input_model2_array)
fig_input, ax_input = plt.subplots(1)
......@@ -135,7 +135,7 @@ def create_data(test_name, test_config, max_depth, *, lambda_param=20, z_weight=
rho_max = np.max(rho_arr)
rho_min = np.min(rho_arr)
result_array_norm = np.log(result_array)
result_array_norm = np.log10(result_array)
# result_array_norm = slopestabilitytools.normalize(result_array)
labels_translator = {0: 'Very Low',
......
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