Skip to content

Commit

Permalink
small docs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinuzziFrancesco committed Mar 28, 2024
1 parent a1f1c63 commit f35bd09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/src/tutorials/basic_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ The package can compute indices at custom precision

```@example basic
T = Float32
savi = compute_index(T, "SAVI"; N=T(nir), R=T(red), L=T(0.5))
savi = compute_index("SAVI"; N=T(nir), R=T(red), L=T(0.5))
```
```@example basic
T = Float16
savi = compute_index(T, "SAVI"; N=T(nir), R=T(red), L=T(0.5))
savi = compute_index("SAVI"; N=T(nir), R=T(red), L=T(0.5))
```

## Computing Multiple Indices
Expand Down
24 changes: 12 additions & 12 deletions docs/src/tutorials/yaxarrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ using YAXArrays, DimensionalData
using SpectralIndices
```

```@ansi yaxarrays
```@example yaxarrays
yaxa = load_dataset("sentinel", YAXArray)
```

As it is possible to observe we have a `YAXArray` object with three dimensions: `bands`, `x` and `y`. Each band is one of the 10 m spectral bands of a Sentinel-2 image.

The data is stored as `Int64`, so let us convert it to `Float` and rescale it:

```@ansi yaxarrays
```@example yaxarrays
yaxa = yaxa./10000
```

Expand All @@ -32,7 +32,7 @@ nothing # hide

now, let's compute the index

```@ansi yaxarrays
```@example yaxarrays
ndvi_compute = compute_index("NDVI"; N=b8, R=b4)
```

Expand All @@ -46,7 +46,7 @@ ndvi_p = NDVI.compute $Float64
```
now, we can compute the index

```@ansi yaxarrays
```@example yaxarrays
ndvi_map = map(ndvi_p, b8, b4)
```
Let's check that we have the same output:
Expand All @@ -70,7 +70,7 @@ out_dims = OutDims("x") # dito
nothing # hide
```

```@ansi yaxarrays
```@example yaxarrays
ndvi_cube = mapCube(ndvi_out, (b8, b4), indims=(in_dims, in_dims),
outdims=OutDims("x", outtype=Float64))
```
Expand All @@ -81,7 +81,7 @@ and we check again the data output matches
ndvi_compute.data == ndvi_cube.data
```

## compute index by named dims
## Computing index by named dims

As usual we can also just feed a properly constructed `YAXArray` to the `compute_index` function. Let's built the array:

Expand All @@ -93,7 +93,7 @@ new_bands_dim = Dim{:Variables}(["R", "N"])
nr_data = cat(yaxa[:, :, index_R], yaxa[:, :, index_N], dims=3)
nothing # hide
```
```@ansi yaxarrays
```@example yaxarrays
new_yaxa = YAXArray((yaxa.x, yaxa.y, new_bands_dim), nr_data)
```

Expand All @@ -102,7 +102,7 @@ new_yaxa = YAXArray((yaxa.x, yaxa.y, new_bands_dim), nr_data)

Now that we have our `YAXArray` with the correctly names `Dim`s we can use it direcly into `compute_index`:

```@ansi yaxarrays
```@example yaxarrays
ndvi = compute_index(
"NDVI", new_yaxa
)
Expand All @@ -124,7 +124,7 @@ kNDVI.reference

Onto the calculations:

```@ansi yaxarrays
```@example yaxarrays
knn = YAXArray((yaxa.x, yaxa.y), fill(1.0, 300, 300));
knr = compute_kernel(
RBF;
Expand All @@ -134,7 +134,7 @@ knr = compute_kernel(
)
```

As always, you can decide to build an `YAXArray` and feed that to the `compute_kernel` function if you prefer:
As always, you can decide to build a `YAXArray` and feed that to the `compute_kernel` function if you prefer:

```@example yaxarrays
a = Float64.(yaxa[bands = At("B08")])
Expand All @@ -146,13 +146,13 @@ params = concatenatecubes([a, b, sigma], kernel_dims)
nothing # hide
```

```@ansi yaxarrays
```@example yaxarrays
knr = compute_kernel(RBF, params)
```

We can finally compute the kNDVI:

```@ansi yaxarrays
```@example yaxarrays
kndvi = compute_index("kNDVI"; kNN = knn, kNR=knr)
```

Expand Down

0 comments on commit f35bd09

Please sign in to comment.