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
6 changes: 6 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ def background():
# --> detector response spectrum
processed_spectrum = __process_spectrum(data, background_spectrum, True)

if processed_spectrum is None:
return {
"success": False,
"text": "Issue Processing Data"
}

# https://radis.readthedocs.io/en/latest/source/radis.spectrum.spectrum.html#radis.spectrum.spectrum.Spectrum.get
x_value, y_value = processed_spectrum.get("transmittance_noslit")

Expand Down
48 changes: 25 additions & 23 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,36 +523,38 @@ def __process_spectrum(params, raw_spectrum, find_peaks):

# Crop spectrum into two halves inorder to minimize memory space in multiscan
# https://radis.readthedocs.io/en/latest/source/radis.spectrum.operations.html#radis.spectrum.operations.crop
try:

num_segments = 256
num_segments = 16

split = (params["waveMin"] + params["waveMax"]) / num_segments
spectra_segments = [] # Create a list of size 6, default value of None
split = (params["waveMin"] + params["waveMax"]) / num_segments
spectra_segments = [] # Create a list of size 6, default value of None

# Range for the first segment
min_index = params["waveMin"]
max_index = params["waveMin"] + split
# Range for the first segment
min_index = params["waveMin"]
max_index = params["waveMin"] + split

# Split and add noise; store in list
for _ in range(num_segments):
segment = crop(spectrum, min_index, max_index, 'cm-1', inplace=False)
segment = __multiscan(segment, params["scan"])
gc.collect()
spectra_segments.append(segment)
min_index = max_index
max_index += split
# Split and add noise; store in list
for _ in range(num_segments):
segment = crop(spectrum, min_index, max_index, 'cm-1', inplace=False)
segment = __multiscan(segment, params["scan"])
gc.collect()
spectra_segments.append(segment)
min_index = max_index
max_index += split

[print(segment) for segment in spectra_segments]
# stitch the spectra back together once noise has been added
# https://radis.readthedocs.io/en/latest/source/radis.spectrum.operations.html#radis.spectrum.operations.concat_spectra
noisey_spectrum = spectra_segments[0]
[print(segment) for segment in spectra_segments]
# stitch the spectra back together once noise has been added
# https://radis.readthedocs.io/en/latest/source/radis.spectrum.operations.html#radis.spectrum.operations.concat_spectra
noisey_spectrum = spectra_segments[0]

for segment in spectra_segments:
if len(segment.get_wavenumber()) != 0 and segment is not noisey_spectrum:
noisey_spectrum = concat_spectra(noisey_spectrum, segment)
for segment in spectra_segments:
if len(segment.get_wavenumber()) != 0 and segment is not noisey_spectrum:
noisey_spectrum = concat_spectra(noisey_spectrum, segment)

spectrum = noisey_spectrum

spectrum = noisey_spectrum
except:
return None
# return processed spectrum
return spectrum

Expand Down