Skip to content

Commit

Permalink
Update to zarrita.js 0.4.0-next.14
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Jun 25, 2024
1 parent 1054356 commit f650c1e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 39 deletions.
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"ndarray": "^1.0.19",
"svelte-icons-pack": "^1.4.6",
"svelte-simple-modal": "^1.4.1",
"zarrita": "^0.4.0-next.13"
"zarrita": "^0.4.0-next.14"
}
}
18 changes: 5 additions & 13 deletions src/JsonValidator/MultiscaleArrays/ZarrArray/ChunkLoader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { range, getChunkShape } from "../../../utils";
import { get, writable } from "svelte/store";
import ChunkViewer from "./ChunkViewer.svelte";
// import * as zarr from "zarrita";
import * as zarr from "zarrita";
import { slice } from "@zarrita/indexing";
Expand Down Expand Up @@ -41,34 +41,26 @@
chunk = undefined;
// Use zarr like this, otherwise we get "Error: Unknown codec: bytes"
let zarr = await import("https://cdn.jsdelivr.net/npm/zarrita@next/+esm");
// let zarr = await import("https://cdn.jsdelivr.net/npm/zarrita@next/+esm");
let url = source + "/" + zarrPath;
const store = new zarr.FetchStore(url);
console.log("store", store)
const arr = await zarr.open(store, { kind: "array" });
console.log("arr", arr)
const view = await zarr.get(arr, [0, 0, null, null]);
console.log("view", view)
// we want to get exactly 1 chunk
// e.g. chunkIndices is (0, 1, 0, 0) and chunk is (1, 125, 125, 125)
// we want to get [0, 125:250, 0:125, 0:125]
console.log('arr', arr, arr.chunks);
let ch = arr.chunks;
const indices = get(chunkIndices);
console.log('indices', indices);
let slices = indices.map((index, dim) => {
if (ch[dim] > 1) {
console.log('dim', dim, 'slice', index * ch[dim], (index + 1) * ch[dim])
return slice(index * ch[dim], (index + 1) * ch[dim]);
} else {
console.log('-', index * ch[dim])
return index * ch[dim];
return index;
}
});
// Updating chunk will trigger ChunkViewer to re-render
console.log("loading chunk", slices)
chunk = await zarr.get(arr, slices);
console.log("slices chunk2", chunk);
}
chunkIndices.subscribe(function () {
Expand Down

0 comments on commit f650c1e

Please sign in to comment.