From 852d4f13d912b56521f19bad19149163e3c64718 Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Thu, 23 May 2024 15:54:01 +0200 Subject: [PATCH] Simplify get started --- docs/src/UserGuide/read.md | 3 +- docs/src/get_started.md | 86 ++++++++++++++------------------------ 2 files changed, 33 insertions(+), 56 deletions(-) diff --git a/docs/src/UserGuide/read.md b/docs/src/UserGuide/read.md index ea6d82bc..cf4024bc 100644 --- a/docs/src/UserGuide/read.md +++ b/docs/src/UserGuide/read.md @@ -1,7 +1,6 @@ # Read YAXArrays and Datasets -Here we learn how to open files as arrays and datasets. - +This section describes how to read files, URLs, and directories into YAXArrays and datasets. ## Read Zarr diff --git a/docs/src/get_started.md b/docs/src/get_started.md index 0acfdb66..13757f72 100644 --- a/docs/src/get_started.md +++ b/docs/src/get_started.md @@ -14,89 +14,67 @@ Alternatively, you can also do import Pkg; Pkg.add("YAXArrays") ``` -:::tip - -The Julia Compiler is always improving. As such, we recommend using the latest stable -version of Julia. - -::: - - ## Quickstart +Create a simple array from random numbers given the size of each dimension or axis: + ```@example quickstart using YAXArrays -``` -You may check the installed version with: - -```julia -pkg> st YAXArrays +a = YAXArray(rand(2,3)) ``` -Let's assemble a `YAXArray` with 4 dimensions i.e. time, x,y and a variable dimension with two variables. +Assemble a more complex `YAXArray` with 4 dimensions, i.e. time, x, y and a variable type: ```@example quickstart -using YAXArrays, DimensionalData +using DimensionalData + +# axes or dimensions with name and tick values axlist = ( Dim{:time}(range(1, 20, length=20)), X(range(1, 10, length=10)), Y(range(1, 5, length=15)), - Dim{:Variable}(["var1", "var2"])) -# and the corresponding data. -data = rand(20, 10, 15, 2); -nothing # hide -``` - -::: info - -With `YAXArrays.jl 0.5` we switched the underlying data type to be a subtype of the DimensionalData.jl types. Therefore the indexing with named dimensions changed to the DimensionalData syntax. See the [`DimensionalData.jl docs`](https://rafaqz.github.io/DimensionalData.jl/stable/). + Dim{:variable}(["temperature", "precipitation"]) +) -::: - -You can also add additional properties via a Dictionary, namely +# the actual data matching the dimensions defined in axlist +data = rand(20, 10, 15, 2) -```@example quickstart +# metadata about the array props = Dict( - "time" => "days", - "x" => "lon", - "y" => "lat", - "var1" => "one of your variables", - "var2" => "your second variable", + "origin" => "YAXArrays.jl example", + "x" => "longitude", + "y" => "latitude", ); -nothing # hide + +a2 = YAXArray(axlist, data, props) ``` -And our first YAXArray is built with: +Get the temperature map at the first point in time: -```@ansi quickstart -ds = YAXArray(axlist, data, props) +```@example quickstart +a2[variable=At("temperature"), time=1].data ``` -## Getting data from a YAXArray +Get more details at the [select page](UserGuide/select) -For axis can be via `.` +## Updates -```@example quickstart -ds.X -``` +:::tip -or better yet via `lookup` +The Julia Compiler is always improving. As such, we recommend using the latest stable +version of Julia. -```@example quickstart -lookup(ds, :X) -``` +::: -note that also the `.data` field can be use +You may check the installed version with: -```@example quickstart -lookup(ds, :X).data +```julia +pkg> st YAXArrays ``` -The data for one variables, i.e. `var1` can be accessed via: +::: info -```@ansi quickstart -ds[Variable=At("var1")] -``` +With `YAXArrays.jl 0.5` we switched the underlying data type to be a subtype of the DimensionalData.jl types. Therefore the indexing with named dimensions changed to the DimensionalData syntax. See the [`DimensionalData.jl docs`](https://rafaqz.github.io/DimensionalData.jl/stable/). -and again, you can use the `.data` field to actually get the data. \ No newline at end of file +::: \ No newline at end of file