tomasstolker / species

Toolkit for atmospheric characterization of directly imaged exoplanets
https://species.readthedocs.io
MIT License
22 stars 10 forks source link

Flushing the print buffer when running MultiNest #108

Open gabrielastro opened 2 weeks ago

gabrielastro commented 2 weeks ago

A small one: I am running species from a script and the output gets mixed up:

Interpolating WISE/WISE.W1... [DONE]
Interpolating WISE/WISE.W2... [DONE]
Interpolating WISE/WISE.W3...[…]/species/species/fit/fit_model.py:1718: RuntimeWarning: overflow encountered in scalar divide
  -0.5
[…]/species/species/fit/fit_model.py:1720: RuntimeWarning: overflow encountered in scalar power
  * (phot_item[0] - phot_flux) ** 2
[…]/species/species/util/model_util.py:458: RuntimeWarning: overflow encountered in power
  model_flux *= 10.0 ** (-0.4 * ext_filt)
[…]/species/species/util/model_util.py:449: RuntimeWarning: overflow encountered in multiply
  if "ism_ext" in model_param:
 *****************************************************
 MultiNest v3.10
 Copyright Farhan Feroz & Mike Hobson
 Release Jul 2015

 no. of live points = 2000
 dimensionality =   10
 *****************************************************
 Starting MultiNest
 generating live points
 live points generated, starting sampling
Acceptance Rate:                        0.999512
Replacements:                               2050
Total Samples:                              2051
Nested Sampling ln(Z):            **************
Importance Nested Sampling ln(Z):     183.325581 +/-  0.999756
Acceptance Rate:                        0.997151
Replacements:                               2100

…

Nested Sampling ln(Z):                241.594402
Importance Nested Sampling ln(Z):     239.276677 +/-  0.089403
Acceptance Rate:                        0.088813
Replacements:                              38900
 [DONE]

Fitting 10 parameters:

…

Total Samples:                            464532
Nested Sampling ln(Z):                241.633970
Importance Nested Sampling ln(Z):     239.280403 +/-  0.089069
 ln(ev)=   241.78528815170094      +/-   8.5812366936118753E-002
 Total Likelihood Evaluations:       464532
 Sampling finished. Exiting MultiNest

i.e. the higher-level species output goes on and afterwards the rest of the one from MultiNest comes…

Thanks!

tomasstolker commented 2 weeks ago

During the call of MultiNest, species is not printing anything, but that may happen when using multiprocessing.

gabrielastro commented 2 weeks ago

Thanks for your quick answer here too. Sorry for not specifying but this was a serial run. What I meant was that MultiNest finishes but does not print out everything yet, the normal species output comes (e.g., [DONE] and then continuing with the script), and then the rest of the MultiNest output comes. Maybe there is a MultiNest buffer that could be flushed once it is finished and before species starts printing again? But only if it is easy. And this was while saving the log to a file through nohup python3 script.py 2>&1 >> species.log &; sorry for forgetting to mention it, even though I do not think it should be specific to this.

tomasstolker commented 2 weeks ago

Hmm not sure why that happened. I don't think that is an issue of species because "Fitting X parameters" and "[Done]" should have been printed before MultiNest is called.

gabrielastro commented 2 weeks ago

Ok, strange! I will try to test it a bit later and see if I can find an explanation.