-
Notifications
You must be signed in to change notification settings - Fork 13
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
Load vendor files #65
Closed
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2ada499
load 1d bruker files
mccarthy677 9123856
added author and email
mccarthy677 4330a14
add nmrglue to the requirements.
deepanshs db6aa1d
moved into folder
mccarthy677 96ad310
Merge branch 'load_vendor_files' of https://github.com/mccarthy677/mr…
mccarthy677 a2437d0
corrected author/email, fixed offsets
mccarthy677 b978afb
Merge branch 'master' into load_vendor_files
deepanshs 0626b9d
Added test data,reformatted load funcs,added ipynb
mccarthy677 69d1f59
Merge branch 'load_vendor_files' of https://github.com/mccarthy677/mr…
mccarthy677 87a9edb
added load_agilent function
mccarthy677 707be10
fixed artifact
mccarthy677 5f30a0c
- simplified code.
deepanshs 291edb5
your changes,i need to commit prior to push/pull
mccarthy677 3feee8c
Merge branch 'master' into load_vendor_files
mccarthy677 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# -*- coding: utf-8 -*- | ||
import csdmpy as cp | ||
import nmrglue as ng | ||
|
||
|
||
def load_bruker_1d(filename): | ||
dic, data = ng.bruker.read(filename) | ||
udic = ng.bruker.guess_udic(dic, data) | ||
|
||
dims = list() | ||
for key, value in list(udic.items()): | ||
if type(key) == int: | ||
obj = cp.Dimension( | ||
type="linear", | ||
count=value["size"], | ||
increment=(str(1 / value["sw"]) + " s"), | ||
coordinates_offset=(str(1 / value["car"]) + " s"), | ||
origin_offset=(str(1e-6 / value["obs"]) + " s"), | ||
label=value["label"], | ||
) | ||
dims.append(obj) | ||
# dims = [cp.LinearDimension( | ||
# count=value['size'], | ||
# increment=(str(1 / value['sw']) + ' s'), | ||
# coordinates_offset=(str(1 / value['car']) + ' s'), | ||
# origin_offset=(str(1e-6 / value['obs']) + ' s'), | ||
# label=value['label']) | ||
# for key, value in list(udic.items()) if type(key) == int | ||
# ] | ||
csdm_data = cp.CSDM( | ||
dimensions=dims, dependent_variables=[cp.as_dependent_variable(data)] | ||
) | ||
return csdm_data, udic | ||
|
||
|
||
# def plot_bruker_2d(data_2d): | ||
# x = data_2d.dimensions | ||
# y = data_2d.dependent_variables | ||
# | ||
# x0 = x[0].coordinates | ||
# x1 = x[1].coordinates | ||
# | ||
# y00 = y[0].components[0] | ||
# | ||
# si = x[0].increment | ||
# extent = ( | ||
# (x0[0] - 0.5 * si).value, | ||
# (x0[-1] + 0.5 * si).value, | ||
# x1[0].value, | ||
# x1[-1].value, | ||
# ) | ||
# | ||
# fig, axi = plt.subplots( | ||
# 2, 2, gridspec_kw={"width_ratios": [4, 1], "height_ratios": [1, 4]} | ||
# ) | ||
# | ||
# ax = axi[1, 0] | ||
# im = NonUniformImage(ax, interpolation="nearest", | ||
# extent=extent, cmap="bone_r") | ||
# im.set_data(x0, x1, y00.real / y00.real.max()) | ||
# | ||
# cbar = fig.colorbar(im) | ||
# cbar.ax.set_ylabel(y[0].axis_label[0]) | ||
# | ||
# ax.images.append(im) | ||
# for i in range(x1.size): | ||
# ax.plot(x0, np.ones(x0.size) * x1[i], "k--", linewidth=0.5) | ||
# ax.grid(axis="x", color="k", linestyle="--", | ||
# linewidth=0.5, which="both") | ||
# | ||
# ax.set_xlim([extent[0], extent[1]]) | ||
# ax.set_ylim([extent[2], extent[3]]) | ||
# ax.set_xlabel(x[0].axis_label) | ||
# ax.set_ylabel(x[1].axis_label) | ||
# ax.set_title(y[0].name) | ||
# | ||
# ax0 = axi[0, 0] | ||
# top = y00[-1].real | ||
# ax0.plot(x0, top, "k", linewidth=0.5) | ||
# ax0.set_xlim([extent[0], extent[1]]) | ||
# ax0.set_ylim([top.min(), top.max()]) | ||
# ax0.axis("off") | ||
# | ||
# ax1 = axi[1, 1] | ||
# right = y00[:, 513].real | ||
# ax1.plot(right, x1, "k", linewidth=0.5) | ||
# ax1.set_ylim([extent[2], extent[3]]) | ||
# ax1.set_xlim([right.min(), right.max()]) | ||
# ax1.axis("off") | ||
# | ||
# axi[0, 1].axis("off") | ||
# | ||
# plt.tight_layout(pad=0.0, w_pad=0.0, h_pad=0.0) | ||
# plt.subplots_adjust(wspace=0.025, hspace=0.05) | ||
# plt.show() | ||
|
||
|
||
# csdm_data, universal_dict = load_bruker_1d("ba2p2o7_zg") | ||
# csdm_data, universal_dict = load_bruker_1d("bruker_1d") | ||
|
||
|
||
# pp.pprint(universal_dict) | ||
# print(csdm_data) | ||
# plot_bruker_2d(data_2d) | ||
|
||
# ax = plt.subplot(projection="csdm") | ||
# ax.plot(csdm_data) | ||
# plt.tight_layout() | ||
# plt.show() | ||
|
||
|
||
# x = range(len(csdm_data)) | ||
# plt.plot(csdm_data) | ||
# plt.show() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace these lines with
reciprocal={"coordinates_offset": f'{value["car"]} Hz', "origin_offset": f'{value["obs"]} MHz'}
The parameter belong in the reciprocal object.