Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamma ray spectra dep #2793

Merged
merged 31 commits into from
Feb 26, 2025

Conversation

Knights-Templars
Copy link
Member

This PR refactors the packets sampling, has gamma ray and positron energy deposition, and positronium contribution to the gamma-ray spectra.

Examples, notebooks, and links to useful references.

🚦 Testing

How did you test these changes?

  • some tests are added

☑️ Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

@Knights-Templars Knights-Templars marked this pull request as draft August 13, 2024 13:55
@tardis-bot
Copy link
Contributor

*beep* *bop*

Hi, human.

I'm the @tardis-bot and couldn't find your records in my database. I think we don't know each other, or you changed your credentials recently.

Please add your name and email to .mailmap in your current branch and push the changes to this pull request.

In case you need to map an existing alias, follow this example.

@tardis-bot
Copy link
Contributor

tardis-bot commented Aug 13, 2024

*beep* *bop*
Hi human,
I ran ruff on the latest commit (b47aceb).
Here are the outputs produced.
Results can also be downloaded as artifacts here.
Summarised output:

95	F405  	[ ] `AdiabaticCoolingRate` may be undefined, or defined from star imports
65	W291  	[*] Trailing whitespace
30	E902  	[ ] No such file or directory (os error 2)
24	G004  	[ ] Logging statement uses f-string
24	E999  	[ ] SyntaxError: Expected ',', found ':'
18	I001  	[*] Import block is un-sorted or un-formatted
17	W293  	[*] Blank line contains whitespace
12	F401  	[*] `astropy.units` imported but unused
7	RET505	[ ] Unnecessary `elif` after `return` statement
7	D202  	[*] No blank lines allowed after function docstring (found 1)
5	INP001	[ ] File `tardis/analysis/opacities.py` is part of an implicit namespace package. Add an `__init__.py`.
5	W292  	[*] No newline at end of file
4	B011  	[*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
4	PT015 	[ ] Assertion always fails, replace with `pytest.fail()`
4	UP004 	[*] Class `ConvergencePlots` inherits from `object`
3	RET506	[ ] Unnecessary `else` after `raise` statement
3	F811  	[ ] Redefinition of unused `monkeysession` from line 6
3	F821  	[ ] Undefined name `get_chain_decay_power_per_ejectamass`
2	PIE808	[*] Unnecessary `start` argument in `range`
2	PTH117	[ ] `os.path.isabs()` should be replaced by `Path.is_absolute()`
2	E712  	[*] Avoid equality comparisons to `False`; use `if not ...:` for false checks
2	E722  	[ ] Do not use bare `except`
2	W605  	[*] Invalid escape sequence: `\A`
2	D406  	[*] Section name should end with a newline ("Returns")
2	D407  	[*] Missing dashed underline after section ("Returns")
2	D411  	[*] Missing blank line before section ("Parameters")
2	UP008 	[*] Use `super()` instead of `super(__class__, self)`
1	ANN204	[ ] Missing return type annotation for special method `__getitem__`
1	S604  	[ ] Function call with truthy `shell` parameter identified, security issue
1	B020  	[ ] Loop control variable `isotope_dict` overrides iterable it iterates
1	FA100 	[ ] Add `from __future__ import annotations` to simplify `typing.Tuple`
1	ISC003	[ ] Explicitly concatenated string should be implicitly concatenated
1	G001  	[ ] Logging statement uses `str.format`
1	NPY201	[ ] `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead.
1	N999  	[ ] Invalid module name: 'GXPacket'
1	E703  	[*] Statement ends with an unnecessary semicolon
1	F403  	[ ] `from tardis.plasma.properties import *` used; unable to detect undefined names
1	F541  	[*] f-string without any placeholders
1	TRY300	[ ] Consider moving this statement to an `else` block

Complete output(might be large):

.github/actions/setup_env/action.yml:4:8: E999 SyntaxError: Expected an expression
.github/actions/setup_env/action.yml:17:1: W293 [*] Blank line contains whitespace
.github/actions/setup_env/action.yml:19:15: W291 [*] Trailing whitespace
.github/actions/setup_env/action.yml:24:1: W293 [*] Blank line contains whitespace
.github/actions/setup_lfs/action.yml:5:8: E999 SyntaxError: Expected an expression
.github/workflows/benchmarks.yml:3:4: E999 SyntaxError: Expected an expression
.github/workflows/benchmarks.yml:20:5: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:86:49: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:116:81: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:117:54: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:204:1: W293 [*] Blank line contains whitespace
.github/workflows/benchmarks.yml:223:22: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:224:170: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:226:84: W291 [*] Trailing whitespace
.github/workflows/benchmarks.yml:243:1: W293 [*] Blank line contains whitespace
.github/workflows/build-docs.yml:7:4: E999 SyntaxError: Expected an expression
.github/workflows/lfs-cache.yml:1:1: E902 No such file or directory (os error 2)
.github/workflows/release.yml:7:4: E999 SyntaxError: Expected an expression
.github/workflows/release.yml:94:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:97:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:104:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:107:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:110:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:115:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:119:1: W293 [*] Blank line contains whitespace
.github/workflows/release.yml:144:23: W292 [*] No newline at end of file
.github/workflows/tests.yml:7:4: E999 SyntaxError: Expected an expression
.mailmap:1:38: E999 SyntaxError: Expected an expression
.mailmap:291:39: W292 [*] No newline at end of file
CHANGELOG.md:4:15: E999 SyntaxError: Expected ',', found ':'
CITATION.cff:3:1: E999 SyntaxError: Invalid annotated assignment target
README.rst:1:1: E999 SyntaxError: Expected a statement
conda-linux-64.lock:5:1: E999 SyntaxError: Expected class, function definition or async function definition after decorator
conda-lock.yml:14:10: E999 SyntaxError: Expected an expression
conda-osx-arm64.lock:5:1: E999 SyntaxError: Expected class, function definition or async function definition after decorator
docs/contributing/development/benchmarks.rst:1:1: E999 SyntaxError: Expected a statement
docs/contributing/development/continuous_integration.rst:1:1: E999 SyntaxError: Expected a statement
docs/contributing/development/continuous_integration.rst:16:76: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:18:68: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:21:92: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:22:86: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:48:1: W293 [*] Blank line contains whitespace
docs/contributing/development/continuous_integration.rst:82:70: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:97:78: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:98:94: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:99:83: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:100:96: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:102:97: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:103:62: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:110:90: W291 [*] Trailing whitespace
docs/contributing/development/continuous_integration.rst:111:19: W292 [*] No newline at end of file
docs/contributing/development/running_tests.rst:1:1: E999 SyntaxError: Expected a statement
docs/contributing/development/running_tests.rst:37:42: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:60:112: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:61:124: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:65:92: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:66:107: W291 [*] Trailing whitespace
docs/contributing/development/running_tests.rst:76:62: W291 [*] Trailing whitespace
docs/index.rst:1:1: E999 SyntaxError: Expected a statement
docs/index.rst:21:51: W291 [*] Trailing whitespace
docs/index.rst:43:76: W291 [*] Trailing whitespace
docs/index.rst:44:64: W291 [*] Trailing whitespace
docs/index.rst:45:71: W291 [*] Trailing whitespace
docs/index.rst:46:69: W291 [*] Trailing whitespace
docs/index.rst:47:68: W291 [*] Trailing whitespace
docs/index.rst:66:1: W293 [*] Blank line contains whitespace
docs/index.rst:79:1: W293 [*] Blank line contains whitespace
docs/index.rst:103:1: W293 [*] Blank line contains whitespace
docs/io/grid/how_to_TardisGridTutorial.ipynb:cell 2:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/grid/how_to_TardisGridTutorial.ipynb:cell 7:2:74: W291 [*] Trailing whitespace
docs/io/grid/how_to_TardisGridTutorial.ipynb:cell 14:1:47: W291 [*] Trailing whitespace
docs/io/grid/how_to_TardisGridTutorial.ipynb:cell 14:4:46: E703 [*] Statement ends with an unnecessary semicolon
docs/io/grid/how_to_TardisGridTutorial.ipynb:cell 15:2:55: W291 [*] Trailing whitespace
docs/io/images/custom_abundance_widget.png:1:1: E902 stream did not contain valid UTF-8
docs/io/images/energy_level_widget_options.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/images/line_info_widget_demo.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/images/packet_diagram.jpg:1:1: E902 stream did not contain valid UTF-8
docs/io/images/sdec_ply_interaction.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/images/shell_info_widget_demo.gif:1:1: E902 stream did not contain valid UTF-8
docs/io/output/how_to_rpacket_tracking.ipynb:cell 12:1:62: W291 [*] Trailing whitespace
docs/io/visualization/demo_observed_spectrum.dat:1:26: E999 SyntaxError: Simple statements must be separated by newlines or semicolons
docs/io/visualization/how_to_generating_widgets.ipynb:cell 5:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/how_to_generating_widgets.ipynb:cell 5:3:5: F401 [*] `tardis.visualization.shell_info_from_hdf` imported but unused
docs/io/visualization/how_to_sdec_plot.ipynb:cell 2:2:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/how_to_sdec_plot.ipynb:cell 29:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/index.rst:1:1: E999 SyntaxError: Expected a statement
docs/io/visualization/index.rst:33:68: W292 [*] No newline at end of file
docs/io/visualization/tardis_example.yml:2:26: E999 SyntaxError: Simple statements must be separated by newlines or semicolons
docs/io/visualization/tutorial_convergence_plot.ipynb:cell 9:4:28: W291 [*] Trailing whitespace
docs/io/visualization/tutorial_convergence_plot.ipynb:cell 12:29:1: W293 [*] Blank line contains whitespace
docs/io/visualization/tutorial_convergence_plot.ipynb:cell 13:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/tutorial_montecarlo_packet_visualization.ipynb:cell 5:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/io/visualization/using_widgets.rst:1:1: E999 SyntaxError: Expected an expression
docs/io/visualization/using_widgets.rst:7:83: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:15:69: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:23:76: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:24:41: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:26:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:29:79: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:39:75: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:40:80: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:41:78: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:42:75: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:43:75: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:51:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:52:79: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:53:73: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:54:71: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:62:74: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:63:76: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:71:80: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:72:79: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:80:78: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:81:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:82:77: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:109:48: W291 [*] Trailing whitespace
docs/io/visualization/using_widgets.rst:161:77: W291 [*] Trailing whitespace
docs/physics/plasma/detailed_balance/collisional_rate_coefficients.hdf:1:1: E902 stream did not contain valid UTF-8
docs/physics/plasma/detailed_balance/comparison.ipynb:cell 31:1:1: I001 [*] Import block is un-sorted or un-formatted
docs/physics/plasma/detailed_balance/test_continuum_template_wkerzen_rate_coeffs.yml:2:26: E999 SyntaxError: Simple statements must be separated by newlines or semicolons
docs/physics/plasma/equilibrium/chianti_solver.ipynb:1:1: E902 No such file or directory (os error 2)
docs/physics/plasma/equilibrium/tardis_solver.ipynb:1:1: E902 No such file or directory (os error 2)
docs/physics/plasma/equilibrium/tardis_solver_cmfgen.ipynb:1:1: E902 No such file or directory (os error 2)
docs/physics/setup/model.ipynb:cell 2:2:1: I001 [*] Import block is un-sorted or un-formatted
docs/physics/setup/model.ipynb:cell 25:19:12: F541 [*] f-string without any placeholders
docs/quickstart.ipynb:cell 12:1:39: W291 [*] Trailing whitespace
docs/quickstart.ipynb:cell 12:5:35: W291 [*] Trailing whitespace
docs/quickstart.ipynb:cell 16:10:26: W605 [*] Invalid escape sequence: `\A`
docs/quickstart.ipynb:cell 16:11:40: W605 [*] Invalid escape sequence: `\A`
docs/resources/credits.rst:1:1: E999 SyntaxError: Expected a statement
docs/workflows/v_inner_solver_workflow.ipynb:1:1: E902 No such file or directory (os error 2)
tardis/analysis/opacities.py:1:1: INP001 File `tardis/analysis/opacities.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/energy_input/GXPacket.py:1:1: N999 Invalid module name: 'GXPacket'
tardis/energy_input/GXPacket.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/energy_input/GXPacket.py:41:16: UP004 [*] Class `GXPacket` inherits from `object`
tardis/energy_input/GXPacket.py:75:9: D407 [*] Missing dashed underline after section ("Returns")
tardis/energy_input/GXPacket.py:75:9: D406 [*] Section name should end with a newline ("Returns")
tardis/energy_input/GXPacket.py:202:13: F821 Undefined name `get_chain_decay_power_per_ejectamass`
tardis/energy_input/GXPacket.py:203:17: F821 Undefined name `inventory`
tardis/energy_input/gamma_ray_packet_source.py:1:25: F401 [*] `astropy.units` imported but unused
tardis/energy_input/gamma_ray_packet_source.py:294:53: F821 Undefined name `positronium_continuum`
tardis/energy_input/main_gamma_ray_loop.py:166:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:167:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:211:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:234:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:235:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:295:17: G004 Logging statement uses f-string
tardis/energy_input/samplers.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/energy_input/samplers.py:178:1: W293 [*] Blank line contains whitespace
tardis/energy_input/samplers.py:190:53: W291 [*] Trailing whitespace
tardis/energy_input/samplers.py:191:35: W291 [*] Trailing whitespace
tardis/energy_input/samplers.py:192:28: W292 [*] No newline at end of file
tardis/energy_input/tests/conftest.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/energy_input/tests/conftest.py:24:9: S604 Function call with truthy `shell` parameter identified, security issue
tardis/energy_input/tests/test_gamma_ray_channel.py:119:9: B020 Loop control variable `isotope_dict` overrides iterable it iterates
tardis/energy_input/tests/test_gamma_ray_grid.py:12:5: PT015 Assertion always fails, replace with `pytest.fail()`
tardis/energy_input/tests/test_gamma_ray_grid.py:12:12: B011 Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
tardis/energy_input/tests/test_gamma_ray_grid.py:18:5: PT015 Assertion always fails, replace with `pytest.fail()`
tardis/energy_input/tests/test_gamma_ray_grid.py:18:12: B011 Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
tardis/energy_input/tests/test_gamma_ray_interactions.py:16:5: PT015 Assertion always fails, replace with `pytest.fail()`
tardis/energy_input/tests/test_gamma_ray_interactions.py:16:12: B011 Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
tardis/energy_input/tests/test_gamma_ray_interactions.py:22:5: PT015 Assertion always fails, replace with `pytest.fail()`
tardis/energy_input/tests/test_gamma_ray_interactions.py:22:12: B011 Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
tardis/energy_input/util.py:409:5: RET505 Unnecessary `elif` after `return` statement
tardis/energy_input/util.py:420:5: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/energy_input/util.py:422:5: D411 [*] Missing blank line before section ("Parameters")
tardis/grid/tests/test_grid.py:1:1: INP001 File `tardis/grid/tests/test_grid.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/io/atom_data/base.py:198:34: G004 Logging statement uses f-string
tardis/io/atom_data/base.py:263:17: G004 Logging statement uses f-string
tardis/io/atom_data/base.py:267:21: G001 Logging statement uses `str.format`
tardis/io/atom_data/base.py:704:17: G004 Logging statement uses f-string
tardis/io/configuration/config_reader.py:53:29: G004 Logging statement uses f-string
tardis/io/configuration/config_reader.py:117:9: RET505 Unnecessary `else` after `return` statement
tardis/io/configuration/config_reader.py:141:13: RET505 Unnecessary `else` after `return` statement
tardis/io/configuration/config_reader.py:218:29: G004 Logging statement uses f-string
tardis/io/configuration/schemas/montecarlo_definitions.yml:1:13: E999 SyntaxError: Expected an expression
tardis/io/model/parse_geometry_configuration.py:50:12: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
tardis/io/model/parse_radiation_field_configuration.py:118:13: G004 Logging statement uses f-string
tardis/io/model/readers/generic_readers.py:20:6: FA100 Add `from __future__ import annotations` to simplify `typing.Tuple`
tardis/io/model/readers/generic_readers.py:47:12: NPY201 `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead.
tardis/io/model/readers/tests/test_arepo_parser.py:1:1: INP001 File `tardis/io/model/readers/tests/test_arepo_parser.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/model/base.py:340:12: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()`
tardis/model/base.py:375:21: G004 Logging statement uses f-string
tardis/opacities/macro_atom/base.py:120:5: D411 [*] Missing blank line before section ("Parameters")
tardis/opacities/macro_atom/base.py:227:5: E722 Do not use bare `except`
tardis/opacities/macro_atom/base.py:246:14: UP008 Use `super()` instead of `super(__class__, self)`
tardis/opacities/macro_atom/base.py:357:9: E722 Do not use bare `except`
tardis/opacities/macro_atom/macroatom_solver.py:8:23: UP004 [*] Class `MacroAtomSolver` inherits from `object`
tardis/opacities/macro_atom/macroatom_solver.py:14:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/opacities/macro_atom/macroatom_solver.py:28:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/opacities/macro_atom/macroatom_solver.py:90:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/opacities/macro_atom/macroatom_state.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/opacities/opacity_solver.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/opacities/opacity_solver.py:9:21: UP004 [*] Class `OpacitySolver` inherits from `object`
tardis/opacities/opacity_solver.py:17:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/opacities/opacity_state.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/opacities/opacity_state.py:42:9: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/opacities/opacity_state.py:174:9: ANN204 Missing return type annotation for special method `__getitem__`
tardis/opacities/opacity_state.py:180:9: D407 [*] Missing dashed underline after section ("Returns")
tardis/opacities/opacity_state.py:180:9: D406 [*] Section name should end with a newline ("Returns")
tardis/opacities/opacity_state.py:215:5: D202 [*] No blank lines allowed after function docstring (found 1)
tardis/opacities/tau_sobolev.py:92:14: UP008 Use `super()` instead of `super(__class__, self)`
tardis/opacities/tests/test_opacity_solver.py:1:1: INP001 File `tardis/opacities/tests/test_opacity_solver.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/opacities/tests/test_opacity_solver.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/opacities/tests/test_opacity_solver.py:2:17: F401 [*] `numpy` imported but unused
tardis/opacities/tests/test_opacity_solver.py:7:44: F401 [*] `tardis.opacities.opacity_state.OpacityState` imported but unused
tardis/opacities/tests/test_opacity_solver.py:8:42: F401 [*] `tardis.opacities.tau_sobolev.calculate_sobolev_line_opacity` imported but unused
tardis/opacities/tests/test_opacity_state_numba.py:1:1: INP001 File `tardis/opacities/tests/test_opacity_state_numba.py` is part of an implicit namespace package. Add an `__init__.py`.
tardis/opacities/tests/test_opacity_state_numba.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/opacities/tests/test_tau_sobolev.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/detailed_balance/rates/__init__.py:2:5: F401 `tardis.plasma.detailed_balance.rates.collision_strengths.UpsilonCMFGENSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/detailed_balance/rates/__init__.py:3:5: F401 `tardis.plasma.detailed_balance.rates.collision_strengths.UpsilonRegemorterSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/detailed_balance/rates/__init__.py:6:5: F401 `tardis.plasma.detailed_balance.rates.collisional_rates.ThermalCollisionalRateSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/detailed_balance/rates/__init__.py:9:5: F401 `tardis.plasma.detailed_balance.rates.radiative_rates.RadiativeRatesSolver` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
tardis/plasma/electron_energy_distribution/__init__.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/electron_energy_distribution/base.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/level_populations.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/rate_matrix.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/rates/__init__.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/rates/collisional_ionization_rates.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/rates/collisional_ionization_strengths.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/rates/photoionization_rates.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/rates/photoionization_strengths.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/tests/__init__.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/tests/conftest.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/tests/test_level_populations.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/equilibrium/tests/test_rate_matrix.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/properties/legacy_property_collections.py:1:1: E902 No such file or directory (os error 2)
tardis/plasma/properties/property_collections.py:10:1: F403 `from tardis.plasma.properties import *` used; unable to detect undefined names
tardis/plasma/properties/property_collections.py:19:9: F405 `DilutePlanckianRadField` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:20:9: F405 `NumberDensity` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:21:9: F405 `TimeExplosion` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:22:9: F405 `AtomicData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:23:9: F405 `JBlues` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:24:9: F405 `LinkTRadTElectron` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:25:9: F405 `HeliumTreatment` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:26:9: F405 `ContinuumInteractionSpecies` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:27:9: F405 `NLTEIonizationSpecies` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:28:9: F405 `NLTEExcitationSpecies` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:33:9: F405 `TRadiative` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:34:9: F405 `DilutionFactor` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:35:9: F405 `BetaRadiation` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:36:9: F405 `Levels` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:37:9: F405 `Lines` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:38:9: F405 `PartitionFunction` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:39:9: F405 `GElectron` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:40:9: F405 `IonizationData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:41:9: F405 `LinesLowerLevelIndex` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:42:9: F405 `LinesUpperLevelIndex` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:44:9: F405 `StimulatedEmissionFactor` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:45:9: F405 `SelectedAtoms` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:46:9: F405 `ElectronTemperature` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:49:55: F405 `PhiSahaLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:50:55: F405 `LevelBoltzmannFactorLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:52:6: F405 `BetaSobolev` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:52:44: F405 `MacroAtomData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:55:6: F405 `PhiSahaNebular` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:55:22: F405 `ZetaData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:55:32: F405 `BetaElectron` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:55:46: F405 `RadiationFieldCorrection` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:58:6: F405 `LevelBoltzmannFactorDiluteLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:60:49: F405 `LevelBoltzmannFactorNoNLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:63:9: F405 `LevelBoltzmannFactorNLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:64:9: F405 `NLTEData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:65:9: F405 `PreviousElectronDensities` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:66:9: F405 `PreviousBetaSobolev` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:67:9: F405 `BetaSobolev` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:71:6: F405 `NLTEIndexHelper` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:71:23: F405 `NLTEPopulationSolverRoot` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:74:6: F405 `NLTEIndexHelper` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:74:23: F405 `NLTEPopulationSolverLU` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:78:9: F405 `HeliumNLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:79:9: F405 `RadiationFieldCorrection` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:80:9: F405 `ZetaData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:81:9: F405 `BetaElectron` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:82:9: F405 `LevelNumberDensityHeNLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:83:9: F405 `IonNumberDensityHeNLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:87:6: F405 `LevelNumberDensity` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:87:26: F405 `IonNumberDensity` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:90:6: F405 `HeliumNumericalNLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:94:9: F405 `PhotoIonRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:95:9: F405 `StimRecombRateFactor` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:96:9: F405 `BfHeatingRateCoeffEstimator` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:97:9: F405 `StimRecombCoolingRateCoeffEstimator` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:98:9: F405 `YgData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:103:9: F405 `StimRecombRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:104:9: F405 `PhotoIonizationData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:105:9: F405 `SpontRecombRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:106:9: F405 `ThermalLevelBoltzmannFactorLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:107:9: F405 `ThermalLTEPartitionFunction` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:108:9: F405 `BetaElectron` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:109:9: F405 `ThermalGElectron` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:110:9: F405 `ThermalPhiSahaLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:111:9: F405 `SahaFactor` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:112:9: F405 `CorrPhotoIonRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:113:9: F405 `SpontRecombCoolingRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:114:9: F405 `RawRecombTransProbs` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:115:9: F405 `RawPhotoIonTransProbs` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:116:9: F405 `RawRadBoundBoundTransProbs` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:117:9: F405 `MarkovChainTransProbs` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:118:9: F405 `NonContinuumTransProbsMask` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:119:9: F405 `YgInterpolator` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:120:9: F405 `CollExcRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:121:9: F405 `CollDeexcRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:122:9: F405 `RawCollisionTransProbs` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:123:9: F405 `MarkovChainIndex` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:124:9: F405 `MarkovChainTransProbsCollector` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:126:9: F405 `MonteCarloTransProbs` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:127:9: F405 `FreeFreeCoolingRate` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:128:9: F405 `FreeBoundCoolingRate` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:130:9: F405 `LevelNumberDensityLTE` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:131:9: F405 `PhotoIonBoltzmannFactor` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:132:9: F405 `FreeBoundEmissionCDF` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:133:9: F405 `LevelIdxs2LineIdx` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:134:9: F405 `LevelIdxs2TransitionIdx` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:135:9: F405 `CollIonRateCoeffSeaton` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:136:9: F405 `CollRecombRateCoeff` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:138:9: F405 `ContinuumInteractionHandler` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:139:9: F405 `BetaSobolev` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:142:58: F405 `AdiabaticCoolingRate` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:145:9: F405 `RawTwoPhotonTransProbs` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:146:9: F405 `TwoPhotonData` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:147:9: F405 `TwoPhotonEmissionCDF` may be undefined, or defined from star imports
tardis/plasma/properties/property_collections.py:148:9: F405 `TwoPhotonFrequencySampler` may be undefined, or defined from star imports
tardis/plasma/standard_plasmas.py:316:9: RET506 Unnecessary `else` after `raise` statement
tardis/radiation_field/validate_radiation_field.py:1:1: E902 No such file or directory (os error 2)
tardis/simulation/base.py:197:13: RET506 Unnecessary `else` after `raise` statement
tardis/simulation/base.py:261:17: G004 Logging statement uses f-string
tardis/simulation/base.py:268:9: RET505 Unnecessary `else` after `return` statement
tardis/simulation/base.py:449:13: G004 Logging statement uses f-string
tardis/simulation/base.py:547:13: G004 Logging statement uses f-string
tardis/simulation/base.py:654:25: G004 Logging statement uses f-string
tardis/simulation/base.py:657:13: G004 Logging statement uses f-string
tardis/simulation/base.py:662:13: G004 Logging statement uses f-string
tardis/simulation/base.py:713:13: TRY300 Consider moving this statement to an `else` block
tardis/simulation/base.py:715:26: G004 Logging statement uses f-string
tardis/spectrum/formal_integral.py:23:5: F811 Redefinition of unused `opacity_state_initialize` from line 13
tardis/spectrum/formal_integral.py:340:13: RET506 Unnecessary `else` after `raise` statement
tardis/spectrum/formal_integral.py:681:5: RET505 Unnecessary `else` after `return` statement
tardis/spectrum/formal_integral.py:717:5: RET505 Unnecessary `else` after `return` statement
tardis/transport/montecarlo/packet_source.py:246:9: RET505 Unnecessary `else` after `return` statement
tardis/transport/montecarlo/tests/conftest.py:14:5: F811 Redefinition of unused `opacity_state_initialize` from line 7
tardis/visualization/tools/convergence_plot.py:3:1: I001 [*] Import block is un-sorted or un-formatted
tardis/visualization/tools/convergence_plot.py:4:25: F401 [*] `matplotlib.cm` imported but unused
tardis/visualization/tools/convergence_plot.py:5:29: F401 [*] `matplotlib.colors` imported but unused
tardis/visualization/tools/convergence_plot.py:39:24: UP004 [*] Class `ConvergencePlots` inherits from `object`
tardis/visualization/tools/convergence_plot.py:321:13: ISC003 Explicitly concatenated string should be implicitly concatenated
tardis/visualization/tools/tests/test_convergence_plot.py:3:1: I001 [*] Import block is un-sorted or un-formatted
tardis/visualization/tools/tests/test_convergence_plot.py:6:36: F401 [*] `tardis.tests.test_util.monkeysession` imported but unused
tardis/visualization/tools/tests/test_convergence_plot.py:87:24: PIE808 [*] Unnecessary `start` argument in `range`
tardis/visualization/tools/tests/test_convergence_plot.py:111:22: PIE808 [*] Unnecessary `start` argument in `range`
tardis/visualization/tools/tests/test_convergence_plot.py:198:9: E712 Avoid equality comparisons to `False`; use `if not ...:` for false checks
tardis/visualization/tools/tests/test_convergence_plot.py:215:9: E712 Avoid equality comparisons to `False`; use `if not ...:` for false checks
tardis/visualization/tools/tests/test_convergence_plot.py:220:40: F811 Redefinition of unused `monkeysession` from line 6
tardis/workflows/simple_tardis_workflow.py:218:17: G004 Logging statement uses f-string
tardis/workflows/simple_tardis_workflow.py:430:17: G004 Logging statement uses f-string
tardis/workflows/standard_tardis_workflow.py:172:13: G004 Logging statement uses f-string
tardis/workflows/standard_tardis_workflow.py:212:17: G004 Logging statement uses f-string
tardis/workflows/util.py:1:1: E902 No such file or directory (os error 2)
tardis/workflows/v_inner_solver.py:1:1: E902 No such file or directory (os error 2)
Found 360 errors.
[*] 136 fixable with the `--fix` option (8 hidden fixes can be enabled with the `--unsafe-fixes` option).

] = PositroniumSampler().sample_energy(n_samples=
np.sum(positronium_formation & annihilation_line & three_photon_decay)
)
energy_array[positronium_formation & annihilation_line & ~three_photon_decay] = 511.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a cool way to do this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

)

from tardis.energy_input.gamma_ray_transport import get_taus
from tardis.energy_input.util import KEV2ERG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an astropy units thing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

astropy units have been used. Do you want separately in this file?

@tardis-bot
Copy link
Contributor

*beep* *bop*

Hi, human.

I'm the @tardis-bot and couldn't find your records in my database. I think we don't know each other, or you changed your credentials recently.

Please add your name and email to .mailmap in your current branch and push the changes to this pull request.

In case you need to map an existing alias, follow this example.

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 41.50943% with 155 lines in your changes missing coverage. Please review.

Project coverage is 69.66%. Comparing base (b95388b) to head (b47aceb).
Report is 39 commits behind head on master.

Files with missing lines Patch % Lines
tardis/energy_input/main_gamma_ray_loop.py 12.50% 63 Missing ⚠️
tardis/energy_input/gamma_ray_packet_source.py 14.70% 29 Missing ⚠️
tardis/energy_input/util.py 13.63% 19 Missing ⚠️
tardis/energy_input/gamma_packet_loop.py 0.00% 13 Missing ⚠️
tardis/energy_input/gamma_ray_channel.py 63.88% 13 Missing ⚠️
tardis/energy_input/samplers.py 40.00% 12 Missing ⚠️
tardis/energy_input/GXPacket.py 0.00% 5 Missing ⚠️
tardis/energy_input/gamma_ray_grid.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2793      +/-   ##
==========================================
- Coverage   70.24%   69.66%   -0.59%     
==========================================
  Files         214      228      +14     
  Lines       15981    16549     +568     
==========================================
+ Hits        11226    11529     +303     
- Misses       4755     5020     +265     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

andrewfullard
andrewfullard previously approved these changes Aug 19, 2024
@andrewfullard andrewfullard marked this pull request as ready for review August 19, 2024 18:25
@tardis-bot
Copy link
Contributor

tardis-bot commented Aug 19, 2024

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (b95388b) and the latest commit (b47aceb).
Here are the logs produced by ASV.
Results can also be downloaded as artifacts here.

Significantly changed benchmarks:

All benchmarks:

Benchmarks that have stayed the same:

| Change   | Before [e0297c6a] <master>   | After [b47acebd]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 44.0±20μs                    | 56.1±20μs           | ~1.27   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 1.53±0.3μs                   | 1.38±0.4μs          | ~0.90   | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 3.46±0.8μs                   | 3.03±0.2μs          | ~0.88   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 24.0±6μs                     | 20.8±5μs            | ~0.87   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 3.81±0.09μs                  | 3.30±0.4μs          | ~0.87   | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 38.1±0.1μs                   | 31.0±0.03μs         | ~0.81   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 4.07±0.03ms                  | 4.28±0.02ms         | 1.05    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 1.97±1μs                     | 2.07±2μs            | 1.05    | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 204±0.05ns                   | 211±0.1ns           | 1.04    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 41.4±20μs                    | 42.9±20μs           | 1.04    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 3.01±0.01ms                  | 3.10±0ms            | 1.03    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 541±100ns                    | 551±100ns           | 1.02    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 727±0.6ns                    | 738±4ns             | 1.02    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 65.4±0.1ms                   | 65.9±0.2ms          | 1.01    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 7.47±3μs                     | 7.54±2μs            | 1.01    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 2.08±0m                      | 2.08±0m             | 1.00    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 1.66±0ms                     | 1.66±0ms            | 1.00    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 6.74±0.9μs                   | 6.73±0.6μs          | 1.00    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 1.21±0μs                     | 1.19±0μs            | 0.99    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 1.07±0m                      | 1.04±0m             | 0.98    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 39.5±0.09s                   | 38.3±0.04s          | 0.97    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 581±200ns                    | 551±200ns           | 0.95    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 2.92±0.5ms                   | 2.78±0.4ms          | 0.95    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |
|          | 631±200ns                    | 591±200ns           | 0.94    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |

If you want to see the graph of the results, you can check it here

@andrewfullard andrewfullard requested review from jvshields, DeerWhale and wkerzendorf and removed request for Rodot- December 3, 2024 16:01
@@ -103,21 +101,20 @@ def gamma_packet_loop(
escaped_packets = 0
scattered_packets = 0
packet_count = len(packets)
# Logging does not work with numba. Using print instead.
print("Entering gamma ray loop for " + str(packet_count) + " packets")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would much prefer using logging, and just doing it right above the function call rather than inside the function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep now this is moving from being in-development, we should formalize some of these logs (which has already been done in some of the other major functions)

@@ -31,7 +31,8 @@ class GXPacketStatus(IntEnum):
("nu_cmf", float64),
("status", int64),
("shell", int64),
("time_current", float64),
("time_start", float64),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good name for a variable that is updated once the packet has travelled a distance.

print("Escaped packets:", escaped_packets)
print("Scattered packets:", scattered_packets)
print("Number of escaped packets:", escaped_packets)
print("Number of scattered packets:", scattered_packets)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note about print statements above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these print statements are useful diagnostics. I am not sure how to use logging here.

dataframe of isotopes for each shell with their decay mode, number of decays, radiation type,
radiation energy and radiation intensity at each time step.

"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function duplicates some code from the function above that could be factored out into a different function

@@ -167,3 +169,98 @@ def create_isotope_decay_df(cumulative_decay_df, gamma_ray_lines):
)

return isotope_decay_df


def time_evolve_mass_fraction(raw_isotope_mass_fraction, time_array):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe combine this with the time_evolve_cumilative_decay function below, and just have the combined function return both the new mass fractions and cumulative decays.

get_index,
get_random_unit_vector,
)
from tardis.transport.montecarlo.packet_source import BasePacketSource

POSITRON_ANNIHILATION_LINE = 511.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps have a comment here adding "in KeV"

# annihilation line of positrons
annihilation_line = packets["radiation_energy_keV"] == POSITRON_ANNIHILATION_LINE
# three photon decay of positronium
three_photon_decay = np.random.random(number_of_packets) > PARA_TO_ORTHO_RATIO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just use np.random.uniform instead of np.random.random? Weird to use different functions between this line and above in 601.

positronium_energy, positronium_intensity = positronium_continuum()
# sample packets from the gamma-ray lines only (include X-rays!)
sampled_packets_df_gamma = decays_per_isotope[
decays_per_isotope["radiation"] == "g"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty weird operation, especially considering the documentation says that decays_per_isotope is an array of int64s. Is the documentation wrong?

andrewfullard
andrewfullard previously approved these changes Feb 25, 2025
@wkerzendorf wkerzendorf merged commit a51af90 into tardis-sn:master Feb 26, 2025
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants