Example #1
0
 def check_show_data_domain_multi(self, ref_markers, ref_colors, Q_nums,
         showdim):
     """
     Check to see that the
     :meth:`bet.postTools.plotDomains.show_data_domain_multi` ran
     without generating an error.
     """
     Q_ref = self.data[[4, 2], :]
     try:
         plotDomains.show_data_domain_multi(self.samples, self.data,
                 Q_ref, Q_nums, ref_markers=ref_markers,
                 ref_colors=ref_colors, showdim=showdim)
         go = True
     except (RuntimeError, TypeError, NameError):
         go = False
     nptest.assert_equal(go, True)      
Example #2
0
 def check_show_data_domain_multi(self, ref_markers, ref_colors, Q_nums,
                                  showdim):
     """
     Check to see that the
     :meth:`bet.postTools.plotDomains.show_data_domain_multi` ran
     without generating an error.
     """
     Q_ref = self.disc._output_sample_set.get_values()[[4, 2], :]
     try:
         plotDomains.show_data_domain_multi(
             self.disc,
             Q_ref, Q_nums, ref_markers=ref_markers,
             ref_colors=ref_colors, showdim=showdim)
         go = True
     except (RuntimeError, TypeError, NameError):
         go = False
     nptest.assert_equal(go, True)
Example #3
0
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')
Example #4
0
# Create sampler
chain_length = 125
num_chains = 80
num_samples = chain_length*num_chains
sampler = asam.sampler(num_samples, chain_length, model)

# Set minima and maxima
lam_domain = np.array([[-900, 1500], [.07, .15], [.1, .2]])

# Get samples
inital_sample_type = "lhs"
(my_disc, all_step_ratios) = sampler.generalized_chains(lam_domain,
        transition_set, kernel_rD, sample_save_file, inital_sample_type)

# Read in points_ref and plot results
ref_sample = mdat['points_true']
ref_sample = ref_sample[:, 14]

# Show the samples in the parameter space
pDom.scatter_rhoD(my_disc, rho_D=rho_D, ref_sample=ref_sample, io_flag='input')
# Show the corresponding samples in the data space
pDom.scatter_rhoD(my_disc, rho_D=rho_D, ref_sample=Q_ref, io_flag='output')
# Show the data domain that corresponds with the convex hull of samples in the
# parameter space
pDom.show_data_domain_2D(my_disc, 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(my_disc, Q_ref=Q_ref, showdim='all')
Example #5
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
ref_sample = mdat['points_true']
ref_sample = ref_sample[:, 14]

# Create input, output, and discretization from data read from file
input_sample_set = sample.sample_set(points.shape[0])
input_sample_set.set_values(points.transpose())
input_sample_set.set_domain(param_domain)
output_sample_set = sample.sample_set(Q.shape[1])
output_sample_set.set_values(Q)
my_disc = sample.discretization(input_sample_set, output_sample_set)

# Show the samples in the parameter space
pDom.scatter_rhoD(my_disc, rho_D=rho_D, ref_sample=ref_sample, io_flag='input')
# Show the corresponding samples in the data space
pDom.scatter_rhoD(output_sample_set,
                  rho_D=rho_D,
                  ref_sample=Q_ref,
                  io_flag='output')

# Show multiple data domains that correspond with the convex hull of samples in
# the parameter space
pDom.show_data_domain_multi(my_disc, Q_ref=Q_ref, showdim='all')
Example #6
0
    return inside.astype('float64') * max_values


# Read in points_ref and plot results
ref_sample = mdat['points_true']
ref_sample = ref_sample[5:7, 15]

# Create input, output, and discretization from data read from file
points = mdat['points']
input_sample_set = sample.sample_set(points.shape[0])
input_sample_set.set_values(points.transpose())
input_sample_set.set_domain(lam_domain)
output_sample_set = sample.sample_set(Q.shape[1])
output_sample_set.set_values(Q)
my_disc = sample.discretization(input_sample_set, output_sample_set)

# Show the samples in the parameter space
pDom.scatter_rhoD(my_disc, rho_D=rho_D, ref_sample=ref_sample, io_flag='input')
# Show the corresponding samples in the data space
pDom.scatter_rhoD(output_sample_set,
                  rho_D=rho_D,
                  ref_sample=Q_ref,
                  io_flag='output')
# Show the data domain that corresponds with the convex hull of samples in the
# parameter space
pDom.show_data_domain_2D(my_disc, 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(my_disc, Q_ref=mdat['Q_true'][15], showdim='all')
Example #7
0
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')       
Example #8
0
    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
ref_sample = mdat['points_true']
ref_sample = ref_sample[5:7, 15]

# Create input, output, and discretization from data read from file
points = mdat['points']
input_sample_set = sample.sample_set(points.shape[0])
input_sample_set.set_values(points.transpose())
input_sample_set.set_domain(lam_domain)
output_sample_set = sample.sample_set(Q.shape[1])
output_sample_set.set_values(Q)
my_disc = sample.discretization(input_sample_set, output_sample_set)

# Show the samples in the parameter space
pDom.scatter_rhoD(my_disc, rho_D=rho_D, ref_sample=ref_sample, io_flag='input')
# Show the corresponding samples in the data space
pDom.scatter_rhoD(output_sample_set, rho_D=rho_D, ref_sample=Q_ref,
        io_flag='output')
# Show the data domain that corresponds with the convex hull of samples in the
# parameter space
pDom.show_data_domain_2D(my_disc, 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(my_disc, Q_ref=mdat['Q_true'][15], 
        showdim='all')