Skip to content

Combine YAXArrays

Data is often scattered across multiple files and corresponding arrays, e.g. one file per time step. This section describes methods on how to combine them into a single YAXArray.

cat along an existing dimension

Here we use cat to combine two arrays consisting of data from the first and the second half of a year into one single array containing the whole year. We glue the arrays along the first dimension using dims = 1: The resulting array whole_year still has one dimension, i.e. time, but with 12 instead of 6 elements.

julia
using YAXArrays
using YAXArrays: YAXArrays as YAX

first_half = YAXArray((YAX.time(1:6),), rand(6))
second_half = YAXArray((YAX.time(7:12),), rand(6))
whole_year = cat(first_half, second_half, dims = 1)
┌ 12-element YAXArray{Float64, 1} ┐
├─────────────────────────────────┴─────────────────────────────── dims ┐
  ↓ time Sampled{Int64} [1, 2, …, 11, 12] ForwardOrdered Regular Points
├───────────────────────────────────────────────────────────── metadata ┤
  Dict{String, Any}()
├───────────────────────────────────────────────────── loaded in memory ┤
  data size: 96.0 bytes
└───────────────────────────────────────────────────────────────────────┘

concatenatecubes to a new dimension

Here we use concatenatecubes to combine two arrays of different variables that have the same dimensions. The resulting array combined has an additional dimension variable indicating from which array the element values originates. Note that using a Dataset instead is a more flexible approach in handling different variables.

julia
using YAXArrays
using YAXArrays: YAXArrays as YAX

temperature = YAXArray((YAX.time(1:6),), rand(6))
precipitation = YAXArray((YAX.time(1:6),), rand(6))
cubes = [temperature,precipitation]
var_axis = Variables(["temp", "prep"])
combined = concatenatecubes(cubes, var_axis)
┌ 6×2 YAXArray{Float64, 2} ┐
├──────────────────────────┴──────────────────────────────── dims ┐
  ↓ time      Sampled{Int64} 1:6 ForwardOrdered Regular Points,
  → Variables Categorical{String} ["temp", "prep"] ReverseOrdered
├─────────────────────────────────────────────────────── metadata ┤
  Dict{String, Any}()
├────────────────────────────────────────────────── loaded lazily ┤
  data size: 96.0 bytes
└─────────────────────────────────────────────────────────────────┘

Layout Switch

Adjust the layout style of VitePress to adapt to different reading needs and screens.

Expand all
The sidebar and content area occupy the entire width of the screen.
Expand sidebar with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Expand all with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Original width
The original layout width of VitePress

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.

Spotlight

Highlight the line where the mouse is currently hovering in the content to optimize for users who may have reading and focusing difficulties.

ONOn
Turn on Spotlight.
OFFOff
Turn off Spotlight.