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

Implementation of a first unit test (DL1) #34

Merged
merged 11 commits into from
Jan 21, 2020
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ install:
- python setup.py install

script:
# - pytest --cov=protopipe
- pytest --cov=protopipe
- travis-sphinx -v --outdir=docs/_build build -n --source=docs/

after_script:
Expand Down
8 changes: 8 additions & 0 deletions protopipe/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Scripts to process and write events with ctapipe
"""
from .write_dl1 import *
from .write_dl2 import *
from .build_model import *
from .model_diagnostic import *
from .make_performance import *
35 changes: 35 additions & 0 deletions protopipe/scripts/tests/test_write_dl1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Test the write_dl1 script in a variety of conditions."""
import os
import protopipe
from protopipe.scripts import write_dl1
from ctapipe.utils import get_dataset_path

# TEST FILES
# 110 events, 98 telescopes at Paranal.
# Instruments tested: LST_LST_LSTCam, MST_MST_FlashCam, SST_ASTRI_ASTRICam
GAMMA_TEST_LARGE = get_dataset_path("gamma_test_large.simtel.gz")
# WARNING: absolutely not sufficient!
# This is just the only file easily usable without external resources.
# Later on, we will need a sub-simtel file from each of the
# MC productions expected to be analyzed with protopipe.

parentdir = os.path.dirname(protopipe.__path__[0]) # where protopipe is
configs = os.path.join(parentdir, "aux/example_config_files/protopipe/")


def test_write_dl1():
"""Very bare test to see if the script reaches the end correctly.

WARNING: some of the cuts in the example config file are not optimized for
cameras other than LSTCam and NectarCam.
In any case, it is expected that in absence of fatal bugs, the script
ends successfully.
"""
exit_status = os.system(
f"python {write_dl1.__file__}\
--config_file {os.path.join(configs, 'analysis.yaml')}\
-o test_dl1.h5\
-i {os.path.dirname(GAMMA_TEST_LARGE)}\
-f {os.path.basename(GAMMA_TEST_LARGE)}"
)
assert exit_status == 0