Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3io.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
common
KM3io.jl
Commits
8f56ff6b
Verified
Commit
8f56ff6b
authored
9 months ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add orientations readout
parent
7beb9755
No related branches found
No related tags found
1 merge request
!32
Orientations readout and interpolation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/exports.jl
+1
-0
1 addition, 0 deletions
src/exports.jl
src/root/calibration.jl
+51
-8
51 additions, 8 deletions
src/root/calibration.jl
with
52 additions
and
8 deletions
src/exports.jl
+
1
−
0
View file @
8f56ff6b
...
...
@@ -84,6 +84,7 @@ calibratetime,
combine
,
floordist
,
slew
,
Orientations
,
# Reconstruction
RecStageRange
,
...
...
This diff is collapsed.
Click to expand it.
src/root/calibration.jl
+
51
−
8
View file @
8f56ff6b
struct
Orientations
times
::
Vector
{
Float64
}
quaternions
::
Vector
{
Quaternion
}
module_ids
::
Set
{
Int
}
times
::
Dict
{
Int
,
Vector
{
Float64
}}
quaternions
::
Dict
{
Int
,
Vector
{
Quaternion
}}
end
function
Base.show
(
io
::
IO
,
o
::
Orientations
)
min_t
=
Inf
max_t
=
-
Inf
for
times
in
values
(
o
.
times
)
_min_t
,
_max_t
=
extrema
(
times
)
if
_min_t
<
min_t
min_t
=
_min_t
end
if
_max_t
>
max_t
max_t
=
_max_t
end
end
t₁
=
unix2datetime
(
min_t
)
t₂
=
unix2datetime
(
max_t
)
print
(
io
,
"Orientations of
$
(length(o.module_ids)) modules (
$
(t₁) to
$
(t₂))"
)
end
function
(
o
::
Orientations
)(
module_id
::
Integer
,
time
::
Real
)
times
=
o
.
times
[
module_id
]
(
time
<
first
(
times
)
||
time
>
last
(
times
))
&&
error
(
"The requested time is outside of the range of the orientations data."
)
idx2
=
searchsortedfirst
(
times
,
time
)
q2
=
o
.
quaternions
[
module_id
][
idx2
]
(
idx2
>=
length
(
times
)
||
idx2
==
1
)
&&
return
q2
idx1
=
idx2
-
1
q1
=
o
.
quaternions
[
module_id
][
idx1
]
t1
=
times
[
idx1
]
t2
=
times
[
idx2
]
Δt
=
t2
-
t1
Δt
==
0.0
&&
return
q1
t
=
(
time
-
t1
)
/
Δt
slerp
(
q1
,
q2
,
t
)
end
function
orientations
(
f
::
UnROOT
.
ROOTFile
)
q_out
=
Dict
{
Int
,
Vector
{
Quaternion
}}()
function
Base.read
(
filename
::
AbstractString
,
T
::
Type
{
Orientations
})
f
=
UnROOT
.
ROOTFile
(
filename
)
module_ids
=
Set
{
Int
}()
quaternions
=
Dict
{
Int
,
Vector
{
Quaternion
}}()
times
=
Dict
{
Int
,
Vector
{
Float64
}}()
for
(
module_id
,
t
,
a
,
b
,
c
,
d
)
in
zip
([
UnROOT
.
LazyBranch
(
f
,
"ORIENTATION/ORIENTATION/
$(b)
"
)
for
b
in
[
"id"
,
"t"
,
"JCOMPASS::JQuaternion/a"
,
"JCOMPASS::JQuaternion/b"
,
"JCOMPASS::JQuaternion/c"
,
"JCOMPASS::JQuaternion/d"
]]
...
)
if
!
haskey
(
q_out
,
module_id
)
q_out
[
module_id
]
=
Quaternion
[]
if
!
(
module_id
∈
module_ids
)
push!
(
module_ids
,
module_id
)
quaternions
[
module_id
]
=
Quaternion
[]
times
[
module_id
]
=
Float64
[]
end
push!
(
q_out
[
module_id
],
Quaternion
(
a
,
b
,
c
,
d
))
push!
(
quaternions
[
module_id
],
Quaternion
(
a
,
b
,
c
,
d
))
push!
(
times
[
module_id
],
t
)
end
q_out
T
(
module_ids
,
times
,
quaternions
)
end
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