bd-j / prospector

Python code for Stellar Population Inference from Spectra and SEDs
http://prospect.readthedocs.io
MIT License
157 stars 73 forks source link

"TypeError: 'NoneType' object is not iterable" : error running Prospector with emcee #319

Closed nanijune closed 3 months ago

nanijune commented 7 months ago

Hello, I am not very familiar with Prospector, and I am getting this error after running prospector using a non parametric SFH, using this command: python XXX.py --objid=0 --emcee --add_duste --outfile=XXX.

Any help is very much appreciated! Below is the full output I get when running the code:

#########################

Building observation /Users/miniforge3/envs/prospector/lib/python3.12/site-packages/prospect/models/parameters.py:137: RuntimeWarning: logmass has wrong length prior, should be 3 warnings.warn(msg.format(p, n), RuntimeWarning)

Initial guesses: [0.5 6. 6. 6. 0. 0. ]

Building sps object Building observation

Building sps object Libraries: (b'bpss', b'bpass', b'DL07') ::::::: <class 'prospect.models.sedmodel.SedModel'>

Free Parameters: (name: prior)

dust2: <class 'prospect.models.priors.TopHat'>(mini=0.0,maxi=5.0) logmass: <class 'prospect.models.priors.LogUniform'>(mini=6,maxi=12) logsfr_ratios: <class 'prospect.models.priors.StudentT'>(mean=[0. 0.],scale=[0.3 0.3],df=[2 2])

Fixed Parameters: (name: value [, depends_on])

zred: [3.77] mass: [1000000.] <function logsfr_ratios_to_masses at 0x143a04900> logzsol: [-1.3] sfh: [3] imf_type: [2] dust_type: [5] agebins: [[0. 8. ] [8. 8.5] [8.5 9. ]] dust1: [0.] add_igm_absorption: [ True] igm_factor: [0.1] add_neb_continuum: [ True]

Fitting model number of walkers=64 /Users/miniforge3/envs/prospector/lib/python3.12/site-packages/prospect/models/priors.py:117: RuntimeWarning: divide by zero encountered in log lnp = np.log(p) done burn #0 (16 iterations) done burn #1 (32 iterations) done burn #2 (64 iterations) number of walkers=64 starting production done production Optimization took 0.0 s Appending current time (24Feb12-15.46) to output file in order to guarantee a unique name. New output filename: ./results_24Feb12-15.46.h5 /Users/miniforge3/envs/prospector/lib/python3.12/site-packages/prospect/io/write_results.py:290: RuntimeWarning: Could not JSON serialize run_params, pickled instead warnings.warn("Could not JSON serialize {}, pickled instead".format(k), /Users/miniforge3/envs/prospector/lib/python3.12/site-packages/prospect/io/write_results.py:290: RuntimeWarning: Could not JSON serialize model_params, pickled instead warnings.warn("Could not JSON serialize {}, pickled instead".format(k), /Users/miniforge3/envs/prospector/lib/python3.12/site-packages/prospect/io/write_results.py:49: RuntimeWarning: Could not obtain prospector version info warnings.warn("Could not obtain prospector version info", RuntimeWarning) Traceback (most recent call last): File "/Users/Dropbox/Mac/Desktop/J0332_paper/J0332_MC_A1.py", line 443, in ind_best = np.argmin([r.cost for r in oresults]) ^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not iterable

################################

bd-j commented 7 months ago

Hi, it looks like your code J0332_MC_A1.py is trying to access optimization results, but optimization has not been performed (the --optimize flag is not set in your call to python XXX.py)

bd-j commented 3 months ago

Assuming this is resolved, but please reopen if you have further questions.