Dimensions
In the NetCDF data model, dimension have names and a length (but possibly an unlimited length) and are defined for a NetCDF dataset (or group). For a given Variable or CFVariable,the names of the corresponding dimensions are obtained with using dimnames.
Base.keys — Methodkeys(d::Dimensions)Return a list of all dimension names in NCDataset ds.
Examples
julia> ds = NCDataset("results.nc", "r");
julia> dimnames = keys(ds.dim)Base.haskey — Methodhaskey(ds::NCDataset,name)
haskey(d::Dimensions,name)
haskey(ds::Attributes,name)Return true if the NCDataset ds (or dimension/attribute list) has a variable (dimension/attribute) with the name name. For example:
ds = NCDataset("/tmp/test.nc","r")
if haskey(ds,"temperature")
println("The file has a variable 'temperature'")
end
if haskey(ds.dim,"lon")
println("The file has a dimension 'lon'")
endThis example checks if the file /tmp/test.nc has a variable with the name temperature and a dimension with the name lon.
NCDatasets.defDim — FunctiondefDim(ds::NCDataset,name,len)Define a dimension in the data set ds with the given name and length len. If len is the special value Inf, then the dimension is considered as unlimited, i.e. it will grow as data is added to the NetCDF file.
For example:
ds = NCDataset("/tmp/test.nc","c")
defDim(ds,"lon",100)This defines the dimension lon with the size 100.
NCDatasets.unlimited — Methodunlimited(d::Dimensions)Return the names of all unlimited dimensions.
Base.setindex! — MethodBase.setindex!(d::Dimensions,len,name::AbstractString)Defines the dimension called name to the length len. Generally dimension are defined by indexing, for example:
ds = NCDataset("file.nc","c")
ds.dim["longitude"] = 100If len is the special value Inf, then the dimension is considered as unlimited, i.e. it will grow as data is added to the NetCDF file.
One can iterate over a list of dimensions as follows:
for (dimname,dim) in ds.dims
# all dimensions
@show (dimname,dim)
end