Skip to content

Commit

Permalink
resolve merge conflicts due to #2060
Browse files Browse the repository at this point in the history
  • Loading branch information
StFroese committed Sep 21, 2022
2 parents 937e212 + b0d9b33 commit 37cfcb5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 13 deletions.
4 changes: 3 additions & 1 deletion ctapipe/io/datawriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def _get_tel_index(event, tel_id):
# (meaning readers need to update scripts)
# - increase the minor number if new columns or datasets are added
# - increase the patch number if there is a small bugfix to the model.
DATA_MODEL_VERSION = "v4.0.0"
DATA_MODEL_VERSION = "v5.0.0"
DATA_MODEL_CHANGE_HISTORY = """
- v5.0.0: - Change DL2 telescope-wise container prefixes from {algorithm}_tel to {algorithm}_tel_{kind}.
As of now, this only changes 'tel_distance' to 'tel_impact_distance'
- v4.0.0: - Changed how ctapipe-specific metadata is stored in hdf5 attributes.
This breaks backwards and forwards compatibility for almost everything.
- Container prefixes are now included for reconstruction algorithms
Expand Down
4 changes: 2 additions & 2 deletions ctapipe/io/hdf5eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@


COMPATIBLE_DATA_MODEL_VERSIONS = [
"v4.0.0",
"v5.0.0",
]


Expand Down Expand Up @@ -446,7 +446,7 @@ def _generator(self):
key: HDF5TableReader(self.file_).read(
table._v_pathname,
containers=container,
prefixes=(f"{algorithm}_tel",),
prefixes=(f"{algorithm}_tel_{kind}",),
)
for key, table in algorithm_group._v_children.items()
}
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/io/tests/test_hdf5eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ def test_read_dl2(dl2_shower_geometry_file):
assert tel_id in e.dl2.tel
assert algorithm in e.dl2.tel[tel_id].impact
impact = e.dl2.tel[tel_id].impact[algorithm]
assert impact.prefix == algorithm + "_tel"
assert impact.prefix == algorithm + "_tel_impact"
assert impact.distance is not None
3 changes: 2 additions & 1 deletion ctapipe/io/tests/test_table_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ def test_read_telescope_events_type(dl2_shower_geometry_file):
expected_ids = subarray.get_tel_ids_for_type("MST_MST_FlashCam")
assert set(table["tel_id"].data).issubset(expected_ids)
assert "equivalent_focal_length" in table.colnames
assert "HillasReconstructor_tel_distance" in table.colnames
# regression test for #2051
assert "HillasReconstructor_tel_impact_distance" in table.colnames


def test_read_telescope_events_by_type(dl2_shower_geometry_file):
Expand Down
4 changes: 3 additions & 1 deletion ctapipe/reco/reco_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ def _store_impact_parameter(self, event):
shower_geom=event.dl2.stereo.geometry[self.__class__.__name__],
subarray=self.subarray,
)
default_prefix = TelescopeImpactParameterContainer.default_prefix
prefix = f"{self.__class__.__name__}_tel_{default_prefix}"
for tel_id in event.trigger.tels_with_trigger:
tel_index = self.subarray.tel_indices[tel_id]
event.dl2.tel[tel_id].impact[
self.__class__.__name__
] = TelescopeImpactParameterContainer(
distance=impact_distances[tel_index],
prefix=f"{self.__class__.__name__}_tel",
prefix=prefix,
)
31 changes: 25 additions & 6 deletions ctapipe/tools/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import os
import sys

from .utils import get_parser
from pkg_resources import resource_filename

from ..core import Provenance, get_module_version
from ..core.plugins import detect_and_import_io_plugins
from ..utils import datasets

from pkg_resources import resource_filename
from .utils import get_parser

__all__ = ["info"]

Expand Down Expand Up @@ -56,6 +56,9 @@ def main(args=None):
"--all", dest="show_all", action="store_true", help="show all info"
)
parser.add_argument("--plugins", action="store_true", help="Print plugin info")
parser.add_argument(
"--datamodel", action="store_true", help="Print data model info"
)
args = parser.parse_args(args)

if len(sys.argv) <= 1:
Expand All @@ -73,15 +76,19 @@ def info(
system=False,
plugins=False,
show_all=False,
datamodel=False,
):
"""
Display information about the current ctapipe installation.
"""
logging.basicConfig(level=logging.INFO, format="%(levelname)s - %(message)s")
logging.basicConfig(level=logging.CRITICAL, format="%(levelname)s - %(message)s")

if version or show_all:
_info_version()

if datamodel or show_all:
_info_datamodel()

if tools or show_all:
_info_tools()

Expand Down Expand Up @@ -119,9 +126,10 @@ def _info_tools():
# full help text from the docstring or ArgumentParser?
# This is the function names, we want the command-line names
# that are defined in setup.py !???
from ctapipe.tools.utils import get_all_descriptions
from textwrap import TextWrapper

from ctapipe.tools.utils import get_all_descriptions

wrapper = TextWrapper(width=80, subsequent_indent=" " * 35)

scripts = get_all_descriptions()
Expand All @@ -148,7 +156,7 @@ def _info_dependencies():


def _info_resources():
""" display all known resources """
"""display all known resources"""

print("\n*** ctapipe resources ***\n")
print("CTAPIPE_SVC_PATH: (directories where resources are searched)")
Expand Down Expand Up @@ -209,5 +217,16 @@ def _info_plugins():
print(f"{name:>20s} -- {version}")


def _info_datamodel():
from ctapipe.io.datawriter import DATA_MODEL_CHANGE_HISTORY, DATA_MODEL_VERSION
from ctapipe.io.hdf5eventsource import COMPATIBLE_DATA_MODEL_VERSIONS

print("\n*** ctapipe data model ***\n")
print(f"output version: {DATA_MODEL_VERSION}")
print(f"compatible input versions: {', '.join(COMPATIBLE_DATA_MODEL_VERSIONS)}")
print("change history:")
print(DATA_MODEL_CHANGE_HISTORY)


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion ctapipe/tools/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,5 @@ def test_dl2(tmp_path, dl2_shower_geometry_file, dl2_proton_geometry_file):
loader = TableLoader(output, load_dl2=True, load_simulated=True)
tel_events = loader.read_telescope_events()
assert "true_impact_distance" in tel_events.colnames
assert "HillasReconstructor_tel_distance" in tel_events.colnames
# regression test for #2051
assert "HillasReconstructor_tel_impact_distance" in tel_events.colnames

0 comments on commit 37cfcb5

Please sign in to comment.