Skip to content

Commit a1b577a

Browse files
committed
added selectedSeries
1 parent a6ede6a commit a1b577a

File tree

10 files changed

+49
-20
lines changed

10 files changed

+49
-20
lines changed

next.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const isGithubActions = process.env.GITHUB_ACTIONS === 'true';
55
// Default values
66
let assetPrefix = '';
77
let basePath = '';
8+
let dataPath = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main`;
89

910
if (isProduction || isGithubActions) {
1011
const repo = process.env.GITHUB_REPOSITORY ?.replace(/.*?\//, '') || process.env.NEXT_PUBLIC_REPO_NAME;
@@ -29,7 +30,7 @@ const nextConfig = {
2930
assetPrefix: assetPrefix,
3031
trailingSlash: true,
3132
env: {
32-
BASE_PATH: basePath,
33+
DATA_PATH: dataPath,
3334
},
3435

3536
async headers() {

src/app/matrix/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const MatrixPage = () => {
1212
dataSelection,
1313
labelFontSize,
1414
noOfDataPoint,
15+
selectedSeries,
1516
setSettings
1617
} = usePlotSettings();
1718
const epochs = [...new Set(dataSelection.map(sel => getEpoch(sel)))];
@@ -38,8 +39,8 @@ const calcPlotHeight = (matrixData: any[]) => {
3839
Promise.all([
3940
// process_df('SW', dataType as 'average' | 'raw', dataSelection, noOfDataPoint),
4041
// process_df('LW', dataType as 'average' | 'raw', dataSelection, noOfDataPoint)
41-
process_df('SW', 'raw', dataSelection, noOfDataPoint),
42-
process_df('LW','raw', dataSelection, noOfDataPoint)
42+
process_df('SW', 'raw', dataSelection, noOfDataPoint, selectedSeries),
43+
process_df('LW','raw', dataSelection, noOfDataPoint, selectedSeries)
4344
])
4445
.then(([swData, lwData]) => {
4546
setSwMatrix(swData);

src/components/LightCurvePlot.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export default function LightCurvePlot() {
2727
const {
2828
dataType, dataSelection, xAxis, errorBars, noOfBins, noOfDataPoint,
2929
plotType, pointSize, lineWidth, legendFontSize, labelFontSize, tooltipFontSize,
30-
figure, rawFigure, avgPointRawMap, filterPercent, isFiltered, setSettings
30+
figure, rawFigure, avgPointRawMap, filterPercent, isFiltered, selectedSeries,
31+
setSettings
3132
} = usePlotSettings();
3233

3334
const [loading, setLoading] = useState(false);
@@ -95,7 +96,8 @@ export default function LightCurvePlot() {
9596

9697
for (const sel of dataSelection) {
9798
const [epoch, r1, r2] = sel.split('_');
98-
const makePath = (wave: 'sw' | 'lw') => `${process.env.BASE_PATH}/data/json/ZTF_J1539/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
99+
// const makePath = (wave: 'sw' | 'lw') => `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/data/json/ZTF_J1539/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
100+
const makePath = (wave: 'sw' | 'lw') => `${process.env.DATA_PATH}/data/json/${selectedSeries}/rawdata/${epoch}/${wave}/${r1}/${r2}.json`;
99101

100102
try {
101103
const [swJson, lwJson] = await Promise.all([
@@ -613,8 +615,10 @@ export default function LightCurvePlot() {
613615

614616
if (!exist) {
615617
// const imgThumbnailsSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/thumbnails/ZTF_J1539/${first.cd.filename}`;
616-
const imgThumbnailsSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${first.cd.filename}`;
617-
const imgSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${first.cd.filename}`;
618+
// const imgThumbnailsSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${first.cd.filename}`;
619+
// const imgSrc = `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${first.cd.filename}`;
620+
const imgThumbnailsSrc = `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${first.cd.filename}`;
621+
const imgSrc = `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${first.cd.filename}`;
618622

619623
setSelectedImages(prev =>
620624
prev.map(p => ({
@@ -721,7 +725,7 @@ export default function LightCurvePlot() {
721725
// eslint-disable-next-line @typescript-eslint/no-explicit-any
722726
function handleHover(e: any) {
723727
const pt = e.points[0];
724-
console.log('Hover data:', pt);
728+
// console.log('Hover data:', pt);
725729
const cd = pt.customdata ?? {};
726730

727731
const hoverData = {

src/components/Matrix/PlotlyMatrixPlotWithImg.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const MatrixPlot = (props: MatrixPlotProps) => {
7474
const [userAnnotations, setUserAnnotations] = useState<Partial<Plotly.Annotations>[]>([]);
7575

7676

77-
const { colorBy, focusRangeMax, setSettings, focusRangeMaxManuallySet } = usePlotSettings();
77+
const { colorBy, focusRangeMax, setSettings, selectedSeries, focusRangeMaxManuallySet } = usePlotSettings();
7878
if (!matrixData || matrixData.length === 0) return null;
7979

8080
const dimensions = Object.keys(matrixData[0]).filter(k => !k.endsWith('__err') && !k.endsWith('__cd') && !k.endsWith("__patch"));
@@ -241,7 +241,8 @@ const MatrixPlot = (props: MatrixPlotProps) => {
241241
};
242242

243243
setImageModal({
244-
imgSrc: `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${firstFilename}`,
244+
// imgSrc: `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${firstFilename}`,
245+
imgSrc: `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${firstFilename}`,
245246
label: firstFilename,
246247
filename: firstFilename,
247248
details,

src/components/Matrix/PlotlyMatrixPlotWithImgWithColor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const MatrixPlot = (props: MatrixPlotProps) => {
7171
// keep a handle to the GraphDiv
7272
const [gd, setGd] = useState<Plotly.PlotlyHTMLElement | null>(null);
7373

74-
const { colorBy, focusRangeMax, setSettings, focusRangeMaxManuallySet } = usePlotSettings();
74+
const { colorBy, focusRangeMax, setSettings, focusRangeMaxManuallySet, selectedSeries } = usePlotSettings();
7575
if (!matrixData || matrixData.length === 0) return null;
7676

7777
const dimensions = Object.keys(matrixData[0]).filter(k => !k.endsWith('__err') && !k.endsWith('__cd') && !k.endsWith("__patch"));
@@ -179,7 +179,8 @@ const MatrixPlot = (props: MatrixPlotProps) => {
179179
};
180180

181181
setImageModal({
182-
imgSrc: `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${firstFilename}`,
182+
// imgSrc: `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${firstFilename}`,
183+
imgSrc: `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${firstFilename}`,
183184
label: firstFilename,
184185
filename: firstFilename,
185186
details,

src/components/Navbar/Navbar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export default function Navbar() {
2121
}
2222

2323
const mainLinks = [
24-
{ name: '2D Plot', href: `${process.env.BASE_PATH}/`, id: '2d-plot-link', disabled: false },
25-
{ name: 'Matrix', href: `${process.env.BASE_PATH}/matrix/`, id: 'matrix-link', disabled: false },
26-
{ name: 'Signal-to-noise', href: `${process.env.BASE_PATH}/noise`, id: 'noise-link', disabled: true },
24+
{ name: '2D Plot', href: `${process.env.DATA_PATH}/`, id: '2d-plot-link', disabled: false },
25+
{ name: 'Matrix', href: `${process.env.DATA_PATH}/matrix/`, id: 'matrix-link', disabled: false },
26+
{ name: 'Signal-to-noise', href: `${process.env.DATA_PATH}/noise`, id: 'noise-link', disabled: true },
2727
]
2828
// const settingsLink = { name: 'Settings', href: '#', id: 'settings-link' }
2929

src/components/Sidebar/Sidebar.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ import { usePathname } from 'next/navigation';
99
const visibilityByPath: Record<string, Partial<Record<string, boolean>>> = {
1010
'/': {
1111
dataType: true,
12+
selectedSeries: true,
1213
dataSelection: true,
1314
averageConfig: true,
1415
xAxis: true,
1516
errorBars: true,
1617
},
1718
'/matrix/': {
1819
dataType: false,
20+
selectedSeries: true,
1921
dataSelection: true,
2022
averageConfig: true,
2123
matrixSection: false,
2224
},
2325
'/matrix_plotly/': {
2426
dataType: true,
27+
selectedSeries: true,
2528
dataSelection: true,
2629
averageConfig: true,
2730
matrixSection: false,
@@ -34,7 +37,7 @@ const visibilityByPath: Record<string, Partial<Record<string, boolean>>> = {
3437

3538
export default function Sidebar() {
3639
const {
37-
dataType, dataSelection, xAxis, errorBars, noOfBins, noOfDataPoint, colorBy, filterPercent, isFiltered, setSettings,
40+
dataType, dataSelection, xAxis, errorBars, noOfBins, noOfDataPoint, colorBy, filterPercent, isFiltered, selectedSeries, setSettings,
3841
// focusRangeMax
3942
} = usePlotSettings();
4043

@@ -48,7 +51,8 @@ export default function Sidebar() {
4851
useEffect(() => {
4952
async function loadDataList() {
5053
try {
51-
const res = await fetch(`${process.env.BASE_PATH}/data/json/ZTF_J1539/dataList.json`);
54+
// const res = await fetch(`https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/data/json/ZTF_J1539/dataList.json`);
55+
const res = await fetch(`${process.env.DATA_PATH}/data/json/${selectedSeries}/dataList.json`);
5256
const docs = await res.json();
5357
setDataList(docs.map((d: string) => ({ label: d, value: d })));
5458
} catch (err) {
@@ -60,6 +64,10 @@ export default function Sidebar() {
6064
loadDataList();
6165
}, []);
6266

67+
const seriesOptions = [
68+
{ value: 'ZTF_J1539', label: 'ZTF_J1539' },
69+
];
70+
6371
const dataTypeOptions = [
6472
{ value: 'average', label: 'Average' },
6573
{ value: 'raw', label: 'Raw' },
@@ -126,6 +134,16 @@ export default function Sidebar() {
126134
/>
127135
</div>)
128136
}
137+
{visibility.selectedSeries && (
138+
<div className="space-y-1 mb-4">
139+
<label className="font-semibold block mb-1">Series</label>
140+
<Select
141+
options={seriesOptions}
142+
value={seriesOptions.find((o) => o.value === selectedSeries)}
143+
onChange={(val) => setSettings({ selectedSeries: val?.value || 'ZTF_J1539' })}
144+
/>
145+
</div>)
146+
}
129147
{/* Data Selection */}
130148
{visibility.dataSelection && (
131149
<div className="space-y-1 mb-4">

src/constants/hoverUtils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { usePlotSettings } from '@/context/PlotSettingsContext';
44

55
// eslint-disable-next-line @typescript-eslint/no-explicit-any
66
export const RenderTooltip: React.FC<{ cd: Record<string, any> }> = ({ cd }) => {
7-
const { tooltipFontSize, thumbnailsSize } = usePlotSettings();
7+
const { tooltipFontSize, thumbnailsSize, selectedSeries } = usePlotSettings();
88

99
if (!cd) return null;
1010

1111
const imgSrc = cd.filename
1212
// ? `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/thumbnails/ZTF_J1539/${cd.filename}`
13-
? `https://raw.githubusercontent.com/iDataVisualizationLab/jwst-data/main/img/full-size/ZTF_J1539/${cd.filename}`
13+
? `${process.env.DATA_PATH}/img/full-size/${selectedSeries}/${cd.filename}`
1414
: null;
1515

1616
return (

src/context/PlotSettingsContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { createContext, useContext, useState } from 'react';
44
import { PlotTrace, PlotLayout } from '@/types/PlotTypes';
55

66
type PlotSettings = {
7+
selectedSeries: string;
78
dataType: string[];
89
dataSelection: string[];
910
xAxis: string;
@@ -41,6 +42,7 @@ type PlotSettings = {
4142

4243

4344
const defaultValue: PlotSettings = {
45+
selectedSeries: "ZTF_J1539",
4446
dataType: ['average'],
4547
dataSelection: [],
4648
xAxis: 'phase',

src/utils/matrix.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export async function process_df(
2828
dataType: 'average' | 'raw',
2929
selection: string[],
3030
count: number,
31+
selectedSeries: string,
3132
): Promise<unknown[]> {
3233
const wave = type.toLowerCase() as 'sw' | 'lw';
3334

@@ -44,7 +45,7 @@ export async function process_df(
4445
for (const sel of selection) {
4546
const [epoch, r_in, r_out] = sel.split('_');
4647
// You said you'll load from df/ (already aligned); we simply pass that JSON into processForTrace.
47-
const url = `${process.env.BASE_PATH}/data/json/ZTF_J1539/df/${epoch}/${wave}/${r_in}/${r_out}.json`;
48+
const url = `${process.env.DATA_PATH}/data/json/${selectedSeries}/df/${epoch}/${wave}/${r_in}/${r_out}.json`;
4849

4950
try {
5051
const res = await fetch(url);

0 commit comments

Comments
 (0)