Skip to content

Commit 7ca7730

Browse files
Merge branch 'main' of github.com:JuliaGeo/AbstractDatasets.jl
2 parents 8e1375c + 43d4fbe commit 7ca7730

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+6247
-257
lines changed

.github/workflows/IntegrationTest.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: IntegrationTest
22
on:
33
push:
4-
branches: [main]
5-
tags: [v*]
64
pull_request:
75

86
concurrency:
@@ -24,16 +22,17 @@ jobs:
2422
- {user: Alexander-Barth, repo: NCDatasets.jl}
2523
- {user: JuliaGeo, repo: GRIBDatasets.jl}
2624
- {user: Alexander-Barth, repo: TIFFDatasets.jl}
25+
- {user: JuliaGeo, repo: ZarrDatasets.jl}
2726

2827
steps:
29-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
3029
- uses: julia-actions/setup-julia@v1
3130
with:
3231
version: ${{ matrix.julia-version }}
3332
arch: x64
3433
- uses: julia-actions/julia-buildpkg@latest
3534
- name: Clone Downstream
36-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3736
with:
3837
repository: ${{ matrix.package.user }}/${{ matrix.package.repo }}
3938
path: downstream

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
arch:
1818
- x64
1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- uses: julia-actions/setup-julia@v1
2222
with:
2323
version: ${{ matrix.version }}
2424
arch: ${{ matrix.arch }}
25-
- uses: actions/cache@v3
25+
- uses: actions/cache@v4
2626
env:
2727
cache-name: cache-artifacts
2828
with:
@@ -39,14 +39,14 @@ jobs:
3939
- uses: julia-actions/julia-runtest@latest
4040
continue-on-error: ${{ matrix.version == 'nightly' }}
4141
- uses: julia-actions/julia-processcoverage@v1
42-
- uses: codecov/codecov-action@v3
42+
- uses: codecov/codecov-action@v4
4343
with:
4444
file: lcov.info
4545
docs:
4646
name: Documentation
4747
runs-on: ubuntu-latest
4848
steps:
49-
- uses: actions/checkout@v3
49+
- uses: actions/checkout@v4
5050
- uses: julia-actions/setup-julia@v1
5151
with:
5252
version: '1'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.jl.cov
33
*.jl.*.cov
44
*~
5+
*.html
56

67
# Files generated by invoking Julia with --track-allocation
78
*.jl.mem

Project.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
name = "CommonDataModel"
22
uuid = "1fbeeb36-5f17-413c-809b-666fb144f157"
3-
authors = ["Alexander Barth <[email protected]>"]
43
keywords = ["netcdf", "GRIB", "climate and forecast conventions", "oceanography", "meteorology", "climatology", "opendap"]
54
license = "MIT"
65
desc = "CommonDataModel is a module that defines types common to NetCDF and GRIB data"
7-
version = "0.2.4"
6+
authors = ["Alexander Barth <[email protected]>"]
7+
version = "0.3.6"
88

99
[deps]
1010
CFTime = "179af706-886a-5703-950a-314cd64e0468"
11-
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1211
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
13-
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
12+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1413
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
14+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
15+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1516

1617
[compat]
17-
julia = "1.6"
18-
Preferences = "1.3"
19-
DataStructures = "0.17, 0.18"
2018
CFTime = "0.1.1"
19+
DataStructures = "0.17, 0.18"
20+
Preferences = "1.3"
21+
julia = "1.6"

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
[![Build Status](https://github.com/JuliaGeo/CommonDataModel.jl/workflows/CI/badge.svg)](https://github.com/JuliaGeo/CommonDataModel.jl/actions)
22
[![codecov.io](http://codecov.io/github/JuliaGeo/CommonDataModel.jl/coverage.svg?branch=main)](http://app.codecov.io/github/JuliaGeo/CommonDataModel.jl?branch=main)
3+
[![documentation stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliageo.github.io/CommonDataModel.jl/stable/)
34
[![documentation dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliageo.github.io/CommonDataModel.jl/dev/)
45

56

67
This package contains abstracts type definition to ensure compatibility of the package [GRIBDatasets](https://github.com/JuliaGeo/GRIBDatasets.jl) and [NCDatasets](https://github.com/Alexander-Barth/NCDatasets.jl) for manipulating GRIB and NetCDF files. This package aims to follow the [Common Data Model](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf_data_model.html) and the [CF (climate and forecast models) Metadata Conventions](https://cfconventions.org/).
78

8-
This package is at a very early state of developpement.
9+
Features include:
10+
* query and edit metadata of arrays and datasets
11+
* virtually concatenating multiple files along a given dimension
12+
* create a virtual subset (`view`) by indices or by values of coordinate variables (`CommonDataModel.select`, `CommonDataModel.@select`)
13+
* group, map and reduce a variable (`CommonDataModel.groupby`, `CommonDataModel.@groupby`) and rolling reductions like running means `CommonDataModel.rolling`)
14+
915

1016
Here is minimal example for loading GRIB or NetCDF files.
1117

@@ -16,7 +22,7 @@ import SomeDatasets # where SomeDatasets is either GRIBDatasets or NCDatasets
1622
ds = SomeDatasets.Dataset("file_name")
1723

1824
# ntime is the number of time instances
19-
ntime = CDM.dims(ds)["time"]
25+
ntime = ds.dim["time"] # or CDM.dims(ds)["time"]
2026

2127
# create an array-like structure v corresponding to variable temperature
2228
v = ds["temperature"]
@@ -28,13 +34,14 @@ subdata = v[10:30,30:5:end]
2834
data = v[:,:]
2935

3036
# load a global attribute
31-
title = CDM.attribs(ds)["title"]
37+
title = ds.attrib["title"] # or CDM.attribs(ds)["title"]
3238
close(ds)
3339
```
3440

3541
Most users would typically import [`GRIBDatasets`](https://github.com/JuliaGeo/GRIBDatasets.jl) and [`NCDatasets`](https://github.com/Alexander-Barth/NCDatasets.jl) directly and not `CommonDataModel`. One should import `CommonDataModel` only to extent the functionality of `GRIBDatasets` and `NCDatasets`.
3642

37-
As a proof-of-concept, there is also an [`TIFFDatasets`](https://github.com/Alexander-Barth/TIFFDatasets.jl) package for GeoTIFF files.
43+
There is also an [`TIFFDatasets`](https://github.com/Alexander-Barth/TIFFDatasets.jl) package for GeoTIFF files and
44+
[`ZarrDatasets`](https://github.com/JuliaGeo/ZarrDatasets.jl) package for Zarr datasets.
3845

3946
# File conversions
4047

@@ -48,5 +55,7 @@ using Downloads: download
4855

4956
grib_file = download("https://github.com/JuliaGeo/GRIBDatasets.jl/raw/98356af026ea39a5ec0b5e64e4289105492321f8/test/sample-data/era5-levels-members.grib")
5057
netcdf_file = "test.nc"
51-
NCDatasets.write(netcdf_file,GRIBDataset(grib_file))
58+
NCDataset(netcdf_file,"c") do ds
59+
NCDatasets.write(ds,GRIBDataset(grib_file))
60+
end
5261
```

docs/Project.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
[deps]
2-
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
2+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
33
CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157"
4+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
5+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
6+
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
7+
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
8+
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
9+
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
10+
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
11+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
12+
13+
[compat]
14+
NCDatasets = "0.14"
15+
GLMakie = "0.8"

docs/make.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
using Documenter: Documenter, makedocs, deploydocs
2-
using CommonDataModel: CommonDataModel
2+
using CommonDataModel
3+
using Literate
4+
5+
Literate.markdown(
6+
"docs/src/tutorial1.jl","docs/src",
7+
execute = true,
8+
documenter = true,
9+
# We add the credit to Literate.jl the footer
10+
credit = false,
11+
)
12+
13+
if get(ENV, "CI", "false") == "true"
14+
# remove datafile on CI
15+
rm("docs/src/sst.day.mean.2023.nc")
16+
end
317

418
makedocs(;
519
modules=[CommonDataModel],
@@ -9,9 +23,12 @@ makedocs(;
923
prettyurls=get(ENV, "CI", "false") == "true",
1024
canonical="https://juliageo.github.io/CommonDataModel.jl",
1125
assets=String[],
26+
footer = "Powered by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl), [Literate.jl](https://github.com/fredrikekre/Literate.jl) and the [Julia Programming Language](https://julialang.org/)"
27+
1228
),
1329
pages=[
1430
"Home" => "index.md",
31+
"Tutorials" => "tutorial1.md",
1532
],
1633
)
1734

docs/src/index.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,47 @@
44
In order to implement a new dataset based `CommonDataModel.jl`
55
one has to create two types derived from:
66

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`.
7+
1. [`AbstractVariable`](@ref CommonDataModel.AbstractVariable): a variable with named dimension and metadata
8+
2. [`AbstractDataset`](@ref CommonDataModel.AbstractDataset): a collection of variable with named dimension, metadata and sub-groups. The sub-groups are also `AbstractDataset`.
99

1010

1111
`CommonDataModel.jl` also provides a type `CFVariable` which wraps a type derived from `AbstractVariable` and applies the scaling described in
12-
[`cfvariable`](#CommonDataModel.cfvariable).
12+
[`cfvariable`](@ref CommonDataModel.cfvariable).
1313

1414
Overview of methods:
1515

16-
| | get names | get values | 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) |
16+
| | get names | get values | set value | property |
17+
|------------|-----------------------------------------------|-----------------------------------------|-------------------------------------------|--------|
18+
| Dimensions | [`dimnames`](@ref CommonDataModel.dimnames) | [`dim`](@ref CommonDataModel.dim) | [`defDim`](@ref CommonDataModel.defDim) | `dim` |
19+
| Attributes | [`attribnames`](@ref CommonDataModel.attribnames) | [`attrib`](@ref CommonDataModel.attrib) | [`defAttrib`](@ref CommonDataModel.defAttrib) | `attrib` |
20+
| Variables | [`varnames`](@ref CommonDataModel.varnames) | [`variable`](@ref CommonDataModel.variable) | [`defVar`](@ref CommonDataModel.defVar) | - |
21+
| Groups | [`groupnames`](@ref CommonDataModel.groupnames) | [`group`](@ref CommonDataModel.group) | [`defGroup`](@ref CommonDataModel.defGroup) | `group` |
2222

23-
For read-only datasets, the methods in last column are not implemented.
23+
For read-only datasets, the methods in "set value" column are not to be implemented.
24+
Attributes can also be delete with the [`delAttrib`](@ref CommonDataModel.delAttrib) functions.
25+
26+
Every struct deriving from `AbstractDataset` have automaticaly the special properties `dim`, `attrib` and `group` which act like dictionaries (unless a field with this name already exists).
27+
For `attrib`, calls to `keys`, `getindex` and `setindex!`, `delete!` are dispated to `attribnames`, `attrib`,`defAttrib`, and `delAttrib` respectively (and likewise for other properties). For example:
28+
29+
``` julia
30+
using NCDatasets
31+
ds = NCDataset("file.nc")
32+
# setindex!(ds.attrib,...) here automatically calls defAttrib(ds,...)
33+
ds.attrib["title"] = "my amazing results";
34+
```
35+
Variables can be accessed by directly indexing the `AbstractDataset`.
36+
37+
Every struct deriving from `AbstractVariable` has the properties `dim`, and `attrib`.
38+
39+
Current functionalities of CommonDataModel include:
40+
* virtually concatenating files along a given dimension
41+
* create a virtual subset (([`view`](@ref Base.view))) by indices or by values of coordinate variables ([`select`](@ref CommonDataModel.select), [`@select`](@ref CommonDataModel.@select))
42+
* group, map and reduce a variable ([`groupby`](@ref CommonDataModel.groupby), [`@groupby`](@ref CommonDataModel.@groupby), [`rolling`](@ref CommonDataModel.rolling))
43+
44+
45+
46+
## API
2447

2548
```@autodocs
26-
Modules = [CommonDataModel]
49+
Modules = [CommonDataModel, CommonDataModel.CatArrays]
2750
```

0 commit comments

Comments
 (0)