Skip to content

Commit

Permalink
Strong .nc IO support #32 from JuliaClimate/lonlatfirst
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris authored Nov 13, 2020
2 parents 02497e3 + 4a80b60 commit 5dd7b70
Show file tree
Hide file tree
Showing 8 changed files with 350 additions and 199 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.nc
Manifest.toml
################################################################################
# DrWatson Project Structure #
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClimateBase"
uuid = "35604d93-0fb8-4872-9436-495b01d137e2"
authors = ["Datseris <datseris.george@gmail.com>", "Philippe Roy <borghor@yahoo.ca>"]
version = "0.8.0"
version = "0.9.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
14 changes: 11 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ C = latmean(B)
```
where in this averaging process each data point is weighted by the cosine of its latitude.

## Making a `ClimArray`
You can create a `ClimArray` yourself, or you can load data from an `.nc` file with CF-conventions, using `ClimArray`.
### Making a `ClimArray`
You can create a `ClimArray` yourself, or you can load data from an `.nc` file with CF-conventions, see [NetCDF IO](@ref).
```@docs
ClimArray(::AbstractArray, ::Tuple)
```
Expand All @@ -56,7 +56,9 @@ end
```
We explicitly assume that `Lon, Lat` are measured in degrees and not radians or meters (extremely important for spatial averaging processes).

---
## NetCDF IO
ClimateBase.jl has support for `file.nc ⇆ ClimArray`.
To load a `ClimArray` directly from an `.nc` file do:
```@docs
ClimArray(::Union{String, Vector{String}})
```
Expand All @@ -73,6 +75,11 @@ nckeys
ncdetails
```

You can also write a bunch of `ClimArray`s directly into an `.nc` file with
```@docs
climarrays_to_nc
```

## Temporal
Functions related with the `Time` dimension.
```@docs
Expand Down Expand Up @@ -112,6 +119,7 @@ spacemean
spaceagg
hemispheric_means
hemispheric_functions
lonlatfirst
```

## General aggregation
Expand Down
2 changes: 1 addition & 1 deletion src/ClimateBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ClimateBase

# TODO: Be sure all exported names have docstrings
include("core/coredefs.jl")
include("core/loading_nc.jl")
include("core/nc_io.jl")
include("core/aggregation.jl")

include("physical_dimensions/spatial.jl")
Expand Down
6 changes: 6 additions & 0 deletions src/core/coredefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export EqArea, Grid, spacestructure

STANDARD_DIMS = (Lon, Lat, Time, Hei, Pre, Coord)

"""
COMMONNAMES
A dictionary of common names of dimensions (as strings) to actual dimension types.
"""
const COMMONNAMES = Dict(
"lat" => Lat,
"latitude" => Lat,
Expand All @@ -37,6 +41,7 @@ const COMMONNAMES = Dict(
"level" => Pre,
)


# the trait EqArea is for equal area grids. Functions can use the `spacestructure` and
# dispatch on `EqArea` or other types while still being type-stable
struct EqArea end
Expand Down Expand Up @@ -64,6 +69,7 @@ struct ClimArray{T,N,D<:Tuple,R<:Tuple,A<:AbstractArray{T,N},Me} <: AbstractDime
attrib::Me
end
ClimArray(A::DimensionalArray) = ClimArray(A.data, A.dims, A.refdims, A.name, A.metadata)
ClimArray(A::ClimArray; name = A.name, attrib = A.attrib) = ClimArray(A.data, A.dims, A.refdims, name, attrib)

"""
ClimArray(A::Array, dims::Tuple; name = "", attrib = nothing)
Expand Down
Loading

2 comments on commit 5dd7b70

@Datseris
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 register()

@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/24622

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.9.0 -m "<description of version>" 5dd7b7049f618ee9eead46cd965fd2f4837af463
git push origin v0.9.0

Please sign in to comment.