Skip to content

Add DiskArrayEngine-based xmap function #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CFTime = "179af706-886a-5703-950a-314cd64e0468"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
DiskArrayEngine = "2d4b2e14-ccd6-4284-b8b0-2378ace7c126"
DiskArrayTools = "fcd2136c-9f69-4db6-97e5-f31981721d63"
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
SkipNan = "aed68c70-c8b0-4309-8cd1-d392a74f991a"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
WeightedOnlineStats = "bbac0a1f-7c9d-5672-960b-c6ca726e5d5d"
YAXArrayBase = "90b8fcef-0c2d-428d-9c56-5f86629e9d14"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/UserGuide/compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Reduce the time dimension by calculating the average value of all points in time

````@example compute
import Statistics: mean
mapslices(mean, a, dims="Time")
mapslices(mean, a, dims="time")
````
There is no time dimension left, because there is only one value left after averaging all time steps.
We can also calculate spatial means resulting in one value per time step:
Expand Down
20 changes: 13 additions & 7 deletions docs/src/UserGuide/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,39 @@ sum_days = sum.(g_tempo, dims=:time)

Weight the seasonal groups by `sum_days`

````@ansi compareXarray
::: danger WIP

DiskArrayEngine fails from here on...

:::

````julia compareXarray
weights = map(./, g_tempo, sum_days)
````

Verify that the sum per season is 1

````@ansi compareXarray
````julia compareXarray
sum.(weights)
````
### weighted seasons

Now, let's weight the seasons

````@ansi compareXarray
````julia compareXarray
g_dsW = broadcast_dims.(*, weights, g_ds)
````

apply a `sum` over the time dimension and drop it

````@ansi compareXarray
````julia compareXarray
weighted_g = sum.(g_dsW, dims = :time);
weighted_g = dropdims.(weighted_g, dims=:time)
````

Calculate the differences

````@ansi compareXarray
````julia compareXarray
diff_g = map(.-, weighted_g, mean_g)
````

Expand All @@ -164,7 +170,7 @@ mean_g, weighted_g, diff_g, seasons_g = weighted_seasons(ds)

Once all calculations are done we can plot the results with `Makie.jl` as follows:

````@example compareXarray
````julia compareXarray
using CairoMakie
# define plot arguments/attributes
colorrange = (-30,30)
Expand All @@ -174,7 +180,7 @@ lowclip = :grey15
cb_label = ds_o.properties["long_name"]
````

````@example compareXarray
````julia compareXarray
with_theme(theme_ggplot2()) do
hm_o, hm_d, hm_w = nothing, nothing, nothing
# the figure
Expand Down
2 changes: 1 addition & 1 deletion docs/src/UserGuide/read.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ ds = open_mfdataset(DD.DimArray(files, YAX.time()))

where the contents of the `time` dimension are the merged values from both files

````@ansi open_list_netcdf
````@example open_list_netcdf
ds["time"]
````

Expand Down
Loading
Loading