From 8fe9cb653ef96b8d79fe3e7ee276d31cb6332022 Mon Sep 17 00:00:00 2001 From: ThibeauWouters Date: Thu, 19 Dec 2024 16:43:10 +0100 Subject: [PATCH] Do not import PBA if not used --- src/.gitignore | 1 + src/fiesta/train/AfterglowData.py | 7 ++- src/fiestaEM.egg-info/PKG-INFO | 58 ---------------------- src/fiestaEM.egg-info/SOURCES.txt | 9 ---- src/fiestaEM.egg-info/dependency_links.txt | 1 - src/fiestaEM.egg-info/requires.txt | 13 ----- src/fiestaEM.egg-info/top_level.txt | 1 - 7 files changed, 7 insertions(+), 83 deletions(-) create mode 100644 src/.gitignore delete mode 100644 src/fiestaEM.egg-info/PKG-INFO delete mode 100644 src/fiestaEM.egg-info/SOURCES.txt delete mode 100644 src/fiestaEM.egg-info/dependency_links.txt delete mode 100644 src/fiestaEM.egg-info/requires.txt delete mode 100644 src/fiestaEM.egg-info/top_level.txt diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..4edf511 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +fiesta.egg-info diff --git a/src/fiesta/train/AfterglowData.py b/src/fiesta/train/AfterglowData.py index 57bb420..80b1c6d 100644 --- a/src/fiesta/train/AfterglowData.py +++ b/src/fiesta/train/AfterglowData.py @@ -9,7 +9,6 @@ from fiesta.constants import days_to_seconds import afterglowpy as grb -from PyBlastAfterglowMag.wrappers import run_grb class AfterglowData: @@ -372,6 +371,12 @@ def _call_pyblastafterglow(self, Args: Float[Array, "n_times"]: The flux density in mJys at the given times. """ + + try: + from PyBlastAfterglowMag.wrappers import run_grb + except ImportError: + raise ImportError("PyBlastAfterglowMag is not installed. Please install it from source") + # Define jet structure (analytic; gaussian) -- 3 free parameters struct = dict( struct= self.jet_type, # type of the structure tophat or gaussian diff --git a/src/fiestaEM.egg-info/PKG-INFO b/src/fiestaEM.egg-info/PKG-INFO deleted file mode 100644 index a59f6cf..0000000 --- a/src/fiestaEM.egg-info/PKG-INFO +++ /dev/null @@ -1,58 +0,0 @@ -Metadata-Version: 2.1 -Name: fiestaEM -Version: 0.0.1 -Summary: Fast inference of electromagnetic signals with JAX -Home-page: https://github.com/ThibeauWouters/fiestaEM -Author: Thibeau Wouters -Author-email: thibeauwouters@gmail.com -License: MIT -Keywords: sampling,inference,astrophysics,kilonovae,gamma-ray bursts -Requires-Python: >=3.10 -Description-Content-Type: text/markdown -License-File: LICENSE -Requires-Dist: jax>=0.4.24 -Requires-Dist: jaxlib>=0.4.24 -Requires-Dist: numpy<2.0.0 -Requires-Dist: pandas<2.0.0 -Requires-Dist: jaxtyping -Requires-Dist: beartype -Requires-Dist: tqdm -Requires-Dist: scipy<=1.14.0 -Requires-Dist: ml_collections -Requires-Dist: astropy -Requires-Dist: sncosmo -Requires-Dist: flowMC -Requires-Dist: joblib - -# fiesta 🎉 - -`fiesta`: **F**ast **I**nference of **E**lectromagnetic **S**ignals and **T**ransients with j**A**x - -![fiesta logo](docs/fiesta_logo.jpeg) - -**NOTE:** `fiesta` is currently under development -- stay tuned! - -## Installation - -pip installation is currently work in progress. Install from source by cloning this Github repository and running -``` -pip install -e . -``` - -NOTE: This is using an older and custom version of `flowMC`. Install by cloning the `flowMC` version at [this fork](https://github.com/ThibeauWouters/flowMC/tree/fiesta) (branch `fiesta`). - -## Training surrogate models - -To train your own surrogate models, have a look at some of the example scripts in the repository for inspiration, under `trained_models` - -- `train_Bu2019lm.py`: Example script showing how to train a surrogate model for the POSSIS `Bu2019lm` kilonova model. -- `train_afterglowpy_tophat.py`: Example script showing how to train a surrogate model for `afterglowpy`, using a tophat jet structure. - -## Examples - -- `run_AT2017gfo_Bu2019lm.py`: Example where we infer the parameters of the AT2017gfo kilonova with the `Bu2019lm` model. -- `run_GRB170817_tophat.py`: Example where we infer the parameters of the GRB170817 GRB with a surrogate model for `afterglowpy`'s tophat jet. **NOTE** This currently only uses one specific filter. The complete inference will be updated soon. - -## Acknowledgements - -The logo was created by [ideogram AI](https://ideogram.ai/). diff --git a/src/fiestaEM.egg-info/SOURCES.txt b/src/fiestaEM.egg-info/SOURCES.txt deleted file mode 100644 index 52a1484..0000000 --- a/src/fiestaEM.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -LICENSE -README.md -pyproject.toml -setup.cfg -src/fiestaEM.egg-info/PKG-INFO -src/fiestaEM.egg-info/SOURCES.txt -src/fiestaEM.egg-info/dependency_links.txt -src/fiestaEM.egg-info/requires.txt -src/fiestaEM.egg-info/top_level.txt \ No newline at end of file diff --git a/src/fiestaEM.egg-info/dependency_links.txt b/src/fiestaEM.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/fiestaEM.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/fiestaEM.egg-info/requires.txt b/src/fiestaEM.egg-info/requires.txt deleted file mode 100644 index 283afba..0000000 --- a/src/fiestaEM.egg-info/requires.txt +++ /dev/null @@ -1,13 +0,0 @@ -jax>=0.4.24 -jaxlib>=0.4.24 -numpy<2.0.0 -pandas<2.0.0 -jaxtyping -beartype -tqdm -scipy<=1.14.0 -ml_collections -astropy -sncosmo -flowMC -joblib diff --git a/src/fiestaEM.egg-info/top_level.txt b/src/fiestaEM.egg-info/top_level.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/fiestaEM.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -