Skip to content

Commit 437f651

Browse files
authored
Merge pull request #584 from EarthyScience/jp/2d-nc
2d Is go
2 parents 602487d + d92b52c commit 437f651

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/components/zarr/NCGetters.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useZarrStore } from "@/GlobalStates/ZarrStore";
22
import { useCacheStore } from "@/GlobalStates/CacheStore";
33
import { useGlobalStore } from "@/GlobalStates/GlobalStore";
44
import { useErrorStore } from "@/GlobalStates/ErrorStore";
5-
import { ToFloat16, CompressArray, DecompressArray, copyChunkToArray, RescaleArray } from "./ZarrLoaderLRU";
5+
import { ToFloat16, CompressArray, DecompressArray, copyChunkToArray, RescaleArray, copyChunkToArray2D } from "./ZarrLoaderLRU";
66
import { Convolve } from "../computation/webGPU";
77
import {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,

src/hooks/useDataFetcher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const useDataFetcher = () => {
7373

7474
//---- Main Fetch ----//
7575
GetArray().then((result) => {
76-
const shape = result.shape;
76+
const shape = result.shape.filter((val) => val != 1);
7777
const [tempTexture, scaling] = ArrayToTexture({
7878
data: result.data,
7979
shape

0 commit comments

Comments
 (0)