summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/config.sh3
-rwxr-xr-xtests/roof-net.sh (renamed from tests/roof.sh)7
-rwxr-xr-xtests/roof-sim.sh14
-rw-r--r--tests/roof.json61
-rw-r--r--tests/roof.py22
-rw-r--r--tests/roof.yaml51
-rw-r--r--tests/test_file.sh11
-rw-r--r--tests/yaml2json.py19
8 files changed, 128 insertions, 60 deletions
diff --git a/tests/config.sh b/tests/config.sh
index ecb46b6..3d5dbba 100644
--- a/tests/config.sh
+++ b/tests/config.sh
@@ -1,6 +1,9 @@
uname -r | grep el7 &> /dev/null
el7=$(($? == 0))
+arch=""
+[ $el7 -ne 0 ] && arch="64"
+
ods_path=/mnt/ands/ods/bin-fedora/
vma_path=/mnt/ands/
vma_lib_path=/mnt/ands/lib64-fedora/
diff --git a/tests/roof.sh b/tests/roof-net.sh
index 12a4cfa..66faa43 100755
--- a/tests/roof.sh
+++ b/tests/roof-net.sh
@@ -5,7 +5,7 @@
bufs=800000
bufs=$((bufs * 4))
-cat roof.yaml | yq . > roof.json
+#cat roof.yaml | sed '/simulation/,$d' | yq . > roof.json
ulimit -l unlimited
echo 1000000000 > /proc/sys/kernel/shmmax # 18446744073692774399
@@ -13,4 +13,7 @@ echo 8000 > /proc/sys/vm/nr_hugepages # 0
#VMA_THREAD_MODE=3 VMA_MTU=0 VMA_RX_POLL=0 VMA_SELECT_POLL=0 VMA_RING_ALLOCATION_LOGIC_RX=20 VMA_RX_BUFS=$bufs LD_PRELOAD=$vma_lib \
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib64" GI_TYPELIB_PATH="/usr/local/lib64/girepository-1.0/" \
- python roof.py "$@"
+ python3 roof.py -c roofhw.json "$@"
+
+
+# python3 roof.py "$@"
diff --git a/tests/roof-sim.sh b/tests/roof-sim.sh
new file mode 100755
index 0000000..4374221
--- /dev/null
+++ b/tests/roof-sim.sh
@@ -0,0 +1,14 @@
+#! /bin/bash
+
+. config.sh
+
+#cat roof.yaml | yq r - -j | jq '' | sed -r '/\[$/ {:a;N;s/\]/&/;Ta;s/\n +//g;s/,(.)/, \1/}' > roof.json
+cat roof.yaml | python3 yaml2json.py | sed -r '/\[$/ {:a;N;s/\]/&/;Ta;s/\n +//g;s/,(.)/, \1/}' > roof.json
+
+LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib$arch" GI_TYPELIB_PATH="/usr/local/lib$arch/girepository-1.0/" \
+ python3 roof.py -c roof.json -o "/home/csa/roof2_data/test_data.sino/sino-%03i.tif" -n 1 "$@"
+# python3 roof.py -c roof.json -o "/home/csa/roof2_data/test_data.sino/sino-%03i.raw" -n 1 "$@"
+
+# python3 roof.py -c roof.json -o "/home/csa/roof2_data/test_data.sino/sino%i.tif" -n 1 "$@"
+
+# python3 roof.py -c roof.json "$@"
diff --git a/tests/roof.json b/tests/roof.json
index 784fb6d..d39a90f 100644
--- a/tests/roof.json
+++ b/tests/roof.json
@@ -1,28 +1,37 @@
{
- "network": {
- "protocol": "udp",
- "port": 4000,
- "streams": 16,
- "header_size": 10,
- "payload_size": 1280,
- "dataset_size": 1024000
- },
- "performance": {
- "buffer_size": 10,
- "packets_at_once": 100
- },
- "setup": {
- "planes": 2,
- "modules": 16,
- "bit_depth": 16,
- "pixels_per_module": 16,
- "samples_per_rotation": 2000000
- },
- "geometry": {
- "fan_projections": 1000,
- "fan_detectors": 432,
- "parallel_projections": 512,
- "parallel_detectors": 256,
- "detector_diameter": 216
- }
+ "hardware": {
+ "planes": 2,
+ "modules": 16,
+ "bit_depth": 16,
+ "channels_per_module": 16,
+ "samples_per_rotation": 500
+ },
+ "geometry": {
+ "detector_diameter": [216, 216],
+ "source_diameter": [360, 365],
+ "source_angle": [270, 275],
+ "source_angle_offset": 3.2,
+ "delta_x": 500,
+ "delta_z": 1200
+ },
+ "reconstruction": {
+ "parallel_projections": 512,
+ "parallel_bins": 256
+ },
+ "network": {
+ "protocol": "udp",
+ "port": 52067,
+ "streams": 16,
+ "header_size": 8,
+ "payload_size": 800
+ },
+ "performance": {
+ "buffer_size": 10,
+ "packets_at_once": 100
+ },
+ "simulation": {
+ "path": "/home/csa/roof2_data/test_data/data_%02u.dat",
+ "first_file_number": 1,
+ "header_size": 0
+ }
}
diff --git a/tests/roof.py b/tests/roof.py
index 831de7c..931c32f 100644
--- a/tests/roof.py
+++ b/tests/roof.py
@@ -1,35 +1,41 @@
import gi
+import re
import sys
import json
import argparse
+
gi.require_version('Ufo', '0.0')
from gi.repository import Ufo
from gi.repository import GObject
class RoofConfig:
- def __init__(self, config="roof.json"):
+ def __init__(self, args, config="roof.json"):
self.streams = 1
-
+ self.bit_depth = 8
+ self.convert = False if ((not args.output) or (re.compile('\.raw$').search(args.output))) else True
+ self.build = "raw" if args.plain else "ufo" if self.convert else "sino"
+
with open(config) as json_file:
cfg = json.load(json_file)
if cfg.get("network", {}).get("streams") != None:
self.streams = cfg["network"]["streams"]
- elif cfg.get("setup", {}).get("modules") != None:
+ elif cfg.get("hardware", {}).get("modules") != None:
self.streams = cfg["setup"]["modules"]
-
-config = "roof.json"
-output = None
+ if cfg.get("hardware", {}).get("bit_depth") != None:
+ self.bit_depth = cfg["hardware"]["bit_depth"]
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', dest="config", default="roof.json", help="ROOF configuration (JSON)")
parser.add_argument('-o', '--output', dest="output", default=None, help="Output file")
parser.add_argument('-n', '--number', dest="number", default=None, type=int, help="Specify number of frames to capture")
+parser.add_argument('-p', '--plain', dest="plain", default=False, type=bool, help="Plain network test (no ROOF structures)")
+#parser.add_argument('-r', '--raw', dest="raw", default=False, type=bool, help="Store raw data, ignore processed")
args = parser.parse_args()
-cfg = RoofConfig(args.config)
+cfg = RoofConfig(args, args.config)
pm = Ufo.PluginManager()
graph = Ufo.TaskGraph()
@@ -46,7 +52,7 @@ else:
if args.number is None: args.number = 5
build = pm.get_task('roof-build')
-build.set_properties(config=args.config, number=args.number)
+build.set_properties(config=args.config, number=args.number, build=cfg.build)
for id in range(cfg.streams):
read = pm.get_task('roof-read')
diff --git a/tests/roof.yaml b/tests/roof.yaml
index 2a24d08..d8a1c92 100644
--- a/tests/roof.yaml
+++ b/tests/roof.yaml
@@ -1,27 +1,40 @@
+hardware:
+ planes: 2
+ modules: 16
+ bit_depth: 16
+ channels_per_module: 16
+ samples_per_rotation: 500
+# sample_rate: 2000000
+# imaging_rate: 2000
+geometry:
+ detector_diameter: [216, 216]
+ source_diameter: [360, 365]
+ source_angle: [270, 275]
+ source_angle_offset: 3.2
+# source_angle_config: "path.xxx"
+ delta_x: 500
+ delta_z: 1200
+#optics:
+# flat_field_config: "path.xxx"
+reconstruction:
+ parallel_projections: 512
+ parallel_bins: 256
network:
protocol: udp
- port: 4000
+ port: 52067
streams: 16
- header_size: 10
- payload_size: 1280
+ header_size: 8
+ payload_size: 800
+# payload_size: 1280
# max_packet_size: 1284
- dataset_size: 1024000
+# dataset_size: 1024000
performance:
buffer_size: 10
# drop_buffers: 0
packets_at_once: 100
-#simulation:
-# first_file_number: 1
-# path: "/mnt/fast/ROOF2/roof2-data.pumpe256/meas/data_pumpe_dyn_192.168.100_%02u.dat"
-setup:
- planes: 2
- modules: 16
- bit_depth: 16
- pixels_per_module: 16
- samples_per_rotation: 2000000
-geometry:
- fan_projections: 1000
- fan_detectors: 432
- parallel_projections: 512
- parallel_detectors: 256
- detector_diameter: 216
+simulation:
+ path: "/home/csa/roof2_data/test_data/data_%02u.dat"
+ first_file_number: 1
+ header_size: 0
+# max_packet_size: 1284
+# dataset_size: 1024000
diff --git a/tests/test_file.sh b/tests/test_file.sh
index 1eb29ca..943268f 100644
--- a/tests/test_file.sh
+++ b/tests/test_file.sh
@@ -3,13 +3,14 @@
shopt -s extglob
packet_size=1280
-packets_per_dataset=50
+packets_per_dataset=25
+packets_per_file=3150
rm -f roof_test.raw
-for packet in $(seq 0 24); do
+for packet in $(seq 0 0); do
for id in $(seq 1 16); do
- name=$(ls -- *$id.@(fx|dat) | grep -P "_0?$id\.\w+")
- echo "Appending packet $packet from $name "
- dd if=$name of="roof_test.raw" bs=$packet_size count=$packets_per_dataset skip=$((packet * $packets_per_dataset)) oflag=append conv=notrunc status=none
+ name=$(ls -- *$id.@(fx|dat) | grep -P "_0?$id\.\w+" | grep -v dark | grep -v flat)
+ echo "Appending packet $packet from $name ..."
+ dd if="$name" of="roof_test.raw" bs=$packet_size count=$packets_per_dataset skip=$((packet * $packets_per_dataset)) oflag=append conv=notrunc status=none
done
done
diff --git a/tests/yaml2json.py b/tests/yaml2json.py
new file mode 100644
index 0000000..e97b472
--- /dev/null
+++ b/tests/yaml2json.py
@@ -0,0 +1,19 @@
+import sys
+import yaml
+import json
+from collections import OrderedDict
+
+def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
+ class OrderedLoader(Loader):
+ pass
+ def construct_mapping(loader, node):
+ loader.flatten_mapping(node)
+ return object_pairs_hook(loader.construct_pairs(node))
+ OrderedLoader.add_constructor(
+ yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
+ construct_mapping)
+ return yaml.load(stream, OrderedLoader)
+
+#obj = json.load(sys.stdin, object_pairs_hook=OrderedDict)
+obj = ordered_load(sys.stdin, yaml.SafeLoader)
+print(json.dumps(obj, indent=4, sort_keys=False))