Created
June 23, 2025 06:47
-
-
Save meggart/f113419adea7a0b4fa415aec6b110b0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using NetCDF, YAXArrays | |
import DiskArrayEngine as DAE | |
ds = open_dataset("/Net/Groups/BGI/data/DataStructureMDI/DATA/Incoming/ESACCI/LC/v2_1_1/orgdata/C3S-LC-L4-LCCS-Map-300m-P1Y-2020-v2.1.1.nc") | |
lc = ds.lccs_class | |
c = YAXArrays.counter(lc) | |
using Distributed | |
addprocs(16) | |
@everywhere begin | |
using Pkg; Pkg.activate(@__DIR__) | |
using NetCDF, YAXArrays, Distributed | |
end | |
@time res = compute(c,runner=DAE.DaggerRunner) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flox.xarray import xarray_reduce | |
import dask | |
from dask.distributed import Client, LocalCluster | |
cluster = LocalCluster(n_workers=16,threads_per_worker=1) | |
client = Client(cluster) | |
import xarray as xr | |
ds = xr.open_dataset("/Net/Groups/BGI/data/DataStructureMDI/DATA/Incoming/ESACCI/LC/v2_1_1/orgdata/C3S-LC-L4-LCCS-Map-300m-P1Y-2020-v2.1.1.nc") | |
#Need to chunk manually, otherwise it breaks | |
lc = ds.lccs_class.chunk(lon=2000,lat=2000) | |
a = xr.DataArray(dask.array.ones(lc.shape),dims=lc.dims,coords=lc.coords) | |
res = xarray_reduce(a,lc,func="sum",expected_groups=range(255)).compute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment