Getting the dimension value at eachslice of a DimArray

Hi,
I’m still getting to grips with practical use of DimensionalData.jl DimArray types.
Suppose I’m using eachslice to iterate over the time dimension of a 3D array, but I want to get the time value at each slice. What property can I access? In other words what could I use for the gettime function in this example?

t = Ti(0.01:0.01:1)
x = X(10:10:100);
y = Y(1:20);
mydata = DimArray(rand(10, 20, 100), (x, y, t), name="example")
for slice in eachslice(mydata, dims=3)
    timevalue = gettime(slice)
    println("the time of this slice is ", timevalue)
end

Currently my clunky workaround would be like this:

for (timevalue, slice) in zip(dims(mydata)[3], eachslice(mydata, dims=3))
    println("the time of this slice is ", timevalue)
end

Hopefully there’s a better answer?

First, use Ti instead of 3 in eachslice so your code is more readable .

Then you can do refdims(slice, Ti)[1] to get the value because we keep the “reference” dimensions around to track where your slice came from.

You could also just loop over for i in axes(dimarray, Ti) and take the views of each slice manually, then you can get the time with dims(dimarray, Ti)[i]