How to splitting 1 NCfile to many NCfile based on time variable?

1 view (last 30 days)
Hi matlab forum,
I'm having trouble about splitting 1 nc file into multiple nc files (files attached here). In this case I want to split file by time.
ncdisp('data_mercator.nc')
Variables:
depth
Size: 35x1
Dimensions: depth
Datatype: single
Attributes:
valid_min = 0.49402
valid_max = 902.3393
units = 'm'
positive = 'down'
unit_long = 'Meters'
long_name = 'Depth'
standard_name = 'depth'
axis = 'Z'
_CoordinateAxisType = 'Height'
_CoordinateZisPositive = 'down'
latitude
Size: 3x1
Dimensions: latitude
Datatype: single
Attributes:
valid_min = -8.25
valid_max = -8.0833
step = 0.083336
units = 'degrees_north'
unit_long = 'Degrees North'
long_name = 'Latitude'
standard_name = 'latitude'
axis = 'Y'
_CoordinateAxisType = 'Lat'
vo
Size: 3x3x35x70
Dimensions: longitude,latitude,depth,time
Datatype: int16
Attributes:
long_name = 'Northward velocity'
standard_name = 'northward_sea_water_velocity'
units = 'm s-1'
unit_long = 'Meters per second'
_FillValue = -32767
add_offset = 0
scale_factor = 0.00061037
cell_methods = 'area: mean'
thetao
Size: 3x3x35x70
Dimensions: longitude,latitude,depth,time
Datatype: int16
Attributes:
long_name = 'Temperature'
standard_name = 'sea_water_potential_temperature'
units = 'degrees_C'
unit_long = 'Degrees Celsius'
_FillValue = -32767
add_offset = 21
scale_factor = 0.00073244
cell_methods = 'area: mean'
uo
Size: 3x3x35x70
Dimensions: longitude,latitude,depth,time
Datatype: int16
Attributes:
long_name = 'Eastward velocity'
standard_name = 'eastward_sea_water_velocity'
units = 'm s-1'
unit_long = 'Meters per second'
_FillValue = -32767
add_offset = 0
scale_factor = 0.00061037
cell_methods = 'area: mean'
time
Size: 70x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'Time (hours since 1950-01-01)'
standard_name = 'time'
calendar = 'gregorian'
units = 'hours since 1950-01-01 00:00:00'
axis = 'T'
_CoordinateAxisType = 'Time'
valid_min = 636252
valid_max = 637908
so
Size: 3x3x35x70
Dimensions: longitude,latitude,depth,time
Datatype: int16
Attributes:
long_name = 'Salinity'
standard_name = 'sea_water_salinity'
units = '1e-3'
unit_long = 'Practical Salinity Unit'
_FillValue = -32767
add_offset = -0.0015259
scale_factor = 0.0015259
cell_methods = 'area: mean'
longitude
Size: 3x1
Dimensions: longitude
Datatype: single
Attributes:
valid_min = 114.3333
valid_max = 114.5
step = 0.083328
units = 'degrees_east'
unit_long = 'Degrees East'
long_name = 'Longitude'
standard_name = 'longitude'
axis = 'X'
_CoordinateAxisType = 'Lon'
zos
Size: 3x3x70
Dimensions: longitude,latitude,time
Datatype: int16
Attributes:
long_name = 'Sea surface height'
standard_name = 'sea_surface_height_above_geoid'
units = 'm'
unit_long = 'Meters'
add_offset = 0
scale_factor = 0.00030519
_FillValue = -32767
cell_methods = 'area: mean'
So I want 70 nc file outputs, like:
data_mercator_01.nc
data_mercator_02.nc
data_mercator_03.nc .... until
data_mercator_70.nc
Based on the matlab documentation here, it only presents combined nc files, not splitting. Can someone give an idea on this?, my first thought must be related to looping, right?
thx forum

Answers (0)

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!