Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make_uc not using correct obs and car #221

Open
gageoleighton opened this issue Oct 3, 2024 · 0 comments
Open

make_uc not using correct obs and car #221

gageoleighton opened this issue Oct 3, 2024 · 0 comments

Comments

@gageoleighton
Copy link

I'm simply trying to plot with ppm on the x-axis...

However, when trying to convert from varian to pipe and then "make_uc" the carrier and observe frequencies are not set correctly.
I'm a bit perplexed by this issue.
Not sure if it's something wrong with my script as I didn't see what could be going wrong with ng source code.

Before print(pdic['FDF1OBS'], pdic['FDF1CAR']) returns 799.964 4.773
While after make_uc
print(uc._car, uc._obs) returns 999.9900000000001 999.99

Any help would be most appreciated!

Also, then the ppm_scale is always 1.5 to 0.5.

import nmrglue as ng
import matplotlib.pyplot as plt

dic, data = ng.varian.read("test")

udic = ng.varian.guess_udic(dic, data)
udic[0]['size'] = 22322
udic[0]['complex'] = True
udic[0]['encoding'] = 'direct'
udic[0]['sw'] = 11160.714
udic[0]['obs'] = 799.964
udic[0]['car'] = 4.773*799.964
udic[0]['label'] = 'H1'

C = ng.convert.converter()
C.from_varian(dic, data, udic)
pdic, pdata = C.to_pipe()

pdic, pdata = ng.pipe_proc.sp(pdic, pdata, off=0.35, end=0.98)
pdic, pdata = ng.pipe_proc.zf(pdic, pdata, auto=True)
pdic, pdata = ng.pipe_proc.ft(pdic, pdata, auto=True)
pdic, pdata = ng.pipe_proc.ps(pdic, pdata, p0=30.0, p1=0.0)
pdic, pdata = ng.pipe_proc.di(pdic, pdata)

print(pdic['FDF1OBS'], pdic['FDF1CAR'])
uc = ng.pipe.make_uc(pdic, pdata)
print(uc._car, uc._obs)

# Pick peaks
threshold = 10e7
peaks = ng.peakpick.pick(pdata[0], pthres=threshold, algorithm='downward')

fig = plt.figure()
ax = fig.add_subplot(111)

ax.plot(uc.ppm_scale(),pdata[0],'k-')

for n, peak in enumerate(peaks):
    height = pdata[0][int(peak['X_AXIS'])]
    ppm = uc.ppm(peak['X_AXIS'])
    ax.scatter(ppm, height, marker='o', color='r', s=100, alpha=0.5)
    ax.text(ppm, height + threshold/5, n+1)


ax.invert_xaxis()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant