A Step Back
I've been looking for basic ways to test twinsyn so that I can be confident that I understand its output. In our last group meeting Bob suggested that I run twinsyn on one of its own output files. If anything, one would expect it to be able to accurately fit its own output. I took a parameter list I used yesterday with about 1000 entries and reformatted one of the synthetic spectra so twinsyn could accept it as an input file. I then ran twinsyn with the same list and reexamined the chi-square results. input spectrum: 1.00 1.00 6000. 0. 2. 0.80 0.90 5800. -57. 2. output chi closest to 1: 1.00 1.00 6000. 0. 2. 0.90 1.00 6000. -56. 2. 0.10061312E+01 output lowest chi: 1.00 1.00 6000. 0. 2. 0.90 0.90 5800. -57. 2. 0.24436003 expected output 1.00 1.00 6000. 0. 2. 0.80 0.90 5800. -57. 2. 0.24528573E+00 These results are unsettling for several reasons. First, Nick and I had been working under the assumption that the output spectrum with the chi-square value closest to 1 was the best fit. Clearly that isn't the case. Also, the output spectra consistently have sharper peaks, which are often noticeably deeper or shallower than the original spectrum. The plot below, for example, shows the unmodified input spectrum in black and the newly produced spectrum with exactly the same parameters in green. At 5183.7 Å we can see a peak that the new synthetic spectrum exaggerates. We can also see how synthetic spectra always have a higher resolution than the input spectrum. The green line was constructed from an array with a little more than twice the number of data points than the input spectrum had. I didn't plot the spectrum with the lowest chi-square value because it is almost identical to the green line. The spectrum with a chi-square closest to 1 is plotted in blue. Bob and Natalie suggested that taking the resolution of the detector and input spectrum into account could help solve the problem where synthetic spectra have exaggerated dips and peaks (I should try to be more consistent when I use the terms 'dip' and 'peak' in the future). It's worth noting that there was no difference between the input spectrum and the rectified spectrum twinsyn compared with its results. A few points to remember: It's possible that twinsyn can't fit its own spectra because it initially rebins and rectifies all input spectra. Maybe they're modified and no longer identical to the next set of spectra is generates. But that doesn't solve the problem. If it doesn't recognize its own spectra, how can it properly fit others? There is a high chance that user error is the source of these problems. I need to reconsider my work process. Maybe some of my IDL procedures are subtly modifying the data in a way they shouldn't. Twinsyn's code makes it look like the best fit should have a chi-square of 0. In that case, why does what should be a spectrum identical to the input return a nonzero chi-square?