From 5e1ce063984129070197439d8ad46ec771812ce0 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 4 Jul 2024 12:26:46 +0100 Subject: [PATCH] Check dimension_names for all zarr.json --- .../MultiscaleArrays/Multiscale.svelte | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/JsonValidator/MultiscaleArrays/Multiscale.svelte b/src/JsonValidator/MultiscaleArrays/Multiscale.svelte index 97e5130..e9fc440 100644 --- a/src/JsonValidator/MultiscaleArrays/Multiscale.svelte +++ b/src/JsonValidator/MultiscaleArrays/Multiscale.svelte @@ -15,6 +15,7 @@ const permitDtypeMismatch = ["0.1", "0.2", "0.3", "0.4"].includes(version); const checkDimSeparator = ["0.2", "0.3", "0.4"].includes(version); + const allowMissingDimNames = ["0.1", "0.2", "0.3", "0.4"].includes(version); function allEqual(items) { return items.every((value) => value == items[0]); @@ -29,11 +30,12 @@ let dimCounts = []; let shapes = []; let dimSeparators = []; + let zarrayJsonList = []; for (let i = 0; i < datasets.length; i++) { let dataset = datasets[i]; let zarray = await getZarrArrayJson(source + "/" + dataset.path); - console.log('zarray', zarray); + zarrayJsonList.push(zarray); // Need to handle Zarr v2 and Zarr v3: dimCounts.push(zarray.shape.length); dtypes.push(zarray.dtype || zarray.data_type); @@ -74,6 +76,24 @@ }); } }); + + if (!allowMissingDimNames) { + let axesNames = JSON.stringify(axes.map(axis => axis.name)); + zarrayJsonList.forEach((arrData, i) => { + let msg; + if (!arrData.dimension_names) { + msg = `No dimension_names found for dataset ${i}`; + } else { + let dimNames = JSON.stringify(arrData.dimension_names); + if (dimNames != axesNames) { + msg = `dimension_names: ${dimNames} don't match axes names: ${axesNames}`; + } + } + if (msg) { + checks.push({msg}); + } + }); + } } if (checkDimSeparator) { dimSeparators.forEach((sep) => {