JuliaDataCubes / JuliaDataCubes/YAXArrays.jl

MovingWindow fills first slice of non-used axis with missing values if it is in second position

Open
#71 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
132
Forks
25
PR merge metrics
No merged PRs in 30d

Description

When I am using the MovingWindow together with the time axis, I get a full missing values block for the first slice of one of my categorical axes.
I managed to reduce it to the following MWE.
This happens only, when the varax is on the second position but then it doesn't matter how the other axes are sorted, I think.
This also doesn't happen when I change the inner function from xout=xin[:,1]to xout=xin[:,2] . I am not sure, whether this is a problem with the code or whether my mental model of the moving window functionality and where I would have to expect missing values is a bit spotty. I was surprised to change the appearance of missing values just by permuting the axes.

julia> a = Array{Union{Float64,Missing}}(rand(10,4,  40, 20));
julia> varax = CategoricalAxis("Variable", 'a':'d')
julia> tim = RangeAxis("Time", 1:10)
julia> lon = RangeAxis("Lon", 1:40)
Lon                 Axis with 40 Elements from 1 to 40

julia> lat = RangeAxis("Lat", 1:20)
Lat                 Axis with 20 Elements from 1 to 20
julia> c = YAXArray([tim, varax, lon,lat], a)
julia> indims = InDims("Time",YAXArrays.MovingWindow("Lon",1,1))
julia> r1 = mapCube(c, indims=indims, outdims=OutDims("Time")) do xout,xin
           xout[:] = xin[:,1]
       end
YAXArray with the following dimensions
Time                Axis with 10 Elements from 1 to 10
Variable            Axis with 4 elements: a b c d 
Lon                 Axis with 40 Elements from 1 to 40
Lat                 Axis with 20 Elements from 1 to 20
Total size: 250.0 KB


julia> r1[1,1,:,:]
40×20 Matrix{Union{Missing, Float64}}:
 missing  missing  missing  missing  missing  …  missing  missing  missing  missing
 missing  missing  missing  missing  missing     missing  missing  missing  missing
 missing  missing  missing  missing  missing     missing  missing  missing  missing
 missing  missing  missing  missing  missing     missing  missing  missing  missing
 ⋮                                            ⋱                             
 missing  missing  missing  missing  missing     missing  missing  missing  missing
 missing  missing  missing  missing  missing     missing  missing  missing  missing
 missing  missing  missing  missing  missing     missing  missing  missing  missing
 missing  missing  missing  missing  missing     missing  missing  missing  missing

julia> r1[1,2,:,:]
40×20 Matrix{Union{Missing, Float64}}:
 0.152638  0.558357   0.461192   0.548065   0.0779111  …  0.0304331  0.680405   0.327451
 0.052784  0.20752    0.664607   0.980943   0.87756       0.891475   0.0584611  0.381391
 0.492464  0.0813945  0.551404   0.768542   0.0143244     0.589523   0.652838   0.381952
 0.578728  0.225605   0.714316   0.267139   0.79113       0.0482949  0.198758   0.777157
 ⋮                                                     ⋱                        
 0.678971  0.111879   0.719779   0.604205   0.164498      0.25564    0.152122   0.763252
 0.155008  0.815441   0.518919   0.232197   0.11415       0.579562   0.688379   0.132528
 0.81373   0.917177   0.403232   0.0163046  0.423272      0.643956   0.35936    0.0754497
 0.141834  0.22601    0.0732191  0.203999   0.78344       0.107945   0.153351   0.73143

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided MWE and tracing MovingWindow through mapCube, comparing the result when the categorical axis is in the second position with the alternative axis order and inner-function selection. Done means the first slice does not gain an unexpected missing-value block solely because axes were permuted, with regression coverage for the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.