Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with camera.get_output_resolution_matrix #126

Closed
julienguy opened this issue May 4, 2023 · 6 comments
Closed

Issue with camera.get_output_resolution_matrix #126

julienguy opened this issue May 4, 2023 · 6 comments
Assignees

Comments

@julienguy
Copy link
Contributor

julienguy commented May 4, 2023

camera.get_output_resolution_matrix is returning the resolution matrix of spectra for the output wavelength grid.
It is deriving it from the input resolution matrix and the input wavelength grid that is finer than the output.
I do not understand the result from this routine that does a complex treatment of indices to average some elements of the sparse matrix.

I think we should expect an output resolution with rms_out close to sqrt( rms_in^2 + bin_width_out^2/12 - bin_width_in^2/12 ) which is resulting frm the convolution of the input resolution and a bin of given width (after subtracting the contribution of the input bin size)

In $DESIMODEL/data/specpsf/psf-quicksim.fits , at 4000A, fwhm_wave = 1.718A , giving sigma = 1.718/(2 * np.sqrt(2 * np.log(2)) = 1.718 / 2.35 = 0.731 A.
The output wavelength grid of quickspectra is 0.8 A , so I would expect the output resolution to have a rms ~= sqrt(0.731**2+0.8**2/12.-0.2**2/12.) = 0.764 A.

But the function camera.get_output_resolution_matrix returns a resolution with a rms of 0.795A which looks like the rebinning has been performed twice ...

Screenshot from 2023-05-04 11-05-54

@julienguy julienguy assigned julienguy and dkirkby and unassigned julienguy May 4, 2023
@julienguy
Copy link
Contributor Author

There is another ambiguity because the input resolution in the code is directly a Gaussian of FWHM given in $DESIMODEL/data/specpsf/psf-quicksim.fits which ignores the input bin size (which is 0.2A by default). This effect is however smaller than the one mentioned above.

@julienguy
Copy link
Contributor Author

I ran a simulation test with a delta function at 4000A as input and confirm the above. I measure a output line sigma=0.769A.

@p-slash
Copy link
Contributor

p-slash commented May 8, 2023

@julienguy I had this simple change some weeks ago, which you can now find on this branch. The changes are minor. I shift every row of the input resolution matrix to the center of the coarse grid.

This gives a one-smoothed resolution matrix, but it does not work like spectro-perfectionism, i.e. Obs != NewResoMat x model.

@dkirkby
Copy link
Member

dkirkby commented May 9, 2023

Just catching up now. The resolution matrix computed by this function is not used internally in specsim, so any problems here should not affect the simulated spectra. Does the simulation test you ran at 4000A contradict this assertion @julienguy ?

@julienguy
Copy link
Contributor Author

It is used in desispec in quickspectra.
https://github.com/desihub/desisim/blob/50998bfa41c5ebfc61930d352a455ea0f913584c/py/desisim/scripts/quickspectra.py#L242
Naim's correction is working fine (I validated it with my 4000A line test), we indeed have recenter the resolution before averaging in one direction. More details will be given in the PR to come.

@julienguy
Copy link
Contributor Author

Solved with PR #128.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants