diff --git a/examples/fromADCIRCMap/Q_1D_parallel.py b/examples/fromADCIRCMap/Q_1D_parallel.py deleted file mode 100644 index 229c6bd0..00000000 --- a/examples/fromADCIRCMap/Q_1D_parallel.py +++ /dev/null @@ -1,103 +0,0 @@ -import bet.calculateP.calculateP as calcP -import bet.calculateP.simpleFunP as sfun -import numpy as np -import scipy.io as sio -from bet.Comm import rank -import bet.util as util - -# Import "Truth" -mdat = sio.loadmat('Q_2D') -Q = mdat['Q'] -Q_ref = mdat['Q_true'] - -# Import Data -samples = mdat['points'].transpose() -lam_domain = np.array([[0.07, .15], [0.1, 0.2]]) - -print "Finished loading data" - -def postprocess(station_nums, ref_num): - - filename = 'P_q'+str(station_nums[0]+1)+'_q' - if len(station_nums) == 3: - filename += '_q'+str(station_nums[2]+1) - filename += '_ref_'+str(ref_num+1) - - data = Q[:, station_nums] - q_ref = Q_ref[ref_num, station_nums] - - # Create Simple function approximation - # Save points used to parition D for simple function approximation and the - # approximation itself (this can be used to make close comparisions...) - (rho_D_M, d_distr_samples, d_Tree) = sfun.uniform_hyperrectangle(data, - q_ref, bin_ratio=0.15, - center_pts_per_edge=np.ones((data.shape[1],))) - - # Calclate P on the actual samples with assumption that voronoi cells have - # equal size - (P1, lam_vol1, io_ptr1) = calcP.prob(samples, data, - rho_D_M, d_distr_samples, d_Tree) - if rank == 0: - print "Consolidating prob" - mdict = dict() - mdict['P1'] = util.get_global_values(P1) - mdict['lam_vol1'] = lam_vol1 - mdict['lem1'] = samples - mdict['io_ptr1'] = io_ptr1 - # Export P - sio.savemat(filename, mdict, do_compression=True) - - """ - num_l_emulate = 1e4 - lambda_emulate = calcP.emulate_iid_lebesgue(lam_domain, num_l_emulate) - print "Finished emulating lambda samples" - - if rank == 0: - mdict['rho_D_M'] = rho_D_M - mdict['d_distr_samples'] = d_distr_samples - mdict['num_l_emulate'] = num_l_emulate - # Export P - sio.savemat(filename, mdict, do_compression=True) - """ - """ - # Calculate P on lambda emulate - (P0, lem0, io_ptr0, emulate_ptr0) = calcP.prob_emulated(samples, data, - rho_D_M, d_distr_samples, lambda_emulate, d_Tree) - - if rank == 0: - print "Consolidating prob_emulated" - mdict['P0'] = util.get_global_values(P0) - mdict['lem0'] = lem0 - mdict['io_ptr0'] = io_ptr0 - mdict['emulate_ptr0'] = emulate_ptr0 - # Export P - sio.savemat(filename, mdict, do_compression=True) - """ - """ - # Calculate P on the actual samples estimating voronoi cell volume with MC - # integration - (P3, lam_vol3, lambda_emulate3, io_ptr3, emulate_ptr3) = calcP.prob_mc(samples, - data, rho_D_M, d_distr_samples, lambda_emulate, d_Tree) - if rank == 0: - print "Consolidating prob_mc" - mdict['P3'] = util.get_global_values(P3) - mdict['lam_vol3'] = lam_vol3 - mdict['io_ptr3'] = io_ptr3 - mdict['emulate_ptr3'] = emulate_ptr3 - # Export P - sio.savemat(filename, mdict, do_compression=True) - """ - -# Post-process and save P and emulated points -ref_nums = [6, 11, 15] # 7, 12, 16 -stations = [1, 4, 5] # 2, 5, 6 - -ref_nums, stations = np.meshgrid(ref_nums, stations) -ref_nums = ref_nums.ravel() -stations = stations.ravel() - -postprocess([0],11) - -#for tnum, stat in zip(ref_nums, stations): -# postprocess([0], tnum) - diff --git a/examples/fromADCIRCMap/Q_3D_parallel.py b/examples/fromADCIRCMap/Q_3D_parallel.py deleted file mode 100644 index cc3bd407..00000000 --- a/examples/fromADCIRCMap/Q_3D_parallel.py +++ /dev/null @@ -1,85 +0,0 @@ -import bet.calculateP.calculateP as calcP -import bet.calculateP.simpleFunP as sfun -import numpy as np -import scipy.io as sio -from bet import util - -from bet.Comm import comm, rank - -# Import "Truth" -mdat = sio.loadmat('Q_3D') -Q = mdat['Q'] -Q_ref = mdat['Q_true'] - -# Import Data -samples = mdat['points'].transpose() -lam_domain = np.array([[-900, 1200], [0.07, .15], [0.1, 0.2]]) - -print "Finished loading data" - -def postprocess(station_nums, ref_num): - - filename = 'P_q'+str(station_nums[0]+1)+'_q'+str(station_nums[1]+1) - if len(station_nums) == 3: - filename += '_q'+str(station_nums[2]+1) - filename += '_ref_'+str(ref_num+1) - - data = Q[:, station_nums] - q_ref = Q_ref[ref_num, station_nums] - - # Create Simple function approximation - # Save points used to parition D for simple function approximation and the - # approximation itself (this can be used to make close comparisions...) - (rho_D_M, d_distr_samples, d_Tree) = sfun.uniform_hyperrectangle(data, - q_ref, bin_ratio=0.15, - center_pts_per_edge=np.ones((data.shape[1],))) - - num_l_emulate = 1e6 - lambda_emulate = calcP.emulate_iid_lebesgue(lam_domain, num_l_emulate) - print "Finished emulating lambda samples" - - # Calculate P on the actual samples estimating voronoi cell volume with MC - # integration - print "Calculating prob_mc" - (P3, lam_vol3, lambda_emulate3, io_ptr3, emulate_ptr3) = calcP.prob_mc(samples, - data, rho_D_M, d_distr_samples, lambda_emulate, d_Tree) - - if rank == 0: - mdict = dict() - mdict['rho_D_M'] = rho_D_M - mdict['d_distr_samples'] = d_distr_samples - mdict['lambda_emulate'] = util.get_global_values(lambda_emulate) - mdict['num_l_emulate'] = mdict['lambda_emulate'].shape[1] - mdict['P3'] = util.get_global_values(P3) - mdict['lam_vol3'] = lam_vol3 - mdict['io_ptr3'] = io_ptr3 - mdict['emulate_ptr3'] = emulate_ptr3 - print "Exporting P" - # Export P - sio.savemat(filename, mdict, do_compression=True) - -# Post-process and save P and emulated points -ref_num = 14 - -# q1, q5, q2 ref 15 -station_nums = [0, 4, 1] # 1, 5, 2 -postprocess(station_nums, ref_num) - -""" -# q1, q5 ref 15 -station_nums = [0, 4] # 1, 5 -postprocess(station_nums, ref_num) - -# q1, q5, q12 ref 16 -station_nums = [0, 4, 11] # 1, 5, 12 -postprocess(station_nums, ref_num) - - -station_nums = [0, 8, 6] # 1, 5, 12 -postprocess(station_nums, ref_num) - - -station_nums = [0, 8, 11] # 1, 5, 12 -postprocess(station_nums, ref_num) -""" - diff --git a/examples/fromADCIRCMap/Q_3D_serial.py b/examples/fromADCIRCMap/Q_3D_serial.py index 4840c815..29f15cad 100644 --- a/examples/fromADCIRCMap/Q_3D_serial.py +++ b/examples/fromADCIRCMap/Q_3D_serial.py @@ -36,14 +36,13 @@ def postprocess(station_nums, ref_num): # Calclate P on the actual samples with assumption that voronoi cells have # equal size - (P1, lam_vol1, io_ptr1, emulate_ptr1) = calcP.prob(samples, data, - rho_D_M, d_distr_samples, d_Tree) + (P1, lam_vol1, io_ptr1) = calcP.prob(samples, data, rho_D_M, + d_distr_samples, d_Tree) print "Calculating prob" mdict['P1'] = P1 mdict['lam_vol1'] = lam_vol1 mdict['lem1'] = samples mdict['io_ptr1'] = io_ptr1 - mdict['emulate_ptr1'] = emulate_ptr1 # Export P and compare to MATLAB solution visually sio.savemat(filename, mdict, do_compression=True) @@ -55,6 +54,7 @@ def postprocess(station_nums, ref_num): station_nums = [0, 4, 1] # 1, 5, 2 postprocess(station_nums, ref_num) +""" # q1, q5 ref 15 station_nums = [0, 4] # 1, 5 postprocess(station_nums, ref_num) @@ -71,5 +71,5 @@ def postprocess(station_nums, ref_num): station_nums = [0, 8, 11] # 1, 5, 12 postprocess(station_nums, ref_num) - +"""