Skip to content

Commit 2885d32

Browse files
authored
Merge pull request #408 from EarthyScience/jp/time-extender
Time Chunk Grabber
2 parents ad6eb7d + b2f3d0e commit 2885d32

File tree

13 files changed

+225
-79
lines changed

13 files changed

+225
-79
lines changed

src/app/globals.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
--glass-bg: rgba(255, 255, 255, 0.15);
8282
--glass-border: rgba(255, 255, 255, 0.25);
8383
--glass-shadow: rgba(0, 0, 0, 0.15);
84+
--play-background: rgb(175, 175, 175);
8485
}
8586

8687
/* Dark Theme */
@@ -137,6 +138,7 @@
137138
--glass-bg: rgba(0, 0, 0, 0.2);
138139
--glass-border: rgba(255, 255, 255, 0.1);
139140
--glass-shadow: rgba(0, 0, 0, 0.3);
141+
--play-background: hsla(0, 0%, 51%, 1);
140142
}
141143

142144
@layer utilities {

src/components/plots/AnalysisWG.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ArrayMinMax, GetCurrentArray } from '@/utils/HelperFuncs';
33
import * as THREE from 'three';
44
import React, { useEffect } from 'react';
55
import { DataReduction, Convolve, Multivariate2D, Multivariate3D, CUMSUM3D, Convolve2D } from '../computation/webGPU';
6-
import { useGlobalStore, useAnalysisStore, usePlotStore, useZarrStore } from '@/utils/GlobalStates';
6+
import { useGlobalStore, useAnalysisStore, usePlotStore } from '@/utils/GlobalStates';
77
import { useShallow } from 'zustand/shallow';
88
import { ZarrDataset } from '../zarr/ZarrLoaderLRU';
99
import { CreateTexture } from '../textures';
@@ -60,7 +60,7 @@ const AnalysisWG = ({ setTexture, ZarrDS }: { setTexture: React.Dispatch<React.S
6060
setAnalysisArray: state.setAnalysisArray, setAnalysisMode: state.setAnalysisMode, setOperation: state.setOperation
6161
})));
6262

63-
const {zSlice, ySlice, xSlice} = useZarrStore(useShallow(state => ({
63+
const {zSlice, ySlice, xSlice} = usePlotStore(useShallow(state => ({
6464
zSlice: state.zSlice,
6565
ySlice: state.ySlice,
6666
xSlice: state.xSlice

src/components/plots/AxisLines.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useAnalysisStore, useGlobalStore, useImageExportStore, usePlotStore, useZarrStore } from '@/utils/GlobalStates'
3+
import { useAnalysisStore, useGlobalStore, useImageExportStore, usePlotStore } from '@/utils/GlobalStates'
44
import React, {useState, useMemo} from 'react'
55
import { useShallow } from 'zustand/shallow'
66
import { Text } from '@react-three/drei'
@@ -35,18 +35,17 @@ const CubeAxis = ({flipX, flipY, flipDown}: {flipX: boolean, flipY: boolean, fli
3535
dataShape: state.dataShape,
3636
revY: state.flipY
3737
})))
38-
const {zSlice, ySlice, xSlice} = useZarrStore(useShallow(state => ({
39-
zSlice: state.zSlice,
40-
ySlice: state.ySlice,
41-
xSlice: state.xSlice
42-
})))
43-
const {xRange, yRange, zRange, plotType, timeScale, animProg} = usePlotStore(useShallow(state => ({
38+
39+
const {xRange, yRange, zRange, plotType, timeScale, animProg, zSlice, ySlice, xSlice} = usePlotStore(useShallow(state => ({
4440
xRange: state.xRange,
4541
yRange: state.yRange,
4642
zRange: state.zRange,
4743
plotType: state.plotType,
4844
timeScale: state.timeScale,
49-
animProg: state.animProg
45+
animProg: state.animProg,
46+
zSlice: state.zSlice,
47+
ySlice: state.ySlice,
48+
xSlice: state.xSlice
5049
})))
5150

5251
const {hideAxis, hideAxisControls} = useImageExportStore(useShallow( state => ({
@@ -344,14 +343,13 @@ const FlatAxis = () =>{
344343
isFlat: state.isFlat
345344
})))
346345

347-
const {plotType} = usePlotStore(useShallow(state=>({
348-
plotType: state.plotType
349-
})))
350-
const {zSlice, ySlice, xSlice} = useZarrStore(useShallow(state => ({
346+
const {plotType, zSlice, ySlice, xSlice} = usePlotStore(useShallow(state=>({
347+
plotType: state.plotType,
351348
zSlice: state.zSlice,
352349
ySlice: state.ySlice,
353350
xSlice: state.xSlice
354351
})))
352+
355353
const {hideAxis, hideAxisControls} = useImageExportStore(useShallow( state => ({
356354
hideAxis: state.hideAxis,
357355
hideAxisControls: state.hideAxisControls

src/components/plots/FlatMap.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import React, {useMemo, useEffect, useRef, useCallback} from 'react'
44
import * as THREE from 'three'
5-
import { useAnalysisStore, useGlobalStore, usePlotStore, useZarrStore } from '@/utils/GlobalStates'
5+
import { useAnalysisStore, useGlobalStore, usePlotStore } from '@/utils/GlobalStates'
66
import { vertShader } from '@/components/computation/shaders'
77
import { flatFrag3D, fragmentFlat } from '../textures/shaders';
88
import { useShallow } from 'zustand/shallow'
@@ -33,25 +33,24 @@ const FlatMap = ({textures, infoSetters} : {textures : THREE.DataTexture | THREE
3333
dataShape: state.dataShape,
3434
textureArrayDepths: state.textureArrayDepths
3535
})))
36-
const {cScale, cOffset, animProg, nanTransparency, nanColor} = usePlotStore(useShallow(state => ({
36+
const {cScale, cOffset, animProg, nanTransparency, nanColor, zSlice, ySlice, xSlice} = usePlotStore(useShallow(state => ({
3737
cOffset: state.cOffset,
3838
cScale: state.cScale,
3939
resetAnim: state.resetAnim,
4040
animate: state.animate,
4141
animProg: state.animProg,
4242
nanTransparency: state.nanTransparency,
43-
nanColor: state.nanColor
43+
nanColor: state.nanColor,
44+
zSlice: state.zSlice,
45+
ySlice: state.ySlice,
46+
xSlice: state.xSlice
4447
})))
4548
const {axis, analysisMode, analysisArray} = useAnalysisStore(useShallow(state=> ({
4649
axis: state.axis,
4750
analysisMode: state.analysisMode,
4851
analysisArray: state.analysisArray
4952
})))
50-
const {zSlice, ySlice, xSlice} = useZarrStore(useShallow(state => ({
51-
zSlice: state.zSlice,
52-
ySlice: state.ySlice,
53-
xSlice: state.xSlice
54-
})))
53+
5554
const dimSlices = [
5655
dimArrays[0].slice(zSlice[0], zSlice[1] ? zSlice[1] : undefined),
5756
dimArrays[1].slice(ySlice[0], ySlice[1] ? ySlice[1] : undefined),

src/components/plots/Plot.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ const Plot = ({ZarrDS}:{ZarrDS: ZarrDataset}) => {
135135
tex.source.data = null
136136
});
137137
}
138+
const {setZSlice, setYSlice, setXSlice} = usePlotStore.getState() // Set the plot slices with zarr slices
139+
setZSlice(zSlice);
140+
setYSlice(ySlice);
141+
setXSlice(xSlice);
138142
ZarrDS.GetArray(variable, {xSlice, ySlice, zSlice}).then((result) => {
139143
const [tempTexture, scaling] = ArrayToTexture({
140144
data: result.data,

src/components/plots/PointCloud.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as THREE from 'three'
33
import { useEffect, useMemo, useState, useRef } from 'react'
44
import { pointFrag, pointVert } from '@/components/textures/shaders'
5-
import { useAnalysisStore, useZarrStore, useGlobalStore, usePlotStore } from '@/utils/GlobalStates';
5+
import { useAnalysisStore, useGlobalStore, usePlotStore } from '@/utils/GlobalStates';
66
import { useShallow } from 'zustand/shallow';
77
import { ZarrDataset } from '../zarr/ZarrLoaderLRU';
88
import { parseUVCoords, getUnitAxis, GetTimeSeries, GetCurrentArray } from '@/utils/HelperFuncs';
@@ -46,24 +46,22 @@ const MappingCube = ({dimensions, ZarrDS, setters} : {dimensions: dimensionsProp
4646
analysisMode: state.analysisMode,
4747
analysisArray: state.analysisArray
4848
})))
49-
const {zSlice, ySlice, xSlice} = useZarrStore(useShallow(state => ({
50-
zSlice: state.zSlice,
51-
ySlice: state.ySlice,
52-
xSlice: state.xSlice
49+
50+
const {timeScale, zSlice, ySlice, xSlice, getColorIdx, incrementColorIdx} = usePlotStore(useShallow(state=> ({
51+
timeScale: state.timeScale,
52+
zSlice: state.zSlice,
53+
ySlice: state.ySlice,
54+
xSlice: state.xSlice,
55+
getColorIdx: state.getColorIdx,
56+
incrementColorIdx: state.incrementColorIdx
5357
})))
58+
5459
const dimSlices = [
5560
dimArrays[0].slice(zSlice[0], zSlice[1] ? zSlice[1] : undefined),
5661
dimArrays[1].slice(ySlice[0], ySlice[1] ? ySlice[1] : undefined),
5762
dimArrays.length > 2 ? dimArrays[2].slice(xSlice[0], xSlice[1] ? xSlice[1] : undefined) : [],
5863
]
5964
const lastNormal = useRef<number | null> ( null )
60-
61-
const {timeScale, getColorIdx, incrementColorIdx} = usePlotStore(useShallow(state=> ({
62-
timeScale: state.timeScale,
63-
getColorIdx: state.getColorIdx,
64-
incrementColorIdx: state.incrementColorIdx
65-
})))
66-
6765
const globalScale = dataShape[2]/500
6866
const offset = 1/500; //I don't really understand that. But the cube is off by one pixel in each dimension
6967

src/components/plots/Sphere.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {useRef, useMemo, useState, useEffect} from 'react'
22
import * as THREE from 'three'
3-
import { useAnalysisStore, useGlobalStore, usePlotStore, useZarrStore } from '@/utils/GlobalStates'
3+
import { useAnalysisStore, useGlobalStore, usePlotStore } from '@/utils/GlobalStates'
44
import { ZarrDataset } from '@/components/zarr/ZarrLoaderLRU';
55
import { useShallow } from 'zustand/shallow'
66
import { sphereVertex, sphereVertexFlat, sphereFrag, flatSphereFrag } from '../textures/shaders'
@@ -51,18 +51,10 @@ export const Sphere = ({textures, ZarrDS} : {textures: THREE.Data3DTexture[] | T
5151
flipY: state.flipY,
5252
textureArrayDepths: state.textureArrayDepths
5353
})))
54-
const {zSlice, ySlice, xSlice} = useZarrStore(useShallow(state => ({
55-
zSlice: state.zSlice,
56-
ySlice: state.ySlice,
57-
xSlice: state.xSlice
58-
})))
59-
const dimSlices = [
60-
dimArrays[0].slice(zSlice[0], zSlice[1] ? zSlice[1] : undefined),
61-
dimArrays[1].slice(ySlice[0], ySlice[1] ? ySlice[1] : undefined),
62-
dimArrays.length > 2 ? dimArrays[2].slice(xSlice[0], xSlice[1] ? xSlice[1] : undefined) : [],
63-
]
54+
6455
const {animate, animProg, cOffset, cScale, selectTS, lonExtent, latExtent,
6556
lonResolution, latResolution, nanColor, nanTransparency, sphereDisplacement, sphereResolution,
57+
zSlice, ySlice, xSlice,
6658
getColorIdx, incrementColorIdx} = usePlotStore(useShallow(state=> ({
6759
animate: state.animate,
6860
animProg: state.animProg,
@@ -77,10 +69,17 @@ export const Sphere = ({textures, ZarrDS} : {textures: THREE.Data3DTexture[] | T
7769
nanTransparency: state.nanTransparency,
7870
sphereDisplacement: state.sphereDisplacement,
7971
sphereResolution: state.sphereResolution,
72+
zSlice: state.zSlice,
73+
ySlice: state.ySlice,
74+
xSlice: state.xSlice,
8075
getColorIdx: state.getColorIdx,
8176
incrementColorIdx: state.incrementColorIdx
8277
})))
83-
78+
const dimSlices = [
79+
dimArrays[0].slice(zSlice[0], zSlice[1] ? zSlice[1] : undefined),
80+
dimArrays[1].slice(ySlice[0], ySlice[1] ? ySlice[1] : undefined),
81+
dimArrays.length > 2 ? dimArrays[2].slice(xSlice[0], xSlice[1] ? xSlice[1] : undefined) : [],
82+
]
8483
const [boundsObj, setBoundsObj] = useState<Record<string, THREE.Vector4>>({})
8584
const [bounds, setBounds] = useState<THREE.Vector4[]>(new Array(10).fill(new THREE.Vector4(-1 , -1, -1, -1)))
8685
const [height, width] = useMemo(()=>isFlat ? dataShape : [dataShape[1], dataShape[2]], [dataShape])

src/components/plots/plotarea/FixedTicks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useThree, useFrame } from '@react-three/fiber'
33
import { useState, useMemo, useEffect, useRef } from 'react'
44
import { parseTimeUnit } from '@/utils/HelperFuncs'
55
import { Fragment } from 'react'
6-
import { useGlobalStore, useZarrStore } from '@/utils/GlobalStates'
6+
import { useGlobalStore, usePlotStore } from '@/utils/GlobalStates'
77
import { useShallow } from 'zustand/shallow'
88

99

@@ -44,7 +44,7 @@ export function FixedTicks({
4444
plotDim:state.plotDim,
4545
valueScales:state.valueScales
4646
})))
47-
const {zSlice, ySlice, xSlice} = useZarrStore(useShallow(state => ({
47+
const {zSlice, ySlice, xSlice} = usePlotStore(useShallow(state => ({
4848
zSlice: state.zSlice,
4949
ySlice: state.ySlice,
5050
xSlice: state.xSlice

src/components/ui/MainPanel/AnalysisOptions.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ const AnalysisOptions = () => {
114114
setAnalysisStore: state.setAnalysisStore, setAnalysisDim: state.setAnalysisDim
115115
})));
116116

117-
const {reFetch, setReFetch} = useZarrStore(useShallow(state => ({
117+
const {reFetch} = useZarrStore(useShallow(state => ({
118118
reFetch: state.reFetch,
119-
setReFetch: state.setReFetch
120119
})))
121120

122121
const [showError, setShowError] = useState<boolean>(false);

src/components/ui/MainPanel/MetaDataInfo.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSi
7171
const {dimArrays, dimNames, dimUnits} = meta.dimInfo
7272
const {maxSize, setMaxSize} = useCacheStore.getState()
7373
const [cacheSize, setCacheSize] = useState(maxSize)
74-
const { zSlice, ySlice, xSlice, reFetch, compress, setZSlice, setYSlice, setXSlice, setReFetch, setCompress } = useZarrStore(useShallow(state => ({
75-
reFetch: state.reFetch,
74+
const { zSlice, ySlice, xSlice, compress, setZSlice, setYSlice, setXSlice, ReFetch, setCompress } = useZarrStore(useShallow(state => ({
7675
zSlice: state.zSlice,
7776
ySlice: state.ySlice,
7877
xSlice: state.xSlice,
7978
compress: state.compress,
8079
setZSlice: state.setZSlice,
8180
setYSlice: state.setYSlice,
8281
setXSlice: state.setXSlice,
83-
setReFetch: state.setReFetch,
82+
ReFetch: state.ReFetch,
8483
setCompress: state.setCompress
8584
})))
8685
const cache = useCacheStore(state => state.cache)
@@ -420,12 +419,12 @@ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSi
420419
disabled={((is4D && idx4D == null) || smallCache)}
421420
onClick={() => {
422421
if (variable == meta.name){
423-
setReFetch(!reFetch)
422+
ReFetch();
424423
}
425424
else{
426425
setMaxSize(cacheSize)
427426
setVariable(meta.name)
428-
setReFetch(!reFetch)
427+
ReFetch();
429428
}
430429
setShowMeta(false)
431430
setOpenVariables(false)

0 commit comments

Comments
 (0)