webbpsf icon indicating copy to clipboard operation
webbpsf copied to clipboard

improve MIRI LRS model details

Open mperrin opened this issue 5 months ago • 2 comments

Address #785.

  • [x] Update LRS slit geometry for better consistency with SIAF
  • [x] 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. )
  • [x] Tunes up cruciform artifact amplitude in LRS mode, using an estimate from F1000W and F1130W.
  • [x] Adjust the distortion code to gracefully skip trying to add distortion for LRS, rather than raising an exception.
  • [x] Add a basic unit test for running an LRS mode PSF sim.

Remaining open items from #785:

  • [x] 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).
  • [x] Need to update pupil shear for this mode using the values from commissioning. See Wright, Sabatke, and Telfer 2022

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 avatar Jan 10 '24 19:01 mperrin

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

pep8speaks avatar Feb 23 '24 00:02 pep8speaks

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

:exclamation: 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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 23 '24 01:02 codecov[bot]

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.

mperrin avatar Apr 26 '24 04:04 mperrin

@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!

obi-wan76 avatar May 02 '24 16:05 obi-wan76

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()

mperrin avatar May 02 '24 17:05 mperrin