@@ -12,7 +12,8 @@ export async function GetArray(varOveride?: string) {
1212 const { idx4D, initStore, variable, setProgress, setStrides, setStatus } = useGlobalStore . getState ( ) ;
1313 const { compress, xSlice, ySlice, zSlice, coarsen, kernelSize, kernelDepth, fetchNC, setCurrentChunks, setArraySize } = useZarrStore . getState ( ) ;
1414 const { cache } = useCacheStore . getState ( ) ;
15- const fetcher = fetchNC ? NCFetcher ( ) : zarrFetcher ( )
15+ const useNC = initStore . startsWith ( "local" ) && fetchNC // In case a user has NetCDF switched but then goes to a remote
16+ const fetcher = useNC ? NCFetcher ( ) : zarrFetcher ( )
1617 const targetVariable = varOveride ?? variable ;
1718 const meta = await fetcher . getMetadata ( targetVariable ) ;
1819 const { shape, chunkShape, fillValue, dtype } = meta ;
@@ -69,15 +70,26 @@ export async function GetArray(varOveride?: string) {
6970
7071 if ( isCacheValid ) {
7172 const chunkData = cachedChunk . compressed ? DecompressArray ( cachedChunk . data ) : cachedChunk . data . slice ( ) ;
72- copyChunkToArray (
73- chunkData ,
74- cachedChunk . shape ,
75- cachedChunk . stride ,
76- typedArray ,
77- outputShape ,
78- destStride as any , [ z , y , x ] ,
79- [ zDim . start , yDim . start , xDim . start ]
80- ) ;
73+ if ( hasZ ) {
74+ copyChunkToArray (
75+ chunkData ,
76+ cachedChunk . shape ,
77+ cachedChunk . stride ,
78+ typedArray ,
79+ outputShape ,
80+ destStride as any , [ z , y , x ] ,
81+ [ zDim . start , yDim . start , xDim . start ]
82+ )
83+ } else {
84+ copyChunkToArray2D (
85+ chunkData ,
86+ cachedChunk . shape ,
87+ cachedChunk . stride ,
88+ typedArray ,
89+ outputShape ,
90+ destStride as any , [ y , x ] ,
91+ [ yDim . start , xDim . start ] )
92+ }
8193 } else {
8294 const raw = await fetcher . fetchChunk ( { variable :targetVariable , rank, shape, chunkShape, x, y, z, xDimIndex, yDimIndex, zDimIndex, idx4D } ) ;
8395
@@ -124,7 +136,6 @@ export async function GetArray(varOveride?: string) {
124136 }
125137 }
126138 }
127-
128139 setProgress ( 0 ) ;
129140 return { data : typedArray , shape : outputShape , dtype, scalingFactor } ;
130141}
0 commit comments