Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapCube not saving cube when using path argument in the outdims #179

Closed
jcortesr opened this issue Sep 30, 2022 · 0 comments
Closed

mapCube not saving cube when using path argument in the outdims #179

jcortesr opened this issue Sep 30, 2022 · 0 comments

Comments

@jcortesr
Copy link

Only when I try it as below it does not work, i.e., wrapping the mapCube function in another function:

axlist = [
    RangeAxis("time", Date(1979,1,1):Day(1):Date(2021,12,31)),
    RangeAxis("lon", range(-60,-70, length=11)),
    RangeAxis("lat", range(-30, -40, length=11)),
    ]
data = rand(Bool,length(axlist[1]), 11, 11)
ds = YAXArray(axlist, data)

function aggregate(xout, xin)
    for m in xout.Time.values
        aggval = sum(xin[time=(m, m + Year(1) - Day(1))].data)
        xout[Time=m].data .= aggval
    end
end

function aggregate(cube::YAXArray, var_name, thr)
    indims = InDims("Time", artype=YAXArray)
    ym = unique(year.(cube.time.values))
    outdims = OutDims(RangeAxis("Time", Date.(ym)), artype=YAXArray, outtype = UInt16, path =  "/scratch/jcortes/git_test_$(var_name)_$thr.zarr")
    mapCube(aggregate, cube; indims, outdims)
end 

var_names  = ["t2m", "t2mmax", "t2mmin", "tp", "spei_30", "spei_90", "spei_180"]
thrs = [0.95, 0.05]

for var_name in var_names
    for thr in thrs
        event_cube = ds
        aggregate(event_cube, var_name, thr)                    
    end
end

The above code runs without errors, but the cubes are not saved.

@lazarusA lazarusA mentioned this issue Sep 20, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants