Skip to content
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

improve MIRI LRS model details #787

Merged
merged 7 commits into from
May 2, 2024

Conversation

mperrin
Copy link
Collaborator

@mperrin mperrin commented Jan 10, 2024

Address #785.

  • Update LRS slit geometry for better consistency with SIAF
  • Fixes SI WFE model to be after coordinate rotation to detector frame for LRS mode. (I believe this fix also will slightly improve the model setup for MIRI coronagraphy too. )
  • Tunes up cruciform artifact amplitude in LRS mode, using an estimate from F1000W and F1130W.
  • Adjust the distortion code to gracefully skip trying to add distortion for LRS, rather than raising an exception.
  • Add a basic unit test for running an LRS mode PSF sim.

Remaining open items from #785:

  • Pupil stop is correctly set to the oversized tricontagon for the P750L pupil mask, but ought to be set to that for any imaging filter used with the LRS. (or, strictly speaking, in general, but we don't model the effects of the oversized internal pupil stop for regular imaging mode).
  • Need to update pupil shear for this mode using the values from commissioning. See Wright, Sabatke, and Telfer 2022

Also:

  • Major improvement in LRS slit PSF calculation fidelity through changing the optical propagation to use a much more finely sampled pixelscale for a small region around the LRS slit, computed via MFT. This makes a very significant difference in fine details of LRS PSF sims.

Defer these as out-of-scope; could be done in some future PR:

  • Need to understand/double check relative about filter-dependent apparent offsets and how to account for them. In discussion with @skendrew . This may be outside of the scope of webbpsf but relevant for fitting physically-optics-based forward models to data for complex scenes seen via the LRS.
  • Wavelength-dependent continuous version of the cruciform convolution kernel needed. (Actually I now think this is out of scope for this PR)
  • SI field dependent WFE: can we get a better estimate of it near the LRS field point? Extrapolate from MIMF sensing near there? Edit: Descope from this PR. The current estimate is good enough for now.

@mperrin mperrin self-assigned this Feb 13, 2024
@mperrin mperrin added the enhancement New feature or request label Feb 13, 2024
@mperrin mperrin added this to the Release 1.3 milestone Feb 13, 2024
@mperrin mperrin mentioned this pull request Feb 22, 2024
9 tasks
@pep8speaks
Copy link

pep8speaks commented Feb 23, 2024

Hello @mperrin, Thank you for updating !

Line 37:29: E261 at least two spaces before inline comment
Line 37:30: E262 inline comment should start with '# '
Line 52:77: E261 at least two spaces before inline comment
Line 56:9: E266 too many leading '#' for block comment
Line 67:17: E225 missing whitespace around operator
Line 90:9: E265 block comment should start with '# '
Line 105:9: E722 do not use bare 'except'
Line 113:23: E127 continuation line over-indented for visual indent
Line 117:13: E265 block comment should start with '# '
Line 131:5: E303 too many blank lines (2)
Line 138:44: E251 unexpected spaces around keyword / parameter equals
Line 138:46: E251 unexpected spaces around keyword / parameter equals
Line 184:24: E225 missing whitespace around operator
Line 188:29: E225 missing whitespace around operator
Line 192:22: E221 multiple spaces before operator
Line 193:20: E221 multiple spaces before operator
Line 194:26: E225 missing whitespace around operator
Line 196:29: E225 missing whitespace around operator
Line 200:29: E225 missing whitespace around operator
Line 202:20: E221 multiple spaces before operator
Line 218:5: E303 too many blank lines (3)
Line 232:71: E225 missing whitespace around operator
Line 270:5: E303 too many blank lines (3)
Line 271:36: E226 missing whitespace around arithmetic operator
Line 271:39: E226 missing whitespace around arithmetic operator
Line 271:55: E226 missing whitespace around arithmetic operator
Line 271:58: E226 missing whitespace around arithmetic operator
Line 278:39: E226 missing whitespace around arithmetic operator
Line 278:47: E226 missing whitespace around arithmetic operator
Line 280:28: E222 multiple spaces after operator
Line 310:25: E226 missing whitespace around arithmetic operator
Line 310:28: E226 missing whitespace around arithmetic operator
Line 351:106: E251 unexpected spaces around keyword / parameter equals
Line 351:108: E251 unexpected spaces around keyword / parameter equals
Line 355:106: E251 unexpected spaces around keyword / parameter equals
Line 355:108: E251 unexpected spaces around keyword / parameter equals
Line 359:43: E226 missing whitespace around arithmetic operator
Line 421:32: E127 continuation line over-indented for visual indent

Line 10:1: E402 module level import not at top of file
Line 14:1: E402 module level import not at top of file
Line 16:1: E731 do not assign a lambda expression, use a def
Line 17:1: E731 do not assign a lambda expression, use a def
Line 18:1: E731 do not assign a lambda expression, use a def
Line 20:1: E731 do not assign a lambda expression, use a def
Line 74:19: E201 whitespace after '('
Line 91:1: E302 expected 2 blank lines, found 1

Line 233:22: E701 multiple statements on one line (colon)
Line 312:26: E225 missing whitespace around operator
Line 351:36: E701 multiple statements on one line (colon)
Line 360:5: E303 too many blank lines (2)
Line 361:29: E127 continuation line over-indented for visual indent
Line 395:47: E114 indentation is not a multiple of four (comment)
Line 395:47: E116 unexpected indentation (comment)
Line 397:27: E701 multiple statements on one line (colon)
Line 398:39: E701 multiple statements on one line (colon)
Line 462:109: E202 whitespace before ')'
Line 477:33: E701 multiple statements on one line (colon)
Line 478:33: E701 multiple statements on one line (colon)
Line 480:72: W504 line break after binary operator
Line 481:37: W504 line break after binary operator
Line 490:43: E701 multiple statements on one line (colon)
Line 493:91: E701 multiple statements on one line (colon)
Line 494:92: E701 multiple statements on one line (colon)
Line 531:23: E126 continuation line over-indented for hanging indent
Line 621:48: E127 continuation line over-indented for visual indent
Line 712:29: E201 whitespace after '('
Line 727:1: E266 too many leading '#' for block comment
Line 801:63: E127 continuation line over-indented for visual indent
Line 802:63: E127 continuation line over-indented for visual indent
Line 803:63: E127 continuation line over-indented for visual indent
Line 804:63: E127 continuation line over-indented for visual indent
Line 862:9: E303 too many blank lines (3)
Line 917:5: E303 too many blank lines (2)
Line 946:18: E114 indentation is not a multiple of four (comment)
Line 946:18: E116 unexpected indentation (comment)
Line 977:5: E303 too many blank lines (2)
Line 985:54: E225 missing whitespace around operator
Line 1015:33: E261 at least two spaces before inline comment
Line 1153:87: E231 missing whitespace after ','
Line 1163:83: E231 missing whitespace after ','
Line 1168:53: E701 multiple statements on one line (colon)
Line 1171:9: E303 too many blank lines (2)
Line 1177:66: E251 unexpected spaces around keyword / parameter equals
Line 1177:68: E251 unexpected spaces around keyword / parameter equals
Line 1215:5: E303 too many blank lines (2)
Line 1238:31: E701 multiple statements on one line (colon)
Line 1239:31: E701 multiple statements on one line (colon)
Line 1243:76: E231 missing whitespace after ','
Line 1249:5: E303 too many blank lines (2)
Line 1249:28: E241 multiple spaces after ','
Line 1284:59: E222 multiple spaces after operator
Line 1285:39: E225 missing whitespace around operator
Line 1288:24: E221 multiple spaces before operator
Line 1301:32: E261 at least two spaces before inline comment
Line 1321:42: E222 multiple spaces after operator
Line 1342:31: E261 at least two spaces before inline comment
Line 1352:98: E225 missing whitespace around operator
Line 1393:27: E225 missing whitespace around operator
Line 1396:26: E225 missing whitespace around operator
Line 1399:33: E225 missing whitespace around operator
Line 1406:36: E261 at least two spaces before inline comment
Line 1411:43: E261 at least two spaces before inline comment
Line 1431:27: E226 missing whitespace around arithmetic operator
Line 1432:49: E225 missing whitespace around operator
Line 1439:5: E303 too many blank lines (2)
Line 1439:54: E226 missing whitespace around arithmetic operator
Line 1463:49: E251 unexpected spaces around keyword / parameter equals
Line 1463:51: E251 unexpected spaces around keyword / parameter equals
Line 1503:80: E251 unexpected spaces around keyword / parameter equals
Line 1503:82: E251 unexpected spaces around keyword / parameter equals
Line 1515:9: E265 block comment should start with '# '
Line 1522:34: E231 missing whitespace after ':'
Line 1522:46: E231 missing whitespace after ':'
Line 1522:57: E231 missing whitespace after ':'
Line 1522:88: E231 missing whitespace after ':'
Line 1523:19: E231 missing whitespace after ','
Line 1524:19: E231 missing whitespace after ','
Line 1525:19: E231 missing whitespace after ','
Line 1528:23: E701 multiple statements on one line (colon)
Line 1555:13: E303 too many blank lines (2)
Line 1588:53: E226 missing whitespace around arithmetic operator
Line 1588:74: E226 missing whitespace around arithmetic operator
Line 1591:23: E231 missing whitespace after ','
Line 1592:23: E231 missing whitespace after ','
Line 1593:23: E231 missing whitespace after ','
Line 1595:23: E231 missing whitespace after ','
Line 1595:86: E203 whitespace before ','
Line 1596:23: E231 missing whitespace after ','
Line 1597:23: E231 missing whitespace after ','
Line 1599:23: E231 missing whitespace after ','
Line 1600:23: E231 missing whitespace after ','
Line 1601:23: E231 missing whitespace after ','
Line 1603:23: E231 missing whitespace after ','
Line 1604:23: E231 missing whitespace after ','
Line 1605:23: E231 missing whitespace after ','
Line 1607:23: E231 missing whitespace after ','
Line 1608:23: E231 missing whitespace after ','
Line 1609:23: E231 missing whitespace after ','
Line 1663:5: E303 too many blank lines (2)
Line 1663:62: E251 unexpected spaces around keyword / parameter equals
Line 1663:64: E251 unexpected spaces around keyword / parameter equals
Line 1709:13: E731 do not assign a lambda expression, use a def
Line 1711:13: E731 do not assign a lambda expression, use a def
Line 1726:12: E225 missing whitespace around operator
Line 1733:9: E266 too many leading '#' for block comment
Line 1733:9: E303 too many blank lines (3)
Line 1742:35: E226 missing whitespace around arithmetic operator
Line 1742:76: E225 missing whitespace around operator
Line 1742:78: E226 missing whitespace around arithmetic operator
Line 1745:45: E251 unexpected spaces around keyword / parameter equals
Line 1745:47: E251 unexpected spaces around keyword / parameter equals
Line 1746:74: E226 missing whitespace around arithmetic operator
Line 1746:86: E226 missing whitespace around arithmetic operator
Line 1750:42: E251 unexpected spaces around keyword / parameter equals
Line 1750:44: E251 unexpected spaces around keyword / parameter equals
Line 1751:42: E251 unexpected spaces around keyword / parameter equals
Line 1751:44: E251 unexpected spaces around keyword / parameter equals
Line 1752:42: E251 unexpected spaces around keyword / parameter equals
Line 1752:44: E251 unexpected spaces around keyword / parameter equals
Line 1761:9: E266 too many leading '#' for block comment
Line 1762:9: E266 too many leading '#' for block comment
Line 1777:13: E303 too many blank lines (2)
Line 1795:13: E303 too many blank lines (2)
Line 1822:26: E222 multiple spaces after operator
Line 1824:33: E116 unexpected indentation (comment)
Line 1950:45: E128 continuation line under-indented for visual indent
Line 1966:63: E127 continuation line over-indented for visual indent
Line 1967:63: E127 continuation line over-indented for visual indent
Line 1968:63: E127 continuation line over-indented for visual indent
Line 1969:63: E124 closing bracket does not match visual indentation
Line 1970:46: E231 missing whitespace after ','
Line 1973:36: E261 at least two spaces before inline comment
Line 1974:56: E226 missing whitespace around arithmetic operator
Line 2037:76: E231 missing whitespace after ','
Line 2042:71: E231 missing whitespace after ','
Line 2048:5: E303 too many blank lines (2)
Line 2076:5: E303 too many blank lines (2)
Line 2169:29: E701 multiple statements on one line (colon)
Line 2202:63: E225 missing whitespace around operator
Line 2210:67: E225 missing whitespace around operator
Line 2212:67: E225 missing whitespace around operator
Line 2215:67: E225 missing whitespace around operator
Line 2217:67: E225 missing whitespace around operator
Line 2246:21: E225 missing whitespace around operator
Line 2248:23: E225 missing whitespace around operator
Line 2250:23: E225 missing whitespace around operator
Line 2252:23: E225 missing whitespace around operator
Line 2278:22: E222 multiple spaces after operator
Line 2293:5: E303 too many blank lines (2)
Line 2311:34: E261 at least two spaces before inline comment
Line 2322:29: E231 missing whitespace after ','
Line 2328:19: E261 at least two spaces before inline comment
Line 2329:69: E226 missing whitespace around arithmetic operator
Line 2330:19: E225 missing whitespace around operator
Line 2337:21: E225 missing whitespace around operator
Line 2355:27: E225 missing whitespace around operator
Line 2373:22: E701 multiple statements on one line (colon)
Line 2471:80: W504 line break after binary operator
Line 2492:40: E225 missing whitespace around operator
Line 2521:57: E202 whitespace before ')'
Line 2535:25: E222 multiple spaces after operator
Line 2535:34: E261 at least two spaces before inline comment
Line 2551:67: E203 whitespace before ':'
Line 2554:65: E124 closing bracket does not match visual indentation
Line 2558:65: E124 closing bracket does not match visual indentation
Line 2562:65: E124 closing bracket does not match visual indentation
Line 2571:65: E128 continuation line under-indented for visual indent
Line 2582:62: E114 indentation is not a multiple of four (comment)
Line 2582:62: E116 unexpected indentation (comment)
Line 2587:9: E303 too many blank lines (2)
Line 2598:1: E302 expected 2 blank lines, found 1
Line 2620:33: E116 unexpected indentation (comment)
Line 2639:29: E701 multiple statements on one line (colon)
Line 2709:1: E303 too many blank lines (3)
Line 2861:62: W504 line break after binary operator
Line 2897:34: E261 at least two spaces before inline comment
Line 2901:26: E226 missing whitespace around arithmetic operator
Line 2968:61: E226 missing whitespace around arithmetic operator
Line 2984:1: E302 expected 2 blank lines, found 1
Line 3080:37: E701 multiple statements on one line (colon)
Line 3091:32: E701 multiple statements on one line (colon)

Comment last updated at 2024-04-29 21:28:55 UTC

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.54%. Comparing base (b536111) to head (8afebc7).
Report is 8 commits behind head on develop.

❗ Current head 8afebc7 differs from pull request most recent head b635325. Consider uploading reports for the commit b635325 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #787      +/-   ##
===========================================
+ Coverage    59.20%   59.54%   +0.33%     
===========================================
  Files           16       16              
  Lines         6955     6926      -29     
===========================================
+ Hits          4118     4124       +6     
+ Misses        2837     2802      -35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mperrin mperrin added the JWST Affects JWST models in WebbPSF label Feb 23, 2024
@mperrin mperrin force-pushed the lrs_improvements branch 2 times, most recently from ad1539e to b7b4a39 Compare March 28, 2024 15:58
@mperrin mperrin marked this pull request as ready for review April 8, 2024 16:51
@mperrin
Copy link
Collaborator Author

mperrin commented Apr 26, 2024

In the course of some science analyses and discussions, I discovered/realized that the LRS calc has been (until now) using a very coarse pixel scale via default FFT propagation from pupil to image plane. This is not sufficiently precise. Much better outputs achieved via using an adjustable matrix Fourier transform to set much finer spatial scale right around the slit.

Figures before and after:
lrs_slit_sampling

As a bonus, this actually makes the code faster too since in this case we can restrict to computing a quite small region of the image plane. But that's not the main motivation.

@obi-wan76
Copy link
Collaborator

@mperrin how do I get the same image/output that you are showing in your comment above? (with the LRS slit). I checked your modifications and I was able to create a LRS PSF based on the test setup but I would like to play around a bit more, specially to get the same images. Thanks!

@mperrin
Copy link
Collaborator Author

mperrin commented May 2, 2024

The above plots were obtained by using the return_intermediates option to calc_psf, to return the wavefront at each intermediate optical plane of the calculation. Like this:

psf, waves = miri.calc_psf(monochromatic=10e-6, fov_pixels=101, return_intermediates=True, display=True)
waves[2].display()

Copy link
Collaborator

@obi-wan76 obi-wan76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I did the example from the test, the intermediate planes, and double check the values from the papers.

@obi-wan76 obi-wan76 merged commit 03ede79 into spacetelescope:develop May 2, 2024
7 checks passed
mperrin added a commit to mperrin/webbpsf-st that referenced this pull request May 12, 2024
@mperrin mperrin deleted the lrs_improvements branch July 26, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request JWST Affects JWST models in WebbPSF
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants