diff --git a/README.md b/README.md index 070c021..c62f268 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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 @@ -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. @@ -163,7 +163,7 @@ For Find Peaks requests, the parameters will include: --- -### Functions.py Functions +### Processing_utils.py Functions #### `zeroY` diff --git a/app.py b/app.py index 6476552..63c1259 100644 --- a/app.py +++ b/app.py @@ -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) @@ -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, diff --git a/processing.py b/processing.py index c03151f..eb8f412 100644 --- a/processing.py +++ b/processing.py @@ -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 @@ -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. diff --git a/functions.py b/processing_utils.py similarity index 100% rename from functions.py rename to processing_utils.py