openspi.core ============ .. py:module:: openspi.core Functions --------- .. autoapisummary:: openspi.core.process_csv openspi.core.process_csv_folder openspi.core.r_script openspi.core.sort_export openspi.core.openspi_main Module Contents --------------- .. py:function:: process_csv(file_path, range_min, range_max) Processes .csv files to match the required format for OpenSpecy processing. (The required format is two columns named ``'wavenumber'`` and ``'intensity'``) :param file_path: The complete path to the .csv file to be processed. This function only accepts .csv files, and any other file types will cause the function to stop. :type file_path: str :param range_min: The minimum wavenumber of the desired spectral range. Note that this value can be greater than the actual minimum if cropping is desired. :type range_min: int :param range_max: The maximum wavenumber of the desired spectral range. Note that this value can be less than the actual maximum if cropping is desired. :type range_max: int :returns: **file_path** -- The complete path to the processed .csv file. :rtype: str .. py:function:: process_csv_folder(folder_path, range_min, range_max) Processes a batch of .csv files in the given folder by calling `process_csv`, then zips the processed files to send to OpenSpecy. :param folder_path: The complete path to the folder containing .csv files to be processed. This function only accepts .csv files, and any other file types will cause the function to stop. :type folder_path: str :param range_min: The minimum wavenumber of the desired spectral range. Note that this value can be greater than the actual minimum if cropping is desired. :type range_min: int :param range_max: The maximum wavenumber of the desired spectral range. Note that this value can be less than the actual maximum if cropping is desired. :type range_max: int :returns: **zipped_file_path** -- The complete path to a zipped folder containing the processed .csv files. This will be located in the same directory as the original folder path. :rtype: str .. py:function:: r_script(file_path, range_min, range_max, adj_intens: bool = False, adj_intens_type: str = 'none', subtract_baseline: bool = False, top_n: int = 5) Processes spectra through the OpenSpecy R package and returns a dataframe with the library matches and other data https://github.com/wincowgerDEV/OpenSpecy-package :param file_path: Path to the zipped folder containing the processed .csv files OR the path to a single .csv file. :type file_path: str :param range_min: The minimum wavenumber of the desired spectral range. Note that this value can be greater than the actual minimum if cropping is desired. :type range_min: int :param range_max: The maximum wavenumber of the desired spectral range. Note that this value can be less than the actual maximum if cropping is desired. :type range_max: int :param top_n: The top *n* highest matches desired. Recommended values: 1 <= n >= 10 (Not yet supported) :type top_n: int :param adj_intens: If True, the function will adjust the intensity of the spectra using the OpenSpecy package. :type adj_intens: bool :param adj_intens_type: The type of intensity adjustment to be made. Options are 'none', 'transmittance', or 'absorbance' :type adj_intens_type: str :param subtract_baseline: If True, the function will subtract the baseline from the spectra using IModPolyFit from the OpenSpecy package. :type subtract_baseline: bool :returns: **df_top_matches** -- A Pandas dataframe containing the library match data for the files. :rtype: dataframe .. py:function:: sort_export(df, excel_path, top_n, nrel=False) Sorts the dataframe exported from the R script and rearranges it into a more presentable format. Exports an Excel file. :param df: The dataframe exported from the R script. :type df: df :param excel_path: The full path to an .xlsx file. :type excel_path: str :param top_n: The number of top matches for each file. Equal to `top_n` in `openspi_main`. Default is 5. :type top_n: int :param nrel: Adds an extra row regarding first well information to the "Matches Checked sheet." :type nrel: Bool :rtype: None. .. py:function:: openspi_main(source_path, range_min, range_max, export_xlsx=None, export_dir=None, nrel_version=False, adj_intens=False, adj_intens_type='none', subtr_baseline=False) A complete function for spectral pre-processing, processing through the OpenSpecy library in R, and configuring/processing the outputted data into an Excel spreadsheet. :param source_path: The complete path to the folder containing .csv files to be processed OR the path to a single .csv file. This function only accepts .csv files, and any other file types will cause the function to stop. :type source_path: str :param range_min: The minimum wavenumber of the desired spectral range. Note that this value can be greater than the actual minimum if cropping is desired. :type range_min: int :param range_max: The maximum wavenumber of the desired spectral range. Note that this value can be less than the actual maximum if cropping is desired. :type range_max: int :param export_xlsx: The desired name of the outputted .xlsx file. If the file name does not contain the file extention `.xlsx`, it will be added. Optional; if not specified, the outputted file will be named according to the source file/folder. :type export_xlsx: str :param export_dir: The desired location of the outputted `.xlsx` file. Optional; if not specified, the file will be saved in the parent directory of the source file/folder. :type export_dir: str :param nrel_version: If True, the function will use the NREL version of OpenSpecy, which has two differences: 1) all .sp files present in the folder will be deleted, and 2) the outputted file will be named in a specific way according to the files contained within. :type nrel_version: bool :param top_n: The top *n* highest matches desired. Recommended values: 1 <= n >= 10. Not yet supported. :type top_n: int :param adj_intens: If True, the function will adjust the intensity of the spectra using the OpenSpecy package. :type adj_intens: bool :param adj_intens_type: The type of intensity adjustment to be made. Options are 'none', 'transmittance', or 'absorbance' :type adj_intens_type: str :param subtr_baseline: If True, the function will subtract the baseline from the spectra using IModPolyFit from the OpenSpecy package. :type subtr_baseline: bool :rtype: None.