@@ -11,20 +11,21 @@ Return a tuple of integers with the size of the variable `var`.
11
11
Note that the size of a variable can change, i.e. for a variable with an
12
12
unlimited dimension.
13
13
"""
14
- Base. size (v:: CFVariable ) = size (v. var)
14
+ Base. size (v:: CFVariable ) = size (parent (v))
15
+ Base. parent (v:: CFVariable ) = v. var
15
16
16
- name (v:: CFVariable ) = name (v . var )
17
- dataset (v:: CFVariable ) = dataset (v . var )
17
+ name (v:: CFVariable ) = name (parent (v) )
18
+ dataset (v:: CFVariable ) = dataset (parent (v) )
18
19
19
20
20
- # be aware that for GRIBDatasets v.attrib is different from v.var .attrib
21
+ # be aware that for GRIBDatasets v.attrib is different from parent(v) .attrib
21
22
attribnames (v:: CFVariable ) = keys (v. attrib)
22
23
attrib (v:: CFVariable ,name:: SymbolOrString ) = v. attrib[name]
23
24
defAttrib (v:: CFVariable ,name,value) = v. attrib[name] = value
24
25
delAttrib (v:: CFVariable ,name) = delete! (v,name)
25
26
26
- dimnames (v:: CFVariable ) = dimnames (v . var )
27
- dim (v:: CFVariable ,name:: SymbolOrString ) = dim (v . var ,name)
27
+ dimnames (v:: CFVariable ) = dimnames (parent (v) )
28
+ dim (v:: CFVariable ,name:: SymbolOrString ) = dim (parent (v) ,name)
28
29
29
30
# necessary for IJulia if showing a variable from a closed file
30
31
Base. show (io:: IO ,:: MIME"text/plain" ,v:: AbstractVariable ) = show (io,v)
@@ -215,7 +216,7 @@ missing_values(v::CFVariable) = v._storage_attrib.missing_values
215
216
216
217
# collect all possible fill values
217
218
function fill_and_missing_values (v:: CFVariable )
218
- T = eltype (v . var )
219
+ T = eltype (parent (v) )
219
220
fv = ()
220
221
if ! isnothing (fillvalue (v))
221
222
fv = (fillvalue (v),)
@@ -448,29 +449,29 @@ end
448
449
# @inline CFinvtransformdata(data::Char,fv,scale_factor,add_offset,time_origin,time_factor,DT) = CFtransform_replace_missing(data,fv)
449
450
450
451
function Base. getindex (v:: CFVariable , indexes:: TIndices... )
451
- data = v . var [indexes... ]
452
+ data = parent (v) [indexes... ]
452
453
return CFtransformdata (data,fill_and_missing_values (v),scale_factor (v),add_offset (v),
453
454
time_origin (v),time_factor (v),maskingvalue (v),eltype (v))
454
455
end
455
456
456
457
function Base. setindex! (v:: CFVariable ,data:: Array{Missing,N} ,indexes:: TIndices... ) where N
457
- v . var [indexes... ] = fill (fillvalue (v),size (data))
458
+ parent (v) [indexes... ] = fill (fillvalue (v),size (data))
458
459
end
459
460
460
461
function Base. setindex! (v:: CFVariable ,data:: Missing ,indexes:: TIndices... )
461
- v . var [indexes... ] = fillvalue (v)
462
+ parent (v) [indexes... ] = fillvalue (v)
462
463
end
463
464
464
465
function Base. setindex! (v:: CFVariable ,data:: Union{T,Array{T}} ,indexes:: TIndices... ) where T <: Union{AbstractCFDateTime,DateTime,Missing}
465
466
466
467
if calendar (v) != = nothing
467
468
# can throw an convertion error if calendar attribute already exists and
468
469
# is incompatible with the provided data
469
- v . var [indexes... ] = CFinvtransformdata (
470
+ parent (v) [indexes... ] = CFinvtransformdata (
470
471
data,fill_and_missing_values (v),scale_factor (v),add_offset (v),
471
472
time_origin (v),time_factor (v),
472
473
maskingvalue (v),
473
- eltype (v . var ))
474
+ eltype (parent (v) ))
474
475
return data
475
476
end
476
477
@@ -479,12 +480,12 @@ end
479
480
480
481
481
482
function Base. setindex! (v:: CFVariable ,data,indexes:: TIndices... )
482
- v . var [indexes... ] = CFinvtransformdata (
483
+ parent (v) [indexes... ] = CFinvtransformdata (
483
484
data,fill_and_missing_values (v),
484
485
scale_factor (v),add_offset (v),
485
486
time_origin (v),time_factor (v),
486
487
maskingvalue (v),
487
- eltype (v . var ))
488
+ eltype (parent (v) ))
488
489
489
490
return data
490
491
end
@@ -551,20 +552,20 @@ end
551
552
552
553
Return a tuple of strings with the dimension names of the variable `v`.
553
554
"""
554
- dimnames (v:: Union{CFVariable,MFCFVariable} ) = dimnames (v . var )
555
+ dimnames (v:: Union{CFVariable,MFCFVariable} ) = dimnames (parent (v) )
555
556
556
- name (v:: Union{CFVariable,MFCFVariable} ) = name (v . var )
557
- chunking (v:: CFVariable ,storage,chunksize) = chunking (v . var ,storage,chunksize)
558
- chunking (v:: CFVariable ) = chunking (v . var )
557
+ name (v:: Union{CFVariable,MFCFVariable} ) = name (parent (v) )
558
+ chunking (v:: CFVariable ,storage,chunksize) = chunking (parent (v) ,storage,chunksize)
559
+ chunking (v:: CFVariable ) = chunking (parent (v) )
559
560
560
- deflate (v:: CFVariable ,shuffle,dodeflate,deflate_level) = deflate (v . var ,shuffle,dodeflate,deflate_level)
561
- deflate (v:: CFVariable ) = deflate (v . var )
561
+ deflate (v:: CFVariable ,shuffle,dodeflate,deflate_level) = deflate (parent (v) ,shuffle,dodeflate,deflate_level)
562
+ deflate (v:: CFVariable ) = deflate (parent (v) )
562
563
563
- checksum (v:: CFVariable ,checksummethod) = checksum (v . var ,checksummethod)
564
- checksum (v:: CFVariable ) = checksum (v . var )
564
+ checksum (v:: CFVariable ,checksummethod) = checksum (parent (v) ,checksummethod)
565
+ checksum (v:: CFVariable ) = checksum (parent (v) )
565
566
566
567
567
- fillmode (v:: CFVariable ) = fillmode (v . var )
568
+ fillmode (v:: CFVariable ) = fillmode (parent (v) )
568
569
569
570
570
571
# ###########################################################
585
586
586
587
Loads a NetCDF (or other format) variables `ncvar` in-place and puts the result in `data` (an
587
588
array of `eltype(ncvar)`) along the specified `indices`. `buffer` is a temporary
588
- array of the same size as data but the type should be `eltype(ncv.var )`, i.e.
589
+ array of the same size as data but the type should be `eltype(parent( ncv) )`, i.e.
589
590
the corresponding type in the files (before applying `scale_factor`,
590
591
`add_offset` and masking fill values). Scaling and masking will be applied to
591
592
the array `data`.
@@ -608,17 +609,17 @@ ds = Dataset("file.nc")
608
609
ncv = ds["vgos"];
609
610
# data and buffer must have the right shape and type
610
611
data = zeros(eltype(ncv),size(ncv)); # here Vector{Float64}
611
- buffer = zeros(eltype(ncv.var ),size(ncv)); # here Vector{Int16}
612
+ buffer = zeros(eltype(parent( ncv) ),size(ncv)); # here Vector{Int16}
612
613
NCDatasets.load!(ncv,data,buffer,:,:,:)
613
614
close(ds)
614
615
```
615
616
"""
616
617
@inline function load! (v:: Union{CFVariable{T,N},MFCFVariable{T,N},SubVariable{T,N}} , data, buffer, indices:: TIndices... ) where {T,N}
617
618
618
- if v . var == nothing
619
+ if parent (v) == nothing
619
620
return load! (v,indices... )
620
621
else
621
- load! (v . var ,buffer,indices... )
622
+ load! (parent (v) ,buffer,indices... )
622
623
fmv = fill_and_missing_values (v)
623
624
return CFtransformdata! (data,buffer,fmv,scale_factor (v),add_offset (v),
624
625
time_origin (v),time_factor (v),
0 commit comments