@@ -2,7 +2,7 @@ import { useZarrStore } from "@/GlobalStates/ZarrStore";
22import { useCacheStore } from "@/GlobalStates/CacheStore" ;
33import { useGlobalStore } from "@/GlobalStates/GlobalStore" ;
44import { useErrorStore } from "@/GlobalStates/ErrorStore" ;
5- import { ToFloat16 , CompressArray , DecompressArray , copyChunkToArray , RescaleArray } from "./ZarrLoaderLRU" ;
5+ import { ToFloat16 , CompressArray , DecompressArray , copyChunkToArray , RescaleArray , copyChunkToArray2D } from "./ZarrLoaderLRU" ;
66import { Convolve } from "../computation/webGPU" ;
77import { coarsen3DArray , calculateStrides , TypedArray } from '@/utils/HelperFuncs'
88
@@ -187,10 +187,8 @@ export async function GetNCArray(variable: string){
187187 let chunkArray = await ncModule . getSlicedVariableArray ( variable , starts , counts )
188188 const chunkType = chunkArray . constructor . name
189189 const isInt = chunkType . includes ( "int" )
190- let chunkStride = rank > 3
191- ? [ counts [ 3 ] * counts [ 2 ] , counts [ 3 ] , 1 ]
192- : [ counts [ 2 ] * counts [ 1 ] , counts [ 2 ] , 1 ]
193190 let thisShape = counts
191+ let chunkStride = calculateStrides ( thisShape )
194192 const filterValues = ( array : TypedArray ) => {
195193 for ( let i = 0 ; i < array . length ; i ++ ) {
196194 if ( array [ i ] === fillValue && ! isInt ) array [ i ] = NaN
@@ -236,7 +234,7 @@ export async function GetNCArray(variable: string){
236234 }
237235 }
238236 }
239- copyChunkToArray (
237+ if ( hasZ ) copyChunkToArray (
240238 chunkF16 ,
241239 thisShape ,
242240 chunkStride as [ number , number , number ] ,
@@ -246,6 +244,16 @@ export async function GetNCArray(variable: string){
246244 [ z , y , x ] ,
247245 [ zDim . start , yDim . start , xDim . start ] ,
248246 )
247+ else copyChunkToArray2D (
248+ chunkF16 ,
249+ thisShape ,
250+ chunkStride as [ number , number ] ,
251+ typedArray ,
252+ outputShape ,
253+ destStride as [ number , number ] ,
254+ [ y , x ] ,
255+ [ yDim . start , xDim . start ] ,
256+ )
249257 const cacheChunk = {
250258 data : compress ? CompressArray ( chunkF16 , 7 ) : chunkF16 ,
251259 shape : chunkShape ,
0 commit comments