-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from WireCell/spdir-metric
Spdir metric
- Loading branch information
Showing
11 changed files
with
1,266 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bats | ||
|
||
# This exercises the detlinegen and linegen commands of wirecell-gen. | ||
|
||
bats_load_library "wct-bats.sh" | ||
|
||
function det_make_plots () { | ||
local det="$1" ; shift | ||
local pln="$1" ; shift | ||
local theta_y="$1" ; shift | ||
local theta_xz="$1" ; shift | ||
local coords="${1:-global}"; shift | ||
|
||
local apa="0" | ||
|
||
local title="${det} apa${apa} plane${pln} y${theta_y} xz${theta_xz} $coords" | ||
local name="$(echo "$title" | tr ' ' '-' | tr -d '*')" | ||
|
||
echo "$title" | ||
|
||
wcpy gen detlinegen -d $det --apa $apa --plane $pln \ | ||
--theta_y="$theta_y" --theta_xz="$theta_xz" \ | ||
--angle-coords="$coords" \ | ||
-o "depos-$name.npz" -m "meta-$name.json" | ||
|
||
wcpy gen plot-depos -p qxz -p qxy -p qzy --title "$title" \ | ||
-o "depos-${name}.pdf" "depos-$name.npz" | ||
|
||
} | ||
|
||
@test "detlinegen plots" { | ||
cd_tmp file | ||
|
||
|
||
for det in pdsp # uboone | ||
do | ||
|
||
# Some care in iterating over angles is needed. If the track is | ||
# parallel to a global coordinate the plotter will barf. | ||
for theta_y in '10*deg' '80*deg' | ||
do | ||
for theta_xz in '10*deg' '80*deg' | ||
do | ||
|
||
# can skip global as it is same as wire-plane 2. | ||
# det_make_plots "$det" "2" "$theta_y" "$theta_xz" "global" | ||
for pln in 0 1 2 | ||
do | ||
det_make_plots "$det" "$pln" "$theta_y" "$theta_xz" "wire-plane" | ||
done | ||
done | ||
done | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env pytest | ||
|
||
import json | ||
import dataclasses | ||
from wirecell.gen import linegen | ||
from wirecell.util.codec import JsonEncoder | ||
|
||
def roundtrip_dataclass(DCType): | ||
t = DCType() | ||
d = t.to_dict() | ||
print(d) | ||
j = json.dumps(d, cls=JsonEncoder) | ||
d2 = json.loads(j) | ||
print(d2) | ||
assert d == d2 | ||
t2 = DCType.from_dict(d2) | ||
|
||
|
||
def test_trackconfig_roundtrip(): | ||
roundtrip_dataclass(linegen.TrackConfig) | ||
|
||
def test_metadata_roundtrip(): | ||
roundtrip_dataclass(linegen.TrackMetadata) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
from wirecell.util.bbox import * | ||
|
||
|
||
def test_slice(): | ||
assert slice(0,4) == union_slice(slice(0,4), slice(1,2)) # inside | ||
assert slice(0,4) == union_slice(slice(1,2), slice(0,4)) # outside | ||
assert slice(0,4) == union_slice(slice(0,1), slice(2,4)) # gap | ||
assert slice(0,4) == union_slice(slice(0,4), slice(1,4)) # overlap | ||
|
||
def test_slice(): | ||
assert np.all(np.array([0,1,2,3]) == union_array(slice(0,4), slice(1,2), order="ascending")) | ||
assert np.all(np.array([1,0,2,3]) == union_array(slice(1,2), slice(0,4), order="seen")) | ||
assert np.all(np.array([1,0,1,2,3]) == union_array(slice(1,2), slice(0,4), order=None)) | ||
assert np.all(np.array([2,3,0]) == union_array(slice(2,4), slice(0,1), order="seen")) | ||
assert np.all(np.array([3,2,1,0]) == union_array(slice(0,4), slice(1,4), order="descending")) | ||
|
||
def test_bbox(): | ||
bb1 = (slice(0,2), slice(10,12)) | ||
bb2 = (slice(3,5), slice(13,15)) | ||
u1 = union(bb1, bb2, form="slices") | ||
assert slice(0,5) == u1[0] | ||
assert slice(10,15) == u1[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env pytest | ||
|
||
from wirecell.util.peaks import * | ||
from wirecell.util.codec import JsonEncoder | ||
|
||
def roundtrip_dataclass(DCType): | ||
t = DCType() | ||
d = t.to_dict() | ||
print(d) | ||
j = json.dumps(d, cls=JsonEncoder) | ||
d2 = json.loads(j) | ||
print(d2) | ||
assert d == d2 | ||
t2 = DCType.from_dict(d2) | ||
|
||
|
||
def test_dataclasses(): | ||
roundtrip_dataclass(Peak1d) | ||
|
Oops, something went wrong.