import os from eiler_SA.forwardmodeling_sa import make_params_dict, write_params_file chloe_model_params = '/home/gabriel/PycharmProjects/FastGrainBoundary-DiffusionSolver/sensitivity_analysis/original_eiler/Eiler94_Amphibolite.txt' output = os.path.split(chloe_model_params)[0] output = os.path.join(output, 'mode_length_temp') fwd_model_parameters = make_params_dict(chloe_model_params) print(fwd_model_parameters) # # # TODO - first change the parameters of the plag vs hornblende modalities print(fwd_model_parameters['Min1-Mode']) # 0.3 - base case plag_mode_key = 'Min1-Mode' plagioclase_mode = float(fwd_model_parameters[plag_mode_key]) plagioclase_mode_start = 0.1 # 0.6 - base case hornb_mode_key = 'Min2-Mode' hornblende_mode = float(fwd_model_parameters[hornb_mode_key]) hornblende_mode_start = 0.8 plag_length_key = 'Min1-W' plag_length = float(fwd_model_parameters[plag_length_key]) plag_length_start = 200.0 horn_length_key = 'Min2-R' horn_length = float(fwd_model_parameters[horn_length_key])
# root = '/home/gabriel/Documents/Euler_SA/euler_modality' # root = '/home/gabriel/Documents/FGB_model/JohnEiler/modality_SF/' root = '/home/gabriel/PycharmProjects/FastGrainBoundary-DiffusionSolver/sensitivity_analysis/mode_length_chloe_cooling/blockD/' outroot = '/home/gabriel/PycharmProjects/FastGrainBoundary-DiffusionSolver/sensitivity_analysis/modality/modality_len_results_fwd/blockD/' if not os.path.exists(outroot): os.mkdir(outroot) # root = '/home/gabriel/PycharmProjects/FastGrainBoundary-DiffusionSolver/sensitivity_analysis/mode_length_configs/' # outroot = '/home/gabriel/PycharmProjects/FastGrainBoundary-DiffusionSolver/sensitivity_analysis/modality/modality_fwd_results/' # root = '/home/gabriel/PycharmProjects/FastGrainBoundary-DiffusionSolver/sensitivity_analysis/mode_length_configs/' for dir in os.listdir(root): print('dir', dir) param_path = os.path.join(root, dir) print('path', param_path) save_name = dir.split('.')[0] fwd_model_params = make_params_dict(params=param_path) print('running the slow model with a cooling file') xresult, yresult, timeresult = forward_model_slow_bulk( fwd_model_params, coolfile=True) # print('running the slow model with no cooling file') # xresult, yresult, timeresult = forward_model_slow_bulk(fwd_model_params) # Save each array as a .npy file save(os.path.join(outroot, '{}_x.npy'.format(save_name)), xresult) save(os.path.join(outroot, '{}_y.npy'.format(save_name)), yresult) save(os.path.join(outroot, '{}_time.npy'.format(save_name)), timeresult)
# year in MA we want to see year_ma = 44 time_step = 0.0005 # convert the year into the index for the y array. Subtract one bc the y array starts at index 0 year_index = int(round(((year_ma / time_step) - 1), 1)) print('year index {}'.format(year_index)) x_path = os.path.join(root, 'Eiler94_Amphibolite_x.npy') y_path = os.path.join(root, 'Eiler94_Amphibolite_y.npy') time_path = os.path.join(root, 'Eiler94_Amphibolite_time.npy') param_path = os.path.join(root, 'Eiler94_Amphibolite.txt') param_dict = make_params_dict(param_path) x_arr = np.load(x_path) y_arr = np.load(y_path) t_arr = np.load(time_path) print('x shape: {}, y shape {}, t shape {}'.format(x_arr.shape, y_arr.shape, t_arr.shape)) # quartz plt.plot(x_arr[:, 0], y_arr[0, year_index, :]) #plt.show() # TODO - construct inverse thingy # 1) Start with a known time-temp history - in our case linear