Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pes_to_spec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Machine Learning projects.
pes_to_spec
Commits
69e6b0e2
Commit
69e6b0e2
authored
2 years ago
by
Danilo Ferreira de Lima
Browse files
Options
Downloads
Patches
Plain Diff
Switched back to fftconvolve.
parent
cc7a024b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pes_to_spec/__init__.py
+1
-1
1 addition, 1 deletion
pes_to_spec/__init__.py
pes_to_spec/model.py
+4
-4
4 additions, 4 deletions
pes_to_spec/model.py
with
5 additions
and
5 deletions
pes_to_spec/__init__.py
+
1
−
1
View file @
69e6b0e2
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
Estimate high-resolution photon spectrometer data from low-resolution non-invasive measurements.
Estimate high-resolution photon spectrometer data from low-resolution non-invasive measurements.
"""
"""
VERSION
=
"
0.1.
6
"
VERSION
=
"
0.1.
7
"
This diff is collapsed.
Click to expand it.
pes_to_spec/model.py
+
4
−
4
View file @
69e6b0e2
...
@@ -3,7 +3,7 @@ from __future__ import annotations
...
@@ -3,7 +3,7 @@ from __future__ import annotations
import
joblib
import
joblib
import
numpy
as
np
import
numpy
as
np
from
scipy.signal
import
convolve
from
scipy.signal
import
fft
convolve
#from scipy.signal import find_peaks_cwt
#from scipy.signal import find_peaks_cwt
from
scipy.optimize
import
fmin_l_bfgs_b
from
scipy.optimize
import
fmin_l_bfgs_b
from
sklearn.decomposition
import
PCA
from
sklearn.decomposition
import
PCA
...
@@ -331,7 +331,7 @@ class HighResolutionSmoother(TransformerMixin, BaseEstimator):
...
@@ -331,7 +331,7 @@ class HighResolutionSmoother(TransformerMixin, BaseEstimator):
gaussian
=
np
.
exp
(
-
0.5
*
(
energy
-
mu
)
**
2
/
self
.
high_res_sigma
**
2
)
gaussian
=
np
.
exp
(
-
0.5
*
(
energy
-
mu
)
**
2
/
self
.
high_res_sigma
**
2
)
gaussian
/=
np
.
sum
(
gaussian
,
axis
=
1
,
keepdims
=
True
)
gaussian
/=
np
.
sum
(
gaussian
,
axis
=
1
,
keepdims
=
True
)
# apply it to the data
# apply it to the data
high_res_gc
=
convolve
(
X
,
gaussian
,
mode
=
"
same
"
,
axes
=
1
)
high_res_gc
=
fft
convolve
(
X
,
gaussian
,
mode
=
"
same
"
,
axes
=
1
)
return
high_res_gc
return
high_res_gc
def
inverse_transform
(
self
,
Xt
:
np
.
ndarray
)
->
np
.
ndarray
:
def
inverse_transform
(
self
,
Xt
:
np
.
ndarray
)
->
np
.
ndarray
:
...
@@ -519,7 +519,7 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator):
...
@@ -519,7 +519,7 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator):
gaussian
=
np
.
exp
(
-
0.5
*
(
axis
-
sum_low_res
.
shape
[
0
]
//
2
)
**
2
/
20
**
2
)
gaussian
=
np
.
exp
(
-
0.5
*
(
axis
-
sum_low_res
.
shape
[
0
]
//
2
)
**
2
/
20
**
2
)
gaussian
/=
np
.
sum
(
gaussian
,
axis
=
0
,
keepdims
=
True
)
gaussian
/=
np
.
sum
(
gaussian
,
axis
=
0
,
keepdims
=
True
)
# apply it to the data
# apply it to the data
smoothened
=
convolve
(
sum_low_res
,
gaussian
,
mode
=
"
same
"
,
axes
=
0
)
smoothened
=
fft
convolve
(
sum_low_res
,
gaussian
,
mode
=
"
same
"
,
axes
=
0
)
peak_idx
=
[
np
.
argmax
(
smoothened
)]
peak_idx
=
[
np
.
argmax
(
smoothened
)]
if
len
(
peak_idx
)
<
1
:
if
len
(
peak_idx
)
<
1
:
raise
PromptNotFoundError
()
raise
PromptNotFoundError
()
...
@@ -1011,7 +1011,7 @@ class Model(TransformerMixin, BaseEstimator):
...
@@ -1011,7 +1011,7 @@ class Model(TransformerMixin, BaseEstimator):
M
=
self
.
wiener_filter
.
shape
[
0
]
M
=
self
.
wiener_filter
.
shape
[
0
]
B
=
expected
.
shape
[
0
]
B
=
expected
.
shape
[
0
]
assert
expected
.
shape
[
1
]
==
M
assert
expected
.
shape
[
1
]
==
M
deconvolved
=
convolve
(
expected
,
deconvolved
=
fft
convolve
(
expected
,
np
.
broadcast_to
(
self
.
wiener_filter
.
reshape
(
1
,
-
1
),
(
B
,
M
)),
np
.
broadcast_to
(
self
.
wiener_filter
.
reshape
(
1
,
-
1
),
(
B
,
M
)),
mode
=
"
same
"
,
mode
=
"
same
"
,
axes
=
1
)
axes
=
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment