Skip to content

Commit

Permalink
Merge pull request #618 from arunavabasu-03/slit_bug
Browse files Browse the repository at this point in the history
remove the mode bug
  • Loading branch information
suzil authored Aug 4, 2022
2 parents e24b036 + b8695a4 commit 873d76b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
21 changes: 14 additions & 7 deletions frontend/src/components/CalcSpectrum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,25 @@ export const CalcSpectrum: React.FC = () => {
.max(30, "Simulate slit must be less than 30"),
}),
});
const { control, handleSubmit, setValue, watch, formState } =
useForm<FormValues>({
defaultValues: { species: [{ molecule: "CO", mole_fraction: 0.1 }] },
resolver: yupResolver(Schema),
});
const { control, handleSubmit, setValue, watch } = useForm<FormValues>({
defaultValues: { species: [{ molecule: "CO", mole_fraction: 0.1 }] },
resolver: yupResolver(Schema),
});

console.log(formState?.errors);
const handleBadResponse = (message: string) => {
setCalcSpectrumResponse(undefined);
setError(message);
};
const onSubmit = async (data: FormValues): Promise<void> => {
console.log(data);
if (useSlit == true) {
if (data.mode === "radiance_noslit") {
data.mode = "radiance";
}
if (data.mode === "transmittance_noslit") {
data.mode = "transmittance";
}
}

setLoading(true);
setError(undefined);
setPlotData({
Expand Down Expand Up @@ -160,6 +166,7 @@ export const CalcSpectrum: React.FC = () => {
};
const databaseWatch = watch("database");
const modeWatch = watch("mode");

React.useEffect(() => {
if (databaseWatch === "geisa") {
setUseGesia(true);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/CalcSpectrumPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 873d76b

Please sign in to comment.