Getting Started

Installation

Install Julia v1.10 or above. YAXArrays.jl is available through the Julia package manager. You can enter it by pressing ] in the REPL and then typing

pkg> add YAXArrays

Alternatively, you can also do

import Pkg; Pkg.add("YAXArrays")

Quickstart

Create a simple array from random numbers given the size of each dimension or axis:

using YAXArrays

a = YAXArray(rand(2,3))
╭─────────────────────────╮
2×3 YAXArray{Float64,2}
├─────────────────────────┴───────────────────────────────────── dims ┐
  ↓ Dim_1 Sampled{Int64} Base.OneTo(2) ForwardOrdered Regular Points,
  → Dim_2 Sampled{Int64} Base.OneTo(3) ForwardOrdered Regular Points
├─────────────────────────────────────────────────────────── metadata ┤
  Dict{String, Any}()
├────────────────────────────────────────────────────────── file size ┤ 
  file size: 48.0 bytes
└─────────────────────────────────────────────────────────────────────┘

Assemble a more complex YAXArray with 4 dimensions, i.e. time, x, y and a variable type:

using DimensionalData

# axes or dimensions with name and tick values
axlist = (
    Dim{:time}(range(1, 20, length=20)),
    X(range(1, 10, length=10)),
    Y(range(1, 5, length=15)),
    Dim{:variable}(["temperature", "precipitation"])
)

# the actual data matching the dimensions defined in axlist
data = rand(20, 10, 15, 2)

# metadata about the array
props = Dict(
    "origin" => "YAXArrays.jl example",
    "x" => "longitude",
    "y" => "latitude",
);

a2 = YAXArray(axlist, data, props)
╭────────────────────────────────╮
20×10×15×2 YAXArray{Float64,4}
├────────────────────────────────┴─────────────────────────────────────── dims ┐
  ↓ time     Sampled{Float64} 1.0:1.0:20.0 ForwardOrdered Regular Points,
  → X        Sampled{Float64} 1.0:1.0:10.0 ForwardOrdered Regular Points,
  ↗ Y        Sampled{Float64} 1.0:0.2857142857142857:5.0 ForwardOrdered Regular Points,
  ⬔ variable Categorical{String} ["temperature", "precipitation"] ReverseOrdered
├──────────────────────────────────────────────────────────────────── metadata ┤
  Dict{String, String} with 3 entries:
  "y"      => "latitude"
  "x"      => "longitude"
  "origin" => "YAXArrays.jl example"
├─────────────────────────────────────────────────────────────────── file size ┤ 
  file size: 46.88 KB
└──────────────────────────────────────────────────────────────────────────────┘

Get the temperature map at the first point in time:

a2[variable=At("temperature"), time=1].data
10×15 view(::Array{Float64, 4}, 1, :, :, 1) with eltype Float64:
 0.0868713  0.561007  0.0163349  0.694381   …  0.421457   0.6874    0.0131618
 0.0111043  0.771401  0.613861   0.476027      0.661882   0.104818  0.705693
 0.132474   0.503118  0.158024   0.275962      0.969289   0.6162    0.556596
 0.511894   0.510341  0.82556    0.683392      0.674403   0.789556  0.953059
 0.730615   0.101552  0.241537   0.883619      0.32073    0.751502  0.0844151
 0.93755    0.322004  0.0174264  0.964753   …  0.407429   0.418002  0.673002
 0.673084   0.430052  0.108441   0.564563      0.0885446  0.624799  0.638551
 0.430868   0.118927  0.242648   0.315912      0.172975   0.347188  0.633929
 0.573226   0.602947  0.268472   0.8796        0.84717    0.67698   0.782297
 0.519113   0.318281  0.942678   0.0376844     0.940622   0.307758  0.771381

Get more details at the select page

Updates

:::tip

The Julia Compiler is always improving. As such, we recommend using the latest stable version of Julia.

:::

You may check the installed version with:

pkg> st YAXArrays

::: info

With YAXArrays.jl 0.5 we switched the underlying data type to be a subtype of the DimensionalData.jl types. Therefore the indexing with named dimensions changed to the DimensionalData syntax. See the DimensionalData.jl docs.

:::