Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having issues with the corner plot. #204

Open
shashankshalgar opened this issue Apr 19, 2022 · 0 comments
Open

Having issues with the corner plot. #204

shashankshalgar opened this issue Apr 19, 2022 · 0 comments

Comments

@shashankshalgar
Copy link

I was trying to run the default case as described on the getting started page:

$mosfit -e LSQ12dlf -m slsn -c

When I try to plot the results using the corner plot, using the cell below:

import logging
logging.disable(logging.WARNING)

par_dict = model['realizations'][0]['parameters']

# Construct chain walker arrays for corner
corner_input = []
with open('../products/chain.json', 'r', encoding = 'utf-8') as f:
    all_chain = np.array(json.load(f))
par_names = all_chain[1]
all_chain = np.asarray(all_chain[0])
all_chain = np.reshape(all_chain,(-1,len(par_names)))

par_labels = []
for i,par_name in enumerate(par_names):
    par_labels.append('$' + ('\\log\\, ' if par_dict[par_name].get('log') else '') +
                 par_dict[par_name]['latex'] + '$')
    if par_dict[par_name].get('log'):
        all_chain[:,i] = np.log10(all_chain[:,i])


cfig = corner.corner(all_chain[-1000:,:], labels=par_labels, quantiles=[0.16, 0.5, 0.84],
                     show_titles=True)
cfig.savefig('../products/corner.pdf')

I get an error:

IndexError                                Traceback (most recent call last)
/tmp/ipykernel_330018/3029066765.py in <module>
      8 with open('products/chain.json', 'r', encoding = 'utf-8') as f:
      9     all_chain = np.array(json.load(f))
---> 10 par_names = all_chain[1]
     11 all_chain = np.asarray(all_chain[0])
     12 all_chain = np.reshape(all_chain,(-1,len(par_names)))

IndexError: index 1 is out of bounds for axis 0 with size 1
​

The format of the chain.json file that is generated is different from what is expected by the mosfit.ipynb file. The all_chain array does not store par_names. I am sorry for the newbie question but is it possible to print the variable names of all the parameters in the chain and their order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant