-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusion with Camera Coordinates and Rotations #255
Comments
That sounds reasonable. It was mainly done this way so that we could draw the camera correctly in the display, but if we have a proper coordinate transform system, we can just apply that before displaying (which makes more sense and is more general) |
@ParsonsRD & @kosack Maybe model-type analyses need the pixel positions in sky coordinates? I would argue to keep separate paths for analyses which require pixel translations/rotations and the much faster analyses which don't. |
In this case, it's a quirk of the MC simulations, which are not in camera coordinates, but in some rotated camera coordinate system that is different for each camera (to keep the hexagons aligned I think), so you do still need to do one derotation from MC coordinates to Camera coordinates when you first read them. You could also track that extra rotation for the hillas params, but it would be quite confusing. We should however support rotating hillas params when going to other coordinate systems, to avoid lots of pixel transforms. |
Hi, yeah this 100 deg rotation factor can make things a bit difficult. To be honest I think it would be a little nicer if we draw the cameras, to do so in the true pixel positions in the camera. Which would be a bit nicer when comparing the image in a camera with a rotation to one without. That would require rotating the pixels in the drawing routine which may be a bit of a pain. With regards to calculating the Hillas parameters in the current scheme (which I admit it is not optimal) it is as fast to convert all the pixel positions to the nominal system. But this will likely not be the case in the future so I will into the conversion of the Hillas parameter objects, this should be fairly simple I think. |
Ok, I'm trying to fix the camera and pixel rotations, as well as writing out nicer cached camera files and I'm a bit confused as to the meaning of each. If I understand correctly. the pixel positions in simtelarray output files should be the correct positions, assuming the camera is installed on the telescope (so no de-rotation should be done), even though we do it now. Therefore I should remove the derotation done when loading the The pixel rotation angle is I guess the one needed to draw hexagons (or rectangles) aligned to the right frame. Is that correct? So it should be applied in the visualization routines. So then, we have pixel_rotation applied in CameraDisplay, and camera rotation is not used at all (correct?) |
In the LST camera one corner-to-corner line must be vertical, as you look
at the camera from the mirror, with the telescope in parking position. From
the HESS camera coordinate system (in which two flat sides of the LST
camera are horizontal), this corresponds to x = -y_hess; y =
-x_hess
…On 18 May 2017 at 15:53, Karl Kosack ***@***.***> wrote:
Better asked: should the LST cam look like this:
[image: lst_a]
<https://cloud.githubusercontent.com/assets/11677812/26205468/1a9d735a-3be2-11e7-95c7-2668308ecdf5.png>
or this:
[image: lst_b]
<https://cloud.githubusercontent.com/assets/11677812/26205473/1fa9ad0a-3be2-11e7-9681-ec5e88ceba83.png>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#255 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANghOkNQKF_UW-_rOBQZq32-zET21K6Vks5r7E1ygaJpZM4K3840>
.
--
Abelardo Moralejo Olaizola
Institut de Física d'Altes Energies
Tel : +34 931641662
Fax: +34 935811938
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
--
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
|
So probably the answer to your question is just: the second one! :) Still, I think it would be nice to have camera displays with the option to show cameras in their "natural" orientation as viewed in parking position. |
But this does not seem to be how the LST camera is defined in the simulation configs.
When Konrad defines the pixel positions he does so, such that the flat size of the hexagon runs along the top of the camera. Then during the reading of the config file he rotates the position of each by 100 deg. So the actual position he uses in sim_telarray is the upper picture. The camera rotation value is only there to make it easier for the rotation value to change and to define the points on a hexagonal grid. |
On 18 May 2017 at 17:36, Dan Parsons ***@***.***> wrote:
But this does not seem to be how the LST camera is defined in the
simulation configs.
# Camera rotation angle [deg].
# New Keyword: Requires 2012-08-21 or newer sim_telarray AND hessio[xxx].
# Rotates the whole camera with all the pixels by the given angle.
# Note that Hillas parameters are given in the 'de-rotated' system
# to avoid portability issues of analysis programs.
Rotate 100.893
When Konrad defines the pixel positions he does so, such that the flat
size of the hexagon runs along the top of the camera. Then during the
reading of the config file he rotates the position of each by 100 deg. So
the actual position he uses in sim_telarray is the upper picture.
Konrad can clarify it, but I do think that the simulation is done
properly, according to the LST design, i.e. "one corner up" as viewed from
the mirror in park position. This means that, when pointed to zenith (from
park), the x,y "hess" camera system matches Corsika's x,y.
…--
Abelardo Moralejo Olaizola
Institut de Física d'Altes Energies
Tel : +34 931641662
Fax: +34 935811938
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
--
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
|
Trying to be a bit more precise, @moralejo when you say :
you mean this for LSTs on CTA-North, which have parking position towards the North? So that when the telescope unparks to Zenith, "up" is pointing South. For CTA-South, where the telescopes a parked pointing South, when the telescope unparks to Zenith then "up" is pointing North! No? |
I just checked the Corsika coordinate system, and in the original document by Heck, Knapp et al they give:
... so it's not even true North (?!). Simtelarray's coordinate system is maybe more relevant, but I can't find the description of this! Does anyone know it, or where to find it (or just ask Konrad!) |
On 19 May 2017 at 10:24, mdpunch ***@***.***> wrote:
Trying to be a bit more precise, @moralejo <https://github.com/moralejo>
when you say :
This means that, when pointed to zenith (from park), the x,y "hess" camera
system matches Corsika's x,y.
you mean this for LSTs on CTA-North, which have parking position towards
the North? So that when the telescope unparks to Zenith, "up" is pointing
South.
For CTA-South, where the telescopes a parked pointing South, when the
telescope unparks to Zenith then "up" is pointing North!
Indeed :) To be more precise, it is "when you point to zenith going up
from the Nort direction" (instead of "from park"). Sorry for that!
Note also that the hess camera system hence corresponds to the camera as
"viewed from behind".
…--
Abelardo Moralejo Olaizola
Institut de Física d'Altes Energies
Tel : +34 931641662
Fax: +34 935811938
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
--
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
|
Hi,
In the second e-mail below, Konrad also added the attached plots of all the cameras.
Karl, regarding your camera plot, if I am not mistaken, the second plot is correct up to a 90 degree rotation, as seen in the plot attached below. |
Summary of Konrad's mail,
Everything else should follow, no (if we adopt Konrad's conventions)? |
But, this is maybe different from the conventions used by others. e.g. MAGIC? http://www.astro.uni-wuerzburg.de/wikineu/index.php/Coordinate_Systems where on the sky y is up and x is in the -ve azimuth direction. So, rotated 90° anti-clockwise w.r.t. Konrad's. Is there a "CTA convention"? |
@GernotMaier could you tell us what the convention is in EventDisplay? |
A definition of the CTA coordinate systems (or at least a documentation) is overdue since years. If one of you would volunteer? Eventdisplay uses the definition from the grisudet detector simulations. Here the description from the manual: We use three connected coordinate systems associated with the atmospheric shower, the ground, and the telescope, respectively. The shower record in the output of cherenkf.c describes the primary and associated photons in a coordinate system located at the telescope with the z-axis pointed down, the x-axis to the East, and the y-axis pointed South. Upon reading the shower record, grisudet immediately converts the shower and photon information to its standard ground coordinate system: z-axis pointed to the zenith, x-axis to the East, and y-axis pointed North. The third reference system, the reference system attached to the telescope, coincides with the standard ground coordinate system when the telescope is pointed to the zenith. For non-zenith primary showers, the telescope rotates its optical axis to point in a direction parallel to the shower line, first by a rotation about its z axis to place its y axis in the plane created by the vertical axis and the direction of the incoming primary. A following rotation about the new x axis (which is still in the horizontal plane) points the telescope z axis in the direction of the primary. The rotation point of the telescope is located on its optical axis a distance equal to the "telescope center offset" below the focal point of the telescope. The horizontal plane through the rotation point defines the ground location of the telescope. (see http://www.physics.utah.edu/gammaray/GrISU/GrISU/Documentation/GrISUDet/gri_codeparameters.html) |
Sigh... So everyone is different? Do I have this right, on the Sky Frame (perpendicular to optical axis):
Which means, we are free to do as we like! This xkcd on standards is appropriate: After reflection, I though that maybe the best would be to keep as close as possible to astropy conventions. Then working along these lines, I found this: Maybe we could adopt something like this as the CTA convention, so for the coordinates in the Horizon frame:
The consider a telescope pointing a Azimuth 0 degrees, Zenith 1 degree
... which becomes the same as Konrad's convention, I think (z is then outwards towards the source). So, in sum, x/y is the same as Alt/Az Comments? |
On 20 May 2017 at 18:27, mdpunch ***@***.***> wrote:
Sigh... So everyone is different? Do I have this right, on the Sky Frame
(perpendicular to optical axis):
- Konrad: *x* up, *y* right
- Abelardo: *x* down, *y* left
I think Konrad's is right, ours not. For us, on the camera plane, as
viewed from the mirror, x is right and y is up. This means that on the sky
frame x is left and y is down.
- Gernot: *x* left, *y* up
(I had forgotten that Whipple defines Azimuth from East, differently
to standard)
Which means, we are free to do as we like!
This xkcd on standards is appropriate:
https://xkcd.com/927/
After reflection, I though that maybe the best would be to keep as close as
possible to astropy conventions. Then working along these lines, I found
this:
http://gamma-astro-data-formats.readthedocs.io/en/latest/
general/coordinates.html
... which is the work from Christoph Deil & co.
Maybe we could adopt something like this as the CTA convention, so for the
coordinates in the Horizon frame:
- Azimuth zero at North, increasing towards East (clockwise)
- *x* at North (corresponding to zero Azimuth)
- *z* towards Zenith
- *y* at West (to keep a right-handed system)
Ok, xyz is like Corsika's except for the difference between magnetic and
geographic north.
The consider a telescope pointing a Azimuth 0 degrees, Zenith 1 degree
... in the Camera Sky frame, then:
- *x* points away from North (so on the Sky, up / towards Zenith / in
positive Elevation direction)
- *y* points away from West (so on the Sky, right / in positive
Azimuth direction)
... which becomes the same as Konrad's convention, I think (z is then
outwards towards the source).
Comments?
I think both Konrad's camera system (for its easy relation to Corsika's)
and the one we use (for its intuitiveness as the natural system when
looking towards the camera) are useful, and both should be defined. The
latter is the natural choice when displaying single cameras, whereas the
former is what you need when displaying e.g. an "array view" from above,
showing the images in different cameras at the corresponding telescope
positions. This is for single-mirror telescopes.
For double-mirror telescopes Konrad's camera system is such that images
appear "as if" it was a single-mirror telescope, so that no change is
needed in the transformations leading to reconstruction. Our system relates
to Konrad's in the same way as for single mirror telescopes, x => -y, y
=>-x, but I am not sure that "makes sense" in terms of camera access for
double-mirror telescopes.
…--
Abelardo Moralejo Olaizola
Institut de Física d'Altes Energies
Tel : +34 931641662 <931%2064%2016%2062>
Fax: +34 935811938 <935%2081%2019%2038>
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
--
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
|
This all points to needing a common description of camera coordinates from the camera groups. Is there one? It should probably go in Jama somewhere if so. It would need to specify which way is "up" and "left", what angles are needed (e.g. a pixel rotation at least to show which way the hexagons of the winston cones align, for cameras that have them), and how to map to SimTelArray coordinates (which may not be the same definition?) I'm still a bit confused as to the "natural" position: you said the LSTCam should have vertical edge lines, but in the second figure there are only horizontal ones, so is there still a mirroring of coordinates or a bad rotation? |
On 23 May 2017 at 10:16, Karl Kosack ***@***.***> wrote:
Still, I think it would be nice to have camera displays with the option to
show cameras in their "natural" orientation as viewed in parking position.
This all points to needing a common description of camera coordinates from
the camera groups. Is there one? It should probably go in Jama somewhere if
so. It would need to specify which way is "up" and "left", what angles are
needed (e.g. a pixel rotation at least to show which way the hexagons of
the winston cones align, for cameras that have them), and how to map to
SimTelArray coordinates (which may not be the same definition?)
I'm still a bit confused as to the "natural" position: you said the LSTCam
should have vertical edge lines, but in the second figure there are only
horizontal ones, so is there still a mirroring of coordinates or a bad
rotation?
The second figure is in the Konrad's coordinates we have discussed; the
first one is simply a rotated system in which the *pixel* hexagons have two
vertical sides.
The LSTCam has two vertical *camera *sides "in the real world", e.g. in
park position. And it is also true in the simulation, when you consider the
definition of Konrad's camera system.
…--
Abelardo Moralejo Olaizola
Institut de Física d'Altes Energies
Tel : +34 931641662
Fax: +34 935811938
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
--
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
|
Can you point me to where Konrad's system is defined and where the "natural" one is defined? I guess I'd prefer "natural" as the standard CameraSystem. I assume there is a flip in either x or y between the two? Are the coordinates defined as if looking at the camera, or through it? What about SC telescopes? We just have to be consistent and make sure the reconstruction treats it correctly. |
Perhaps the newer plots below from Konrad can help clarify the relation between the simulation coordinate system to the "natural" one. |
If we just have look at the sky, and forget about cameras, then everyone will know what AltAz axes are in the sky plane. Is this what you mean by "looking through the camera", Karl? For a 1-mirror camera, everything on the sky becomes a mirror image (translation through the optical axis), so that on the camera we have, looking from the front to an image on the focal plane or on the lid: For a 2-mirror camera, I think it's just a double mirroring, so the camera looks like the sky if you stand in front of it (except you'll get in the way!). So <x = Az> and <y = Alt>. So, maybe don't think of Konrad's coordinate system as xy, but as AltAz. |
On 23 May 2017 at 14:31, Karl Kosack <notifications@github.com> wrote:
I guess I'd prefer "natural" as the standard CameraSystem.
I assume there is a flip in either x or y between the two?
The transformation is x' = -y; y' = -x
Are the coordinates defined as if looking at the camera, or through it?
The x and y in Konrad's system are well oriented when you look at the
camera from behind.
In the camera system we use (in MARS) they are well oriented (x is right,
y is up) when you look *into *the focal plane.
What about SC telescopes? We just have to be consistent and make sure the
reconstruction treats it correctly.
Regarding reconstruction, for the simulated events the trick is done
already by Konrad through the pixel coordinates. For SC cameras, he
defines the pixel coordinates in the simulation such that for the
reconstruction they can be treated exactly the same as if they were pixels
of a single-mirror telescope (using a certain equivalent focal length).
That is, if you plot a shower image as seen by an SCT and by an MST in the
same location, using the pixel coordinates as given by simtelarray, the two
images will be in the same area of the cameras and have the same
orientation.
for displaying purposes, what we need is to know what SC telescope teams
consider the natural coordinate system for their cameras.
…--
Abelardo Moralejo Olaizola
Institut de Física d'Altes Energies
Tel : +34 931641662
Fax: +34 935811938
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
--
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
|
So, turning by 90 and flipping y is the same as just making a mirror image through zero and then swapping the names of the coordinates. |
@moralejo Abelardo
Not sure what you mean by "well-oriented". In Konrad's system, the first coordinate is on the vertical axis, which if you call it x is not, I think, what Karl means by "Natural" These discussions of coordinate systems don't go very well by this forum, I think, it would be much easier if we were all in front of a whiteboard! |
On 23 May 2017 at 16:24, mdpunch ***@***.***> wrote:
@moralejo <https://github.com/moralejo> Abelardo
The x and y in Konrad's system are well oriented when you look at the
camera from behind.
Not sure what you mean by "well-oriented".
I mean that a 90-degree counter-clockwise rotation of the x-axis would
bring it on top of the y axis. Sorry for the sloppy wording.
In Konrad's system, the first coordinate is on the vertical axis, which if
you call it x is not, I think, what Karl means by "Natural"
We agree. What we say is that the natural way of displaying camera images
is the following:
x = -y_konrad
y = -x_konrad
…--
Abelardo Moralejo Olaizola
Institut de Física d'Altes Energies
Tel : +34 931641662
Fax: +34 935811938
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
--
Avís - Aviso - Legal Notice - (LOPD) - http://legal.ifae.es
|
Ok, thanks this clears things up a bit (and points out the confusion!). In any case, we discussed that the CameraGeometry or CameraDisplay needs a way to specify the coordinate system, so we can display images in various systems (reconstruction "nominal", telescope "sky" coordinates, etc), so we can certainly add a new system (or systems) to describe all the ones we would like to be able to show. the current "CameraSystem" is the SimTelArray one, but we can add one for these flipped systems as well, along with transfroms between them. Then in the CameraGeometry we can just change |
@AMWMitchell this may be something that could be useful to standardize in the PO: a list of coordinate systems with an official name "CameraSystem", "NaturalCameraSystem", or whatever, and their definitions:
Just the camera and ground coordinates are a good starting point, and then up through sky coords as well. |
It was pointed out at the last workshop that all cameras are currently rotated 90 deg with respect to their real parking positions. This seems to be due to the strange coordinate system used for the MCs, where the x-axis is up, so we should probably apply this as well to the base system. |
I just produced a PROD4 simtel file, doing this: import matplotlib.pyplot as plt
from eventio import SimTelFile
from ctapipe.visualization import CameraDisplay
from ctapipe.instrument import CameraGeometry
import numpy as np
import astropy.units as u
f = SimTelFile('./gamma_test_prod4.simtel.gz')
keys = set()
geoms = []
for tel_id, desc in f.telescope_descriptions.items():
cam = desc['camera_settings']
key = cam['n_pixels'], cam['mirror_area'], cam['focal_length']
if key not in keys:
keys.add(key)
print(key)
if cam['pixel_shape'][0] == 1:
pix_type = 'hexagonal'
pix_rotation = '0d'
elif cam['pixel_shape'][0] == 3:
pix_type = 'hexagonal'
pix_rotation = '30d'
elif cam['pixel_shape'][0] == 2:
pix_type = 'rectangular'
pix_rotation = '0d'
geoms.append(CameraGeometry(
'telescope_{}'.format(tel_id),
np.arange(cam['n_pixels']),
cam['pixel_x'] * u.m,
cam['pixel_y'] * u.m,
cam['pixel_area'] * u.m**2,
pix_type=pix_type,
pix_rotation=pix_rotation,
cam_rotation=-cam['cam_rot'] * u.rad,
apply_derotation=True,
))
for geom in geoms:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
d = CameraDisplay(geom, ax=ax)
d.image = geom.pix_id
d.add_colorbar()
fig.tight_layout()
fig.savefig('camgeom_{}.png'.format(geom.cam_id), dpi=200) I get this: Is this what's expected? |
I think this can be closed now, EngineeringCameraFrame and CameraFrame have documentation how they are defined and transformation is possible between the two. |
Currently the default behaviour of the CameraGeometry class is to return the position of the camera pixels de-rotated by the camera rotation angle defined in sim_telarray. But I'm not really sure this is the right thing to do as the de-rotated position of the pixels isn't really useful for anything and in order to place the images in the nominal system you need to rotate the images back.
Would it not make more sense just to return the pixel positions in their regular rotated position to remove a step from the analysis?
The text was updated successfully, but these errors were encountered: