Closed keheintz closed 1 year ago
Hi Kasper, did you try installing MultiNest yourself? It doesn't get installed by default with the code. Usually the easiest way to get it is via conda.
Hi Adam, yes I should have installed it following bagpipes installation docs -- or do you have to install pymultinest separately / after installing MultiNest?
Update: It looks like it can read the pymultinest import now after installing it with conda.
ModuleNotFoundError Traceback (most recent call last) Input In [1], in <cell line: 4>() 2 import pandas as pd 3 import numpy as np ----> 4 import bagpipes as pipes
File /opt/anaconda3/lib/python3.9/site-packages/bagpipes/init.py:3, in
File /opt/anaconda3/lib/python3.9/site-packages/bagpipes/models/init.py:3, in
File /opt/anaconda3/lib/python3.9/site-packages/bagpipes/models/making/init.py:4, in
File /opt/anaconda3/lib/python3.9/site-packages/bagpipes/models/making/make_cloudy_models.py:9, in
File /opt/anaconda3/lib/python3.9/site-packages/bagpipes/utils.py:5, in
File /opt/anaconda3/lib/python3.9/site-packages/astropy/cosmology/init.py:13, in
File /opt/anaconda3/lib/python3.9/site-packages/astropy/cosmology/io/init.py:9, in astropy.cosmology
. NOT public API.
6 """
8 # Import to register with the I/O machinery
----> 9 from . import cosmology, ecsv, mapping, model, row, table, yaml
File /opt/anaconda3/lib/python3.9/site-packages/astropy/cosmology/io/cosmology.py:84, in
File /opt/anaconda3/lib/python3.9/site-packages/astropy/io/registry/core.py:108, in UnifiedInputRegistry.register_reader(self, data_format, data_class, function, force, priority) 103 raise IORegistryError("Reader for format '{}' and class '{}' is " 104 'already defined' 105 ''.format(data_format, data_class.name)) 107 if data_class not in self._delayed_docs_classes: --> 108 self._updatedoc(data_class, 'read')
File /opt/anaconda3/lib/python3.9/site-packages/astropy/io/registry/base.py:418, in _UnifiedIORegistryBase._updatedoc(self, data_class, readwrite) 414 left_indent = ' ' * min(match.start() for match in matches if match) 416 # Get the available unified I/O formats for this class 417 # Include only formats that have a reader, and drop the 'Data class' column --> 418 format_table = self.get_formats(data_class, readwrite.capitalize()) 419 format_table.remove_column('Data class') 421 # Get the available formats as a table, then munge the output of pformat() 422 # a bit and put it into the docstring.
File /opt/anaconda3/lib/python3.9/site-packages/astropy/io/registry/core.py:404, in UnifiedIORegistry.get_formats(self, data_class, readwrite)
384 def get_formats(self, data_class=None, readwrite=None):
385 """
386 Get the list of registered I/O formats as a ~astropy.table.Table
.
387
(...)
402 Table of available I/O formats.
403 """
--> 404 return super().get_formats(data_class, readwrite)
File /opt/anaconda3/lib/python3.9/site-packages/astropy/io/registry/base.py:86, in _UnifiedIORegistryBase.get_formats(self, data_class, filter_on)
64 def get_formats(self, data_class=None, filter_on=None):
65 """
66 Get the list of registered formats as a ~astropy.table.Table
.
67
(...)
84 If filter_on
is not None nor a registry name.
85 """
---> 86 from astropy.table import Table
88 # set up the column names
89 colnames = (
90 "Data class", "Format",
91 *[self._registries[k]["column"] for k in self._registries_order],
92 "Deprecated")
File /opt/anaconda3/lib/python3.9/site-packages/astropy/table/init.py:75, in
ModuleNotFoundError: No module named 'asdf_astropy.io'
Hmm, haven't seen that one before, what version of astropy are you running?
I live to idiot-proof software! I have astropy.version = '5.1'
Ok that's the same version as me. I'm pretty sure this is an astropy issue though, can you successfully run "from astropy.cosmology import FlatLambdaCDM" in a python terminal?
One potential shortcut to fixing this might be to make a new anaconda environment for bagpipes, whilst installing all the dependencies from scratch. I have a yml file that should do this for you, which I'll email. Try the instructions at https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file
No, it actually outputs an error now (which it didn't before) so there indeed may be some issue cosmology astropy package.
But thanks for the .yml file! Will try installing in a new environment with that.
Hello,
I have just tried installing and running Bagpipes, but I get the following error, which seems to suggest that PyMultiNest is not loaded correctly: Bagpipes: fitting object
NameError Traceback (most recent call last) /var/folders/91/z2qvcffn6b5ccndf82s32_fh0000gn/T/ipykernel_56739/1459370564.py in
----> 1 fit = load_results(run_id)
/var/folders/91/z2qvcffn6b5ccndf82s32_fh0000gn/T/ipykernel_56739/2772977949.py in load_results(run_id) 6 #set_model_type(run_id) 7 fit = pipes.fit(observed_galaxy, fit_instructions, run=run_id) ----> 8 fit.fit() 9 fit.posterior.get_advanced_quantities() # posterior.model_galaxy 10 return fit
/opt/anaconda3/lib/python3.9/site-packages/bagpipes/fitting/fit.py in fit(self, verbose, n_live, use_MPI) 120 start_time = time.time() 121 --> 122 with warnings.catch_warnings(): 123 warnings.simplefilter("ignore") 124 pmn.run(self.fitted_model.lnlike,
NameError: name 'pmn' is not defined
However, this bit in the .fit file seems to be compiled ok without complaining though, so I'm not sure what the issue could be: try: import pymultinest as pmn
except (ImportError, RuntimeError, SystemExit) as e: print("Bagpipes: PyMultiNest import failed, fitting will be unavailable.")
Any ideas for a fix?
Thanks! Kasper