webbpsf icon indicating copy to clipboard operation
webbpsf copied to clipboard

Add MIRI IFU (MRS) functionality to MIRI class

Open patapisp opened this issue 1 year ago • 4 comments

Work in progress to add functionality for the MIRI IFU - Medium Resolution Spectrometer.

Added quite a few changes to webbpsf_core.py:MIRI to accommodate the instrument setup for the MRS.

  • added (hardcoded) attributes for the rotation angle of the IFU FoV, wavelength ranges of the IFU spectral channels, and updated the _IFU_pixelscale
  • added two new properties of wavelength and band
  • added two (static methods) that calculate the in-flight measured FWHM and resolving power
  • overwrote class methods for filter.setter, image_mask.setter, detector.setter, aperture name.setter
  • added method _update_detector that deals with MIRI specific detector architecture
  • overwrote class method calc_psf to accommodate the MIRI IFU PSF broadening
  • overwrote class method calc_datacube that calculate multi wavelength cubes

I hope the general structure and implementation follows webbpsf guidelines and I tried to use as much of the already implemented functionality as possible.

To Do:

  • [ ] Add to webbpsf documentation
  • [ ] Add test for MIRI-IFU
  • [ ] Add filters to filters.csv
  • [ ] Implement IFU detector PSF projection for use in forward modelling application
  • [ ] Add detector scattering effect

patapisp avatar Jul 19 '23 10:07 patapisp

@patapisp thanks so much for this PR. I added myself as a reviewer and I'll try to help with the testing and documentation.

obi-wan76 avatar Jul 19 '23 16:07 obi-wan76

@obi-wan76 thanks! As a start, this code should produce a monochromatic PSF for the MRS broadened to match the in-flight FWHM. I named the filters for the IFU "D[subband]" where D stands for dichroic (the filter that selects the wavelength range) and sub-band being one of SHORT/MEDIUM/LONG (see docs).

The main issue for compatibility I think is the handling of the siaf apertures which are a bit more complicated for the MRS and resulted in a bit of a convoluted logic in the class.

import webbpsf

miri = webbpsf.MIRI()
miri.image_mask = "MIRI-IFU_1"
miri.filter = "DSHORT"

miri._print_mrs_config()
out = miri.calc_psf(monochromatic=miri.wavelength, oversample=5, fov_arcsec=8, add_distortion=False, display=False, broadening="both")

import matplotlib.pyplot as plt
import numpy as np
plt.figure()
plt.imshow(np.log10(out[2].data), origin="lower", vmin=-6)
plt.show()
image

patapisp avatar Jul 20 '23 11:07 patapisp

@patapisp big picture question for IFU PSFs. It seems to me that we should try to be careful to distinguish between the intrinsic PSF, versus broadening from detector effects (brighter fatter and IPC and so on), versus broadening from pipeline processing and drizzling.

How have you been thinking about IFU cube sampling for this PR? Are you targeting to have the simulated PSFs match the drizzled PSFs for the default cube output parameters, or something else?

I expect you have thought about this in more detail than I have, so probably have more insights than I do...

mperrin avatar Aug 02 '23 20:08 mperrin

@mperrin that's a good point, and indeed I have been struggling to decide a clear output. The code itself is of course able to reproduce all the different PSFs of the IFU. I would give the user the ability to produce whatever they want, but I would as a default produce the standard pipeline output (in ifualign mode). An additional PSF option is the PSF projected on the detector (a feature that might come later).

Following the webbpsf convention I use an extension for the oversampled and detector sampled monochromatic PSF, and the broadened PSF as measured in the pipeline cube. Any feedback here, especially for potential user consistency between MIRI and NIRSpec is welcome!

The model currently looks like this:

image

patapisp avatar Aug 10 '23 20:08 patapisp