Skip to content

Commit

Permalink
Merge pull request #2354 from cta-observatory/tel_coord_reference_loc…
Browse files Browse the repository at this point in the history
…ation

Fill reference_location into SubarrayDescription.tel_coords
  • Loading branch information
maxnoe committed Jun 20, 2023
2 parents 623ac86 + 6a7cc29 commit b3ea362
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion ctapipe/instrument/subarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def tel_coords(self):
pos_y = [p[1].to_value(u.m) for p in self.positions.values()]
pos_z = [p[2].to_value(u.m) for p in self.positions.values()]

return SkyCoord(x=pos_x, y=pos_y, z=pos_z, unit=u.m, frame=GroundFrame())
frame = GroundFrame(reference_location=self.reference_location)

return SkyCoord(x=pos_x, y=pos_y, z=pos_z, unit=u.m, frame=frame)

@lazyproperty
def tel_ids(self):
Expand Down
10 changes: 5 additions & 5 deletions ctapipe/instrument/tests/test_subarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
TelescopeDescription,
)

LOCATION = EarthLocation(lon=-17 * u.deg, lat=28 * u.deg, height=2200 * u.m)


def create_subarray(tel_type, n_tels=10):
"""generate a simple subarray for testing purposes"""
Expand All @@ -31,11 +33,7 @@ def create_subarray(tel_type, n_tels=10):
"test array",
tel_positions=pos,
tel_descriptions=tel,
reference_location=EarthLocation(
lon=-17 * u.deg,
lat=28 * u.deg,
height=2200 * u.m,
),
reference_location=LOCATION,
)


Expand Down Expand Up @@ -65,6 +63,8 @@ def test_subarray_description(prod5_mst_nectarcam):
assert isinstance(sub.tel_coords, SkyCoord)
assert len(sub.tel_coords) == n_tels

assert sub.tel_coords.reference_location == LOCATION

subsub = sub.select_subarray([2, 3, 4, 6], name="newsub")
assert subsub.n_tels == 4
assert set(subsub.tels.keys()) == {2, 3, 4, 6}
Expand Down
1 change: 1 addition & 0 deletions docs/changes/2354.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correctly fill ``reference_location`` for ``SubarrayDescription.tel_coords``.

0 comments on commit b3ea362

Please sign in to comment.