Skip to content

Commit c27469e

Browse files
committed
add avg to snr, add upload from local
1 parent 422b065 commit c27469e

19 files changed

Lines changed: 708 additions & 118 deletions

src/app/(main)/layout.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// app/(main)/layout.tsx
2+
3+
import { ReactNode } from 'react';
4+
import Navbar from '@/components/Navbar/Navbar';
5+
import Sidebar from '@/components/Sidebar/Sidebar';
6+
import { PlotSettingsProvider } from '@/context/PlotSettingsContext';
7+
8+
export const metadata = {
9+
title: 'JWST Precision Timing',
10+
description: 'Data visualization for JWST time-series analysis',
11+
};
12+
13+
14+
export default function RootLayout({ children }: { children: ReactNode }) {
15+
return (
16+
17+
<div className="flex flex-col min-h-screen">
18+
<PlotSettingsProvider>
19+
<Navbar />
20+
<div className="flex flex-1 overflow-hidden">
21+
<Sidebar />
22+
<main className="flex-1 h-[calc(100vh-52px)] overflow-auto bg-gray-50 ">
23+
{children}
24+
</main>
25+
</div>
26+
</PlotSettingsProvider>
27+
</div>
28+
29+
);
30+
}
Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ const MatrixPage = () => {
1313
labelFontSize,
1414
noOfDataPoint,
1515
selectedSeries,
16+
uploadedDatasets,
17+
viewType,
1618
setSettings
1719
} = usePlotSettings();
20+
useEffect(() => {
21+
setSettings({ viewType: 'matrix' })
22+
}
23+
, []);
1824
const epochs = [...new Set(dataSelection.map(sel => getEpoch(sel)))];
1925
const isValid = dataSelection.length >= 2 && epochs.length === 1;
2026
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -23,24 +29,24 @@ const MatrixPage = () => {
2329
const [lwMatrix, setLwMatrix] = useState<any[] | null>(null);
2430
const [loading, setLoading] = useState(false);
2531
const [error, setError] = useState(false);
26-
const baseHeight = 600;
27-
const extraPerDimension = 120; // adjust as needed
32+
const baseHeight = 600;
33+
const extraPerDimension = 120; // adjust as needed
2834

29-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
30-
const calcPlotHeight = (matrixData: any[]) => {
31-
const dimCount = matrixData.length > 0 ? Object.keys(matrixData[0]).length : 2;
32-
return dataSelection.length > 5
33-
? baseHeight + (dimCount - 2) * extraPerDimension
34-
: baseHeight;
35-
};
35+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
36+
const calcPlotHeight = (matrixData: any[]) => {
37+
const dimCount = matrixData.length > 0 ? Object.keys(matrixData[0]).length : 2;
38+
return dataSelection.length > 5
39+
? baseHeight + (dimCount - 2) * extraPerDimension
40+
: baseHeight;
41+
};
3642
useEffect(() => {
3743
if (!isValid) return;
3844
setLoading(true);
3945
Promise.all([
4046
// process_df('SW', dataType as 'average' | 'raw', dataSelection, noOfDataPoint),
4147
// process_df('LW', dataType as 'average' | 'raw', dataSelection, noOfDataPoint)
42-
process_df('SW', 'raw', dataSelection, noOfDataPoint, selectedSeries),
43-
process_df('LW','raw', dataSelection, noOfDataPoint, selectedSeries)
48+
process_df('SW', 'raw', viewType, dataSelection, noOfDataPoint, selectedSeries, uploadedDatasets),
49+
process_df('LW', 'raw', viewType, dataSelection, noOfDataPoint, selectedSeries, uploadedDatasets)
4450
])
4551
.then(([swData, lwData]) => {
4652
setSwMatrix(swData);
@@ -53,7 +59,7 @@ const calcPlotHeight = (matrixData: any[]) => {
5359
setError(true);
5460
})
5561
.finally(() => setLoading(false));
56-
// }, [dataSelection, dataType, noOfDataPoint]);
62+
// }, [dataSelection, dataType, noOfDataPoint]);
5763
}, [dataSelection, noOfDataPoint]);
5864

5965
return (
@@ -69,7 +75,7 @@ const calcPlotHeight = (matrixData: any[]) => {
6975
) : (
7076
<div className={`grid gap-6 ${dataSelection.length > 5 ? 'grid-rows-2 grid-cols-1' : 'grid-cols-1 lg:grid-cols-2'}`}>
7177
<MatrixPlot
72-
// <D3MatrixPlot
78+
// <D3MatrixPlot
7379
matrixData={swMatrix}
7480
labelFontSize={labelFontSize}
7581
title="SW Scatter Matrix"
@@ -79,7 +85,7 @@ const calcPlotHeight = (matrixData: any[]) => {
7985
/>
8086

8187
<MatrixPlot
82-
// <D3MatrixPlot
88+
// <D3MatrixPlot
8389
matrixData={lwMatrix}
8490
labelFontSize={labelFontSize}
8591
title="LW Scatter Matrix"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function HomePage() {
99
setSettings
1010
} = usePlotSettings();
1111
useEffect(() => {
12-
setSettings({ dataType: [] })
12+
setSettings({ dataType: [], viewType: '2d' })
1313
}
1414
, []);
1515
return (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function SNR() {
88
setSettings
99
} = usePlotSettings();
1010
useEffect(() => {
11-
setSettings({ dataType: ['snr'] })
11+
setSettings({ dataType: [], viewType: 'snr' })
1212
}
1313
, []);
1414

src/app/layout.tsx

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
// app/layout.tsx
2-
import './globals.css';
3-
import { ReactNode } from 'react';
4-
import Navbar from '@/components/Navbar/Navbar';
5-
import Sidebar from '@/components/Sidebar/Sidebar';
6-
import { PlotSettingsProvider } from '@/context/PlotSettingsContext';
7-
export const metadata = {
8-
title: 'JWST Precision Timing',
9-
description: 'Data visualization for JWST time-series analysis',
10-
};
2+
import "./globals.css";
3+
import type { ReactNode } from "react";
114

125
export default function RootLayout({ children }: { children: ReactNode }) {
136
return (
147
<html lang="en">
15-
<body className="bg-white text-gray-900">
16-
<div className="flex flex-col min-h-screen">
17-
<PlotSettingsProvider>
18-
<Navbar />
19-
<div className="flex flex-1 overflow-hidden">
20-
<Sidebar />
21-
<main className="flex-1 h-[calc(100vh-52px)] overflow-auto bg-gray-50 ">
22-
{children}
23-
</main>
24-
</div>
25-
</PlotSettingsProvider>
26-
</div>
8+
<body>
9+
{children}
2710
</body>
2811
</html>
2912
);
30-
}
13+
}

src/components/LightCurvePlot.tsx

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default function LightCurvePlot() {
2828
dataType, dataSelection, xAxis, errorBars, noOfBins, noOfDataPoint,
2929
plotType, pointSize, lineWidth, legendFontSize, labelFontSize, tooltipFontSize,
3030
figure, rawFigure, avgPointRawMap, filterPercent, isRawFilterInside, selectedSeries, rawFilterMode, sigmaK,
31+
uploadedDatasets, viewType,
3132
setSettings
3233
} = usePlotSettings();
3334

@@ -131,14 +132,43 @@ function applyRawFilter(
131132

132133
for (const sel of dataSelection) {
133134
const [epoch, r1, r2] = sel.split('_');
134-
// const makePath = (wave: 'sw' | 'lw') => `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/data/json/ZTF_J1539/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
135-
const makePath = (wave: 'sw' | 'lw') => `${process.env.DATA_PATH}/data/json/${selectedSeries}/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
135+
136+
// // const makePath = (wave: 'sw' | 'lw') => `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/data/json/ZTF_J1539/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
137+
// const makePath = (wave: 'sw' | 'lw') => `${process.env.DATA_PATH}/data/json/${selectedSeries}/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
136138

137139
try {
138-
const [swJson, lwJson] = await Promise.all([
139-
fetch(makePath('sw')).then(r => r.json()),
140-
fetch(makePath('lw')).then(r => r.json())
141-
]);
140+
let swJson;
141+
let lwJson;
142+
143+
if (selectedSeries === 'local') {
144+
const dataset = uploadedDatasets[sel];
145+
146+
if (!dataset) {
147+
console.warn("Missing local dataset:", sel);
148+
continue;
149+
}
150+
151+
if (dataset.type === 'raw') {
152+
swJson = dataset.sw;
153+
lwJson = dataset.lw;
154+
} else {
155+
console.warn("Matrix dataset used in LightCurvePlot:", sel);
156+
continue;
157+
}
158+
159+
} else {
160+
const makePath = (wave: 'sw' | 'lw') =>
161+
`${process.env.DATA_PATH}/data/json/${selectedSeries}/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
162+
163+
[swJson, lwJson] = await Promise.all([
164+
fetch(makePath('sw')).then(r => r.json()),
165+
fetch(makePath('lw')).then(r => r.json())
166+
]);
167+
}
168+
// const [swJson, lwJson] = await Promise.all([
169+
// fetch(makePath('sw')).then(r => r.json()),
170+
// fetch(makePath('lw')).then(r => r.json())
171+
// ]);
142172

143173
const timeKey = xKeyMap[xAxis];
144174
for (const dType of dataTypeSorted) {
@@ -161,7 +191,7 @@ function applyRawFilter(
161191
// markerBorderColor = '#000000';
162192
// lineColor = '#000000';
163193
}
164-
const { traces: traceSW, patch: patchSW } = addTrace({ wave: 'SW', json: swJson, axis: xAxis, mode: dType, noOfBins, noOfDataPoint, timeKey, epoch, r_in: r1, r_out: r2, avgPointRawMap, markerFillColor, markerBorderColor, lineColor, plotType: plotType as 'lines' | 'markers' | 'lines+markers', errorBars: errorBars as 'bar' | 'hide' | 'separate' | undefined, pointSize, lineWidth, dataMode });
194+
const { traces: traceSW, patch: patchSW } = addTrace({ wave: 'SW', json: swJson, axis: xAxis, mode: dType, viewType: viewType, noOfBins, noOfDataPoint, timeKey, epoch, r_in: r1, r_out: r2, avgPointRawMap, markerFillColor, markerBorderColor, lineColor, plotType: plotType as 'lines' | 'markers' | 'lines+markers', errorBars: errorBars as 'bar' | 'hide' | 'separate' | undefined, pointSize, lineWidth, dataMode });
165195
rawTracesSW.push(...traceSW);
166196
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
167197
// @ts-expect-error
@@ -185,7 +215,7 @@ function applyRawFilter(
185215
)
186216
}
187217
}));
188-
const { traces: traceLW, patch: patchLW } = addTrace({ wave: 'LW', json: lwJson, axis: xAxis, mode: dType, noOfBins, noOfDataPoint, timeKey, epoch, r_in: r1, r_out: r2, avgPointRawMap, markerFillColor, markerBorderColor, lineColor, plotType: plotType as 'lines' | 'markers' | 'lines+markers', errorBars: errorBars as 'bar' | 'hide' | 'separate' | undefined, pointSize, lineWidth, dataMode });
218+
const { traces: traceLW, patch: patchLW } = addTrace({ wave: 'LW', json: lwJson, axis: xAxis, mode: dType, viewType: viewType, noOfBins, noOfDataPoint, timeKey, epoch, r_in: r1, r_out: r2, avgPointRawMap, markerFillColor, markerBorderColor, lineColor, plotType: plotType as 'lines' | 'markers' | 'lines+markers', errorBars: errorBars as 'bar' | 'hide' | 'separate' | undefined, pointSize, lineWidth, dataMode });
189219
rawTracesLW.push(...traceLW);
190220

191221
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -773,9 +803,14 @@ function applyRawFilter(
773803
// const imgThumbnailsSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/thumbnails/ZTF_J1539/${first.cd.filename}`;
774804
// const imgThumbnailsSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${first.cd.filename}`;
775805
// const imgSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${first.cd.filename}`;
776-
const imgThumbnailsSrc = `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${first.cd.filename}`;
777-
const imgSrc = `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${first.cd.filename}`;
778-
806+
807+
808+
// const imgThumbnailsSrc = `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${first.cd.filename}`;
809+
// const imgSrc = `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${first.cd.filename}`;
810+
811+
// TODO: fix hard code on selected series here
812+
const imgThumbnailsSrc = `${process.env.DATA_PATH}/img/full-size/ZTF_J1539/${first.cd.filename}`;
813+
const imgSrc = `${process.env.DATA_PATH}/img/full-size/ZTF_J1539/${first.cd.filename}`;
779814
setSelectedImages(prev =>
780815
prev.map(p => ({
781816
...p,

0 commit comments

Comments
 (0)