[PIPE2D-1065] fitPfsFluxReference.py: whitening and LSF convolution must be done in a correct order Created: 03/Aug/22  Updated: 16/Aug/22  Resolved: 16/Aug/22

Status: Done
Project: DRP 2-D Pipeline
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Normal
Reporter: sogo.mineo Assignee: sogo.mineo
Resolution: Done Votes: 0
Labels: flux-calibration
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Reviewers: hassan

 Description   

Currently, a model spectrum is whitened first, and then convolved with an LSF.

https://github.com/Subaru-PFS/drp_stella/blob/4bd04590532a0a19ac25d9c9f7c0631749f1c3db/python/pfs/drp/stella/fitPfsFluxReference.py#L502

if whitenedModel is None:
    whitenedModel = self.whitenSpectrum(model, mode="model")
convolvedModel = convolveLsf(
    whitenedModel, pfsMergedLsf[pfsConfig.fiberId[iFiber]], obsSpectrum.wavelength
)

This order is wrong because the LSF convolution lowers the (whitened) continuum by ~10% due to absorption lines densely present. Since the density of the absorption lines differs from place to place, the continuum resulting from the convolution is not even horizontal. The model spectra must be convolved with the LSF first, and then be whitened.

The problem is that whitening takes very long time. In the current code shown above, the result of whitening is cached. But such caching cannot be done if convolution takes place before whitening, for the LSFs vary from fiber to fiber. We do not want to make this task any more time-consuming.

I will therefore split the method whitenSpectrum() into two: continuum = computeContinuum() and continuum.whiten(spectrum). I will compute the continuum of the model using the average LSF, and then cache the continuum.

if continuum is None:
    continuum = self.computeContinuum(convolveLsf(model, averageLSF), mode="model")
convolvedModel = convolveLsf(
    model, pfsMergedLsf[pfsConfig.fiberId[iFiber]], obsSpectrum.wavelength
)
whitenedModel = continuum.whiten(convolvedModel)

From experiments, the continuum made in this way is different from the continuum computed with the correct LSF by < 1% for most cases if FWHM difference is < 50%.



 Comments   
Comment by sogo.mineo [ 08/Aug/22 ]

Could you review this PR?
(This is not urgent because I am not available until Aug 16)

Comment by hassan [ 11/Aug/22 ]

Suggested changes look fine. Minor comment related to the setting of flux values in the case of bad pixels added to pull request. https://github.com/Subaru-PFS/drp_stella/pull/283

Comment by sogo.mineo [ 16/Aug/22 ]

Thanks for your review. I replied to the comment and merged the branch without modification.

Generated at Sat Feb 10 16:02:17 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.