Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
a96611b1
Commit
a96611b1
authored
9 months ago
by
fima
Browse files
Options
Downloads
Patches
Plain Diff
Saving zarr now does not use dask
parent
08915229
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/io/saving.py
+23
-8
23 additions, 8 deletions
qim3d/io/saving.py
with
23 additions
and
8 deletions
qim3d/io/saving.py
+
23
−
8
View file @
a96611b1
...
@@ -77,6 +77,7 @@ class DataSaver:
...
@@ -77,6 +77,7 @@ class DataSaver:
self
.
compression
=
kwargs
.
get
(
"
compression
"
,
False
)
self
.
compression
=
kwargs
.
get
(
"
compression
"
,
False
)
self
.
basename
=
kwargs
.
get
(
"
basename
"
,
None
)
self
.
basename
=
kwargs
.
get
(
"
basename
"
,
None
)
self
.
sliced_dim
=
kwargs
.
get
(
"
sliced_dim
"
,
0
)
self
.
sliced_dim
=
kwargs
.
get
(
"
sliced_dim
"
,
0
)
self
.
chunk_shape
=
kwargs
.
get
(
"
chunk_shape
"
,
"
auto
"
)
def
save_tiff
(
self
,
path
,
data
):
def
save_tiff
(
self
,
path
,
data
):
"""
Save data to a TIFF file to the given path.
"""
Save data to a TIFF file to the given path.
...
@@ -267,11 +268,17 @@ class DataSaver:
...
@@ -267,11 +268,17 @@ class DataSaver:
Returns:
Returns:
zarr.core.Array: The Zarr array saved on disk.
zarr.core.Array: The Zarr array saved on disk.
"""
"""
assert
isinstance
(
data
,
da
.
Array
),
'
data must be a dask array
'
# forces compute when saving to zarr
# Old version that is using dask
da
.
to_zarr
(
data
,
path
,
compute
=
True
,
overwrite
=
self
.
replace
,
compressor
=
zarr
.
Blosc
(
cname
=
'
zstd
'
,
clevel
=
3
,
shuffle
=
2
))
# assert isinstance(data, da.Array), 'data must be a dask array'
# # forces compute when saving to zarr
# da.to_zarr(data, path, compute=True, overwrite=self.replace, compressor=zarr.Blosc(cname='zstd', clevel=3, shuffle=2))
zarr_array
=
zarr
.
open
(
path
,
mode
=
"
w
"
,
shape
=
data
.
shape
,
chunks
=
self
.
chunk_shape
,
dtype
=
data
.
dtype
)
zarr_array
[:]
=
data
def
save_PIL
(
self
,
path
,
data
):
def
save_PIL
(
self
,
path
,
data
):
"""
Save data to a PIL file to the given path.
"""
Save data to a PIL file to the given path.
...
@@ -396,7 +403,14 @@ class DataSaver:
...
@@ -396,7 +403,14 @@ class DataSaver:
def
save
(
def
save
(
path
,
data
,
replace
=
False
,
compression
=
False
,
basename
=
None
,
sliced_dim
=
0
,
**
kwargs
path
,
data
,
replace
=
False
,
compression
=
False
,
basename
=
None
,
sliced_dim
=
0
,
chunk_shape
=
"
auto
"
,
**
kwargs
,
):
):
"""
Save data to a specified file path.
"""
Save data to a specified file path.
...
@@ -427,5 +441,6 @@ def save(
...
@@ -427,5 +441,6 @@ def save(
compression
=
compression
,
compression
=
compression
,
basename
=
basename
,
basename
=
basename
,
sliced_dim
=
sliced_dim
,
sliced_dim
=
sliced_dim
,
chunk_shape
=
chunk_shape
,
**
kwargs
,
**
kwargs
,
).
save
(
path
,
data
)
).
save
(
path
,
data
)
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