<commit_before>"""
Module contains methods of calculating a pore size distribution starting from a DFT
kernel. Please note that calculation of the DFT/NLDFT/QSDFT kernels are outside the
scope of this program.
"""

import os

import numpy
import pandas
import scipy

from ..utilities.math_utilities import bspline
from ..utilities.exceptions import CalculationError

_KERNELS = {}

INTERNAL = os.path.join(os.path.dirname(__file__),
                        'kernels', 'dft - N2 - carbon.csv')


def psd_dft_kernel_fit(pressure, loading, kernel_path, bspline_order=2):
    r"""
    Fit a DFT kernel on experimental adsorption data.

    Parameters
    ----------
    loading : array
        Adsorbed amount in mmol/g.
    pressure : array
        Relative pressure.
    kernel_path : str
        The location of the kernel to use.
    bspline_order : int
        The smoothing order of the b-splines fit to the data.
        If set to 0, data will be returned as-is.

    Returns
    -------
    pore widths : array
        The widths of the pores.
    pore_dist : array<commit_msg>isort<commit_after>"""
Module contains methods of calculating a pore size distribution starting from a DFT
kernel. Please note that calculation of the DFT/NLDFT/QSDFT kernels are outside the
scope of this program.
"""

import os

import numpy
import pandas
import scipy

from ..utilities.exceptions import CalculationError
from ..utilities.math_utilities import bspline

_KERNELS = {}

INTERNAL = os.path.join(os.path.dirname(__file__),
                        'kernels', 'dft - N2 - carbon.csv')


def psd_dft_kernel_fit(pressure, loading, kernel_path, bspline_order=2):
    r"""
    Fit a DFT kernel on experimental adsorption data.

    Parameters
    ----------
    loading : array
        Adsorbed amount in mmol/g.
    pressure : array
        Relative pressure.
    kernel_path : str
        The location of the kernel to use.
    bspline_order : int
        The smoothing order of the b-splines fit to the data.
        If set to 0, data will be returned as-is.

    Returns
    -------
    pore widths : array
        The widths of the pores.
    pore_dist : array
{'fraction_non_alphanumeric': 0.07799442896935933, 'fraction_numerical': 0.002785515320334262, 'mean_word_length': 2.5270049099836336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4104424', 'n_tokens_mistral': 656, 'n_tokens_neox': 607, 'n_words': 237}