gzuidhof / zarr.js

Javascript implementation of Zarr
https://guido.io/zarr.js
Apache License 2.0
133 stars 23 forks source link

Unable to open main zarr? #148

Closed TheJeran closed 11 months ago

TheJeran commented 11 months ago

Am I dumb or does this not work as expected? I'm coming from a python background so I'm not super familiar with this library.

When I load in a zarr it looks for the .zarray file in the main zarr directory. Which is not where they are stored. It's stored in the variable subdirectories. I'm not familiar with zarr v2 vs v3. But is this a v2/v3 issue?

import { HTTPStore, openArray } from "zarr";

const store = new HTTPStore('http://localhost:5173/germany_tree_age.zarr')
const z = await openArray({ store });
console.log(z)

throws error

http://localhost:5173/germany_tree_age.zarr/.zarray net::ERR_ABORTED 404 (Not Found)

however I can get values using

const store = new HTTPStore('http://localhost:5173/germany_tree_age.zarr/ForestAge_TC010')

but this seems a bit broken. As I have no coordinate information.

Is this working as expected?

manzt commented 11 months ago

This works as expected and is not related to zarr v2 or v3 (Zarr.js only support v2). openArray is desired to open an array (i.e., .zarray) the root of the store you provided is a group (which should contains a .zgroup key).

import { HTTPStore , openGroup } from "zarr";
const store = new HTTPStore('http://localhost:5173/germany_tree_age.zarr');
const z = await openGroup({ store }); // open a group
const arr = await z.getItem("ForestAge_TC010"); // open a path relative to the group (could return group or array)

Or you can directly open an array from a path with openArray via:

import { HTTPStore , openArray } from "zarr";
const store = new HTTPStore('http://localhost:5173/germany_tree_age.zarr');
const z = await openArray({ store, path: "ForestAge_TC010" }); // open an array directly from the store
TheJeran commented 11 months ago

Awesome thank you!