Skip to content

Commit

Permalink
fix: update frequency for the simulated spectrum (#2534)
Browse files Browse the repository at this point in the history
close #2533
  • Loading branch information
hamed-musallam committed Jul 21, 2023
1 parent 1ca5910 commit 23958a0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/component/reducer/actions/SpectrumsActions.ts
Expand Up @@ -651,23 +651,29 @@ function handleSimulateSpectrum(
(s) => s.id === draft.view.currentSimulatedSpectrumKey,
);
}
const { frequency, to, from } = options;

const info = {
originFrequency: frequency,
baseFrequency: frequency,
name: spinSystem,
};

if (spectrumIndex !== -1) {
(draft.data[spectrumIndex] as Spectrum1D).data = { x, re: y };
const spectrum = draft.data[spectrumIndex] as Spectrum1D;
spectrum.data = { x, re: y };
spectrum.info = { ...spectrum.info, ...info };
const [x1, x2] = draft.originDomain.xDomain;
const isInXDomain = options.to - options.from <= x2 - x1;
const isInXDomain = to - from <= x2 - x1;
setDomain(draft, { updateYDomain: false, updateXDomain: !isInXDomain });
} else {
const { frequency } = options;
const spectrum = initiateDatum1D(
{
data: { x, re: y },
info: {
isFt: true,
originFrequency: frequency,
baseFrequency: frequency,
nucleus: '1H',
name: spinSystem,
...info,
},
},
{ usedColors: draft.usedColors },
Expand Down

0 comments on commit 23958a0

Please sign in to comment.