Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyrost
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
Container 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
Nikolay Ivanov
pyrost
Commits
14d56768
Commit
14d56768
authored
3 years ago
by
simply-nicky
Browse files
Options
Downloads
Patches
Plain Diff
Default backend changed to numpy
parent
787a648f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dev.ipynb
+55
-69
55 additions, 69 deletions
dev.ipynb
pyrost/bin/beam_calc.pyx
+7
-7
7 additions, 7 deletions
pyrost/bin/beam_calc.pyx
pyrost/simulation/st_sim.py
+1
-1
1 addition, 1 deletion
pyrost/simulation/st_sim.py
with
63 additions
and
77 deletions
dev.ipynb
+
55
−
69
View file @
14d56768
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
pyrost/bin/beam_calc.pyx
+
7
−
7
View file @
14d56768
...
...
@@ -18,7 +18,7 @@ def init_fftw():
init_fftw
()
def
next_fast_len
(
np
.
npy_intp
target
,
str
backend
=
'
fftw
'
):
def
next_fast_len
(
np
.
npy_intp
target
,
str
backend
=
'
numpy
'
):
r
"""
Find the next fast size of input data to fft, for zero-padding, etc.
FFT algorithms gain their speed by a recursive divide and conquer strategy.
This relies on efficient functions for small prime factors of the input length.
...
...
@@ -180,7 +180,7 @@ cdef np.ndarray gf_fft(np.ndarray inp, np.ndarray sigma, np.ndarray order, str m
return
out
def
gaussian_filter
(
inp
:
np
.
ndarray
,
sigma
:
object
,
order
:
object
=
0
,
mode
:
str
=
'
reflect
'
,
cval
:
cython
.
double
=
0.
,
truncate
:
cython
.
double
=
4.
,
backend
:
str
=
'
fftw
'
,
cval
:
cython
.
double
=
0.
,
truncate
:
cython
.
double
=
4.
,
backend
:
str
=
'
numpy
'
,
num_threads
:
cython
.
uint
=
1
)
->
np
.
ndarray
:
r
"""
Multidimensional Gaussian filter. The multidimensional filter is implemented as
a sequence of 1-D FFT convolutions.
...
...
@@ -266,9 +266,9 @@ cdef np.ndarray ggm_fft(np.ndarray inp, np.ndarray sigma, str mode, double cval,
raise
ValueError
(
'
{:s} is invalid backend
'
.
format
(
backend
))
return
out
def
gaussian_gradient_magnitude
(
inp
:
np
.
ndarray
,
sigma
:
object
,
mode
:
str
=
'
mirror
'
,
def
gaussian_gradient_magnitude
(
inp
:
np
.
ndarray
,
sigma
:
object
,
mode
:
str
=
'
reflect
'
,
cval
:
cython
.
double
=
0.
,
truncate
:
cython
.
double
=
4.
,
backend
:
str
=
'
fftw
'
,
num_threads
:
cython
.
uint
=
1
)
->
np
.
ndarray
:
backend
:
str
=
'
numpy
'
,
num_threads
:
cython
.
uint
=
1
)
->
np
.
ndarray
:
r
"""
Multidimensional gradient magnitude using Gaussian derivatives. The multidimensional
filter is implemented as a sequence of 1-D FFT convolutions.
...
...
@@ -319,7 +319,7 @@ def gaussian_gradient_magnitude(inp: np.ndarray, sigma: object, mode: str='mirro
return
ggm
(
input
=
inp
,
sigma
=
sigma
,
mode
=
mode
,
cval
=
cval
,
truncate
=
truncate
)
def
rsc_wp
(
wft
:
np
.
ndarray
,
dx0
:
cython
.
double
,
dx
:
cython
.
double
,
z
:
cython
.
double
,
wl
:
cython
.
double
,
axis
:
cython
.
int
=-
1
,
backend
:
str
=
'
fftw
'
,
wl
:
cython
.
double
,
axis
:
cython
.
int
=-
1
,
backend
:
str
=
'
numpy
'
,
num_threads
:
cython
.
uint
=
1
)
->
np
.
ndarray
:
r
"""
Wavefront propagator based on Rayleigh-Sommerfeld convolution
method [RSC]_. Propagates a wavefront `wft` by `z` distance
...
...
@@ -405,7 +405,7 @@ def rsc_wp(wft: np.ndarray, dx0: cython.double, dx: cython.double, z: cython.dou
def
fraunhofer_wp
(
wft
:
np
.
ndarray
,
dx0
:
cython
.
double
,
dx
:
cython
.
double
,
z
:
cython
.
double
,
wl
:
cython
.
double
,
axis
:
cython
.
int
=-
1
,
backend
:
str
=
'
fftw
'
,
num_threads
:
cython
.
uint
=
1
)
->
np
.
ndarray
:
backend
:
str
=
'
numpy
'
,
num_threads
:
cython
.
uint
=
1
)
->
np
.
ndarray
:
r
"""
Fraunhofer diffraction propagator. Propagates a wavefront `wft` by
`z` distance downstream. You can choose between
'
fftw
'
and
'
numpy
'
backends for FFT calculations.
'
fftw
'
backend supports multiprocessing.
...
...
@@ -582,7 +582,7 @@ def mll_profile(x_arr: np.ndarray, layers: np.ndarray, complex mt0,
return
ml_profile_wrapper
(
x_arr
,
layers
,
0.
,
mt0
,
mt1
,
sigma
,
num_threads
)
def
fft_convolve
(
array
:
np
.
ndarray
,
kernel
:
np
.
ndarray
,
axis
:
cython
.
int
=-
1
,
mode
:
str
=
'
constant
'
,
cval
:
cython
.
double
=
0.0
,
backend
:
str
=
'
fftw
'
,
mode
:
str
=
'
constant
'
,
cval
:
cython
.
double
=
0.0
,
backend
:
str
=
'
numpy
'
,
num_threads
:
cython
.
uint
=
1
)
->
np
.
ndarray
:
"""
Convolve a multi-dimensional `array` with one-dimensional `kernel` along the
`axis` by means of FFT. Output has the same size as `array`.
...
...
This diff is collapsed.
Click to expand it.
pyrost/simulation/st_sim.py
+
1
−
1
View file @
14d56768
...
...
@@ -101,7 +101,7 @@ class STSim(DataContainer):
init_set
=
{
'
bars
'
,
'
det_wfx
'
,
'
det_wfy
'
,
'
det_ix
'
,
'
det_iy
'
,
'
lens_wfx
'
,
'
lens_wfy
'
,
'
n_x
'
,
'
n_y
'
,
'
roi
'
,
'
smp_pos
'
,
'
smp_profile
'
,
'
smp_wfx
'
,
'
smp_wfy
'
}
def
__init__
(
self
,
params
,
backend
=
'
fftw
'
,
num_threads
=
None
,
**
kwargs
):
def
__init__
(
self
,
params
,
backend
,
num_threads
=
None
,
**
kwargs
):
if
num_threads
is
None
:
num_threads
=
cpu_count
()
if
not
backend
in
self
.
backends
:
...
...
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