-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from JuliaGeo/abstractds
Harmonize API with NCDatasets.jl
- Loading branch information
Showing
15 changed files
with
406 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,17 @@ authors = ["tcarion <[email protected]> and contributors"] | |
version = "0.1.1" | ||
|
||
[deps] | ||
CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157" | ||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3" | ||
GRIB = "b16dfd50-4035-11e9-28d4-9dfe17e6779b" | ||
|
||
[compat] | ||
CommonDataModel = "^0.2.1" | ||
DataStructures = "0.18" | ||
DiskArrays = "0.3.0" | ||
GRIB = "0.3.0" | ||
DiskArrays = "0.3" | ||
GRIB = "0.3" | ||
julia = "1" | ||
|
||
[extras] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
# struct CFVariable{T, N, AT, TSA} <: AbstractGRIBVariable{T,N} | ||
# var::Variable{T, N, AT} | ||
# attrib::Dict{String, Any} | ||
# _storage_attrib::TSA | ||
# end | ||
|
||
# function CFVariable(ds, varname; _v = Variable(ds, varname)) | ||
# v = _v | ||
# missing_val = missing_value(v) | ||
# T = eltype(v) | ||
# N = ndims(v) | ||
|
||
# storage_attrib = ( | ||
# missing_value = missing_val, | ||
# ) | ||
|
||
# attribs = cflayer_attributes(v) | ||
|
||
# CFVariable{T, N, typeof(parent(v)), typeof(storage_attrib)}(_v, attribs, storage_attrib) | ||
# end | ||
|
||
# Base.parent(cfvar::CFVariable) = parent(cfvar.var) | ||
# Base.size(cfvar::CFVariable) = size(cfvar.var) | ||
# Base.getindex(cfvar::CFVariable, I...) = getindex(parent(cfvar), I...) | ||
|
||
# function Base.getindex(cfvar::CFVariable{T, N, TV}, I...) where {T,N,TV <: DA.AbstractDiskArray{T, N}} | ||
# A = getindex(parent(cfvar), I...) | ||
# misval = cfvar._storage_attrib.missing_value | ||
|
||
# isnothing(misval) && (return A) | ||
|
||
# # return any(x -> x == misval, A) ? replace(A, misval => missing) : A | ||
# return any(A .== misval) ? replace(A, misval => missing) : A | ||
|
||
# end | ||
|
||
# varname(cfvar::CFVariable) = varname(cfvar.var) | ||
# dims(cfvar::CFVariable) = dims(cfvar.var) | ||
|
||
_get_dim(cfvar::CFVariable, dimname) = _get_dim(cfvar.var, dimname) | ||
function cfvariable(ds, varname) | ||
v = Variable(ds, string(varname)) | ||
misval = missing_value(v) | ||
CDM.cfvariable( | ||
ds, varname; | ||
_v = v, | ||
missing_value = isnothing(misval) ? eltype(v)[] : [misval], | ||
attrib = cflayer_attributes(v), | ||
) | ||
end | ||
|
||
# In case of layer variable | ||
cflayer_attributes(var::Variable{T, N, <: DA.AbstractDiskArray{T, N}}) where {T, N} = cflayer_attributes(parent(var).layer_index) | ||
|
||
# In case of a coordinate variable | ||
cflayer_attributes(var::Variable) = var.attrib | ||
|
||
function cflayer_attributes(index::FileIndex) | ||
attributes = Dict{String, Any}() | ||
|
||
for (gribkey, cfkey) in CF_MAP_ATTRIBUTES | ||
if haskey(index, gribkey) && !occursin("unknown", getone(index, gribkey)) | ||
attributes[cfkey] = join(index[gribkey], ", ") | ||
end | ||
end | ||
|
||
return attributes | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.