Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xsocs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kmap
xsocs
Commits
93ec4f86
Commit
93ec4f86
authored
Nov 20, 2018
by
Thomas Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a per process cache to avoid reading the same data multiple time
parent
541a3c70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
xsocs/process/fit/peak_fit.py
xsocs/process/fit/peak_fit.py
+16
-5
No files found.
xsocs/process/fit/peak_fit.py
View file @
93ec4f86
...
...
@@ -187,6 +187,7 @@ class PeakFitter(Thread):
self
.
__set_status
(
self
.
RUNNING
)
pool
=
multiprocessing
.
Pool
(
self
.
__n_proc
)
fit_results
=
[]
for
result
in
pool
.
imap
(
functools
.
partial
(
_fit_process
,
...
...
@@ -256,6 +257,10 @@ class PeakFitter(Thread):
return
results
# Per process cache for fit process
_per_process_cache
=
None
def
_fit_process
(
index
,
qspace_f
,
fit_type
=
FitTypes
.
GAUSSIAN
,
...
...
@@ -278,11 +283,17 @@ def _fit_process(index,
:return: Fit results as a list of results for dim0, dim1 and dim2
:rtype: List[List[Union[float,bool]]]
"""
# Read data from file
with
QSpaceH5
.
QSpaceH5
(
qspace_f
)
as
qspace_h5
:
axes
=
qspace_h5
.
qspace_dimension_values
hits
=
qspace_h5
.
histo
qspace
=
qspace_h5
.
qspace_slice
(
index
)
global
_per_process_cache
if
_per_process_cache
is
None
:
# Initialize per process cache
qspace_h5
=
QSpaceH5
.
QSpaceH5
(
qspace_f
)
_per_process_cache
=
(
qspace_h5
,
qspace_h5
.
qspace_dimension_values
,
qspace_h5
.
histo
)
# Retrieve data/file from cache
qspace_h5
,
axes
,
hits
=
_per_process_cache
# Load qspace
qspace
=
qspace_h5
.
qspace_slice
(
index
)
# apply Qspace ROI
if
roiIndices
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment