def get_nu_1st_2nd(self): import pandas as pd filename = './fom/nus_mom.csv' fom = pd.read_csv(filename).to_numpy() # For now, grep proj and rom relerr at the same time if self.info['init'] == 'zero': self.info['J0'] = mypostpro.find_nearest(self.outputs['t'][0, :], 501) elif self.info['init'] == 'ic': self.info['J0'] = 0 files_dict = self.cdict('nu') nbs = [] ms = [] sds = [] merr = [] verr = [] sderr = [] for nb, fnames in files_dict.items(): for fname in fnames: nuss = mypostpro.read_nuss(fname) nuss[:, 2] = nuss[:, 2] / 40 avgidx1 = mypostpro.find_nearest(nuss[:, 1], int(self.info['J0'])) rom_mean = mypostpro.cmean(nuss[avgidx1:-1, :], 2) rom_var = mypostpro.cvar(nuss[avgidx1:-1, :], rom_mean, 2) rom_sd = mypostpro.csd(nuss[avgidx1:-1, :], rom_mean, 2) [mean_err, var_err, sd_err] = mypostpro.cnuss_err(fom[0][0], fom[0][1], fom[0][1], rom_mean, rom_var, rom_sd) merr.append(mean_err) verr.append(var_err) sderr.append(sd_err) nbs.append(int(nb)) ms.append(rom_mean) sds.append(rom_sd) self.nbs, self.nus_ms, self.nus_sds, self.mnuserr, self.stdnuserr = [ list(tuple) for tuple in zip(*sorted(zip(nbs, ms, sds, merr, sderr))) ] return
color_ctr = 0 i = 0 tpath = './nu/' fig, ax = plt.subplots(1, tight_layout=True) # get the FOM data filename = '../../../../fom_nuss/nuss_fom_'+str(int(anchor)) data = mypostpro.read_nuss(filename) data[:, 2] = data[:, 2]/40 idx1 = mypostpro.find_nearest(data[:, 0], 0) idx2 = mypostpro.find_nearest(data[:, 0], 1000) avgidx1 = mypostpro.find_nearest(data[:, 0], 501) nuss_fom = data[avgidx1:idx2, :] fom_mean = mypostpro.cmean(nuss_fom[:idx2], 2) fom_var = mypostpro.cvar(nuss_fom[:idx2], fom_mean, 2) fom_sd = mypostpro.csd(nuss_fom[:idx2], fom_mean, 2) print('FOM data at deg '+str(int(anchor-90)), fom_mean, fom_var, fom_sd) ax.plot(nuss_fom[:, 0], nuss_fom[:, 2], 'k-', mfc="None", label=r'FOM') for nb, fnames in dict_final: for fname in fnames: forleg = fname.split('_') deg = int(forleg[-2]) match_rom = re.match('^.*_(.*)rom_.*$', fname) assert match_rom is not None
m_all = np.array(m_his) sderr_all = np.array(sderr_his) sd_all = np.array(sd_his) fom_m_list = [] fom_sd_list = [] for i, test in enumerate(P_test): filename = '../../../fom_nuss/nuss_fom_'+str(test) data = mypostpro.read_nuss(filename) data[:, 2] = data[:, 2]/40 idx1 = mypostpro.find_nearest(data[:, 0], 0) idx2 = mypostpro.find_nearest(data[:, 0], 1000) nuss_fom = data[idx1:idx2, :] avgidx1 = mypostpro.find_nearest(data[:, 0], 501) fom_mean = mypostpro.cmean(nuss_fom[avgidx1:idx2], 2) fom_var = mypostpro.cvar(nuss_fom[avgidx1:idx2], fom_mean, 2) fom_sd = mypostpro.csd(nuss_fom[avgidx1:idx2], fom_mean, 2) fom_m_list.append(fom_mean) fom_sd_list.append(fom_sd) fig1, ax1 = plt.subplots(1, tight_layout=True) fig2, ax2 = plt.subplots(1, tight_layout=True) fig3, ax3 = plt.subplots(1, tight_layout=True) fig4, ax4 = plt.subplots(1, tight_layout=True) for i, train, in enumerate(P_train): qoi_params = {'c': colors[i], 'marker': 'o', 'mfc': 'None', 'linestyle': '--', 'label': r'\textit{it} = '+str(i+1)} ax1.semilogy(angle, merr_all[i, :], **qoi_params)