GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
228 stars 107 forks source link

update some aspects of WFIRST module #675

Closed rmandelb closed 7 years ago

rmandelb commented 9 years ago

Some parts of the WFIRST PSF should be updated to match what is posted at http://wfirst.gsfc.nasa.gov/science/sdt_public/wps/references/instrument/

This issue (assigned to me) is for that work. Three possible updates:

rmandelb commented 9 years ago

@arunkannawadi , @chazshapiro: I took care of the first item on the list today, updating the Zernikes at the centers of each SCA to the new values. This seems to have largely fixed the pesky chromatic trends that we were seeing. For example, if I take this script and run it on the master branch:

import galsim
import galsim.wfirst as wf

SCA=11
blue_wavelength=850.
red_wavelength=1500.
draw_scale = 0.01 # arcsec

# First check WFIRST effective PSF using only obscured Airy, and compare the adaptive size using 
# the two wavelengths.
pix = galsim.Pixel(wf.pixel_scale)
blue_psf = galsim.Convolve(
    galsim.OpticalPSF(lam=blue_wavelength, diam=wf.diameter, obscuration=wf.obscuration), pix)
red_psf = galsim.Convolve(
    galsim.OpticalPSF(lam=red_wavelength, diam=wf.diameter, obscuration=wf.obscuration), pix)
blue_im = blue_psf.drawImage(method='no_pixel', scale=draw_scale)
red_im = red_psf.drawImage(method='no_pixel', scale=draw_scale)
blue_res = blue_im.FindAdaptiveMom()
red_res = red_im.FindAdaptiveMom()
print 'Obscured Airy adaptive sizes: ',blue_res.moments_sigma,red_res.moments_sigma
print '  Ratio (blue/red): ',blue_res.moments_sigma/red_res.moments_sigma

# Then, do the same trick, but using the aberrated PSFs.
pix = galsim.Pixel(wf.pixel_scale)
blue_psf = galsim.Convolve(
    wf.getPSF(SCAs=SCA, approximate_struts=True, wavelength=blue_wavelength)[SCA], pix)
red_psf = galsim.Convolve(
    wf.getPSF(SCAs=SCA, approximate_struts=True, wavelength=red_wavelength)[SCA], pix)
blue_im = blue_psf.drawImage(method='no_pixel', scale=draw_scale)
red_im = red_psf.drawImage(method='no_pixel', scale=draw_scale)
blue_res = blue_im.FindAdaptiveMom()
red_res = red_im.FindAdaptiveMom()
print 'Aberrated WFIRST PSF adaptive sizes: ',blue_res.moments_sigma,red_res.moments_sigma
print '  Ratio (blue/red): ',blue_res.moments_sigma/red_res.moments_sigma

then the results are

Obscured Airy adaptive sizes:  4.95253229141 6.1473531723
  Ratio (blue/red):  0.805636532114
Aberrated WFIRST PSF adaptive sizes:  10.9347467422 7.68850660324
  Ratio (blue/red):  1.42221985446

which says that for a WFIRST PSF, the aberrated PSF sizes follow the opposite chromatic trend from obscured Airy profiles. But if I run this on branch #675, the results are:

Obscured Airy adaptive sizes:  4.95253229141 6.1473531723
  Ratio (blue/red):  0.805636532114
Aberrated WFIRST PSF adaptive sizes:  5.86929321289 6.35082387924
  Ratio (blue/red):  0.924178236476

This says that while aberrations reduce the degree to which the blue PSFs are smaller than red ones, the trend is still there (just at a lower level). That's more like what we expect.

@arunkannawadi , can you please rerun some of your codes on this branch and confirm that you also see results that make more sense now? If so, then I will try to wrap this up and make a pull request (which involves fixing one small unit test failure).

Edited on github to add: I did not yet investigate what precisely is responsible for this change. However, before making a PR I will look into that.

arunkannawadi commented 9 years ago

Yes, the new aberrations seem much more sensible. The effective PSF size increases with the wavelength, although not linearly, which is fine. The only exception is Z087 band, whose PSF size is greater than that of Y106 band.

To generate the detailed plot with control over each effect, I'll have to run the script on Coma cluster. Once it is up ( hopefully tomorrow ), I'll run my script and upload the plot here.

On Mon, Jul 20, 2015 at 3:13 PM, Rachel Mandelbaum <notifications@github.com

wrote:

@arunkannawadi https://github.com/arunkannawadi , @chazshapiro https://github.com/chazshapiro: I took care of the first item on the list today, updating the Zernikes at the centers of each SCA to the new values. This seems to have largely fixed the pesky chromatic trends that we were seeing. For example, if I take this script and run it on the master branch:

import galsim import galsim.wfirst as wf

SCA=11 blue_wavelength=850. red_wavelength=1500. draw_scale = 0.01 # arcsec

First check WFIRST effective PSF using only obscured Airy, and compare the adaptive size using

the two wavelengths.

pix = galsim.Pixel(wf.pixel_scale) blue_psf = galsim.Convolve( galsim.OpticalPSF(lam=blue_wavelength, diam=wf.diameter, obscuration=wf.obscuration), pix) red_psf = galsim.Convolve( galsim.OpticalPSF(lam=red_wavelength, diam=wf.diameter, obscuration=wf.obscuration), pix) blue_im = blue_psf.drawImage(method='no_pixel', scale=draw_scale) red_im = red_psf.drawImage(method='no_pixel', scale=draw_scale) blue_res = blue_im.FindAdaptiveMom() red_res = red_im.FindAdaptiveMom() print 'Obscured Airy adaptive sizes: ',blue_res.moments_sigma,red_res.moments_sigma print ' Ratio (blue/red): ',blue_res.moments_sigma/red_res.moments_sigma

Then, do the same trick, but using the aberrated PSFs.

pix = galsim.Pixel(wf.pixel_scale) blue_psf = galsim.Convolve( wf.getPSF(SCAs=SCA, approximate_struts=True, wavelength=blue_wavelength)[SCA], pix) red_psf = galsim.Convolve( wf.getPSF(SCAs=SCA, approximate_struts=True, wavelength=red_wavelength)[SCA], pix) blue_im = blue_psf.drawImage(method='no_pixel', scale=draw_scale) red_im = red_psf.drawImage(method='no_pixel', scale=draw_scale) blue_res = blue_im.FindAdaptiveMom() red_res = red_im.FindAdaptiveMom() print 'Aberrated WFIRST PSF adaptive sizes: ',blue_res.moments_sigma,red_res.moments_sigma print ' Ratio (blue/red): ',blue_res.moments_sigma/red_res.moments_sigma

then the results are

Obscured Airy adaptive sizes: 4.95253229141 6.1473531723 Ratio (blue/red): 0.805636532114 Aberrated WFIRST PSF adaptive sizes: 10.9347467422 7.68850660324 Ratio (blue/red): 1.42221985446

which says that for a WFIRST PSF, the aberrated PSF sizes follow the opposite chromatic trend from obscured Airy profiles. But if I run this on branch #675 https://github.com/GalSim-developers/GalSim/issues/675, the results are:

Obscured Airy adaptive sizes: 4.95253229141 6.1473531723 Ratio (blue/red): 0.805636532114 Aberrated WFIRST PSF adaptive sizes: 5.86929321289 6.35082387924 Ratio (blue/red): 0.924178236476

This says that while aberrations reduce the degree to which the blue PSFs are smaller than red ones, the trend is still there (just at a lower level). That's more like what we expect.

@arunkannawadi https://github.com/arunkannawadi , can you please rerun some of your codes on this branch and confirm that you also see results that make more sense now? If so, then I will try to wrap this up and make a pull request (which involves fixing one small unit test failure).

— Reply to this email directly or view it on GitHub https://github.com/GalSim-developers/GalSim/issues/675#issuecomment-122993295 .

Regards

Arun Kannawadi Jayaraman PhD candidate, Dept. of Physics, Carnegie Mellon University, Pittsburgh, PA 15213

rmandelb commented 9 years ago

Thanks.

rmandelb commented 9 years ago

In the meantime, I fixed a unit test failure and investigated why this is happening. If I consider the bluer wavelength that I used in my testing script, the aberrations were

[ 0.          0.          0.          0.         -0.1559142  -0.05956615
 -0.07788034  0.05458311  0.01243232 -0.04585532  0.03051682  0.07345786]

(in units of waves) on the master branch, and

[ 0.          0.          0.          0.          0.00684377 -0.06367797
 -0.02092074  0.05082251 -0.02664341  0.00415585  0.00594476  0.0096473 ]

on this branch. So nearly all of them are smaller now, with a particularly huge change in the defocus (factor of ~20). Smaller aberrations overall would qualitatively explain the change we see with the new code.

Arun, I am going to make a PR for this since it seems basically sensible. I look forward to seeing your plots once they are available.

arunkannawadi commented 9 years ago

psf_analysis_c5 This plot show the size of the effective PSF (PSF convolved with the pixel response) for different WFIRST bandpasses along the horizontal axis. The vertical axis is not important; it it just some naive numerical factor that scales with the effective wavelength . The effective PSFs are drawn on a large ( 648, 648 ) image with 1/8 of the WFIRST pixel scale.

The PSFs with aberrations are by and large bigger than than those without aberrations. The aberrations are larger for blue bands than for red bands. The PSF sizes increase from blue to red, as expected, with Z087 band being an exception because of the large aberrations. The PSFs without aberrations obey the expected trend.

rmandelb commented 9 years ago

I'm not closing this issue, because there are still two possible updates (longer-term, more work) listed in the original issue.

josePhoenix commented 8 years ago

I noticed that the WFIRST reference data in share/ seem to be based on Cycle 5, and I went looking for open WFIRST issues. Not sure if this is the appropriate place to comment, but @rmandelb is the update to Cycle 6 / MCR data in the cards for the near future?

rmandelb commented 8 years ago

Yes, this is definitely an appropriate place to comment.

The short answer is that my student who has worked on the WFIRST module graduated, so I think it�s unlikely he will want to do this (and things are a bit busy for me to do this myself during this semester). However, I have identified another student who may be interested in working on this. If that works out, which I think it will, then an update is in the cards in the near-ish term. (next ~2 months)

josePhoenix commented 8 years ago

Great, thank you for the update! I'll listen for notifications on this issue.

rmandelb commented 7 years ago

Notes on what needs to be done, per discussion with Chris and Troxel:

  1. variation of Zernikes across SCAs
  2. cycle 5 to 6 updates: 90 degree rotation of FOV is most pressing
  3. Phase A aberrations and field distortion will be out soon, so wait on that instead of going from cycle 5 to 6; Chris to check with Jeff Kruk about when that will be ready
  4. Chris to provide updates to numbers in __init__.py for WFIRST module. (update, Chris sent them and RM can implement)
  5. Renumber SCAs based on cycle 6 layout? (https://wfirst.gsfc.nasa.gov/science/sdt_public/wps/references/instrument/WFIRSTMCR_FieldLayout_6.5.9b.jpg) and resulting unit test, PSF, dox changes.

2 and 4 are low-hanging fruit to be done quickly. 1 has some bookkeeping, and 3 requires us to wait on Jeff.

Longer term development:

rmjarvis commented 7 years ago

individual pixel effects: ability to put in a flat field including effects down to the sub-pixel level. Cross-hatching pattern could then be simulated.

FYI, the current state of things on this item is that we can make a flat field that includes astrometric effects down to the ~pixel scale if the WCS is accurate to that level. It takes a numerical derivative of the astrometric solution with +- 1 pixel for the discrete derivative. Here is an example for DECam using Gary's astrometric solution that includes edge distortions, tree rings, etc:

https://github.com/gbernstein/pixmappy/pull/2#issuecomment-286642919

image

QE effects aren't there of course, but those would be very straightforward to add if you have a pixel-by-pixel map of QE variation to multiply the image.

rmandelb commented 7 years ago

That is really cool!

rmandelb commented 7 years ago

All - I am going to try to make a PR on this branch to get some of the most critical updates and bug fixes since cycle 5 into the WFIRST module, deferring many functionality upgrades that will have a smaller impact on the simulations for later. For reference, here's what will make it into the PR:

Below is a list of things I am not doing now:

All of this means that, unfortunately, the module will be in somewhat of a hybrid state, with some cycle 7 updates but other things left at cycle 5. This will be clearly documented, and will let us get the major WCS changes into the next tagged version of GalSim.

My own to-do list:

rmandelb commented 7 years ago

@rmjarvis - after these changes, the WFIRST WCS unit tests fail, while the rest still pass. The reason for this is simple: we compare the WCS against a stored / precomputed one, and so of course the test fails after we updated the WCS code without regenerating the stored one.

So the obvious answer to this conundrum is that I should regenerate the standards. But... The way I got them in the first place is like this: 1) I got WCS code from Jeff Kruk. 2) I rewrote it in python and put it in GalSim. 3) I ran Jeff's code and saved some results for the unit test comparison.

Now, i changed a lot of numbers in the GalSim version of the code. I could go back to Jeff's code and change all the same numbers and regenerate the standards (it'll be slightly annoying but doable). However, is there even value in this? If we know that for one set of SCA center positions and orientations, the two codes agree, I don't see why they wouldn't agree with the changed versions. So in some sense, this comparison against Jeff's code seems obsolete.

What do you think? Obviously we shouldn't leave the code untested, so we'd have to come up with something else.

rmjarvis commented 7 years ago

Yeah, these kind of validations are tricky. What is the procedure you went through just now to convince yourself that the code is correct? Is there some version of that we can codify in the tests?

If not, but if you're nonetheless convinced that the code is probably right now, we could just make a regression test that saves current values to test against and have the test make sure things don't change in the future.

rmandelb commented 7 years ago

What we've done for validation of these updates is compare Chris's code against GalSim outputs, and confirm that for multiple positions for center of the focal plane and multiple selected position angles, we get the same WCS to within a good tolerance. It's actually not perfect, but the differences are tiny compared to the major overall features we're trying to correct (e.g., 90 degree rotation about the observatory axis, swapping rows of SCASs).

So i guess the options are:

  1. Save current values to test against.
  2. Save values from Chris's code to test against (but then we need to build in the tolerance for the tiny offset that we were not able to explain).
rmjarvis commented 7 years ago

Sorry, I guess I never replied to this. I'd suggest putting in some of Chris's results as an external code comparison, and just set the tolerance appropriately. Probably make sure to get a couple points on each SCA to check all the bookkeeping.

rmjarvis commented 7 years ago

This can be closed when PR #918 is merged. I made a new issue #919 with the remaining tasks to be done.

rmandelb commented 7 years ago

Closing #675.