IAP GITLAB

Skip to content

Resolve "first_interactions.py crash"

Marvin Gottowik requested to merge 714-first_interactions-py-crash into master

Closes #714

the error in first_interactions.py (see https://gitlab.iap.kit.edu/AirShowerPhysics/corsika/-/jobs/323117)

Traceback (most recent call last):
  File "/builds/0/corsika/python/examples/first_interactions.py", line 57, in <module>
    norm = np.sqrt(sum(np.array(mother.momentum) ** 2))  # total momentum
TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'int'

came from overwritting the variables manually here self.px = self.py = self.pz = None. Printing self directly after Particle.__init__(self, prop_dict) has valid momentum components.

FirstInteraction:
	x: 0
	y: 0
	z: 112750
	nx: 0
	ny: 0
	nz: -1
	pdg: 2212
	name: p+
	total_energy: 10000
	kinetic_energy: 9999.06173
	px: 0
	py: 0
	pz: -9999.99995598247
	time: 0
	slant_depth: 0
	n_secondaries: 50

Since mypy needs to know that px, py, and pz exist for the momentum property I added them analogously to position and direction to the Particle class.

Edited by Marvin Gottowik

Merge request reports

Loading