Skip to content

Commit

Permalink
Merge pull request #99 from Brennaser/main
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
Brennaser authored Jul 24, 2023
2 parents f1ac756 + 43cfa97 commit 8f97ae8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ This repository contains the back-end of the [Virtual FTIR Spectrometer](https:/

- `processing.py`

- This module contains four functions: `process_spectrum`, `process_background`, `generate_spectrum`, and `find_peaks`. These functions are used for the generation and anaylsis of realistic spectra. Find more details about each function [here](#processingpy-functions).
- This module contains four functions: `process_spectrum`, `generate_background`, `generate_spectrum`, and `find_peaks`. These functions are used for the generation and anaylsis of realistic spectra. Find more details about each function [here](#processingpy-functions).

- `functions.py`
- `processing_utils.py`

- This utility module contains helper functions for the `processing.py` module. These functions include functions to approxiamate physical components of an FTIR Spectrometer, approximate realistic noise, check user parameters, and calculate the resolution of the spectra. Find more details about the individual functions [here](#functionspy-functions).

Expand Down Expand Up @@ -135,7 +135,7 @@ For Find Peaks requests, the parameters will include:
- Background
- Background takes in parameters, checks them, and calls `generate_spectrum` the same as Spectrum. After these preliminary steps, Background then calls `process_background` to get a spectrum where all the y-values are 1 ([details](#process_background)). By calling `generate_spectrum` and then calling `process_background` with the resulting spectrum, the x-values and overall resolution of the spectrum is accurate; the background data lines up with a sample spectrum with the same parameters. From here, the spectrum is sent to `process_spectrum` so it will more closely resemble a real spectrum. Like Spectrum, this function sends the x and y-values of the resulting spectrum back to the user.
- Background takes in parameters, checks them, and calls `generate_spectrum` the same as Spectrum. After these preliminary steps, Background then calls `generate_background` to get a spectrum where all the y-values are 1 ([details](#generate_background)). By calling `generate_spectrum` and then calling `generate_background` with the resulting spectrum, the x-values and overall resolution of the spectrum is accurate; the background data lines up with a sample spectrum with the same parameters. From here, the spectrum is sent to `process_spectrum` so it will more closely resemble a real spectrum. Like Spectrum, this function sends the x and y-values of the resulting spectrum back to the user.
- Find Peaks
Expand All @@ -149,7 +149,7 @@ For Find Peaks requests, the parameters will include:
- This function takes an ideal spectrum and returns a spectrum that is approximately the spectrum that would be generated by a physical spectrometer. This is achieved by creating additional spectra based on mathematical functions that approximate the behavior of FTIR components. The user chooses which of these spectra will be used by picking a [Beamsplitter](#beamsplitters), [Cell Window](#cell-windows), [Detector](#detector), and a source (Globar or Tungsten) for the [Blackbody Spectrum](#blackbody). Those spectra are then multiplied into the base spectrum and realistic noise is added. Find more detail on the component functions [here](#component-functions) and find more detail about noise generation [here](#multiscan).
#### `process_background`
#### `generate_background`
- This function takes the wavenumbers (x-values) of a spectra and sets all y-values to one to simulate an ideal background spectrum.
Expand All @@ -163,7 +163,7 @@ For Find Peaks requests, the parameters will include:
---
### Functions.py Functions
### Processing_utils.py Functions
#### `zeroY`
Expand Down
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from flask_cors import CORS
from processing import (
generate_spectrum,
process_background,
generate_background,
process_spectrum,
find_peaks
)
from functions import param_check
from processing_utils import param_check

app = Flask(__name__)
CORS(app)
Expand Down Expand Up @@ -91,7 +91,7 @@ def background() -> dict[bool, list[float], list[float]]:
# perform:
# --> set all y-values to one
try:
background_spectrum = process_background(spectrum)
background_spectrum = generate_background(spectrum)
except:
return {
"success": False,
Expand Down
4 changes: 2 additions & 2 deletions processing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import radis
from radis import SerialSlabs, Spectrum, calc_spectrum, MergeSlabs
from specutils.fitting import find_lines_threshold
from functions import zeroY, calc_wstep, multiscan, get_component_spectra
from processing_utils import zeroY, calc_wstep, multiscan, get_component_spectra

from pydantic import ConfigDict, validate_arguments

Expand Down Expand Up @@ -84,7 +84,7 @@ def process_spectrum(params: dict[str, object], raw_spectrum: Spectrum) -> Spect


# @validate_arguments(config=ConfigDict(strict=True, arbitrary_types_allowed=True))
def process_background(raw_spectrum: Spectrum) -> Spectrum:
def generate_background(raw_spectrum: Spectrum) -> Spectrum:
"""
Accepts a spectrum generated using 'generate_spectrum()'.
A background by default has all y-values of one.
Expand Down
File renamed without changes.

0 comments on commit 8f97ae8

Please sign in to comment.