Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__param_check,
__process_background,
__process_spectrum,
__find_peaks
__find_peaks,
)

app = Flask(__name__)
Expand Down Expand Up @@ -102,24 +102,24 @@ def background():
"y": list(map(str, y_value)),
}


@app.route("/find_peaks", methods=["POST"])
def find_peaks():
data = json.loads(request.data)

peaks= __find_peaks(data["x"], data["y"], float(data["lowerbound"]), float(data["upperbound"]), float(data["threshold"]))
peaks = __find_peaks(
data["x"],
data["y"],
float(data["lowerbound"]),
float(data["upperbound"]),
float(data["threshold"]),
)

if peaks:
return {
"success": True,
"peaks": peaks,
"error": None
}
return {"success": True, "peaks": peaks, "error": None}
else:
return {
"success": False,
"peaks": None,
"error": "wstep too small"
}
return {"success": False, "peaks": None, "error": "wstep too small"}


# set debug to false in production environment
if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,9 @@ def __find_peaks(x_data, y_data, lowerbound, upperbound, threshold=0):
spectrum = Spectrum.from_array(
x_data, y_data, "absorbance_noslit", wunit="cm-1", unit=""
)
new_spec = spectrum.to_specutils() # NOTE: this is the problem when wstep is < 0.01
new_spec = (
spectrum.to_specutils()
) # NOTE: this is the problem when wstep is < 0.01
lines = find_lines_threshold(new_spec, noise_factor=1)
except:
return None
Expand Down