Commit 37e72d8e authored by Feliks Kuba Kiszkurno's avatar Feliks Kuba Kiszkurno
Browse files

Separate some functions

Moved some legend_without_duplicate_labels and match_time_step to separate files. Modified ogs_compare accordingly.
parent be5addea
import matplotlib.pyplot as plt
def legend_without_duplicate_labels(
figure): # modified Julien Jm @ https://stackoverflow.com/questions/19385639/duplicate-items-in-legend-in-matplotlib
handles, labels = plt.gca().get_legend_handles_labels()
by_label = dict(zip(labels, handles))
figure.legend(by_label.values(), by_label.keys(), loc='lower center', ncol=4)
\ No newline at end of file
import numpy as np
def match_time_step(time_steps, obs_time_step):
# Warning: assumes all time steps are unique and that there will be only one index
# returned by np.argmin
time_steps = np.array(time_steps)
time_steps_ref = obs_time_step * np.ones_like(time_steps)
time_diff = np.abs(time_steps_ref - time_steps)
return np.argmin(time_diff)
......@@ -10,17 +10,11 @@ import numpy as np
from ogs_compare.Tools.load_points import load_points
from ogs_compare.Tools.plot_points import plot_points
from ogs_compare.Tools.detect_experiments import detect_experiments, getfilesbyextension, extract_params
from ogs_compare.Tools.legend_without_duplicate_labels import legend_without_duplicate_labels
from AHM.models import heatsource
def legend_without_duplicate_labels(
figure): # modified Julien Jm @ https://stackoverflow.com/questions/19385639/duplicate-items-in-legend-in-matplotlib
handles, labels = plt.gca().get_legend_handles_labels()
by_label = dict(zip(labels, handles))
figure.legend(by_label.values(), by_label.keys(), loc='lower center', ncol=4)
# TODO: This should be removed and AHM package should be called directly
def get_analytica_model(parameter_name, x, y, z, t, ogs_model=None):
model = heatsource.ANASOL()
......@@ -112,15 +106,6 @@ def read_data(experiments_to_include, field_to_read, points, results_folder):
return experiments_results, experiments_results_param, point_names, time_steps
def match_time_step(time_steps, obs_time_step):
# Warning: assumes all time steps are unique and that there will be only one index
# returned by np.argmin
time_steps = np.array(time_steps)
time_steps_ref = obs_time_step * np.ones_like(time_steps)
time_diff = np.abs(time_steps_ref - time_steps)
return np.argmin(time_diff)
def ogs_compare_time_point(config_dict, results_folder, time_step,
analytical_ref=True, ogs_model=None):
SEC2A = 1 / (356 * 24 * 60 * 60) # time in seconds to time in years
......
Supports Markdown
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