Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
[compat]
Aqua = "0.8.9"
CSV = "0.10"
CommonDataModel = "0.3"
CommonDataModel = "0.4"
Compat = "4.10"
Dates = "1"
DiskArrays = "0.3, 0.4"
Expand Down
4 changes: 2 additions & 2 deletions src/Instruments/IASI/VariableExtra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function CDM.variable(

T = eltype(disk_array)
N = ndims(disk_array)
return MetopVariable{T, N, R}(ds, disk_array, varname)
return MetopVariable{T, N, R, typeof(disk_array)}(ds, disk_array, varname)
else
return default_variable(ds, varname)
end
Expand Down Expand Up @@ -106,7 +106,7 @@ function CDM.variable(
data_array = getfield(gaird, varname)
T = eltype(data_array)
N = ndims(data_array)
return MetopVariable{T, N, R}(ds, data_array, varname)
return MetopVariable{T, N, R, typeof(data_array)}(ds, data_array, varname)
end

return default_variable(ds, varname)
Expand Down
23 changes: 16 additions & 7 deletions src/InterfaceDataModel/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
`MetopVariable` wraps an `AbstractArray` so it can be used with `MetopDataset`.
The data array is normally `AbstractMetopDiskArray`.
"""
struct MetopVariable{T, N, R} <: CDM.AbstractVariable{T, N}
struct MetopVariable{T, N, R, A <: AbstractArray{T, N}} <: CDM.AbstractVariable{T, N}
parent::MetopDataset{R}
data_array::AbstractArray{T, N}
data_array::A
field_name::Symbol
end

Expand Down Expand Up @@ -80,7 +80,7 @@ function default_variable(ds::MetopDataset{R}, varname::CDM.SymbolOrString) wher
T = eltype(disk_array)
N = ndims(disk_array)

return MetopVariable{T, N, R}(ds, disk_array, varname)
return MetopVariable{T, N, R, typeof(disk_array)}(ds, disk_array, varname)
end

function default_dimnames(v::MetopVariable{T, N, R}) where {T, N, R}
Expand Down Expand Up @@ -130,12 +130,21 @@ function CDM.attrib(v::MetopVariable, name::CDM.SymbolOrString)
end

Base.size(v::MetopVariable) = size(v.data_array)
Base.parent(v::MetopVariable) = v.data_array

### get index
function Base.getindex(v::MetopVariable, indices...)
checkbounds(v, indices...)
return getindex(v.data_array, indices...)
function DiskArrays.readblock!(v::MetopVariable{T, N, R, <:DiskArrays.AbstractArray},
aout,
indexes::Vararg{OrdinalRange, N}) where {T, N, R}
return DiskArrays.readblock!(parent(v), aout, indexes...)
end

function DiskArrays.readblock!(v::MetopVariable{T, N},
aout,
indexes::Vararg{OrdinalRange, N}) where {T, N}
aout .= getindex(parent(v), indexes...)
return nothing
end

# fix ambiguity
Base.getindex(v::MetopVariable, n::CDM.CFStdName) = getindex(v::CDM.AbstractVariable, n)
function Base.getindex(v::MetopVariable, name::CDM.SymbolOrString)
Expand Down
4 changes: 2 additions & 2 deletions src/MetopDatasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Dates: DateFormat, Day, Millisecond, Microsecond, format
import CommonDataModel as CDM
import CSV
import Dates: DateTime
import Base: size, keys, close, getindex
import Base: size, keys, close, getindex, parent
import DiskArrays
using Compat: @compat
using PrecompileTools: @setup_workload, @compile_workload
Expand Down Expand Up @@ -36,7 +36,7 @@ Returns path to folder storing reduced test data. Note that the test data is dow
the first time the function it called.
"""
get_test_data_artifact() = joinpath(
LazyArtifacts.artifact"test_data_MetopDatasets", "reduced_data")
LazyArtifacts.artifact"test_data_MetopDatasets", "reduced_data")

export MetopDataset

Expand Down
Loading