Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarusA committed Dec 15, 2024
1 parent 8dd7fd7 commit 115440b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ using YAXArrays: YAXArrays as YAX

axlist = (
YAX.time(range(1, 20, length=20)),
X(range(1, 10, length=10)),
Y(range(1, 5, length=15)),
lon(range(1, 10, length=10)),
lat(range(1, 5, length=15)),
Variables(["var1", "var2"]))
```
```
↓ time 1.0:1.0:20.0,
X 1.0:1.0:10.0,
Y 1.0:0.2857142857142857:5.0,
Variable ["var1", "var2"]
lon 1.0:1.0:10.0,
lat 1.0:0.2857142857142857:5.0,
Variables ["var1", "var2"]
```

and the corresponding data.
Expand Down Expand Up @@ -150,8 +150,8 @@ ds = YAXArray(axlist, data, props)
│ 20×10×15×2 YAXArray{Float64,4} │
├────────────────────────────────┴─────────────────────────────────────────────── dims ┐
↓ time Sampled{Float64} 1.0:1.0:20.0 ForwardOrdered Regular Points,
X Sampled{Float64} 1.0:1.0:10.0 ForwardOrdered Regular Points,
Y Sampled{Float64} 1.0:0.2857142857142857:5.0 ForwardOrdered Regular Points,
lon Sampled{Float64} 1.0:1.0:10.0 ForwardOrdered Regular Points,
lat Sampled{Float64} 1.0:0.2857142857142857:5.0 ForwardOrdered Regular Points,
⬔ Variable Categorical{String} ["var1", "var2"] ForwardOrdered
├──────────────────────────────────────────────────────────────────────────── metadata ┤
Dict{String, String} with 5 entries:
Expand All @@ -170,17 +170,17 @@ ds = YAXArray(axlist, data, props)
For axis can be via `.`

```julia
ds.X
ds.lon
```
```
X Sampled{Float64} ForwardOrdered Regular Points
lon Sampled{Float64} ForwardOrdered Regular Points
wrapping: 1.0:1.0:10.0
```

or better yet via `lookup`

```julia
lookup(ds, :X)
lookup(ds, :lon)
```
```
Sampled{Float64} ForwardOrdered Regular Points
Expand All @@ -189,7 +189,7 @@ wrapping: 1.0:1.0:10.0

note that also the `.data` field can be use
```julia
lookup(ds, :X).data
lookup(ds, :lon).data
```
```
1.0:1.0:10.0
Expand All @@ -198,15 +198,15 @@ lookup(ds, :X).data
The data for one variables, i.e. `var1` can be accessed via:

```julia
ds[Variable=At("var1")]
ds[Variables=At("var1")]
```
```
╭──────────────────────────────╮
│ 20×10×15 YAXArray{Float64,3} │
├──────────────────────────────┴────────────────────────────────────────────── dims ┐
↓ time Sampled{Float64} 1.0:1.0:20.0 ForwardOrdered Regular Points,
X Sampled{Float64} 1.0:1.0:10.0 ForwardOrdered Regular Points,
Y Sampled{Float64} 1.0:0.2857142857142857:5.0 ForwardOrdered Regular Points
lon Sampled{Float64} 1.0:1.0:10.0 ForwardOrdered Regular Points,
lat Sampled{Float64} 1.0:0.2857142857142857:5.0 ForwardOrdered Regular Points
├───────────────────────────────────────────────────────────────────────── metadata ┤
Dict{String, String} with 5 entries:
"var1" => "one of your variables"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/UserGuide/combine.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ using YAXArrays: YAXArrays as YAX
temperature = YAXArray((YAX.time(1:6),), rand(6))
precipitation = YAXArray((YAX.time(1:6),), rand(6))
cubes = [temperature,precipitation]
var_axis = Dim{:variable}(["temp", "prep"])
var_axis = Variables(["temp", "prep"])
combined = concatenatecubes(cubes, var_axis)
````
12 changes: 6 additions & 6 deletions docs/src/UserGuide/compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,23 @@ Note the `.` after `f`, this is because we will slice across time, namely, the f
Here, we do create `YAXArrays` only with the desired dimensions as

````@ansi mapCube
lon = YAXArray(lon(range(1, 15)))
lat = YAXArray(lat(range(1, 10)))
lon_yax = YAXArray(lon(range(1, 15)))
lat_yax = YAXArray(lat(range(1, 10)))
````

And a time Cube's Axis

````@example mapCube
tspan = Date("2022-01-01"):Day(1):Date("2022-01-30")
time = YAXArray(YAX.time(tspan))
time_yax = YAXArray(YAX.time(tspan))
````

note that the following can be extended to arbitrary `YAXArrays` with additional data and dimensions.

Let's generate a new `cube` using `mapCube` and saving the output directly into disk.

````@ansi mapCube
gen_cube = mapCube(g, (lon, lat, time);
gen_cube = mapCube(g, (lon_yax, lat_yax, time_yax);
indims = (InDims(), InDims(), InDims("time")),
outdims = OutDims("time", overwrite=true, path="my_gen_cube.zarr", backend=:zarr,
outtype = Float32)
Expand All @@ -172,7 +172,7 @@ gen_cube.data[1, :, :]
but, we can generate a another cube with a different `output order` as follows

````@ansi mapCube
gen_cube = mapCube(g, (lon, lat, time);
gen_cube = mapCube(g, (lon_yax, lat_yax, time_yax);
indims = (InDims("lon"), InDims(), InDims()),
outdims = OutDims("lon", overwrite=true, path="my_gen_cube.zarr", backend=:zarr,
outtype = Float32)
Expand Down Expand Up @@ -209,7 +209,7 @@ axlist = (
YAX.time(Date("2022-01-01"):Day(1):Date("2022-01-05")),
lon(range(1, 4, length=4)),
lat(range(1, 3, length=3)),
Dim{:variables}(["a", "b"])
Variables(["a", "b"])
)
Random.seed!(123)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/UserGuide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ d_keys = keys(stocks)
currently there is not direct support to obtain `dims` from a `TimeArray`, but we can code a function for it

````@example howdoi
getTArrayAxes(ta::TimeArray) = (YAX.time(timestamp(ta)), Dim{:variable}(colnames(ta)), );
getTArrayAxes(ta::TimeArray) = (YAX.time(timestamp(ta)), Variables(colnames(ta)), );
nothing # hide
````
then, we create the `YAXArrays` as
Expand Down
10 changes: 4 additions & 6 deletions docs/src/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ a = YAXArray(rand(2,3))
Assemble a more complex `YAXArray` with 4 dimensions, i.e. time, x, y and a variable type:

```@example quickstart
using DimensionalData
# axes or dimensions with name and tick values
axlist = (
YAX.time(range(1, 20, length=20)),
X(range(1, 10, length=10)),
Y(range(1, 5, length=15)),
Dim{:variable}(["temperature", "precipitation"])
lon(range(1, 10, length=10)),
lat(range(1, 5, length=15)),
Variables(["temperature", "precipitation"])
)
# the actual data matching the dimensions defined in axlist
Expand All @@ -54,7 +52,7 @@ a2 = YAXArray(axlist, data, props)
Get the temperature map at the first point in time:

```@example quickstart
a2[variable=At("temperature"), time=1].data
a2[Variables=At("temperature"), time=1].data
```

## Updates
Expand Down

0 comments on commit 115440b

Please sign in to comment.