OttoStruve / muler

A Python package for working with pipeline-produced spectra from IGRINS, HPF, and Keck NIRSPEC
https://muler.readthedocs.io
MIT License
15 stars 9 forks source link

Questions on the blaze function template #117

Closed caponepascal closed 1 year ago

caponepascal commented 2 years ago

I have some general questions regarding the blaze function template used when running .deblaze().

Firstly, I would like to know more on how the blaze function template is obtained. Somewhere on this GitHub page (I can't seem to find the exact place again though, sorry), both a 2021 median and Goldilocks calibration data are mentioned. I know that HPF spectra can be deblazed using a LDLS spectrum (https://github.com/grzeimann/Goldilocks_Documentation/blob/master/README.md#sky-subtraction-and-deblazing). Does the blaze function template used by muler then simply come from these Goldilocks products?

Secondly, I looked at the actual blaze function template and noticed some "wiggles" in the flux especially in the redder orders. What are these features? Are these a "mathematical" (in the sense of the computation used to obtain the template) or rather a "physical" (as intrinsic to the blaze function) artefact?

Thank you in advance for the help!

gully commented 2 years ago

Hi @caponepascal thank you for raising this Issue! 🙏

It appears you are referring to the blaze file at this line: https://github.com/OttoStruve/muler/blob/6387c94e5440f781c4197cc0074d6745b8123784/src/muler/hpf.py#L49

That file indeed has three columns: wavelength_Angstrom,blaze_2021,blaze_Goldilocks

And yes, Goldilocks comes from Goldilocks and the blaze_2021 is the 2021 median.

Does the blaze function template used by muler then simply come from these Goldilocks products?

Yes The pipeline defaults to using the Goldilocks version, which can be seen as the default kwarg on this line:

https://github.com/OttoStruve/muler/blob/6387c94e5440f781c4197cc0074d6745b8123784/src/muler/hpf.py#L227

The main difference between the two static blaze templates are bias and variance:

After some visual inspection and consideration of typical use cases we decided the Goldilocks version with lower variance would be preferred for most users.

What are these features? Are these a "mathematical" (in the sense of the computation used to obtain the template) or rather a "physical" (as intrinsic to the blaze function) artefact?

The root cause of any given wiggle in the blaze function may be difficult to attribute without more information. A plausible physical or numerical origin could be prescribed, but one should not jump to conclusions without carefully drilling down into the specific subregions you refer to. Some subregions near water absorption can exhibit nearly chaotic behavior, for example.

Some heuristics may help you reach an expedient solution: if the 2021 median and the Goldilocks versions both share the features it may point towards a genuine instrumental signal. If the two methods diverge, perhap the numerical differences between the techniques are to blame, and therefore the numerical interpretation prevails. Which scenario do you find for your spectral regions of interest?

In general, these blaze functions should be considered as "coarse". They are intended for quick-look analysis, and make some strong assumptions, such as the blaze function being static-in-time, as opposed to changing-in-time. In reality we know that the blaze function changes secularly over time as the throughput of the fibers and overall instrument change from year-to-year and season-to-season and possibly night-to-night.

Ideally one should observe an A0V calibrator close-in-time to your observation. If you apply the deblaze operation to both your target and the A0V calibrator, the blaze term will reside in both the numerator and denominator. So the blaze will cancel out entirely. But then you may have incomple cancellation of the A0V lines, yielding different residuals in your spectrum, which may outweigh your blaze residuals.

Here are two other relevant Issues or Pull Requests that discuss the heritage of the method and some of the considerations that went into the design:

20

https://github.com/OttoStruve/muler/pull/27

gully commented 1 year ago

Thank you again @caponepascal for raising this question, and for engaging with the repository. Did the response adequately answer your question? I am closing this issue due to inactivity and in hopes that this answer satisfied your needs. If you still have any questions feel free to re-open this Issue or open a new one. Best wishes and good luck with your project! :pray: