mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-07-02 09:39:24 +09:00
update: skew (skew calculating algorithm & analysis notebook)
This commit is contained in:
parent
365f91c7a8
commit
72ac9a012a
6 changed files with 2461 additions and 440 deletions
|
@ -22,19 +22,21 @@ function get_skew(file::T) where {T <: AbstractString}
|
|||
@debug "file: $(file)"
|
||||
lines = Iterators.Stateful(eachline(file))
|
||||
|
||||
first_line = popfirst!(lines)
|
||||
# criteria: https://gitlab.cern.ch/dhashimo/PS_Board_QAQC/-/blob/master/Software_Test/project_auto_reset/QAQC_test_func.cxx?ref_type=heads#L208
|
||||
was_0_before = false
|
||||
# criteria is changed from QAQC for skew parsing
|
||||
let
|
||||
first_line = popfirst!(lines)
|
||||
time, high = _parse_line(first_line)
|
||||
if high > 0
|
||||
@debug "Unexpected first line" file
|
||||
return missing
|
||||
if high == 0
|
||||
was_0_before = true
|
||||
end
|
||||
end
|
||||
|
||||
time_and_counts = Iterators.map(_parse_line, lines)
|
||||
for (time, high) in time_and_counts
|
||||
if high >= 500
|
||||
if high == 0
|
||||
was_0_before = true
|
||||
elseif was_0_before && high >= 500
|
||||
return time
|
||||
end
|
||||
end
|
||||
|
@ -93,17 +95,14 @@ this returns Tuple of 2 `missing`s.
|
|||
function get_skew_and_riseup(file::T) where {T <: AbstractString}
|
||||
lines = Iterators.Stateful(eachline(file))
|
||||
|
||||
last_low_time = 0.0
|
||||
first_high_time = 0.0
|
||||
skew = 0.0
|
||||
last_low_time = missing
|
||||
first_high_time = missing
|
||||
skew = missing
|
||||
is_rised = false
|
||||
|
||||
let
|
||||
_time, high = _parse_line(popfirst!(lines))
|
||||
if high > 0
|
||||
@debug "Unexpected first line"
|
||||
return (missing, missing)
|
||||
elseif high == 0
|
||||
if high == 0
|
||||
last_low_time = time
|
||||
end
|
||||
end
|
||||
|
@ -112,16 +111,16 @@ function get_skew_and_riseup(file::T) where {T <: AbstractString}
|
|||
time, high = _parse_line(line)
|
||||
if high == 0
|
||||
last_low_time = time
|
||||
elseif !is_rised && high >= 500
|
||||
elseif !ismissing(last_low_time) && !is_rised && high >= 500
|
||||
skew = time
|
||||
is_rised = true
|
||||
elseif high == 1000
|
||||
elseif !ismissing(skew) && high == 1000
|
||||
first_high_time = time
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if first_high_time == 0
|
||||
if first_high_time === missing
|
||||
@debug "Clock skew out of range"
|
||||
return (missing, missing)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue