From bc799a1ba576ae8646e252b1a49a355053a3f234 Mon Sep 17 00:00:00 2001 From: Arunava Basu Date: Wed, 3 Aug 2022 20:48:01 +0530 Subject: [PATCH 1/7] working to remove the bug --- frontend/src/components/CalcSpectrum.tsx | 16 +++++++++++++++- frontend/src/components/fields/Mode.tsx | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/CalcSpectrum.tsx b/frontend/src/components/CalcSpectrum.tsx index 87a0622c..9e770c35 100644 --- a/frontend/src/components/CalcSpectrum.tsx +++ b/frontend/src/components/CalcSpectrum.tsx @@ -160,6 +160,8 @@ export const CalcSpectrum: React.FC = () => { }; const databaseWatch = watch("database"); const modeWatch = watch("mode"); + // const useSlitWatch = watch("simulate_slit"); + // console.log(useSlitWatch); React.useEffect(() => { if (databaseWatch === "geisa") { setUseGesia(true); @@ -176,7 +178,19 @@ export const CalcSpectrum: React.FC = () => { } else { setValue("simulate_slit", 5); } - }, [databaseWatch, modeWatch]); + if (useSlit == true) { + if (modeWatch === "radiance_noslit") { + setValue("mode", "radiance"); + } else { + setValue("mode", "radiance_noslit"); + } + if (modeWatch === "transmittance_noslit") { + setValue("mode", "transmittance"); + } else { + setValue("mode", "transmittance_noslit"); + } + } + }, [databaseWatch, modeWatch, useSlit]); const UseNonEquilibriumCalculations = () => ( ; } +enum mode { + Absorbance = "Absorbance", + Radiance = "radiance", + Radiance_noslit = "radiance_noslit", + Transmittance = "Transmittance", + Transmittance_noslit = "Transmittance_noslit", +} export const Mode: React.FC = ({ control }) => { return ( @@ -30,9 +37,14 @@ export const Mode: React.FC = ({ control }) => { value={field.value} label="Select" > - Absorbance - Radiance - Transmittance + Absorbance + + + Radiance + + + Transmittance + )} /> From 210b8fbd9824ed36d414b846d9545a0b405de2f5 Mon Sep 17 00:00:00 2001 From: Arunava Basu Date: Thu, 4 Aug 2022 00:22:56 +0530 Subject: [PATCH 2/7] bug removed modify the submit function to change the mode --- frontend/src/components/CalcSpectrum.tsx | 34 +++++++++++++++--------- frontend/src/components/fields/Mode.tsx | 18 +++---------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/frontend/src/components/CalcSpectrum.tsx b/frontend/src/components/CalcSpectrum.tsx index 9e770c35..92da2321 100644 --- a/frontend/src/components/CalcSpectrum.tsx +++ b/frontend/src/components/CalcSpectrum.tsx @@ -128,6 +128,14 @@ export const CalcSpectrum: React.FC = () => { setError(message); }; const onSubmit = async (data: FormValues): Promise => { + if (useSlit == true) { + if (data.mode === "radiance_noslit") { + data.mode = "radiance"; + } + if (data.mode === "transmittance_noslit") { + data.mode = "transmittance"; + } + } console.log(data); setLoading(true); setError(undefined); @@ -178,19 +186,19 @@ export const CalcSpectrum: React.FC = () => { } else { setValue("simulate_slit", 5); } - if (useSlit == true) { - if (modeWatch === "radiance_noslit") { - setValue("mode", "radiance"); - } else { - setValue("mode", "radiance_noslit"); - } - if (modeWatch === "transmittance_noslit") { - setValue("mode", "transmittance"); - } else { - setValue("mode", "transmittance_noslit"); - } - } - }, [databaseWatch, modeWatch, useSlit]); + // if (useSlit == true) { + // if (modeWatch === "radiance_noslit") { + // setValue("mode", "radiance"); + // } else { + // setValue("mode", "radiance_noslit"); + // } + // if (modeWatch === "transmittance_noslit") { + // setValue("mode", "transmittance"); + // } else { + // setValue("mode", "transmittance_noslit"); + // } + // } + }, [databaseWatch, modeWatch]); const UseNonEquilibriumCalculations = () => ( ; } -enum mode { - Absorbance = "Absorbance", - Radiance = "radiance", - Radiance_noslit = "radiance_noslit", - Transmittance = "Transmittance", - Transmittance_noslit = "Transmittance_noslit", -} export const Mode: React.FC = ({ control }) => { return ( @@ -37,14 +30,9 @@ export const Mode: React.FC = ({ control }) => { value={field.value} label="Select" > - Absorbance - - - Radiance - - - Transmittance - + Absorbance + Radiance + Transmittance )} /> From 0d4a5bc15c42b60645fb260a09c0c2302f051a11 Mon Sep 17 00:00:00 2001 From: Arunava Basu Date: Thu, 4 Aug 2022 00:24:51 +0530 Subject: [PATCH 3/7] remove comments --- frontend/src/components/CalcSpectrum.tsx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/frontend/src/components/CalcSpectrum.tsx b/frontend/src/components/CalcSpectrum.tsx index 92da2321..f1304587 100644 --- a/frontend/src/components/CalcSpectrum.tsx +++ b/frontend/src/components/CalcSpectrum.tsx @@ -186,18 +186,6 @@ export const CalcSpectrum: React.FC = () => { } else { setValue("simulate_slit", 5); } - // if (useSlit == true) { - // if (modeWatch === "radiance_noslit") { - // setValue("mode", "radiance"); - // } else { - // setValue("mode", "radiance_noslit"); - // } - // if (modeWatch === "transmittance_noslit") { - // setValue("mode", "transmittance"); - // } else { - // setValue("mode", "transmittance_noslit"); - // } - // } }, [databaseWatch, modeWatch]); const UseNonEquilibriumCalculations = () => ( From 4e5fcce9c9d4e7176c283d21a7183566937a4fd1 Mon Sep 17 00:00:00 2001 From: Arunava Basu Date: Thu, 4 Aug 2022 00:26:39 +0530 Subject: [PATCH 4/7] remove `console.log` --- frontend/src/components/CalcSpectrum.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/CalcSpectrum.tsx b/frontend/src/components/CalcSpectrum.tsx index f1304587..60fb6fb6 100644 --- a/frontend/src/components/CalcSpectrum.tsx +++ b/frontend/src/components/CalcSpectrum.tsx @@ -122,7 +122,6 @@ export const CalcSpectrum: React.FC = () => { resolver: yupResolver(Schema), }); - console.log(formState?.errors); const handleBadResponse = (message: string) => { setCalcSpectrumResponse(undefined); setError(message); @@ -136,7 +135,7 @@ export const CalcSpectrum: React.FC = () => { data.mode = "transmittance"; } } - console.log(data); + setLoading(true); setError(undefined); setPlotData({ @@ -168,8 +167,7 @@ export const CalcSpectrum: React.FC = () => { }; const databaseWatch = watch("database"); const modeWatch = watch("mode"); - // const useSlitWatch = watch("simulate_slit"); - // console.log(useSlitWatch); + React.useEffect(() => { if (databaseWatch === "geisa") { setUseGesia(true); From a1c63920ae2c1c9e1bee73146cf40c41eda48247 Mon Sep 17 00:00:00 2001 From: Arunava Basu Date: Thu, 4 Aug 2022 00:32:45 +0530 Subject: [PATCH 5/7] unused variable removed --- frontend/src/components/CalcSpectrum.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/CalcSpectrum.tsx b/frontend/src/components/CalcSpectrum.tsx index 60fb6fb6..096ae130 100644 --- a/frontend/src/components/CalcSpectrum.tsx +++ b/frontend/src/components/CalcSpectrum.tsx @@ -116,11 +116,10 @@ export const CalcSpectrum: React.FC = () => { .max(30, "Simulate slit must be less than 30"), }), }); - const { control, handleSubmit, setValue, watch, formState } = - useForm({ - defaultValues: { species: [{ molecule: "CO", mole_fraction: 0.1 }] }, - resolver: yupResolver(Schema), - }); + const { control, handleSubmit, setValue, watch } = useForm({ + defaultValues: { species: [{ molecule: "CO", mole_fraction: 0.1 }] }, + resolver: yupResolver(Schema), + }); const handleBadResponse = (message: string) => { setCalcSpectrumResponse(undefined); From a300debadabb2c2b6cf70e65bdd880d7911da05e Mon Sep 17 00:00:00 2001 From: Arunava Basu Date: Thu, 4 Aug 2022 19:13:21 +0530 Subject: [PATCH 6/7] fixed the plot object && server files --- frontend/src/components/CalcSpectrum.tsx | 3 +++ frontend/src/components/CalcSpectrumPlot.tsx | 4 ++-- server/main.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/CalcSpectrum.tsx b/frontend/src/components/CalcSpectrum.tsx index 096ae130..27a73f7a 100644 --- a/frontend/src/components/CalcSpectrum.tsx +++ b/frontend/src/components/CalcSpectrum.tsx @@ -126,8 +126,11 @@ export const CalcSpectrum: React.FC = () => { setError(message); }; const onSubmit = async (data: FormValues): Promise => { + // let modeLabel; if (useSlit == true) { if (data.mode === "radiance_noslit") { + // modeLabel = "Absorbance"; + // data.units = "-ln(I/I0)"; data.mode = "radiance"; } if (data.mode === "transmittance_noslit") { diff --git a/frontend/src/components/CalcSpectrumPlot.tsx b/frontend/src/components/CalcSpectrumPlot.tsx index d8b695e9..132bbcf7 100644 --- a/frontend/src/components/CalcSpectrumPlot.tsx +++ b/frontend/src/components/CalcSpectrumPlot.tsx @@ -24,9 +24,9 @@ const CalcSpectrumPlot_ = ({ if (mode === "absorbance") { modeLabel = "Absorbance"; data.units = "-ln(I/I0)"; - } else if (mode === "transmittance_noslit") { + } else if (mode.startsWith("transmittance")) { modeLabel = "Transmittance"; - } else if (mode === "radiance_noslit") { + } else if (mode.startsWith("radiance")) { modeLabel = "Radiance"; } else { throw new Error("Invalid mode"); diff --git a/server/main.py b/server/main.py index dd5ebb31..e438aa2c 100644 --- a/server/main.py +++ b/server/main.py @@ -32,7 +32,7 @@ class Payload(BaseModel): trot: Optional[float] = None path_length: float simulate_slit: Optional[int] = None - mode: Literal["absorbance", "transmittance_noslit", "radiance_noslit"] + mode: Literal["absorbance", "transmittance_noslit", "radiance_noslit", "transmittance", "radiance"] database: Literal["hitran", "geisa"] use_simulate_slit: bool = False From b8695a4177d97dc37c46ecfe59e193044d703d15 Mon Sep 17 00:00:00 2001 From: Arunava Basu Date: Thu, 4 Aug 2022 19:20:08 +0530 Subject: [PATCH 7/7] comments removed --- frontend/src/components/CalcSpectrum.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/frontend/src/components/CalcSpectrum.tsx b/frontend/src/components/CalcSpectrum.tsx index 27a73f7a..096ae130 100644 --- a/frontend/src/components/CalcSpectrum.tsx +++ b/frontend/src/components/CalcSpectrum.tsx @@ -126,11 +126,8 @@ export const CalcSpectrum: React.FC = () => { setError(message); }; const onSubmit = async (data: FormValues): Promise => { - // let modeLabel; if (useSlit == true) { if (data.mode === "radiance_noslit") { - // modeLabel = "Absorbance"; - // data.units = "-ln(I/I0)"; data.mode = "radiance"; } if (data.mode === "transmittance_noslit") {