From 09b520b83a4a9136aa02a8a4c9adf4513869389d Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 23 Nov 2023 23:20:31 +0000 Subject: [PATCH] build based on 880be4e --- .../crash/generated/course/course/index.html | 126 ++++---- previews/PR568/reference/index.html | 268 +++++++++--------- previews/PR568/search/search_index.json | 2 +- previews/PR568/sitemap.xml.gz | Bin 127 -> 127 bytes 4 files changed, 198 insertions(+), 198 deletions(-) diff --git a/previews/PR568/crash/generated/course/course/index.html b/previews/PR568/crash/generated/course/course/index.html index cbff15b85..2ab51171f 100644 --- a/previews/PR568/crash/generated/course/course/index.html +++ b/previews/PR568/crash/generated/course/course/index.html @@ -591,32 +591,32 @@

Dimensions and DimArraysA = rand(X(5), Y(5))
5×5 DimArray{Float64,2} with dimensions: X, Y
- 0.311551   0.456841  0.721526  0.435496   0.407604
- 0.0314271  0.910207  0.833412  0.254205   0.245365
- 0.337067   0.136774  0.221974  0.0167196  0.433512
- 0.571846   0.867841  0.996957  0.0487373  0.0929695
- 0.230113   0.135144  0.780989  0.528185   0.29594
+ 0.461325   0.8431    0.782148   0.749449  0.31217
+ 0.241514   0.138161  0.336      0.28491   0.831904
+ 0.109044   0.598698  0.30281    0.829182  0.271389
+ 0.0977132  0.63052   0.534344   0.331739  0.315462
+ 0.0336821  0.642018  0.0731809  0.888225  0.810319
 

get value

A[Y(1), X(2)]
 
-
0.03142706241854176
+
0.24151387312926442
 

As shown above, Dimensions can be used to construct arrays in rand, ones, zeros and fill with either a range for a lookup index or a number for the dimension length.

Or we can use the Dim{X} dims by using Symbols, and indexing with keywords:

A = DimArray(rand(5, 5), (:a, :b))
 
5×5 DimArray{Float64,2} with dimensions: Dim{:a}, Dim{:b}
- 0.682815  0.850178  0.760162  0.17839    0.126447
- 0.783886  0.181768  0.874999  0.275593   0.362856
- 0.609333  0.7653    0.3663    0.377261   0.717694
- 0.356301  0.579718  0.354531  0.713865   0.471926
- 0.339224  0.746804  0.107938  0.0799614  0.766145
+ 0.782406   0.404004  0.0384209  0.126395  0.213012
+ 0.303812   0.952501  0.266923   0.250459  0.732001
+ 0.0343281  0.131738  0.0263003  0.87979   0.937614
+ 0.20561    0.405973  0.117466   0.535632  0.662165
+ 0.468297   0.465038  0.973552   0.606813  0.688237
 

get value

A[a=3, b=5]
 
-
0.71769367324973
+
0.9376140541417589
 

Often, we want to provide a lookup index for the dimension:

Here both X and Ti are dimensions from DimensionalData. The currently exported dimensions are X, Y, Z, Ti (Ti is shortening of Time).

The length of each dimension index has to match the size of the corresponding array axis.

@@ -647,19 +647,19 @@

Dimensions and DimArrays
12×10 DimArray{Float64,2} with dimensions: 
   Dim{:time} Sampled{DateTime} DateTime("2001-01-01T00:00:00"):Month(1):DateTime("2001-12-01T00:00:00") ForwardOrdered Regular Points,
   Dim{:distance} Sampled{Int64} 10:10:100 ForwardOrdered Regular Points
-                                   …  80           90         100
-  2001-01-01T00:00:00      0.00971342   0.562502    0.609121
-  2001-02-01T00:00:00      0.838984     0.75164     0.801973
-  2001-03-01T00:00:00      0.619199     0.937823    0.900711
-  2001-04-01T00:00:00      0.770603     0.707126    0.60753
-  2001-05-01T00:00:00  …   0.00159321   0.788161    0.907038
-  2001-06-01T00:00:00      0.690368     0.746431    0.354156
-  2001-07-01T00:00:00      0.0718767    0.50853     0.419419
-  2001-08-01T00:00:00      0.485233     0.818955    0.746544
-  2001-09-01T00:00:00      0.502876     0.784225    0.652392
-  2001-10-01T00:00:00  …   0.0748758    0.614539    0.943011
-  2001-11-01T00:00:00      0.300063     0.356417    0.134969
-  2001-12-01T00:00:00      0.506552     0.935332    0.409229
+                                   …  80         90         100
+  2001-01-01T00:00:00      0.798125   0.712841    0.754911
+  2001-02-01T00:00:00      0.971043   0.317214    0.0136019
+  2001-03-01T00:00:00      0.520036   0.690481    0.320414
+  2001-04-01T00:00:00      0.125068   0.423247    0.423717
+  2001-05-01T00:00:00  …   0.287405   0.501309    0.438374
+  2001-06-01T00:00:00      0.410531   0.950214    0.621235
+  2001-07-01T00:00:00      0.834235   0.789531    0.743405
+  2001-08-01T00:00:00      0.853966   0.634005    0.424101
+  2001-09-01T00:00:00      0.859316   0.588221    0.268555
+  2001-10-01T00:00:00  …   0.723767   0.745889    0.64083
+  2001-11-01T00:00:00      0.58551    0.424475    0.610547
+  2001-12-01T00:00:00      0.266558   0.85589     0.139885
 

Symbols can be more convenient to use than defining custom dims with @dim, but have some downsides. They don't inherit from a specific Dimension type, so plots will not know what axis to put them on. They also cannot use the basic constructor methods like rand or zeros, as we cannot dispatch on Symbol for Base methods without "type-piracy".

@@ -673,10 +673,10 @@

Indexing the array by name and ind X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points, Ti Sampled{DateTime} DateTime("2001-01-01T00:00:00"):Month(2):DateTime("2001-11-01T00:00:00") ForwardOrdered Regular Points 2001-01-01T00:00:00 … 2001-11-01T00:00:00 - 10 0.671345 0.565462 - 40 0.682487 0.316966 - 70 0.136808 0.550636 - 100 0.381094 0.476372 + 10 0.45369 0.0120772 + 40 0.585578 0.966221 + 70 0.0589364 0.469902 + 100 0.217847 0.278389

When specifying only one dimension, all elements of the other dimensions are assumed to be included:

A[X(1:3:10)]
@@ -685,10 +685,10 @@ 

Indexing the array by name and ind X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points, Ti Sampled{DateTime} DateTime("2001-01-01T00:00:00"):Month(1):DateTime("2001-12-01T00:00:00") ForwardOrdered Regular Points 2001-01-01T00:00:00 … 2001-12-01T00:00:00 - 10 0.671345 0.323025 - 40 0.682487 0.820954 - 70 0.136808 0.593108 - 100 0.381094 0.0281335 + 10 0.45369 0.343509 + 40 0.585578 0.831535 + 70 0.0589364 0.922556 + 100 0.217847 0.222959

Indexing

@@ -748,13 +748,13 @@

Indexing Performanceprintln(@btime $A2[X(1), Y(2)])

-
  43.799 ns (0 allocations: 0 bytes)
+
  43.688 ns (0 allocations: 0 bytes)
 1.0
 

and

println(@btime parent($A2)[1, 2])
 
-
3×4×1 DimArray{Float64,3} with dimensions: X, Y, Ti
 [:, :, 1]
- 1.73331  2.92759  2.49549  2.30835
- 2.13014  1.54409  3.02662  3.02718
- 1.95383  3.24542  1.89865  3.37258
+ 1.89767  2.71666  2.94472  3.18355
+ 2.9894   2.93941  3.21275  2.04066
+ 2.18769  2.4382   2.62694  2.62173
 

This also works in methods from Statistics:

using Statistics
@@ -776,9 +776,9 @@ 

Specifying dims<

3×4×1 DimArray{Float64,3} with dimensions: X, Y, Ti
 [:, :, 1]
- 0.346663  0.585519  0.499099  0.46167
- 0.426028  0.308819  0.605325  0.605436
- 0.390765  0.649085  0.379729  0.674515
+ 0.379534  0.543332  0.588944  0.636711
+ 0.59788   0.587883  0.64255   0.408133
+ 0.437538  0.487641  0.525388  0.524346
 

@@ -845,8 +845,8 @@

LookupArrays and Selectors
A2[distance=12 .. 35, time=Date(2001, 5) .. Date(2001, 7)]
@@ -863,7 +863,7 @@ 

LookupArrays and SelectorsA4 = rand(Ti(timespan), X(10:10:100)) A4[X(Near(35)), Ti(At(DateTime(2001,5)))]

-
0.27463208325575683
+
0.7844238575217434
 

Without dim wrappers selectors must be in the right order, and specify all axes:

5-element Vector{Float64}:
- 0.24277448211977626
- 0.2243311093335526
- 0.32511774209530075
- 0.2550241019905538
- 0.4235163791944876
+ 0.23782475482190868
+ 0.10215310323944482
+ 0.014306472825666106
+ 0.5100856183627
+ 0.45872357840022293
 

But unless the DimArray is one dimensional, this will return a regular Array. It is not possible to keep the LookupArray or even Dimensions after linear indexing is used.

diff --git a/previews/PR568/reference/index.html b/previews/PR568/reference/index.html index ada22f7b7..b13ae54c9 100644 --- a/previews/PR568/reference/index.html +++ b/previews/PR568/reference/index.html @@ -555,7 +555,7 @@

Arraysmetadata, name and refdims methods, although these are optional.

A rebuild method for AbstractDimArray must accept data, dims, refdims, name, metadata arguments.

Indexing AbstractDimArray with non-range AbstractArray has undefined effects on the Dimension index. Use forward-ordered arrays only"

-

source

+

source

# DimensionalData.DimArrayType.

DimArray <: AbstractDimArray
@@ -586,7 +586,7 @@ 

Arraysjulia> A[Near(DateTime(2001, 5, 4)), Between(20, 50)];

-

source

+

source

Multi-array datasets¤

@@ -606,7 +606,7 @@

Multi-array datasetsDimStack for the concrete implementation. Most methods are defined on the abstract type.

To extend AbstractDimStack, implement argument and keyword version of rebuild and also rebuild_from_arrays.

The constructor of an AbstractDimStack must accept a NamedTuple.

-

source

+

source

# DimensionalData.DimStackType.

DimStack <: AbstractDimStack
@@ -659,7 +659,7 @@ 

Multi-array datasetsjulia> s[X(At(:a))] isa DimStack true

-

source

+

source

Dimension indices generators¤

@@ -673,7 +673,7 @@

Dimension indices generators
DimKeys <: AbstractArray
@@ -683,7 +683,7 @@ 

Dimension indices generatorsDimKeys(dims::Dimension)

Like CartesianIndices, but for the lookup values of Dimensions. Behaves as an Array of Tuple of Dimension(At(lookupvalue)) for all combinations of the lookup values of dims.

-

source

+

source

# DimensionalData.DimPointsType.

DimPoints <: AbstractArray
@@ -698,7 +698,7 @@ 

Dimension indices generatorsTables.jl/TableTraits.jl interface¤

@@ -707,7 +707,7 @@

Tables.jl/TableTraits.jl interface
AbstractDimTable <: Tables.AbstractColumns
 

Abstract supertype for dim tables

-

source

+

source

# DimensionalData.DimTableType.

DimTable <: AbstractDimTable
@@ -735,7 +735,7 @@ 

Tables.jl/TableTraits.jl interface :band_2 Float64 :band_3 Float64

-

source

+

source

# DimensionalData.DimColumnType.

-

source

+

source

# DimensionalData.Dimensions.LookupArrays.rebuildFunction.

This also works for all the data layers in a DimStack.

-

source

+

source

# DimensionalData.broadcast_dimsFunction.

Return a dimension new_dim whose indices are a MergedLookup of the indices of old_dims.

-

source

+

source

mergedims(dims, old_dims => new_dim, others::Pair...) => dims_new
 

If dimensions old_dims, new_dim, etc. are found in dims, then return new dims_new where all dims in old_dims have been combined into a single dim new_dim. The returned dimension will keep only the name of new_dim. Its coords will be a MergedLookup of the coords of the dims in old_dims. New dimensions are always placed at the end of dims_new. others contains other dimension pairs to be merged.

@@ -930,23 +930,23 @@

Common methodsDim{:time} MergedLookup{Tuple{Int64}} Tuple{Int64}[(0,), (3,), (4,)] Ti, Dim{:space} MergedLookup{Tuple{Float64, Int64}} Tuple{Float64, Int64}[(0.0, 10), (0.1, 10), …, (0.3, 100), (0.4, 100)] X, Y -

source

+

source

mergedims(A::AbstractDimArray, dim_pairs::Pair...) => AbstractDimArray
 mergedims(A::AbstractDimStack, dim_pairs::Pair...) => AbstractDimStack
 

Return a new array or stack whose dimensions are the result of mergedims(dims(A), dim_pairs).

-

source

+

source

# DimensionalData.unmergedimsFunction.

unmergedims(merged_dims::Tuple{Vararg{Dimension}}) => Tuple{Vararg{Dimension}}
 

Return the unmerged dimensions from a tuple of merged dimensions. However, the order of the original dimensions are not necessarily preserved.

-

source

+

source

unmergedims(A::AbstractDimArray, original_dims) => AbstractDimArray
 unmergedims(A::AbstractDimStack, original_dims) => AbstractDimStack
 

Return a new array or stack whose dimensions are restored to their original prior to calling mergedims(A, dim_pairs).

-

source

+

source

# DimensionalData.reorderFunction.

reorder(A::Union{AbstractDimArray,AbstractDimStack}, order::Pair...)
@@ -974,7 +974,7 @@ 

Common methodsCommon methods
cat(stacks...; keys=(:sea_surface_temp, :humidity), dims=Ti)
 

-

source

+

source

# Base.mapFunction.

Base.map(f, stacks::AbstractDimStack...)
 

Apply function f to each layer of the stacks.

If f returns DimArrays the result will be another DimStack. Other values will be returned in a NamedTuple.

-

source

+

source

# Base.copy!Function.

Base.copy!(dst::AbstractArray, src::AbstractGimStack, key::Key)
@@ -1011,7 +1011,7 @@ 

Common methods
copy!(array, stack, :humidity)
 

-

source

+

source

Base.copy!(dst::AbstractDimStack, src::AbstractDimStack, [keys=keys(dst)])
 

Copy all or a subset of layers from one stack to another.

@@ -1019,7 +1019,7 @@

Common methods
copy!(dst::AbstractDimStack, src::AbstractDimStack, keys=(:sea_surface_temp, :humidity))
 
-

source

+

source

# Base.eachsliceFunction.

Base.eachslice(stack::AbstractDimStack; dims)
@@ -1049,7 +1049,7 @@ 

Common methods :x Float64 dims: Y (3) :y Float64 dims: Y, Ti (3×5)

-

source

+

source

Most base methods work as expected, using Dimension wherever a dims keyword is used. They are not allspecifically documented here.

Shorthand constructors:

# @@ -1071,7 +1071,7 @@

Common methods
<a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/1964cb53fe1d41aa54ef34aa5d8e2a6d1f576b59/src/array/array.jl#L409-L432' class='documenter-source'>source</a><br>
+
-

source

+

source

# Base.zerosFunction.

Base.zeros(x, dims::Dimension...; kw...) => DimArray
@@ -1134,7 +1134,7 @@ 

Common methods
<a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/1964cb53fe1d41aa54ef34aa5d8e2a6d1f576b59/src/array/array.jl#L472-L504' class='documenter-source'>source</a><br>
+
<a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/880be4ed77668862150c04ba270acc22fb134cca/src/array/array.jl#L472-L504' class='documenter-source'>source</a><br>
 
 <a id='Base.ones' href='#Base.ones'>#</a>
 **`Base.ones`** &mdash; *Function*.
@@ -1166,7 +1166,7 @@ 

Common methods
<a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/1964cb53fe1d41aa54ef34aa5d8e2a6d1f576b59/src/array/array.jl#L507-L539' class='documenter-source'>source</a><br>
+
 

Dimension objects may have lookup and metadata fields to track additional information about the data and the index, and their relationship.

-

source

+

source

# DimensionalData.Dimensions.DependentDimType.

DependentDim <: Dimension
 

Abstract supertype for Dependent dimensions. These will plot on the Y axis.

-

source

+

source

# DimensionalData.Dimensions.IndependentDimType.

IndependentDim <: Dimension
 

Abstract supertype for independent dimensions. Thise will plot on the X axis.

-

source

+

source

# DimensionalData.Dimensions.XDimType.

XDim <: IndependentDim
 

Abstract supertype for all X dimensions.

-

source

+

source

# DimensionalData.Dimensions.YDimType.

YDim <: DependentDim
 

Abstract supertype for all Y dimensions.

-

source

+

source

# DimensionalData.Dimensions.ZDimType.

ZDim <: DependentDim
 

Abstract supertype for all Z dimensions.

-

source

+

source

# DimensionalData.Dimensions.TimeDimType.

TimeDim <: IndependentDim
 

Abstract supertype for all time dimensions.

In a TimeDime with Interval sampling the locus will automatically be set to Start(). Dates and times generally refer to the start of a month, hour, second etc., not the central point as is more common with spatial data. `

-

source

+

source

# DimensionalData.Dimensions.XType.

X <: XDim
@@ -1312,7 +1312,7 @@ 

Common methods# Or mean(A; dims=X)

-

source

+

source

# DimensionalData.Dimensions.YType.

Y <: YDim
@@ -1327,7 +1327,7 @@ 

Common methods# Or mean(A; dims=Y)

-

source

+

source

# DimensionalData.Dimensions.ZType.

Z <: ZDim
@@ -1342,7 +1342,7 @@ 

Common methods# Or mean(A; dims=Z)

-

source

+

source

# DimensionalData.Dimensions.TiType.

m Ti <: TimeDim

@@ -1357,7 +1357,7 @@

Common methods# Or mean(A; dims=Ti)

-

source

+

source

# DimensionalData.Dimensions.DimType.

Dim{S}(val=:)
@@ -1372,7 +1372,7 @@ 

Common methodsDim{:custom} Char['a', 'b', 'c']

-

source

+

source

# DimensionalData.Dimensions.CoordType.

Coord <: Dimension
@@ -1415,7 +1415,7 @@ 

Common methods 0.3 0.4

-

source

+

source

# DimensionalData.Dimensions.AnonDimType.

AnonDim <: Dimension
@@ -1423,7 +1423,7 @@ 

Common methodsAnonDim()

Anonymous dimension. Used when extra dimensions are created, such as during transpose of a vector.

-

source

+

source

# DimensionalData.Dimensions.@dimMacro.

@dim typ [supertype=Dimension] [name::String=string(typ)]
@@ -1436,7 +1436,7 @@ 

Common methods@dim Lon XDim "Longitude" # output

-

source

+

source

Exported methods¤

@@ -1468,7 +1468,7 @@

Exported methodsjulia> hasdim(A, Ti) false

-

source

+

source

# DimensionalData.Dimensions.dimnumFunction.

dimnum(x, query::Tuple) => NTuple{Int}
@@ -1492,7 +1492,7 @@ 

Exported methodsjulia> dimnum(A, Y) 2

-

source

+

source

Non-exported methods¤

@@ -1505,7 +1505,7 @@

Non-exported methodsLookupArray of a dimension. This dictates properties of the dimension such as array axis and index order, and sampling properties.

dims can be a Dimension, a dimension type, or a tuple of either.

-

source

+

source

# DimensionalData.Dimensions.labelFunction.

label(x) => String
@@ -1515,7 +1515,7 @@ 

Non-exported methods
dim2key(dim::Dimension) => Symbol
@@ -1524,7 +1524,7 @@ 

Non-exported methods@dim macro.

All other Dim{S}() dimensions will generate Symbols S.

-

source

+

source

# DimensionalData.Dimensions.key2dimFunction.

key2dim(s::Symbol) => Dimension
@@ -1533,19 +1533,19 @@ 

Non-exported methods@dim macro.

All other Symbols S will generate Dim{S}() dimensions.

-

source

+

source

# DimensionalData.Dimensions.dims2indicesFunction.

dims2indices(dim::Dimension, I) => NTuple{Union{Colon,AbstractArray,Int}}
 

Convert a Dimension or Selector I to indices of Int, AbstractArray or Colon.

-

source

+

source

# DimensionalData.Dimensions.LookupArrays.selectindicesFunction.

selectindices(lookups, selectors)
 

Converts Selector to regular indices.

-

source

+

source

# DimensionalData.Dimensions.formatFunction.

format(dims, x) => Tuple{Vararg{Dimension,N}}
@@ -1553,14 +1553,14 @@ 

Non-exported methodsLookupArray hasn't been specified, a lookup is chosen based on the type and element type of the index.

-

source

+

source

# DimensionalData.Dimensions.reducedimsFunction.

reducedims(x, dimstoreduce) => Tuple{Vararg{Dimension}}
 

Replace the specified dimensions with an index of length 1. This is usually to match a new array size where an axis has been reduced with a method like mean or reduce to a length of 1, but the number of dimensions has not changed.

LookupArray traits are also updated to correspond to the change in cell step, sampling type and order.

-

source

+

source

# DimensionalData.Dimensions.swapdimsFunction.

swapdims(x::T, newdims) => T
@@ -1585,7 +1585,7 @@ 

Non-exported methods 1.0 1.0 1.0 1.0 [and 1 more slices...]

-

source

+

source

# DimensionalData.Dimensions.slicedimsFunction.

slicedims(x, I) => Tuple{Tuple,Tuple}
@@ -1600,7 +1600,7 @@ 

Non-exported methods
comparedims(A::AbstractDimArray...; kw...)
@@ -1622,13 +1622,13 @@ 

Non-exported methods
combinedims(xs; check=true)
 

Combine the dimensions of each object in xs, in the order they are found.

-

source

+

source

# DimensionalData.Dimensions.otherdimsFunction.

otherdims(x, query) => Tuple{Vararg{Dimension,N}}
@@ -1652,7 +1652,7 @@ 

Non-exported methodsjulia> otherdims(A, (Y, Z)) X

-

source

+

source

# DimensionalData.Dimensions.commondimsFunction.

commondims([f], x, query) => Tuple{Vararg{Dimension}}
@@ -1673,7 +1673,7 @@ 

Non-exported methodsjulia> commondims(A, Ti) ()

-

source

+

source

# DimensionalData.Dimensions.sortdimsFunction.

sortdims([f], tosort, order) => Tuple
@@ -1681,14 +1681,14 @@ 

Non-exported methodsTimeDim can be used in order.

f is <: by default, but can be >: to sort abstract types by concrete types.

-

source

+

source

# DimensionalData.Dimensions.LookupArrays.basetypeofFunction.

basetypeof(x) => Type
 

Get the "base" type of an object - the minimum required to define the object without it's fields. By default this is the full UnionAll for the type. But custom basetypeof methods can be defined for types with free type parameters.

In DimensionalData this is primariliy used for comparing Dimensions, where Dim{:x} is different from Dim{:y}.

-

source

+

source

# DimensionalData.Dimensions.setdimsFunction.

setdims(X, newdims) => AbstractArray
@@ -1709,7 +1709,7 @@ 

Non-exported methodsCategorical{Char} ForwardOrdered wrapping: 'a':1:'j'

-

source

+

source

# DimensionalData.Dimensions.dimsmatchFunction.

Generate a title string based on reference dimension values.

-

source

+

source

# DimensionalData.rebuild_from_arraysFunction.

rebuild_from_arrays(s::AbstractDimStack, das::NamedTuple{<:Any,<:Tuple{Vararg{AbstractDimArray}}}; kw...)
@@ -1753,7 +1753,7 @@ 

Non-exported methodsLookupArrays¤

@@ -1768,7 +1768,7 @@

LookupArrays
using DimensionalData
 using DimensionalData.LookupArrays
 

-

source

+

source

Selectors¤

@@ -1787,7 +1787,7 @@

SelectorsWhere
  • Contains
  • -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.IntSelectorType.

    IntSelector <: Selector
    @@ -1799,7 +1799,7 @@ 

    SelectorsContains
  • Near
  • -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.ArraySelectorType.

    ArraySelector <: Selector
    @@ -1811,7 +1811,7 @@ 

    SelectorsTouches
  • Where
  • -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AtType.

    At <: IntSelector
    @@ -1832,7 +1832,7 @@ 

    Selectors5

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.NearType.

    Near <: IntSelector
    @@ -1850,7 +1850,7 @@ 

    Selectors# output 4

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.BetweenType.

    Between <: ArraySelector
    @@ -1877,7 +1877,7 @@ 

    Selectors 5 6 20 4 5

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.TouchesType.

    Touches <: ArraySelector
    @@ -1900,7 +1900,7 @@ 

    Selectors 5 6 20 4 5

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.ContainsType.

    Contains <: IntSelector
    @@ -1919,7 +1919,7 @@ 

    Selectors# output 3

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.WhereType.

    Where <: ArraySelector
    @@ -1941,7 +1941,7 @@ 

    Selectors 19 21 20 4 6

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AllType.

    All <: Selector
    @@ -1965,7 +1965,7 @@ 

    Selectors 10.0 1 2 19 20 50.0 3 6 57 60

    -

    source

    +

    source

    Lookup properties:

    # DimensionalData.Dimensions.LookupArrays.boundsFunction.

    @@ -1977,7 +1977,7 @@

    Selectors
    val(x)
    @@ -1986,28 +1986,28 @@ 

    Selectors
    LookupArray
     

    Types defining the behaviour of a lookup index, how it is plotted and how Selectors like Between work.

    A LookupArray may be NoLookup indicating that the index is just the underlying array axis, Categorical for ordered or unordered categories, or a Sampled index for Points or Intervals.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AlignedType.

    Aligned <: LookupArray
     

    Abstract supertype for LookupArrays where the index is aligned with the array axes.

    This is by far the most common supertype for LookupArray.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractSampledType.

    AbstractSampled <: Aligned
     

    Abstract supertype for LookupArrays where the index is aligned with the array, and is independent of other dimensions. Sampled is provided by this package.

    AbstractSampled must have order, span and sampling fields, or a rebuild method that accpts them as keyword arguments.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.SampledType.

    Sampled <: AbstractSampled
    @@ -2046,14 +2046,14 @@ 

    Selectors 40 1.0 1.0 1.0 1.0 20 1.0 1.0 1.0 1.0

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractCyclicType.

    AbstractCyclic <: AbstractSampled end
     

    An abstract supertype for cyclic lookups.

    These are AbstractSampled lookups that are cyclic for Selectors.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.CyclicType.

    Cyclic <: AbstractCyclic
    @@ -2077,7 +2077,7 @@ 

    SelectorsSampled as the full cycle is likely no longer available.
  • .. or Between selectors do not work in a cycled way: they work as for Sampled. This may change in future to return cycled values, but there are problems with this, such as leap years breaking correct date cycling of a single year. If you actually need this behaviour, please make a GitHub issue.
  • -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractCategoricalType.

    AbstractCategorical <: Aligned
    @@ -2085,7 +2085,7 @@ 

    SelectorsLookupArrays where the values are categories.

    Categorical is the provided concrete implementation. but this can easily be extended - all methods are defined for AbstractCategorical.

    All AbstractCategorical must provide a rebuild method with data, order and metadata keyword arguments.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.CategoricalType.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.UnalignedType.

    Unaligned <: LookupArray
     

    Abstract supertype for LookupArray where the index is not aligned to the grid.

    Indexing an Unaligned with Selectors must provide all other Unaligned dimensions.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.TransformedType.

    Transformed <: Unaligned
    @@ -2154,7 +2154,7 @@ 

    Selectors# output 9

    -

    source

    +

    source

    # DimensionalData.Dimensions.MergedLookupType.

    MergedLookup <: LookupArray
    @@ -2172,7 +2172,7 @@ 

    Selectors
    NoLookup <: LookupArray
    @@ -2200,7 +2200,7 @@ 

    SelectorsNoLookup, NoLookup

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AutoLookupType.

    AutoLookup <: LookupArray
    @@ -2210,13 +2210,13 @@ 

    SelectorsLookupArray, the default lookup. It will be converted automatically to another LookupArray when it is possible to detect it from the index.

    Keywords will be used in the detected LookupArray constructor.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AutoIndexType.

    AutoIndex
     

    Detect a LookupArray index from the context. This is used in NoLookup to simply use the array axis as the index when the array is constructed, and in set to change the LookupArray type without changing the index values.

    -

    source

    +

    source

    Metadata¤

    @@ -2227,7 +2227,7 @@

    Metadataset without ambiguity about where to put them.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.MetadataType.

    Metadata <: AbstractMetadata
    @@ -2237,7 +2237,7 @@ 

    MetadataMetadata{X}(; kw...) => Metadata{NamedTuple}

    General Metadata object. The X type parameter categorises the metadata for method dispatch, if required.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.NoMetadataType.

    NoMetadata <: AbstractMetadata
    @@ -2245,7 +2245,7 @@ 

    MetadataNoMetadata()

    Indicates an object has no metadata. But unlike using nothing, get, keys and haskey will still work on it, get always returning the fallback argument. keys returns () while haskey always returns false.

    -

    source

    +

    source

    LookupArray traits¤

    @@ -2256,7 +2256,7 @@

    LookupArray traitsLookupArray.

    These modify the behaviour of the lookup index.

    The term "Trait" is used loosely - these may be fields of an object of traits hard-coded to specific types.

    -

    source

    +

    source

    Order¤

    @@ -2265,13 +2265,13 @@

    Order
    Order <: LookupArrayTrait
     

    Traits for the order of a LookupArray. These determine how searchsorted finds values in the index, and how objects are plotted.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.OrderedType.

    Ordered <: Order
     

    Supertype for the order of an ordered LookupArray, including ForwardOrdered and ReverseOrdered.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.ForwardOrderedType.

    ForwardOrdered <: Ordered
    @@ -2279,7 +2279,7 @@ 

    Order ForwardOrdered()

    Indicates that the LookupArray index is in the normal forward order.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.ReverseOrderedType.

    ReverseOrdered <: Ordered
    @@ -2287,7 +2287,7 @@ 

    Order ReverseOrdered()

    Indicates that the LookupArray index is in the reverse order.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.UnorderedType.

    Unordered <: Order
    @@ -2296,7 +2296,7 @@ 

    Order

    Indicates that LookupArray is unordered.

    This means the index cannot be searched with searchsortedfirst or similar optimised methods - instead it will use findfirst.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AutoOrderType.

    AutoOrder <: Order
    @@ -2304,7 +2304,7 @@ 

    Order AutoOrder()

    Specifies that the Order of a LookupArray will be found automatically where possible.

    -

    source

    +

    source

    Span¤

    @@ -2313,7 +2313,7 @@

    Span¤
    Span <: LookupArrayTrait
     

    Defines the type of span used in a Sampling index. These are Regular or Irregular.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.RegularType.

    Regular <: Span
    @@ -2321,7 +2321,7 @@ 

    Span¤Regular(step=AutoStep())

    Points or Intervals that have a fixed, regular step.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.IrregularType.

    Irregular <: Span
    @@ -2330,14 +2330,14 @@ 

    Span¤Irregular(lowerbound, upperbound)

    Points or Intervals that have an Irrigular step size. To enable bounds tracking and accuract selectors, the starting bounds are provided as a 2 tuple, or 2 arguments. (nothing, nothing) is acceptable input, the bounds will be guessed from the index, but may be innaccurate.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.ExplicitType.

    Explicit(bounds::AbstractMatix)
     

    Intervals where the span is explicitly listed for every interval.

    This uses a matrix where with length 2 columns for each index value, holding the lower and upper bounds for that specific index.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AutoSpanType.

    AutoSpan <: Span
    @@ -2345,7 +2345,7 @@ 

    Span¤AutoSpan()

    The span will be guessed and replaced in format or set.

    -

    source

    +

    source

    Sampling¤

    @@ -2354,7 +2354,7 @@

    Sampling
    Sampling <: LookupArrayTrait
     

    Indicates the sampling method used by the index: Points or Intervals.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.PointsType.

    Points <: Sampling
    @@ -2363,7 +2363,7 @@ 

    SamplingSampling lookup where single samples at exact points.

    These are always plotted at the center of array cells.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.IntervalsType.

    Intervals <: Sampling
    @@ -2372,7 +2372,7 @@ 

    SamplingSampling specifying that sampled values are the mean (or similar) value over an interval, rather than at one specific point.

    Intervals require a Locus of Start, Center or End to define the location in the interval that the index values refer to.

    -

    source

    +

    source

    Loci¤

    @@ -2382,7 +2382,7 @@

    Loci¤Abstract supertype of types that indicate the position of index values where they represent Intervals.

    These allow for values array cells to align with the Start, Center, or End of values in the lookup index.

    This means they can be plotted with correct axis markers, and allows automatic converrsions to between formats with different standards (such as NetCDF and GeoTiff).

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.CenterType.

    Center <: Locus
    @@ -2390,7 +2390,7 @@ 

    Loci¤Center()

    Indicates a lookup value is for the center of its corresponding array cell.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.StartType.

    Start <: Locus
    @@ -2398,7 +2398,7 @@ 

    Loci¤Start()

    Indicates a lookup value is for the start of its corresponding array cell, in the direction of the lookup index order.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.EndType.

    End <: Locus
    @@ -2406,7 +2406,7 @@ 

    Loci¤End()

    Indicates a lookup value is for the end of its corresponding array cell, in the direction of the lookup index order.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.AutoLocusType.

    AutoLocus <: Locus
    @@ -2414,7 +2414,7 @@ 

    Loci¤AutoLocus()

    Indicates a interval where the index position is not yet known. This will be filled with a default value on object construction.

    -

    source

    +

    source

    LookupArrays methods¤

    @@ -2424,14 +2424,14 @@

    LookupArrays methodshasselection(x, selectors::Tuple) => Bool

    Check if indexing into x with selectors can be performed, where x is some object with a dims method, and selectors is a Selector or Dimension or a tuple of either.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.shiftlocusFunction.

    shiftlocus(locus::Locus, x)
     

    Shift the index of x from the current locus to the new locus.

    We only shift Sampled, Regular or Explicit, Intervals.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.samplingFunction.

    sampling(x, [dims::Tuple]) => Tuple
    @@ -2441,7 +2441,7 @@ 

    LookupArrays methodsSampling for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.spanFunction.

    span(x, [dims::Tuple]) => Tuple
    @@ -2451,7 +2451,7 @@ 

    LookupArrays methodsSpan for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.orderFunction.

    order(x, [dims::Tuple]) => Tuple
    @@ -2460,7 +2460,7 @@ 

    LookupArrays methodsUnordered

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.indexFunction.

    index(x) => Tuple{Vararg{AbstractArray}}
    @@ -2472,7 +2472,7 @@ 

    LookupArrays methods
    locus(x, [dims::Tuple]) => Tuple
    @@ -2482,7 +2482,7 @@ 

    LookupArrays methodsLocus for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    -

    source

    +

    source

    # DimensionalData.Dimensions.LookupArrays.unitsFunction.

    units(x) => Union{Nothing,Any}
    @@ -2493,7 +2493,7 @@ 

    LookupArrays methodsName¤

    @@ -2502,7 +2502,7 @@

    Name¤
    AbstractName
     

    Abstract supertype for name wrappers.

    -

    source

    +

    source

    # DimensionalData.NameType.

    Name <: AbstractName
    @@ -2511,7 +2511,7 @@ 

    Name¤Name(name::NoName) => NoName

    Name wrapper. This lets arrays keep symbol names when the array wrapper neeeds to be `isbits, like for use on GPUs. It makes the name a property of the type. It's not necessary to use in normal use, a symbol is probably easier.

    -

    source

    +

    source

    # DimensionalData.NoNameType.

    NoName <: AbstractName
    @@ -2519,7 +2519,7 @@ 

    Name¤NoName()

    NoName specifies an array is not named, and is the default name value for all AbstractDimArrays.

    -

    source

    +

    source

    diff --git a/previews/PR568/search/search_index.json b/previews/PR568/search/search_index.json index a35a53dab..ed6ea4b0e 100644 --- a/previews/PR568/search/search_index.json +++ b/previews/PR568/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#dimensionaldata","title":"DimensionalData","text":"

    DimensionalData.jl provides tools and abstractions for working with datasets that have named dimensions, and optionally a lookup index.

    DimensionalData is a pluggable, generalised version of AxisArrays.jl with a cleaner syntax, and additional functionality found in NamedDims.jl. It has similar goals to pythons xarray, and is primarily written for use with spatial data in Rasters.jl.

    "},{"location":"#goals","title":"Goals","text":"
    • Clean, readable syntax. Minimise required parentheses, minimise of exported
    • Zero-cost dimensional indexing a[Y(4), X(5)] of a single value. methods, and instead extend Base methods whenever possible.
    • Plotting is easy: data should plot sensibly and correctly with useful labels, by default.
    • Least surprise: everything works the same as in Base, but with named dims. If a method accepts numeric indices or dims=X in base, you should be able to use DimensionalData.jl dims.
    • Minimal interface: implementing a dimension-aware type should be easy.
    • Maximum extensibility: always use method dispatch. Regular types over special syntax. Recursion over @generated. Always dispatch on abstract types.
    • Type stability: dimensional methods should be type stable more often than Base methods
    • Functional style: structs are always rebuilt, and other than the array data, fields are not mutated in place.
    "},{"location":"#for-package-developers","title":"For package developers","text":""},{"location":"#data-types-and-the-interface","title":"Data types and the interface","text":"

    DimensionalData.jl provides the concrete DimArray type. But its behaviours are intended to be easily applied to other array types.

    more

    The main requirement for extending DimensionalData.jl is to define a dims method that returns a Tuple of Dimension that matches the dimension order and axis values of your data. Define rebuild and base methods for similar and parent if you want the metadata to persist through transformations (see the DimArray and AbstractDimArray types). A refdims method returns the lost dimensions of a previous transformation, passed in to the rebuild method. refdims can be discarded, the main loss being plot labels and ability to reconstruct dimensions in cat.

    Inheriting from AbstractDimArray in this way will give nearly all the functionality of using DimArray.

    "},{"location":"#lookuparrays-and-dimensions","title":"LookupArrays and Dimensions","text":"

    Sub modules LookupArrays and Dimensions define the behviour of dimensions and their lookup index.

    LookupArrays and Dimensions

    "},{"location":"reference/","title":"Reference","text":""},{"location":"reference/#api","title":"API","text":""},{"location":"reference/#arrays","title":"Arrays","text":"

    # DimensionalData.AbstractDimArray \u2014 Type.

    AbstractDimArray <: AbstractArray\n

    Abstract supertype for all \"dim\" arrays.

    These arrays return a Tuple of Dimension from a dims method, and can be rebuilt using rebuild.

    parent must return the source array.

    They should have metadata, name and refdims methods, although these are optional.

    A rebuild method for AbstractDimArray must accept data, dims, refdims, name, metadata arguments.

    Indexing AbstractDimArray with non-range AbstractArray has undefined effects on the Dimension index. Use forward-ordered arrays only\"

    source

    # DimensionalData.DimArray \u2014 Type.

    DimArray <: AbstractDimArray\n\nDimArray(data, dims, refdims, name, metadata)\nDimArray(data, dims::Tuple; refdims=(), name=NoName(), metadata=NoMetadata())\n

    The main concrete subtype of AbstractDimArray.

    DimArray maintains and updates its Dimensions through transformations and moves dimensions to reference dimension refdims after reducing operations (like e.g. mean).

    Arguments

    • data: An AbstractArray.
    • dims: A Tuple of Dimension
    • name: A string name for the array. Shows in plots and tables.
    • refdims: refence dimensions. Usually set programmatically to track past slices and reductions of dimension for labelling and reconstruction.
    • metadata: Dict or Metadata object, or NoMetadata()

    Indexing can be done with all regular indices, or with Dimensions and/or Selectors.

    Indexing AbstractDimArray with non-range AbstractArray has undefined effects on the Dimension index. Use forward-ordered arrays only\"

    Example:

    using Dates, DimensionalData\n\nti = (Ti(DateTime(2001):Month(1):DateTime(2001,12)),\nx = X(10:10:100))\nA = DimArray(rand(12,10), (ti, x), \"example\")\n\njulia> A[X(Near([12, 35])), Ti(At(DateTime(2001,5)))];\n\njulia> A[Near(DateTime(2001, 5, 4)), Between(20, 50)];\n

    source

    "},{"location":"reference/#multi-array-datasets","title":"Multi-array datasets","text":"

    # DimensionalData.AbstractDimStack \u2014 Type.

    AbstractDimStack\n

    Abstract supertype for dimensional stacks.

    These have multiple layers of data, but share dimensions.

    Notably, their behaviour lies somewhere between a DimArray and a NamedTuple:

    • indexing with a Symbol as in dimstack[:symbol] returns a DimArray layer.
    • iteration amd map are apply over array layers, as indexed with a Symbol.
    • getindex and many base methods are applied as for DimArray - to avoid the need to allways use map.

    This design gives very succinct code when working with many-layered, mixed-dimension objects. But it may be jarring initially - the most surprising outcome is that dimstack[1] will return a NamedTuple of values for the first index in all layers, while first(dimstack) will return the first value of the iterator - the DimArray for the first layer.

    See DimStack for the concrete implementation. Most methods are defined on the abstract type.

    To extend AbstractDimStack, implement argument and keyword version of rebuild and also rebuild_from_arrays.

    The constructor of an AbstractDimStack must accept a NamedTuple.

    source

    # DimensionalData.DimStack \u2014 Type.

    DimStack <: AbstractDimStack\n\nDimStack(data::AbstractDimArray...)\nDimStack(data::Tuple{Vararg{AbstractDimArray}})\nDimStack(data::NamedTuple{Keys,Vararg{AbstractDimArray}})\nDimStack(data::NamedTuple, dims::DimTuple; metadata=NoMetadata())\n

    DimStack holds multiple objects sharing some dimensions, in a NamedTuple.

    Notably, their behaviour lies somewhere between a DimArray and a NamedTuple:

    • indexing with a Symbol as in dimstack[:symbol] returns a DimArray layer.
    • iteration amd map are apply over array layers, as indexed with a Symbol.
    • getindex or view with Int, Dimensions or Selectors that resolve to Int will return a NamedTuple of values from each layer in the stack. This has very good performace, and avoids the need to always use map.
    • getindex or view with a Vector or Colon will return another DimStack where all data layers have been sliced.
    • setindex! must pass a Tuple or NamedTuple maching the layers.
    • many base and Statistics methods (sum, mean etc) will work as for a DimArray again removing the need to use map.

    For example, here we take the mean over the time dimension for all layers :

    mean(mydimstack; dims=Ti)\n

    And this equivalent to:

    map(A -> mean(A; dims=Ti), mydimstack)\n

    This design gives succinct code when working with many-layered, mixed-dimension objects.

    But it may be jarring initially - the most surprising outcome is that dimstack[1] will return a NamedTuple of values for the first index in all layers, while first(dimstack) will return the first value of the iterator - the DimArray for the first layer.

    DimStack can be constructed from multiple AbstractDimArray or a NamedTuple of AbstractArray and a matching dims tuple.

    Most Base and Statistics methods that apply to AbstractArray can be used on all layers of the stack simulataneously. The result is a DimStack, or a NamedTuple if methods like mean are used without dims arguments, and return a single non-array value.

    Example

    julia> using DimensionalData\n\njulia> A = [1.0 2.0 3.0; 4.0 5.0 6.0];\n\njulia> dimz = (X([:a, :b]), Y(10.0:10.0:30.0))\nX Symbol[:a, :b],\nY 10.0:10.0:30.0\n\njulia> da1 = DimArray(1A, dimz; name=:one);\n\njulia> da2 = DimArray(2A, dimz; name=:two);\n\njulia> da3 = DimArray(3A, dimz; name=:three);\n\njulia> s = DimStack(da1, da2, da3);\n\njulia> s[At(:b), At(10.0)]\n(one = 4.0, two = 8.0, three = 12.0)\n\njulia> s[X(At(:a))] isa DimStack\ntrue\n

    source

    "},{"location":"reference/#dimension-indices-generators","title":"Dimension indices generators","text":"

    # DimensionalData.DimIndices \u2014 Type.

    DimIndices <: AbstractArray\n\nDimIndices(x)\nDimIndices(dims::Tuple)\nDimIndices(dims::Dimension)\n

    Like CartesianIndices, but for Dimensions. Behaves as an Array of Tuple of Dimension(i) for all combinations of the axis indices of dims.

    This can be used to view/index into arbitrary dimensions over an array, and is especially useful when combined with otherdims, to iterate over the indices of unknown dimension.

    source

    # DimensionalData.DimKeys \u2014 Type.

    DimKeys <: AbstractArray\n\nDimKeys(x)\nDimKeys(dims::Tuple)\nDimKeys(dims::Dimension)\n

    Like CartesianIndices, but for the lookup values of Dimensions. Behaves as an Array of Tuple of Dimension(At(lookupvalue)) for all combinations of the lookup values of dims.

    source

    # DimensionalData.DimPoints \u2014 Type.

    DimPoints <: AbstractArray\n\nDimPoints(x; order)\nDimPoints(dims::Tuple; order)\nDimPoints(dims::Dimension; order)\n

    Like CartesianIndices, but for the point values of the dimension index. Behaves as an Array of Tuple lookup values (whatever they are) for all combinations of the lookup values of dims.

    Either a Dimension, a Tuple of Dimension or an object that defines a dims method can be passed in.

    Keywords

    • order: determines the order of the points, the same as the order of dims by default.

    source

    "},{"location":"reference/#tablesjltabletraitsjl-interface","title":"Tables.jl/TableTraits.jl interface","text":"

    # DimensionalData.AbstractDimTable \u2014 Type.

    AbstractDimTable <: Tables.AbstractColumns\n

    Abstract supertype for dim tables

    source

    # DimensionalData.DimTable \u2014 Type.

    DimTable <: AbstractDimTable\n\nDimTable(s::AbstractDimStack; mergedims=nothing)\nDimTable(x::AbstractDimArray; layersfrom=nothing, mergedims=nothing)\nDimTable(xs::Vararg{AbstractDimArray}; layernames=nothing, mergedims=nothing)\n

    Construct a Tables.jl/TableTraits.jl compatible object out of an AbstractDimArray or AbstractDimStack.

    This table will have columns for the array data and columns for each Dimension index, as a [DimColumn]. These are lazy, and generated as required.

    Column names are converted from the dimension types using DimensionalData.dim2key. This means type Ti becomes the column name :Ti, and Dim{:custom} becomes :custom.

    To get dimension columns, you can index with Dimension (X()) or Dimension type (X) as well as the regular Int or Symbol.

    Keywords

    • mergedims: Combine two or more dimensions into a new dimension.
    • layersfrom: Treat a dimension of an AbstractDimArray as layers of an AbstractDimStack.

    Example

    julia> a = DimArray(rand(32,32,3), (X,Y,Dim{:band}));\n\njulia> DimTable(a, layersfrom=Dim{:band}, mergedims=(X,Y)=>:geometry)\nDimTable with 1024 rows, 4 columns, and schema:\n :geometry  Tuple{Int64, Int64}\n :band_1    Float64\n :band_2    Float64\n :band_3    Float64\n

    source

    # DimensionalData.DimColumn \u2014 Type.

    DimColumn{T,D<:Dimension} <: AbstractVector{T}\n\nDimColumn(dim::Dimension, dims::Tuple{Vararg{DimTuple}})\nDimColumn(dim::DimColumn, length::Int, dimstride::Int)\n

    A table column based on a Dimension and it's relationship with other Dimensions in dims.

    length is the product of all dim lengths (usually the length of the corresponding array data), while stride is the product of the preceding dimension lengths, which may or may not be the real stride of the corresponding array depending on the data type. For A isa Array, the dimstride will match the stride.

    When the second argument is a Tuple of Dimension, the length and dimstride fields are calculated from the dimensions, relative to the column dimension dim.

    This object will be returned as a column of DimTable.

    source

    "},{"location":"reference/#common-methods","title":"Common methods","text":"

    Common functions for obtaining information from objects:

    # DimensionalData.Dimensions.dims \u2014 Function.

    dims(x, [dims::Tuple]) => Tuple{Vararg{Dimension}}\ndims(x, dim) => Dimension\n

    Return a tuple of Dimensions for an object, in the order that matches the axes or columns of the underlying data.

    dims can be Dimension, Dimension types, or Symbols for Dim{Symbol}.

    The default is to return nothing.

    source

    # DimensionalData.Dimensions.refdims \u2014 Function.

    refdims(x, [dims::Tuple]) => Tuple{Vararg{Dimension}}\nrefdims(x, dim) => Dimension\n

    Reference dimensions for an array that is a slice or view of another array with more dimensions.

    slicedims(a, dims) returns a tuple containing the current new dimensions and the new reference dimensions. Refdims can be stored in a field or disgarded, as it is mostly to give context to plots. Ignoring refdims will simply leave some captions empty.

    The default is to return an empty Tuple ().

    source

    # DimensionalData.Dimensions.LookupArrays.metadata \u2014 Function.

    metadata(x) => (object metadata)\nmetadata(x, dims::Tuple)  => Tuple (Dimension metadata)\nmetadata(xs::Tuple) => Tuple\n

    Returns the metadata for an object or for the specified dimension(s)

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.name \u2014 Function.

    name(x) => Symbol\nname(xs:Tuple) => NTuple{N,Symbol}\nname(x, dims::Tuple) => NTuple{N,Symbol}\nname(x, dim) => Symbol\n

    Get the name of an array or Dimension, or a tuple of of either as a Symbol.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    Utility methods for transforming DimensionalData objects:

    # DimensionalData.Dimensions.LookupArrays.set \u2014 Function.

    set(x, val)\nset(x, args::Pairs...) => x with updated field/s\nset(x, args...; kw...) => x with updated field/s\nset(x, args::Tuple{Vararg{Dimension}}; kw...) => x with updated field/s\n\nset(dim::Dimension, index::AbstractArray) => Dimension\nset(dim::Dimension, lookup::LookupArray) => Dimension\nset(dim::Dimension, lookupcomponent::LookupArrayTrait) => Dimension\nset(dim::Dimension, metadata::AbstractMetadata) => Dimension\n

    Set the properties of an object, its internal data or the traits of its dimensions and lookup index.

    As DimensionalData is so strongly typed you do not need to specify what field of a LookupArray to set - there is no ambiguity.

    To set fields of a LookupArray you need to specify the dimension. This can be done using X => val pairs, X = val keyword arguments, or X(val) wrapped arguments.

    When a Dimension or LookupArray is passed to set to replace the existing ones, fields that are not set will keep their original values.

    Notes:

    Changing a lookup index range/vector will also update the step size and order where applicable.

    Setting the Order like ForwardOrdered will not reverse the array or dimension to match. Use reverse and reorder to do this.

    Examples

    julia> using DimensionalData; const DD = DimensionalData\nDimensionalData\n\njulia> da = DimArray(zeros(3, 4), (custom=10.0:010.0:30.0, Z=-20:010.0:10.0));\n\njulia> set(da, ones(3, 4))\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Regular Points,\n  Z Sampled{Float64} -20.0:10.0:10.0 ForwardOrdered Regular Points\n       -20.0  -10.0  0.0  10.0\n 10.0    1.0    1.0  1.0   1.0\n 20.0    1.0    1.0  1.0   1.0\n 30.0    1.0    1.0  1.0   1.0 \n

    Change the Dimension wrapper type:

    julia> set(da, :Z => Ti, :custom => Z)\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Z Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Regular Points,\n  Ti Sampled{Float64} -20.0:10.0:10.0 ForwardOrdered Regular Points\n       -20.0  -10.0  0.0  10.0\n 10.0    0.0    0.0  0.0   0.0\n 20.0    0.0    0.0  0.0   0.0\n 30.0    0.0    0.0  0.0   0.0 \n

    Change the lookup Vector:

    julia> set(da, Z => [:a, :b, :c, :d], :custom => [4, 5, 6])\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Int64} Int64[4, 5, 6] ForwardOrdered Regular Points,\n  Z Sampled{Symbol} Symbol[:a, :b, :c, :d] ForwardOrdered Regular Points\n     :a   :b   :c   :d\n 4  0.0  0.0  0.0  0.0\n 5  0.0  0.0  0.0  0.0\n 6  0.0  0.0  0.0  0.0\n

    Change the LookupArray type:

    julia> set(da, Z=DD.NoLookup(), custom=DD.Sampled())\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Regular Points,\n  Z\n 10.0  0.0  0.0  0.0  0.0\n 20.0  0.0  0.0  0.0  0.0\n 30.0  0.0  0.0  0.0  0.0\n

    Change the Sampling trait:

    julia> set(da, :custom => DD.Irregular(10, 12), Z => DD.Regular(9.9))\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Irregular Points,\n  Z Sampled{Float64} -20.0:10.0:10.0 ForwardOrdered Regular Points\n       -20.0  -10.0  0.0  10.0\n 10.0    0.0    0.0  0.0   0.0\n 20.0    0.0    0.0  0.0   0.0\n 30.0    0.0    0.0  0.0   0.0\n

    source

    # DimensionalData.Dimensions.LookupArrays.rebuild \u2014 Function.

    rebuild(x, args...)\nrebuild(x; kw...)\n

    Rebuild an object struct with updated field values.

    x can be a AbstractDimArray, a Dimension, LookupArray or other custom types.

    This is an abstraction that alows inbuilt and custom types to be rebuilt to update their fields, as most objects in DimensionalData.jl are immutable.

    The arguments version can be concise but depends on a fixed order defined for some DimensionalData objects. It should be defined based on the object type in DimensionalData, adding the fields specific to your object.

    The keyword version ignores order, and is mostly automated using ConstructionBase.setproperties. It should only be defined if your object has missing fields or fields with different names to DimensionalData objects.

    The arguments required are defined for the abstract type that has a rebuild method.

    source

    # DimensionalData.modify \u2014 Function.

    modify(f, A::AbstractDimArray) => AbstractDimArray\nmodify(f, s::AbstractDimStack) => AbstractDimStack\nmodify(f, dim::Dimension) => Dimension\nmodify(f, x, lookupdim::Dimension) => typeof(x)\n

    Modify the parent data, rebuilding the object wrapper without change. f must return a AbstractArray of the same size as the original.

    This method is mostly useful as a way of swapping the parent array type of an object.

    Example

    If we have a previously-defined DimArray, we can copy it to an Nvidia GPU with:

    A = DimArray(rand(100, 100), (X, Y))\nmodify(CuArray, A)\n

    This also works for all the data layers in a DimStack.

    source

    # DimensionalData.broadcast_dims \u2014 Function.

    broadcast_dims(f, sources::AbstractDimArray...) => AbstractDimArray\n

    Broadcast function f over the AbstractDimArrays in sources, permuting and reshaping dimensions to match where required. The result will contain all the dimensions in all passed in arrays in the order in which they are found.

    Arguments

    • sources: AbstractDimArrays to broadcast over with f.

    This is like broadcasting over every slice of A if it is sliced by the dimensions of B.

    source

    # DimensionalData.broadcast_dims! \u2014 Function.

    broadcast_dims!(f, dest::AbstractDimArray, sources::AbstractDimArray...) => dest\n

    Broadcast function f over the AbstractDimArrays in sources, writing to dest. sources are permuting and reshaping dimensions to match where required.

    The result will contain all the dimensions in all passed in arrays, in the order in which they are found.

    Arguments

    • dest: AbstractDimArray to update.
    • sources: AbstractDimArrays to broadcast over with f.

    source

    # DimensionalData.mergedims \u2014 Function.

    mergedims(old_dims => new_dim) => Dimension\n

    Return a dimension new_dim whose indices are a MergedLookup of the indices of old_dims.

    source

    mergedims(dims, old_dims => new_dim, others::Pair...) => dims_new\n

    If dimensions old_dims, new_dim, etc. are found in dims, then return new dims_new where all dims in old_dims have been combined into a single dim new_dim. The returned dimension will keep only the name of new_dim. Its coords will be a MergedLookup of the coords of the dims in old_dims. New dimensions are always placed at the end of dims_new. others contains other dimension pairs to be merged.

    Example

    julia> ds = (X(0:0.1:0.4), Y(10:10:100), Ti([0, 3, 4]));\njulia> mergedims(ds, Ti => :time, (X, Y) => :space)\nDim{:time} MergedLookup{Tuple{Int64}} Tuple{Int64}[(0,), (3,), (4,)] Ti,\nDim{:space} MergedLookup{Tuple{Float64, Int64}} Tuple{Float64, Int64}[(0.0, 10), (0.1, 10), \u2026, (0.3, 100), (0.4, 100)] X, Y\n

    source

    mergedims(A::AbstractDimArray, dim_pairs::Pair...) => AbstractDimArray\nmergedims(A::AbstractDimStack, dim_pairs::Pair...) => AbstractDimStack\n

    Return a new array or stack whose dimensions are the result of mergedims(dims(A), dim_pairs).

    source

    # DimensionalData.unmergedims \u2014 Function.

    unmergedims(merged_dims::Tuple{Vararg{Dimension}}) => Tuple{Vararg{Dimension}}\n

    Return the unmerged dimensions from a tuple of merged dimensions. However, the order of the original dimensions are not necessarily preserved.

    source

    unmergedims(A::AbstractDimArray, original_dims) => AbstractDimArray\nunmergedims(A::AbstractDimStack, original_dims) => AbstractDimStack\n

    Return a new array or stack whose dimensions are restored to their original prior to calling mergedims(A, dim_pairs).

    source

    # DimensionalData.reorder \u2014 Function.

    reorder(A::Union{AbstractDimArray,AbstractDimStack}, order::Pair...)\nreorder(A::Union{AbstractDimArray,AbstractDimStack}, order)\nreorder(A::Dimension, order::Order)\n

    Reorder every dims index/array to order, or reorder index for the the given dimension(s) in order.

    order can be an Order, Dimension => Order pairs. A Tuple of Dimensions or any object that defines dims can be used in which case dimensions are

    If no axis reversal is required the same objects will be returned, without allocation.

    Example

    **Create a DimArray**\n\nda = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(300:-100:100)))\n\n**Reverse it**\n\nrev = reverse(da, dims=Y)\n\n**using `da` in reorder will return it to the original order**\n\nreorder(rev, da) == da\n\n**output**\n\ntrue\n\n\n<a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/1964cb53fe1d41aa54ef34aa5d8e2a6d1f576b59/src/utils.jl#L2-L27' class='documenter-source'>source</a><br>\n\n<a id='Base.cat' href='#Base.cat'>#</a>\n**`Base.cat`** &mdash; *Function*.\n\n\n\n```julia\nBase.cat(stacks::AbstractDimStack...; [keys=keys(stacks[1])], dims)\n

    Concatenate all or a subset of layers for all passed in stacks.

    Keywords

    • keys: Tuple of Symbol for the stack keys to concatenate.
    • dims: Dimension of child array to concatenate on.

    Example

    Concatenate the :seasurfacetemp and :humidity layers in the time dimension:

    cat(stacks...; keys=(:sea_surface_temp, :humidity), dims=Ti)\n

    source

    # Base.map \u2014 Function.

    Base.map(f, stacks::AbstractDimStack...)\n

    Apply function f to each layer of the stacks.

    If f returns DimArrays the result will be another DimStack. Other values will be returned in a NamedTuple.

    source

    # Base.copy! \u2014 Function.

    Base.copy!(dst::AbstractArray, src::AbstractGimStack, key::Key)\n

    Copy the stack layer key to dst, which can be any AbstractArray.

    Example

    Copy the :humidity layer from stack to array.

    copy!(array, stack, :humidity)\n

    source

    Base.copy!(dst::AbstractDimStack, src::AbstractDimStack, [keys=keys(dst)])\n

    Copy all or a subset of layers from one stack to another.

    Example

    Copy just the :sea_surface_temp and :humidity layers from src to dst.

    copy!(dst::AbstractDimStack, src::AbstractDimStack, keys=(:sea_surface_temp, :humidity))\n

    source

    # Base.eachslice \u2014 Function.

    Base.eachslice(stack::AbstractDimStack; dims)\n

    Create a generator that iterates over dimensions dims of stack, returning stacks that select all the data from the other dimensions in stack using views.

    The generator has size and axes equivalent to those of the provided dims.

    Examples

    julia> ds = DimStack((\n           x=DimArray(randn(2, 3, 4), (X([:x1, :x2]), Y(1:3), Z)),\n           y=DimArray(randn(2, 3, 5), (X([:x1, :x2]), Y(1:3), Ti))\n       ));\n\njulia> slices = eachslice(ds; dims=(Z, X));\n\njulia> size(slices)\n(4, 2)\n\njulia> map(dims, axes(slices))\nZ,\nX Categorical{Symbol} Symbol[x1, x2] ForwardOrdered\n\njulia> first(slices)\nDimStack with dimensions:\n  Y Sampled{Int64} 1:3 ForwardOrdered Regular Points,\n  Ti\nand 2 layers:\n  :x Float64 dims: Y (3)\n  :y Float64 dims: Y, Ti (3\u00d75)\n

    source

    Most base methods work as expected, using Dimension wherever a dims keyword is used. They are not allspecifically documented here.

    Shorthand constructors:

    # Base.fill \u2014 Function.

    Base.fill(x, dims::Dimension...; kw...) => DimArray\nBase.fill(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\n

    Create a DimArray with a fill value of x.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    ```@doctest julia> using DimensionalData

    julia> rand(Bool, X(2), Y(4)) 2\u00d74 DimArray{Bool,2} with dimensions: X, Y 1 0 0 1 1 0 1 1

    <a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/1964cb53fe1d41aa54ef34aa5d8e2a6d1f576b59/src/array/array.jl#L409-L432' class='documenter-source'>source</a><br>\n\n<a id='Base.rand' href='#Base.rand'>#</a>\n**`Base.rand`** &mdash; *Function*.\n\n\n\n```julia\nBase.rand(x, dims::Dimension...; kw...) => DimArray\nBase.rand(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\nBase.rand(r::AbstractRNG, x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\nBase.rand(r::AbstractRNG, x, dims::Dimension...; kw...) => DimArray\n

    Create a DimArray of random values.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    julia> using DimensionalData\n\njulia> rand(Bool, X(2), Y(4))\n2\u00d74 DimArray{Bool,2} with dimensions: X, Y\n 1  0  0  1\n 1  0  1  1\n\njulia> rand(X([:a, :b, :c]), Y(100.0:50:200.0))\n3\u00d73 DimArray{Float64,2} with dimensions:\n  X: Symbol[a, b, c] Categorical: Unordered,\n  Y: 100.0:50.0:200.0 Sampled: Ordered Regular Points\n 0.43204   0.835111  0.624231\n 0.752868  0.471638  0.193652\n 0.484558  0.846559  0.455256\n

    source

    # Base.zeros \u2014 Function.

    Base.zeros(x, dims::Dimension...; kw...) => DimArray\nBase.zeros(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\n

    Create a DimArray of zeros.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    ```@doctest julia> using DimensionalData

    julia> zeros(Bool, X(2), Y(4)) 2\u00d74 DimArray{Bool,2} with dimensions: X, Y 0 0 0 0 0 0 0 0

    julia> zeros(X([:a, :b, :c]), Y(100.0:50:200.0)) 3\u00d73 DimArray{Float64,2} with dimensions: X: Symbol[a, b, c] Categorical: Unordered, Y: 100.0:50.0:200.0 Sampled: Ordered Regular Points 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

    <a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/1964cb53fe1d41aa54ef34aa5d8e2a6d1f576b59/src/array/array.jl#L472-L504' class='documenter-source'>source</a><br>\n\n<a id='Base.ones' href='#Base.ones'>#</a>\n**`Base.ones`** &mdash; *Function*.\n\n\n\n```julia\nBase.ones(x, dims::Dimension...; kw...) => DimArray\nBase.ones(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\n

    Create a DimArray of ones.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    ```@doctest julia> using DimensionalData

    julia> ones(Bool, X(2), Y(4)) 2\u00d74 DimArray{Bool,2} with dimensions: X, Y 1 1 1 1 1 1 1 1

    julia> ones(X([:a, :b, :c]), Y(100.0:50:200.0)) 3\u00d73 DimArray{Float64,2} with dimensions: X: Symbol[a, b, c] Categorical: Unordered, Y: 100.0:50.0:200.0 Sampled: Ordered Regular Points 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0

    <a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/1964cb53fe1d41aa54ef34aa5d8e2a6d1f576b59/src/array/array.jl#L507-L539' class='documenter-source'>source</a><br>\n\n\n<a id='Dimensions'></a>\n\n<a id='Dimensions-1'></a>\n\n# Dimensions\n\n\nHandling of Dimensions is kept in a sub-module `Dimensions`.\n\n<a id='DimensionalData.Dimensions' href='#DimensionalData.Dimensions'>#</a>\n**`DimensionalData.Dimensions`** &mdash; *Module*.\n\n\n\nDimensions\n\nSub-module for [`Dimension`](reference.md#DimensionalData.Dimensions.Dimension)s wrappers, and operations on them used in DimensionalData.jl.\n\nTo load `Dimensions` types and methods into scope:\n\n```julia\nusing DimensionalData\nusing DimensionalData.Dimensions\n

    source

    Dimensions have a type-heirarchy that organises plotting and dimension matching.

    # DimensionalData.Dimensions.Dimension \u2014 Type.

    Dimension\n

    Abstract supertype of all dimension types.

    Example concrete implementations are X, Y, Z, Ti (Time), and the custom [Dim]@ref) dimension.

    Dimensions label the axes of an AbstractDimArray, or other dimensional objects, and are used to index into the array.

    They may also provide an alternate index to lookup for each array axis. This may be any AbstractVector matching the array axis length, or a Val holding a tuple for compile-time index lookups.

    Dimensions also have lookup and metadata fields.

    lookup gives more details about the dimension, such as that it is Categorical or Sampled as Points or Intervals along some transect. DimensionalData will attempt to guess the lookup from the passed-in index value.

    Example:

    using DimensionalData, Dates\n\nx = X(2:2:10)\ny = Y(['a', 'b', 'c'])\nti = Ti(DateTime(2021, 1):Month(1):DateTime(2021, 12))\n\nA = DimArray(zeros(3, 5, 12), (y, x, ti))\n\n# output\n\n3\u00d75\u00d712 DimArray{Float64,3} with dimensions:\n  Y Categorical{Char} Char['a', 'b', 'c'] ForwardOrdered,\n  X Sampled{Int64} 2:2:10 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2021-01-01T00:00:00\"):Month(1):DateTime(\"2021-12-01T00:00:00\") ForwardOrdered Regular Points\n[:, :, 1]\n       2    4    6    8    10\n  'a'  0.0  0.0  0.0  0.0   0.0\n  'b'  0.0  0.0  0.0  0.0   0.0\n  'c'  0.0  0.0  0.0  0.0   0.0\n[and 11 more slices...]\n

    For simplicity, the same Dimension types are also used as wrappers in getindex, like:

    x = A[X(2), Y(3)]\n\n# output\n\n12-element DimArray{Float64,1} with dimensions:\n  Ti Sampled{DateTime} DateTime(\"2021-01-01T00:00:00\"):Month(1):DateTime(\"2021-12-01T00:00:00\") ForwardOrdered Regular Points\nand reference dimensions:\n  Y Categorical{Char} Char['c'] ForwardOrdered,\n  X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points\n 2021-01-01T00:00:00  0.0\n 2021-02-01T00:00:00  0.0\n 2021-03-01T00:00:00  0.0\n 2021-04-01T00:00:00  0.0\n \u22ee\n 2021-10-01T00:00:00  0.0\n 2021-11-01T00:00:00  0.0\n 2021-12-01T00:00:00  0.0\n

    A Dimension can also wrap Selector.

    x = A[X(Between(3, 4)), Y(At('b'))]\n\n# output\n\n1\u00d712 DimArray{Float64,2} with dimensions:\n  X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2021-01-01T00:00:00\"):Month(1):DateTime(\"2021-12-01T00:00:00\") ForwardOrdered Regular Points\nand reference dimensions:\n  Y Categorical{Char} Char['b'] ForwardOrdered\n     2021-01-01T00:00:00  \u2026   2021-12-01T00:00:00\n 4  0.0                                  0.0\n

    Dimension objects may have lookup and metadata fields to track additional information about the data and the index, and their relationship.

    source

    # DimensionalData.Dimensions.DependentDim \u2014 Type.

    DependentDim <: Dimension\n

    Abstract supertype for Dependent dimensions. These will plot on the Y axis.

    source

    # DimensionalData.Dimensions.IndependentDim \u2014 Type.

    IndependentDim <: Dimension\n

    Abstract supertype for independent dimensions. Thise will plot on the X axis.

    source

    # DimensionalData.Dimensions.XDim \u2014 Type.

    XDim <: IndependentDim\n

    Abstract supertype for all X dimensions.

    source

    # DimensionalData.Dimensions.YDim \u2014 Type.

    YDim <: DependentDim\n

    Abstract supertype for all Y dimensions.

    source

    # DimensionalData.Dimensions.ZDim \u2014 Type.

    ZDim <: DependentDim\n

    Abstract supertype for all Z dimensions.

    source

    # DimensionalData.Dimensions.TimeDim \u2014 Type.

    TimeDim <: IndependentDim\n

    Abstract supertype for all time dimensions.

    In a TimeDime with Interval sampling the locus will automatically be set to Start(). Dates and times generally refer to the start of a month, hour, second etc., not the central point as is more common with spatial data. `

    source

    # DimensionalData.Dimensions.X \u2014 Type.

    X <: XDim\n\nX(val=:)\n

    X Dimension. X <: XDim <: IndependentDim

    Example:

    xdim = X(2:2:10)\n# Or\nval = A[X(1)]\n# Or\nmean(A; dims=X)\n

    source

    # DimensionalData.Dimensions.Y \u2014 Type.

    Y <: YDim\n\nY(val=:)\n

    Y Dimension. Y <: YDim <: DependentDim

    Example:

    ydim = Y(['a', 'b', 'c'])\n# Or\nval = A[Y(1)]\n# Or\nmean(A; dims=Y)\n

    source

    # DimensionalData.Dimensions.Z \u2014 Type.

    Z <: ZDim\n\nZ(val=:)\n

    Z Dimension. Z <: ZDim <: Dimension

    Example:

    zdim = Z(10:10:100)\n# Or\nval = A[Z(1)]\n# Or\nmean(A; dims=Z)\n

    source

    # DimensionalData.Dimensions.Ti \u2014 Type.

    m Ti <: TimeDim

    Ti(val=:)\n

    Time Dimension. Ti <: TimeDim <: IndependentDim

    Time is already used by Dates, and T is a common type parameter, We use Ti to avoid clashes.

    Example:

    timedim = Ti(DateTime(2021, 1):Month(1):DateTime(2021, 12))\n# Or\nval = A[Ti(1)]\n# Or\nmean(A; dims=Ti)\n

    source

    # DimensionalData.Dimensions.Dim \u2014 Type.

    Dim{S}(val=:)\n

    A generic dimension. For use when custom dims are required when loading data from a file. Can be used as keyword arguments for indexing.

    Dimension types take precedence over same named Dim types when indexing with symbols, or e.g. creating Tables.jl keys.

    using DimensionalData\n\ndim = Dim{:custom}(['a', 'b', 'c'])\n\n# output\n\nDim{:custom} Char['a', 'b', 'c']\n

    source

    # DimensionalData.Dimensions.Coord \u2014 Type.

    Coord <: Dimension\n

    A coordinate dimension itself holds dimensions.

    This allows combining point data with other dimensions, such as time.

    Example

    julia> using DimensionalData\n\njulia> dim = Coord([(1.0,1.0,1.0), (1.0,2.0,2.0), (3.0,4.0,4.0), (1.0,3.0,4.0)], (X(), Y(), Z()))\nCoord ::\n  val: Tuple{Float64, Float64, Float64}[(1.0, 1.0, 1.0), (1.0, 2.0, 2.0), (3.0, 4.0, 4.0), (1.0, 3.0,\n4.0)]\n  lookup: MergedLookup\nCoord{Vector{Tuple{Float64, Float64, Float64}}, DimensionalData.MergedLookup{Tuple{X{Colon, AutoLookup{Auto\nOrder}, NoMetadata}, Y{Colon, AutoLookup{AutoOrder}, NoMetadata}, Z{Colon, AutoLookup{AutoOrder}, NoMetada\nta}}}, NoMetadata}\n\njulia> da = DimArray(0.1:0.1:0.4, dim)\n4-element DimArray{Float64,1} with dimensions:\n  Coord (): Tuple{Float64, Float64, Float64}[(1.0, 1.0, 1.0), (1.0, 2.0, 2.0), (3.0, 4.0, 4.0), (1.0,\n3.0, 4.0)]\n    MergedLookup\n 0.1\n 0.2\n 0.3\n 0.4\n\njulia> da[Coord(Z(At(1.0)), Y(Between(1, 3)))]\n1-element DimArray{Float64,1} with dimensions:\n  Coord (): Tuple{Float64, Float64, Float64}[(1.0, 1.0, 1.0)] MergedLookup\n 0.1\n\njulia> da[Coord(4)] == 0.4\ntrue\n\njulia> da[Coord(Between(1, 5), :, At(4.0))]\n2-element DimArray{Float64,1} with dimensions:\n  Coord (): Tuple{Float64, Float64, Float64}[(3.0, 4.0, 4.0), (1.0, 3.0, 4.0)] MergedLookup\n 0.3\n 0.4\n

    source

    # DimensionalData.Dimensions.AnonDim \u2014 Type.

    AnonDim <: Dimension\n\nAnonDim()\n

    Anonymous dimension. Used when extra dimensions are created, such as during transpose of a vector.

    source

    # DimensionalData.Dimensions.@dim \u2014 Macro.

    @dim typ [supertype=Dimension] [name::String=string(typ)]\n

    Macro to easily define new dimensions. The supertype will be inserted into the type of the dim. The default is simply YourDim <: Dimension. Making a Dimesion inherit from XDim, YDim, ZDim or TimeDim will affect automatic plot layout and other methods that dispatch on these types. <: YDim are plotted on the Y axis, <: XDim on the X axis, etc.

    Example:

    using DimensionalData\nusing DimensionalData: @dim, YDim, XDim\n@dim Lat YDim \"latitude\"\n@dim Lon XDim \"Longitude\"\n# output\n

    source

    "},{"location":"reference/#exported-methods","title":"Exported methods","text":"

    # DimensionalData.Dimensions.hasdim \u2014 Function.

    hasdim([f], x, query::Tuple) => NTUple{Bool}\nhasdim([f], x, query...) => NTUple{Bool}\nhasdim([f], x, query) => Bool\n

    Check if an object x has dimensions that match or inherit from the query dimensions.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension or a single Dimension.
    • query: Tuple or single Dimension or dimension Type.
    • f: <: by default, but can be >: to match abstract types to concrete types.

    Check if an object or tuple contains an Dimension, or a tuple of dimensions.

    Example

    julia> using DimensionalData\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> hasdim(A, X)\ntrue\n\njulia> hasdim(A, (Z, X, Y))\n(true, true, true)\n\njulia> hasdim(A, Ti)\nfalse\n

    source

    # DimensionalData.Dimensions.dimnum \u2014 Function.

    dimnum(x, query::Tuple) => NTuple{Int}\ndimnum(x, query) => Int\n

    Get the number(s) of Dimension(s) as ordered in the dimensions of an object.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension or a single Dimension.
    • query: Tuple, Array or single Dimension or dimension Type.

    The return type will be a Tuple of Int or a single Int, depending on wether query is a Tuple or single Dimension.

    Example

    julia> using DimensionalData\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> dimnum(A, (Z, X, Y))\n(3, 1, 2)\n\njulia> dimnum(A, Y)\n2\n

    source

    "},{"location":"reference/#non-exported-methods","title":"Non-exported methods","text":"

    # DimensionalData.Dimensions.lookup \u2014 Function.

    lookup(x::Dimension) => LookupArray\nlookup(x, [dims::Tuple]) => Tuple{Vararg{LookupArray}}\nlookup(x::Tuple) => Tuple{Vararg{LookupArray}}\nlookup(x, dim) => LookupArray\n

    Returns the LookupArray of a dimension. This dictates properties of the dimension such as array axis and index order, and sampling properties.

    dims can be a Dimension, a dimension type, or a tuple of either.

    source

    # DimensionalData.Dimensions.label \u2014 Function.

    label(x) => String\nlabel(x, dims::Tuple) => NTuple{N,String}\nlabel(x, dim) => String\nlabel(xs::Tuple) => NTuple{N,String}\n

    Get a plot label for data or a dimension. This will include the name and units if they exist, and anything else that should be shown on a plot.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.dim2key \u2014 Function.

    dim2key(dim::Dimension) => Symbol\ndim2key(dims::Type{<:Dimension}) => Symbol\ndim2key(dims::Tuple) => Tuple{Symbol,Vararg}\n

    Convert a dimension object to a simbol. X(), Y(), Ti() etc will be converted. to :X, :Y, :Ti, as with any other dims generated with the @dim macro.

    All other Dim{S}() dimensions will generate Symbols S.

    source

    # DimensionalData.Dimensions.key2dim \u2014 Function.

    key2dim(s::Symbol) => Dimension\nkey2dim(dims...) => Tuple{Dimension,Vararg}\nkey2dim(dims::Tuple) => Tuple{Dimension,Vararg}\n

    Convert a symbol to a dimension object. :X, :Y, :Ti etc will be converted. to X(), Y(), Ti(), as with any other dims generated with the @dim macro.

    All other Symbols S will generate Dim{S}() dimensions.

    source

    # DimensionalData.Dimensions.dims2indices \u2014 Function.

    dims2indices(dim::Dimension, I) => NTuple{Union{Colon,AbstractArray,Int}}\n

    Convert a Dimension or Selector I to indices of Int, AbstractArray or Colon.

    source

    # DimensionalData.Dimensions.LookupArrays.selectindices \u2014 Function.

    selectindices(lookups, selectors)\n

    Converts Selector to regular indices.

    source

    # DimensionalData.Dimensions.format \u2014 Function.

    format(dims, x) => Tuple{Vararg{Dimension,N}}\n

    Format the passed-in dimension(s) dims to match the object x.

    Errors are thrown if dims don't match the array dims or size, and any fields holding Auto- objects are filled with guessed objects.

    If a LookupArray hasn't been specified, a lookup is chosen based on the type and element type of the index.

    source

    # DimensionalData.Dimensions.reducedims \u2014 Function.

    reducedims(x, dimstoreduce) => Tuple{Vararg{Dimension}}\n

    Replace the specified dimensions with an index of length 1. This is usually to match a new array size where an axis has been reduced with a method like mean or reduce to a length of 1, but the number of dimensions has not changed.

    LookupArray traits are also updated to correspond to the change in cell step, sampling type and order.

    source

    # DimensionalData.Dimensions.swapdims \u2014 Function.

    swapdims(x::T, newdims) => T\nswapdims(dims::Tuple, newdims) => Tuple{Vararg{Dimension}}\n

    Swap dimensions for the passed in dimensions, in the order passed.

    Passing in the Dimension types rewraps the dimension index, keeping the index values and metadata, while constructed Dimension objectes replace the original dimension. nothing leaves the original dimension as-is.

    Arguments

    • x: any object with a dims method or a Tuple of Dimension.
    • newdim: Tuple of Dimension or dimension Type.

    Example

    using DimensionalData\nA = ones(X(2), Y(4), Z(2))\nDimensions.swapdims(A, (Dim{:a}, Dim{:b}, Dim{:c}))\n\n# output\n2\u00d74\u00d72 DimArray{Float64,3} with dimensions: Dim{:a}, Dim{:b}, Dim{:c}\n[:, :, 1]\n 1.0  1.0  1.0  1.0\n 1.0  1.0  1.0  1.0\n[and 1 more slices...]\n

    source

    # DimensionalData.Dimensions.slicedims \u2014 Function.

    slicedims(x, I) => Tuple{Tuple,Tuple}\nslicedims(f, x, I) => Tuple{Tuple,Tuple}\n

    Slice the dimensions to match the axis values of the new array.

    All methods return a tuple conatining two tuples: the new dimensions, and the reference dimensions. The ref dimensions are no longer used in the new struct but are useful to give context to plots.

    Called at the array level the returned tuple will also include the previous reference dims attached to the array.

    Arguments

    • f: a function getindex, view or dotview. This will be used for slicing getindex is the default if f is not included.
    • x: An AbstractDimArray, Tuple of Dimension, or Dimension
    • I: A tuple of Integer, Colon or AbstractArray

    source

    # DimensionalData.Dimensions.comparedims \u2014 Function.

    comparedims(A::AbstractDimArray...; kw...)\ncomparedims(A::Tuple...; kw...)\ncomparedims(A::Dimension...; kw...)\ncomparedims(::Type{Bool}, args...; kw...)\n

    Check that dimensions or tuples of dimensions passed as each argument are the same, and return the first valid dimension. If AbstractDimArrays are passed as arguments their dimensions are compared.

    Empty tuples and nothing dimension values are ignored, returning the Dimension value if it exists.

    Passing Bool as the first argument means true/false will be returned, rather than throwing an error.

    Keywords

    These are all Bool flags:

    • type: compare dimension type, true by default.
    • valtype: compare wrapped value type, false by default.
    • val: compare wrapped values, false by default.
    • order: compare order, false by default.
    • length: compare lengths, true by default.
    • ignore_length_one: ignore length 1 in comparisons, and return whichever dimension is not length 1, if any. This is useful in e.g. broadcasting comparisons. false by default.
    • warn: a String or nothing. Used only for Bool methods, to give a warning for false values and include warn in the warning text.

    source

    # DimensionalData.Dimensions.combinedims \u2014 Function.

    combinedims(xs; check=true)\n

    Combine the dimensions of each object in xs, in the order they are found.

    source

    # DimensionalData.Dimensions.otherdims \u2014 Function.

    otherdims(x, query) => Tuple{Vararg{Dimension,N}}\n

    Get the dimensions of an object not in query.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension.
    • query: Tuple or single Dimension or dimension Type.
    • f: <: by default, but can be >: to match abstract types to concrete types.

    A tuple holding the unmatched dimensions is always returned.

    Example

    julia> using DimensionalData, DimensionalData.Dimensions\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> otherdims(A, X)\nY, Z\n\njulia> otherdims(A, (Y, Z))\nX\n

    source

    # DimensionalData.Dimensions.commondims \u2014 Function.

    commondims([f], x, query) => Tuple{Vararg{Dimension}}\n

    This is basically dims(x, query) where the order of the original is kept, unlike dims where the query tuple determines the order

    Also unlike dims,commondims always returns a Tuple, no matter the input. No errors are thrown if dims are absent from either x or query.

    f is <: by default, but can be >: to sort abstract types by concrete types.

    julia> using DimensionalData, .Dimensions\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> commondims(A, X)\nX\n\njulia> commondims(A, (X, Z))\nX, Z\n\njulia> commondims(A, Ti)\n()\n

    source

    # DimensionalData.Dimensions.sortdims \u2014 Function.

    sortdims([f], tosort, order) => Tuple\n

    Sort dimensions tosort by order. Dimensions in order but missing from tosort are replaced with nothing.

    tosort and order can be Tuples or Vectors or Dimension or dimension type. Abstract supertypes like TimeDim can be used in order.

    f is <: by default, but can be >: to sort abstract types by concrete types.

    source

    # DimensionalData.Dimensions.LookupArrays.basetypeof \u2014 Function.

    basetypeof(x) => Type\n

    Get the \"base\" type of an object - the minimum required to define the object without it's fields. By default this is the full UnionAll for the type. But custom basetypeof methods can be defined for types with free type parameters.

    In DimensionalData this is primariliy used for comparing Dimensions, where Dim{:x} is different from Dim{:y}.

    source

    # DimensionalData.Dimensions.setdims \u2014 Function.

    setdims(X, newdims) => AbstractArray\nsetdims(::Tuple, newdims) => Tuple{Vararg{Dimension,N}}\n

    Replaces the first dim matching <: basetypeof(newdim) with newdim, and returns a new object or tuple with the dimension updated.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension or a single Dimension.
    • newdim: Tuple or single Dimension, Type or Symbol.

    Example

    using DimensionalData, DimensionalData.Dimensions, DimensionalData.LookupArrays\nA = ones(X(10), Y(10:10:100))\nB = setdims(A, Y(Categorical('a':'j'; order=ForwardOrdered())))\nlookup(B, Y)\n# output\nCategorical{Char} ForwardOrdered\nwrapping: 'a':1:'j'\n

    source

    # DimensionalData.Dimensions.dimsmatch \u2014 Function.

    dimsmatch([f], dim, query) => Bool\ndimsmatch([f], dims::Tuple, query::Tuple) => Bool\n

    Compare 2 dimensions or Tuple of Dimension are of the same base type, or are at least rotations/transformations of the same type.

    f is <: by default, but can be >: to match abstract types to concrete types.

    source

    # DimensionalData.Dimensions.dimstride \u2014 Function.

    dimstride(x, dim) => Int\n

    Get the stride of the dimension relative to the other dimensions.

    This may or may not be equal to the stride of the related array, although it will be for Array.

    Arguments

    • x is any object with a dims method, or a Tuple of Dimension.
    • dim is a Dimension, Dimension type, or and Int. Using an Int is not type-stable.

    source

    # DimensionalData.refdims_title \u2014 Function.

    refdims_title(A::AbstractDimArray)\nrefdims_title(refdims::Tuple)\nrefdims_title(refdim::Dimension)\n

    Generate a title string based on reference dimension values.

    source

    # DimensionalData.rebuild_from_arrays \u2014 Function.

    rebuild_from_arrays(s::AbstractDimStack, das::NamedTuple{<:Any,<:Tuple{Vararg{AbstractDimArray}}}; kw...)\n

    Rebuild an AbstractDimStack from a Tuple or NamedTuple of AbstractDimArray and an existing stack.

    Keywords

    Keywords are simply the fields of the stack object:

    • data
    • dims
    • refdims
    • metadata
    • layerdims
    • layermetadata

    source

    "},{"location":"reference/#lookuparrays","title":"LookupArrays","text":"

    # DimensionalData.Dimensions.LookupArrays \u2014 Module.

    LookupArrays\n

    Module for LookupArrays and [Selector]s used in DimensionalData.jl

    LookupArrays defines traits and AbstractArray wrappers that give specific behaviours for a lookup index when indexed with Selector.

    For example, these allow tracking over array order so fast indexing works evne when the array is reversed.

    To load LookupArrays types and methods into scope:

    using DimensionalData\nusing DimensionalData.LookupArrays\n

    source

    "},{"location":"reference/#selectors","title":"Selectors","text":"

    # DimensionalData.Dimensions.LookupArrays.Selector \u2014 Type.

    Selector\n

    Abstract supertype for all selectors.

    Selectors are wrappers that indicate that passed values are not the array indices, but values to be selected from the dimension index, such as DateTime objects for a Ti dimension.

    Selectors provided in DimensionalData are:

    • At
    • Between
    • Touches
    • Near
    • Where
    • Contains

    source

    # DimensionalData.Dimensions.LookupArrays.IntSelector \u2014 Type.

    IntSelector <: Selector\n

    Abstract supertype for Selectors that return a single Int index.

    IntSelectors provided by DimensionalData are:

    • At
    • Contains
    • Near

    source

    # DimensionalData.Dimensions.LookupArrays.ArraySelector \u2014 Type.

    ArraySelector <: Selector\n

    Abstract supertype for Selectors that return an AbstractArray.

    ArraySelectors provided by DimensionalData are:

    • Between
    • Touches
    • Where

    source

    # DimensionalData.Dimensions.LookupArrays.At \u2014 Type.

    At <: IntSelector\n\nAt(x, atol, rtol)\nAt(x; atol=nothing, rtol=nothing)\n

    Selector that exactly matches the value on the passed-in dimensions, or throws an error. For ranges and arrays, every intermediate value must match an existing value - not just the end points.

    x can be any value or Vector of values.

    atol and rtol are passed to isapprox. For Number rtol will be set to Base.rtoldefault, otherwise nothing, and wont be used.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(At(20)), Y(At(6))]\n\n# output\n\n5\n

    source

    # DimensionalData.Dimensions.LookupArrays.Near \u2014 Type.

    Near <: IntSelector\n\nNear(x)\n

    Selector that selects the nearest index to x.

    With Points this is simply the index values nearest to the x, however with Intervals it is the interval center nearest to x. This will be offset from the index value for Start and End loci.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(Near(23)), Y(Near(5.1))]\n\n# output\n4\n

    source

    # DimensionalData.Dimensions.LookupArrays.Between \u2014 Type.

    Between <: ArraySelector\n\nBetween(a, b)\n

    Depreciated: use a..b instead of Between(a, b). Other Interval objects from IntervalSets.jl, like `OpenInterval(a, b) will also work, giving the correct open/closed boundaries.

    Between will e removed in furture to avoid clashes with DataFrames.Between.

    Selector that retreive all indices located between 2 values, evaluated with >= for the lower value, and < for the upper value. This means the same value will not be counted twice in 2 adjacent Between selections.

    For Intervals the whole interval must be lie between the values. For Points the points must fall between the values. Different Sampling types may give different results with the same input - this is the intended behaviour.

    Between for Irregular intervals is a little complicated. The interval is the distance between a value and the next (for Start locus) or previous (for End locus) value.

    For Center, we take the mid point between two index values as the start and end of each interval. This may or may not make sense for the values in your indes, so use Between with Irregular Intervals(Center()) with caution.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(Between(15, 25)), Y(Between(4, 6.5))]\n\n# output\n\n1\u00d72 DimArray{Int64,2} with dimensions:\n  X Sampled{Int64} 20:10:20 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 5:6 ForwardOrdered Regular Points\n     5  6\n 20  4  5\n

    source

    # DimensionalData.Dimensions.LookupArrays.Touches \u2014 Type.

    Touches <: ArraySelector\n\nTouches(a, b)\n

    Selector that retreives all indices touching the closed interval 2 values, for the maximum possible area that could interact with the supplied range.

    This can be better than .. when e.g. subsetting an area to rasterize, as you may wish to include pixels that just touch the area, rather than those that fall within it.

    Touches is different to using closed intervals when the lookups also contain intervals - if any of the intervals touch, they are included. With .. they are discarded unless the whole cell interval falls inside the selector interval.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(Touches(15, 25)), Y(Touches(4, 6.5))]\n\n# output\n1\u00d72 DimArray{Int64,2} with dimensions:\n  X Sampled{Int64} 20:10:20 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 5:6 ForwardOrdered Regular Points\n     5  6\n 20  4  5\n

    source

    # DimensionalData.Dimensions.LookupArrays.Contains \u2014 Type.

    Contains <: IntSelector\n\nContains(x)\n

    Selector that selects the interval the value is contained by. If the interval is not present in the index, an error will be thrown.

    Can only be used for Intervals or Categorical. For Categorical it falls back to using At. Contains should not be confused with Base.contains - use Where(contains(x)) to check for if values are contain in categorical values like strings.

    Example

    using DimensionalData; const DD = DimensionalData\ndims_ = X(10:10:20; sampling=DD.Intervals(DD.Center())),\n        Y(5:7; sampling=DD.Intervals(DD.Center()))\nA = DimArray([1 2 3; 4 5 6], dims_)\nA[X(Contains(8)), Y(Contains(6.8))]\n\n# output\n3\n

    source

    # DimensionalData.Dimensions.LookupArrays.Where \u2014 Type.

    Where <: ArraySelector\n\nWhere(f::Function)\n

    Selector that filters a dimension lookup by any function that accepts a single value and returns a Bool.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(19:21)))\nA[X(Where(x -> x > 15)), Y(Where(x -> x in (19, 21)))]\n\n# output\n\n1\u00d72 DimArray{Int64,2} with dimensions:\n  X Sampled{Int64} Int64[20] ForwardOrdered Regular Points,\n  Y Sampled{Int64} Int64[19, 21] ForwardOrdered Regular Points\n     19  21\n 20   4   6\n

    source

    # DimensionalData.Dimensions.LookupArrays.All \u2014 Type.

    All <: Selector\n\nAll(selectors::Selector...)\n

    Selector that combines the results of other selectors. The indices used will be the union of all result sorted in ascending order.

    Example

    using DimensionalData, Unitful\n\ndimz = X(10.0:20:200.0), Ti(1u\"s\":5u\"s\":100u\"s\")\nA = DimArray((1:10) * (1:20)', dimz)\nA[X=All(At(10.0), At(50.0)), Ti=All(1u\"s\"..10u\"s\", 90u\"s\"..100u\"s\")]\n\n# output\n\n2\u00d74 DimArray{Int64,2} with dimensions:\n  X Sampled{Float64} Float64[10.0, 50.0] ForwardOrdered Regular Points,\n  Ti Sampled{Quantity{Int64, \ud835\udc13, Unitful.FreeUnits{(s,), \ud835\udc13, nothing}}} Quantity{Int64, \ud835\udc13, Unitful.FreeUnits{(s,), \ud835\udc13, nothing}}[1 s, 6 s, 91 s, 96 s] ForwardOrdered Regular Points\n       1 s  6 s  91 s  96 s\n 10.0    1    2    19    20\n 50.0    3    6    57    60\n

    source

    Lookup properties:

    # DimensionalData.Dimensions.LookupArrays.bounds \u2014 Function.

    bounds(xs, [dims::Tuple]) => Tuple{Vararg{Tuple{T,T}}}\nbounds(xs::Tuple) => Tuple{Vararg{Tuple{T,T}}}\nbounds(x, dim) => Tuple{T,T}\nbounds(dim::Union{Dimension,LookupArray}) => Tuple{T,T}\n

    Return the bounds of all dimensions of an object, of a specific dimension, or of a tuple of dimensions.

    If bounds are not known, one or both values may be nothing.

    dims can be a Dimension, a dimension type, or a tuple of either.

    source

    # DimensionalData.Dimensions.LookupArrays.val \u2014 Function.

    val(x)\nval(dims::Tuple) => Tuple\n

    Return the contained value of a wrapper object.

    dims can be Dimension, Dimension types, or Symbols for Dim{Symbol}.

    Objects that don't define a val method are returned unaltered.

    source

    # DimensionalData.Dimensions.LookupArrays.LookupArray \u2014 Type.

    LookupArray\n

    Types defining the behaviour of a lookup index, how it is plotted and how Selectors like Between work.

    A LookupArray may be NoLookup indicating that the index is just the underlying array axis, Categorical for ordered or unordered categories, or a Sampled index for Points or Intervals.

    source

    # DimensionalData.Dimensions.LookupArrays.Aligned \u2014 Type.

    Aligned <: LookupArray\n

    Abstract supertype for LookupArrays where the index is aligned with the array axes.

    This is by far the most common supertype for LookupArray.

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractSampled \u2014 Type.

    AbstractSampled <: Aligned\n

    Abstract supertype for LookupArrays where the index is aligned with the array, and is independent of other dimensions. Sampled is provided by this package.

    AbstractSampled must have order, span and sampling fields, or a rebuild method that accpts them as keyword arguments.

    source

    # DimensionalData.Dimensions.LookupArrays.Sampled \u2014 Type.

    Sampled <: AbstractSampled\n\nSampled(data::AbstractVector, order::Order, span::Span, sampling::Sampling, metadata)\nSampled(data=AutoIndex(); order=AutoOrder(), span=AutoSpan(), sampling=Points(), metadata=NoMetadata())\n

    A concrete implementation of the LookupArray AbstractSampled. It can be used to represent Points or Intervals.

    Sampled is capable of representing gridded data from a wide range of sources, allowing correct bounds and Selectors for points or intervals of regular, irregular, forward and reverse indexes.

    On AbstractDimArray construction, Sampled lookup is assigned for all lookups of AbstractRange not assigned to Categorical.

    Arguments

    • data: An AbstractVector of index values, matching the length of the curresponding array axis.
    • order: Order) indicating the order of the index, AutoOrder by default, detected from the order of data to be ForwardOrdered, ReverseOrdered or Unordered. These can be provided explicitly if they are known and performance is important.
    • span: indicates the size of intervals or distance between points, and will be set to Regular for AbstractRange and Irregular for AbstractArray, unless assigned manually.
    • sampling: is assigned to Points, unless set to Intervals manually. Using Intervals will change the behaviour of bounds and Selectorss to take account for the full size of the interval, rather than the point alone.
    • metadata: a Dict or Metadata wrapper that holds any metadata object adding more information about the array axis - useful for extending DimensionalData for specific contexts, like geospatial data in GeoData.jl. By default it is NoMetadata().

    Example

    Create an array with [Interval] sampling, and Regular span for a vector with known spacing.

    We set the Locus of the Intervals to Start specifying that the index values are for the positions at the start of each interval.

    using DimensionalData, DimensionalData.LookupArrays\n\nx = X(Sampled(100:-20:10; sampling=Intervals(Start())))\ny = Y(Sampled([1, 4, 7, 10]; span=Regular(3), sampling=Intervals(Start())))\nA = ones(x, y)\n\n# output\n5\u00d74 DimArray{Float64,2} with dimensions:\n  X Sampled{Int64} 100:-20:20 ReverseOrdered Regular Intervals,\n  Y Sampled{Int64} Int64[1, 4, 7, 10] ForwardOrdered Regular Intervals\n      1    4    7    10\n 100  1.0  1.0  1.0   1.0\n  80  1.0  1.0  1.0   1.0\n  60  1.0  1.0  1.0   1.0\n  40  1.0  1.0  1.0   1.0\n  20  1.0  1.0  1.0   1.0\n

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractCyclic \u2014 Type.

    AbstractCyclic <: AbstractSampled end\n

    An abstract supertype for cyclic lookups.

    These are AbstractSampled lookups that are cyclic for Selectors.

    source

    # DimensionalData.Dimensions.LookupArrays.Cyclic \u2014 Type.

    Cyclic <: AbstractCyclic\n\nCyclic(data; order=AutoOrder(), span=AutoSpan(), sampling=Points(), metadata=NoMetadata(), cycle)\n

    A Cyclic lookup is similar to Sampled but out of range Selectors At, Near, Contains will cycle the values to typemin or typemax over the length of cycle. Where and .. work as for Sampled.

    This is useful when we are using mean annual datasets over a real time-span, or for wrapping longitudes so that -360 and 360 are the same.

    Arguments

    • data: An AbstractVector of index values, matching the length of the curresponding array axis.
    • order: Order) indicating the order of the index, AutoOrder by default, detected from the order of data to be ForwardOrdered, ReverseOrdered or Unordered. These can be provided explicitly if they are known and performance is important.
    • span: indicates the size of intervals or distance between points, and will be set to Regular for AbstractRange and Irregular for AbstractArray, unless assigned manually.
    • sampling: is assigned to Points, unless set to Intervals manually. Using Intervals will change the behaviour of bounds and Selectorss to take account for the full size of the interval, rather than the point alone.
    • metadata: a Dict or Metadata wrapper that holds any metadata object adding more information about the array axis - useful for extending DimensionalData for specific contexts, like geospatial data in GeoData.jl. By default it is NoMetadata().
    • cycle: the length of the cycle. This does not have to exactly match the data, the step size is Week(1) the cycle can be Years(1).

    Notes

    1. If you use dates and e.g. cycle over a Year, every year will have the number and spacing of Weeks and Days as the cycle year. Using At may not be reliable in terms of exact dates, as it will be applied to the specified date plus or minus n years.
    2. Indexing into a Cycled with any AbstractArray or AbstractRange will return a Sampled as the full cycle is likely no longer available.
    3. .. or Between selectors do not work in a cycled way: they work as for Sampled. This may change in future to return cycled values, but there are problems with this, such as leap years breaking correct date cycling of a single year. If you actually need this behaviour, please make a GitHub issue.

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractCategorical \u2014 Type.

    AbstractCategorical <: Aligned\n

    LookupArrays where the values are categories.

    Categorical is the provided concrete implementation. but this can easily be extended - all methods are defined for AbstractCategorical.

    All AbstractCategorical must provide a rebuild method with data, order and metadata keyword arguments.

    source

    # DimensionalData.Dimensions.LookupArrays.Categorical \u2014 Type.

    Categorical <: AbstractCategorical\n\nCategorical(o::Order)\nCategorical(; order=Unordered())\n

    An LookupArray where the values are categories.

    This will be automatically assigned if the index contains AbstractString, Symbol or Char. Otherwise it can be assigned manually.

    Order will be determined automatically where possible.

    Arguments

    • data: An AbstractVector of index values, matching the length of the curresponding array axis.
    • order: Order) indicating the order of the index, AutoOrder by default, detected from the order of data to be ForwardOrdered, ReverseOrdered or Unordered. Can be provided if this is known and performance is important.
    • metadata: a Dict or Metadata wrapper that holds any metadata object adding more information about the array axis - useful for extending DimensionalData for specific contexts, like geospatial data in GeoData.jl. By default it is NoMetadata().

    Example

    Create an array with [Interval] sampling.

    using DimensionalData\n\nds = X([\"one\", \"two\", \"three\"]), Y([:a, :b, :c, :d])\nA = DimArray(rand(3, 4), ds)\nDimensions.lookup(A)\n\n# output\n\nCategorical{String} String[\"one\", \"two\", \"three\"] Unordered,\nCategorical{Symbol} Symbol[:a, :b, :c, :d] ForwardOrdered\n

    source

    # DimensionalData.Dimensions.LookupArrays.Unaligned \u2014 Type.

    Unaligned <: LookupArray\n

    Abstract supertype for LookupArray where the index is not aligned to the grid.

    Indexing an Unaligned with Selectors must provide all other Unaligned dimensions.

    source

    # DimensionalData.Dimensions.LookupArrays.Transformed \u2014 Type.

    Transformed <: Unaligned\n\nTransformed(f, dim::Dimension; metadata=NoMetadata())\n

    LookupArray that uses an affine transformation to convert dimensions from dims(lookup) to dims(array). This can be useful when the dimensions are e.g. rotated from a more commonly used axis.

    Any function can be used to do the transformation, but transformations from CoordinateTransformations.jl may be useful.

    Arguments

    • f: transformation function
    • dim: a dimension to transform to.

    Keyword Arguments

    • metdata:

    Example

    using DimensionalData, DimensionalData.LookupArrays, CoordinateTransformations\n\nm = LinearMap([0.5 0.0; 0.0 0.5])\nA = [1 2  3  4\n     5 6  7  8\n     9 10 11 12];\nda = DimArray(A, (t1=Transformed(m, X), t2=Transformed(m, Y)))\n\nda[X(At(6)), Y(At(2))]\n\n# output\n9\n

    source

    # DimensionalData.Dimensions.MergedLookup \u2014 Type.

    MergedLookup <: LookupArray\n\nMergedLookup(data, dims; [metadata])\n

    A LookupArray that holds multiple combined dimensions.

    MergedLookup can be indexed with Selectors like At, Between, and Where although Near has undefined meaning.

    Arguments

    • data: A Vector of Tuple.
    • dims: A Tuple of Dimension indicating the dimensions in the tuples in data.

    Keywords

    • metadata: a Dict or Metadata object to attach dimension metadata.

    source

    # DimensionalData.Dimensions.LookupArrays.NoLookup \u2014 Type.

    NoLookup <: LookupArray\n\nNoLookup()\n

    A LookupArray that is identical to the array axis. Selectors can't be used on this lookup.

    Example

    Defining a DimArray without passing an index to the dimensions, it will be assigned NoLookup:

    using DimensionalData\n\nA = DimArray(rand(3, 3), (X, Y))\nDimensions.lookup(A)\n\n# output\n\nNoLookup, NoLookup\n

    Which is identical to:

    using .LookupArrays\nA = DimArray(rand(3, 3), (X(NoLookup()), Y(NoLookup())))\nDimensions.lookup(A)\n\n# output\n\nNoLookup, NoLookup\n

    source

    # DimensionalData.Dimensions.LookupArrays.AutoLookup \u2014 Type.

    AutoLookup <: LookupArray\n\nAutoLookup()\nAutoLookup(index=AutoIndex(); kw...)\n

    Automatic LookupArray, the default lookup. It will be converted automatically to another LookupArray when it is possible to detect it from the index.

    Keywords will be used in the detected LookupArray constructor.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoIndex \u2014 Type.

    AutoIndex\n

    Detect a LookupArray index from the context. This is used in NoLookup to simply use the array axis as the index when the array is constructed, and in set to change the LookupArray type without changing the index values.

    source

    "},{"location":"reference/#metadata","title":"Metadata","text":"

    # DimensionalData.Dimensions.LookupArrays.AbstractMetadata \u2014 Type.

    AbstractMetadata{X,T}\n

    Abstract supertype for all metadata wrappers.

    Metadata wrappers allow tracking the contents and origin of metadata. This can facilitate conversion between metadata types (for saving a file to a differenet format) or simply saving data back to the same file type with identical metadata.

    Using a wrapper instead of Dict or NamedTuple also lets us pass metadata objects to set without ambiguity about where to put them.

    source

    # DimensionalData.Dimensions.LookupArrays.Metadata \u2014 Type.

    Metadata <: AbstractMetadata\n\nMetadata{X}(val::Union{Dict,NamedTuple})\nMetadata{X}(pairs::Pair...) => Metadata{Dict}\nMetadata{X}(; kw...) => Metadata{NamedTuple}\n

    General Metadata object. The X type parameter categorises the metadata for method dispatch, if required.

    source

    # DimensionalData.Dimensions.LookupArrays.NoMetadata \u2014 Type.

    NoMetadata <: AbstractMetadata\n\nNoMetadata()\n

    Indicates an object has no metadata. But unlike using nothing, get, keys and haskey will still work on it, get always returning the fallback argument. keys returns () while haskey always returns false.

    source

    "},{"location":"reference/#lookuparray-traits","title":"LookupArray traits","text":"

    # DimensionalData.Dimensions.LookupArrays.LookupArrayTrait \u2014 Type.

    LookupArrayTrait\n

    Abstract supertype of all traits of a LookupArray.

    These modify the behaviour of the lookup index.

    The term \"Trait\" is used loosely - these may be fields of an object of traits hard-coded to specific types.

    source

    "},{"location":"reference/#order","title":"Order","text":"

    # DimensionalData.Dimensions.LookupArrays.Order \u2014 Type.

    Order <: LookupArrayTrait\n

    Traits for the order of a LookupArray. These determine how searchsorted finds values in the index, and how objects are plotted.

    source

    # DimensionalData.Dimensions.LookupArrays.Ordered \u2014 Type.

    Ordered <: Order\n

    Supertype for the order of an ordered LookupArray, including ForwardOrdered and ReverseOrdered.

    source

    # DimensionalData.Dimensions.LookupArrays.ForwardOrdered \u2014 Type.

    ForwardOrdered <: Ordered\n\nForwardOrdered()\n

    Indicates that the LookupArray index is in the normal forward order.

    source

    # DimensionalData.Dimensions.LookupArrays.ReverseOrdered \u2014 Type.

    ReverseOrdered <: Ordered\n\nReverseOrdered()\n

    Indicates that the LookupArray index is in the reverse order.

    source

    # DimensionalData.Dimensions.LookupArrays.Unordered \u2014 Type.

    Unordered <: Order\n\nUnordered()\n

    Indicates that LookupArray is unordered.

    This means the index cannot be searched with searchsortedfirst or similar optimised methods - instead it will use findfirst.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoOrder \u2014 Type.

    AutoOrder <: Order\n\nAutoOrder()\n

    Specifies that the Order of a LookupArray will be found automatically where possible.

    source

    "},{"location":"reference/#span","title":"Span","text":"

    # DimensionalData.Dimensions.LookupArrays.Span \u2014 Type.

    Span <: LookupArrayTrait\n

    Defines the type of span used in a Sampling index. These are Regular or Irregular.

    source

    # DimensionalData.Dimensions.LookupArrays.Regular \u2014 Type.

    Regular <: Span\n\nRegular(step=AutoStep())\n

    Points or Intervals that have a fixed, regular step.

    source

    # DimensionalData.Dimensions.LookupArrays.Irregular \u2014 Type.

    Irregular <: Span\n\nIrregular(bounds::Tuple)\nIrregular(lowerbound, upperbound)\n

    Points or Intervals that have an Irrigular step size. To enable bounds tracking and accuract selectors, the starting bounds are provided as a 2 tuple, or 2 arguments. (nothing, nothing) is acceptable input, the bounds will be guessed from the index, but may be innaccurate.

    source

    # DimensionalData.Dimensions.LookupArrays.Explicit \u2014 Type.

    Explicit(bounds::AbstractMatix)\n

    Intervals where the span is explicitly listed for every interval.

    This uses a matrix where with length 2 columns for each index value, holding the lower and upper bounds for that specific index.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoSpan \u2014 Type.

    AutoSpan <: Span\n\nAutoSpan()\n

    The span will be guessed and replaced in format or set.

    source

    "},{"location":"reference/#sampling","title":"Sampling","text":"

    # DimensionalData.Dimensions.LookupArrays.Sampling \u2014 Type.

    Sampling <: LookupArrayTrait\n

    Indicates the sampling method used by the index: Points or Intervals.

    source

    # DimensionalData.Dimensions.LookupArrays.Points \u2014 Type.

    Points <: Sampling\n\nPoints()\n

    Sampling lookup where single samples at exact points.

    These are always plotted at the center of array cells.

    source

    # DimensionalData.Dimensions.LookupArrays.Intervals \u2014 Type.

    Intervals <: Sampling\n\nIntervals(locus::Locus)\n

    Sampling specifying that sampled values are the mean (or similar) value over an interval, rather than at one specific point.

    Intervals require a Locus of Start, Center or End to define the location in the interval that the index values refer to.

    source

    "},{"location":"reference/#loci","title":"Loci","text":"

    # DimensionalData.Dimensions.LookupArrays.Locus \u2014 Type.

    Locus <: LookupArrayTrait

    Abstract supertype of types that indicate the position of index values where they represent Intervals.

    These allow for values array cells to align with the Start, Center, or End of values in the lookup index.

    This means they can be plotted with correct axis markers, and allows automatic converrsions to between formats with different standards (such as NetCDF and GeoTiff).

    source

    # DimensionalData.Dimensions.LookupArrays.Center \u2014 Type.

    Center <: Locus\n\nCenter()\n

    Indicates a lookup value is for the center of its corresponding array cell.

    source

    # DimensionalData.Dimensions.LookupArrays.Start \u2014 Type.

    Start <: Locus\n\nStart()\n

    Indicates a lookup value is for the start of its corresponding array cell, in the direction of the lookup index order.

    source

    # DimensionalData.Dimensions.LookupArrays.End \u2014 Type.

    End <: Locus\n\nEnd()\n

    Indicates a lookup value is for the end of its corresponding array cell, in the direction of the lookup index order.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoLocus \u2014 Type.

    AutoLocus <: Locus\n\nAutoLocus()\n

    Indicates a interval where the index position is not yet known. This will be filled with a default value on object construction.

    source

    "},{"location":"reference/#lookuparrays-methods","title":"LookupArrays methods","text":"

    # DimensionalData.Dimensions.LookupArrays.hasselection \u2014 Function.

    hasselection(x, selector) => Bool\nhasselection(x, selectors::Tuple) => Bool\n

    Check if indexing into x with selectors can be performed, where x is some object with a dims method, and selectors is a Selector or Dimension or a tuple of either.

    source

    # DimensionalData.Dimensions.LookupArrays.shiftlocus \u2014 Function.

    shiftlocus(locus::Locus, x)\n

    Shift the index of x from the current locus to the new locus.

    We only shift Sampled, Regular or Explicit, Intervals.

    source

    # DimensionalData.Dimensions.LookupArrays.sampling \u2014 Function.

    sampling(x, [dims::Tuple]) => Tuple\nsampling(x, dim) => Sampling\nsampling(xs::Tuple) => Tuple{Vararg{Sampling}}\nsampling(x:Union{Dimension,LookupArray}) => Sampling\n

    Return the Sampling for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.span \u2014 Function.

    span(x, [dims::Tuple]) => Tuple\nspan(x, dim) => Span\nspan(xs::Tuple) => Tuple{Vararg{Span,N}}\nspan(x::Union{Dimension,LookupArray}) => Span\n

    Return the Span for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.order \u2014 Function.

    order(x, [dims::Tuple]) => Tuple\norder(xs::Tuple) => Tuple\norder(x::Union{Dimension,LookupArray}) => Order\n

    Return the Ordering of the dimension index for each dimension: ForwardOrdered, ReverseOrdered, or Unordered

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.index \u2014 Function.

    index(x) => Tuple{Vararg{AbstractArray}}\nindex(x, dims::Tuple) => Tuple{Vararg{AbstractArray}}\nindex(dims::Tuple) => Tuple{Vararg{AbstractArray}}}\nindex(x, dim) => AbstractArray\nindex(dim::Dimension) => AbstractArray\n

    Return the contained index of a Dimension.

    Only valid when a Dimension contains an AbstractArray or a Val tuple like Val{(:a, :b)}(). The Val is unwrapped to return just the Tuple

    dims can be a Dimension, or a tuple of Dimension.

    source

    # DimensionalData.Dimensions.LookupArrays.locus \u2014 Function.

    locus(x, [dims::Tuple]) => Tuple\nlocus(x, dim) => Locus\nlocus(xs::Tuple) => Tuple{Vararg{Locus,N}}\nlocus(x::Union{Dimension,LookupArray}) => Locus\n

    Return the Locus for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.units \u2014 Function.

    units(x) => Union{Nothing,Any}\nunits(xs:Tuple) => Tuple\nunit(A::AbstractDimArray, dims::Tuple) => Tuple\nunit(A::AbstractDimArray, dim) => Union{Nothing,Any}\n

    Get the units of an array or Dimension, or a tuple of of either.

    Units do not have a set field, and may or may not be included in metadata. This method is to facilitate use in labels and plots when units are available, not a guarantee that they will be. If not available, nothing is returned.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    "},{"location":"reference/#name","title":"Name","text":"

    # DimensionalData.AbstractName \u2014 Type.

    AbstractName\n

    Abstract supertype for name wrappers.

    source

    # DimensionalData.Name \u2014 Type.

    Name <: AbstractName\n\nName(name::Union{Symbol,Name) => Name\nName(name::NoName) => NoName\n

    Name wrapper. This lets arrays keep symbol names when the array wrapper neeeds to be `isbits, like for use on GPUs. It makes the name a property of the type. It's not necessary to use in normal use, a symbol is probably easier.

    source

    # DimensionalData.NoName \u2014 Type.

    NoName <: AbstractName\n\nNoName()\n

    NoName specifies an array is not named, and is the default name value for all AbstractDimArrays.

    source

    "},{"location":"crash/generated/course/course/","title":"Crash course","text":"
    using DimensionalData\n
    "},{"location":"crash/generated/course/course/#dimensions-and-dimarrays","title":"Dimensions and DimArrays","text":"

    The core type of DimensionalData.jl is the Dimension and the types that inherit from it, such as Ti, X, Y, Z, the generic Dim{:x}, or others that you define manually using the @dim macro.

    Dimensions are primarily used in DimArray, other AbstractDimArray.

    We can use dimensions without a value index - these simply label the axis. A DimArray with labelled dimensions is constructed by:

    using DimensionalData\nA = rand(X(5), Y(5))\n
    5\u00d75 DimArray{Float64,2} with dimensions: X, Y\n 0.311551   0.456841  0.721526  0.435496   0.407604\n 0.0314271  0.910207  0.833412  0.254205   0.245365\n 0.337067   0.136774  0.221974  0.0167196  0.433512\n 0.571846   0.867841  0.996957  0.0487373  0.0929695\n 0.230113   0.135144  0.780989  0.528185   0.29594\n

    get value

    A[Y(1), X(2)]\n
    0.03142706241854176\n

    As shown above, Dimensions can be used to construct arrays in rand, ones, zeros and fill with either a range for a lookup index or a number for the dimension length.

    Or we can use the Dim{X} dims by using Symbols, and indexing with keywords:

    A = DimArray(rand(5, 5), (:a, :b))\n
    5\u00d75 DimArray{Float64,2} with dimensions: Dim{:a}, Dim{:b}\n 0.682815  0.850178  0.760162  0.17839    0.126447\n 0.783886  0.181768  0.874999  0.275593   0.362856\n 0.609333  0.7653    0.3663    0.377261   0.717694\n 0.356301  0.579718  0.354531  0.713865   0.471926\n 0.339224  0.746804  0.107938  0.0799614  0.766145\n

    get value

    A[a=3, b=5]\n
    0.71769367324973\n

    Often, we want to provide a lookup index for the dimension:

    using Dates\nt = DateTime(2001):Month(1):DateTime(2001,12)\nx = 10:10:100\nA = rand(X(x), Ti(t))\n
    10\u00d712 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 10:10:100 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-12-01T00:00:00\") ForwardOrdered Regular Points\n       2001-01-01T00:00:00  \u2026   2001-12-01T00:00:00\n  10  0.671345                             0.323025\n  20  0.0639875                            0.718253\n  30  0.351877                             0.837483\n  40  0.682487                             0.820954\n  50  0.769756                          \u2026  0.0477008\n  60  0.108969                             0.524176\n  70  0.136808                             0.593108\n  80  0.54007                              0.070707\n  90  0.342106                             0.117203\n 100  0.381094                          \u2026  0.0281335\n

    Here both X and Ti are dimensions from DimensionalData. The currently exported dimensions are X, Y, Z, Ti (Ti is shortening of Time).

    The length of each dimension index has to match the size of the corresponding array axis.

    This can also be done with Symbol, using Dim{X}:

    A2 = DimArray(rand(12, 10), (time=t, distance=x))\n
    12\u00d710 DimArray{Float64,2} with dimensions: \n  Dim{:time} Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-12-01T00:00:00\") ForwardOrdered Regular Points,\n  Dim{:distance} Sampled{Int64} 10:10:100 ForwardOrdered Regular Points\n                                   \u2026  80           90         100\n  2001-01-01T00:00:00      0.00971342   0.562502    0.609121\n  2001-02-01T00:00:00      0.838984     0.75164     0.801973\n  2001-03-01T00:00:00      0.619199     0.937823    0.900711\n  2001-04-01T00:00:00      0.770603     0.707126    0.60753\n  2001-05-01T00:00:00  \u2026   0.00159321   0.788161    0.907038\n  2001-06-01T00:00:00      0.690368     0.746431    0.354156\n  2001-07-01T00:00:00      0.0718767    0.50853     0.419419\n  2001-08-01T00:00:00      0.485233     0.818955    0.746544\n  2001-09-01T00:00:00      0.502876     0.784225    0.652392\n  2001-10-01T00:00:00  \u2026   0.0748758    0.614539    0.943011\n  2001-11-01T00:00:00      0.300063     0.356417    0.134969\n  2001-12-01T00:00:00      0.506552     0.935332    0.409229\n

    Symbols can be more convenient to use than defining custom dims with @dim, but have some downsides. They don't inherit from a specific Dimension type, so plots will not know what axis to put them on. They also cannot use the basic constructor methods like rand or zeros, as we cannot dispatch on Symbol for Base methods without \"type-piracy\".

    "},{"location":"crash/generated/course/course/#indexing-the-array-by-name-and-index","title":"Indexing the array by name and index","text":"

    Dimensions can be used to index the array by name, without having to worry about the order of the dimensions.

    The simplest case is to select a dimension by index. Let's say every 2nd point of the Ti dimension and every 3rd point of the X dimension. This is done with the simple Ti(range) syntax like so:

    A[X(1:3:11), Ti(1:2:11)]\n
    4\u00d76 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(2):DateTime(\"2001-11-01T00:00:00\") ForwardOrdered Regular Points\n       2001-01-01T00:00:00  \u2026   2001-11-01T00:00:00\n  10  0.671345                             0.565462\n  40  0.682487                             0.316966\n  70  0.136808                             0.550636\n 100  0.381094                             0.476372\n

    When specifying only one dimension, all elements of the other dimensions are assumed to be included:

    A[X(1:3:10)]\n
    4\u00d712 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-12-01T00:00:00\") ForwardOrdered Regular Points\n       2001-01-01T00:00:00  \u2026   2001-12-01T00:00:00\n  10  0.671345                             0.323025\n  40  0.682487                             0.820954\n  70  0.136808                             0.593108\n 100  0.381094                             0.0281335\n

    Indexing

    Indexing AbstractDimArrays works with getindex, setindex! and view. The result is still an AbstracDimArray, unless using all single Int or Selectors that resolve to Int.

    Dimensions can be used to construct arrays in rand, ones, zeros and fill with either a range for a lookup index or a number for the dimension length.

    using DimensionalData\nA1 = ones(X(1:40), Y(50))\n
    40\u00d750 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 1:40 ForwardOrdered Regular Points,\n  Y\n  1  1.0  1.0  1.0  1.0  1.0  1.0  1.0  \u2026  1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  2  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  3  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  4  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  5  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  6  1.0  1.0  1.0  1.0  1.0  1.0  1.0  \u2026  1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  \u22ee                      \u22ee              \u22f1  \u22ee                        \u22ee    \n 35  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 36  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 37  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 38  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 39  1.0  1.0  1.0  1.0  1.0  1.0  1.0  \u2026  1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 40  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n

    We can also use dim wrappers for indexing, so that the dimension order in the underlying array does not need to be known:

    A1[Y(1), X(1:10)]\n
    10-element DimArray{Float64,1} with dimensions: \n  X Sampled{Int64} 1:10 ForwardOrdered Regular Points\nand reference dimensions: Y\n  1  1.0\n  2  1.0\n  3  1.0\n  4  1.0\n  5  1.0\n  6  1.0\n  7  1.0\n  8  1.0\n  9  1.0\n 10  1.0\n

    "},{"location":"crash/generated/course/course/#indexing-performance","title":"Indexing Performance","text":"

    Indexing with Dimension has no runtime cost:

    A2 = ones(X(3), Y(3))\n
    3\u00d73 DimArray{Float64,2} with dimensions: X, Y\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n

    time ?

    using BenchmarkTools\n\nprintln(@btime $A2[X(1), Y(2)])\n
      43.799 ns (0 allocations: 0 bytes)\n1.0\n

    and

    println(@btime parent($A2)[1, 2])\n
      3.406 ns (0 allocations: 0 bytes)\n1.0\n

    "},{"location":"crash/generated/course/course/#specifying-dims-keyword-arguments-with-dimension","title":"Specifying dims keyword arguments with Dimension","text":"

    In many Julia functions like size or sum, you can specify the dimension along which to perform the operation as an Int. It is also possible to do this using Dimension types with AbstractDimArray:

    A3 = rand(X(3), Y(4), Ti(5));\nsum(A3; dims=Ti)\n
    3\u00d74\u00d71 DimArray{Float64,3} with dimensions: X, Y, Ti\n[:, :, 1]\n 1.73331  2.92759  2.49549  2.30835\n 2.13014  1.54409  3.02662  3.02718\n 1.95383  3.24542  1.89865  3.37258\n

    This also works in methods from Statistics:

    using Statistics\nmean(A3; dims=Ti)\n
    3\u00d74\u00d71 DimArray{Float64,3} with dimensions: X, Y, Ti\n[:, :, 1]\n 0.346663  0.585519  0.499099  0.46167\n 0.426028  0.308819  0.605325  0.605436\n 0.390765  0.649085  0.379729  0.674515\n

    "},{"location":"crash/generated/course/course/#methods-where-dims-dim-types-or-symbols-can-be-used-to-indicate-the-array-dimension","title":"Methods where dims, dim types, or Symbols can be used to indicate the array dimension:","text":"
    • size, axes, firstindex, lastindex
    • cat, reverse, dropdims
    • reduce, mapreduce
    • sum, prod, maximum, minimum,
    • mean, median, extrema, std, var, cor, cov
    • permutedims, adjoint, transpose, Transpose
    • mapslices, eachslice
    "},{"location":"crash/generated/course/course/#lookuparrays-and-selectors","title":"LookupArrays and Selectors","text":"

    Indexing by value in DimensionalData is done with Selectors. IntervalSets.jl is now used for selecting ranges of values (formerly Between).

    Selector Description At(x) get the index exactly matching the passed in value(s) Near(x) get the closest index to the passed in value(s) Contains(x) get indices where the value x falls within an interval Where(f) filter the array axis by a function of the dimension index values. [Not(x)] get all indices not selected by x, which can be another selector. [a..b] get all indices between two values, inclusively. [OpenInterval(a, b)] get all indices between a and b, exclusively. [Interval{A,B}(a, b)] get all indices between a and b, as :closed or :open.

    Selectors find indices in the LookupArray, for each dimension. Here we use an Interval to select a range between integers and DateTime:

    A[X(12..35), Ti(Date(2001, 5)..Date(2001, 7))]\n
    2\u00d73 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 20:10:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-05-01T00:00:00\"):Month(1):DateTime(\"2001-07-01T00:00:00\") ForwardOrdered Regular Points\n      2001-05-01T00:00:00  \u2026   2001-07-01T00:00:00\n 20  0.652854                             0.609298\n 30  0.795113                             0.700076\n

    To select intervals in DimArrays (e.g. A2) you need to specify dimname=a .. b:

    A2[distance=12 .. 35, time=Date(2001, 5) .. Date(2001, 7)]\n
    3\u00d73 DimArray{Float64,2} with dimensions: X, Y\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n

    Selectors can be used in getindex, setindex! and view to select indices matching the passed in value(s)

    We can use selectors inside dim wrappers, here selecting values from DateTime and Int:

    using Dates\ntimespan = DateTime(2001,1):Month(1):DateTime(2001,12)\nA4 = rand(Ti(timespan), X(10:10:100))\nA4[X(Near(35)), Ti(At(DateTime(2001,5)))]\n
    0.27463208325575683\n

    Without dim wrappers selectors must be in the right order, and specify all axes:

    using Unitful\nA5 = rand(Y((1:10:100)u\"m\"), Ti((1:5:100)u\"s\"));\nA5[10.5u\"m\" .. 50.5u\"m\", Near(23u\"s\")]\n
    4-element DimArray{Float64,1} with dimensions: \n  Y Sampled{Quantity{Int64, \ud835\udc0b, Unitful.FreeUnits{(m,), \ud835\udc0b, nothing}}} (11:10:41) m ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{Quantity{Int64, \ud835\udc13, Unitful.FreeUnits{(s,), \ud835\udc13, nothing}}} (21:5:21) s ForwardOrdered Regular Points\n 11 m  0.382984\n 21 m  0.63463\n 31 m  0.360448\n 41 m  0.867114\n

    We can also use Linear indices as in standard Array:

    A5[1:5]\n
    5-element Vector{Float64}:\n 0.24277448211977626\n 0.2243311093335526\n 0.32511774209530075\n 0.2550241019905538\n 0.4235163791944876\n

    But unless the DimArray is one dimensional, this will return a regular Array. It is not possible to keep the LookupArray or even Dimensions after linear indexing is used.

    "},{"location":"crash/generated/course/course/#lookuparrays-and-traits","title":"LookupArrays and traits","text":"

    Using a regular range or Vector as a lookup index has a number of downsides. We cannot use searchsorted for fast searches without knowing the order of the array, and this is slow to compute at runtime. It also means reverse or rotations cannot be used while keeping the DimArray wrapper.

    Step sizes are also a problem. Some ranges like LinRange lose their step size with a length of 1. Often, instead of a range, multi-dimensional data formats provide a Vector of evenly spaced values for a lookup, with a step size specified separately. Converting to a range introduces floating point errors that means points may not be selected with At without setting tolerances.

    This means using a lookup wrapper with traits is more generally robust and versatile than simply using a range or vector. DimensionalData provides types for specifying details about the dimension index, in the LookupArrays sub-module:

    using DimensionalData\nusing .LookupArrays\n

    The main LookupArray are :

    • Sampled
    • Categorical,
    • NoLookup

    Each comes with specific traits that are either fixed or variable, depending on the contained index. These enable optimisations with Selectors, and modified behaviours, such as:

    1. Selection of Intervals or Points, which will give slightly

    different results for selectors like .. - as whole intervals are selected, and have different bounds values.

    1. Tracking of lookup order. A reverse order is labelled ReverseOrdered and

    will still work with searchsorted, and for plots to always be the right way up when either the index or the array is backwards. Reversing a DimArray will reverse the LookupArray for that dimension, swapping ReverseOrdered to ForwardOrdered.

    1. Sampled Intervals can have index located at a Locus of:

    2. Start,

    3. Center
    4. End

    Which specifies the point of the interval represented in the index, to match different data standards, e.g. GeoTIFF (Start) and NetCDF (Center).

    1. A Span specifies the gap between Points or the size of

    Intervals. This may be:

    • Regular, in the case of a range and equally spaced vector,
    • Irregular for unequally spaced vectors
    • Explicit for the case where all interval start and end points are specified explicitly - as is common in the NetCDF standard.

    These traits all for subtypes of Aligned.

    Unaligned also exists to handle dimensions with an index that is rotated or otherwise transformed in relation to the underlying array, such as Transformed.

    "},{"location":"crash/generated/course/course/#lookuparray-detection","title":"LookupArray detection","text":"

    Aligned types will be detected automatically if not specified - which usually isn't required.

    • An empty Dimension or a Type or Symbol will be assigned NoLookup - this behaves as a simple named dimension without a lookup index.
    • A Dimension containing and index of String, Char, Symbol or mixed types will be given the Categorical mode,
    • A range will be assigned Sampled, defaulting to Regular, Points
    • Other AbstractVector will be assigned Sampled Irregular Points.

    In all cases the Order of ForwardOrdered or ReverseOrdered will be be detected, otherwise Unordered for an unsorted Array.

    See the LookupArray API docs for more detail.

    "},{"location":"crash/generated/course/course/#referenced-dimensions","title":"Referenced dimensions","text":"

    The reference dimensions record the previous dimensions that an array was selected from. These can be use for plot labelling, and tracking array changes so that cat can reconstruct the lookup array from previous dimensions that have been sliced.

    "},{"location":"crash/generated/course/course/#warnings","title":"Warnings","text":"

    Indexing with unordered or reverse-ordered arrays has undefined behaviour. It will trash the dimension index, break searchsorted and nothing will make sense any more. So do it at you own risk.

    However, indexing with sorted vectors of Int can be useful, so it's allowed. But it may do strange things to interval sizes for Intervals that are not Explicit.

    This selects the first 5 entries of the underlying array. In the case that A has only one dimension, it will be retained. Multidimensional AbstracDimArray indexed this way will return a regular array.

    This page was generated using Literate.jl.

    "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#dimensionaldata","title":"DimensionalData","text":"

    DimensionalData.jl provides tools and abstractions for working with datasets that have named dimensions, and optionally a lookup index.

    DimensionalData is a pluggable, generalised version of AxisArrays.jl with a cleaner syntax, and additional functionality found in NamedDims.jl. It has similar goals to pythons xarray, and is primarily written for use with spatial data in Rasters.jl.

    "},{"location":"#goals","title":"Goals","text":"
    • Clean, readable syntax. Minimise required parentheses, minimise of exported
    • Zero-cost dimensional indexing a[Y(4), X(5)] of a single value. methods, and instead extend Base methods whenever possible.
    • Plotting is easy: data should plot sensibly and correctly with useful labels, by default.
    • Least surprise: everything works the same as in Base, but with named dims. If a method accepts numeric indices or dims=X in base, you should be able to use DimensionalData.jl dims.
    • Minimal interface: implementing a dimension-aware type should be easy.
    • Maximum extensibility: always use method dispatch. Regular types over special syntax. Recursion over @generated. Always dispatch on abstract types.
    • Type stability: dimensional methods should be type stable more often than Base methods
    • Functional style: structs are always rebuilt, and other than the array data, fields are not mutated in place.
    "},{"location":"#for-package-developers","title":"For package developers","text":""},{"location":"#data-types-and-the-interface","title":"Data types and the interface","text":"

    DimensionalData.jl provides the concrete DimArray type. But its behaviours are intended to be easily applied to other array types.

    more

    The main requirement for extending DimensionalData.jl is to define a dims method that returns a Tuple of Dimension that matches the dimension order and axis values of your data. Define rebuild and base methods for similar and parent if you want the metadata to persist through transformations (see the DimArray and AbstractDimArray types). A refdims method returns the lost dimensions of a previous transformation, passed in to the rebuild method. refdims can be discarded, the main loss being plot labels and ability to reconstruct dimensions in cat.

    Inheriting from AbstractDimArray in this way will give nearly all the functionality of using DimArray.

    "},{"location":"#lookuparrays-and-dimensions","title":"LookupArrays and Dimensions","text":"

    Sub modules LookupArrays and Dimensions define the behviour of dimensions and their lookup index.

    LookupArrays and Dimensions

    "},{"location":"reference/","title":"Reference","text":""},{"location":"reference/#api","title":"API","text":""},{"location":"reference/#arrays","title":"Arrays","text":"

    # DimensionalData.AbstractDimArray \u2014 Type.

    AbstractDimArray <: AbstractArray\n

    Abstract supertype for all \"dim\" arrays.

    These arrays return a Tuple of Dimension from a dims method, and can be rebuilt using rebuild.

    parent must return the source array.

    They should have metadata, name and refdims methods, although these are optional.

    A rebuild method for AbstractDimArray must accept data, dims, refdims, name, metadata arguments.

    Indexing AbstractDimArray with non-range AbstractArray has undefined effects on the Dimension index. Use forward-ordered arrays only\"

    source

    # DimensionalData.DimArray \u2014 Type.

    DimArray <: AbstractDimArray\n\nDimArray(data, dims, refdims, name, metadata)\nDimArray(data, dims::Tuple; refdims=(), name=NoName(), metadata=NoMetadata())\n

    The main concrete subtype of AbstractDimArray.

    DimArray maintains and updates its Dimensions through transformations and moves dimensions to reference dimension refdims after reducing operations (like e.g. mean).

    Arguments

    • data: An AbstractArray.
    • dims: A Tuple of Dimension
    • name: A string name for the array. Shows in plots and tables.
    • refdims: refence dimensions. Usually set programmatically to track past slices and reductions of dimension for labelling and reconstruction.
    • metadata: Dict or Metadata object, or NoMetadata()

    Indexing can be done with all regular indices, or with Dimensions and/or Selectors.

    Indexing AbstractDimArray with non-range AbstractArray has undefined effects on the Dimension index. Use forward-ordered arrays only\"

    Example:

    using Dates, DimensionalData\n\nti = (Ti(DateTime(2001):Month(1):DateTime(2001,12)),\nx = X(10:10:100))\nA = DimArray(rand(12,10), (ti, x), \"example\")\n\njulia> A[X(Near([12, 35])), Ti(At(DateTime(2001,5)))];\n\njulia> A[Near(DateTime(2001, 5, 4)), Between(20, 50)];\n

    source

    "},{"location":"reference/#multi-array-datasets","title":"Multi-array datasets","text":"

    # DimensionalData.AbstractDimStack \u2014 Type.

    AbstractDimStack\n

    Abstract supertype for dimensional stacks.

    These have multiple layers of data, but share dimensions.

    Notably, their behaviour lies somewhere between a DimArray and a NamedTuple:

    • indexing with a Symbol as in dimstack[:symbol] returns a DimArray layer.
    • iteration amd map are apply over array layers, as indexed with a Symbol.
    • getindex and many base methods are applied as for DimArray - to avoid the need to allways use map.

    This design gives very succinct code when working with many-layered, mixed-dimension objects. But it may be jarring initially - the most surprising outcome is that dimstack[1] will return a NamedTuple of values for the first index in all layers, while first(dimstack) will return the first value of the iterator - the DimArray for the first layer.

    See DimStack for the concrete implementation. Most methods are defined on the abstract type.

    To extend AbstractDimStack, implement argument and keyword version of rebuild and also rebuild_from_arrays.

    The constructor of an AbstractDimStack must accept a NamedTuple.

    source

    # DimensionalData.DimStack \u2014 Type.

    DimStack <: AbstractDimStack\n\nDimStack(data::AbstractDimArray...)\nDimStack(data::Tuple{Vararg{AbstractDimArray}})\nDimStack(data::NamedTuple{Keys,Vararg{AbstractDimArray}})\nDimStack(data::NamedTuple, dims::DimTuple; metadata=NoMetadata())\n

    DimStack holds multiple objects sharing some dimensions, in a NamedTuple.

    Notably, their behaviour lies somewhere between a DimArray and a NamedTuple:

    • indexing with a Symbol as in dimstack[:symbol] returns a DimArray layer.
    • iteration amd map are apply over array layers, as indexed with a Symbol.
    • getindex or view with Int, Dimensions or Selectors that resolve to Int will return a NamedTuple of values from each layer in the stack. This has very good performace, and avoids the need to always use map.
    • getindex or view with a Vector or Colon will return another DimStack where all data layers have been sliced.
    • setindex! must pass a Tuple or NamedTuple maching the layers.
    • many base and Statistics methods (sum, mean etc) will work as for a DimArray again removing the need to use map.

    For example, here we take the mean over the time dimension for all layers :

    mean(mydimstack; dims=Ti)\n

    And this equivalent to:

    map(A -> mean(A; dims=Ti), mydimstack)\n

    This design gives succinct code when working with many-layered, mixed-dimension objects.

    But it may be jarring initially - the most surprising outcome is that dimstack[1] will return a NamedTuple of values for the first index in all layers, while first(dimstack) will return the first value of the iterator - the DimArray for the first layer.

    DimStack can be constructed from multiple AbstractDimArray or a NamedTuple of AbstractArray and a matching dims tuple.

    Most Base and Statistics methods that apply to AbstractArray can be used on all layers of the stack simulataneously. The result is a DimStack, or a NamedTuple if methods like mean are used without dims arguments, and return a single non-array value.

    Example

    julia> using DimensionalData\n\njulia> A = [1.0 2.0 3.0; 4.0 5.0 6.0];\n\njulia> dimz = (X([:a, :b]), Y(10.0:10.0:30.0))\nX Symbol[:a, :b],\nY 10.0:10.0:30.0\n\njulia> da1 = DimArray(1A, dimz; name=:one);\n\njulia> da2 = DimArray(2A, dimz; name=:two);\n\njulia> da3 = DimArray(3A, dimz; name=:three);\n\njulia> s = DimStack(da1, da2, da3);\n\njulia> s[At(:b), At(10.0)]\n(one = 4.0, two = 8.0, three = 12.0)\n\njulia> s[X(At(:a))] isa DimStack\ntrue\n

    source

    "},{"location":"reference/#dimension-indices-generators","title":"Dimension indices generators","text":"

    # DimensionalData.DimIndices \u2014 Type.

    DimIndices <: AbstractArray\n\nDimIndices(x)\nDimIndices(dims::Tuple)\nDimIndices(dims::Dimension)\n

    Like CartesianIndices, but for Dimensions. Behaves as an Array of Tuple of Dimension(i) for all combinations of the axis indices of dims.

    This can be used to view/index into arbitrary dimensions over an array, and is especially useful when combined with otherdims, to iterate over the indices of unknown dimension.

    source

    # DimensionalData.DimKeys \u2014 Type.

    DimKeys <: AbstractArray\n\nDimKeys(x)\nDimKeys(dims::Tuple)\nDimKeys(dims::Dimension)\n

    Like CartesianIndices, but for the lookup values of Dimensions. Behaves as an Array of Tuple of Dimension(At(lookupvalue)) for all combinations of the lookup values of dims.

    source

    # DimensionalData.DimPoints \u2014 Type.

    DimPoints <: AbstractArray\n\nDimPoints(x; order)\nDimPoints(dims::Tuple; order)\nDimPoints(dims::Dimension; order)\n

    Like CartesianIndices, but for the point values of the dimension index. Behaves as an Array of Tuple lookup values (whatever they are) for all combinations of the lookup values of dims.

    Either a Dimension, a Tuple of Dimension or an object that defines a dims method can be passed in.

    Keywords

    • order: determines the order of the points, the same as the order of dims by default.

    source

    "},{"location":"reference/#tablesjltabletraitsjl-interface","title":"Tables.jl/TableTraits.jl interface","text":"

    # DimensionalData.AbstractDimTable \u2014 Type.

    AbstractDimTable <: Tables.AbstractColumns\n

    Abstract supertype for dim tables

    source

    # DimensionalData.DimTable \u2014 Type.

    DimTable <: AbstractDimTable\n\nDimTable(s::AbstractDimStack; mergedims=nothing)\nDimTable(x::AbstractDimArray; layersfrom=nothing, mergedims=nothing)\nDimTable(xs::Vararg{AbstractDimArray}; layernames=nothing, mergedims=nothing)\n

    Construct a Tables.jl/TableTraits.jl compatible object out of an AbstractDimArray or AbstractDimStack.

    This table will have columns for the array data and columns for each Dimension index, as a [DimColumn]. These are lazy, and generated as required.

    Column names are converted from the dimension types using DimensionalData.dim2key. This means type Ti becomes the column name :Ti, and Dim{:custom} becomes :custom.

    To get dimension columns, you can index with Dimension (X()) or Dimension type (X) as well as the regular Int or Symbol.

    Keywords

    • mergedims: Combine two or more dimensions into a new dimension.
    • layersfrom: Treat a dimension of an AbstractDimArray as layers of an AbstractDimStack.

    Example

    julia> a = DimArray(rand(32,32,3), (X,Y,Dim{:band}));\n\njulia> DimTable(a, layersfrom=Dim{:band}, mergedims=(X,Y)=>:geometry)\nDimTable with 1024 rows, 4 columns, and schema:\n :geometry  Tuple{Int64, Int64}\n :band_1    Float64\n :band_2    Float64\n :band_3    Float64\n

    source

    # DimensionalData.DimColumn \u2014 Type.

    DimColumn{T,D<:Dimension} <: AbstractVector{T}\n\nDimColumn(dim::Dimension, dims::Tuple{Vararg{DimTuple}})\nDimColumn(dim::DimColumn, length::Int, dimstride::Int)\n

    A table column based on a Dimension and it's relationship with other Dimensions in dims.

    length is the product of all dim lengths (usually the length of the corresponding array data), while stride is the product of the preceding dimension lengths, which may or may not be the real stride of the corresponding array depending on the data type. For A isa Array, the dimstride will match the stride.

    When the second argument is a Tuple of Dimension, the length and dimstride fields are calculated from the dimensions, relative to the column dimension dim.

    This object will be returned as a column of DimTable.

    source

    "},{"location":"reference/#common-methods","title":"Common methods","text":"

    Common functions for obtaining information from objects:

    # DimensionalData.Dimensions.dims \u2014 Function.

    dims(x, [dims::Tuple]) => Tuple{Vararg{Dimension}}\ndims(x, dim) => Dimension\n

    Return a tuple of Dimensions for an object, in the order that matches the axes or columns of the underlying data.

    dims can be Dimension, Dimension types, or Symbols for Dim{Symbol}.

    The default is to return nothing.

    source

    # DimensionalData.Dimensions.refdims \u2014 Function.

    refdims(x, [dims::Tuple]) => Tuple{Vararg{Dimension}}\nrefdims(x, dim) => Dimension\n

    Reference dimensions for an array that is a slice or view of another array with more dimensions.

    slicedims(a, dims) returns a tuple containing the current new dimensions and the new reference dimensions. Refdims can be stored in a field or disgarded, as it is mostly to give context to plots. Ignoring refdims will simply leave some captions empty.

    The default is to return an empty Tuple ().

    source

    # DimensionalData.Dimensions.LookupArrays.metadata \u2014 Function.

    metadata(x) => (object metadata)\nmetadata(x, dims::Tuple)  => Tuple (Dimension metadata)\nmetadata(xs::Tuple) => Tuple\n

    Returns the metadata for an object or for the specified dimension(s)

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.name \u2014 Function.

    name(x) => Symbol\nname(xs:Tuple) => NTuple{N,Symbol}\nname(x, dims::Tuple) => NTuple{N,Symbol}\nname(x, dim) => Symbol\n

    Get the name of an array or Dimension, or a tuple of of either as a Symbol.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    Utility methods for transforming DimensionalData objects:

    # DimensionalData.Dimensions.LookupArrays.set \u2014 Function.

    set(x, val)\nset(x, args::Pairs...) => x with updated field/s\nset(x, args...; kw...) => x with updated field/s\nset(x, args::Tuple{Vararg{Dimension}}; kw...) => x with updated field/s\n\nset(dim::Dimension, index::AbstractArray) => Dimension\nset(dim::Dimension, lookup::LookupArray) => Dimension\nset(dim::Dimension, lookupcomponent::LookupArrayTrait) => Dimension\nset(dim::Dimension, metadata::AbstractMetadata) => Dimension\n

    Set the properties of an object, its internal data or the traits of its dimensions and lookup index.

    As DimensionalData is so strongly typed you do not need to specify what field of a LookupArray to set - there is no ambiguity.

    To set fields of a LookupArray you need to specify the dimension. This can be done using X => val pairs, X = val keyword arguments, or X(val) wrapped arguments.

    When a Dimension or LookupArray is passed to set to replace the existing ones, fields that are not set will keep their original values.

    Notes:

    Changing a lookup index range/vector will also update the step size and order where applicable.

    Setting the Order like ForwardOrdered will not reverse the array or dimension to match. Use reverse and reorder to do this.

    Examples

    julia> using DimensionalData; const DD = DimensionalData\nDimensionalData\n\njulia> da = DimArray(zeros(3, 4), (custom=10.0:010.0:30.0, Z=-20:010.0:10.0));\n\njulia> set(da, ones(3, 4))\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Regular Points,\n  Z Sampled{Float64} -20.0:10.0:10.0 ForwardOrdered Regular Points\n       -20.0  -10.0  0.0  10.0\n 10.0    1.0    1.0  1.0   1.0\n 20.0    1.0    1.0  1.0   1.0\n 30.0    1.0    1.0  1.0   1.0 \n

    Change the Dimension wrapper type:

    julia> set(da, :Z => Ti, :custom => Z)\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Z Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Regular Points,\n  Ti Sampled{Float64} -20.0:10.0:10.0 ForwardOrdered Regular Points\n       -20.0  -10.0  0.0  10.0\n 10.0    0.0    0.0  0.0   0.0\n 20.0    0.0    0.0  0.0   0.0\n 30.0    0.0    0.0  0.0   0.0 \n

    Change the lookup Vector:

    julia> set(da, Z => [:a, :b, :c, :d], :custom => [4, 5, 6])\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Int64} Int64[4, 5, 6] ForwardOrdered Regular Points,\n  Z Sampled{Symbol} Symbol[:a, :b, :c, :d] ForwardOrdered Regular Points\n     :a   :b   :c   :d\n 4  0.0  0.0  0.0  0.0\n 5  0.0  0.0  0.0  0.0\n 6  0.0  0.0  0.0  0.0\n

    Change the LookupArray type:

    julia> set(da, Z=DD.NoLookup(), custom=DD.Sampled())\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Regular Points,\n  Z\n 10.0  0.0  0.0  0.0  0.0\n 20.0  0.0  0.0  0.0  0.0\n 30.0  0.0  0.0  0.0  0.0\n

    Change the Sampling trait:

    julia> set(da, :custom => DD.Irregular(10, 12), Z => DD.Regular(9.9))\n3\u00d74 DimArray{Float64,2} with dimensions:\n  Dim{:custom} Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Irregular Points,\n  Z Sampled{Float64} -20.0:10.0:10.0 ForwardOrdered Regular Points\n       -20.0  -10.0  0.0  10.0\n 10.0    0.0    0.0  0.0   0.0\n 20.0    0.0    0.0  0.0   0.0\n 30.0    0.0    0.0  0.0   0.0\n

    source

    # DimensionalData.Dimensions.LookupArrays.rebuild \u2014 Function.

    rebuild(x, args...)\nrebuild(x; kw...)\n

    Rebuild an object struct with updated field values.

    x can be a AbstractDimArray, a Dimension, LookupArray or other custom types.

    This is an abstraction that alows inbuilt and custom types to be rebuilt to update their fields, as most objects in DimensionalData.jl are immutable.

    The arguments version can be concise but depends on a fixed order defined for some DimensionalData objects. It should be defined based on the object type in DimensionalData, adding the fields specific to your object.

    The keyword version ignores order, and is mostly automated using ConstructionBase.setproperties. It should only be defined if your object has missing fields or fields with different names to DimensionalData objects.

    The arguments required are defined for the abstract type that has a rebuild method.

    source

    # DimensionalData.modify \u2014 Function.

    modify(f, A::AbstractDimArray) => AbstractDimArray\nmodify(f, s::AbstractDimStack) => AbstractDimStack\nmodify(f, dim::Dimension) => Dimension\nmodify(f, x, lookupdim::Dimension) => typeof(x)\n

    Modify the parent data, rebuilding the object wrapper without change. f must return a AbstractArray of the same size as the original.

    This method is mostly useful as a way of swapping the parent array type of an object.

    Example

    If we have a previously-defined DimArray, we can copy it to an Nvidia GPU with:

    A = DimArray(rand(100, 100), (X, Y))\nmodify(CuArray, A)\n

    This also works for all the data layers in a DimStack.

    source

    # DimensionalData.broadcast_dims \u2014 Function.

    broadcast_dims(f, sources::AbstractDimArray...) => AbstractDimArray\n

    Broadcast function f over the AbstractDimArrays in sources, permuting and reshaping dimensions to match where required. The result will contain all the dimensions in all passed in arrays in the order in which they are found.

    Arguments

    • sources: AbstractDimArrays to broadcast over with f.

    This is like broadcasting over every slice of A if it is sliced by the dimensions of B.

    source

    # DimensionalData.broadcast_dims! \u2014 Function.

    broadcast_dims!(f, dest::AbstractDimArray, sources::AbstractDimArray...) => dest\n

    Broadcast function f over the AbstractDimArrays in sources, writing to dest. sources are permuting and reshaping dimensions to match where required.

    The result will contain all the dimensions in all passed in arrays, in the order in which they are found.

    Arguments

    • dest: AbstractDimArray to update.
    • sources: AbstractDimArrays to broadcast over with f.

    source

    # DimensionalData.mergedims \u2014 Function.

    mergedims(old_dims => new_dim) => Dimension\n

    Return a dimension new_dim whose indices are a MergedLookup of the indices of old_dims.

    source

    mergedims(dims, old_dims => new_dim, others::Pair...) => dims_new\n

    If dimensions old_dims, new_dim, etc. are found in dims, then return new dims_new where all dims in old_dims have been combined into a single dim new_dim. The returned dimension will keep only the name of new_dim. Its coords will be a MergedLookup of the coords of the dims in old_dims. New dimensions are always placed at the end of dims_new. others contains other dimension pairs to be merged.

    Example

    julia> ds = (X(0:0.1:0.4), Y(10:10:100), Ti([0, 3, 4]));\njulia> mergedims(ds, Ti => :time, (X, Y) => :space)\nDim{:time} MergedLookup{Tuple{Int64}} Tuple{Int64}[(0,), (3,), (4,)] Ti,\nDim{:space} MergedLookup{Tuple{Float64, Int64}} Tuple{Float64, Int64}[(0.0, 10), (0.1, 10), \u2026, (0.3, 100), (0.4, 100)] X, Y\n

    source

    mergedims(A::AbstractDimArray, dim_pairs::Pair...) => AbstractDimArray\nmergedims(A::AbstractDimStack, dim_pairs::Pair...) => AbstractDimStack\n

    Return a new array or stack whose dimensions are the result of mergedims(dims(A), dim_pairs).

    source

    # DimensionalData.unmergedims \u2014 Function.

    unmergedims(merged_dims::Tuple{Vararg{Dimension}}) => Tuple{Vararg{Dimension}}\n

    Return the unmerged dimensions from a tuple of merged dimensions. However, the order of the original dimensions are not necessarily preserved.

    source

    unmergedims(A::AbstractDimArray, original_dims) => AbstractDimArray\nunmergedims(A::AbstractDimStack, original_dims) => AbstractDimStack\n

    Return a new array or stack whose dimensions are restored to their original prior to calling mergedims(A, dim_pairs).

    source

    # DimensionalData.reorder \u2014 Function.

    reorder(A::Union{AbstractDimArray,AbstractDimStack}, order::Pair...)\nreorder(A::Union{AbstractDimArray,AbstractDimStack}, order)\nreorder(A::Dimension, order::Order)\n

    Reorder every dims index/array to order, or reorder index for the the given dimension(s) in order.

    order can be an Order, Dimension => Order pairs. A Tuple of Dimensions or any object that defines dims can be used in which case dimensions are

    If no axis reversal is required the same objects will be returned, without allocation.

    Example

    **Create a DimArray**\n\nda = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(300:-100:100)))\n\n**Reverse it**\n\nrev = reverse(da, dims=Y)\n\n**using `da` in reorder will return it to the original order**\n\nreorder(rev, da) == da\n\n**output**\n\ntrue\n\n\n<a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/880be4ed77668862150c04ba270acc22fb134cca/src/utils.jl#L2-L27' class='documenter-source'>source</a><br>\n\n<a id='Base.cat' href='#Base.cat'>#</a>\n**`Base.cat`** &mdash; *Function*.\n\n\n\n```julia\nBase.cat(stacks::AbstractDimStack...; [keys=keys(stacks[1])], dims)\n

    Concatenate all or a subset of layers for all passed in stacks.

    Keywords

    • keys: Tuple of Symbol for the stack keys to concatenate.
    • dims: Dimension of child array to concatenate on.

    Example

    Concatenate the :seasurfacetemp and :humidity layers in the time dimension:

    cat(stacks...; keys=(:sea_surface_temp, :humidity), dims=Ti)\n

    source

    # Base.map \u2014 Function.

    Base.map(f, stacks::AbstractDimStack...)\n

    Apply function f to each layer of the stacks.

    If f returns DimArrays the result will be another DimStack. Other values will be returned in a NamedTuple.

    source

    # Base.copy! \u2014 Function.

    Base.copy!(dst::AbstractArray, src::AbstractGimStack, key::Key)\n

    Copy the stack layer key to dst, which can be any AbstractArray.

    Example

    Copy the :humidity layer from stack to array.

    copy!(array, stack, :humidity)\n

    source

    Base.copy!(dst::AbstractDimStack, src::AbstractDimStack, [keys=keys(dst)])\n

    Copy all or a subset of layers from one stack to another.

    Example

    Copy just the :sea_surface_temp and :humidity layers from src to dst.

    copy!(dst::AbstractDimStack, src::AbstractDimStack, keys=(:sea_surface_temp, :humidity))\n

    source

    # Base.eachslice \u2014 Function.

    Base.eachslice(stack::AbstractDimStack; dims)\n

    Create a generator that iterates over dimensions dims of stack, returning stacks that select all the data from the other dimensions in stack using views.

    The generator has size and axes equivalent to those of the provided dims.

    Examples

    julia> ds = DimStack((\n           x=DimArray(randn(2, 3, 4), (X([:x1, :x2]), Y(1:3), Z)),\n           y=DimArray(randn(2, 3, 5), (X([:x1, :x2]), Y(1:3), Ti))\n       ));\n\njulia> slices = eachslice(ds; dims=(Z, X));\n\njulia> size(slices)\n(4, 2)\n\njulia> map(dims, axes(slices))\nZ,\nX Categorical{Symbol} Symbol[x1, x2] ForwardOrdered\n\njulia> first(slices)\nDimStack with dimensions:\n  Y Sampled{Int64} 1:3 ForwardOrdered Regular Points,\n  Ti\nand 2 layers:\n  :x Float64 dims: Y (3)\n  :y Float64 dims: Y, Ti (3\u00d75)\n

    source

    Most base methods work as expected, using Dimension wherever a dims keyword is used. They are not allspecifically documented here.

    Shorthand constructors:

    # Base.fill \u2014 Function.

    Base.fill(x, dims::Dimension...; kw...) => DimArray\nBase.fill(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\n

    Create a DimArray with a fill value of x.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    ```@doctest julia> using DimensionalData

    julia> rand(Bool, X(2), Y(4)) 2\u00d74 DimArray{Bool,2} with dimensions: X, Y 1 0 0 1 1 0 1 1

    <a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/880be4ed77668862150c04ba270acc22fb134cca/src/array/array.jl#L409-L432' class='documenter-source'>source</a><br>\n\n<a id='Base.rand' href='#Base.rand'>#</a>\n**`Base.rand`** &mdash; *Function*.\n\n\n\n```julia\nBase.rand(x, dims::Dimension...; kw...) => DimArray\nBase.rand(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\nBase.rand(r::AbstractRNG, x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\nBase.rand(r::AbstractRNG, x, dims::Dimension...; kw...) => DimArray\n

    Create a DimArray of random values.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    julia> using DimensionalData\n\njulia> rand(Bool, X(2), Y(4))\n2\u00d74 DimArray{Bool,2} with dimensions: X, Y\n 1  0  0  1\n 1  0  1  1\n\njulia> rand(X([:a, :b, :c]), Y(100.0:50:200.0))\n3\u00d73 DimArray{Float64,2} with dimensions:\n  X: Symbol[a, b, c] Categorical: Unordered,\n  Y: 100.0:50.0:200.0 Sampled: Ordered Regular Points\n 0.43204   0.835111  0.624231\n 0.752868  0.471638  0.193652\n 0.484558  0.846559  0.455256\n

    source

    # Base.zeros \u2014 Function.

    Base.zeros(x, dims::Dimension...; kw...) => DimArray\nBase.zeros(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\n

    Create a DimArray of zeros.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    ```@doctest julia> using DimensionalData

    julia> zeros(Bool, X(2), Y(4)) 2\u00d74 DimArray{Bool,2} with dimensions: X, Y 0 0 0 0 0 0 0 0

    julia> zeros(X([:a, :b, :c]), Y(100.0:50:200.0)) 3\u00d73 DimArray{Float64,2} with dimensions: X: Symbol[a, b, c] Categorical: Unordered, Y: 100.0:50.0:200.0 Sampled: Ordered Regular Points 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

    <a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/880be4ed77668862150c04ba270acc22fb134cca/src/array/array.jl#L472-L504' class='documenter-source'>source</a><br>\n\n<a id='Base.ones' href='#Base.ones'>#</a>\n**`Base.ones`** &mdash; *Function*.\n\n\n\n```julia\nBase.ones(x, dims::Dimension...; kw...) => DimArray\nBase.ones(x, dims::Tuple{Vararg{Dimension}}; kw...) => DimArray\n

    Create a DimArray of ones.

    There are two kinds of Dimension value acepted:

    • A Dimension holding an AbstractVector will set the dimension index to that AbstractVector, and detect the dimension lookup.
    • A Dimension holding an Integer will set the length of the axis, and set the dimension lookup to NoLookup.

    Keywords are the same as for DimArray.

    Example

    ```@doctest julia> using DimensionalData

    julia> ones(Bool, X(2), Y(4)) 2\u00d74 DimArray{Bool,2} with dimensions: X, Y 1 1 1 1 1 1 1 1

    julia> ones(X([:a, :b, :c]), Y(100.0:50:200.0)) 3\u00d73 DimArray{Float64,2} with dimensions: X: Symbol[a, b, c] Categorical: Unordered, Y: 100.0:50.0:200.0 Sampled: Ordered Regular Points 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0

    <a target='_blank' href='https://github.com/rafaqz/DimensionalData.jl/blob/880be4ed77668862150c04ba270acc22fb134cca/src/array/array.jl#L507-L539' class='documenter-source'>source</a><br>\n\n\n<a id='Dimensions'></a>\n\n<a id='Dimensions-1'></a>\n\n# Dimensions\n\n\nHandling of Dimensions is kept in a sub-module `Dimensions`.\n\n<a id='DimensionalData.Dimensions' href='#DimensionalData.Dimensions'>#</a>\n**`DimensionalData.Dimensions`** &mdash; *Module*.\n\n\n\nDimensions\n\nSub-module for [`Dimension`](reference.md#DimensionalData.Dimensions.Dimension)s wrappers, and operations on them used in DimensionalData.jl.\n\nTo load `Dimensions` types and methods into scope:\n\n```julia\nusing DimensionalData\nusing DimensionalData.Dimensions\n

    source

    Dimensions have a type-heirarchy that organises plotting and dimension matching.

    # DimensionalData.Dimensions.Dimension \u2014 Type.

    Dimension\n

    Abstract supertype of all dimension types.

    Example concrete implementations are X, Y, Z, Ti (Time), and the custom [Dim]@ref) dimension.

    Dimensions label the axes of an AbstractDimArray, or other dimensional objects, and are used to index into the array.

    They may also provide an alternate index to lookup for each array axis. This may be any AbstractVector matching the array axis length, or a Val holding a tuple for compile-time index lookups.

    Dimensions also have lookup and metadata fields.

    lookup gives more details about the dimension, such as that it is Categorical or Sampled as Points or Intervals along some transect. DimensionalData will attempt to guess the lookup from the passed-in index value.

    Example:

    using DimensionalData, Dates\n\nx = X(2:2:10)\ny = Y(['a', 'b', 'c'])\nti = Ti(DateTime(2021, 1):Month(1):DateTime(2021, 12))\n\nA = DimArray(zeros(3, 5, 12), (y, x, ti))\n\n# output\n\n3\u00d75\u00d712 DimArray{Float64,3} with dimensions:\n  Y Categorical{Char} Char['a', 'b', 'c'] ForwardOrdered,\n  X Sampled{Int64} 2:2:10 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2021-01-01T00:00:00\"):Month(1):DateTime(\"2021-12-01T00:00:00\") ForwardOrdered Regular Points\n[:, :, 1]\n       2    4    6    8    10\n  'a'  0.0  0.0  0.0  0.0   0.0\n  'b'  0.0  0.0  0.0  0.0   0.0\n  'c'  0.0  0.0  0.0  0.0   0.0\n[and 11 more slices...]\n

    For simplicity, the same Dimension types are also used as wrappers in getindex, like:

    x = A[X(2), Y(3)]\n\n# output\n\n12-element DimArray{Float64,1} with dimensions:\n  Ti Sampled{DateTime} DateTime(\"2021-01-01T00:00:00\"):Month(1):DateTime(\"2021-12-01T00:00:00\") ForwardOrdered Regular Points\nand reference dimensions:\n  Y Categorical{Char} Char['c'] ForwardOrdered,\n  X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points\n 2021-01-01T00:00:00  0.0\n 2021-02-01T00:00:00  0.0\n 2021-03-01T00:00:00  0.0\n 2021-04-01T00:00:00  0.0\n \u22ee\n 2021-10-01T00:00:00  0.0\n 2021-11-01T00:00:00  0.0\n 2021-12-01T00:00:00  0.0\n

    A Dimension can also wrap Selector.

    x = A[X(Between(3, 4)), Y(At('b'))]\n\n# output\n\n1\u00d712 DimArray{Float64,2} with dimensions:\n  X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2021-01-01T00:00:00\"):Month(1):DateTime(\"2021-12-01T00:00:00\") ForwardOrdered Regular Points\nand reference dimensions:\n  Y Categorical{Char} Char['b'] ForwardOrdered\n     2021-01-01T00:00:00  \u2026   2021-12-01T00:00:00\n 4  0.0                                  0.0\n

    Dimension objects may have lookup and metadata fields to track additional information about the data and the index, and their relationship.

    source

    # DimensionalData.Dimensions.DependentDim \u2014 Type.

    DependentDim <: Dimension\n

    Abstract supertype for Dependent dimensions. These will plot on the Y axis.

    source

    # DimensionalData.Dimensions.IndependentDim \u2014 Type.

    IndependentDim <: Dimension\n

    Abstract supertype for independent dimensions. Thise will plot on the X axis.

    source

    # DimensionalData.Dimensions.XDim \u2014 Type.

    XDim <: IndependentDim\n

    Abstract supertype for all X dimensions.

    source

    # DimensionalData.Dimensions.YDim \u2014 Type.

    YDim <: DependentDim\n

    Abstract supertype for all Y dimensions.

    source

    # DimensionalData.Dimensions.ZDim \u2014 Type.

    ZDim <: DependentDim\n

    Abstract supertype for all Z dimensions.

    source

    # DimensionalData.Dimensions.TimeDim \u2014 Type.

    TimeDim <: IndependentDim\n

    Abstract supertype for all time dimensions.

    In a TimeDime with Interval sampling the locus will automatically be set to Start(). Dates and times generally refer to the start of a month, hour, second etc., not the central point as is more common with spatial data. `

    source

    # DimensionalData.Dimensions.X \u2014 Type.

    X <: XDim\n\nX(val=:)\n

    X Dimension. X <: XDim <: IndependentDim

    Example:

    xdim = X(2:2:10)\n# Or\nval = A[X(1)]\n# Or\nmean(A; dims=X)\n

    source

    # DimensionalData.Dimensions.Y \u2014 Type.

    Y <: YDim\n\nY(val=:)\n

    Y Dimension. Y <: YDim <: DependentDim

    Example:

    ydim = Y(['a', 'b', 'c'])\n# Or\nval = A[Y(1)]\n# Or\nmean(A; dims=Y)\n

    source

    # DimensionalData.Dimensions.Z \u2014 Type.

    Z <: ZDim\n\nZ(val=:)\n

    Z Dimension. Z <: ZDim <: Dimension

    Example:

    zdim = Z(10:10:100)\n# Or\nval = A[Z(1)]\n# Or\nmean(A; dims=Z)\n

    source

    # DimensionalData.Dimensions.Ti \u2014 Type.

    m Ti <: TimeDim

    Ti(val=:)\n

    Time Dimension. Ti <: TimeDim <: IndependentDim

    Time is already used by Dates, and T is a common type parameter, We use Ti to avoid clashes.

    Example:

    timedim = Ti(DateTime(2021, 1):Month(1):DateTime(2021, 12))\n# Or\nval = A[Ti(1)]\n# Or\nmean(A; dims=Ti)\n

    source

    # DimensionalData.Dimensions.Dim \u2014 Type.

    Dim{S}(val=:)\n

    A generic dimension. For use when custom dims are required when loading data from a file. Can be used as keyword arguments for indexing.

    Dimension types take precedence over same named Dim types when indexing with symbols, or e.g. creating Tables.jl keys.

    using DimensionalData\n\ndim = Dim{:custom}(['a', 'b', 'c'])\n\n# output\n\nDim{:custom} Char['a', 'b', 'c']\n

    source

    # DimensionalData.Dimensions.Coord \u2014 Type.

    Coord <: Dimension\n

    A coordinate dimension itself holds dimensions.

    This allows combining point data with other dimensions, such as time.

    Example

    julia> using DimensionalData\n\njulia> dim = Coord([(1.0,1.0,1.0), (1.0,2.0,2.0), (3.0,4.0,4.0), (1.0,3.0,4.0)], (X(), Y(), Z()))\nCoord ::\n  val: Tuple{Float64, Float64, Float64}[(1.0, 1.0, 1.0), (1.0, 2.0, 2.0), (3.0, 4.0, 4.0), (1.0, 3.0,\n4.0)]\n  lookup: MergedLookup\nCoord{Vector{Tuple{Float64, Float64, Float64}}, DimensionalData.MergedLookup{Tuple{X{Colon, AutoLookup{Auto\nOrder}, NoMetadata}, Y{Colon, AutoLookup{AutoOrder}, NoMetadata}, Z{Colon, AutoLookup{AutoOrder}, NoMetada\nta}}}, NoMetadata}\n\njulia> da = DimArray(0.1:0.1:0.4, dim)\n4-element DimArray{Float64,1} with dimensions:\n  Coord (): Tuple{Float64, Float64, Float64}[(1.0, 1.0, 1.0), (1.0, 2.0, 2.0), (3.0, 4.0, 4.0), (1.0,\n3.0, 4.0)]\n    MergedLookup\n 0.1\n 0.2\n 0.3\n 0.4\n\njulia> da[Coord(Z(At(1.0)), Y(Between(1, 3)))]\n1-element DimArray{Float64,1} with dimensions:\n  Coord (): Tuple{Float64, Float64, Float64}[(1.0, 1.0, 1.0)] MergedLookup\n 0.1\n\njulia> da[Coord(4)] == 0.4\ntrue\n\njulia> da[Coord(Between(1, 5), :, At(4.0))]\n2-element DimArray{Float64,1} with dimensions:\n  Coord (): Tuple{Float64, Float64, Float64}[(3.0, 4.0, 4.0), (1.0, 3.0, 4.0)] MergedLookup\n 0.3\n 0.4\n

    source

    # DimensionalData.Dimensions.AnonDim \u2014 Type.

    AnonDim <: Dimension\n\nAnonDim()\n

    Anonymous dimension. Used when extra dimensions are created, such as during transpose of a vector.

    source

    # DimensionalData.Dimensions.@dim \u2014 Macro.

    @dim typ [supertype=Dimension] [name::String=string(typ)]\n

    Macro to easily define new dimensions. The supertype will be inserted into the type of the dim. The default is simply YourDim <: Dimension. Making a Dimesion inherit from XDim, YDim, ZDim or TimeDim will affect automatic plot layout and other methods that dispatch on these types. <: YDim are plotted on the Y axis, <: XDim on the X axis, etc.

    Example:

    using DimensionalData\nusing DimensionalData: @dim, YDim, XDim\n@dim Lat YDim \"latitude\"\n@dim Lon XDim \"Longitude\"\n# output\n

    source

    "},{"location":"reference/#exported-methods","title":"Exported methods","text":"

    # DimensionalData.Dimensions.hasdim \u2014 Function.

    hasdim([f], x, query::Tuple) => NTUple{Bool}\nhasdim([f], x, query...) => NTUple{Bool}\nhasdim([f], x, query) => Bool\n

    Check if an object x has dimensions that match or inherit from the query dimensions.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension or a single Dimension.
    • query: Tuple or single Dimension or dimension Type.
    • f: <: by default, but can be >: to match abstract types to concrete types.

    Check if an object or tuple contains an Dimension, or a tuple of dimensions.

    Example

    julia> using DimensionalData\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> hasdim(A, X)\ntrue\n\njulia> hasdim(A, (Z, X, Y))\n(true, true, true)\n\njulia> hasdim(A, Ti)\nfalse\n

    source

    # DimensionalData.Dimensions.dimnum \u2014 Function.

    dimnum(x, query::Tuple) => NTuple{Int}\ndimnum(x, query) => Int\n

    Get the number(s) of Dimension(s) as ordered in the dimensions of an object.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension or a single Dimension.
    • query: Tuple, Array or single Dimension or dimension Type.

    The return type will be a Tuple of Int or a single Int, depending on wether query is a Tuple or single Dimension.

    Example

    julia> using DimensionalData\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> dimnum(A, (Z, X, Y))\n(3, 1, 2)\n\njulia> dimnum(A, Y)\n2\n

    source

    "},{"location":"reference/#non-exported-methods","title":"Non-exported methods","text":"

    # DimensionalData.Dimensions.lookup \u2014 Function.

    lookup(x::Dimension) => LookupArray\nlookup(x, [dims::Tuple]) => Tuple{Vararg{LookupArray}}\nlookup(x::Tuple) => Tuple{Vararg{LookupArray}}\nlookup(x, dim) => LookupArray\n

    Returns the LookupArray of a dimension. This dictates properties of the dimension such as array axis and index order, and sampling properties.

    dims can be a Dimension, a dimension type, or a tuple of either.

    source

    # DimensionalData.Dimensions.label \u2014 Function.

    label(x) => String\nlabel(x, dims::Tuple) => NTuple{N,String}\nlabel(x, dim) => String\nlabel(xs::Tuple) => NTuple{N,String}\n

    Get a plot label for data or a dimension. This will include the name and units if they exist, and anything else that should be shown on a plot.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.dim2key \u2014 Function.

    dim2key(dim::Dimension) => Symbol\ndim2key(dims::Type{<:Dimension}) => Symbol\ndim2key(dims::Tuple) => Tuple{Symbol,Vararg}\n

    Convert a dimension object to a simbol. X(), Y(), Ti() etc will be converted. to :X, :Y, :Ti, as with any other dims generated with the @dim macro.

    All other Dim{S}() dimensions will generate Symbols S.

    source

    # DimensionalData.Dimensions.key2dim \u2014 Function.

    key2dim(s::Symbol) => Dimension\nkey2dim(dims...) => Tuple{Dimension,Vararg}\nkey2dim(dims::Tuple) => Tuple{Dimension,Vararg}\n

    Convert a symbol to a dimension object. :X, :Y, :Ti etc will be converted. to X(), Y(), Ti(), as with any other dims generated with the @dim macro.

    All other Symbols S will generate Dim{S}() dimensions.

    source

    # DimensionalData.Dimensions.dims2indices \u2014 Function.

    dims2indices(dim::Dimension, I) => NTuple{Union{Colon,AbstractArray,Int}}\n

    Convert a Dimension or Selector I to indices of Int, AbstractArray or Colon.

    source

    # DimensionalData.Dimensions.LookupArrays.selectindices \u2014 Function.

    selectindices(lookups, selectors)\n

    Converts Selector to regular indices.

    source

    # DimensionalData.Dimensions.format \u2014 Function.

    format(dims, x) => Tuple{Vararg{Dimension,N}}\n

    Format the passed-in dimension(s) dims to match the object x.

    Errors are thrown if dims don't match the array dims or size, and any fields holding Auto- objects are filled with guessed objects.

    If a LookupArray hasn't been specified, a lookup is chosen based on the type and element type of the index.

    source

    # DimensionalData.Dimensions.reducedims \u2014 Function.

    reducedims(x, dimstoreduce) => Tuple{Vararg{Dimension}}\n

    Replace the specified dimensions with an index of length 1. This is usually to match a new array size where an axis has been reduced with a method like mean or reduce to a length of 1, but the number of dimensions has not changed.

    LookupArray traits are also updated to correspond to the change in cell step, sampling type and order.

    source

    # DimensionalData.Dimensions.swapdims \u2014 Function.

    swapdims(x::T, newdims) => T\nswapdims(dims::Tuple, newdims) => Tuple{Vararg{Dimension}}\n

    Swap dimensions for the passed in dimensions, in the order passed.

    Passing in the Dimension types rewraps the dimension index, keeping the index values and metadata, while constructed Dimension objectes replace the original dimension. nothing leaves the original dimension as-is.

    Arguments

    • x: any object with a dims method or a Tuple of Dimension.
    • newdim: Tuple of Dimension or dimension Type.

    Example

    using DimensionalData\nA = ones(X(2), Y(4), Z(2))\nDimensions.swapdims(A, (Dim{:a}, Dim{:b}, Dim{:c}))\n\n# output\n2\u00d74\u00d72 DimArray{Float64,3} with dimensions: Dim{:a}, Dim{:b}, Dim{:c}\n[:, :, 1]\n 1.0  1.0  1.0  1.0\n 1.0  1.0  1.0  1.0\n[and 1 more slices...]\n

    source

    # DimensionalData.Dimensions.slicedims \u2014 Function.

    slicedims(x, I) => Tuple{Tuple,Tuple}\nslicedims(f, x, I) => Tuple{Tuple,Tuple}\n

    Slice the dimensions to match the axis values of the new array.

    All methods return a tuple conatining two tuples: the new dimensions, and the reference dimensions. The ref dimensions are no longer used in the new struct but are useful to give context to plots.

    Called at the array level the returned tuple will also include the previous reference dims attached to the array.

    Arguments

    • f: a function getindex, view or dotview. This will be used for slicing getindex is the default if f is not included.
    • x: An AbstractDimArray, Tuple of Dimension, or Dimension
    • I: A tuple of Integer, Colon or AbstractArray

    source

    # DimensionalData.Dimensions.comparedims \u2014 Function.

    comparedims(A::AbstractDimArray...; kw...)\ncomparedims(A::Tuple...; kw...)\ncomparedims(A::Dimension...; kw...)\ncomparedims(::Type{Bool}, args...; kw...)\n

    Check that dimensions or tuples of dimensions passed as each argument are the same, and return the first valid dimension. If AbstractDimArrays are passed as arguments their dimensions are compared.

    Empty tuples and nothing dimension values are ignored, returning the Dimension value if it exists.

    Passing Bool as the first argument means true/false will be returned, rather than throwing an error.

    Keywords

    These are all Bool flags:

    • type: compare dimension type, true by default.
    • valtype: compare wrapped value type, false by default.
    • val: compare wrapped values, false by default.
    • order: compare order, false by default.
    • length: compare lengths, true by default.
    • ignore_length_one: ignore length 1 in comparisons, and return whichever dimension is not length 1, if any. This is useful in e.g. broadcasting comparisons. false by default.
    • warn: a String or nothing. Used only for Bool methods, to give a warning for false values and include warn in the warning text.

    source

    # DimensionalData.Dimensions.combinedims \u2014 Function.

    combinedims(xs; check=true)\n

    Combine the dimensions of each object in xs, in the order they are found.

    source

    # DimensionalData.Dimensions.otherdims \u2014 Function.

    otherdims(x, query) => Tuple{Vararg{Dimension,N}}\n

    Get the dimensions of an object not in query.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension.
    • query: Tuple or single Dimension or dimension Type.
    • f: <: by default, but can be >: to match abstract types to concrete types.

    A tuple holding the unmatched dimensions is always returned.

    Example

    julia> using DimensionalData, DimensionalData.Dimensions\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> otherdims(A, X)\nY, Z\n\njulia> otherdims(A, (Y, Z))\nX\n

    source

    # DimensionalData.Dimensions.commondims \u2014 Function.

    commondims([f], x, query) => Tuple{Vararg{Dimension}}\n

    This is basically dims(x, query) where the order of the original is kept, unlike dims where the query tuple determines the order

    Also unlike dims,commondims always returns a Tuple, no matter the input. No errors are thrown if dims are absent from either x or query.

    f is <: by default, but can be >: to sort abstract types by concrete types.

    julia> using DimensionalData, .Dimensions\n\njulia> A = DimArray(ones(10, 10, 10), (X, Y, Z));\n\njulia> commondims(A, X)\nX\n\njulia> commondims(A, (X, Z))\nX, Z\n\njulia> commondims(A, Ti)\n()\n

    source

    # DimensionalData.Dimensions.sortdims \u2014 Function.

    sortdims([f], tosort, order) => Tuple\n

    Sort dimensions tosort by order. Dimensions in order but missing from tosort are replaced with nothing.

    tosort and order can be Tuples or Vectors or Dimension or dimension type. Abstract supertypes like TimeDim can be used in order.

    f is <: by default, but can be >: to sort abstract types by concrete types.

    source

    # DimensionalData.Dimensions.LookupArrays.basetypeof \u2014 Function.

    basetypeof(x) => Type\n

    Get the \"base\" type of an object - the minimum required to define the object without it's fields. By default this is the full UnionAll for the type. But custom basetypeof methods can be defined for types with free type parameters.

    In DimensionalData this is primariliy used for comparing Dimensions, where Dim{:x} is different from Dim{:y}.

    source

    # DimensionalData.Dimensions.setdims \u2014 Function.

    setdims(X, newdims) => AbstractArray\nsetdims(::Tuple, newdims) => Tuple{Vararg{Dimension,N}}\n

    Replaces the first dim matching <: basetypeof(newdim) with newdim, and returns a new object or tuple with the dimension updated.

    Arguments

    • x: any object with a dims method, a Tuple of Dimension or a single Dimension.
    • newdim: Tuple or single Dimension, Type or Symbol.

    Example

    using DimensionalData, DimensionalData.Dimensions, DimensionalData.LookupArrays\nA = ones(X(10), Y(10:10:100))\nB = setdims(A, Y(Categorical('a':'j'; order=ForwardOrdered())))\nlookup(B, Y)\n# output\nCategorical{Char} ForwardOrdered\nwrapping: 'a':1:'j'\n

    source

    # DimensionalData.Dimensions.dimsmatch \u2014 Function.

    dimsmatch([f], dim, query) => Bool\ndimsmatch([f], dims::Tuple, query::Tuple) => Bool\n

    Compare 2 dimensions or Tuple of Dimension are of the same base type, or are at least rotations/transformations of the same type.

    f is <: by default, but can be >: to match abstract types to concrete types.

    source

    # DimensionalData.Dimensions.dimstride \u2014 Function.

    dimstride(x, dim) => Int\n

    Get the stride of the dimension relative to the other dimensions.

    This may or may not be equal to the stride of the related array, although it will be for Array.

    Arguments

    • x is any object with a dims method, or a Tuple of Dimension.
    • dim is a Dimension, Dimension type, or and Int. Using an Int is not type-stable.

    source

    # DimensionalData.refdims_title \u2014 Function.

    refdims_title(A::AbstractDimArray)\nrefdims_title(refdims::Tuple)\nrefdims_title(refdim::Dimension)\n

    Generate a title string based on reference dimension values.

    source

    # DimensionalData.rebuild_from_arrays \u2014 Function.

    rebuild_from_arrays(s::AbstractDimStack, das::NamedTuple{<:Any,<:Tuple{Vararg{AbstractDimArray}}}; kw...)\n

    Rebuild an AbstractDimStack from a Tuple or NamedTuple of AbstractDimArray and an existing stack.

    Keywords

    Keywords are simply the fields of the stack object:

    • data
    • dims
    • refdims
    • metadata
    • layerdims
    • layermetadata

    source

    "},{"location":"reference/#lookuparrays","title":"LookupArrays","text":"

    # DimensionalData.Dimensions.LookupArrays \u2014 Module.

    LookupArrays\n

    Module for LookupArrays and [Selector]s used in DimensionalData.jl

    LookupArrays defines traits and AbstractArray wrappers that give specific behaviours for a lookup index when indexed with Selector.

    For example, these allow tracking over array order so fast indexing works evne when the array is reversed.

    To load LookupArrays types and methods into scope:

    using DimensionalData\nusing DimensionalData.LookupArrays\n

    source

    "},{"location":"reference/#selectors","title":"Selectors","text":"

    # DimensionalData.Dimensions.LookupArrays.Selector \u2014 Type.

    Selector\n

    Abstract supertype for all selectors.

    Selectors are wrappers that indicate that passed values are not the array indices, but values to be selected from the dimension index, such as DateTime objects for a Ti dimension.

    Selectors provided in DimensionalData are:

    • At
    • Between
    • Touches
    • Near
    • Where
    • Contains

    source

    # DimensionalData.Dimensions.LookupArrays.IntSelector \u2014 Type.

    IntSelector <: Selector\n

    Abstract supertype for Selectors that return a single Int index.

    IntSelectors provided by DimensionalData are:

    • At
    • Contains
    • Near

    source

    # DimensionalData.Dimensions.LookupArrays.ArraySelector \u2014 Type.

    ArraySelector <: Selector\n

    Abstract supertype for Selectors that return an AbstractArray.

    ArraySelectors provided by DimensionalData are:

    • Between
    • Touches
    • Where

    source

    # DimensionalData.Dimensions.LookupArrays.At \u2014 Type.

    At <: IntSelector\n\nAt(x, atol, rtol)\nAt(x; atol=nothing, rtol=nothing)\n

    Selector that exactly matches the value on the passed-in dimensions, or throws an error. For ranges and arrays, every intermediate value must match an existing value - not just the end points.

    x can be any value or Vector of values.

    atol and rtol are passed to isapprox. For Number rtol will be set to Base.rtoldefault, otherwise nothing, and wont be used.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(At(20)), Y(At(6))]\n\n# output\n\n5\n

    source

    # DimensionalData.Dimensions.LookupArrays.Near \u2014 Type.

    Near <: IntSelector\n\nNear(x)\n

    Selector that selects the nearest index to x.

    With Points this is simply the index values nearest to the x, however with Intervals it is the interval center nearest to x. This will be offset from the index value for Start and End loci.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(Near(23)), Y(Near(5.1))]\n\n# output\n4\n

    source

    # DimensionalData.Dimensions.LookupArrays.Between \u2014 Type.

    Between <: ArraySelector\n\nBetween(a, b)\n

    Depreciated: use a..b instead of Between(a, b). Other Interval objects from IntervalSets.jl, like `OpenInterval(a, b) will also work, giving the correct open/closed boundaries.

    Between will e removed in furture to avoid clashes with DataFrames.Between.

    Selector that retreive all indices located between 2 values, evaluated with >= for the lower value, and < for the upper value. This means the same value will not be counted twice in 2 adjacent Between selections.

    For Intervals the whole interval must be lie between the values. For Points the points must fall between the values. Different Sampling types may give different results with the same input - this is the intended behaviour.

    Between for Irregular intervals is a little complicated. The interval is the distance between a value and the next (for Start locus) or previous (for End locus) value.

    For Center, we take the mid point between two index values as the start and end of each interval. This may or may not make sense for the values in your indes, so use Between with Irregular Intervals(Center()) with caution.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(Between(15, 25)), Y(Between(4, 6.5))]\n\n# output\n\n1\u00d72 DimArray{Int64,2} with dimensions:\n  X Sampled{Int64} 20:10:20 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 5:6 ForwardOrdered Regular Points\n     5  6\n 20  4  5\n

    source

    # DimensionalData.Dimensions.LookupArrays.Touches \u2014 Type.

    Touches <: ArraySelector\n\nTouches(a, b)\n

    Selector that retreives all indices touching the closed interval 2 values, for the maximum possible area that could interact with the supplied range.

    This can be better than .. when e.g. subsetting an area to rasterize, as you may wish to include pixels that just touch the area, rather than those that fall within it.

    Touches is different to using closed intervals when the lookups also contain intervals - if any of the intervals touch, they are included. With .. they are discarded unless the whole cell interval falls inside the selector interval.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))\nA[X(Touches(15, 25)), Y(Touches(4, 6.5))]\n\n# output\n1\u00d72 DimArray{Int64,2} with dimensions:\n  X Sampled{Int64} 20:10:20 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 5:6 ForwardOrdered Regular Points\n     5  6\n 20  4  5\n

    source

    # DimensionalData.Dimensions.LookupArrays.Contains \u2014 Type.

    Contains <: IntSelector\n\nContains(x)\n

    Selector that selects the interval the value is contained by. If the interval is not present in the index, an error will be thrown.

    Can only be used for Intervals or Categorical. For Categorical it falls back to using At. Contains should not be confused with Base.contains - use Where(contains(x)) to check for if values are contain in categorical values like strings.

    Example

    using DimensionalData; const DD = DimensionalData\ndims_ = X(10:10:20; sampling=DD.Intervals(DD.Center())),\n        Y(5:7; sampling=DD.Intervals(DD.Center()))\nA = DimArray([1 2 3; 4 5 6], dims_)\nA[X(Contains(8)), Y(Contains(6.8))]\n\n# output\n3\n

    source

    # DimensionalData.Dimensions.LookupArrays.Where \u2014 Type.

    Where <: ArraySelector\n\nWhere(f::Function)\n

    Selector that filters a dimension lookup by any function that accepts a single value and returns a Bool.

    Example

    using DimensionalData\n\nA = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(19:21)))\nA[X(Where(x -> x > 15)), Y(Where(x -> x in (19, 21)))]\n\n# output\n\n1\u00d72 DimArray{Int64,2} with dimensions:\n  X Sampled{Int64} Int64[20] ForwardOrdered Regular Points,\n  Y Sampled{Int64} Int64[19, 21] ForwardOrdered Regular Points\n     19  21\n 20   4   6\n

    source

    # DimensionalData.Dimensions.LookupArrays.All \u2014 Type.

    All <: Selector\n\nAll(selectors::Selector...)\n

    Selector that combines the results of other selectors. The indices used will be the union of all result sorted in ascending order.

    Example

    using DimensionalData, Unitful\n\ndimz = X(10.0:20:200.0), Ti(1u\"s\":5u\"s\":100u\"s\")\nA = DimArray((1:10) * (1:20)', dimz)\nA[X=All(At(10.0), At(50.0)), Ti=All(1u\"s\"..10u\"s\", 90u\"s\"..100u\"s\")]\n\n# output\n\n2\u00d74 DimArray{Int64,2} with dimensions:\n  X Sampled{Float64} Float64[10.0, 50.0] ForwardOrdered Regular Points,\n  Ti Sampled{Quantity{Int64, \ud835\udc13, Unitful.FreeUnits{(s,), \ud835\udc13, nothing}}} Quantity{Int64, \ud835\udc13, Unitful.FreeUnits{(s,), \ud835\udc13, nothing}}[1 s, 6 s, 91 s, 96 s] ForwardOrdered Regular Points\n       1 s  6 s  91 s  96 s\n 10.0    1    2    19    20\n 50.0    3    6    57    60\n

    source

    Lookup properties:

    # DimensionalData.Dimensions.LookupArrays.bounds \u2014 Function.

    bounds(xs, [dims::Tuple]) => Tuple{Vararg{Tuple{T,T}}}\nbounds(xs::Tuple) => Tuple{Vararg{Tuple{T,T}}}\nbounds(x, dim) => Tuple{T,T}\nbounds(dim::Union{Dimension,LookupArray}) => Tuple{T,T}\n

    Return the bounds of all dimensions of an object, of a specific dimension, or of a tuple of dimensions.

    If bounds are not known, one or both values may be nothing.

    dims can be a Dimension, a dimension type, or a tuple of either.

    source

    # DimensionalData.Dimensions.LookupArrays.val \u2014 Function.

    val(x)\nval(dims::Tuple) => Tuple\n

    Return the contained value of a wrapper object.

    dims can be Dimension, Dimension types, or Symbols for Dim{Symbol}.

    Objects that don't define a val method are returned unaltered.

    source

    # DimensionalData.Dimensions.LookupArrays.LookupArray \u2014 Type.

    LookupArray\n

    Types defining the behaviour of a lookup index, how it is plotted and how Selectors like Between work.

    A LookupArray may be NoLookup indicating that the index is just the underlying array axis, Categorical for ordered or unordered categories, or a Sampled index for Points or Intervals.

    source

    # DimensionalData.Dimensions.LookupArrays.Aligned \u2014 Type.

    Aligned <: LookupArray\n

    Abstract supertype for LookupArrays where the index is aligned with the array axes.

    This is by far the most common supertype for LookupArray.

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractSampled \u2014 Type.

    AbstractSampled <: Aligned\n

    Abstract supertype for LookupArrays where the index is aligned with the array, and is independent of other dimensions. Sampled is provided by this package.

    AbstractSampled must have order, span and sampling fields, or a rebuild method that accpts them as keyword arguments.

    source

    # DimensionalData.Dimensions.LookupArrays.Sampled \u2014 Type.

    Sampled <: AbstractSampled\n\nSampled(data::AbstractVector, order::Order, span::Span, sampling::Sampling, metadata)\nSampled(data=AutoIndex(); order=AutoOrder(), span=AutoSpan(), sampling=Points(), metadata=NoMetadata())\n

    A concrete implementation of the LookupArray AbstractSampled. It can be used to represent Points or Intervals.

    Sampled is capable of representing gridded data from a wide range of sources, allowing correct bounds and Selectors for points or intervals of regular, irregular, forward and reverse indexes.

    On AbstractDimArray construction, Sampled lookup is assigned for all lookups of AbstractRange not assigned to Categorical.

    Arguments

    • data: An AbstractVector of index values, matching the length of the curresponding array axis.
    • order: Order) indicating the order of the index, AutoOrder by default, detected from the order of data to be ForwardOrdered, ReverseOrdered or Unordered. These can be provided explicitly if they are known and performance is important.
    • span: indicates the size of intervals or distance between points, and will be set to Regular for AbstractRange and Irregular for AbstractArray, unless assigned manually.
    • sampling: is assigned to Points, unless set to Intervals manually. Using Intervals will change the behaviour of bounds and Selectorss to take account for the full size of the interval, rather than the point alone.
    • metadata: a Dict or Metadata wrapper that holds any metadata object adding more information about the array axis - useful for extending DimensionalData for specific contexts, like geospatial data in GeoData.jl. By default it is NoMetadata().

    Example

    Create an array with [Interval] sampling, and Regular span for a vector with known spacing.

    We set the Locus of the Intervals to Start specifying that the index values are for the positions at the start of each interval.

    using DimensionalData, DimensionalData.LookupArrays\n\nx = X(Sampled(100:-20:10; sampling=Intervals(Start())))\ny = Y(Sampled([1, 4, 7, 10]; span=Regular(3), sampling=Intervals(Start())))\nA = ones(x, y)\n\n# output\n5\u00d74 DimArray{Float64,2} with dimensions:\n  X Sampled{Int64} 100:-20:20 ReverseOrdered Regular Intervals,\n  Y Sampled{Int64} Int64[1, 4, 7, 10] ForwardOrdered Regular Intervals\n      1    4    7    10\n 100  1.0  1.0  1.0   1.0\n  80  1.0  1.0  1.0   1.0\n  60  1.0  1.0  1.0   1.0\n  40  1.0  1.0  1.0   1.0\n  20  1.0  1.0  1.0   1.0\n

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractCyclic \u2014 Type.

    AbstractCyclic <: AbstractSampled end\n

    An abstract supertype for cyclic lookups.

    These are AbstractSampled lookups that are cyclic for Selectors.

    source

    # DimensionalData.Dimensions.LookupArrays.Cyclic \u2014 Type.

    Cyclic <: AbstractCyclic\n\nCyclic(data; order=AutoOrder(), span=AutoSpan(), sampling=Points(), metadata=NoMetadata(), cycle)\n

    A Cyclic lookup is similar to Sampled but out of range Selectors At, Near, Contains will cycle the values to typemin or typemax over the length of cycle. Where and .. work as for Sampled.

    This is useful when we are using mean annual datasets over a real time-span, or for wrapping longitudes so that -360 and 360 are the same.

    Arguments

    • data: An AbstractVector of index values, matching the length of the curresponding array axis.
    • order: Order) indicating the order of the index, AutoOrder by default, detected from the order of data to be ForwardOrdered, ReverseOrdered or Unordered. These can be provided explicitly if they are known and performance is important.
    • span: indicates the size of intervals or distance between points, and will be set to Regular for AbstractRange and Irregular for AbstractArray, unless assigned manually.
    • sampling: is assigned to Points, unless set to Intervals manually. Using Intervals will change the behaviour of bounds and Selectorss to take account for the full size of the interval, rather than the point alone.
    • metadata: a Dict or Metadata wrapper that holds any metadata object adding more information about the array axis - useful for extending DimensionalData for specific contexts, like geospatial data in GeoData.jl. By default it is NoMetadata().
    • cycle: the length of the cycle. This does not have to exactly match the data, the step size is Week(1) the cycle can be Years(1).

    Notes

    1. If you use dates and e.g. cycle over a Year, every year will have the number and spacing of Weeks and Days as the cycle year. Using At may not be reliable in terms of exact dates, as it will be applied to the specified date plus or minus n years.
    2. Indexing into a Cycled with any AbstractArray or AbstractRange will return a Sampled as the full cycle is likely no longer available.
    3. .. or Between selectors do not work in a cycled way: they work as for Sampled. This may change in future to return cycled values, but there are problems with this, such as leap years breaking correct date cycling of a single year. If you actually need this behaviour, please make a GitHub issue.

    source

    # DimensionalData.Dimensions.LookupArrays.AbstractCategorical \u2014 Type.

    AbstractCategorical <: Aligned\n

    LookupArrays where the values are categories.

    Categorical is the provided concrete implementation. but this can easily be extended - all methods are defined for AbstractCategorical.

    All AbstractCategorical must provide a rebuild method with data, order and metadata keyword arguments.

    source

    # DimensionalData.Dimensions.LookupArrays.Categorical \u2014 Type.

    Categorical <: AbstractCategorical\n\nCategorical(o::Order)\nCategorical(; order=Unordered())\n

    An LookupArray where the values are categories.

    This will be automatically assigned if the index contains AbstractString, Symbol or Char. Otherwise it can be assigned manually.

    Order will be determined automatically where possible.

    Arguments

    • data: An AbstractVector of index values, matching the length of the curresponding array axis.
    • order: Order) indicating the order of the index, AutoOrder by default, detected from the order of data to be ForwardOrdered, ReverseOrdered or Unordered. Can be provided if this is known and performance is important.
    • metadata: a Dict or Metadata wrapper that holds any metadata object adding more information about the array axis - useful for extending DimensionalData for specific contexts, like geospatial data in GeoData.jl. By default it is NoMetadata().

    Example

    Create an array with [Interval] sampling.

    using DimensionalData\n\nds = X([\"one\", \"two\", \"three\"]), Y([:a, :b, :c, :d])\nA = DimArray(rand(3, 4), ds)\nDimensions.lookup(A)\n\n# output\n\nCategorical{String} String[\"one\", \"two\", \"three\"] Unordered,\nCategorical{Symbol} Symbol[:a, :b, :c, :d] ForwardOrdered\n

    source

    # DimensionalData.Dimensions.LookupArrays.Unaligned \u2014 Type.

    Unaligned <: LookupArray\n

    Abstract supertype for LookupArray where the index is not aligned to the grid.

    Indexing an Unaligned with Selectors must provide all other Unaligned dimensions.

    source

    # DimensionalData.Dimensions.LookupArrays.Transformed \u2014 Type.

    Transformed <: Unaligned\n\nTransformed(f, dim::Dimension; metadata=NoMetadata())\n

    LookupArray that uses an affine transformation to convert dimensions from dims(lookup) to dims(array). This can be useful when the dimensions are e.g. rotated from a more commonly used axis.

    Any function can be used to do the transformation, but transformations from CoordinateTransformations.jl may be useful.

    Arguments

    • f: transformation function
    • dim: a dimension to transform to.

    Keyword Arguments

    • metdata:

    Example

    using DimensionalData, DimensionalData.LookupArrays, CoordinateTransformations\n\nm = LinearMap([0.5 0.0; 0.0 0.5])\nA = [1 2  3  4\n     5 6  7  8\n     9 10 11 12];\nda = DimArray(A, (t1=Transformed(m, X), t2=Transformed(m, Y)))\n\nda[X(At(6)), Y(At(2))]\n\n# output\n9\n

    source

    # DimensionalData.Dimensions.MergedLookup \u2014 Type.

    MergedLookup <: LookupArray\n\nMergedLookup(data, dims; [metadata])\n

    A LookupArray that holds multiple combined dimensions.

    MergedLookup can be indexed with Selectors like At, Between, and Where although Near has undefined meaning.

    Arguments

    • data: A Vector of Tuple.
    • dims: A Tuple of Dimension indicating the dimensions in the tuples in data.

    Keywords

    • metadata: a Dict or Metadata object to attach dimension metadata.

    source

    # DimensionalData.Dimensions.LookupArrays.NoLookup \u2014 Type.

    NoLookup <: LookupArray\n\nNoLookup()\n

    A LookupArray that is identical to the array axis. Selectors can't be used on this lookup.

    Example

    Defining a DimArray without passing an index to the dimensions, it will be assigned NoLookup:

    using DimensionalData\n\nA = DimArray(rand(3, 3), (X, Y))\nDimensions.lookup(A)\n\n# output\n\nNoLookup, NoLookup\n

    Which is identical to:

    using .LookupArrays\nA = DimArray(rand(3, 3), (X(NoLookup()), Y(NoLookup())))\nDimensions.lookup(A)\n\n# output\n\nNoLookup, NoLookup\n

    source

    # DimensionalData.Dimensions.LookupArrays.AutoLookup \u2014 Type.

    AutoLookup <: LookupArray\n\nAutoLookup()\nAutoLookup(index=AutoIndex(); kw...)\n

    Automatic LookupArray, the default lookup. It will be converted automatically to another LookupArray when it is possible to detect it from the index.

    Keywords will be used in the detected LookupArray constructor.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoIndex \u2014 Type.

    AutoIndex\n

    Detect a LookupArray index from the context. This is used in NoLookup to simply use the array axis as the index when the array is constructed, and in set to change the LookupArray type without changing the index values.

    source

    "},{"location":"reference/#metadata","title":"Metadata","text":"

    # DimensionalData.Dimensions.LookupArrays.AbstractMetadata \u2014 Type.

    AbstractMetadata{X,T}\n

    Abstract supertype for all metadata wrappers.

    Metadata wrappers allow tracking the contents and origin of metadata. This can facilitate conversion between metadata types (for saving a file to a differenet format) or simply saving data back to the same file type with identical metadata.

    Using a wrapper instead of Dict or NamedTuple also lets us pass metadata objects to set without ambiguity about where to put them.

    source

    # DimensionalData.Dimensions.LookupArrays.Metadata \u2014 Type.

    Metadata <: AbstractMetadata\n\nMetadata{X}(val::Union{Dict,NamedTuple})\nMetadata{X}(pairs::Pair...) => Metadata{Dict}\nMetadata{X}(; kw...) => Metadata{NamedTuple}\n

    General Metadata object. The X type parameter categorises the metadata for method dispatch, if required.

    source

    # DimensionalData.Dimensions.LookupArrays.NoMetadata \u2014 Type.

    NoMetadata <: AbstractMetadata\n\nNoMetadata()\n

    Indicates an object has no metadata. But unlike using nothing, get, keys and haskey will still work on it, get always returning the fallback argument. keys returns () while haskey always returns false.

    source

    "},{"location":"reference/#lookuparray-traits","title":"LookupArray traits","text":"

    # DimensionalData.Dimensions.LookupArrays.LookupArrayTrait \u2014 Type.

    LookupArrayTrait\n

    Abstract supertype of all traits of a LookupArray.

    These modify the behaviour of the lookup index.

    The term \"Trait\" is used loosely - these may be fields of an object of traits hard-coded to specific types.

    source

    "},{"location":"reference/#order","title":"Order","text":"

    # DimensionalData.Dimensions.LookupArrays.Order \u2014 Type.

    Order <: LookupArrayTrait\n

    Traits for the order of a LookupArray. These determine how searchsorted finds values in the index, and how objects are plotted.

    source

    # DimensionalData.Dimensions.LookupArrays.Ordered \u2014 Type.

    Ordered <: Order\n

    Supertype for the order of an ordered LookupArray, including ForwardOrdered and ReverseOrdered.

    source

    # DimensionalData.Dimensions.LookupArrays.ForwardOrdered \u2014 Type.

    ForwardOrdered <: Ordered\n\nForwardOrdered()\n

    Indicates that the LookupArray index is in the normal forward order.

    source

    # DimensionalData.Dimensions.LookupArrays.ReverseOrdered \u2014 Type.

    ReverseOrdered <: Ordered\n\nReverseOrdered()\n

    Indicates that the LookupArray index is in the reverse order.

    source

    # DimensionalData.Dimensions.LookupArrays.Unordered \u2014 Type.

    Unordered <: Order\n\nUnordered()\n

    Indicates that LookupArray is unordered.

    This means the index cannot be searched with searchsortedfirst or similar optimised methods - instead it will use findfirst.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoOrder \u2014 Type.

    AutoOrder <: Order\n\nAutoOrder()\n

    Specifies that the Order of a LookupArray will be found automatically where possible.

    source

    "},{"location":"reference/#span","title":"Span","text":"

    # DimensionalData.Dimensions.LookupArrays.Span \u2014 Type.

    Span <: LookupArrayTrait\n

    Defines the type of span used in a Sampling index. These are Regular or Irregular.

    source

    # DimensionalData.Dimensions.LookupArrays.Regular \u2014 Type.

    Regular <: Span\n\nRegular(step=AutoStep())\n

    Points or Intervals that have a fixed, regular step.

    source

    # DimensionalData.Dimensions.LookupArrays.Irregular \u2014 Type.

    Irregular <: Span\n\nIrregular(bounds::Tuple)\nIrregular(lowerbound, upperbound)\n

    Points or Intervals that have an Irrigular step size. To enable bounds tracking and accuract selectors, the starting bounds are provided as a 2 tuple, or 2 arguments. (nothing, nothing) is acceptable input, the bounds will be guessed from the index, but may be innaccurate.

    source

    # DimensionalData.Dimensions.LookupArrays.Explicit \u2014 Type.

    Explicit(bounds::AbstractMatix)\n

    Intervals where the span is explicitly listed for every interval.

    This uses a matrix where with length 2 columns for each index value, holding the lower and upper bounds for that specific index.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoSpan \u2014 Type.

    AutoSpan <: Span\n\nAutoSpan()\n

    The span will be guessed and replaced in format or set.

    source

    "},{"location":"reference/#sampling","title":"Sampling","text":"

    # DimensionalData.Dimensions.LookupArrays.Sampling \u2014 Type.

    Sampling <: LookupArrayTrait\n

    Indicates the sampling method used by the index: Points or Intervals.

    source

    # DimensionalData.Dimensions.LookupArrays.Points \u2014 Type.

    Points <: Sampling\n\nPoints()\n

    Sampling lookup where single samples at exact points.

    These are always plotted at the center of array cells.

    source

    # DimensionalData.Dimensions.LookupArrays.Intervals \u2014 Type.

    Intervals <: Sampling\n\nIntervals(locus::Locus)\n

    Sampling specifying that sampled values are the mean (or similar) value over an interval, rather than at one specific point.

    Intervals require a Locus of Start, Center or End to define the location in the interval that the index values refer to.

    source

    "},{"location":"reference/#loci","title":"Loci","text":"

    # DimensionalData.Dimensions.LookupArrays.Locus \u2014 Type.

    Locus <: LookupArrayTrait

    Abstract supertype of types that indicate the position of index values where they represent Intervals.

    These allow for values array cells to align with the Start, Center, or End of values in the lookup index.

    This means they can be plotted with correct axis markers, and allows automatic converrsions to between formats with different standards (such as NetCDF and GeoTiff).

    source

    # DimensionalData.Dimensions.LookupArrays.Center \u2014 Type.

    Center <: Locus\n\nCenter()\n

    Indicates a lookup value is for the center of its corresponding array cell.

    source

    # DimensionalData.Dimensions.LookupArrays.Start \u2014 Type.

    Start <: Locus\n\nStart()\n

    Indicates a lookup value is for the start of its corresponding array cell, in the direction of the lookup index order.

    source

    # DimensionalData.Dimensions.LookupArrays.End \u2014 Type.

    End <: Locus\n\nEnd()\n

    Indicates a lookup value is for the end of its corresponding array cell, in the direction of the lookup index order.

    source

    # DimensionalData.Dimensions.LookupArrays.AutoLocus \u2014 Type.

    AutoLocus <: Locus\n\nAutoLocus()\n

    Indicates a interval where the index position is not yet known. This will be filled with a default value on object construction.

    source

    "},{"location":"reference/#lookuparrays-methods","title":"LookupArrays methods","text":"

    # DimensionalData.Dimensions.LookupArrays.hasselection \u2014 Function.

    hasselection(x, selector) => Bool\nhasselection(x, selectors::Tuple) => Bool\n

    Check if indexing into x with selectors can be performed, where x is some object with a dims method, and selectors is a Selector or Dimension or a tuple of either.

    source

    # DimensionalData.Dimensions.LookupArrays.shiftlocus \u2014 Function.

    shiftlocus(locus::Locus, x)\n

    Shift the index of x from the current locus to the new locus.

    We only shift Sampled, Regular or Explicit, Intervals.

    source

    # DimensionalData.Dimensions.LookupArrays.sampling \u2014 Function.

    sampling(x, [dims::Tuple]) => Tuple\nsampling(x, dim) => Sampling\nsampling(xs::Tuple) => Tuple{Vararg{Sampling}}\nsampling(x:Union{Dimension,LookupArray}) => Sampling\n

    Return the Sampling for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.span \u2014 Function.

    span(x, [dims::Tuple]) => Tuple\nspan(x, dim) => Span\nspan(xs::Tuple) => Tuple{Vararg{Span,N}}\nspan(x::Union{Dimension,LookupArray}) => Span\n

    Return the Span for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.order \u2014 Function.

    order(x, [dims::Tuple]) => Tuple\norder(xs::Tuple) => Tuple\norder(x::Union{Dimension,LookupArray}) => Order\n

    Return the Ordering of the dimension index for each dimension: ForwardOrdered, ReverseOrdered, or Unordered

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.index \u2014 Function.

    index(x) => Tuple{Vararg{AbstractArray}}\nindex(x, dims::Tuple) => Tuple{Vararg{AbstractArray}}\nindex(dims::Tuple) => Tuple{Vararg{AbstractArray}}}\nindex(x, dim) => AbstractArray\nindex(dim::Dimension) => AbstractArray\n

    Return the contained index of a Dimension.

    Only valid when a Dimension contains an AbstractArray or a Val tuple like Val{(:a, :b)}(). The Val is unwrapped to return just the Tuple

    dims can be a Dimension, or a tuple of Dimension.

    source

    # DimensionalData.Dimensions.LookupArrays.locus \u2014 Function.

    locus(x, [dims::Tuple]) => Tuple\nlocus(x, dim) => Locus\nlocus(xs::Tuple) => Tuple{Vararg{Locus,N}}\nlocus(x::Union{Dimension,LookupArray}) => Locus\n

    Return the Locus for each dimension.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    # DimensionalData.Dimensions.LookupArrays.units \u2014 Function.

    units(x) => Union{Nothing,Any}\nunits(xs:Tuple) => Tuple\nunit(A::AbstractDimArray, dims::Tuple) => Tuple\nunit(A::AbstractDimArray, dim) => Union{Nothing,Any}\n

    Get the units of an array or Dimension, or a tuple of of either.

    Units do not have a set field, and may or may not be included in metadata. This method is to facilitate use in labels and plots when units are available, not a guarantee that they will be. If not available, nothing is returned.

    Second argument dims can be Dimensions, Dimension types, or Symbols for Dim{Symbol}.

    source

    "},{"location":"reference/#name","title":"Name","text":"

    # DimensionalData.AbstractName \u2014 Type.

    AbstractName\n

    Abstract supertype for name wrappers.

    source

    # DimensionalData.Name \u2014 Type.

    Name <: AbstractName\n\nName(name::Union{Symbol,Name) => Name\nName(name::NoName) => NoName\n

    Name wrapper. This lets arrays keep symbol names when the array wrapper neeeds to be `isbits, like for use on GPUs. It makes the name a property of the type. It's not necessary to use in normal use, a symbol is probably easier.

    source

    # DimensionalData.NoName \u2014 Type.

    NoName <: AbstractName\n\nNoName()\n

    NoName specifies an array is not named, and is the default name value for all AbstractDimArrays.

    source

    "},{"location":"crash/generated/course/course/","title":"Crash course","text":"
    using DimensionalData\n
    "},{"location":"crash/generated/course/course/#dimensions-and-dimarrays","title":"Dimensions and DimArrays","text":"

    The core type of DimensionalData.jl is the Dimension and the types that inherit from it, such as Ti, X, Y, Z, the generic Dim{:x}, or others that you define manually using the @dim macro.

    Dimensions are primarily used in DimArray, other AbstractDimArray.

    We can use dimensions without a value index - these simply label the axis. A DimArray with labelled dimensions is constructed by:

    using DimensionalData\nA = rand(X(5), Y(5))\n
    5\u00d75 DimArray{Float64,2} with dimensions: X, Y\n 0.461325   0.8431    0.782148   0.749449  0.31217\n 0.241514   0.138161  0.336      0.28491   0.831904\n 0.109044   0.598698  0.30281    0.829182  0.271389\n 0.0977132  0.63052   0.534344   0.331739  0.315462\n 0.0336821  0.642018  0.0731809  0.888225  0.810319\n

    get value

    A[Y(1), X(2)]\n
    0.24151387312926442\n

    As shown above, Dimensions can be used to construct arrays in rand, ones, zeros and fill with either a range for a lookup index or a number for the dimension length.

    Or we can use the Dim{X} dims by using Symbols, and indexing with keywords:

    A = DimArray(rand(5, 5), (:a, :b))\n
    5\u00d75 DimArray{Float64,2} with dimensions: Dim{:a}, Dim{:b}\n 0.782406   0.404004  0.0384209  0.126395  0.213012\n 0.303812   0.952501  0.266923   0.250459  0.732001\n 0.0343281  0.131738  0.0263003  0.87979   0.937614\n 0.20561    0.405973  0.117466   0.535632  0.662165\n 0.468297   0.465038  0.973552   0.606813  0.688237\n

    get value

    A[a=3, b=5]\n
    0.9376140541417589\n

    Often, we want to provide a lookup index for the dimension:

    using Dates\nt = DateTime(2001):Month(1):DateTime(2001,12)\nx = 10:10:100\nA = rand(X(x), Ti(t))\n
    10\u00d712 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 10:10:100 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-12-01T00:00:00\") ForwardOrdered Regular Points\n       2001-01-01T00:00:00  \u2026   2001-12-01T00:00:00\n  10  0.45369                              0.343509\n  20  0.0171005                            0.38129\n  30  0.406912                             0.745937\n  40  0.585578                             0.831535\n  50  0.611388                          \u2026  0.149655\n  60  0.346391                             0.478455\n  70  0.0589364                            0.922556\n  80  0.767139                             0.858749\n  90  0.465084                             0.667982\n 100  0.217847                          \u2026  0.222959\n

    Here both X and Ti are dimensions from DimensionalData. The currently exported dimensions are X, Y, Z, Ti (Ti is shortening of Time).

    The length of each dimension index has to match the size of the corresponding array axis.

    This can also be done with Symbol, using Dim{X}:

    A2 = DimArray(rand(12, 10), (time=t, distance=x))\n
    12\u00d710 DimArray{Float64,2} with dimensions: \n  Dim{:time} Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-12-01T00:00:00\") ForwardOrdered Regular Points,\n  Dim{:distance} Sampled{Int64} 10:10:100 ForwardOrdered Regular Points\n                                   \u2026  80         90         100\n  2001-01-01T00:00:00      0.798125   0.712841    0.754911\n  2001-02-01T00:00:00      0.971043   0.317214    0.0136019\n  2001-03-01T00:00:00      0.520036   0.690481    0.320414\n  2001-04-01T00:00:00      0.125068   0.423247    0.423717\n  2001-05-01T00:00:00  \u2026   0.287405   0.501309    0.438374\n  2001-06-01T00:00:00      0.410531   0.950214    0.621235\n  2001-07-01T00:00:00      0.834235   0.789531    0.743405\n  2001-08-01T00:00:00      0.853966   0.634005    0.424101\n  2001-09-01T00:00:00      0.859316   0.588221    0.268555\n  2001-10-01T00:00:00  \u2026   0.723767   0.745889    0.64083\n  2001-11-01T00:00:00      0.58551    0.424475    0.610547\n  2001-12-01T00:00:00      0.266558   0.85589     0.139885\n

    Symbols can be more convenient to use than defining custom dims with @dim, but have some downsides. They don't inherit from a specific Dimension type, so plots will not know what axis to put them on. They also cannot use the basic constructor methods like rand or zeros, as we cannot dispatch on Symbol for Base methods without \"type-piracy\".

    "},{"location":"crash/generated/course/course/#indexing-the-array-by-name-and-index","title":"Indexing the array by name and index","text":"

    Dimensions can be used to index the array by name, without having to worry about the order of the dimensions.

    The simplest case is to select a dimension by index. Let's say every 2nd point of the Ti dimension and every 3rd point of the X dimension. This is done with the simple Ti(range) syntax like so:

    A[X(1:3:11), Ti(1:2:11)]\n
    4\u00d76 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(2):DateTime(\"2001-11-01T00:00:00\") ForwardOrdered Regular Points\n       2001-01-01T00:00:00  \u2026   2001-11-01T00:00:00\n  10  0.45369                              0.0120772\n  40  0.585578                             0.966221\n  70  0.0589364                            0.469902\n 100  0.217847                             0.278389\n

    When specifying only one dimension, all elements of the other dimensions are assumed to be included:

    A[X(1:3:10)]\n
    4\u00d712 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-12-01T00:00:00\") ForwardOrdered Regular Points\n       2001-01-01T00:00:00  \u2026   2001-12-01T00:00:00\n  10  0.45369                              0.343509\n  40  0.585578                             0.831535\n  70  0.0589364                            0.922556\n 100  0.217847                             0.222959\n

    Indexing

    Indexing AbstractDimArrays works with getindex, setindex! and view. The result is still an AbstracDimArray, unless using all single Int or Selectors that resolve to Int.

    Dimensions can be used to construct arrays in rand, ones, zeros and fill with either a range for a lookup index or a number for the dimension length.

    using DimensionalData\nA1 = ones(X(1:40), Y(50))\n
    40\u00d750 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 1:40 ForwardOrdered Regular Points,\n  Y\n  1  1.0  1.0  1.0  1.0  1.0  1.0  1.0  \u2026  1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  2  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  3  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  4  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  5  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  6  1.0  1.0  1.0  1.0  1.0  1.0  1.0  \u2026  1.0  1.0  1.0  1.0  1.0  1.0  1.0\n  \u22ee                      \u22ee              \u22f1  \u22ee                        \u22ee    \n 35  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 36  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 37  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 38  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 39  1.0  1.0  1.0  1.0  1.0  1.0  1.0  \u2026  1.0  1.0  1.0  1.0  1.0  1.0  1.0\n 40  1.0  1.0  1.0  1.0  1.0  1.0  1.0     1.0  1.0  1.0  1.0  1.0  1.0  1.0\n

    We can also use dim wrappers for indexing, so that the dimension order in the underlying array does not need to be known:

    A1[Y(1), X(1:10)]\n
    10-element DimArray{Float64,1} with dimensions: \n  X Sampled{Int64} 1:10 ForwardOrdered Regular Points\nand reference dimensions: Y\n  1  1.0\n  2  1.0\n  3  1.0\n  4  1.0\n  5  1.0\n  6  1.0\n  7  1.0\n  8  1.0\n  9  1.0\n 10  1.0\n

    "},{"location":"crash/generated/course/course/#indexing-performance","title":"Indexing Performance","text":"

    Indexing with Dimension has no runtime cost:

    A2 = ones(X(3), Y(3))\n
    3\u00d73 DimArray{Float64,2} with dimensions: X, Y\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n

    time ?

    using BenchmarkTools\n\nprintln(@btime $A2[X(1), Y(2)])\n
      43.688 ns (0 allocations: 0 bytes)\n1.0\n

    and

    println(@btime parent($A2)[1, 2])\n
      3.095 ns (0 allocations: 0 bytes)\n1.0\n

    "},{"location":"crash/generated/course/course/#specifying-dims-keyword-arguments-with-dimension","title":"Specifying dims keyword arguments with Dimension","text":"

    In many Julia functions like size or sum, you can specify the dimension along which to perform the operation as an Int. It is also possible to do this using Dimension types with AbstractDimArray:

    A3 = rand(X(3), Y(4), Ti(5));\nsum(A3; dims=Ti)\n
    3\u00d74\u00d71 DimArray{Float64,3} with dimensions: X, Y, Ti\n[:, :, 1]\n 1.89767  2.71666  2.94472  3.18355\n 2.9894   2.93941  3.21275  2.04066\n 2.18769  2.4382   2.62694  2.62173\n

    This also works in methods from Statistics:

    using Statistics\nmean(A3; dims=Ti)\n
    3\u00d74\u00d71 DimArray{Float64,3} with dimensions: X, Y, Ti\n[:, :, 1]\n 0.379534  0.543332  0.588944  0.636711\n 0.59788   0.587883  0.64255   0.408133\n 0.437538  0.487641  0.525388  0.524346\n

    "},{"location":"crash/generated/course/course/#methods-where-dims-dim-types-or-symbols-can-be-used-to-indicate-the-array-dimension","title":"Methods where dims, dim types, or Symbols can be used to indicate the array dimension:","text":"
    • size, axes, firstindex, lastindex
    • cat, reverse, dropdims
    • reduce, mapreduce
    • sum, prod, maximum, minimum,
    • mean, median, extrema, std, var, cor, cov
    • permutedims, adjoint, transpose, Transpose
    • mapslices, eachslice
    "},{"location":"crash/generated/course/course/#lookuparrays-and-selectors","title":"LookupArrays and Selectors","text":"

    Indexing by value in DimensionalData is done with Selectors. IntervalSets.jl is now used for selecting ranges of values (formerly Between).

    Selector Description At(x) get the index exactly matching the passed in value(s) Near(x) get the closest index to the passed in value(s) Contains(x) get indices where the value x falls within an interval Where(f) filter the array axis by a function of the dimension index values. [Not(x)] get all indices not selected by x, which can be another selector. [a..b] get all indices between two values, inclusively. [OpenInterval(a, b)] get all indices between a and b, exclusively. [Interval{A,B}(a, b)] get all indices between a and b, as :closed or :open.

    Selectors find indices in the LookupArray, for each dimension. Here we use an Interval to select a range between integers and DateTime:

    A[X(12..35), Ti(Date(2001, 5)..Date(2001, 7))]\n
    2\u00d73 DimArray{Float64,2} with dimensions: \n  X Sampled{Int64} 20:10:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-05-01T00:00:00\"):Month(1):DateTime(\"2001-07-01T00:00:00\") ForwardOrdered Regular Points\n      2001-05-01T00:00:00  \u2026   2001-07-01T00:00:00\n 20  0.395694                             0.425266\n 30  0.877296                             0.218414\n

    To select intervals in DimArrays (e.g. A2) you need to specify dimname=a .. b:

    A2[distance=12 .. 35, time=Date(2001, 5) .. Date(2001, 7)]\n
    3\u00d73 DimArray{Float64,2} with dimensions: X, Y\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n 1.0  1.0  1.0\n

    Selectors can be used in getindex, setindex! and view to select indices matching the passed in value(s)

    We can use selectors inside dim wrappers, here selecting values from DateTime and Int:

    using Dates\ntimespan = DateTime(2001,1):Month(1):DateTime(2001,12)\nA4 = rand(Ti(timespan), X(10:10:100))\nA4[X(Near(35)), Ti(At(DateTime(2001,5)))]\n
    0.7844238575217434\n

    Without dim wrappers selectors must be in the right order, and specify all axes:

    using Unitful\nA5 = rand(Y((1:10:100)u\"m\"), Ti((1:5:100)u\"s\"));\nA5[10.5u\"m\" .. 50.5u\"m\", Near(23u\"s\")]\n
    4-element DimArray{Float64,1} with dimensions: \n  Y Sampled{Quantity{Int64, \ud835\udc0b, Unitful.FreeUnits{(m,), \ud835\udc0b, nothing}}} (11:10:41) m ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{Quantity{Int64, \ud835\udc13, Unitful.FreeUnits{(s,), \ud835\udc13, nothing}}} (21:5:21) s ForwardOrdered Regular Points\n 11 m  0.163947\n 21 m  0.822844\n 31 m  0.151179\n 41 m  0.401123\n

    We can also use Linear indices as in standard Array:

    A5[1:5]\n
    5-element Vector{Float64}:\n 0.23782475482190868\n 0.10215310323944482\n 0.014306472825666106\n 0.5100856183627\n 0.45872357840022293\n

    But unless the DimArray is one dimensional, this will return a regular Array. It is not possible to keep the LookupArray or even Dimensions after linear indexing is used.

    "},{"location":"crash/generated/course/course/#lookuparrays-and-traits","title":"LookupArrays and traits","text":"

    Using a regular range or Vector as a lookup index has a number of downsides. We cannot use searchsorted for fast searches without knowing the order of the array, and this is slow to compute at runtime. It also means reverse or rotations cannot be used while keeping the DimArray wrapper.

    Step sizes are also a problem. Some ranges like LinRange lose their step size with a length of 1. Often, instead of a range, multi-dimensional data formats provide a Vector of evenly spaced values for a lookup, with a step size specified separately. Converting to a range introduces floating point errors that means points may not be selected with At without setting tolerances.

    This means using a lookup wrapper with traits is more generally robust and versatile than simply using a range or vector. DimensionalData provides types for specifying details about the dimension index, in the LookupArrays sub-module:

    using DimensionalData\nusing .LookupArrays\n

    The main LookupArray are :

    • Sampled
    • Categorical,
    • NoLookup

    Each comes with specific traits that are either fixed or variable, depending on the contained index. These enable optimisations with Selectors, and modified behaviours, such as:

    1. Selection of Intervals or Points, which will give slightly

    different results for selectors like .. - as whole intervals are selected, and have different bounds values.

    1. Tracking of lookup order. A reverse order is labelled ReverseOrdered and

    will still work with searchsorted, and for plots to always be the right way up when either the index or the array is backwards. Reversing a DimArray will reverse the LookupArray for that dimension, swapping ReverseOrdered to ForwardOrdered.

    1. Sampled Intervals can have index located at a Locus of:

    2. Start,

    3. Center
    4. End

    Which specifies the point of the interval represented in the index, to match different data standards, e.g. GeoTIFF (Start) and NetCDF (Center).

    1. A Span specifies the gap between Points or the size of

    Intervals. This may be:

    • Regular, in the case of a range and equally spaced vector,
    • Irregular for unequally spaced vectors
    • Explicit for the case where all interval start and end points are specified explicitly - as is common in the NetCDF standard.

    These traits all for subtypes of Aligned.

    Unaligned also exists to handle dimensions with an index that is rotated or otherwise transformed in relation to the underlying array, such as Transformed.

    "},{"location":"crash/generated/course/course/#lookuparray-detection","title":"LookupArray detection","text":"

    Aligned types will be detected automatically if not specified - which usually isn't required.

    • An empty Dimension or a Type or Symbol will be assigned NoLookup - this behaves as a simple named dimension without a lookup index.
    • A Dimension containing and index of String, Char, Symbol or mixed types will be given the Categorical mode,
    • A range will be assigned Sampled, defaulting to Regular, Points
    • Other AbstractVector will be assigned Sampled Irregular Points.

    In all cases the Order of ForwardOrdered or ReverseOrdered will be be detected, otherwise Unordered for an unsorted Array.

    See the LookupArray API docs for more detail.

    "},{"location":"crash/generated/course/course/#referenced-dimensions","title":"Referenced dimensions","text":"

    The reference dimensions record the previous dimensions that an array was selected from. These can be use for plot labelling, and tracking array changes so that cat can reconstruct the lookup array from previous dimensions that have been sliced.

    "},{"location":"crash/generated/course/course/#warnings","title":"Warnings","text":"

    Indexing with unordered or reverse-ordered arrays has undefined behaviour. It will trash the dimension index, break searchsorted and nothing will make sense any more. So do it at you own risk.

    However, indexing with sorted vectors of Int can be useful, so it's allowed. But it may do strange things to interval sizes for Intervals that are not Explicit.

    This selects the first 5 entries of the underlying array. In the case that A has only one dimension, it will be retained. Multidimensional AbstracDimArray indexed this way will return a regular array.

    This page was generated using Literate.jl.

    "}]} \ No newline at end of file diff --git a/previews/PR568/sitemap.xml.gz b/previews/PR568/sitemap.xml.gz index 034e7137e587a8cf0c4c4ba5b797b79892a77f93..8b89d4653a8d1bd141b24f67e62cdc3049b85a39 100644 GIT binary patch delta 12 Tcmb=gXOr*d;IO(kk*yK{7+M48 delta 12 Tcmb=gXOr*d;7GbVk*yK{86E@<