Automatically demote wave duplication outputs when the highest dimension has one index
I often run into trouble when I don't realize that a 1-column 2D wave is not a 1D wave. Usually, these result after I run duplicate/o/r=[][columnOfInterest] sourceWv,columnWave and forget to follow it with redimension/n=(-1) columnWv
I think it would be better if duplicate's default was to demote the wave (i.e., to 1D in this case) if possible.
Would it be possible to use the following syntax to get either behavior in some future version of Igor?
•print dimsize(columnWv,1) //currently prints one. In the future, let the duplicate result in 0, indicating 1D wave
•duplicate/o/r=[][2,2] sourceWv,columnWv
•print dimsize(columnWv,1) //current also prints one. In the future, this behavior should be unchanged
The advantage of this change in syntax would be that the simpler syntax produces the more intuitive result (in my opinion). I suppose the main danger is that someone accidentally erases the dimension label for the duplicated column (or layer, etc.)
For backwards compatibility and transparency, perhaps instead duplicate could just have a flag (e.g., /dem) to demote if the highest dimension if the output wave has only one index.
I'm all for that. And of course it should work for columns, layers, chunks. And I also prefer a new flag so that existing code still works.
October 12, 2019 at 07:18 am - Permalink
Could the new flag /DIM=N also upsize? Would that be of any use?
// make a new matrix filled with the second column of an existing matrix
duplicate/r=[][2]/DIM=2 sourceMatrix, newMatrix
October 12, 2019 at 08:24 am - Permalink
Just curious, have you considered using:
MatrixOP/O columnWv = col(sourceWv,2)
The result is 1D, however wave scaling would not be preserved.
October 13, 2019 at 11:48 pm - Permalink
If columnWv pre-exists and has been scaled,
/S Preserves the dimension scaling, units and wave note of a pre-existing destination wave in a MatrixOp/O command.
October 14, 2019 at 05:00 am - Permalink
@s.r.chinn: I think you would want to have the dimension scaling from sourceWv or?
October 14, 2019 at 09:37 am - Permalink
In reply to @s.r.chinn: I think you… by thomas_braun
Thomas, I agree with what you would want. However, the help file must be read literally.
In the following example snippet
make/O/N=(10,5) sourceWv
setscale x, 1,4,"", sourceWv
setscale y, 2,3,"", sourceWv
sourceWv = x+y
make/O/N=10 columnWv
copyscales sourceWv, columnWv
MatrixOP/O/S columnWv = col(sourceWv,2)
end
you get the desired result. However, if MatrixOP has to create the new columnWv, the sourceWv scaling does not transfer.
October 14, 2019 at 10:07 am - Permalink
In reply to Just curious, have you… by ChrLie
I have, but I usually want to preserve wave scaling, labels in other dimensions, and/or the wave note.
I am not looking for alternatives. In posting, I just wanted to point out that the current Duplicate behavior is sometimes troublesome/confusing, so some explicit handling (via a flag or syntax) would be an improvement.
Seems to me like it could be helpful, but it's hard for me to say what rules should be followed for any new points (and how they would generalize up to 4 dimensions).
Thanks!
October 15, 2019 at 10:09 am - Permalink