-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add EngineeringCameraFrame * Allow plotting in engineering frame * Add transform_to to CameraGeometry and use it in plotting * Rename constants * Move transformation from plotting to Geometry * Add example to the docs * Remove unused imports * Add dual-mirror case * Style fixes * Update docs * Add missing docstring
- Loading branch information
Showing
8 changed files
with
225 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
''' | ||
Tests for the conversion between camera coordinate frames | ||
''' | ||
from astropy.coordinates import SkyCoord | ||
import astropy.units as u | ||
|
||
|
||
def test_conversion(): | ||
''' | ||
Test conversion between CameraFrame and EngineeringCameraFrame | ||
''' | ||
from ctapipe.coordinates import CameraFrame, EngineeringCameraFrame | ||
|
||
coords = SkyCoord(x=[3, 1] * u.m, y=[2, 4] * u.m, frame=CameraFrame()) | ||
|
||
for coord in coords: | ||
eng_coord = coord.transform_to(EngineeringCameraFrame()) | ||
|
||
assert eng_coord.x == -coord.y | ||
assert eng_coord.y == -coord.x | ||
|
||
back = eng_coord.transform_to(CameraFrame()) | ||
assert back.x == coord.x | ||
assert back.y == coord.y | ||
|
||
eng_coord = coord.transform_to(EngineeringCameraFrame(n_mirrors=2)) | ||
|
||
assert eng_coord.x == coord.y | ||
assert eng_coord.y == -coord.x | ||
|
||
back = eng_coord.transform_to(CameraFrame()) | ||
assert back.x == coord.x | ||
assert back.y == coord.y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
''' | ||
Plot the same event in two camera displays showing the | ||
different coordinate frames for camera coordinates. | ||
''' | ||
from ctapipe.instrument import CameraGeometry | ||
from ctapipe.visualization import CameraDisplay | ||
import matplotlib.pyplot as plt | ||
from ctapipe.coordinates import EngineeringCameraFrame | ||
from ctapipe.image.toymodel import Gaussian | ||
import astropy.units as u | ||
|
||
|
||
def main(): | ||
fig, axs = plt.subplots(1, 2, constrained_layout=True, figsize=(6, 3)) | ||
|
||
model = Gaussian(0 * u.m, 0.1 * u.m, 0.3 * u.m, 0.05 * u.m, 25 * u.deg) | ||
cam = CameraGeometry.from_name('FlashCam') | ||
image, *_ = model.generate_image(cam, 2500) | ||
|
||
CameraDisplay(cam, ax=axs[0], image=image) | ||
CameraDisplay( | ||
cam.transform_to(EngineeringCameraFrame()), | ||
ax=axs[1], | ||
image=image, | ||
) | ||
|
||
axs[0].set_title('CameraFrame') | ||
axs[1].set_title('EngineeringCameraFrame') | ||
|
||
plt.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |