From ca37ac61686a91761e71114f52e2c97eb36ce537 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Thu, 19 May 2022 16:39:06 +0200 Subject: [PATCH 1/8] added a EastingNorthing frame --- ctapipe/coordinates/__init__.py | 8 ++- ctapipe/coordinates/ground_frames.py | 57 +++++++++++++++++++ ctapipe/coordinates/tests/test_coordinates.py | 12 ++++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/ctapipe/coordinates/__init__.py b/ctapipe/coordinates/__init__.py index 5a210b554e9..d32680ed006 100644 --- a/ctapipe/coordinates/__init__.py +++ b/ctapipe/coordinates/__init__.py @@ -10,7 +10,12 @@ import warnings from .telescope_frame import TelescopeFrame from .nominal_frame import NominalFrame -from .ground_frames import GroundFrame, TiltedGroundFrame, project_to_ground +from .ground_frames import ( + GroundFrame, + TiltedGroundFrame, + project_to_ground, + EastingNorthingFrame, +) from .camera_frame import CameraFrame, EngineeringCameraFrame @@ -21,6 +26,7 @@ "NominalFrame", "GroundFrame", "TiltedGroundFrame", + "EastingNorthingFrame", "MissingFrameAttributeWarning", "project_to_ground", ] diff --git a/ctapipe/coordinates/ground_frames.py b/ctapipe/coordinates/ground_frames.py index 7285607b8c4..27cd88eb52b 100644 --- a/ctapipe/coordinates/ground_frames.py +++ b/ctapipe/coordinates/ground_frames.py @@ -13,6 +13,7 @@ - Tests Tests Tests! """ +from astropy.coordinates import SkyCoord import astropy.units as u import numpy as np from astropy.coordinates import ( @@ -21,6 +22,7 @@ FunctionTransform, CoordinateAttribute, AltAz, + RepresentationMapping, ) from astropy.coordinates import frame_transform_graph from numpy import cos, sin @@ -29,6 +31,7 @@ "GroundFrame", "TiltedGroundFrame", "project_to_ground", + "EastingNorthingFrame", ] @@ -47,6 +50,25 @@ class GroundFrame(BaseCoordinateFrame): default_representation = CartesianRepresentation +class EastingNorthingFrame(BaseCoordinateFrame): + """GroundFrame but in standard Easting/Northing coordinates instead of + SimTel/Corsika conventions + + Frame attributes: None + + """ + + default_representation = CartesianRepresentation + + frame_specific_representation_info = { + CartesianRepresentation: [ + RepresentationMapping("x", "easting"), + RepresentationMapping("y", "northing"), + RepresentationMapping("z", "height"), + ] + } + + class TiltedGroundFrame(BaseCoordinateFrame): """Tilted ground coordinate frame. The tilted ground coordinate frame is a cartesian system describing the 2 dimensional projected @@ -200,3 +222,38 @@ def project_to_ground(tilt_system): y_projected = y_initial - trans[2][1] * z_initial / trans[2][2] return GroundFrame(x=x_projected * unit, y=y_projected * unit, z=0 * unit) + + +@frame_transform_graph.transform(FunctionTransform, GroundFrame, GroundFrame) +def ground_to_ground(ground_coords, ground_frame): + return ground_coords + + +@frame_transform_graph.transform(FunctionTransform, GroundFrame, EastingNorthingFrame) +def ground_to_easting_northing(ground_coords, eastnorth_frame): + """ + convert GroundFrame points into eastings/northings for plotting purposes + + """ + + return eastnorth_frame.realize_frame( + CartesianRepresentation( + x=-ground_coords.y, y=ground_coords.x, z=ground_coords.z + ) + ) + + +@frame_transform_graph.transform(FunctionTransform, EastingNorthingFrame, GroundFrame) +def ground_to_easting_northing(eastnorth_coords, ground_frame): + """ + convert GroundFrame points into eastings/northings for plotting purposes + + """ + + return ground_frame.realize_frame( + CartesianRepresentation( + x=eastnorth_coords.northing, + y=-eastnorth_coords.easting, + z=eastnorth_coords.height, + ) + ) diff --git a/ctapipe/coordinates/tests/test_coordinates.py b/ctapipe/coordinates/tests/test_coordinates.py index 3e76f16ac5e..116cac1ddc5 100644 --- a/ctapipe/coordinates/tests/test_coordinates.py +++ b/ctapipe/coordinates/tests/test_coordinates.py @@ -268,3 +268,15 @@ def test_ground_frame_roundtrip(): assert u.isclose(coord.x, back.x) assert u.isclose(coord.y, back.y) assert u.isclose(coord.z, back.z) + + +def test_ground_to_eastnorth_roundtrip(): + from ctapipe.coordinates import GroundFrame, EastingNorthingFrame + + ground = SkyCoord(x=[1, 2, 3], y=[-2, 5, 2], z=[1, -1, 2], frame=GroundFrame()) + eastnorth = ground.transform_to(EastingNorthingFrame()) + ground2 = eastnorth.transform_to(GroundFrame()) + + assert u.isclose(ground.x, ground2.x).all() + assert u.isclose(ground.y, ground2.y).all() + assert u.isclose(ground.z, ground2.z).all() From 35e0e69d5f5aeb91d66a6d8bae2a6ecd0f2e20f2 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Thu, 19 May 2022 16:39:35 +0200 Subject: [PATCH 2/8] improve ArrayDisplay - adds circular grid - properly label axes based on frame --- ctapipe/visualization/mpl_array.py | 65 ++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/ctapipe/visualization/mpl_array.py b/ctapipe/visualization/mpl_array.py index 5d895ec8d86..4bb42b61afa 100644 --- a/ctapipe/visualization/mpl_array.py +++ b/ctapipe/visualization/mpl_array.py @@ -62,10 +62,12 @@ def __init__( self.frame = frame self.subarray = subarray + self.axes = axes or plt.gca() # get the telescope positions. If a new frame is set, this will # transform to the new frame. - self.tel_coords = subarray.tel_coords.transform_to(frame) + self.tel_coords = subarray.tel_coords.transform_to(frame).cartesian + self.unit = self.tel_coords.x.unit # set up colors per telescope type tel_types = [str(tel) for tel in subarray.tels.values()] @@ -76,6 +78,10 @@ def __init__( for tel in subarray.tel.values() ] + self.radii = radius + else: + self.radii = np.ones(len(tel_types)) * radius + if title is None: title = subarray.name @@ -116,15 +122,22 @@ def __init__( ) plt.legend(handles=legend_elements) + self.add_radial_grid() + + # create the plot self.tel_colors = tel_color self.autoupdate = autoupdate self.telescopes = PatchCollection(patches, match_original=True) self.telescopes.set_linewidth(2.0) - self.axes = axes or plt.gca() self.axes.add_collection(self.telescopes) self.axes.set_aspect(1.0) self.axes.set_title(title) + xunit = self.tel_coords.x.unit.to_string("latex") + yunit = self.tel_coords.y.unit.to_string("latex") + xname, yname, _ = frame.get_representation_component_names().keys() + self.axes.set_xlabel(f"{xname} [{xunit}] $\\rightarrow$") + self.axes.set_ylabel(f"{yname} [{yunit}] $\\rightarrow$") self._labels = [] self._quiver = None self.axes.autoscale_view() @@ -136,12 +149,42 @@ def values(self): @values.setter def values(self, values): - """ set the telescope colors to display """ + """set the telescope colors to display""" self.telescopes.set_array(np.ma.masked_invalid(values)) self._update() + def add_radial_grid(self, spacing=100 * u.m): + # add some dotted circles for distance estimation: + + n_circles = np.round( + (np.sqrt(self.subarray.footprint / np.pi) / spacing).to_value(""), + 0, + ) + circle_radii = np.arange(1, n_circles + 2, 1) * spacing.to_value(self.unit) + circle_patches = PatchCollection( + [ + Circle( + xy=(0, 0), + radius=r, + fill=False, + fc="none", + linestyle="dotted", + color="gray", + alpha=0.1, + lw=1, + ) + for r in circle_radii + ], + color="#eeeeee", + ls="dotted", + fc="none", + lw=3, + ) + + self.axes.add_collection(circle_patches) + def set_vector_uv(self, uu, vv, c=None, **kwargs): - """ sets the vector field U,V and color for all telescopes + """sets the vector field U,V and color for all telescopes Parameters ---------- @@ -289,9 +332,17 @@ def set_line_hillas(self, hillas_dict, core_dict, range, **kwargs): def add_labels(self): px = self.tel_coords.x.to_value("m") py = self.tel_coords.y.to_value("m") - for tel, x, y in zip(self.subarray.tels, px, py): + for tel, x, y, r in zip(self.subarray.tels, px, py, self.radii): name = str(tel) - lab = self.axes.text(x, y, name, fontsize=8, clip_on=True) + lab = self.axes.text( + x, + y - r * 1.8, + name, + fontsize=8, + clip_on=True, + horizontalalignment="center", + verticalalignment="top", + ) self._labels.append(lab) def remove_labels(self): @@ -300,7 +351,7 @@ def remove_labels(self): self._labels = [] def _update(self): - """ signal a redraw if necessary """ + """signal a redraw if necessary""" if self.autoupdate: plt.draw() From 6c13047d668cb2ea7eef235392e9fded8c3ff629 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Thu, 19 May 2022 16:40:20 +0200 Subject: [PATCH 3/8] use a EastingNorthing ArrayDisplay in peek() --- ctapipe/instrument/subarray.py | 42 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/ctapipe/instrument/subarray.py b/ctapipe/instrument/subarray.py index 557040b42b0..59aab98f41e 100644 --- a/ctapipe/instrument/subarray.py +++ b/ctapipe/instrument/subarray.py @@ -90,7 +90,7 @@ def __repr__(self): @property def tel(self): - """ for backward compatibility""" + """for backward compatibility""" return self.tels @property @@ -132,7 +132,7 @@ def info(self, printer=print): @lazyproperty def tel_coords(self): - """ returns telescope positions as astropy.coordinates.SkyCoord""" + """returns telescope positions as astropy.coordinates.SkyCoord""" pos_x = np.array([p[0].to("m").value for p in self.positions.values()]) * u.m pos_y = np.array([p[1].to("m").value for p in self.positions.values()]) * u.m @@ -142,7 +142,7 @@ def tel_coords(self): @lazyproperty def tel_ids(self): - """ telescope IDs as an array""" + """telescope IDs as an array""" return np.array(list(self.tel.keys())) @lazyproperty @@ -277,8 +277,8 @@ def to_table(self, kind="subarray"): unique_types = self.telescope_types mirror_area = u.Quantity( - [t.optics.mirror_area.to_value(u.m ** 2) for t in unique_types], - u.m ** 2, + [t.optics.mirror_area.to_value(u.m**2) for t in unique_types], + u.m**2, ) focal_length = u.Quantity( [t.optics.equivalent_focal_length.to_value(u.m) for t in unique_types], @@ -334,45 +334,31 @@ def peek(self): """ from matplotlib import pyplot as plt from astropy.visualization import quantity_support + from ctapipe.visualization import ArrayDisplay + from ctapipe.coordinates.ground_frames import EastingNorthingFrame types = set(self.tels.values()) tab = self.to_table() plt.figure(figsize=(8, 8)) - - with quantity_support(): - for tel_type in types: - tels = tab[tab["tel_description"] == str(tel_type)]["tel_id"] - sub = self.select_subarray(tels, name=tel_type) - tel_coords = sub.tel_coords - radius = np.array( - [ - np.sqrt(tel.optics.mirror_area / np.pi).value - for tel in sub.tels.values() - ] - ) - - plt.scatter( - tel_coords.x, tel_coords.y, s=radius * 8, alpha=0.5, label=tel_type - ) - - plt.legend(loc="best") - plt.title(self.name) - plt.tight_layout() + ad = ArrayDisplay(subarray=self, frame=EastingNorthingFrame(), tel_scale=0.75) + ad.add_labels() + plt.title(self.name) + plt.tight_layout() @lazyproperty def telescope_types(self) -> List[TelescopeDescription]: - """ list of telescope types in the array""" + """list of telescope types in the array""" return list({tel for tel in self.tel.values()}) @lazyproperty def camera_types(self) -> List[CameraDescription]: - """ list of camera types in the array """ + """list of camera types in the array""" return list({tel.camera for tel in self.tel.values()}) @lazyproperty def optics_types(self) -> List[OpticsDescription]: - """ list of optics types in the array """ + """list of optics types in the array""" return list({tel.optics for tel in self.tel.values()}) def get_tel_ids_for_type(self, tel_type): From 00d1cd098ab1db5eee48f703b1ed80463c5079f4 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Thu, 19 May 2022 17:17:59 +0200 Subject: [PATCH 4/8] fixed imports and wrong func name --- ctapipe/coordinates/ground_frames.py | 9 ++++----- ctapipe/instrument/subarray.py | 28 +++++++++++----------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/ctapipe/coordinates/ground_frames.py b/ctapipe/coordinates/ground_frames.py index 27cd88eb52b..1bb74454b98 100644 --- a/ctapipe/coordinates/ground_frames.py +++ b/ctapipe/coordinates/ground_frames.py @@ -13,18 +13,17 @@ - Tests Tests Tests! """ -from astropy.coordinates import SkyCoord import astropy.units as u import numpy as np from astropy.coordinates import ( + AltAz, BaseCoordinateFrame, CartesianRepresentation, - FunctionTransform, CoordinateAttribute, - AltAz, + FunctionTransform, RepresentationMapping, + frame_transform_graph, ) -from astropy.coordinates import frame_transform_graph from numpy import cos, sin __all__ = [ @@ -244,7 +243,7 @@ def ground_to_easting_northing(ground_coords, eastnorth_frame): @frame_transform_graph.transform(FunctionTransform, EastingNorthingFrame, GroundFrame) -def ground_to_easting_northing(eastnorth_coords, ground_frame): +def easting_northing_to_ground(eastnorth_coords, ground_frame): """ convert GroundFrame points into eastings/northings for plotting purposes diff --git a/ctapipe/instrument/subarray.py b/ctapipe/instrument/subarray.py index 59aab98f41e..7c41ae24b21 100644 --- a/ctapipe/instrument/subarray.py +++ b/ctapipe/instrument/subarray.py @@ -1,26 +1,24 @@ """ Description of Arrays or Subarrays of telescopes """ -from typing import Dict, List, Union -from contextlib import ExitStack import warnings +from contextlib import ExitStack +from copy import copy +from itertools import groupby +from typing import Dict, List, Union +import ctapipe import numpy as np +import tables from astropy import units as u from astropy.coordinates import SkyCoord from astropy.table import QTable, Table from astropy.utils import lazyproperty -import tables -from copy import copy -from itertools import groupby -import ctapipe - -from ..coordinates import GroundFrame, CameraFrame -from .telescope import TelescopeDescription -from .camera import CameraDescription, CameraReadout, CameraGeometry +from ..coordinates import CameraFrame, GroundFrame +from .camera import CameraDescription, CameraGeometry, CameraReadout from .optics import OpticsDescription - +from .telescope import TelescopeDescription __all__ = ["SubarrayDescription"] @@ -332,13 +330,9 @@ def peek(self): """ Draw a quick matplotlib plot of the array """ - from matplotlib import pyplot as plt - from astropy.visualization import quantity_support - from ctapipe.visualization import ArrayDisplay from ctapipe.coordinates.ground_frames import EastingNorthingFrame - - types = set(self.tels.values()) - tab = self.to_table() + from ctapipe.visualization import ArrayDisplay + from matplotlib import pyplot as plt plt.figure(figsize=(8, 8)) ad = ArrayDisplay(subarray=self, frame=EastingNorthingFrame(), tel_scale=0.75) From c384f6bd92ee0e9c8df9705ea797175a2e9aff15 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Fri, 20 May 2022 15:51:36 +0200 Subject: [PATCH 5/8] use AffineTransform and improve test --- ctapipe/coordinates/ground_frames.py | 24 +++++++------------ ctapipe/coordinates/tests/test_coordinates.py | 8 ++++++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ctapipe/coordinates/ground_frames.py b/ctapipe/coordinates/ground_frames.py index 1bb74454b98..c0e15429fdd 100644 --- a/ctapipe/coordinates/ground_frames.py +++ b/ctapipe/coordinates/ground_frames.py @@ -23,6 +23,7 @@ FunctionTransform, RepresentationMapping, frame_transform_graph, + AffineTransform, ) from numpy import cos, sin @@ -228,31 +229,24 @@ def ground_to_ground(ground_coords, ground_frame): return ground_coords -@frame_transform_graph.transform(FunctionTransform, GroundFrame, EastingNorthingFrame) +@frame_transform_graph.transform(AffineTransform, GroundFrame, EastingNorthingFrame) def ground_to_easting_northing(ground_coords, eastnorth_frame): """ convert GroundFrame points into eastings/northings for plotting purposes """ - - return eastnorth_frame.realize_frame( - CartesianRepresentation( - x=-ground_coords.y, y=ground_coords.x, z=ground_coords.z - ) - ) + offset = CartesianRepresentation([0, 0, 0] * u.m) + matrix = np.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) + return matrix, offset -@frame_transform_graph.transform(FunctionTransform, EastingNorthingFrame, GroundFrame) +@frame_transform_graph.transform(AffineTransform, EastingNorthingFrame, GroundFrame) def easting_northing_to_ground(eastnorth_coords, ground_frame): """ convert GroundFrame points into eastings/northings for plotting purposes """ - return ground_frame.realize_frame( - CartesianRepresentation( - x=eastnorth_coords.northing, - y=-eastnorth_coords.easting, - z=eastnorth_coords.height, - ) - ) + offset = CartesianRepresentation([0, 0, 0] * u.m) + matrix = np.asarray([[0, 1, 0], [-1, 0, 0], [0, 0, 1]]) + return matrix, offset diff --git a/ctapipe/coordinates/tests/test_coordinates.py b/ctapipe/coordinates/tests/test_coordinates.py index 116cac1ddc5..6608f11efae 100644 --- a/ctapipe/coordinates/tests/test_coordinates.py +++ b/ctapipe/coordinates/tests/test_coordinates.py @@ -273,10 +273,16 @@ def test_ground_frame_roundtrip(): def test_ground_to_eastnorth_roundtrip(): from ctapipe.coordinates import GroundFrame, EastingNorthingFrame - ground = SkyCoord(x=[1, 2, 3], y=[-2, 5, 2], z=[1, -1, 2], frame=GroundFrame()) + ground = SkyCoord( + x=[1, 2, 3] * u.m, y=[-2, 5, 2] * u.m, z=[1, -1, 2] * u.m, frame=GroundFrame() + ) eastnorth = ground.transform_to(EastingNorthingFrame()) ground2 = eastnorth.transform_to(GroundFrame()) + assert u.isclose(eastnorth.easting, [2, -5, -2] * u.m).all() + assert u.isclose(eastnorth.northing, [1, 2, 3] * u.m).all() + assert u.isclose(eastnorth.height, [1, -1, 2] * u.m).all() + assert u.isclose(ground.x, ground2.x).all() assert u.isclose(ground.y, ground2.y).all() assert u.isclose(ground.z, ground2.z).all() From fc3146f12ed2f9e3a082a8f513fb46eed26f1630 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Fri, 20 May 2022 15:54:57 +0200 Subject: [PATCH 6/8] use constant matrices for AffineTransform --- ctapipe/coordinates/ground_frames.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ctapipe/coordinates/ground_frames.py b/ctapipe/coordinates/ground_frames.py index c0e15429fdd..3d1d4cf7dab 100644 --- a/ctapipe/coordinates/ground_frames.py +++ b/ctapipe/coordinates/ground_frames.py @@ -14,6 +14,7 @@ - Tests Tests Tests! """ import astropy.units as u +from astropy.units.quantity import Quantity import numpy as np from astropy.coordinates import ( AltAz, @@ -229,24 +230,26 @@ def ground_to_ground(ground_coords, ground_frame): return ground_coords +# Matrices for transforming between GroundFrame and EastingNorthingFrame +NO_OFFSET = CartesianRepresentation(Quantity([0, 0, 0], u.m)) +GROUND_TO_EASTNORTH = np.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) +EASTNORTH_TO_GROUND = np.asarray([[0, 1, 0], [-1, 0, 0], [0, 0, 1]]) + + @frame_transform_graph.transform(AffineTransform, GroundFrame, EastingNorthingFrame) def ground_to_easting_northing(ground_coords, eastnorth_frame): """ convert GroundFrame points into eastings/northings for plotting purposes """ - offset = CartesianRepresentation([0, 0, 0] * u.m) - matrix = np.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) - return matrix, offset + + return GROUND_TO_EASTNORTH, NO_OFFSET @frame_transform_graph.transform(AffineTransform, EastingNorthingFrame, GroundFrame) def easting_northing_to_ground(eastnorth_coords, ground_frame): """ - convert GroundFrame points into eastings/northings for plotting purposes + convert eastings/northings back to GroundFrame """ - - offset = CartesianRepresentation([0, 0, 0] * u.m) - matrix = np.asarray([[0, 1, 0], [-1, 0, 0], [0, 0, 1]]) - return matrix, offset + return EASTNORTH_TO_GROUND, NO_OFFSET From 6c2ddf693d601d7b78db32f87fca488e4b812ee8 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Fri, 20 May 2022 16:13:17 +0200 Subject: [PATCH 7/8] fix some style warnings --- ctapipe/coordinates/ground_frames.py | 2 ++ ctapipe/coordinates/tests/test_coordinates.py | 2 ++ ctapipe/instrument/subarray.py | 4 ++-- ctapipe/visualization/mpl_array.py | 10 +++++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ctapipe/coordinates/ground_frames.py b/ctapipe/coordinates/ground_frames.py index 3d1d4cf7dab..551bd853846 100644 --- a/ctapipe/coordinates/ground_frames.py +++ b/ctapipe/coordinates/ground_frames.py @@ -227,6 +227,8 @@ def project_to_ground(tilt_system): @frame_transform_graph.transform(FunctionTransform, GroundFrame, GroundFrame) def ground_to_ground(ground_coords, ground_frame): + """Null transform for going from ground to ground, since there are no + attributes of the GroundSystem""" return ground_coords diff --git a/ctapipe/coordinates/tests/test_coordinates.py b/ctapipe/coordinates/tests/test_coordinates.py index 6608f11efae..991df48acbb 100644 --- a/ctapipe/coordinates/tests/test_coordinates.py +++ b/ctapipe/coordinates/tests/test_coordinates.py @@ -257,6 +257,7 @@ def test_camera_focal_length_array(): def test_ground_frame_roundtrip(): + """test transform from sky to ground roundtrip""" from ctapipe.coordinates import GroundFrame, TiltedGroundFrame normal = SkyCoord(alt=70 * u.deg, az=0 * u.deg, frame=AltAz()) @@ -271,6 +272,7 @@ def test_ground_frame_roundtrip(): def test_ground_to_eastnorth_roundtrip(): + """Check Ground to EastingNorthing and the round-trip""" from ctapipe.coordinates import GroundFrame, EastingNorthingFrame ground = SkyCoord( diff --git a/ctapipe/instrument/subarray.py b/ctapipe/instrument/subarray.py index 7c41ae24b21..cc7c5b6d4a1 100644 --- a/ctapipe/instrument/subarray.py +++ b/ctapipe/instrument/subarray.py @@ -7,7 +7,6 @@ from itertools import groupby from typing import Dict, List, Union -import ctapipe import numpy as np import tables from astropy import units as u @@ -15,6 +14,7 @@ from astropy.table import QTable, Table from astropy.utils import lazyproperty +from .. import __version__ as CTAPIPE_VERSION from ..coordinates import CameraFrame, GroundFrame from .camera import CameraDescription, CameraGeometry, CameraReadout from .optics import OpticsDescription @@ -236,7 +236,7 @@ def to_table(self, kind="subarray"): meta = { "ORIGIN": "ctapipe.instrument.SubarrayDescription", "SUBARRAY": self.name, - "SOFT_VER": ctapipe.__version__, + "SOFT_VER": CTAPIPE_VERSION, "TAB_TYPE": kind, } diff --git a/ctapipe/visualization/mpl_array.py b/ctapipe/visualization/mpl_array.py index 4bb42b61afa..1c3b3e2c456 100644 --- a/ctapipe/visualization/mpl_array.py +++ b/ctapipe/visualization/mpl_array.py @@ -154,7 +154,15 @@ def values(self, values): self._update() def add_radial_grid(self, spacing=100 * u.m): - # add some dotted circles for distance estimation: + """add some dotted rings for distance estimation. The number of rings + is estimated automatically from the spacing and the array footprint. + + Parameters + ---------- + spacing: Quantity + spacing between rings + + """ n_circles = np.round( (np.sqrt(self.subarray.footprint / np.pi) / spacing).to_value(""), From 7b64069531de210f7e0a6a90bc02a34cc3f9f29e Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Tue, 24 May 2022 12:16:19 +0200 Subject: [PATCH 8/8] simplify transform --- ctapipe/coordinates/ground_frames.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ctapipe/coordinates/ground_frames.py b/ctapipe/coordinates/ground_frames.py index 551bd853846..8b19bb4dfba 100644 --- a/ctapipe/coordinates/ground_frames.py +++ b/ctapipe/coordinates/ground_frames.py @@ -235,7 +235,6 @@ def ground_to_ground(ground_coords, ground_frame): # Matrices for transforming between GroundFrame and EastingNorthingFrame NO_OFFSET = CartesianRepresentation(Quantity([0, 0, 0], u.m)) GROUND_TO_EASTNORTH = np.asarray([[0, -1, 0], [1, 0, 0], [0, 0, 1]]) -EASTNORTH_TO_GROUND = np.asarray([[0, 1, 0], [-1, 0, 0], [0, 0, 1]]) @frame_transform_graph.transform(AffineTransform, GroundFrame, EastingNorthingFrame) @@ -254,4 +253,4 @@ def easting_northing_to_ground(eastnorth_coords, ground_frame): convert eastings/northings back to GroundFrame """ - return EASTNORTH_TO_GROUND, NO_OFFSET + return GROUND_TO_EASTNORTH.T, NO_OFFSET