Repository navigation
Conversation
3f6514e to
f9e11a5
Compare
|
Some updates here. I've been doing a detailed code comparison of GalSim's handling of the cycle 9 data we are currently using with how STPSF uses it, and I made a number of updates to bring GalSim in line with STPSF.
Aside - another bug that was introduced in #1363 was the loss of the pixel scale in the pupil plane image. This caused GalSim to have to estimate it from the contents of the image, which ended up with a slightly wrong number. We don't use that function anymore for the Roman PSF, but I fixed flip_ud() and related functions to preserve the wcs of the image rather than setting it to None. Some nice images showing the current agreement:
|
|
Sorry to be the peanut gallery on a minor part of this, but: your point about interpolants caught my eye. |
…otation of SCAs from previous conventions
…e rotation from entrance to exit pupil
128444c to
0ae9fdb
Compare
|
Yeah, we have strong recommendations not to mess with the k_interpolant choice, but I remember Gary telling me that x_interpolant is basically just a user choice. It's part of the definition of what you mean by the InterpolatedImage profile. So we probably just made assumptions that Quintic was also good there, but I think the way most people intend interpolated images should be using something that approximates a sinc interpolant. Which means a Lanczos to some order. I might make a PR changing the default to something reasonable like Lanczos 7 maybe. But not as part of this one. BTW, these changes have edged past what I think is properly considered a bug fix, so I'll release all these with a new minor version number, 2.9.0 (once we're done getting through everything), rather than the next in the 2.8 series as I had been originally planning. As a result, I retargeted this to merge to main rather than releases/2.8. |
nihardalal
left a comment
There was a problem hiding this comment.
I also took a look, things look overall good to me minus some documentation updates to be inline with the new coordinate system
There was a problem hiding this comment.
I think these changes all look good to me. Boresight and PA seem like very useful additions, and I also like the 5 point interpolation. I appreciate that the code is also a bit cleaner now (e.g. cleaning up the aberrations so that the interpolation looks cleaner)
There was a problem hiding this comment.
Also thanks for catching the entrance/exit pupil thing! I think we were too hyperfocused on the sign flip earlier that we missed where the pupil fit in the full picture
| @@ -94,6 +94,10 @@ def getWCS(world_pos, PA=None, date=None, SCAs=None, PA_is_FPA=False): | |||
| Cycle 6, which includes some significant updates from Cycle 5, including a 90 degree rotation of | |||
| the focal plane axes relative to the payload axes, and two rows of SCAs are swapped. | |||
|
|
|||
There was a problem hiding this comment.
I appreciate this documentation
| @@ -137,8 +141,6 @@ def getWCS(world_pos, PA=None, date=None, SCAs=None, PA_is_FPA=False): | |||
| # Sun in the absence of a roll offset (i.e., roll offset = 0 defines the optimal position angle | |||
| # for the observatory), +Y_obs makes a right-handed system. | |||
| # | |||
There was a problem hiding this comment.
I think we should come up with a set of reference figures at some point, or link to the ones Chris made in PSFSim here: https://github.com/Roman-HLIS-Cosmology-PIT/PSFSim/blob/main/docs/coordinates.rst
| while shift_val > tol/coord.arcsec: | ||
| test_wcs = getWCS(fpa_cent, PA, date, use_SCA, PA_is_FPA)[use_SCA] | ||
| im_cent_pos = PositionD(n_pix/2, n_pix/2) | ||
| im_cent_pos = PositionD((n_pix+1)/2, (n_pix+1)/2) |
There was a problem hiding this comment.
Does this affect anything? I think this looks more correct than previous, and in line with how we usually center things
There was a problem hiding this comment.
Not really. It's slightly more correct for the 1-based image coordinates we use. But I don't think it materially matters much.
There was a problem hiding this comment.
Thanks for these changes - I thought when I was using the functions last time that I would take all the meta information with it, didn't realize that wasn't explicitly happening
There was a problem hiding this comment.
It's a reasonable assumption. Which is why I changed the default. In my review it didn't occur to me that it wouldn't keep the pixel scale. That's a sign of bad API design.
There was a problem hiding this comment.
I gave this a cursory look, but I'm glad the STPSF test is in here. This looks like a very comprehensive update, thanks for working this out Mike!
Fix positive/negative docs, which still had the old SCA orientations. Co-authored-by: Nihar Dalal <140463192+nihardalal@users.noreply.github.com> Co-authored-by: Mike Jarvis <michael@jarvis.net>
|
Thanks for the detailed PR Mike! I have been doing comparisons with STPSF and PSFSim, and I think there might still be a sign flip missing in the pupil mask in galsim. Let me elaborate: While comparing this branch with STPSF 2.3.1 and PSFSim, I found that the PSF's strut pattern is mirrored up–down relative to both. The cause seems to be the orientation of the pupil files in This seems to suggest that the up-down flip that Nihar had added previously was the correct flip to the pupil currently in galsim. The problem might be that the pupil mask and the zernikes were not in the same frame in Cycle 9, and that the flip was necessary to do get them in the same frame. Maybe this was fixed in Cycle 10 and the pupil mask and zernikes were now in the same frame.
So I think the the existing tests passes in Here is a galsim_pr_pupil_orientation.py that you can use to replicate the results. |
…pply the flip they now do directly to the file
|
Interesting. I intentionally scoped this so far to stick to the Cycle 9 inputs rather than update the input files yet to try to identify code differences rather than reference file issues. I updated the generate script to use roman's original reference files from cycle 9 rather than the ones we copied into galsim, and the old orientation is there. (This is their 2.0.0 data.) So the change in the reference pupil's orientation happened after that. Of course, that also means that using the new STPSF code with the old reference files is probably wrong. But I'm not sure where the aberrations fit into that. I.e. when to have STPSF flip the pupil plane when using the old files -- before or after applying the aberrations. I have another branch where I've started updating the GalSim reference files to Cycle 10 and later, so that will be a more definitive test that we match current STPSF for both code and reference files. For now I've put a y flip in the generator script before applying aberrations. I think I found evidence that this is right from historical stpsf code, but it's hard to say for sure. I think I won't be fully confident in this choice until I finish updating everything to the current reference files. And I re-added the flip_ud line in GalSim to match this treatment. Thanks for catching this Federico! |
|
We can discuss this more on the PSF call today, but I can concur that old versions of STPSF had an inconsistent sign treatment, but I think the project (and especially Tim Brandt) seem confident that whatever in STPSF 2.3.1 matches the real data pretty well. I think a useful task would be to dig through the STPSF release notes and document exactly which flips were made when |





When working on fitting the PSF of Roman commissioning data, I realized we have a bug in the Roman getPSF function in terms of how we rotate the PSF to sky coordinates according to how the telescope is oriented. We just apply the wcs.toWorld() function. This gets the rotation and reflection (approximately) correct, but also applies the distortion, which is wrong. The upshot of the bug is that the PSF is not properly distorted when drawn with the same WCS. This PR fixes this to just apply the orthogonal part of the WCS without the distortion (symmetric positive definite part).
However, using the WCS for this is an approximation, which is still not completely correct. The WCS can include rotation components from pixel geometry, which are not properly part of the rotation we want. It turns out the Roman ASDF files include the information we need to do this correctly. Namely the boresight direction and the position angle of the V3 axis. So I also added the option to provide these directly, which does the more correct rotation. The rotation angle can still change slightly across the field of view, due to the direction to north changing slightly. But any other rotation in the WCS will be applied correctly when the object is drawn on an image.