Skip to content

Commit 0eb537c

Browse files
remove reference to NetCDF
1 parent ed5a70a commit 0eb537c

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

docs/src/index.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11

2-
## Abstract types
2+
## Data types
33

44
In order to implement a new dataset based `CommonDataModel.jl`
55
one has to create two types derived from:
6-
1 .`AbstractVariable`: a variable with named dimension and metadata
7-
2. `AbstractDataset`: a collection of variable with named dimension, metadata and sub-groups. The sub-groups are also `AbstractDataset`.
86

7+
1. [`AbstractVariable`](#CommonDataModel.AbstractVariable): a variable with named dimension and metadata
8+
2. [`AbstractDataset`](#CommonDataModel.AbstractDataset): a collection of variable with named dimension, metadata and sub-groups. The sub-groups are also `AbstractDataset`.
9+
10+
11+
`CommonDataModel.jl` also provides a type `CFVariable` which wraps a type derived from `AbstractVariable` and applies the scaling described in
12+
[`cfvariable`](#CommonDataModel.cfvariable).
913

1014
Overview of methods:
1115

12-
| | get names | get value | write / set value |
13-
|------------|---------------|------------|-------------------|
14-
| Dimensions | `dimnames` | `dim` | `defDim` |
15-
| Attributes | `attribnames` | `attrib` | `defAttrib` |
16-
| Variables | `varnames` | `variable` | `defVar` |
17-
| Groups | `groupnames` | `group` | `defGroup` |
16+
| | get names | get value e| write / set value |
17+
|------------|-----------------------------------------------|-----------------------------------------|-------------------------------------------|
18+
| Dimensions | [`dimnames`](#CommonDataModel.dimnames) | [`dim`](#CommonDataModel.dim) | [`defDim`](#CommonDataModel.defDim) |
19+
| Attributes | [`attribnames`](#CommonDataModel.attribnames) | [`attrib`](#CommonDataModel.attrib) | [`defAttrib`](#CommonDataModel.defAttrib) |
20+
| Variables | [`varnames`](#CommonDataModel.varname s) | [`variable`](#CommonDataModel.variable) | [`defVar`](#CommonDataModel.defVar) |
21+
| Groups | [`groupnames`](#CommonDataModel.groupnames) | [`group`](#CommonDataModel.group) | [`defGroup`](#CommonDataModel.defGroup) |
1822

1923
For read-only datasets, the methods in last column are not implemented.
2024

src/cfvariable.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dataset(v::CFVariable) = dataset(v.var)
2727

2828
attribnames(v::CFVariable) = keys(v.attrib)
2929
attrib(v::CFVariable,name::AbstractString) = v.attrib[name]
30+
defAttrib(v::CFVariable,name,value) = defAttrib(v.var,name,value)
3031

3132
dimnames(v::CFVariable) = dimnames(v.var)
3233
dim(v::CFVariable,name::AbstractString) = dim(v.var,name)
@@ -40,12 +41,12 @@ Base.display(v::AbstractVariable) = show(stdout,v)
4041
"""
4142
v = cfvariable(ds::NCDataset,varname::AbstractString; <attrib> = <value>)
4243
43-
Return the NetCDF variable `varname` in the dataset `ds` as a
44+
Return the variable `varname` in the dataset `ds` as a
4445
`NCDataset.CFVariable`. The keyword argument `<attrib>` are
45-
the NetCDF attributes (`fillvalue`, `missing_value`, `scale_factor`, `add_offset`,
46+
the attributes (`fillvalue`, `missing_value`, `scale_factor`, `add_offset`,
4647
`units` and `calendar`) relevant to the CF conventions.
4748
By specifing the value of these attributes, the one can override the value
48-
specified in the NetCDF file. If the attribute is set to `nothing`, then
49+
specified in the data set. If the attribute is set to `nothing`, then
4950
the attribute is not loaded and the corresponding transformation is ignored.
5051
This function is similar to `ds[varname]` with the additional flexibility that
5152
some variable attributes can be overridden.
@@ -409,7 +410,7 @@ function Base.setindex!(v::CFVariable,data::Union{T,Array{T,N}},indexes::Union{I
409410
return data
410411
end
411412

412-
throw(NetCDFError(-1, "Time units and calendar must be defined during defVar and cannot change"))
413+
@error "Time units and calendar must be defined during defVar and cannot change"
413414
end
414415

415416

@@ -440,7 +441,7 @@ end
440441
"""
441442
_getattrib(ds,v,parentname,attribname,default)
442443
443-
Get a NetCDF attribute, looking also at the parent variable name
444+
Get an attribute, looking also at the parent variable name
444445
(linked via the bounds attribute as following the CF conventions).
445446
The default value is returned if the attribute cannot be found.
446447
"""

test/test_scaling.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ CDM.defDim(md,"lat",size(data,2))
105105
mv = CDM.defVar(md,"data",eltype(data),("lon","lat"), attrib = OrderedDict{String,Any}(
106106
"units" => "days since 2000-01-01"))
107107

108+
CDM.defAttrib(mv,"foo","bar")
109+
110+
@test CDM.attrib(mv,"foo") == "bar"
111+
108112
mv.var[:,:] .= data
109113

110114
@test CDM.dim(md,"lon") == size(data,1)
@@ -124,4 +128,6 @@ md["data"][1,2] = DateTime(2000,2,1)
124128

125129

126130
@test CDM.dataset(md["data"]) == md
131+
132+
127133
close(md)

0 commit comments

Comments
 (0)