Skip to content

Commit

Permalink
Add trucate parameter to ng.bruker.remove_digital_filter
Browse files Browse the repository at this point in the history
When True this parameter causes the phase applied when removing the Bruker
digital filter to be truncated, this is the default option.

Closes #24
  • Loading branch information
jjhelmus committed Jan 13, 2015
1 parent f132ef9 commit 923f484
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Binary file modified examples/bruker_data/figure_nmrglue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/bruker_data/process_and_plot_nmrglue.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# process the spectrum
data = ng.proc_base.zf_size(data, 32768) # zero fill to 32768 points
data = ng.proc_base.fft(data) # Fourier transform
data = ng.proc_base.ps(data, p0=-88.0) # phase correction
data = ng.proc_base.ps(data, p0=-50.0) # phase correction
data = ng.proc_base.di(data) # discard the imaginaries
data = ng.proc_base.rev(data) # reverse the data

Expand Down
21 changes: 17 additions & 4 deletions nmrglue/fileio/bruker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ def uncomplexify_data(data_in):
}


def remove_digital_filter(dic, data):
def remove_digital_filter(dic, data, truncate=True):
"""
Remove the digital filter from Bruker data.
Expand All @@ -1375,6 +1375,11 @@ def remove_digital_filter(dic, data):
Dictionary of Bruker parameters.
data : ndarray
Array of NMR data to remove digital filter from.
truncate : bool, optional
True to truncate the phase shift prior to removing the digital filter.
This typically produces a better looking spectrum but may remove
useful data. False uses a non-truncated phase.
Returns
-------
Expand Down Expand Up @@ -1402,10 +1407,10 @@ def remove_digital_filter(dic, data):
else:
grpdly = dic['acqus']['GRPDLY']

return rm_dig_filter(data, decim, dspfvs, grpdly)
return rm_dig_filter(data, decim, dspfvs, grpdly, truncate)


def rm_dig_filter(data, decim, dspfvs, grpdly=0):
def rm_dig_filter(data, decim, dspfvs, grpdly=0, truncate_grpdly=True):
"""
Remove the digital filter from Bruker data.
Expand All @@ -1418,8 +1423,13 @@ def rm_dig_filter(data, decim, dspfvs, grpdly=0):
dspfvs : int
Firmware version (Bruker DSPFVS parameter).
grpdly : float, optional
Group delay. (Bruker GRPDLY parameter). When non-zero decom and
Group delay. (Bruker GRPDLY parameter). When non-zero decim and
dspfvs are ignored.
truncate_grpdly : bool, optional
True to truncate the value of grpdly provided or determined from
the decim and dspfvs parameters before removing the digital filter.
This typically produces a better looking spectrum but may remove useful
data. False uses a non-truncated grpdly value.
Returns
-------
Expand Down Expand Up @@ -1468,6 +1478,9 @@ def rm_dig_filter(data, decim, dspfvs, grpdly=0):
raise ValueError("decim not in lookup table")
phase = bruker_dsp_table[dspfvs][decim]

if truncate_grpdly: # truncate the phase
phase = np.floor(phase)

# and the number of points to remove (skip) and add to the beginning
skip = int(np.floor(phase + 2.)) # round up two integers
add = int(max(skip - 6, 0)) # 6 less, or 0
Expand Down

0 comments on commit 923f484

Please sign in to comment.