Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3BUU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
simulation
KM3BUU
Commits
bee84332
Commit
bee84332
authored
4 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Plain Diff
Merge branch 'python' of git.km3net.de:simulation/km3buu into python
parents
db63a824
bb6437ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Merge python environment
Pipeline
#11552
failed
4 years ago
Stage: test
Stage: coverage
Stage: doc
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/nuclei_xsections.py
+57
-24
57 additions, 24 deletions
scripts/nuclei_xsections.py
with
57 additions
and
24 deletions
scripts/nuclei_xsections.py
+
57
−
24
View file @
bee84332
...
...
@@ -22,7 +22,6 @@ import os
import
time
import
numpy
as
np
import
km3pipe
as
kp
import
matplotlib.pyplot
as
plt
from
tempfile
import
TemporaryDirectory
from
os.path
import
dirname
,
abspath
from
collections
import
defaultdict
...
...
@@ -73,7 +72,7 @@ def generate_neutrino_jobcard(process, flavor, energy, target):
# INPUT
jc
.
set_property
(
"
input
"
,
"
numTimeSteps
"
,
0
)
jc
.
set_property
(
"
input
"
,
"
eventtype
"
,
5
)
jc
.
set_property
(
"
input
"
,
"
numEnsembles
"
,
100
)
jc
.
set_property
(
"
input
"
,
"
numEnsembles
"
,
100
00
)
jc
.
set_property
(
"
input
"
,
"
delta_T
"
,
0.2
)
jc
.
set_property
(
"
input
"
,
"
localEnsemble
"
,
True
)
jc
.
set_property
(
"
input
"
,
"
num_runs_SameEnergy
"
,
1
)
...
...
@@ -94,8 +93,7 @@ def worker(energy, Z, anti_flag=False):
process
=
"
anticc
"
# create a neutrino jobcard for oxygen
tmpjc
=
generate_neutrino_jobcard
(
process
,
"
electron
"
,
energy
,
(
Z
,
2
*
Z
))
datadir
=
TemporaryDirectory
(
dir
=
dirname
(
__file__
),
prefix
=
"
%sGeV
"
%
energy
)
datadir
=
TemporaryDirectory
(
dir
=
dirname
(
'
.
'
),
prefix
=
"
%sGeV
"
%
energy
)
run_jobcard
(
tmpjc
,
datadir
.
name
)
data
=
GiBUUOutput
(
datadir
)
return
data
...
...
@@ -103,23 +101,49 @@ def worker(energy, Z, anti_flag=False):
def
plot
(
datafile
,
plotfile
):
import
h5py
f
=
h5py
.
File
(
datafile
,
'
r
'
)
data
=
f
[
'
xsec
'
][()]
data
=
data
[[
'
energy
'
,
'
Z
'
,
'
sum
'
]]
energies
=
np
.
sort
(
np
.
unique
(
data
[
'
energy
'
]))
Zrange
=
np
.
sort
(
np
.
unique
(
data
[
'
Z
'
]))
fig
,
ax
=
plt
.
subplots
()
h
=
ax
.
hist2d
(
x
=
data
[
'
energy
'
],
y
=
data
[
'
Z
'
],
bins
=
(
energies
,
Zrange
),
weights
=
np
.
divide
(
data
[
'
sum
'
],
data
[
'
energy
'
]))
cb
=
plt
.
colorbar
(
h
[
3
],
ax
=
ax
)
cb
.
ax
.
get_yaxis
().
labelpad
=
15
cb
.
ax
.
set_ylabel
(
r
"
$\nu$ Crosssection / E [$10^-38cm^{cm^2}/GeV$]
"
)
plt
.
xlabel
(
"
Energy [GeV]
"
)
plt
.
ylabel
(
r
"
Z
"
)
plt
.
xscale
(
'
log
'
)
plt
.
savefig
(
plotfile
)
import
matplotlib.pyplot
as
plt
from
matplotlib.backends.backend_pdf
import
PdfPages
import
matplotlib.colors
as
colors
with
PdfPages
(
plotfile
)
as
pdf
:
f
=
h5py
.
File
(
datafile
,
'
r
'
)
data
=
f
[
'
xsec
'
][()]
data
=
data
[[
'
energy
'
,
'
Z
'
,
'
sum
'
]]
energies
=
np
.
sort
(
np
.
unique
(
data
[
'
energy
'
]))
Zrange
=
np
.
sort
(
np
.
unique
(
data
[
'
Z
'
]))
fig
,
ax
=
plt
.
subplots
()
h
=
ax
.
hist2d
(
x
=
data
[
'
energy
'
],
y
=
data
[
'
Z
'
],
bins
=
(
energies
,
Zrange
),
weights
=
np
.
divide
(
data
[
'
sum
'
],
data
[
'
energy
'
]))
cb
=
plt
.
colorbar
(
h
[
3
],
ax
=
ax
)
cb
.
ax
.
get_yaxis
().
labelpad
=
15
cb
.
ax
.
set_ylabel
(
r
"
$\nu$ Crosssection / E [$10^-38cm^{cm^2}/GeV$]
"
)
plt
.
xlabel
(
"
Energy [GeV]
"
)
plt
.
ylabel
(
r
"
Z
"
)
plt
.
xscale
(
'
log
'
)
pdf
.
savefig
()
plt
.
close
()
data
=
f
[
'
particles
'
][()]
data
=
data
[[
'
energy
'
,
'
Z
'
,
'
multiplicity
'
,
'
particles
'
]]
particle_ids
=
np
.
unique
(
data
[
'
particles
'
])
for
p
in
particle_ids
:
mask
=
data
[
'
particles
'
]
==
p
fig
,
ax
=
plt
.
subplots
()
tmp
=
data
[
mask
]
h
=
ax
.
hist2d
(
x
=
tmp
[
'
energy
'
],
y
=
tmp
[
'
Z
'
],
bins
=
(
energies
,
Zrange
),
weights
=
tmp
[
'
multiplicity
'
],
norm
=
colors
.
LogNorm
())
cb
=
plt
.
colorbar
(
h
[
3
],
ax
=
ax
)
cb
.
ax
.
get_yaxis
().
labelpad
=
15
cb
.
ax
.
set_ylabel
(
r
"
Particle Count
"
)
plt
.
xlabel
(
"
Energy [GeV]
"
)
plt
.
ylabel
(
r
"
Z
"
)
plt
.
xscale
(
'
log
'
)
plt
.
title
(
'
Particle %s
'
%
p
)
pdf
.
savefig
()
plt
.
close
()
class
GiBUUTaskPump
(
kp
.
Module
):
...
...
@@ -135,10 +159,19 @@ class GiBUUTaskPump(kp.Module):
key
=
list
(
self
.
tasks
.
keys
())[
0
]
task
=
self
.
tasks
.
pop
(
key
)
res
=
task
.
result
()
dct
=
dict
(
res
.
xsection
.
_xsections
)
xsec
=
res
.
xsection
dct
=
dict
(
zip
(
xsec
.
dtype
.
names
,
xsec
.
tolist
())
)
dct
.
update
({
'
energy
'
:
self
.
energies
[
key
[
0
]],
'
Z
'
:
self
.
Zrange
[
key
[
1
]]})
blob
[
'
Xsection
'
]
=
kp
.
Table
(
dct
,
h5loc
=
'
xsec
'
)
ev
=
res
.
events
[:]
ids
,
counts
=
np
.
unique
(
ev
[
'
id
'
],
return_counts
=
True
)
dct
=
{
'
energy
'
:
self
.
energies
[
key
[
0
]],
'
Z
'
:
self
.
Zrange
[
key
[
1
]],
'
particles
'
:
ids
,
'
multiplicity
'
:
counts
}
blob
[
'
Particles
'
]
=
kp
.
Table
(
dct
,
h5loc
=
'
particles
'
)
return
blob
...
...
@@ -165,7 +198,7 @@ def main():
if
args
[
'
--Zmax
'
]:
Zmax
=
int
(
args
[
'
--Zmax
'
])
energies
=
np
.
logspace
(
-
1
,
1
,
4
0
)
energies
=
np
.
logspace
(
-
1
,
3
,
10
0
)
Zrange
=
range
(
Zmin
,
Zmax
+
1
)
tasks
=
{}
with
ThreadPoolExecutor
(
max_workers
=
workers
)
as
executor
:
...
...
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