Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSD Detector Project
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
Container Registry
Model registry
Operate
Environments
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
CSD-team
CSD Detector Project
Commits
58448269
Commit
58448269
authored
6 years ago
by
lorenzennio
Browse files
Options
Downloads
Patches
Plain Diff
Added documentation.
parent
89198072
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
analysis.py
+34
-12
34 additions, 12 deletions
analysis.py
with
34 additions
and
12 deletions
analysis.py
+
34
−
12
View file @
58448269
"""
Analysis class
"""
import
numpy
as
np
import
pandas
as
pd
import
matplotlib
as
plt
class
Analysis
:
"""
Analysis class:
This class computes mean and error on the detector output angles.
The results can then be visualized with two plots.
"""
def
__init__
(
self
,
angles
):
# Better to put in Pandas dataframe
"""
The class is initialized with the angles from the detector results
and then automatically deletes
'
None
'
entries and computes the minimum
range of angles and the error.
"""
self
.
xAngles
=
pd
.
Series
({
'
High
'
:
angles
[
0
][
0
],
'
Low
'
:
angles
[
0
][
1
],})
self
.
yAngles
=
pd
.
Series
({
'
High
'
:
angles
[
1
][
0
],
...
...
@@ -19,20 +25,35 @@ class Analysis:
self
.
results
=
pd
.
DataFrame
({
'
Mean
'
:
np
.
zeros
(
2
),
'
Error
'
:
np
.
zeros
(
2
)})
#
TODO:
Determine mean and std
self
.
rmNone
()
#Determine mean and std
self
.
FillAngles
()
self
.
Angles
(
self
.
xAngles
[
'
High
'
],
self
.
xAngles
[
'
Low
'
],
call
=
0
)
self
.
Angles
(
self
.
yAngles
[
'
High
'
],
self
.
yAngles
[
'
Low
'
],
call
=
1
)
#TODO: Plot
def
rmNone
(
self
):
self
.
xAngles
[
'
High
'
]
=
np
.
array
([
x
for
x
in
self
.
xAngles
[
'
High
'
]
if
x
is
not
None
])
self
.
xAngles
[
'
Low
'
]
=
np
.
array
([
x
for
x
in
self
.
xAngles
[
'
Low
'
]
if
x
is
not
None
])
self
.
yAngles
[
'
High
'
]
=
np
.
array
([
x
for
x
in
self
.
yAngles
[
'
High
'
]
if
x
is
not
None
])
self
.
yAngles
[
'
Low
'
]
=
np
.
array
([
x
for
x
in
self
.
yAngles
[
'
Low
'
]
if
x
is
not
None
])
def
FillAngles
(
self
):
"""
Fill the angle data into the class vaiebles.
"""
self
.
xAngles
[
'
High
'
]
=
np
.
array
([
x
for
x
in
self
.
xAngles
[
'
High
'
]
if
x
is
not
None
])
self
.
xAngles
[
'
Low
'
]
=
np
.
array
([
x
for
x
in
self
.
xAngles
[
'
Low
'
]
if
x
is
not
None
])
self
.
yAngles
[
'
High
'
]
=
np
.
array
([
x
for
x
in
self
.
yAngles
[
'
High
'
]
if
x
is
not
None
])
self
.
yAngles
[
'
Low
'
]
=
np
.
array
([
x
for
x
in
self
.
yAngles
[
'
Low
'
]
if
x
is
not
None
])
def
Angles
(
self
,
high
,
low
,
call
=
0
):
"""
Algorithm to compute the minimum possible range of angles.
The upper and lower angles must be given as a argument and also
the
'
call
'
variable secifies the plane you are working in
(x-z or y-z plane).
The algorithim loops over the angles from the last detector layer
to the first, and replaces the upper and lower angle bounds, if
a certain layer restricts the range further.
The mean is calculated as the arithmetic mean of the resulting
angles and the error is the difference from the mean to the angle
bounds.
"""
highRev
=
high
[::
-
1
]
lowRev
=
low
[::
-
1
]
highBound
=
highRev
[
0
]
...
...
@@ -43,6 +64,7 @@ class Analysis:
highBound
=
a
if
b
<
highBound
and
b
>
lowBound
:
lowBound
=
b
print
(
highBound
,
lowBound
)
error
=
(
highBound
-
lowBound
)
/
2
mean
=
highBound
-
error
self
.
results
[
'
Mean
'
][
call
]
=
mean
...
...
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