Closed hamogu closed 8 months ago
As I do more testing, I find that there is even more to it:
Left is an asymetric input image, right is the marx simulated eventlist for that input image. So, the "off by one" that this issue started with seems to be a happy accident of placing the one pixel about in the middle of the input image, which also means that the "fix" that closed this issue is incomplete.
This is all a misunderstanding of how the IMAGE source works, complicated by the fact that the initial bug report used a good-for-testing special case.
From https://space.mit.edu/cxc/marx/indetail/models.html#image-source: "marx inspects the header of the file for a WCS specification and extracts the pixel scale. However, it does not extract the position or orientation on the sky. marx will just assume that the image is centered on the optical axis and that the axes directions are aligned with the detector axes."
What happens here is that the input image have a WCS coordinate system, but marx ignores all of that except for the absolute value of "CDELT1" and "CDELT2". That leads to the flip that I showed in the comment above (because one of the CDELT keywords is negative, which is ignored by marx) and it also leads to the original bug report: The single pixel is located at integer pixel (50,50) which is not exactly the middle of a (100,100) array. When flipped in one direction (because marx ignore the sign of the CDELT), that pixel would be at (51, 50) - which is just one pixel off. And that "one pixel off" location is correctly simulated by marx.
So, after many, many hours of investigation, I can confirm that marx behaves exactly as advertised and this is, in fact, not a bug. The behavior might be confusing and not what most users expect, but given the long heritage, I won't change it. Instead, I will try to make this more clear in the documentation. If a simulation with an image using the full WCS information is required, use a SIMPUT source and the external SIMPUT library.
reported by @kglotfelty
I'm trying to do something with marx using an input image and I think that there might be a pixel-shift/offset happening.
I tried to simplify things as much as possible. I've attached my input "S-ImageFile" which is just a single pixel (delta function):
So the centroid/pixel is at 4097,4097. In ra/dec it's
I'm using obsid 7901 so you can grab the asol file from the archive
Okay, now set up a copy of
marx.par
and now run
marx
andmarx2fits
The x/y grid is the same grid I used to make
delta.img
. Now check the centroidWe see that the centroid is off-by-1 pixel in the X direction 4096 instead of 4097.
I can also see it in ds9
(image attached).
Any idea what might be going on? This is the first time I've tried using SourceType=IMAGE so I'm not sure if there is some parameter(s) I need to tweak.
(Note: The attached file is a fits file called "delta.img". However, github does not allow arbitrary file extensions for attached files, so I simply added ".png" to the end to fool github. To use the file, download and rename is "delta.img" again.)![delta img](https://user-images.githubusercontent.com/498688/119023025-4b412100-b96f-11eb-8d5d-da693a93408e.png)