cylammarco / ASPIRED

Automated SpectroPhotometric Image REDuction (ASPIRED)
https://aspired.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
30 stars 4 forks source link

sensitivity curve should be a polynomial fit #34

Closed cylammarco closed 3 years ago

cylammarco commented 3 years ago

compute_sensitivity is using an interpolation function instead of a polynomial fit. This leads to a noisy sensitivity curve, which is significantly worse near the detector edges.

rjs3273 commented 3 years ago

This is such a tough one. Certainly a polynomial option would be a great thing to offer. The problem is it is very instrument dependent. If you have a sensitivity that gradually rises, peaks and gradually falls then a polynomial is great. If you have a fairly flat response that plummets rapidly at the ends (like sprat) then polynomials can be poor. Sharp bends are terrible for polynomial too. But you are right, if the interpolation becomes unstable then the polynomial can be better. I have no proof of this, but my gut says the safest default may be very low order (linear?) interpolation function. Ultimately though my experience with every instrument is endless tinkering to really optimise and picking the right function is always a compromise, never quite ideal so there is not guaranteed best and safe answer.

cylammarco commented 3 years ago

Perhaps I should keep the interpolation method as the default but also provide a polynomial fit option. The add_sensitivity_itp(...) should change to calling a new function add_sensitivity(..., method='interpolation') where the method accepts 'interpolation', 'polynomial' or a callable function. Also need to add a new function add_sensitivity_poly(...).

cylammarco commented 3 years ago

Instead of having separate itp or poly, changed the sensitivity_itp to sensitivity_func that can hold either an interpolated function or a polynomial function. The default setting is still using interpolation because it is much more stable, I do not recommend using polynomial in an automated reduction unless the sensitivity is known to be well described by a low order polynomial.