Skip to content
Snippets Groups Projects
Commit 10ed0317 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 6714fc59
No related branches found
No related tags found
No related merge requests found
import netCDF4 as nc import netCDF4 as nc
import numpy as np import numpy as np
import xarray as xr
def split_dataset(input_file, output_pattern, dim_name, chunk_size): def split_dataset(input_file, output_pattern, dim_name, chunk_size):
...@@ -55,5 +56,12 @@ def split_dataset(input_file, output_pattern, dim_name, chunk_size): ...@@ -55,5 +56,12 @@ def split_dataset(input_file, output_pattern, dim_name, chunk_size):
ds.close() ds.close()
def concatenate_nc4_files(nc_files, output_file, concat_dim_name='time'):
datasets = [xr.open_dataset(nc_file) for nc_file in nc_files]
combined = xr.concat(datasets, dim=concat_dim_name)
combined.to_netcdf(output_file)
print(f"All files combined and saved to {output_file}")
# Call the function # Call the function
# split_dataset('input.nc', 'output_{}.nc', 'time', 10) # split_dataset('input.nc', 'output_{}.nc', 'time', 10)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment