def __init__(self, pps_dir, eval_dir, model_dir, params, draw_eigen_function_plot=True, compare_against_spdmd=False):

        self.pps_dir = pps_dir
        self.eval_dir = eval_dir
        self.model_dir = model_dir
        mkdir(self.pps_dir)
        self.params = params
        self.type = None
        self.dt = None
        self.index_selected_in_full = None
        self.draw_eigen_function_plot = draw_eigen_function_plot
        self.compare_against_spdmd = compare_against_spdmd
Пример #2
0
    def pps_sweep_alpha(self,
                        zoomed_X_Y_max=None,
                        case_specific_frequency_dict={'draw_st': False}):

        fig_data = np.load(self.eval_dir + '/MultiTaskElasticNet_result.npz')
        alphas_enet = fig_data['alphas_enet']
        coefs_enet_comp = fig_data['coefs_enet_comp']

        # loop over all alpha
        for ii, alpha in enumerate(alphas_enet):
            print("current alpha = ", alpha, " index = ", ii)

            # 1 make directory
            alpha_dir_eval = self.eval_dir + '/sweep/sweep_alpha_' + str(alpha)
            alpha_dir = self.pps_dir + '/sweep_alpha_' + str(alpha)
            mkdir(alpha_dir)

            # 2 compute the index of selected modes
            non_zero_index_bool_array = np.linalg.norm(
                coefs_enet_comp[:, :, ii], axis=0) > 0
            further_selected_index_array = self.index_selected_in_full[
                non_zero_index_bool_array]

            print("number of non-zero coef = ",
                  len(further_selected_index_array))

            if len(further_selected_index_array) > 0:

                # 3 draw the eigenvalue selected plot
                self.pps_scatter_plot_eigenvalue(
                    index_selected_array=further_selected_index_array,
                    path_to_save=alpha_dir,
                    zoomed_X_Y_max=zoomed_X_Y_max,
                    case_specific_frequency_dict=case_specific_frequency_dict)

                # 4. load and draw trajectory comparison
                # load npz data from eval directory for parameter sweep
                fig_data = np.load(alpha_dir_eval + '/save_trj_comparison.npz')
                true_trajectory = fig_data['ttrj']
                pred_trajectory = fig_data['ptrj']
                true_tsnap = fig_data['tt']
                self.pps_plot_trajectory_given_pred(
                    true_tsnap=true_tsnap,
                    pred_trajectory=pred_trajectory,
                    true_trajectory=true_trajectory,
                    path_to_save_fig=alpha_dir)
                # 5. load and draw eigenfunction plot
                if self.draw_eigen_function_plot:
                    self.plot_eigenfunction_given_index_and_path(
                        index_of_eigens=further_selected_index_array,
                        save_path=alpha_dir)
        return
Пример #3
0
 def makedir(dir):
     mkdir(dir)
Пример #4
0
    def make_case_dir(self):
        """Create directory for cases"""

        mkdir(directory=self.dir)
        mkdir(directory=self.sub_dir)