marblestation / iSpec

Download input files from https://www.cfa.harvard.edu/~sblancoc/iSpec/dev/input.tar.gz
http://www.blancocuaresma.com/s/
GNU Affero General Public License v3.0
29 stars 6 forks source link

Inconsistency between synthetic spectra obtained within GUI and using python code #10

Open nagarajvernekar30 opened 5 months ago

nagarajvernekar30 commented 5 months ago

Hello,

I was using iSpec to create a grid of low resolution synthetic spectra. For this, I was using turbospectrum with VALD linelist and MARCS models. What I noticed was that, the spectrum I obtained using the python code given in example.py to generate synthetic spectrum was providing a different spectrum compared to the one obtained within the GUI. I generated sun spectra using both these and compared to real sun at 5000 resolution and found the GUI spectrum is a much better representation than the one obtained through the python code.

Upon trying a bunch of different things, I found that, this difference is not seen in high resolution. Therefore, I think its the problem of convolving the spectrum to lower resolution. I think it could be due to the fact that when the spectrum is being degraded, the code is only giving a to_resolution but not from_resolution. From past experience with degrading spectrum within iSpec GUI, I know that when the from_resolution is not provided, the degraded spectrum is not good enough.

Do you think this is correct ? If this is correct, then why don't the GUI face the same problem in degrading ?

marblestation commented 5 months ago

Hi @nagarajvernekar30!

I may not fully understand your question. In the GUI, when you synthesize a spectrum, a resolution is requested. Similarly, in the example.py, the example that synthesizes a spectrum also requires a resolution. In none of them a "from_resolution" is required.

In the degrade resolution function, in the GUI and in example.py you have both: the "from resolution" and the "to resolution".

Maybe you can further elaborate and provide concrete steps and code so that I can reproduce them on my end?

Thank you!

nagarajvernekar30 commented 5 months ago

So I solved this issue but this is something that needs to be addressed.

The issue is, the output obtain by synthesising a spectrum within the GUI is different from the output obtained from Python code. This difference increases with a decrease in the resolution. From the tests I did, it has to do with the way the spectrum is convolved after the synthesis to obtain the desired resolution. I am not entirely sure why the convolution takes place properly when I use the GUI but it does not work properly when using Python code.

The workaround that I found to solve this issue was, as the maximum step size within the GUI is 0.01 nm, the user should also restrict their step size to this value even using Python code (I was initially using a larger step size and therefore I was facing issues). Once the synthesis is performed at 0.01 nm, then the spectrum must be resampled to the desired step size. In my case, I wanted a step size of 0.025 nm as my resolution was 5000. Maybe you can add this point to the example.py file so that others will know this when they are synthesising lower-resolution grids.

To reproduce this issue:

  1. Generate an optical solar spectrum using the VALD line list, marcs model and turbospectrum code (this is what I used.) within the GUI. The resolution is 5000 but the step size is 0.025 nm. As this is not allowed in GUI, you keep the step size to a max of 0.01 nm and once the spectrum is made, you resample it to 0.025 nm.

  2. Generate the same solar spectrum with the python using the same parameters and models. Keep the resolution at 5000 and step size at 0.025nm.

  3. Compare the spectrum obtained from step 1 and step 2. They will not be the same. Thanks..