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

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

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 (00a34a0).
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
20	G004  	[ ] Logging statement uses f-string
13	E902  	[ ] No such file or directory (os error 2)
10	F401  	[*] `astropy.units` imported but unused
8	I001  	[*] Import block is un-sorted or un-formatted
7	E999  	[ ] SyntaxError: Expected ',', found ':'
7	D202  	[*] No blank lines allowed after function docstring (found 1)
4	B011  	[*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
4	PT015 	[ ] Assertion always fails, replace with `pytest.fail()`
4	RET505	[ ] Unnecessary `elif` after `return` statement
4	UP004 	[*] Class `ConvergencePlots` inherits from `object`
3	RET506	[ ] Unnecessary `else` after `raise` statement
3	F821  	[ ] Undefined name `get_chain_decay_power_per_ejectamass`
2	INP001	[ ] File `tardis/opacities/tests/test_opacity_solver.py` is part of an implicit namespace package. Add an `__init__.py`.
2	E722  	[ ] Do not use bare `except`
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	ISC003	[ ] Explicitly concatenated string should be implicitly concatenated
1	G001  	[ ] Logging statement uses `str.format`
1	N999  	[ ] Invalid module name: 'GXPacket'
1	W292  	[*] No newline at end of file
1	F403  	[ ] `from tardis.plasma.properties import *` used; unable to detect undefined names
1	F811  	[ ] Redefinition of unused `opacity_state_initialize` from line 13
1	TRY300	[ ] Consider moving this statement to an `else` block

Complete output(might be large):

.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
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/resources/credits.rst:1:1: E999 SyntaxError: Expected a statement
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:167:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:168:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:212:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:229:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:230:17: G004 Logging statement uses f-string
tardis/energy_input/main_gamma_ray_loop.py:284:17: G004 Logging statement uses f-string
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/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/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/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/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/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/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/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
Found 204 errors.
[*] 32 fixable with the `--fix` option (6 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!

tardis/energy_input/gamma_ray_packet_source.py Outdated Show resolved Hide resolved
tardis/energy_input/gamma_packet_loop.py Outdated Show resolved Hide resolved
)

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 42.47104% with 149 lines in your changes missing coverage. Please review.

Project coverage is 70.55%. Comparing base (b95388b) to head (00a34a0).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
tardis/energy_input/main_gamma_ray_loop.py 13.04% 60 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_ray_channel.py 63.88% 13 Missing ⚠️
tardis/energy_input/gamma_packet_loop.py 0.00% 12 Missing ⚠️
tardis/energy_input/samplers.py 44.44% 10 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%   70.55%   +0.30%     
==========================================
  Files         214      221       +7     
  Lines       15981    16261     +280     
==========================================
+ Hits        11226    11473     +247     
- Misses       4755     4788      +33     

☔ 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 (92df2cf) and the latest commit (9f83760).
Here are the logs produced by ASV.
Results can also be downloaded as artifacts here.

Significantly changed benchmarks:

All benchmarks:

Benchmarks that have improved:

| Change   | Before [b79b61ed] <master>   | After [9f83760a]    | Ratio   | Benchmark (Parameter)                                                                                                                        |
|----------|------------------------------|---------------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------|
|          | failed                       | 541±100ns           | n/a     | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                               |
|          | failed                       | 571±200ns           | n/a     | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                         |
|          | failed                       | 602±100ns           | n/a     | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                                       |
|          | failed                       | 3.68±0.02ms         | n/a     | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                            |
|          | failed                       | 2.72±0ms            | n/a     | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                              |
|          | failed                       | 38.9±0.05s          | n/a     | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                                |
|          | failed                       | 1.02±0m             | n/a     | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                               |
|          | failed                       | 2.08±0m             | n/a     | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                          |
|          | failed                       | 207±0.2ns           | n/a     | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                                |
|          | failed                       | 1.18±0μs            | n/a     | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                         |
|          | failed                       | 1.44±0.4μs          | n/a     | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                             |
|          | failed                       | 3.42±2μs            | n/a     | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators                |
|          | failed                       | 43.6±40μs           | n/a     | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                                  |
|          | failed                       | 45.7±30μs           | n/a     | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                                   |
|          | failed                       | 785±3ns             | n/a     | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                                |
|          | failed                       | 1.68±0ms            | n/a     | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                                      |
|          | failed                       | 27.4±9μs            | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list(10, 10)  |
|          | failed                       | 20.8±2μs            | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list(10, 50)  |
|          | failed                       | 26.3±5μs            | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list(100, 10) |
|          | failed                       | 28.7±6μs            | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list(100, 50) |
|          | failed                       | 7.52±0.01μs         | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list(10, 10)                   |
|          | failed                       | 7.74±0μs            | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list(10, 50)                   |
|          | failed                       | 55.7±0.1μs          | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list(100, 10)                  |
|          | failed                       | 50.7±0.02μs         | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list(100, 50)                  |
|          | failed                       | 63.9±0.5ms          | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe(10, 10)                   |
|          | failed                       | 63.3±0.1ms          | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe(10, 50)                   |
|          | failed                       | 62.5±0.04ms         | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe(100, 10)                  |
|          | failed                       | 64.5±0.2ms          | n/a     | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe(100, 50)                  |
|          | failed                       | 2.63±0.3ms          | n/a     | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                                 |
|          | failed                       | 2.94±0.5μs          | n/a     | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                                |
|          | failed                       | 6.16±1μs            | n/a     | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                                    |
|          | failed                       | 7.05±2μs            | n/a     | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                             |
|          | failed                       | 3.29±0.6μs          | n/a     | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                                       |

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

@@ -47,6 +47,7 @@ Atharwa Kharkar <[email protected]> atharwa_24 <[email protected]
Atul Kumar <[email protected]>

Anirban Dutta <[email protected]>
Anirban Dutta <[email protected]>
Copy link
Member Author

Choose a reason for hiding this comment

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

Change mailmap!

@@ -103,21 +101,23 @@ def gamma_packet_loop(
escaped_packets = 0
scattered_packets = 0
packet_count = len(packets)
# Logging does not work with numba
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove the "print statement".

packet_effective_times,
)
decay_time_indices = []
for i in range(number_of_packets):
Copy link
Contributor

Choose a reason for hiding this comment

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

If the decay time indices is not needed, perhaps just remove this part of the code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. True. Added time_index as part of the G_packet. This eliminates the use of the for loop also.

tardis/energy_input/gamma_ray_packet_source.py Outdated Show resolved Hide resolved
tardis/energy_input/main_gamma_ray_loop.py Outdated Show resolved Hide resolved
n_grid : int, optional
Number of grid points for the CDF, by default 1000
"""
self.x_grid = np.linspace(0.01, 0.99, n_grid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't it go from 0 to 1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because if you see the pdf there is log(1-x) which is inf at 1. Also in few terms it is (1-x)/x, so the function diverges at 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. What effect does this limited grid have? If you're doing 1000 points I would expect 0.001 instead of 0.01 as the min and 0.999 as the max.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. True. We can go as low in the lower end and as high in the higher end. I did not check the differences, but can do that.

tardis/energy_input/samplers.py Show resolved Hide resolved
@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?

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