def check_show_data(self, data, sample_nos, q_ref, save, qnums, showdim): """ Check to see that the :meth:`bet.postTools.plotDomains.show_data` ran without generating an error. """ try: if data.shape[1] == 4: plotDomains.show_data(data, self.rho_D, q_ref, sample_nos, save, False, qnums, showdim) else: plotDomains.show_data(data, None, q_ref, sample_nos, save, False, qnums, showdim) go = True except (RuntimeError, TypeError, NameError): print "ERROR" print data.shape print q_ref print sample_nos print save print qnums print showdim go = False nptest.assert_equal(go, True)
def rho_D(outputs): rho_left = np.repeat([Q_ref - .5 * bin_size], outputs.shape[0], 0) rho_right = np.repeat([Q_ref + .5 * bin_size], outputs.shape[0], 0) rho_left = np.all(np.greater_equal(outputs, rho_left), axis=1) rho_right = np.all(np.less_equal(outputs, rho_right), axis=1) inside = np.logical_and(rho_left, rho_right) max_values = np.repeat(maximum, outputs.shape[0], 0) return inside.astype('float64') * max_values # Read in points_ref and plot results p_ref = mdat['points_true'] p_ref = p_ref[5:7, 15] # Show the samples in the parameter space pDom.show_param(samples=points.transpose(), data=Q, rho_D=rho_D, p_ref=p_ref) # Show the corresponding samples in the data space pDom.show_data(data=Q, rho_D=rho_D, Q_ref=Q_ref) # Show the data domain that corresponds with the convex hull of samples in the # parameter space pDom.show_data_domain_2D(samples=points.transpose(), data=Q, Q_ref=Q_ref) # Show multiple data domains that correspond with the convex hull of samples in # the parameter space pDom.show_data_domain_multi(samples=points.transpose(), data=mdat['Q'], Q_ref=mdat['Q_true'][15], Q_nums=[1, 2, 5], showdim='all')
QoI_indices=[0,1,2,3] # Indices for output data with which you want to invert bin_ratio = 0.25 #ratio of length of data region to invert data = dataf[:,QoI_indices] Q_ref=Q_ref[QoI_indices] dmax = data.max(axis=0) dmin = data.min(axis=0) dscale = bin_ratio*(dmax-dmin) Qmax = Q_ref + 0.5*dscale Qmin = Q_ref -0.5*dscale def rho_D(x): return np.all(np.logical_and(np.greater(x,Qmin), np.less(x,Qmax)),axis=1) # Plot the data domain plotD.show_data(data, Q_ref = Q_ref, rho_D=rho_D, showdim=2) # Whether or not to use deterministic description of simple function approximation of # ouput probability deterministic_discretize_D = True if deterministic_discretize_D == True: (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.uniform_hyperrectangle(data=data, Q_ref=Q_ref, bin_ratio=bin_ratio, center_pts_per_edge = 1) else: (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.unif_unif(data=data, Q_ref=Q_ref, M=50, bin_ratio=bin_ratio, num_d_emulate=1E5)
data = dataf[:, QoI_indices] Q_ref = Q_ref[QoI_indices] dmax = data.max(axis=0) dmin = data.min(axis=0) dscale = bin_ratio * (dmax - dmin) Qmax = Q_ref + 0.5 * dscale Qmin = Q_ref - 0.5 * dscale def rho_D(x): return np.all(np.logical_and(np.greater(x, Qmin), np.less(x, Qmax)), axis=1) # Plot the data domain plotD.show_data(data, Q_ref=Q_ref, rho_D=rho_D, showdim=2) # Whether or not to use deterministic description of simple function approximation of # ouput probability deterministic_discretize_D = True if deterministic_discretize_D == True: (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.uniform_hyperrectangle( data=data, Q_ref=Q_ref, bin_ratio=bin_ratio, center_pts_per_edge=1 ) else: (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.unif_unif( data=data, Q_ref=Q_ref, M=50, bin_ratio=bin_ratio, num_d_emulate=1e5 ) # calculate probablities making Monte Carlo assumption (P, lam_vol, io_ptr) = calculateP.prob(
Q_ref = Q_ref[14, station_nums] # 15th/20 bin_ratio = 0.15 bin_size = (np.max(Q, 0)-np.min(Q, 0))*bin_ratio points = mdat['points'] # Create kernel maximum = 1/np.product(bin_size) def rho_D(outputs): rho_left = np.repeat([Q_ref-.5*bin_size], outputs.shape[0], 0) rho_right = np.repeat([Q_ref+.5*bin_size], outputs.shape[0], 0) rho_left = np.all(np.greater_equal(outputs, rho_left), axis=1) rho_right = np.all(np.less_equal(outputs, rho_right), axis=1) inside = np.logical_and(rho_left, rho_right) max_values = np.repeat(maximum, outputs.shape[0], 0) return inside.astype('float64')*max_values # Read in points_ref and plot results p_ref = mdat['points_true'] p_ref = p_ref[:, 14] # Show the samples in the parameter space pDom.show_param(samples=points.transpose(), data=Q, rho_D=rho_D, p_ref=p_ref) # Show the corresponding samples in the data space pDom.show_data(data=Q, rho_D=rho_D, Q_ref=Q_ref) # Show multiple data domains that correspond with the convex hull of samples in # the parameter space pDom.show_data_domain_multi(samples=points.transpose(), data=mdat['Q'], Q_ref=mdat['Q_true'][15], Q_nums=[1,2,5], showdim='all')