Chapter 6.  Adding Dimensions

Table of Contents

Adding netCDF Dimensions

Adding netCDF Dimensions

We have three dimensions to add to our empty shell of a netCDF file, latitude, longitude, and time. Another aptly-named m-file, nc_adddim.m is just what we need.

>> nc_add_dimension ( 'test.nc', 'latitude', 20 )
>> nc_add_dimension ( 'test.nc', 'longitude', 30 )
>> nc_add_dimension ( 'test.nc', 'time', 0 )
>> nc_dump ( 'test.nc' )
netcdf test.nc {

dimensions:
        latitude = 20 ;
        longitude = 30 ;
        time = UNLIMITED ; (0 currently)

}

    

Note that giving a dimension size of zero is the way to make it an unlimited dimension, which is what we want for time series.