Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Fix spectra does not deal correctly with set_reference #55

Open
RadixSeven opened this issue Aug 22, 2011 · 1 comment
Open

Fix spectra does not deal correctly with set_reference #55

RadixSeven opened this issue Aug 22, 2011 · 1 comment

Comments

@RadixSeven
Copy link
Collaborator

When doing a set reference, fix_spectra copies the values to the right x indices in the new spectrum but has two problems

  1. y values that will be moved to x's outside the range after the shift are discarded. This can conceivably lose precious data that doesn't need to be lost.
  2. y values from x's that originally lie outside the range and that the shift would bring into the range are left unchanged - giving realistic looking garbage

The second problem is the worst. Imagine that a spectrum needs to be shifted 7 array indices. Then the first seven and second seven indices will hold duplicate y values. This can throw off error standard-deviation estimation which uses the first 30 points.

A proposed fix

Initially, keep a different set of x-values for each spectrum. We can create this new set by adding the shift amount to each x value.

Then take the intersection of the ranges covered by the resulting x values as the new range. Choose the union for all spectra of all the x-values that fall in this range. These are the new x-values. For each spectrum, linearly interpolate the y-values at x values that were not directly measured and copy the rest.

@RadixSeven
Copy link
Collaborator Author

To reproduce

  1. Run fix_spectra
  2. Open smaller_anit.zip
  3. Set reference making 6.08-6.05 (Allantonin) go to 0.

Result

The resulting spectrum will obviously be the result of pasting a copy of the upper half of the spectrum on top of the lower half.

What was expected

The resulting spectrum should be almost unchanged with the exception of a few points lost on the edges.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant