IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Pranav Sampathkumar
corsika
Commits
cad89b3a
Commit
cad89b3a
authored
3 years ago
by
Remy Prechelt
Browse files
Options
Downloads
Patches
Plain Diff
Add support for loading the energy loss processes.
parent
01ab0f56
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/corsika/io/outputs/__init__.py
+2
-0
2 additions, 0 deletions
python/corsika/io/outputs/__init__.py
python/corsika/io/outputs/energy_loss.py
+87
-0
87 additions, 0 deletions
python/corsika/io/outputs/energy_loss.py
with
89 additions
and
0 deletions
python/corsika/io/outputs/__init__.py
+
2
−
0
View file @
cad89b3a
...
...
@@ -12,6 +12,7 @@ from .track_writer import TrackWriter
from
.longitudinal_profile
import
LongitudinalProfile
from
.bethe_bloch
import
BetheBlochPDG
from
.particle_cut
import
ParticleCut
from
.energy_loss
import
EnergyLoss
from
.output
import
Output
__all__
=
[
...
...
@@ -21,4 +22,5 @@ __all__ = [
"
LongitudinalProfile
"
,
"
BetheBlochPDG
"
,
"
ParticleCut
"
,
"
EnergyLoss
"
]
This diff is collapsed.
Click to expand it.
python/corsika/io/outputs/energy_loss.py
0 → 100644
+
87
−
0
View file @
cad89b3a
"""
Read data written by EnergyLoss.
(c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
This software is distributed under the terms of the GNU General Public
Licence version 3 (GPL Version 3). See file LICENSE for a full version of
the license.
"""
import
logging
import
os.path
as
op
from
typing
import
Any
import
pyarrow.parquet
as
pq
from
.output
import
Output
class
EnergyLoss
(
Output
):
"""
Read particle data from a EnergyLoss process.
"""
def
__init__
(
self
,
path
:
str
):
"""
Load the particle data into a parquet table.
Parameters
----------
path: str
The path to the directory containing this output.
"""
super
().
__init__
(
path
)
# try and load our data
try
:
self
.
__data
=
pq
.
read_table
(
op
.
join
(
path
,
"
dEdX.parquet
"
))
except
Exception
as
e
:
logging
.
getLogger
(
"
corsika
"
).
warn
(
f
"
An error occured loading a EnergyLoss:
{
e
}
"
)
def
is_good
(
self
)
->
bool
:
"""
Returns true if this output has been read successfully
and has the correct files/state/etc.
Returns
-------
bool:
True if this is a good output.
"""
return
self
.
__data
is
not
None
def
astype
(
self
,
dtype
:
str
=
"
pandas
"
,
**
kwargs
:
Any
)
->
Any
:
"""
Load the particle data from this track writer.
All additional keyword arguments are passed to `parquet.read_table`
Parameters
----------
dtype: str
The data format to return the data in (i.e. numpy, pandas, etc.)
Returns
-------
Any:
The return type of this method is determined by `dtype`.
"""
if
dtype
==
"
arrow
"
:
return
self
.
__data
elif
dtype
==
"
pandas
"
:
return
self
.
__data
.
to_pandas
()
else
:
raise
ValueError
(
(
f
"
Unknown format
'
{
dtype
}
'
for EnergyLoss.
"
"
We currently only support [
'
arrow
'
,
'
pandas
'
].
"
)
)
def
__repr__
(
self
)
->
str
:
"""
Return a string representation of this class.
"""
return
f
"
EnergyLess(
'
{
self
.
config
[
'
name
'
]
}
'
)
"
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