# Getting the dimension value at eachslice of a DimArray

**URL:** https://discourse.julialang.org/t/getting-the-dimension-value-at-eachslice-of-a-dimarray/122088
**Category:** General Usage
**Tags:** dimensionaldata
**Created:** [October 31, 2024, 4:47pm UTC](https://discourse.julialang.org/t/getting-the-dimension-value-at-eachslice-of-a-dimarray/122088 "2024-10-31T16:47:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gmcardle](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@gmcardle](https://discourse.julialang.org/u/gmcardle)
#### Post date: [October 31, 2024, 4:47pm UTC](https://discourse.julialang.org/t/getting-the-dimension-value-at-eachslice-of-a-dimarray/122088/1 "2024-10-31T16:47:42Z")

</div>

Hi,  
I’m still getting to grips with practical use of [DimensionalData.jl](https://github.com/rafaqz/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?

```julia
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:

```julia
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?

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [November 1, 2024, 9:29am UTC](https://discourse.julialang.org/t/getting-the-dimension-value-at-eachslice-of-a-dimarray/122088/2 "2024-11-01T09:29:06Z")

</div>

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]`
