init
This commit is contained in:
commit
30a9eef102
2999 changed files with 1898721 additions and 0 deletions
29
optifik/io.py
Normal file
29
optifik/io.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import numpy as np
|
||||
|
||||
|
||||
def load_spectrum(spectrum_path, lambda_min=0, lambda_max=np.inf,
|
||||
delimiter=','):
|
||||
"""
|
||||
Load a spectrum file.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
spectrum_path : string
|
||||
File path.
|
||||
lambda_min : scalar, optional
|
||||
Cut the data at this minimum wavelength in nm.
|
||||
lambda_max : scalar, optional
|
||||
Cut the data at this maximum wavelength in nm.
|
||||
delimiter : string, optional
|
||||
Delimiter between columns in the datafile.
|
||||
|
||||
Returns
|
||||
-------
|
||||
values : arrays
|
||||
(lamdbas, intensities)
|
||||
"""
|
||||
data = np.loadtxt(spectrum_path, delimiter=delimiter)
|
||||
lambdas, intensities = np.column_stack(data)
|
||||
|
||||
mask = (lambdas > lambda_min) & (lambdas < lambda_max)
|
||||
return lambdas[mask], intensities[mask]
|
Loading…
Add table
Add a link
Reference in a new issue