TSFitPy-developers / TSFitPy

Turbospectrum Spectral Fitting with Python (TSFitPy)
14 stars 4 forks source link

Chi**2 going crazy #66

Closed zhukgleb closed 7 months ago

zhukgleb commented 7 months ago

The example works fine, but the real spectrum produces $\chi^2 = 999999.00000000$. Interpolation, smoothing, theoretical spectra give the same result. But the funny thing is that when synthesizing the spectrum with the given parameters in generate_synthetic_spectra.py and further fitting with the same parameters, we get the same $\chi^2 = 999999.00000000$ I acted entirely according to the instructions, no additional errors occurred when installing the package, I do not use inadequate values for temperatures/g/metallicity. add files to reproduce: 0.spec.txt spectra_parameters.csv fitlist.txt tsfitpy_input_configuration_test.cfg.txt Thank you in advance

stormnick commented 7 months ago

Hi, when you run it, what do you get printed in the terminal/console? Usually it gives a pretty good indication what goes wrong.

You can also change debug_mode to 2 in the config file and it should print even more information. The fact that generate_synthetic_spectra.py indicates that TurboSpectrum works, so could also simply be a bug on my part.

zhukgleb commented 7 months ago

out.log Hi again. Thanks for the answer! I don't see nothing special in log. Part of the code that fit as I understand it did not give any results when debugging.

stormnick commented 7 months ago

Hi, I have taken a look at the logs and it seems like you are fitting the following lines: 5415.199 and 5441.339 (see e.g. your linemask in input_files/linemask_files/Fe/fe-lmask_test.txt). However, the spectra you provided goes from 5800 up to 5900. Since there is no spectra in the fitting range, chi sqr is 999999. I should make it clear to the user that this is the reason it happens (will do in the next update), sorry!

Could you please try to either fit a line within the spectra range (for that you can change the linemask) or use another spectra that has spectra for 5400-5450 AA ranges? I think the sample spectrum in input_files/sample_spectrum/UVES_Sun-1_cleaned_norm.txt can be used for that. Based on your logs, it should work otherwise. Let me know if you get any issues!

zhukgleb commented 7 months ago

Oh, that was stupid! Thanks for the help, now it's a matter of masks.