IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Air Shower Physics
corsika
Commits
7b4e1df0
Commit
7b4e1df0
authored
1 year ago
by
Alan Coleman
Committed by
Alan Coleman
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add additional plot
parent
63cff319
No related branches found
Branches containing commit
No related tags found
1 merge request
!559
Resolve "make friendly example scripts for the release"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/examples/particle_dist.py
+43
-1
43 additions, 1 deletion
python/examples/particle_dist.py
with
43 additions
and
1 deletion
python/examples/particle_dist.py
+
43
−
1
View file @
7b4e1df0
...
@@ -7,6 +7,7 @@ import argparse
...
@@ -7,6 +7,7 @@ import argparse
import
numpy
as
np
import
numpy
as
np
import
corsika
import
corsika
import
os
import
os
import
particle
here
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
here
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
...
@@ -40,7 +41,7 @@ bins = np.linspace(-max_r, max_r, n_bins)
...
@@ -40,7 +41,7 @@ bins = np.linspace(-max_r, max_r, n_bins)
unit_str
=
particles_config
[
"
units
"
][
"
length
"
]
# read in the printed units
unit_str
=
particles_config
[
"
units
"
][
"
length
"
]
# read in the printed units
plt
.
figure
()
plt
.
figure
()
plt
.
axes
().
set_aspect
(
'
equal
'
)
plt
.
axes
().
set_aspect
(
"
equal
"
)
plt
.
title
(
particles_config
[
"
type
"
])
plt
.
title
(
particles_config
[
"
type
"
])
plt
.
xlabel
(
f
"
observation plane x (
{
unit_str
}
)
"
)
plt
.
xlabel
(
f
"
observation plane x (
{
unit_str
}
)
"
)
plt
.
ylabel
(
f
"
observation plane y (
{
unit_str
}
)
"
)
plt
.
ylabel
(
f
"
observation plane y (
{
unit_str
}
)
"
)
...
@@ -48,3 +49,44 @@ plt.ylabel(f"observation plane y ({unit_str})")
...
@@ -48,3 +49,44 @@ plt.ylabel(f"observation plane y ({unit_str})")
plt
.
hist2d
(
particles
[
"
x
"
],
particles
[
"
y
"
],
weights
=
particles
[
"
weight
"
],
bins
=
(
bins
,
bins
),
norm
=
mpl
.
colors
.
LogNorm
())
plt
.
hist2d
(
particles
[
"
x
"
],
particles
[
"
y
"
],
weights
=
particles
[
"
weight
"
],
bins
=
(
bins
,
bins
),
norm
=
mpl
.
colors
.
LogNorm
())
plt
.
savefig
(
os
.
path
.
join
(
args
.
output_dir
,
"
particle_dist.png
"
))
plt
.
savefig
(
os
.
path
.
join
(
args
.
output_dir
,
"
particle_dist.png
"
))
######################
## Make a plot of the lateral distribution of particles
## this is based off the approximate shower axis
######################
# This is only the approximate trajectory of the shower
avg_x_dir
=
np
.
average
(
particles
[
"
nx
"
])
avg_y_dir
=
np
.
average
(
particles
[
"
ny
"
])
avg_z_dir
=
np
.
average
(
particles
[
"
nz
"
])
avg_x
=
np
.
average
(
particles
[
"
x
"
])
avg_y
=
np
.
average
(
particles
[
"
y
"
])
r_dot_n
=
(
particles
[
"
x
"
]
-
avg_x
)
*
avg_x_dir
+
(
particles
[
"
y
"
]
-
avg_y
)
*
avg_y_dir
displacement_sq
=
(
particles
[
"
x
"
]
-
avg_x
)
**
2
+
(
particles
[
"
y
"
]
-
avg_y
)
**
2
if
"
z
"
in
particles
.
keys
():
# z may not be written out
avg_z
=
np
.
average
(
particles
[
"
z
"
])
r_dot_n
+=
(
particles
[
"
z
"
]
-
avg_z
)
*
avg_z_dir
displacement_sq
+=
(
particles
[
"
z
"
]
-
avg_z
)
**
2
r_axis
=
np
.
sqrt
(
displacement_sq
-
r_dot_n
**
2
)
bins
=
np
.
linspace
(
0
,
max
(
r_axis
)
*
1.05
,
int
(
n_bins
/
2
+
1
))
plt
.
figure
()
plt
.
xlabel
(
f
"
distance to shower axis (
{
unit_str
}
)
"
)
plt
.
ylabel
(
"
number of particles
"
)
plt
.
semilogy
()
pids
=
[
22
,
11
,
-
11
,
211
,
-
211
,
13
,
-
13
,
2212
,
2112
]
# List of common EAS particles
for
pid
in
pids
:
name
=
particle
.
Particle
.
from_pdgid
(
pid
).
latex_name
try
:
# Not all particle types might be in the file
plt
.
hist
(
r_axis
,
weights
=
(
particles
[
"
pdg
"
]
==
pid
).
astype
(
float
),
bins
=
bins
,
label
=
f
"
$
{
name
}
$,
{
pid
}
"
,
histtype
=
"
step
"
)
except
:
pass
plt
.
legend
()
plt
.
savefig
(
os
.
path
.
join
(
args
.
output_dir
,
"
particle_lateral.png
"
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment