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

easier axis renaming #76

Closed
gdkrmr opened this issue Aug 29, 2018 · 2 comments
Closed

easier axis renaming #76

gdkrmr opened this issue Aug 29, 2018 · 2 comments

Comments

@gdkrmr
Copy link
Collaborator

gdkrmr commented Aug 29, 2018

For distance matrices or correlation matrices you need an easy way to "duplicate" axes, something like this:

PcaAxis = CABLAB.Cubes.Axes.CategoricalAxis{String, Symbol("PCA axes")}
makePcaAxis(n::Integer) = PcaAxis(["PCA_" * @sprintf("%03d", i) for i in 1:n])
function outPcaAxes{A <: CABLAB.CubeAxis}(axis::Type{A} = VariableAxis, i::Int = 1)
    ( (cube, pargs) -> makePcaAxis(length(CABLAB.getAxis(axis, cube[i]))), )
end

If you have a pca axis as above for two sets of variables and want to make a correlation you have to do something like this:

BioPcaAxis = CABLAB.Cubes.Axes.CategoricalAxis{String, Symbol("Bio PCA axes")}
makeBioPcaAxis(n::Integer) = BioPcaAxis(["Bio_PCA_" * @sprintf("%03d", i) for i in 1:n])
function outBioPcaAxes{A <: CABLAB.CubeAxis}(axis::Type{A} = VariableAxis, i::Int = 1)
    ( (cube, pargs) -> makeBioPcaAxis(length(CABLAB.getAxis(axis, cube[i]))), )
end

AtmPcaAxis = CABLAB.Cubes.Axes.CategoricalAxis{String, Symbol("Atm PCA axes")}
makeAtmPcaAxis(n::Integer) = AtmPcaAxis(["Atm_PCA_" * @sprintf("%03d", i) for i in 1:n])
function outAtmPcaAxes{A <: CABLAB.CubeAxis}(axis::Type{A} = VariableAxis, i::Int = 1)
    ( (cube, pargs) -> makeAtmPcaAxis(length(CABLAB.getAxis(axis, cube[i]))), )
end

and then for changing the actual axes:

map!(x -> typeof(x) == RMSE.PcaAxis ? makeBioPcaAxis(length(getAxis(RMSE.PcaAxis, bio_global_pca_cube))) : x, 
     bio_global_pca_cube.axes)
map!(x -> typeof(x) == RMSE.PcaAxis ? makeAtmPcaAxis(length(getAxis(RMSE.PcaAxis, atm_global_pca_cube))) : x, 
     atm_global_pca_cube.axes)

some easy way to change the axes would be appreciated, e.g.:

BioPcaAxis = prefix_axis(PcaAxis, "Bio")
AtmPcaAxis = prefix_axis(PcaAxis, "Atm")
change_axis!(bio_global_pca_cube, PcaAxis, BioPcaAxis)
change_axis!(atm_global_pca_cube, PcaAxis, BioPcaAxis)
@martin-gutwin
Copy link
Collaborator

Bumping this issue, because output axes from cubefittable have a generic name at the moment. Would be the easiest way to implement a renaming function.

@martin-gutwin martin-gutwin pinned this issue Mar 22, 2019
@meggart
Copy link
Member

meggart commented Jun 11, 2019

This should be solved now? Can you try renameaxis!(cube,"Time"=>"Newtime")

@meggart meggart closed this as completed Aug 23, 2019
@meggart meggart unpinned this issue Jan 22, 2020
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

3 participants