Set Roman pupil radius correctly, even if pupil files have zero padding#152
Conversation
|
Thanks for the fast response! This doesn't quite fix it because the Here's a minimal example: import stpsf
WL = 1.577e-6 # F158 central wavelength [m]
DEFOCUS_WV = 0.25 # requested defocus [waves P-V]
EXPECTED_RADIUS_M = 2.36312 / 2 # physical entrance pupil radius [m]
stpsf.setup_logging()
wfi = stpsf.roman.WFI()
wfi.filter = 'F158'
wfi.options['defocus_waves'] = DEFOCUS_WV
wfi.options['defocus_wavelength'] = WL
found_radius_before_m = wfi.pupil_radius
psf, wavefronts = wfi.calc_psf(monochromatic=WL, return_intermediates=True)
found_radius_after_m = wfi.pupil_radius.to_value('m')
rho_max = EXPECTED_RADIUS_M/found_radius_after_m
print(f"\n")
print(f"Physical entrance pupil radius: {EXPECTED_RADIUS_M:.4f} m")
print(f"wfi.pupil_radius before calc_psf: {found_radius_before_m:.4f} m")
print(f"wfi.pupil_radius after calc_psf: {found_radius_after_m:.4f} m")
print(f"rho_max = physical / ThinLens radius: {rho_max:.4f}")
print(f"Expected defocus underscale (rho_max^2): {rho_max**2:.4f}")Result: |
|
@bergkoet OK let's try this again. Thanks for the minimal example code, and for pointing out the exact line causing the error; that was very helpful. With the latest commit just added to this branch, I have your test code passing: |
That works for me, too. Many thanks! |
This should fix #151 reported by @bergkoet.
Currently, we are setting both a
RomanTelescope.PUPIL_RADIUSclass attribute (~correctly) and aself.pupil_radiusinstance attribute (incorrectly), which is both not working and also more complex than is necessary. This PR simplifies to just setting aself.pupil_radiusvalue, correctly. Conveniently thePUPIL_RADIUSone was only used in one single place in the code so this is not a complex edit.I moved the numeric value definition to
constants.pywhich is a better place for it anyhow.