Skip to content

Commit

Permalink
Simplify get started
Browse files Browse the repository at this point in the history
  • Loading branch information
danlooo committed May 23, 2024
1 parent e5216d9 commit 852d4f1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 56 deletions.
3 changes: 1 addition & 2 deletions docs/src/UserGuide/read.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
86 changes: 32 additions & 54 deletions docs/src/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
:::

0 comments on commit 852d4f1

Please sign in to comment.