BrownDwarf / jammer

Comparison of new synthetic model grids with data
MIT License
0 stars 0 forks source link

Use a wavelength-dependent spectral resolution taper when available #8

Closed gully closed 7 years ago

gully commented 7 years ago

Ok, I've implemented a wavelength-dependent spectral resolution taper for the SpeX Prism instrument mode. First, I digitized the resolution plot from the SpeX website: Then, I scaled the resolution to a 0.5" slit instead of a 0.3" slit. Then, I modified grid_tools.py to apply a wavelength dependent taper on the FFT:

                if self.Instrument.name == 'SPEX_PRZ':
                    #Need a wavelength dependent taper.
                    fl_final = self.wl_final*0.0
                    for j in range(len(self.wl_final)//8):
                        R_est = np.mean(self.Instrument.res_gradient()(self.wl_final[8*j:8*j+8]))
                        sigma = 299792.46/R_est / 2.35 # in km/s
                        # Instrumentally broaden the spectrum by multiplying with a Gaussian in Fourier space
                        taper = np.exp(-2 * (np.pi ** 2) * (sigma ** 2) * (self.ss ** 2))
                        FF_tap = FF * taper
                        fl_tapered = np.fft.irfft(FF_tap)
                        interp = InterpolatedUnivariateSpline(self.wl_FFT, fl_tapered, k=5)
                        fl_final[8*j:8*j+8] = interp(self.wl_final[8*j:8*j+8])
                else:
                    FF_tap = FF * self.tap... #and so on...
gully commented 7 years ago

I break up the final spectral grid into 8 pixels at a time. Recall that at this stage the final spectral grid is oversampled by typically 4x. This level of over-sampling is probably overkill, but I didn't want to introduce large discontinuities in the spectrum. This change slows down grid.py --create considerably, (by roughly a factor of 256x slower). But recall that you generally only have to run grid.py --create once, and then it is preserved for all other MCMC jobs. In fact, the library HDF5 file can (and probably should) be copied from project to project, as long as the stellar parameters fall in the same range.

gully commented 7 years ago

I could probably save some computation time by truncating fl_tapered to the relevant portion in the interpolation step. I'm assuming that the FFT dominates the computation time though.