Skip to content

Commit 43c24df

Browse files
committed
Bump CommonDataModel and replace getindex with DiskArrays.readblock!
1 parent 516b2f0 commit 43c24df

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
1616
[compat]
1717
Aqua = "0.8.9"
1818
CSV = "0.10"
19-
CommonDataModel = "0.3"
19+
CommonDataModel = "0.4"
2020
Compat = "4.10"
2121
Dates = "1"
2222
DiskArrays = "0.3, 0.4"

src/Instruments/IASI/VariableExtra.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function CDM.variable(
2828

2929
T = eltype(disk_array)
3030
N = ndims(disk_array)
31-
return MetopVariable{T, N, R}(ds, disk_array, varname)
31+
return MetopVariable{T, N, R, typeof(disk_array)}(ds, disk_array, varname)
3232
else
3333
return default_variable(ds, varname)
3434
end
@@ -106,7 +106,7 @@ function CDM.variable(
106106
data_array = getfield(gaird, varname)
107107
T = eltype(data_array)
108108
N = ndims(data_array)
109-
return MetopVariable{T, N, R}(ds, data_array, varname)
109+
return MetopVariable{T, N, R, typeof(data_array)}(ds, data_array, varname)
110110
end
111111

112112
return default_variable(ds, varname)

src/InterfaceDataModel/variable.jl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
`MetopVariable` wraps an `AbstractArray` so it can be used with `MetopDataset`.
88
The data array is normally `AbstractMetopDiskArray`.
99
"""
10-
struct MetopVariable{T, N, R} <: CDM.AbstractVariable{T, N}
10+
struct MetopVariable{T, N, R, A <: AbstractArray{T, N}} <: CDM.AbstractVariable{T, N}
1111
parent::MetopDataset{R}
12-
data_array::AbstractArray{T, N}
12+
data_array::A
1313
field_name::Symbol
1414
end
1515

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

83-
return MetopVariable{T, N, R}(ds, disk_array, varname)
83+
return MetopVariable{T, N, R, typeof(disk_array)}(ds, disk_array, varname)
8484
end
8585

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

132132
Base.size(v::MetopVariable) = size(v.data_array)
133+
Base.parent(v::MetopVariable) = v.data_array
133134

134-
### get index
135-
function Base.getindex(v::MetopVariable, indices...)
136-
checkbounds(v, indices...)
137-
return getindex(v.data_array, indices...)
135+
function DiskArrays.readblock!(v::MetopVariable{T, N, R, <:DiskArrays.AbstractArray},
136+
aout,
137+
indexes::Vararg{OrdinalRange, N}) where {T, N, R}
138+
return DiskArrays.readblock!(parent(v), aout, indexes...)
138139
end
140+
141+
function DiskArrays.readblock!(v::MetopVariable{T, N},
142+
aout,
143+
indexes::Vararg{OrdinalRange, N}) where {T, N}
144+
aout .= getindex(parent(v), indexes...)
145+
return nothing
146+
end
147+
139148
# fix ambiguity
140149
Base.getindex(v::MetopVariable, n::CDM.CFStdName) = getindex(v::CDM.AbstractVariable, n)
141150
function Base.getindex(v::MetopVariable, name::CDM.SymbolOrString)

src/MetopDatasets.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Dates: DateFormat, Day, Millisecond, Microsecond, format
77
import CommonDataModel as CDM
88
import CSV
99
import Dates: DateTime
10-
import Base: size, keys, close, getindex
10+
import Base: size, keys, close, getindex, parent
1111
import DiskArrays
1212
using Compat: @compat
1313
using PrecompileTools: @setup_workload, @compile_workload
@@ -36,7 +36,7 @@ Returns path to folder storing reduced test data. Note that the test data is dow
3636
the first time the function it called.
3737
"""
3838
get_test_data_artifact() = joinpath(
39-
LazyArtifacts.artifact"test_data_MetopDatasets", "reduced_data")
39+
LazyArtifacts.artifact"test_data_MetopDatasets", "reduced_data")
4040

4141
export MetopDataset
4242

0 commit comments

Comments
 (0)