Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enstools-encoding
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
w2w
enstools-encoding
Commits
487b7413
"git@gitlab.physik.uni-muenchen.de:w2w/autoicon.git" did not exist on "bd01baefd49fbc2cb557601b30498a74cc3bb357"
Commit
487b7413
authored
1 year ago
by
Oriol Tintó
Browse files
Options
Downloads
Patches
Plain Diff
Refactor chunking functions to chunk first in the time dimension.
parent
f4c137eb
No related branches found
No related tags found
1 merge request
!11
Chunking
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
enstools/encoding/dataset_encoding.py
+17
-6
17 additions, 6 deletions
enstools/encoding/dataset_encoding.py
with
17 additions
and
6 deletions
enstools/encoding/dataset_encoding.py
+
17
−
6
View file @
487b7413
...
...
@@ -31,6 +31,7 @@ import numpy as np
import
xarray
import
yaml
import
enstools.encoding.chunk_size
from
.
import
rules
from
.errors
import
InvalidCompressionSpecification
from
.variable_encoding
import
_Mapping
,
parse_variable_specification
,
Encoding
,
\
...
...
@@ -236,7 +237,10 @@ class DatasetEncoding(_Mapping):
all_encodings
=
{
**
coordinate_encodings
,
**
data_variable_encodings
}
# Need to specify chunk size, otherwise it breaks down.
self
.
chunk
(
encodings
=
all_encodings
)
self
.
chunk
(
encodings
=
all_encodings
,
chunk_memory_size
=
enstools
.
encoding
.
chunk_size
.
chunk_size
,
)
return
all_encodings
...
...
@@ -315,12 +319,19 @@ def find_chunk_sizes(data_array, chunk_size):
chunk_sizes
=
{}
chunk_number
=
{}
# Sort dimensions by size
dims
=
sorted
(
data_array
.
dims
,
key
=
lambda
x
:
data_array
[
x
].
shape
)
# Sort dimensions such that 'time' is always first and rest by size
dims
=
sorted
(
data_array
.
dims
,
key
=
lambda
x
:
(
x
!=
'
time
'
,
data_array
[
x
].
shape
))
pending_num_chunks
=
num_chunks
for
dim
in
dims
:
chunk_sizes
[
dim
]
=
max
(
1
,
int
(
data_array
[
dim
].
size
//
pending_num_chunks
))
chunk_number
[
dim
]
=
data_array
[
dim
].
size
//
chunk_sizes
[
dim
]
if
dim
==
'
time
'
or
pending_num_chunks
>
1
:
chunk_sizes
[
dim
]
=
max
(
1
,
int
(
data_array
[
dim
].
size
//
pending_num_chunks
))
chunk_number
[
dim
]
=
data_array
[
dim
].
size
//
chunk_sizes
[
dim
]
pending_num_chunks
=
math
.
ceil
(
pending_num_chunks
/
chunk_number
[
dim
])
pending_num_chunks
=
math
.
ceil
(
pending_num_chunks
/
chunk_number
[
dim
])
else
:
# If we have already chunked in the 'time' dimension and pending_num_chunks <= 1,
# then keep the whole dimension together in one chunk
chunk_sizes
[
dim
]
=
data_array
[
dim
].
size
return
chunk_sizes
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