Skip to content

Commit

Permalink
Merge branch 'master' into bokeh_plotter
Browse files Browse the repository at this point in the history
* master: (60 commits)
  Add test that shows slicing breaks cam geom and fix it (cta-observatory#782)
  fix ctapipe build failure (cta-observatory#811)
  fix package name for yaml (should be pyyaml) (cta-observatory#810)
  Implement number of islands (cta-observatory#801)
  fixed ranges of cam-display so they correspond to fixed toymodel sims (cta-observatory#808)
  Fix unknown section example warning (cta-observatory#800)
  Fix timing parameters for case when there are negative values in image (cta-observatory#804)
  Update Timing Parameters (cta-observatory#799)
  speed up unit tests that use test_event fixture (cta-observatory#798)
  Add unit to h_max in HillasReconstructor (cta-observatory#797)
  Codacy code style improvements (cta-observatory#796)
  Minor changes: mostly deprecationwarning fixes (cta-observatory#787)
  Array plotting (cta-observatory#784)
  added a config file for github change-drafter plugin (cta-observatory#795)
  Simple HESS adaptations (cta-observatory#794)
  add test for sliced geometries for hillas calculation (cta-observatory#781)
  Impact intersection (cta-observatory#778)
  updated main documentation page (cta-observatory#792)
  Implement concentration image features (cta-observatory#791)
  Fix bad builds by changing channel name (missing pyqt package) (cta-observatory#793)
  ...

# Conflicts:
#	ctapipe/calib/camera/dl1.py
  • Loading branch information
watsonjj committed Nov 9, 2018
2 parents 40c53da + 56411ae commit 7612656
Show file tree
Hide file tree
Showing 123 changed files with 8,723 additions and 3,362 deletions.
8 changes: 8 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
template: |
## What's Changed since $PREVIOUS_TAG
$CHANGES
## Contributers
$CONTRIBUTERS
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ install:
- pip install codecov
# ----- SST1M:
- conda install protobuf
- pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.44.4.tar.gz
- pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v1.4.0.tar.gz
# ----- end of SST1M
# ----- target_software
- conda install -c conda-forge cfitsio
Expand All @@ -72,6 +72,7 @@ script:
- pytest --cov=ctapipe
- ctapipe-info --version # print out the version string
- travis-sphinx -v --outdir=docbuild build --source=docs/
- ./execute_ipynbs.py

after_script:
- source deactivate
Expand Down
86 changes: 86 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,89 @@ GernotMaier
David Landriu
labsaha
Pierre Aubert
Karl Kosack <[email protected]>
Jason Watson <[email protected]>
Dan Parsons <[email protected]>
Jean Jacquemier <[email protected]>
Tino Michael <[email protected]>
Maximilian Nöthe <[email protected]>
Christoph Deil <[email protected]>
Alison Mitchell <[email protected]>
justuszorn <[email protected]>
Dominik Neise <[email protected]>
Samuel Timothy Spencer <[email protected]>
tino-michael <[email protected]>
AMWMitchell <[email protected]>
Kai Brügge <[email protected]>
Raquel de los Reyes <[email protected]>
Michele Mastropietro <[email protected]>
Jeremie DECOCK <[email protected]>
Abelardo Moralejo Olaizola <[email protected]>
tialis <[email protected]>
Markus Gaug <[email protected]>
fvisconti <[email protected]>
Wrijupan Bhattacharyya <[email protected]>
bultako <[email protected]>
Paolo Cumani <[email protected]>
Ruben Lopez-Coto <[email protected]>
Tristan Carel <[email protected]>
Franca Cassol <[email protected]>
nieto@talos <[email protected]>
Tarek Hassan <[email protected]>
Orel Gueta <[email protected]>
Miguel Nievas <[email protected]>
Michael Punch <[email protected]>
Daniel Parsons <[email protected]>
Cyril Alispach <[email protected]>
Thomas Vuillaume <[email protected]>
Konstantin Pfrang <[email protected]>
GernotMaier <[email protected]>
David Landriu <[email protected]>
Pierre Aubert <[email protected]>
labsaha <[email protected]>
thomas gasparetto <[email protected]>
thomasarmstrong <[email protected]>
Julien Lefaucheur <[email protected]>
Karl Kosack
Jason Watson
Dan Parsons
Jean Jacquemier
Tino Michael
Maximilian Nöthe
Christoph Deil
Alison Mitchell
justuszorn
Dominik Neise
Samuel Timothy Spencer
tino-michael
AMWMitchell
Kai Brügge
Raquel de los Reyes
Michele Mastropietro
Jeremie DECOCK
Abelardo Moralejo Olaizola
tialis
Markus Gaug
fvisconti
Wrijupan Bhattacharyya
bultako
Paolo Cumani
Ruben Lopez-Coto
Tristan Carel
Franca Cassol
nieto@talos
Tarek Hassan
Orel Gueta
Miguel Nievas
Michael Punch
Daniel Parsons
Cyril Alispach
Thomas Vuillaume
Konstantin Pfrang
GernotMaier
David Landriu
Pierre Aubert
labsaha
thomas gasparetto
thomasarmstrong
Julien Lefaucheur
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
=======
ctapipe |teststatus| |codacy| |coverage| |conda|
=======
.. |teststatus| image:: http://img.shields.io/travis/cta-observatory/ctapipe.svg?branch=master

.. |teststatus| image:: https://travis-ci.org/cta-observatory/ctapipe.svg?branch=master
:target: https://travis-ci.org/cta-observatory/ctapipe
:alt: Test Status
.. |codacy| image:: https://api.codacy.com/project/badge/Grade/d4f525fcb5d1421eb3a93dfa4eb5573d
Expand Down
4 changes: 0 additions & 4 deletions ctapipe/analysis/camera/chargeresolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ def __init__(self, config=None, tool=None, **kwargs):
Tool executable that is calling this component.
Passes the correct logger to the component.
Set to None if no Tool to pass.
reductor : ctapipe.calib.camera.reductors.Reductor
The reductor to use to reduce the waveforms in the event.
By default no data volume reduction is applied, and the dl0 samples
will equal the r1 samples.
kwargs
"""
super().__init__(config=config, parent=tool, **kwargs)
Expand Down
16 changes: 8 additions & 8 deletions ctapipe/calib/camera/dl0.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
transition exists as a conveniance in the pipepline and can be used to test
data volume reduction methods inside the pipeline. By default, no data volume
reduction is applied, and the DL0 samples are identical to the R1. However,
if a reductor from `ctapipe.image.reductors` is passed to the
if a reducer from `ctapipe.image.reducers` is passed to the
`CameraDL0Reducer`, then the reduction will be applied.
"""
from ctapipe.core import Component
Expand All @@ -27,18 +27,18 @@ class CameraDL0Reducer(Component):
Tool executable that is calling this component.
Passes the correct logger to the component.
Set to None if no Tool to pass.
reductor : ctapipe.calib.camera.reductors.Reductor
The reductor to use to reduce the waveforms in the event.
reducer : ctapipe.calib.camera.reducer.Reducer
The reducer to use to reduce the waveforms in the event.
By default no data volume reduction is applied, and the dl0 samples
will equal the r1 samples.
kwargs
"""
def __init__(self, config=None, tool=None, reductor=None, **kwargs):
def __init__(self, config=None, tool=None, reducer=None, **kwargs):
super().__init__(config=config, parent=tool, **kwargs)
if reductor is None:
if reducer is None:
self.log.info("Applying no data volume reduction in the "
"conversion from R1 to DL0")
self._reductor = reductor
self._reducer = reducer
self._r1_empty_warn = False

def check_r1_exists(self, event, telid):
Expand Down Expand Up @@ -84,8 +84,8 @@ def reduce(self, event):
for telid in tels:
r1 = event.r1.tel[telid].waveform
if self.check_r1_exists(event, telid):
if self._reductor is None:
if self._reducer is None:
event.dl0.tel[telid].waveform = r1
else:
reduction = self._reductor.reduce_waveforms(r1)
reduction = self._reducer.reduce_waveforms(r1)
event.dl0.tel[telid].waveform = reduction
7 changes: 1 addition & 6 deletions ctapipe/calib/camera/dl1.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,7 @@ def get_correction(self, event, telid):
# Don't apply correction when window_shift or window_width
# does not exist in extractor, or when container does not have
# a reference pulse shape
shape = event.dl0.tel[telid].waveform.shape
if shape.size != 3:
raise KeyError("this function should return 1 when "
"channel is removed from dl0")
# TODO
return np.ones(shape[0])
return np.ones(event.dl0.tel[telid].waveform.shape[0])

def calibrate(self, event):
"""
Expand Down
10 changes: 7 additions & 3 deletions ctapipe/calib/camera/r1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
of the data.
"""
from abc import abstractmethod

import numpy as np
from ...core import Component, Factory
from ...core.traits import Unicode
from ...io import EventSource
Expand Down Expand Up @@ -243,6 +243,7 @@ def __init__(self, config=None, tool=None, **kwargs):
self.log.error(msg)
raise

self._r1_wf = None
self.tc = target_calib
self.calibrator = None
self.telid = 0
Expand Down Expand Up @@ -303,10 +304,13 @@ def real_calibrate(self, event):
'non-targetio event.')

if self.check_r0_exists(event, self.telid):
samples = event.r0.tel[self.telid].waveform[0]
samples = event.r0.tel[self.telid].waveform
if self._r1_wf is None:
self._r1_wf = np.zeros(samples.shape, dtype=np.float32)
fci = event.targetio.tel[self.telid].first_cell_ids
r1 = event.r1.tel[self.telid].waveform[0]
self.calibrator.ApplyEvent(samples, fci, r1)
self.calibrator.ApplyEvent(samples[0], fci, self._r1_wf[0])
event.r1.tel[self.telid].waveform = self._r1_wf


class CameraR1CalibratorFactory(Factory):
Expand Down
9 changes: 4 additions & 5 deletions ctapipe/calib/camera/tests/test_calibrator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from copy import deepcopy
from numpy.testing import assert_allclose

from ctapipe.calib.camera import (
CameraCalibrator,
HESSIOR1Calibrator,
Expand All @@ -10,14 +10,13 @@
from ctapipe.utils import get_dataset_path


def test_camera_calibrator(test_event):
event = deepcopy(test_event) # so we don't modify the test event
def test_camera_calibrator(example_event):
telid = 11

calibrator = CameraCalibrator(r1_product="HESSIOR1Calibrator")

calibrator.calibrate(event)
image = event.dl1.tel[telid].image
calibrator.calibrate(example_event)
image = example_event.dl1.tel[telid].image
assert_allclose(image[0, 0], -2.216, 1e-3)


Expand Down
22 changes: 9 additions & 13 deletions ctapipe/calib/camera/tests/test_dl0.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from copy import deepcopy

from numpy.testing import assert_almost_equal

from ctapipe.calib.camera.dl0 import CameraDL0Reducer
Expand All @@ -11,22 +9,20 @@ def previous_calibration(event):
r1.calibrate(event)


def test_camera_dl0_reducer(test_event):
event = deepcopy(test_event)
previous_calibration(event)
def test_camera_dl0_reducer(example_event):
previous_calibration(example_event)
telid = 11

reducer = CameraDL0Reducer()
reducer.reduce(event)
waveforms = event.dl0.tel[telid].waveform
reducer.reduce(example_event)
waveforms = example_event.dl0.tel[telid].waveform
assert_almost_equal(waveforms[0, 0, 0], -0.091, 3)


def test_check_r1_exists(test_event):
event = deepcopy(test_event)
def test_check_r1_exists(example_event):
telid = 11
previous_calibration(event)
previous_calibration(example_event)
reducer = CameraDL0Reducer()
assert(reducer.check_r1_exists(event, telid) is True)
event.r1.tel[telid].waveform = None
assert(reducer.check_r1_exists(event, telid) is False)
assert (reducer.check_r1_exists(example_event, telid) is True)
example_event.r1.tel[telid].waveform = None
assert (reducer.check_r1_exists(example_event, telid) is False)
42 changes: 23 additions & 19 deletions ctapipe/calib/camera/tests/test_dl1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from copy import deepcopy

from numpy.testing import assert_allclose

from ctapipe.calib.camera.dl0 import CameraDL0Reducer
Expand All @@ -15,40 +13,46 @@ def previous_calibration(event):
dl0.reduce(event)


def test_integration_correction(test_event):
event = deepcopy(test_event)
def test_integration_correction(example_event):
telid = 11
width = 7
shift = 3
shape = event.mc.tel[telid].reference_pulse_shape
shape = example_event.mc.tel[telid].reference_pulse_shape
n_chan = shape.shape[0]
step = event.mc.tel[telid].meta['refstep']
time_slice = event.mc.tel[telid].time_slice
step = example_event.mc.tel[telid].meta['refstep']
time_slice = example_event.mc.tel[telid].time_slice
correction = integration_correction(n_chan, shape, step,
time_slice, width, shift)
assert_allclose(correction[0], 1.077, 1e-3)


def test_camera_dl1_calibrator(test_event):
event = deepcopy(test_event)
previous_calibration(event)
def test_integration_correction_no_ref_pulse(example_event):
previous_calibration(example_event)
telid = list(example_event.dl0.tel.keys())[0]
delattr(example_event, 'mc')
calibrator = CameraDL1Calibrator()
correction = calibrator.get_correction(example_event, telid)
assert correction[0] == 1


def test_camera_dl1_calibrator(example_event):
previous_calibration(example_event)
telid = 11

calibrator = CameraDL1Calibrator()

correction = calibrator.get_correction(event, telid)
correction = calibrator.get_correction(example_event, telid)
assert_allclose(correction[0], 1.077, 1e-3)

calibrator.calibrate(event)
image = event.dl1.tel[telid].image
calibrator.calibrate(example_event)
image = example_event.dl1.tel[telid].image
assert_allclose(image[0, 0], -2.216, 1e-3)


def test_check_dl0_exists(test_event):
event = deepcopy(test_event)
def test_check_dl0_exists(example_event):
telid = 11
previous_calibration(event)
previous_calibration(example_event)
calibrator = CameraDL1Calibrator()
assert(calibrator.check_dl0_exists(event, telid) is True)
event.dl0.tel[telid].waveform = None
assert(calibrator.check_dl0_exists(event, telid) is False)
assert(calibrator.check_dl0_exists(example_event, telid) is True)
example_event.dl0.tel[telid].waveform = None
assert(calibrator.check_dl0_exists(example_event, telid) is False)
Loading

0 comments on commit 7612656

Please sign in to comment.