Skip to content

Commit

Permalink
Update docs for finding variable names (#143)
Browse files Browse the repository at this point in the history
* Update docs for finding variable names

* Update Project.toml
  • Loading branch information
meggart authored Feb 24, 2021
1 parent 4179cd6 commit da5e568
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "30363a11-5582-574a-97bb-aa9a979735b9"
keywords = ["NetCDF", "IO"]
license = "MIT"
desc = "NetCDF file reading and writing"
version = "0.11.2"
version = "0.11.3"

[deps]
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/intermediate.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ NetCDF.open
## Getting information

The `NetCDF.open` function returns an object of type `NcFile` which contains meta-Information about the file and associated variables. You can index
the `NcFile` object `nc[varname]` to retrieve an `NcVar` object and retrieve information about it. You can run `names(nc)` to get a list of available variables.
the `NcFile` object `nc[varname]` to retrieve an `NcVar` object and retrieve information about it. You can run `keys(nc)` to get a list of available variables.

Most of the following functions of the medium-level interface will use either an `NcFile` or an `NcVar` object as their first argument.

Expand Down
1 change: 1 addition & 0 deletions src/NetCDF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ end
#Define getindex method to retrieve a variable
Base.getindex(nc::NcFile, i::AbstractString) = haskey(nc.vars, i) ? nc.vars[i] :
error("NetCDF file $(nc.name) does not have a variable named $(i)")
Base.keys(nc::NcFile) = keys(nc.vars)

include("netcdf_helpers.jl")

Expand Down
1 change: 1 addition & 0 deletions test/intermediate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ NetCDF.open(fn1, mode = NC_NOWRITE) do nc1
@test xs == NetCDF.readvar(nc1, "vstr")
NetCDF.readvar(nc1, "v1", start = [1, 1, 1], count = [-1, -1, -1])
@test xs == NetCDF.nc_char2string(NetCDF.readvar(nc1, "vchar"))
@test sort(["vstr", "Dim2", "v1", "Dim1", "vchar"]) == sort(collect(keys(nc1)))
end

NetCDF.open(fn2, mode = NC_NOWRITE) do nc2
Expand Down

2 comments on commit da5e568

@meggart
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/30736

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.3 -m "<description of version>" da5e568f4e95b57b5c2c4f584627271b537cd3ab
git push origin v0.11.3

Please sign in to comment.