当前位置: 首页>>代码示例>>Python>>正文


Python ChainConsumer.configure方法代码示例

本文整理汇总了Python中chainconsumer.ChainConsumer.configure方法的典型用法代码示例。如果您正苦于以下问题:Python ChainConsumer.configure方法的具体用法?Python ChainConsumer.configure怎么用?Python ChainConsumer.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chainconsumer.ChainConsumer的用法示例。


在下文中一共展示了ChainConsumer.configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: debug_plots

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
def debug_plots(std):
    print(std)

    res = load_stan_from_folder(std, merge=True, cut=False)
    chain, posterior, t, p, f, l, w, ow = res
    # print(w.mean())
    # import matplotlib.pyplot as plt
    # plt.hist(np.log(w), 100)
    # plt.show()
    # exit()
    logw = np.log(w)
    m = np.mean(logw)
    s = np.std(logw)
    print(m, s)
    logw -= (m + 3 * s)
    good = logw < 0
    logw *= good
    w = np.exp(logw)

    c = ChainConsumer()
    c.add_chain(chain, weights=w, name="corrected")
    c.configure(summary=True)
    c.plot(figsize=2.0, filename="output.png", parameters=9)

    c = ChainConsumer()
    c.add_chain(chain, name="uncorrected")
    c.add_chain(chain, weights=w, name="corrected")
    # c.add_chain(chain, name="calib")
    c.plot(filename="output_comparison.png", parameters=9, figsize=1.3)
    c.plot_walks(chains=1, filename="walks.png")
开发者ID:dessn,项目名称:sn-bhm,代码行数:32,代码来源:load.py

示例2: test_shade_alpha_algorithm2

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
 def test_shade_alpha_algorithm2(self):
     consumer = ChainConsumer()
     consumer.add_chain(self.data)
     consumer.add_chain(self.data)
     consumer.configure()
     alpha0 = consumer.chains[0].config["shade_alpha"]
     alpha1 = consumer.chains[0].config["shade_alpha"]
     assert alpha0 == 1.0 / 2.0
     assert alpha1 == 1.0 / 2.0
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:11,代码来源:test_chainconsumer.py

示例3: test_shade_alpha_algorithm3

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
 def test_shade_alpha_algorithm3(self):
     consumer = ChainConsumer()
     consumer.add_chain(self.data)
     consumer.add_chain(self.data)
     consumer.add_chain(self.data)
     consumer.configure()
     alphas = [c.config["shade_alpha"] for c in consumer.chains]
     assert len(alphas) == 3
     assert alphas[0] == 1.0 / 3.0
     assert alphas[1] == 1.0 / 3.0
     assert alphas[2] == 1.0 / 3.0
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:13,代码来源:test_chainconsumer.py

示例4: test_remove_chain_by_name

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
 def test_remove_chain_by_name(self):
     tolerance = 5e-2
     consumer = ChainConsumer()
     consumer.add_chain(self.data * 2, name="a")
     consumer.add_chain(self.data, name="b")
     consumer.remove_chain(chain="a")
     consumer.configure()
     summary = consumer.analysis.get_summary()
     assert isinstance(summary, dict)
     actual = np.array(list(summary.values())[0])
     expected = np.array([3.5, 5.0, 6.5])
     diff = np.abs(expected - actual)
     assert np.all(diff < tolerance)
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:15,代码来源:test_chainconsumer.py

示例5: test_remove_multiple_chains3

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
 def test_remove_multiple_chains3(self):
     tolerance = 5e-2
     consumer = ChainConsumer()
     consumer.add_chain(self.data * 2, parameters=["p1"], name="a")
     consumer.add_chain(self.data, parameters=["p2"], name="b")
     consumer.add_chain(self.data * 3, parameters=["p3"], name="c")
     consumer.remove_chain(chain=["a", 2])
     consumer.configure()
     summary = consumer.analysis.get_summary()
     assert isinstance(summary, dict)
     assert "p2" in summary
     assert "p1" not in summary
     assert "p3" not in summary
     actual = np.array(list(summary.values())[0])
     expected = np.array([3.5, 5.0, 6.5])
     diff = np.abs(expected - actual)
     assert np.all(diff < tolerance)
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:19,代码来源:test_chainconsumer.py

示例6:

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
    mean_scattered = multivariate_normal.rvs(mean=mean, cov=cov)
    data = multivariate_normal.rvs(mean=mean_scattered, cov=cov, size=5000)
    data2 = data + multivariate_normal.rvs(mean=[8, -8, 7], cov=cov)
    posterior = multivariate_normal.logpdf(data, mean=mean_scattered, cov=cov)
    plot_contour = i == 0

    c.add_chain(data, posterior=posterior, parameters=p, color='p', name="Sim1")

    c.add_chain(data2, posterior=posterior, parameters=p, color='k',
                marker_style="+", marker_size=20, name="Sim2", marker_alpha=0.5)

c.add_chain(data + np.array([4, -4, 3]), parameters=p, posterior=posterior, name="Contour Too",
            plot_contour=True, plot_point=True, marker_style="*", marker_size=40,
            color="a", shade=True, shade_alpha=0.3, kde=True, linestyle="--", bar_shade=True)

c.configure(legend_artists=True)

fig = c.plotter.plot()
fig.set_size_inches(2.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.

###############################################################################
# If you've loaded a whole host of chains in, but only want to focus on one
# set, you can also pick out all chains with the same name when plotting.

fig = c.plotter.plot(chains="Sim1")
fig.set_size_inches(2.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.

###############################################################################
# Finally, we should clarify what exactly the points mean! If you don't specify
# anything, by defaults the points represent the coordinates of the
# maximum posterior value. However, in high dimensional surfaces, this maximum
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:33,代码来源:plot_hundreds_of_chains.py

示例7: multivariate_normal

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
https://github.com/cpadavis/preliminize, which will add watermark to arbitrary
figures!

"""

import numpy as np
from numpy.random import multivariate_normal
from chainconsumer import ChainConsumer

np.random.seed(0)
data1 = multivariate_normal([3, 5], [[1, 0], [0, 1]], size=1000000)
data2 = multivariate_normal([5, 3], [[1, 0], [0, 1]], size=10000)


c = ChainConsumer()
c.add_chain(data1, parameters=["$x$", "$y$"], name="Good results")
c.add_chain(data2, name="Unfinished results")
fig = c.plotter.plot(watermark=r"\textbf{Preliminary}", figsize=2.0)


###############################################################################
# You can also control the text options sent to the matplotlib text call.

c = ChainConsumer()
c.add_chain(data1, parameters=["$x$", "$y$"], name="Good results")
c.add_chain(data2, name="Unfinished results")
kwargs = {"color": "purple", "alpha": 1.0, "family": "sanserif", "usetex": False, "weight": "bold"}
c.configure(watermark_text_kwargs=kwargs, flip=True)
fig = c.plotter.plot(watermark="SECRET RESULTS", figsize=2.0)

开发者ID:Samreay,项目名称:ChainConsumer,代码行数:31,代码来源:plot_preliminary.py

示例8: multivariate_normal

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
"""
==============
Shade Gradient
==============

Control contour contrast!

To help make your confidence levels more obvious, you can play with the gradient steepness and
resulting contrast in your contours.
"""

import numpy as np
from numpy.random import multivariate_normal
from chainconsumer import ChainConsumer

np.random.seed(0)
data1 = multivariate_normal([0, 0], [[1, 0], [0, 1]], size=1000000)
data2 = multivariate_normal([4, -4], [[1, 0], [0, 1]], size=1000000)

c = ChainConsumer()
c.add_chain(data1, parameters=["$x$", "$y$"])
c.add_chain(data2, parameters=["$x$", "$y$"])
c.configure(shade_gradient=[0.1, 3.0], colors=['o', 'k'], sigmas=[0, 1, 2, 3], shade_alpha=1.0)
fig = c.plotter.plot()

fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:28,代码来源:plot_shade_gradient.py

示例9: ChainConsumer

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
the order of the parameters is not preserved in the dictionary.

"""
import numpy as np
from chainconsumer import ChainConsumer
from scipy.stats import multivariate_normal


x, y = np.linspace(-3, 3, 50), np.linspace(-7, 7, 100)
xx, yy = np.meshgrid(x, y, indexing='ij')
pdf = np.exp(-0.5 * (xx * xx + yy * yy / 4 + np.abs(xx * yy)))

c = ChainConsumer()
c.add_chain([x, y], parameters=["$x$", "$y$"], weights=pdf, grid=True)
fig = c.plotter.plot()
fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.

###############################################################################
# If you have the flattened array already, you can also pass this

# Turning 2D data to flat data.
xs, ys = xx.flatten(), yy.flatten()
coords = np.vstack((xs, ys)).T
pdf_flat = multivariate_normal.pdf(coords, mean=[0.0, 0.0], cov=[[1.0, 0.7], [0.7, 3.5]])
c = ChainConsumer()
c.add_chain([xs, ys], parameters=["$x$", "$y$"], weights=pdf_flat, grid=True)
c.configure(smooth=1)  # Notice how smoothing changes the results!
fig = c.plotter.plot()

fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:32,代码来源:plot_grid.py

示例10: smoothness

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
"""
========================
Gaussian KDE and Extents
========================

Smooth marginalised distributions with a Gaussian KDE, and pick custom extents.


Note that invoking the KDE on large data sets will significantly increase rendering time when
you have a large number of points. You can also pass a float to your KDE to modify the width
of the bandpass by that factor!

You can see the increase in contour smoothness (without broadening) for when you have a
low number of samples in your chains!
"""

import numpy as np
from chainconsumer import ChainConsumer

np.random.seed(0)
data = np.random.multivariate_normal([0.0, 4.0], [[1.0, -0.7], [-0.7, 1.5]], size=3000)

c = ChainConsumer()
c.add_chain(data, name="KDE on")
c.add_chain(data + 1, name="KDE off")
c.add_chain(data + 2, name="KDE x2!")
c.configure(kde=[True, False, 2.0], shade_alpha=0.1, flip=False)
fig = c.plotter.plot(extents=[(-2, 4), (0, 9)])

fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:32,代码来源:plot_kde_extents.py

示例11: colour

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
Multiple Colour Scatter!
========================

Why show only one colour, when you can display more!

In the basic colour example, we showed one parameter being used
to give colour information. However, you can pick a different colour, or no colour (`None`),
for each chain.

You can also pick the same parameter in multiple chains, and all the scatter points will be put
on the same colour scale. The underlying contours will still be distinguishable automatically
by adding alternative linestyles, as shown below.
"""

import numpy as np
from numpy.random import normal, multivariate_normal
from chainconsumer import ChainConsumer

np.random.seed(1)
cov = normal(size=(4, 4))
data = multivariate_normal(normal(size=4), np.dot(cov, cov.T), size=100000)
cov = 1 + 0.5 * normal(size=(4, 4))
data2 = multivariate_normal(4+normal(size=4), np.dot(cov, cov.T), size=100000)

c = ChainConsumer().add_chain(data, parameters=["$x$", "$y$", "$z$", "$g$"], name="a")
c.add_chain(data2, parameters=["$x$", "$y$", "$z$", "$t$"], name="b")
c.configure(color_params=["$g$", "$t$"])
fig = c.plotter.plot(figsize=1.75)

fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:32,代码来源:plot_colorpoints.py

示例12: string

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
"""
===================
Blinding Parameters
===================

You can blind parameters and not show axis labels very easily!

Just give ChainConsumer the `blind` parameter when plotting. You can specify `True` to blind all parameters,
or give it a string (or list of strings) detailing the specific parameters you want blinded!

"""

import numpy as np
from numpy.random import multivariate_normal
from chainconsumer import ChainConsumer

np.random.seed(0)
data = multivariate_normal([0, 0], [[1, 0], [0, 1]], size=1000000)

c = ChainConsumer().add_chain(data, parameters=["$x$", "$y$"])
c.configure(colors=["g"])
fig = c.plotter.plot(blind="$y$")

fig.set_size_inches(2.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:26,代码来源:plot_blinding.py

示例13: multivariate_normal

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
Because of that, you can pass any keywords to the legend call you want via `legend_kwargs`.
"""

import numpy as np
from numpy.random import multivariate_normal
from chainconsumer import ChainConsumer

np.random.seed(0)
data1 = multivariate_normal([0, 0], [[1, 0], [0, 1]], size=1000000)
data2 = data1 + 2

c = ChainConsumer()
c.add_chain(data1, parameters=["$x$", "$y$"], name="Chain 1")
c.add_chain(data2, parameters=["$x$", "$y$"], name="Chain 2")
c.configure(colors=['lb', 'g'])
fig = c.plotter.plot()
fig.set_size_inches(2.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.

###############################################################################
# If the linestyles are different and the colours are the same, the artists
# will reappear.

c = ChainConsumer()
c.add_chain(data1, parameters=["$x$", "$y$"], name="Chain 1")
c.add_chain(data2, parameters=["$x$", "$y$"], name="Chain 2")
c.configure(colors=['lb', 'lb'], linestyles=["-", "--"])
fig = c.plotter.plot()
fig.set_size_inches(2.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.

###############################################################################
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:32,代码来源:plot_legend_options.py

示例14: normal

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
np.random.seed(2)
cov = normal(size=(2, 2)) + np.identity(2)
d1 = multivariate_normal(normal(size=2), np.dot(cov, cov.T), size=100000)
cov = normal(size=(2, 2)) + np.identity(2)
d2 = multivariate_normal(normal(size=2), np.dot(cov, cov.T), size=100000)
cov = normal(size=(2, 2)) + np.identity(2)
d3 = multivariate_normal(normal(size=2), np.dot(cov, cov.T), size=1000000)

c = ChainConsumer()
c.add_chain(d1, parameters=["$x$", "$y$"])
c.add_chain(d2)
c.add_chain(d3)

c.configure(linestyles=["-", "--", "-"], linewidths=[1.0, 3.0, 1.0],
            bins=[3.0, 1.0, 1.0], colors=["#1E88E5", "#D32F2F", "#111111"],
            smooth=[0, 1, 2], shade=[True, True, False],
            shade_alpha=[0.2, 0.1, 0.0], bar_shade=[True, False, False])
fig = c.plotter.plot()

fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.

###############################################################################
# List options are useful for when the properties of the chains are
# interconnected. But if you know the properties at the start,
# you can define them when adding the chains. List options will not
# override explicit chain configurations, so you can use the global
# configure to set options for all chains you haven't explicitly specified.
#
# Note here how even though we set 'all' chains to dotted lines of width 2, our third
# chain, with its explicit options, ignores that.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:32,代码来源:plot_lists.py

示例15: ChainConsumer

# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure [as 别名]
"""
=====================
Flips, Ticks and Size
=====================

You can stop the second parameter rotating in the plot if you prefer squares!

Unlike the Introduction example, which shows the rotated plots, this example shows them
without the rotation.

Also, you can pass in a tuple for the figure size. We also demonstrate adding more
ticks to the axis in this example. Also, I change the colour to red, just for fun.
"""

import numpy as np
from chainconsumer import ChainConsumer

np.random.seed(0)
data = np.random.multivariate_normal([1.5, 4.0], [[1.0, 0.7], [0.7, 1.5]], size=1000000)
data[:, 0] = np.abs(data[:, 0])

c = ChainConsumer().add_chain(data, parameters=["$x_1$", "$x_2$"])
c.configure(flip=False, max_ticks=10, colors="#D32F2F")
fig = c.plotter.plot(figsize=(6, 6))

fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:28,代码来源:plot_dont_flip.py


注:本文中的chainconsumer.ChainConsumer.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。