Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates for timing #211

Merged
merged 35 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2caa370
updates for timing
tianluyuan Aug 18, 2023
0eb7c15
actually use the new function
tianluyuan Aug 18, 2023
8b829e6
type annotate and fix a typo
tianluyuan Aug 18, 2023
6d13a40
improt List
tianluyuan Aug 18, 2023
1240118
fix mypy error
tianluyuan Aug 18, 2023
7cd77dc
name to pulse_cleaning
tianluyuan Aug 18, 2023
3d03786
remove unused arg and revert brights threshold to 2
tianluyuan Aug 21, 2023
bb45677
Merge branch 'main' into updates_mlpd
tianluyuan Aug 23, 2023
cd6a4b5
<bot> update dependencies*.log files(s)
wipacdevbot Aug 23, 2023
47c1b85
set FIRST_NSIDE_PIXEL_EXTENSION to 0 as a placeholder
tianluyuan Aug 23, 2023
75f63ea
Merge branch 'main' into updates_mlpd
tianluyuan Aug 25, 2023
56c284b
increase relerr
tianluyuan Sep 7, 2023
b93d6e2
Merge branch 'main' into updates_mlpd
tianluyuan Sep 7, 2023
2dad125
<bot> update dependencies*.log files(s)
wipacdevbot Sep 7, 2023
a44cf6d
add hivecleaning
tianluyuan Sep 8, 2023
194b94f
small refactor
tianluyuan Sep 8, 2023
afcc98b
back out hiveclean
tianluyuan Sep 9, 2023
d361817
Merge branch 'main' into updates_mlpd
tianluyuan Sep 13, 2023
49ddb43
remove check in tests.yml
tianluyuan Sep 13, 2023
21db106
update some of the test reference values
tianluyuan Sep 13, 2023
0c1b494
remove unused npz results. tighten tolerances a bit. update a few mor…
tianluyuan Sep 13, 2023
4e6c21b
update some deprecated I3Tray imports
tianluyuan Sep 13, 2023
4b7cb78
update last test reference
tianluyuan Sep 13, 2023
2c3e540
bump EWMS_PILOT_TASK_TIMEOUT in env-vars.sh
tianluyuan Sep 14, 2023
9d708f2
use default wait for first mesasge
tianluyuan Sep 14, 2023
53935b6
update deprecated from I3Tray
tianluyuan Sep 14, 2023
d92bedf
set the TIMEOUT_FROM_CLEINTS
tianluyuan Sep 14, 2023
178ef91
bump ewms 0.12.1
tianluyuan Sep 15, 2023
4b70107
bump ewms 0.12.2
tianluyuan Sep 15, 2023
630c9a5
<bot> update dependencies*.log files(s)
wipacdevbot Sep 15, 2023
276703f
free disk space
ric-evans Sep 18, 2023
addb35f
<bot> update dependencies*.log files(s)
wipacdevbot Sep 18, 2023
11526cb
try 10GB swap
ric-evans Sep 18, 2023
4fee488
try `actionhippie/swap-space@v1`
ric-evans Sep 18, 2023
092011a
update test values
tianluyuan Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,8 @@ jobs:
cd ./resources/launch_scripts
./local-scan.sh

- name: test output against known result (.npz/.json)
- name: test output against known result (.json)
run: |
if [[ ${{ matrix.reco_algo }} == 'millipede_wilks' ]]; then
if [[ $(date +"%s") -gt 1695235370 ]]; then
echo "Date and time (GMT): Wednesday, September 20, 2023 18:42:50"
echo "tests should pass nowish, ping Tianlu about the ftp-v1 timing spline table fix"
exit 1
else
exit 0
fi
fi

ls $SKYSCAN_OUTPUT_DIR
# get newest run*.json
outfile=$(find $SKYSCAN_OUTPUT_DIR -type f -name "run*.json" -exec stat -c '%y %n' {} + | sort | tail -1 | awk '{print $4}')
Expand Down Expand Up @@ -531,4 +521,4 @@ jobs:
git_committer_email: ${{ env.BOT_EMAIL }}
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
# repository_username: __token__
# repository_password: ${{ secrets.PYPI_TOKEN }}
# repository_password: ${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion skymap_scanner/client/reco_icetray.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pathlib import Path
from typing import Any, List, Union

from I3Tray import I3Tray # type: ignore[import]
from icecube.icetray import I3Tray # type: ignore[import]
from icecube import ( # type: ignore[import] # noqa: F401
dataio,
frame_object_diff,
Expand Down
51 changes: 49 additions & 2 deletions skymap_scanner/recos/common/pulse_proc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import copy
import numpy
from typing import Final, Union
from typing import Final, Union, List

from I3Tray import I3Units # type: ignore[import]
from icecube.icetray import I3Units # type: ignore[import]
from icecube import dataclasses # type: ignore[import]


Expand Down Expand Up @@ -77,3 +77,50 @@ def late_pulse_cleaning(
frame[output_pulses_name + "TimeRange"] = copy.deepcopy(
frame[orig_pulses_name + "TimeRange"]
)


def pulse_cleaning(
frame,
input_pulses_name: str,
output_pulses_name: str,
residual,
):
pulses = dataclasses.I3RecoPulseSeriesMap.from_frame(frame, input_pulses_name)
mask = dataclasses.I3RecoPulseSeriesMapMask(frame, input_pulses_name)
counter, charge = 0, 0
qtot = 0
times = dataclasses.I3TimeWindowSeriesMap()
all_ts: List[float] = []
all_cs: List[float] = []
for omkey, ps in pulses.items():
ts = numpy.asarray([p.time for p in ps])
all_ts.extend(ts)
cs = numpy.asarray([p.charge for p in ps])
all_cs.extend(cs)
tw_start = weighted_quantile(numpy.asarray(all_ts), numpy.asarray(all_cs), 0.1) - 1000
tw_stop = weighted_quantile(numpy.asarray(all_ts), numpy.asarray(all_cs), 0.95) + 1000
for omkey, ps in pulses.items():
ts = numpy.asarray([p.time for p in ps])
cs = numpy.asarray([p.charge for p in ps])
median = weighted_median(ts, cs)
dts = numpy.ediff1d(ts)
median_dts = numpy.median(dts)
qtot += cs.sum()
for p in ps:
if median_dts > 1200 and len(dts) > 1:
# attempt to mask out correlated noise
mask.set(omkey, p, False)
elif p.time >= (latest_time := min(median + residual, tw_stop)) or p.time < tw_start:
if omkey not in times:
tws = dataclasses.I3TimeWindowSeries()
tws.append(
dataclasses.I3TimeWindow(latest_time, numpy.inf)
) # this defines the **excluded** time window
times[omkey] = tws
mask.set(omkey, p, False)
counter += 1
charge += p.charge

frame[output_pulses_name] = mask
frame[output_pulses_name + "TimeWindows"] = times
frame[output_pulses_name + "TimeRange"] = dataclasses.I3TimeWindow(tw_start, tw_stop)
2 changes: 1 addition & 1 deletion skymap_scanner/recos/common/vertex_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from icecube import dataclasses # type: ignore[import]
from I3Tray import I3Units # type: ignore[import]
from icecube.icetray import I3Units # type: ignore[import]


class VertexGenerator:
Expand Down
2 changes: 1 addition & 1 deletion skymap_scanner/recos/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time
from typing import List, Final

from I3Tray import I3Units # type: ignore[import]
from icecube.icetray import I3Units # type: ignore[import]
from icecube import ( # type: ignore[import] # noqa: F401
dataclasses,
frame_object_diff,
Expand Down
2 changes: 1 addition & 1 deletion skymap_scanner/recos/millipede_original.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy

from I3Tray import I3Units
from icecube.icetray import I3Units
from icecube import ( # noqa: F401
VHESelfVeto,
dataclasses,
Expand Down
34 changes: 20 additions & 14 deletions skymap_scanner/recos/millipede_wilks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import Final, List, Tuple

import numpy
from I3Tray import I3Units
from icecube.icetray import I3Units
from icecube import ( # noqa: F401
VHESelfVeto,
dataclasses,
Expand All @@ -22,14 +22,14 @@
millipede,
photonics_service,
recclasses,
simclasses,
simclasses
)
from icecube.icetray import I3Frame

from .. import config as cfg
from ..utils.pixel_classes import RecoPixelVariation
from . import RecoInterface, VertexGenerator
from .common.pulse_proc import mask_deepcore, late_pulse_cleaning
from .common.pulse_proc import mask_deepcore, pulse_cleaning

class MillipedeWilks(RecoInterface):
"""Reco logic for millipede."""
Expand All @@ -38,11 +38,13 @@ class MillipedeWilks(RecoInterface):
FTP_ABS_SPLINE = "cascade_single_spice_ftp-v1_flat_z20_a5.abs.fits"
FTP_PROB_SPLINE = "cascade_single_spice_ftp-v1_flat_z20_a5.prob.fits"
FTP_EFFD_SPLINE = "cascade_effectivedistance_spice_ftp-v1_z20.eff.fits"
FTP_EFFP_SPLINE = "cascade_effectivedistance_spice_ftp-v1_z20.prob.fits"
FTP_TMOD_SPLINE = "cascade_effectivedistance_spice_ftp-v1_z20.tmod.fits"

SPLINE_REQUIREMENTS = [FTP_ABS_SPLINE, FTP_PROB_SPLINE, FTP_EFFD_SPLINE]
SPLINE_REQUIREMENTS = [FTP_ABS_SPLINE, FTP_PROB_SPLINE, FTP_EFFD_SPLINE,
FTP_EFFP_SPLINE, FTP_TMOD_SPLINE]
# Constants ########################################################

pulsesName_orig = cfg.INPUT_PULSES_NAME
pulsesName = cfg.INPUT_PULSES_NAME + "IC"
pulsesName_cleaned = pulsesName+'LatePulseCleaned'

Expand All @@ -65,12 +67,16 @@ def setup_reco(self):
abs_spline: str = datastager.get_filepath(self.FTP_ABS_SPLINE)
prob_spline: str = datastager.get_filepath(self.FTP_PROB_SPLINE)
effd_spline: str = datastager.get_filepath(self.FTP_EFFD_SPLINE)
effp_spline: str = datastager.get_filepath(self.FTP_EFFP_SPLINE)
tmod_spline: str = datastager.get_filepath(self.FTP_TMOD_SPLINE)

self.cascade_service = photonics_service.I3PhotoSplineService(
abs_spline, prob_spline, timingSigma=0.0,
effectivedistancetable = effd_spline,
tiltTableDir = os.path.expandvars('$I3_BUILD/ice-models/resources/models/ICEMODEL/spice_ftp-v1/'),
quantileEpsilon=1
quantileEpsilon=1,
effectivedistancetableprob = effp_spline,
effectivedistancetabletmod = tmod_spline
)

self.muon_service = None
Expand Down Expand Up @@ -172,17 +178,17 @@ def skipunhits(frame, output, pulses):

frame[output] = unhits

tray.Add(skipunhits, output='OtherUnhits', pulses=cls.pulsesName)
ExcludedDOMs.append('OtherUnhits')

##################

tray.AddModule(late_pulse_cleaning, "LatePulseCleaning",
tray.AddModule(pulse_cleaning, "LatePulseCleaning",
input_pulses_name=cls.pulsesName,
output_pulses_name=cls.pulsesName_cleaned,
orig_pulses_name=cls.pulsesName_orig,
residual=1.5e3*I3Units.ns)
return ExcludedDOMs + [cls.pulsesName_cleaned+'TimeWindows']
ExcludedDOMs.append(cls.pulsesName_cleaned+'TimeWindows')

tray.Add(skipunhits, output='OtherUnhits', pulses=cls.pulsesName_cleaned)
ExcludedDOMs.append('OtherUnhits')
return ExcludedDOMs


@icetray.traysegment
def traysegment(self, tray, name, logger, seed=None):
Expand All @@ -207,7 +213,7 @@ def notify0(frame):
Pulses=self.pulsesName_cleaned,
BinSigma=2,
MinTimeWidth=25,
RelUncertainty=0.3)
RelUncertainty=1)

tray.AddService('I3GSLRandomServiceFactory','I3RandomService')

Expand Down
2 changes: 1 addition & 1 deletion skymap_scanner/recos/splinempe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Final, List


from I3Tray import I3Units # type: ignore[import]
from icecube.icetray import I3Units # type: ignore[import]

# NOTE: icecube module imports are required to make IceTray modules and services available.
from icecube import ( # type: ignore[import] # noqa: F401
Expand Down
2 changes: 1 addition & 1 deletion skymap_scanner/server/start_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import healpy # type: ignore[import]
import mqclient as mq
import numpy
from I3Tray import I3Units # type: ignore[import]
from icecube.icetray import I3Units # type: ignore[import]
from icecube import ( # type: ignore[import]
astro,
dataclasses,
Expand Down
2 changes: 1 addition & 1 deletion skymap_scanner/utils/prepare_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
from typing import Union, List

from I3Tray import I3Tray # type: ignore[import]
from icecube.icetray import I3Tray # type: ignore[import]
from icecube import icetray # type: ignore[import]
from icecube.frame_object_diff.segments import uncompress # type: ignore[import]

Expand Down
2 changes: 1 addition & 1 deletion tests/compare_scan_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from skyreader import SkyScanResult
from wipac_dev_tools import logging_tools

RTOL_PER_FIELD = {"llh": 0.18, "E_in": 0.7, "E_tot": 0.7}
RTOL_PER_FIELD = {"llh": 0.15, "E_in": 0.1, "E_tot": 0.1}


def read_file(filepath: Path) -> SkyScanResult:
Expand Down
Binary file modified tests/data/reco_pixel_pkls/millipede_wilks/BRONZE/pix.out.pkl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,77 @@
"E_tot"
],
"data": [
[
[
0,
333.8115059639348,
8563.892342009616,
8563.892342009616
126.38114632411437,
5241.262194364837,
5241.262194364837
],
[
1,
333.7291416388994,
14753.6997025439,
14753.6997025439
125.18614261171011,
4770.901739386568,
97317068489.0751
],
[
2,
324.54558625576686,
7264.871600857262,
10515.68731299288
120.5334856322618,
4541.573130514726,
4541.573130514726
],
[
3,
334.7846753468303,
6598.2632814149565,
7577.056152015813
127.51615963455372,
5157.642800402355,
5201.420713265329
],
[
4,
327.8656127148552,
7229.275061582002,
14185.14125705467
120.58305726767188,
4179.421962017046,
17697.095837204422
],
[
5,
325.29146978913224,
9977.181123899314,
7895763.342219342
125.55386417676894,
5401.557410295537,
5401.557410295537
],
[
6,
331.5395815324554,
7454.208046150723,
50303.60385834099
120.81547847480626,
4470.270273289149,
14979.397763776346
],
[
7,
324.70916170926915,
11017.804391750058,
18576754.509056866
124.2783280347043,
5712.5845051136175,
5712.5845051136175
],
[
8,
311.3694736493094,
8137.554624196082,
9797.958766249872
116.42702192317712,
3800.472255088158,
3800.472255088158
],
[
9,
324.84472870443784,
6282.414244617621,
964695010.097
125.83301174352532,
4415.348401578086,
4415.348401578086
],
[
10,
329.011384345754,
7206.515271762042,
7206.515271762042
124.16439913624171,
4295.2972095867735,
4295.2972095867735
],
[
11,
323.2556751592042,
354786.45979516796,
354786.45979516796
120.79128966342194,
3607.4755539002545,
4978041313.265813
]
],
"metadata": {
Expand All @@ -89,4 +89,4 @@
"is_real_event": false
}
}
}
}
Loading