@@ -2,6 +2,7 @@ abstract type AbstractGRIBVariable{T, N} <: AbstractVariable{T, N} end
2
2
3
3
"""
4
4
DiskValues{T, N, M} <: DA.AbstractDiskArray{T, N}
5
+
5
6
Object that maps the dimensions lookup to GRIB messages offsets.
6
7
`message_dims` are the dimensions that are found in the GRIB message (namely longitudes and latitudes).
7
8
`other_dims` are the dimensions that have been infered from reading the GRIB file index.
@@ -90,7 +91,7 @@ function DA.readblock!(A::DiskValues, aout, i::AbstractUnitRange...)
90
91
end
91
92
92
93
DA. eachchunk (A:: DiskValues ) = DA. GridChunks (A, size (A))
93
- DA. haschunks (A:: DiskValues ) = DA. Unchunked ()
94
+ DA. haschunks (A:: DiskValues ) = DA. Chunked () # Its basically one large chunk
94
95
95
96
"""
96
97
Variable <: AbstractArray
@@ -105,7 +106,6 @@ struct Variable{T, N, TA <: Union{Array{T, N}, DA.AbstractDiskArray{T, N}}, TP}
105
106
end
106
107
Base. parent (var:: Variable ) = var. values
107
108
Base. size (var:: Variable ) = _size_dims (var. dims)
108
- Base. getindex (var:: Variable , I... ) = getindex (parent (var), I... )
109
109
110
110
ndims (:: AbstractGRIBVariable{T,N} ) where {T,N} = N
111
111
varname (var:: Variable ) = var. name
@@ -125,6 +125,19 @@ dataset(var::AbstractGRIBVariable) = var.ds
125
125
126
126
_get_dim (var:: Variable , key:: String ) = _get_dim (var. dims, key)
127
127
128
+ DA. @implement_diskarray Variable
129
+ # Avoid DiskArrays.jl indexing when the parent is an Array
130
+ Base. getindex (var:: Variable{T,N,Array{T,N}} , I:: AbstractUnitRange... ) where {T,N} =
131
+ getindex (parent (var), I... )
132
+ Base. getindex (var:: Variable{T,N,Array{T,N}} , I... ) where {T,N} =
133
+ getindex (parent (var), I... )
134
+
135
+ function DA. readblock! (A:: Variable , aout, i:: AbstractUnitRange... )
136
+ DA. readblock! (parent (A), aout, i... )
137
+ end
138
+ DA. eachchunk (A:: Variable ) = DA. eachchunk (parent (A))
139
+ DA. haschunks (A:: Variable ) = DA. haschunks (parent (A))
140
+
128
141
function Variable (ds:: GRIBDataset , key)
129
142
dsdims = ds. dims
130
143
if key in dsdims
0 commit comments