Search code examples
arraysdata-manipulationidl-programming-language

IDL Remove columns and rows of 3D array


I have an array which has dimensions [385,417,513] which corresponds to a 3D data cube for a quantity.

I want to remove every nth element of each dimension to reduce the data size of the array and make it easier to plot. E.g remove every 5th element from the x,y and z dimensions to get an array of size [77,83,102]

In IDL I cannot find any functionality which lets me remove columns or rows in this way. This surely cannot be the case?

https://www.harrisgeospatial.com/docs/array_manipulation.html


Solution

  • How about this:

    IDL> x = findgen(385, 417, 513)
    IDL> new_x = x[0:*:5, 0:*:5, 0:*:5]
    IDL> help, new_x
    NEW_X           FLOAT     = Array[77, 84, 103]
    

    This has a few more elements than your requested size because 5 doesn't divide evenly into 417 or 513.