Skip to content

Commit

Permalink
from pyhht to emd library
Browse files Browse the repository at this point in the history
  • Loading branch information
georgievgeorgi committed Mar 13, 2024
1 parent 2d5c3b0 commit d71c14e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"numpy",
"pandas",
"pydantic==1.*",
"pyhht",
"emd",
"renishawWiRE", # rc1-parser
"scikit-learn",
"scipy>=1.8.0,<1.12",
"scipy>=1.8.0",
"spc-io~=0.0.2", # rc1-parser
"statsmodels",
"uncertainties",
Expand Down
14 changes: 9 additions & 5 deletions src/ramanchada2/spectrum/filters/sharpen_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from pydantic import validate_arguments, confloat, PositiveInt
from scipy import signal, fft
import pyhht
import emd

from ramanchada2.misc.spectrum_deco import add_spectrum_filter
from ..spectrum import Spectrum
Expand Down Expand Up @@ -41,16 +41,20 @@ def hht_sharpening(old_spe: Spectrum,
new_spe: Spectrum, /,
movmin=100
):
imfs = pyhht.emd.EMD(old_spe.y, old_spe.x).decompose()
imfs = emd.sift.sift(old_spe.y).T
freq_list = list()
for ansig in signal.hilbert(imfs):
freq_list.append(pyhht.utils.inst_freq(ansig)[0])
freq_list.append(emd.spectra.freq_from_phase(
emd.spectra.phase_from_complex_signal(ansig, ret_phase='unwrapped'), 1))
freq = np.array(freq_list)
imfsall = imfs[:, 1:-1].copy()
freq[freq < 0] = 0
freq[np.isnan(freq)] = 0
imfsall = imfs.copy()
imfsall[np.isnan(imfsall)] = 0
imfsall[freq > .3] = 0
imfsall *= freq**.5
ynew = np.sum(imfsall, axis=0)
new_spe.y = np.pad(ynew, 1)
new_spe.y = ynew
new_spe.y = new_spe.subtract_moving_minimum(movmin).normalize().y # type: ignore
new_spe.y = new_spe.y * old_spe.y.max() + old_spe.y.min()

Expand Down

0 comments on commit d71c14e

Please sign in to comment.