Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
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
Tom Rink
python
Commits
4f7178e9
Commit
4f7178e9
authored
9 months ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot
parent
9fa27fc6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/util/split_nc4.py
+3
-3
3 additions, 3 deletions
modules/util/split_nc4.py
with
3 additions
and
3 deletions
modules/util/split_nc4.py
+
3
−
3
View file @
4f7178e9
...
...
@@ -5,16 +5,16 @@ import numpy as np
def
split_dataset
(
input_file
,
output_pattern
,
dim_name
,
chunk_size
):
# Load the input dataset
ds
=
nc
.
Dataset
(
input_file
,
'
r
'
,
format
=
'
NETCDF4
'
)
dim_size
=
len
(
ds
.
dimensions
[
dim_name
])
outer_
dim_size
=
len
(
ds
.
dimensions
[
dim_name
])
# Calculate the number of chunks
num_chunks
=
int
(
np
.
ceil
(
dim_size
/
chunk_size
))
num_chunks
=
int
(
np
.
ceil
(
outer_
dim_size
/
chunk_size
))
# Loop through each chunk
for
i
in
range
(
num_chunks
-
1
):
# Determine the start and end indices of this chunk
start
=
i
*
chunk_size
end
=
min
((
i
+
1
)
*
chunk_size
,
dim_size
)
end
=
min
((
i
+
1
)
*
chunk_size
,
outer_
dim_size
)
# Slicing along our dimension of interest
slice_indices
=
slice
(
start
,
end
)
...
...
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