Skip to content

Instantly share code, notes, and snippets.

@oeway
Created January 22, 2020 17:00
Show Gist options
  • Save oeway/04c737a60db6dbf8961c4704b077a04c to your computer and use it in GitHub Desktop.
Save oeway/04c737a60db6dbf8961c4704b077a04c to your computer and use it in GitHub Desktop.
<docs>
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "Zarr-Demo",
"type": "iframe",
"tags": [],
"ui": "",
"version": "0.1.0",
"cover": "",
"description": "[TODO: describe this plugin with one sentence.]",
"icon": "extension",
"inputs": null,
"outputs": null,
"api_version": "0.1.7",
"env": "",
"permissions": [],
"requirements": ["https://unpkg.com/zarr/dist/zarr.umd.js"],
"dependencies": []
}
</config>
<script lang="javascript">
class ImJoyPlugin {
async setup() {
api.log('initialized')
}
async run(ctx) {
const store = new zarr.ObjectStore();
const myZarrArray = await zarr.ones([3, 4], { store, chunks: [1, 2] });
console.log(myZarrArray.chunks); // [1, 2]
const arr = await myZarrArray.get([zarr.slice(0, 2)]);
console.log(arr instanceof zarr.NestedArray); // true
console.log(arr.shape); // [2, 4]
try{
const z = await zarr.openArray({
store: "https://cors-anywhere.herokuapp.com/https://zarr-demo.s3-eu-west-2.amazonaws.com/",
path: "store/foo/bar/baz/",
mode: 'r'
});
console.log(z);
api.alert('open array done!')
}
catch(e){
console.error(e)
}
// try{
// const z = await zarr.openArray({
// store: "https://cors-anywhere.herokuapp.com/https://storage.googleapis.com/pangeo-data/",
// path: "CMIP6_3hr/BCC-CSM2-MR/historical/r1i1p1f1/pr/lat",
// mode: 'r'
// });
// console.log(z);
// api.alert('open group done!')
// }
// catch(e){
// console.error(e)
// }
// try{
// const g = await zarr.openGroup("https://cors-anywhere.herokuapp.com/https://storage.googleapis.com/pangeo-data/", "CMIP6_3hr/BCC-CSM2-MR/historical/r1i1p1f1/pr", "r");
// console.log(g);
// api.alert('open group done!'+g.name)
// }
// catch(e){
// console.error(e)
// }
// try{
// const g = await zarr.openGroup("https://cors-anywhere.herokuapp.com/https://zarr-demo.s3-eu-west-2.amazonaws.com/", "store", "r");
// console.log(g);
// api.alert('open group done!'+g.name)
// }
// catch(e){
// console.error(e)
// }
}
}
api.export(new ImJoyPlugin())
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment