Comments (4)
Can I confirm you're using the 1.* version of ChainConsumer for this? There's the grid example here. If you can share the wfit file itself I can try to reproduce orioerky,
from chainconsumer.
Sorry for the late reply, I missed your previous comment somehow. Here is a URL link where I uploaded the file
https://rb.gy/1u8nz9
I would also like to mention I tried this
the version I have is 1.0.0, I had issues with v. 1.1.2
from chainconsumer import ChainConsumer, Chain
import pandas as pd
import numpy as np
# Define the path and load the data
df = pd.read_csv('DIROPT00000_COVOPT000_FITOPT000_CHI2GRID.DAT', sep=r'\s+', comment='#')
w0 = df.iloc[:, [2]]
wa = df.iloc[:, [3]]
# Calculate weights
weights = np.exp(-0.5 * df['chi2_tot'].values)
# Create a Chain object with the samples and weights
chain = Chain(
samples= df.iloc[:, [3, 2]], # w0, wa
weights=weights, # Add weights to the chain
name="Test", # Add a name
color="red", # Add a color
grid = True
)
# Initialize ChainConsumer and add the chain
c = ChainConsumer()
c.add_chain(chain)
fig = c.plotter.plot(figsize='column')
if you please give your feedback will be useful, thanks.
from chainconsumer.
I think the main issue here is your computation of weights is incorrect. You need a delta chi2, not the absolute value, and you can see if you inspect the weights
you've made they'll be all zero. I should make an issue to support 0 weights better, and also log weights properly, but in the meantime this code should work:
import numpy as np
import pandas as pd
from chainconsumer import Chain, ChainConsumer
# Define the path and load the data
df = pd.read_csv("DIROPT00000_COVOPT000_FITOPT000_CHI2GRID.DAT", sep=r"\s+", comment="#")
# Add a weight column. Theres poor handling of zero weights in ChainConsumer, so I add a small value here
df["weight"] = np.exp(-0.5 * (df["chi2_tot"] - df["chi2_tot"].min())) + 1e-50
# Initialize ChainConsumer and add the chain
c = ChainConsumer()
c.add_chain(Chain(samples=df[["w0", "wa", "weight"]], name="Test", color="red", grid=True))
fig = c.plotter.plot(figsize="column")
from chainconsumer.
Amazing, thank you. this is exactly what I was looking for.
from chainconsumer.
Related Issues (20)
- Feature request : Option to parse a custom fig instance HOT 2
- How to change tick width and height in the corner plots ? HOT 1
- adding yaxis label to distribution plots
- Title bug when `display=True` HOT 2
- ImportError: cannot import name 'Chain' from 'chainconsumer' HOT 2
- Plot truth in marginal distributions HOT 2
- [Bug] Wrong count of `walkers` after the chain division
- Plot of contour is getting cut. HOT 9
- Chain labels/legends when using `plot_contour`. HOT 2
- Problems with `typing_extensions` HOT 2
- Different renderer for summary text and axis labels HOT 1
- Chain straight from dict / chain from numpyro with only certain fields HOT 7
- [Bug] Wrong type returned by `get_bins` HOT 1
- Removing certain entries from legends
- Add a weight option to chainconsumer
- Update CI and package management HOT 5
- Chain.from_arviz does not handle multidimensional variables
- legend not showing and axis labels not using latex format HOT 2
- implement multi-ensemble r-hat diagnostic HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chainconsumer.