GithubHelp home page GithubHelp logo

grburgess / ronswanson Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 2.0 12.43 MB

Ron Swanson builds tables for 3ML

Home Page: http://jmichaelburgess.com/ronswanson/index.html

License: Other

Python 95.37% TeX 4.63%
3ml astromodels data-analysis interpolation python ron-swanson spectral-fitting

ronswanson's Introduction

ronswanson

CI codecov Documentation Status DOI PyPI PyPI - Downloads

alt text

Ron Swanson builds tables for 3ML.

This tool provides an easy interface to construct 3ML table models from computational expensive simulations on HPC systems. Why? Because it is your right to do so!

Installation

pip install ronswanson

or

git clone https://github.com/grburgess/ronswanson
cd ronswanson
python setup.py install

Contributing

Contributions to ronswanson are always welcome. They can come in the form of:

Bug reports

Please use the Github issue tracking system for any bugs, for questions, and or feature requests.

Code

Additional features you have the impetus to add are always welcome. Please follow the PEP8 python standards and format your code with black

Documentation

Additions or examples, tutorials, or better explanations are always welcome. To ensure that the documentation builds with the current version of the software, I am using jupytext to write the documentation in Markdown. These are automatically converted to and executed as jupyter notebooks when changes are pushed to Github.

Credits

Inspiration by Elisa Schoesser.

ronswanson's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

ronswanson's Issues

Energy Grid in ronswanson

  • ronswanson version: 0.3.1
  • Python version: 3.8
  • Operating System: MacOS

Description

The energy grid is not clear in relation to how spectra are constructed from models. In the example given, the BandSimulation class evaluates the Band function at the energies provided in the energy grid. For Monte Carlo models, I need to specify a energy bin for which I collect photons in. How is this handled in ronswanson and therefore in future fitting using 3ML.

No such file or directory: '/opt/conda/lib/python3.9/site-packages/ronswanson/data/log_theme.ini'

  • ronswanson version: 0.2.5 (pip install ronswanson as of right now)
  • Python version: 3.9
  • Operating System: bullseye/sid

Description

Tried to follow the example in the doc http://jmichaelburgess.com/ronswanson/notebooks/ronswanson.html#Example-with-a-Band-function

in relation to openjournals/joss-reviews#4969

What I Did

FileNotFoundError                         Traceback (most recent call last)
Input In [3], in <cell line: 5>()
      3 import numpy as np
      4 from astromodels import Band
----> 5 import ronswanson as dukesilver
      8 class BandSimulation(dukesilver.Simulation):
      9     def __init__(
     10         self,
     11         simulation_id: int,
   (...)
     14         out_file: str,
     15     ) -> None:

File /opt/conda/lib/python3.9/site-packages/ronswanson/__init__.py:9, in <module>
      6 __email__ = '[email protected]'
      8 from ._version import get_versions
----> 9 from .database import Database
     10 from .simulation import Simulation
     11 from .simulation_builder import SimulationBuilder

File /opt/conda/lib/python3.9/site-packages/ronswanson/database.py:12, in <module>
      9 from astromodels.utils.logging import silence_console_log
     10 from tqdm.auto import tqdm
---> 12 from ronswanson.grids import Parameter, ParameterGrid
     13 from ronswanson.utils.color import Colors
     15 from .utils.logging import setup_logger

File /opt/conda/lib/python3.9/site-packages/ronswanson/grids.py:9, in <module>
      6 import numpy as np
      7 import yaml
----> 9 from .utils.logging import setup_logger
     11 log = setup_logger(__name__)
     14 @dataclass(frozen=True)
     15 class EnergyGrid:

File /opt/conda/lib/python3.9/site-packages/ronswanson/utils/logging.py:25, in <module>
     16         return logRecord.levelno != self.__level
     19 _console_formatter = logging.Formatter(
     20     ' %(message)s',
     21     datefmt="%H:%M:%S",
     22 )
---> 25 mytheme = Theme().read(get_path_of_data_file("log_theme.ini"))
     26 console = Console(theme=mytheme)
     28 ronswanson_console_log_handler = RichHandler(
     29     level=ronswanson_config.logging.level,
     30     rich_tracebacks=True,
     31     markup=True,
     32     console=console,
     33 )

File /opt/conda/lib/python3.9/site-packages/rich/theme.py:69, in Theme.read(cls, path, inherit)
     58 @classmethod
     59 def read(cls, path: str, inherit: bool = True) -> "Theme":
     60     """Read a theme from a path.
     61 
     62     Args:
   (...)
     67         Theme: A new theme instance.
     68     """
---> 69     with open(path, "rt") as config_file:
     70         return cls.from_file(config_file, source=path, inherit=inherit)

FileNotFoundError: [Errno 2] No such file or directory: '/opt/conda/lib/python3.9/site-packages/ronswanson/data/log_theme.ini'

https://renkulab.io/projects/vladimir.savchenko/ronswanson-review/files/blob/Untitled.ipynb

Broadening the scope of ronswanson: building table models for other software?

This issue is related to ronswanson's review for the journal of the open source software, specifically to the item:

Substantial scholarly effort: Does this submission meet the scope eligibility described in the JOSS guidelines

The software is quite young, it started in summer 2022. I do not doubt the amount of work it went in, nor that it will be cited in future; but the fact that it produces template models only for one specific software (3ML), I think makes its scope a bit narrow. Would it be too much work to allow to generate also template models for other packages that have serialisable models (also via .yaml files), e.g. gammapy? I think it would be a huge advantage for this work and it would significantly broaden its scope and usage.

On the other hand, maybe the authors consider this outside of their original intention. It would be good to hear their opinion on this. From a quick look at the documentation, it seems to me that the database with the model and its parameters can be dumped in a 3ML model. Can't a functionality be added to do the same with gammapy? Are there other fundamental routines in ronswanson using 3ML?

If finally generating gammapy-compatible models is judged too much, then maybe a paragraph in the paper can outline future possible expansions of ronswanson to other modelling packages with serialisable models?

Improving the example in the documentation - eventually adding more

This issue is related to ronswanson's review for the journal of the open source software, specifically to the item:

Example usage: Do the authors include examples of how to use the software (ideally to solve real-world analysis problems).

I tried to re-run the Intro example myself, but - to be honest - it took me quite some time to understand what the different steps of the tutorial represent. I feel that the explanation can be improved.

Moreover, reading the paper draft, I got the idea that the unique feature provided by this package was that:

one can create a so-called template or table model by evaluating the simulation on a grid of its parameters, and use interpolation on the output which allows for the simulated model to compared with data via the likelihood in a reasonable amount of time.

But in this tutorial (the only one in the documentation) this is not fully shown.
We are only shown a simple analytical function that is evaluated on a grid of parameters and whose values vs energy are stored in a database. I understand that the band function is used for simplicity (and that ronswanson might be especially useful for more sophisticated models) but we are not shown how this model database can speed up a statistical analysis leveraging the interpolation of the model outputs that the author discusses. And maybe this is non trivial to show, but the current example does not show the particular feature advertised in the paper.

Maybe it would be good to add a statistical evaluation relying on the models in the database in this tutorial, to show the advantages of using this framework? Or maybe - even better - one could add another tutorial notebook illustrating the speed-up in the statistical calculation with the database models?

Is it possible to create only energy-dependent models - f(E), can other type of models be created? This is not clear.

P.S. I would not use the term "simulation" for a simple analytical function evaluated on a grid of parameters.

!simulation_build sim_build.yml Traceback (most recent call last): File "/opt/conda/bin/simulation_build", line 5, in <module> from scripts.simulation_build import simulation_build ModuleNotFoundError: No module named 'scripts'

  • ronswanson version: master
  • Python version: 3.9
  • Operating System: bullseye

Description

!simulation_build sim_build.yml

Traceback (most recent call last):
  File "/opt/conda/bin/simulation_build", line 5, in <module>
    from scripts.simulation_build import simulation_build
ModuleNotFoundError: No module named 'scripts'

Docs: separate the intro and make a clearer case for ronswanson

This issue is related to ronswanson's review for the journal of the open source software, specifically to the item:

A statement of need: Do the authors clearly state what problems the software is designed to solve and who the target audience is?

Now in the docs there is a single Intro page with a brief statement of need, installation instructions and a first example.
On the other hand, in the main doc page there is a brief introductory paragraph just stating:

This tool provides an easy interface to construct 3ML table models from computational expensive simulations on HPC systems. Why? Because it is your right to do so!

Though a conversational approach is always welcome in documentations, maybe the authors can better detail here the problem the software aims to solve, add some physical applications (what is the case of a simulation / analysis for which ronswanson would be useful?) and also for whom this software is helpful?

Maybe it would be better to have the installation instructions separated from the first example.
They can go in the main page as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.