Skip to content

Commit

Permalink
Add tests for new object versions
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Oct 1, 2019
1 parent 7691acd commit 46082f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion eventio/simtel/objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
''' Implementations of the simtel_array EventIO object types '''
import numpy as np
from io import BytesIO, SEEK_END
from io import BytesIO
import struct
from ..base import EventIOObject, read_header
from ..tools import (
Expand Down
23 changes: 20 additions & 3 deletions tests/simtel/test_simtel_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_2003_v2():
# print(pixel_id, sector)


def test_2004_3_objects():
def test_2004():
from eventio.simtel.objects import PixelSettings

with EventIOFile(prod2_file) as f:
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_2008_3_objects():
assert tracking_info['range_high_alt'] == approx(2 * np.pi)


def test_2009_3_objects():
def test_2009():
from eventio.simtel.objects import TriggerInformation

with EventIOFile(prod2_file) as f:
Expand All @@ -255,6 +255,17 @@ def test_2009_3_objects():
assert 'gps_time' in data
assert 'teltrg_time_by_type' in data

with EventIOFile('tests/resources/prod4_pixelsettings_v3.gz') as f:
for o in yield_n_and_assert(f, TriggerInformation, n=10):
assert o.header.version == 3

data = parse_and_assert_consumption(o, limit=3)
assert 'plane_wavefront_compensation' in data
comp = data['plane_wavefront_compensation']
assert comp['az'] == 0
assert comp['alt'] == np.float32(np.pi / 2)
assert comp['speed_of_light'] == approx(29.97, abs=0.01)


def test_2100_3_objects():
from eventio.simtel.objects import TrackingPosition
Expand Down Expand Up @@ -288,7 +299,7 @@ def test_2010():
assert n_events > 0


def test_2011_3_objects():
def test_2011():
from eventio.simtel.objects import TelescopeEventHeader

with EventIOFile(prod2_file) as f:
Expand Down Expand Up @@ -358,6 +369,12 @@ def test_2011_3_objects():
}
'''

with EventIOFile('tests/resources/prod4_pixelsettings_v3.gz') as f:
for i, o in enumerate(yield_n_and_assert(f, TelescopeEventHeader, n=10)):
o = parse_and_assert_consumption(o, limit=3)
assert 'relative_trigger_time' in o
assert 'readout_time' in o


def test_2012_3_objects():
from eventio.simtel.objects import ADCSums
Expand Down

0 comments on commit 46082f1

Please sign in to comment.