rpoleski / MulensModel

Microlensing Modelling package
https://rpoleski.github.io/MulensModel/
Other
57 stars 15 forks source link

yaml output in ulnes_model_fit.py #43

Closed mjmroz closed 2 years ago

rpoleski commented 2 years ago

Adding output in YAML format was on my task list for quite some time. The obvious advantage is that such output can then be easily read using python scripts. I see your approach is to add print(..., file=self._yaml_results_file) in many places. This makes some functions quite long, so it would be good to make them shorter. The disadvantage is that the code structure is less clear - there are many if self._yaml_results: statements in different places of the code. The alternative would be to add to a dict everything that should go to the output file and print it at the end using something like:

with open(self._output_yaml_file, "w") as output:
    yaml.dump(self._yaml_info, output, default_flow_style=False)

Here we get less control over how exactly the file looks like. I'm not yet sure which approach is better. Note that current changes do not work if fitting is done using MultiNest instead of EMCEE. Any opinions?

rpoleski commented 2 years ago

I would change option name: "results" -> "yaml output" (i.e., more specific). Current approach allows sending the yaml output to standard output, which for me doesn't make much sense. Current version is OK and only some minor changes will be needed. I should work on it soon.

rpoleski commented 2 years ago

Ok, I've better understood this code. I've realized that flush=True was there similarly to self._print_model_file. I've brought it back. To be done:

rpoleski commented 2 years ago

Tasks left + new ones: