anand0xff / ImPlaneIA

Tools for fitting (image plane fringes), calibrating, and analyzing NRM data across multiple instruments and modes
BSD 3-Clause "New" or "Revised" License
7 stars 4 forks source link

Fix spec #28

Closed rcooper295 closed 2 years ago

rcooper295 commented 2 years ago

Updates to how filter throughput and source spectrum are retrieved to remove dependence on Poppy and fix broken functions. Now this is done using three functions: get_filt_spec(): reads the throughput for the requested filter from the webbpsf-data files into a synphot spectral element. get_src_spec(): takes spectral type string and returns synphot source spectrum combine_src_filt(): combines filter and source spectrum and calculates effective stimulus in nspecbin wavelength bins across the filter. See docstrings/code for more details. These functions depend on webbpsf filter transmission files, synphot, and stsynphot to produce the final list of wavelengths and weights used to make the NRM model in fringe fitting. It allows for some flexibility in InstrumentData.NIRISS(). The argument src can be either a spectral type string (e.g. A0V, which is the default) and it will use a lookup table of Phoenix models to retrieve a spectrum, or a pre-existing synphot.Spectrum.SourceSpectrum such as a blackbody or flat spectrum. If the argument bandpass is given, it overrides all other parameters that deal with the spectrum (src, nspecbin, filt). Bandpass can be a numpy array of [(weight, wavelength)] or a synphot spectrum.

rcooper295 commented 2 years ago

To quickly see how the filter combination works, do:

from nrm_analysis.misctools import utils
utils.test_spec_comb()
anand0xff commented 2 years ago

Looks good - at some point in future there may be ways to shorten the code by using some synphot calls instead of doing some spectra, multiplicaltions bin-by-bin ourselves. The unrestricted 'bandpass' argument is excellent - very flexible usage possible!

anand0xff commented 2 years ago

I'll leave you to delete the branch.