quantalyze 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantalyze/__init__.py +4 -0
- quantalyze/core/__init__.py +4 -0
- quantalyze/core/differentiation.py +71 -0
- quantalyze/core/fft.py +0 -0
- quantalyze/core/fitting.py +90 -0
- quantalyze/core/interpolation.py +0 -0
- quantalyze/core/smoothing.py +71 -0
- quantalyze/core/symmetrize.py +54 -0
- quantalyze/plotting.py +52 -0
- quantalyze/thermometry.py +58 -0
- quantalyze/transport.py +108 -0
- quantalyze-0.1.0.dist-info/METADATA +15 -0
- quantalyze-0.1.0.dist-info/RECORD +14 -0
- quantalyze-0.1.0.dist-info/WHEEL +4 -0
quantalyze/__init__.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
def forward_difference(df, x_column, y_column):
|
|
2
|
+
"""
|
|
3
|
+
Calculate the forward difference of a given DataFrame.
|
|
4
|
+
|
|
5
|
+
Parameters:
|
|
6
|
+
df (pandas.DataFrame): The DataFrame containing the data.
|
|
7
|
+
x_column (str): The name of the column representing the x-values.
|
|
8
|
+
y_column (str): The name of the column representing the y-values.
|
|
9
|
+
|
|
10
|
+
Returns:
|
|
11
|
+
pandas.Series: A Series containing the forward differences of the y-values with respect to the x-values.
|
|
12
|
+
"""
|
|
13
|
+
forward_diff = df[y_column].diff().shift(-1) / df[x_column].diff().shift(-1)
|
|
14
|
+
return forward_diff
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def backward_difference(df, x_column, y_column):
|
|
18
|
+
"""
|
|
19
|
+
Calculate the backward difference of a DataFrame column.
|
|
20
|
+
|
|
21
|
+
Parameters:
|
|
22
|
+
df (pandas.DataFrame): The DataFrame containing the data.
|
|
23
|
+
x_column (str): The name of the column to use as the x-values.
|
|
24
|
+
y_column (str): The name of the column to use as the y-values.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
pandas.Series: The backward difference of the y_column with respect to the x_column.
|
|
28
|
+
"""
|
|
29
|
+
backward_diff = df[y_column].diff() / df[x_column].diff()
|
|
30
|
+
return backward_diff
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def central_difference(df, x_column, y_column):
|
|
34
|
+
"""
|
|
35
|
+
Calculate the central difference for a given DataFrame.
|
|
36
|
+
|
|
37
|
+
The central difference is computed as the average of the forward difference
|
|
38
|
+
and the backward difference for the specified columns.
|
|
39
|
+
|
|
40
|
+
Parameters:
|
|
41
|
+
df (pandas.DataFrame): The input DataFrame containing the data.
|
|
42
|
+
x_column (str): The name of the column representing the x-values.
|
|
43
|
+
y_column (str): The name of the column representing the y-values.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
pandas.Series: A Series containing the central difference values.
|
|
47
|
+
"""
|
|
48
|
+
forward_diff = forward_difference(df, x_column, y_column)
|
|
49
|
+
backward_diff = backward_difference(df, x_column, y_column)
|
|
50
|
+
central_diff = (forward_diff + backward_diff) / 2
|
|
51
|
+
return central_diff
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def derivative(df, x_column, y_column):
|
|
56
|
+
"""
|
|
57
|
+
Calculate the derivative of the y_column with respect to the x_column.
|
|
58
|
+
|
|
59
|
+
This method computes the numerical derivative of a given y_column with respect to an x_column
|
|
60
|
+
in a pandas DataFrame using central difference method.
|
|
61
|
+
|
|
62
|
+
Parameters:
|
|
63
|
+
df (pandas.DataFrame): The input DataFrame containing the data.
|
|
64
|
+
x_column (str): The name of the column representing the x-axis.
|
|
65
|
+
y_column (str): The name of the column representing the y-axis.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
pandas.Series: A Series with the derivative values.
|
|
69
|
+
"""
|
|
70
|
+
return central_difference(df, x_column, y_column)
|
|
71
|
+
|
quantalyze/core/fft.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from scipy.optimize import curve_fit
|
|
2
|
+
from inspect import signature
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Fit:
|
|
6
|
+
|
|
7
|
+
def __init__(self, func, popt, pcov):
|
|
8
|
+
self.func = func
|
|
9
|
+
self.popt = popt
|
|
10
|
+
self.pcov = pcov
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def evaluate(self, x):
|
|
14
|
+
"""
|
|
15
|
+
Evaluate the fitted function at given data points.
|
|
16
|
+
|
|
17
|
+
Parameters:
|
|
18
|
+
x : array-like
|
|
19
|
+
The input data points where the function should be evaluated.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
array-like
|
|
23
|
+
The evaluated values of the fitted function at the given data points.
|
|
24
|
+
"""
|
|
25
|
+
return self.func(x, *self.popt)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def plot(self, ax, x, **kwargs):
|
|
29
|
+
"""
|
|
30
|
+
Plot the evaluated function on the given axes.
|
|
31
|
+
|
|
32
|
+
Parameters:
|
|
33
|
+
ax (matplotlib.axes.Axes): The axes on which to plot.
|
|
34
|
+
x (array-like): The x values to evaluate the function.
|
|
35
|
+
**kwargs: Additional keyword arguments to pass to the plot function.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
None
|
|
39
|
+
"""
|
|
40
|
+
ax.plot(x, self.evaluate(x), **kwargs)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def fit(func, df, x_column, y_column, x_min=None, x_max=None, y_min=None, y_max=None, p0=None):
|
|
44
|
+
"""
|
|
45
|
+
Fits a given function to data in a DataFrame within an optional x and y range.
|
|
46
|
+
|
|
47
|
+
Parameters:
|
|
48
|
+
func (callable): The function to fit to the data. It should take x data as the first argument and parameters to fit as subsequent arguments.
|
|
49
|
+
df (pandas.DataFrame): The input DataFrame containing the data.
|
|
50
|
+
x_column (str): The name of the column in the DataFrame to use as the x data.
|
|
51
|
+
y_column (str): The name of the column in the DataFrame to use as the y data.
|
|
52
|
+
x_min (float, optional): The minimum value of x to include in the fitting. Defaults to None.
|
|
53
|
+
x_max (float, optional): The maximum value of x to include in the fitting. Defaults to None.
|
|
54
|
+
y_min (float, optional): The minimum value of y to include in the fitting. Defaults to None.
|
|
55
|
+
y_max (float, optional): The maximum value of y to include in the fitting. Defaults to None.
|
|
56
|
+
p0 (array-like, optional): Initial guess for the parameters. Defaults to None.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
Fit: An instance of the Fit class containing the fitted function and parameters.
|
|
60
|
+
"""
|
|
61
|
+
# Filter the dataframe based on x_min and x_max
|
|
62
|
+
if x_min is not None:
|
|
63
|
+
df = df[df[x_column] >= x_min]
|
|
64
|
+
if x_max is not None:
|
|
65
|
+
df = df[df[x_column] <= x_max]
|
|
66
|
+
|
|
67
|
+
# Filter the dataframe based on y_min and y_max
|
|
68
|
+
if y_min is not None:
|
|
69
|
+
df = df[df[y_column] >= y_min]
|
|
70
|
+
if y_max is not None:
|
|
71
|
+
df = df[df[y_column] <= y_max]
|
|
72
|
+
|
|
73
|
+
# Extract x and y data
|
|
74
|
+
x_data = df[x_column].values
|
|
75
|
+
y_data = df[y_column].values
|
|
76
|
+
|
|
77
|
+
# Check if there is data to fit
|
|
78
|
+
if len(x_data) == 0 or len(y_data) == 0:
|
|
79
|
+
raise RuntimeError("No data in the specified x or y range to fit.")
|
|
80
|
+
|
|
81
|
+
# Check if p0 is provided and has the correct length
|
|
82
|
+
if p0 is not None:
|
|
83
|
+
num_params = len(signature(func).parameters) - 1 # Subtract 1 for the x parameter
|
|
84
|
+
if len(p0) != num_params:
|
|
85
|
+
raise ValueError(f"Initial guess p0 must have length {num_params}, but got {len(p0)}.")
|
|
86
|
+
|
|
87
|
+
# Perform curve fitting
|
|
88
|
+
popt, pcov = curve_fit(func, x_data, y_data, p0=p0)
|
|
89
|
+
|
|
90
|
+
return Fit(func=func, popt=popt, pcov=pcov)
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import numpy as np
|
|
3
|
+
from scipy.signal import savgol_filter as scipy_savgol_filter
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def bin(dfs, column, minimum, maximum, width):
|
|
10
|
+
"""
|
|
11
|
+
Bin the data in the specified column of the DataFrame(s) into equal-width bins and compute the mean of each bin.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
dfs (pandas.DataFrame or list of pandas.DataFrame): The input DataFrame(s) containing the data to be binned.
|
|
15
|
+
column (str): The name of the column in the DataFrame(s) to be binned.
|
|
16
|
+
minimum (float): The minimum value of the range to be binned.
|
|
17
|
+
maximum (float): The maximum value of the range to be binned.
|
|
18
|
+
width (float): The width of each bin.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
pandas.DataFrame: A DataFrame containing the mean values of each bin, with the bin midpoints as the values in the specified column.
|
|
22
|
+
"""
|
|
23
|
+
def bin_single_df(df):
|
|
24
|
+
bin_edges = np.arange(minimum - width / 2, maximum + width / 2 + width, width)
|
|
25
|
+
bin_midpoints = (bin_edges[1:] + bin_edges[:-1]) / 2
|
|
26
|
+
df['bin'] = pd.cut(df[column], bins=bin_edges, include_lowest=True)
|
|
27
|
+
binned = df.groupby('bin').agg('mean').reset_index()
|
|
28
|
+
binned[column] = bin_midpoints
|
|
29
|
+
binned = binned.drop('bin', axis=1)
|
|
30
|
+
return binned
|
|
31
|
+
|
|
32
|
+
if isinstance(dfs, list):
|
|
33
|
+
combined_df = pd.concat(dfs, ignore_index=True)
|
|
34
|
+
return bin_single_df(combined_df)
|
|
35
|
+
else:
|
|
36
|
+
return bin_single_df(dfs)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def window(df, column, window_size=5, window_type='triang'):
|
|
41
|
+
"""
|
|
42
|
+
Apply a rolling window smoothing to a specified column in a DataFrame.
|
|
43
|
+
|
|
44
|
+
Parameters:
|
|
45
|
+
df (pandas.DataFrame): The input DataFrame containing the data.
|
|
46
|
+
column (str): The name of the column to which the rolling window smoothing will be applied.
|
|
47
|
+
window_size (int, optional): The size of the rolling window. Default is 5.
|
|
48
|
+
window_type (str, optional): The type of window to use. Default is 'triang'.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
pandas.Series: A Series with the smoothed values.
|
|
52
|
+
"""
|
|
53
|
+
return df[column].rolling(window=window_size, win_type=window_type, center=True).mean()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def savgol_filter(df, column, window_size=5, order=2):
|
|
57
|
+
"""
|
|
58
|
+
Apply a Savitzky-Golay filter to a specified column in a DataFrame.
|
|
59
|
+
|
|
60
|
+
Parameters:
|
|
61
|
+
df (pandas.DataFrame): The input DataFrame containing the data.
|
|
62
|
+
column (str): The name of the column to which the Savitzky-Golay filter will be applied.
|
|
63
|
+
window_size (int, optional): The size of the window. Default is 5.
|
|
64
|
+
order (int, optional): The order of the polynomial used to fit the samples. Default is 2.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
pandas.Series: A Series with the smoothed values.
|
|
68
|
+
"""
|
|
69
|
+
return pd.Series(scipy_savgol_filter(df[column], window_size, order), index=df.index)
|
|
70
|
+
|
|
71
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from .smoothing import bin
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def symmetrize(dfs, x_column, y_column, minimum, maximum, step):
|
|
7
|
+
"""
|
|
8
|
+
Symmetrizes the given dataframes by combining them, filtering based on the x_column values,
|
|
9
|
+
and then averaging the y_column values with their reversed counterparts.
|
|
10
|
+
|
|
11
|
+
Parameters:
|
|
12
|
+
dfs (list of pd.DataFrame): List of dataframes to be symmetrized.
|
|
13
|
+
x_column (str): The name of the column to be used for filtering and sorting.
|
|
14
|
+
y_column (str): The name of the column to be symmetrized.
|
|
15
|
+
minimum (float): The minimum value for filtering the x_column.
|
|
16
|
+
maximum (float): The maximum value for filtering the x_column.
|
|
17
|
+
step (float): The step size for binning the x_column values.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
pd.DataFrame: A new dataframe with symmetrized y_column values.
|
|
21
|
+
"""
|
|
22
|
+
dfs = [df[(df[x_column] >= minimum) & (df[x_column] <= maximum)] for df in dfs]
|
|
23
|
+
combined = pd.concat(dfs)
|
|
24
|
+
combined = combined.sort_values(by=x_column)
|
|
25
|
+
combined = bin(combined, x_column, -maximum, maximum, step)
|
|
26
|
+
new_df = pd.DataFrame(data={x_column: combined[x_column], 'a': combined[y_column], 'b': combined[y_column].values[::-1]})
|
|
27
|
+
new_df[y_column] = (new_df["a"]+new_df["b"])/2
|
|
28
|
+
new_df = new_df.drop(columns=['a', 'b'])
|
|
29
|
+
return new_df
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def antisymmetrize(dfs, x_column, y_column, minimum, maximum, step):
|
|
33
|
+
"""
|
|
34
|
+
Antisymmetrizes the given dataframes by reflecting the y-values around the x-axis.
|
|
35
|
+
|
|
36
|
+
Parameters:
|
|
37
|
+
dfs (list of pd.DataFrame): List of dataframes to be antisymmetrized.
|
|
38
|
+
x_column (str): The name of the column representing the x-axis.
|
|
39
|
+
y_column (str): The name of the column representing the y-axis.
|
|
40
|
+
minimum (float): The minimum value of the x-axis range to consider.
|
|
41
|
+
maximum (float): The maximum value of the x-axis range to consider.
|
|
42
|
+
step (float): The step size for binning the x-axis values.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
pd.DataFrame: A new dataframe with antisymmetrized y-values.
|
|
46
|
+
"""
|
|
47
|
+
dfs = [df[(df[x_column] >= minimum) & (df[x_column] <= maximum)] for df in dfs]
|
|
48
|
+
combined = pd.concat(dfs)
|
|
49
|
+
combined = combined.sort_values(by=x_column)
|
|
50
|
+
combined = bin(combined, x_column, -maximum, maximum, step)
|
|
51
|
+
new_df = pd.DataFrame(data={x_column: combined[x_column], 'a': combined[y_column], 'b': combined[y_column].values[::-1]})
|
|
52
|
+
new_df[y_column] = (new_df["a"]-new_df["b"])/2
|
|
53
|
+
new_df = new_df.drop(columns=['a', 'b'])
|
|
54
|
+
return new_df
|
quantalyze/plotting.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def _set_ticks_inwards(fig):
|
|
6
|
+
"""
|
|
7
|
+
Set the direction of ticks on the axes to inwards.
|
|
8
|
+
|
|
9
|
+
Parameters:
|
|
10
|
+
fig (matplotlib.figure.Figure): The figure to modify.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
matplotlib.figure.Figure: The modified figure.
|
|
14
|
+
"""
|
|
15
|
+
for ax in fig.axes:
|
|
16
|
+
ax.tick_params(direction='in')
|
|
17
|
+
|
|
18
|
+
return fig
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def nature_single_column(fig):
|
|
23
|
+
"""
|
|
24
|
+
Adjusts the size and tick orientation of a matplotlib figure to match the
|
|
25
|
+
single-column format typically used in Nature journal publications.
|
|
26
|
+
Parameters:
|
|
27
|
+
fig (matplotlib.figure.Figure): The figure to be adjusted.
|
|
28
|
+
Returns:
|
|
29
|
+
matplotlib.figure.Figure: The adjusted figure.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
fig.set_size_inches(3.5, 2.5)
|
|
33
|
+
|
|
34
|
+
_set_ticks_inwards(fig)
|
|
35
|
+
|
|
36
|
+
return fig
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def nature_double_column(fig):
|
|
40
|
+
"""
|
|
41
|
+
Adjusts the size of the given figure to fit a double column format for Nature journal.
|
|
42
|
+
Parameters:
|
|
43
|
+
fig (matplotlib.figure.Figure): The figure to be adjusted.
|
|
44
|
+
Returns:
|
|
45
|
+
matplotlib.figure.Figure: The adjusted figure with the new size.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
fig.set_size_inches(7.2, 4.5)
|
|
49
|
+
|
|
50
|
+
_set_ticks_inwards(fig)
|
|
51
|
+
|
|
52
|
+
return fig
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from numpy.polynomial.chebyshev import Chebyshev
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ChebychevFit:
|
|
6
|
+
|
|
7
|
+
def __init__(self, cheb_fit_R_to_T, cheb_fit_T_to_R):
|
|
8
|
+
self.cheb_fit_R_to_T = cheb_fit_R_to_T
|
|
9
|
+
self.cheb_fit_T_to_R = cheb_fit_T_to_R
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def resistance_to_temperature(self, resistance):
|
|
13
|
+
"""
|
|
14
|
+
Convert resistance to temperature using the Chebyshev fit.
|
|
15
|
+
Parameters:
|
|
16
|
+
resistance (float): Resistance in ohms.
|
|
17
|
+
Returns:
|
|
18
|
+
float: Temperature in Kelvin.
|
|
19
|
+
"""
|
|
20
|
+
log_R = np.log10(resistance)
|
|
21
|
+
log_T = self.cheb_fit_R_to_T(log_R)
|
|
22
|
+
return 10**log_T
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def temperature_to_resistance(self, temperature):
|
|
26
|
+
"""
|
|
27
|
+
Convert temperature to resistance using the Chebyshev fit.
|
|
28
|
+
Parameters:
|
|
29
|
+
temperature (float): Temperature in Kelvin.
|
|
30
|
+
Returns:
|
|
31
|
+
float: Resistance in ohms.
|
|
32
|
+
"""
|
|
33
|
+
log_T = np.log10(temperature)
|
|
34
|
+
log_R = self.cheb_fit_T_to_R(log_T)
|
|
35
|
+
return 10**log_R
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def fit_chebyshev_polynomial(df, resistance_column='resistance', temperature_column='temperature', order=7):
|
|
39
|
+
"""
|
|
40
|
+
Fits Chebyshev polynomials to log-log data for resistance vs. temperature.
|
|
41
|
+
|
|
42
|
+
Parameters:
|
|
43
|
+
df (pandas.DataFrame): DataFrame containing 'resistance' and 'temperature' columns.
|
|
44
|
+
resistance_column (str): Name of the column containing resistance data.
|
|
45
|
+
temperature_column (str): Name of the column containing temperature data.
|
|
46
|
+
order (int): Order of the Chebyshev polynomial.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
tuple: (Chebyshev object for R->T, Chebyshev object for T->R)
|
|
50
|
+
"""
|
|
51
|
+
log_R = np.log10(df[resistance_column])
|
|
52
|
+
log_T = np.log10(df[temperature_column])
|
|
53
|
+
|
|
54
|
+
cheb_fit_R_to_T = Chebyshev.fit(log_R, log_T, order)
|
|
55
|
+
cheb_fit_T_to_R = Chebyshev.fit(log_T, log_R, order)
|
|
56
|
+
|
|
57
|
+
return ChebychevFit(cheb_fit_R_to_T, cheb_fit_T_to_R)
|
|
58
|
+
|
quantalyze/transport.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def calculate_resistance(df, voltage, current):
|
|
5
|
+
"""
|
|
6
|
+
Calculate the electrical resistance using voltage and current.
|
|
7
|
+
|
|
8
|
+
Parameters:
|
|
9
|
+
df (pandas.DataFrame): The dataframe containing the data.
|
|
10
|
+
voltage (str): The name of the column in the dataframe that contains the voltage values.
|
|
11
|
+
current (str or float): The name of the column in the dataframe that contains the current values if it's a string,
|
|
12
|
+
or a constant current value if it's a float.
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
pandas.Series: A series containing the calculated resistance values.
|
|
16
|
+
"""
|
|
17
|
+
if isinstance(current, str):
|
|
18
|
+
resistance = df[voltage] / df[current]
|
|
19
|
+
else:
|
|
20
|
+
resistance = df[voltage] / current
|
|
21
|
+
return resistance
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def calculate_resistivity(df, length=None, width=None, thickness=None, resistance=None, voltage=None, current=None, geometric_factor=None):
|
|
25
|
+
"""
|
|
26
|
+
Calculate the electrical resistivity using either resistance or voltage and current, along with length, width, and thickness,
|
|
27
|
+
or a provided geometric factor.
|
|
28
|
+
|
|
29
|
+
Parameters:
|
|
30
|
+
df (pandas.DataFrame): The dataframe containing the data.
|
|
31
|
+
resistance (str, optional): The name of the column in the dataframe that contains the resistance values.
|
|
32
|
+
voltage (str, optional): The name of the column in the dataframe that contains the voltage values.
|
|
33
|
+
current (str or float, optional): The name of the column in the dataframe that contains the current values if it's a string,
|
|
34
|
+
or a constant current value if it's a float.
|
|
35
|
+
length (float, optional): The length of the material.
|
|
36
|
+
width (float, optional): The width of the material.
|
|
37
|
+
thickness (float, optional): The thickness of the material.
|
|
38
|
+
geometric_factor (float, optional): The pre-calculated geometric factor (width * thickness / length).
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
pandas.Series: A series containing the calculated resistivity values.
|
|
42
|
+
"""
|
|
43
|
+
if resistance is None:
|
|
44
|
+
if voltage is not None and current is not None:
|
|
45
|
+
resistance = calculate_resistance(df, voltage, current)
|
|
46
|
+
else:
|
|
47
|
+
raise ValueError("Either resistance or both voltage and current must be provided.")
|
|
48
|
+
else:
|
|
49
|
+
resistance = df[resistance]
|
|
50
|
+
|
|
51
|
+
if geometric_factor is None:
|
|
52
|
+
if length is not None and width is not None and thickness is not None:
|
|
53
|
+
geometric_factor = (width * thickness) / length
|
|
54
|
+
else:
|
|
55
|
+
raise ValueError("Either geometric_factor or all of length, width, and thickness must be provided.")
|
|
56
|
+
|
|
57
|
+
resistivity = resistance * geometric_factor
|
|
58
|
+
return resistivity
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def calculate_hall_resistance(df, hall_voltage, current):
|
|
62
|
+
"""
|
|
63
|
+
Calculate the Hall resistance using the Hall voltage and current.
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
df (pandas.DataFrame): The dataframe containing the data.
|
|
67
|
+
hall_voltage (str): The name of the column in the dataframe that contains the Hall voltage values.
|
|
68
|
+
current (str or float): The name of the column in the dataframe that contains the current values if it's a string,
|
|
69
|
+
or a constant current value if it's a float.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
pandas.Series: A series containing the calculated Hall resistance values.
|
|
73
|
+
"""
|
|
74
|
+
if isinstance(current, str):
|
|
75
|
+
hall_resistance = df[hall_voltage] / df[current]
|
|
76
|
+
else:
|
|
77
|
+
hall_resistance = df[hall_voltage] / current
|
|
78
|
+
return hall_resistance
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def calculate_hall_resistivity(df, hall_resistance=None, hall_voltage=None, current=None, thickness=None):
|
|
82
|
+
"""
|
|
83
|
+
Calculate the Hall resistivity using either Hall resistance or Hall voltage and current, along with thickness.
|
|
84
|
+
|
|
85
|
+
Parameters:
|
|
86
|
+
df (pandas.DataFrame): The dataframe containing the data.
|
|
87
|
+
hall_resistance (str, optional): The name of the column in the dataframe that contains the Hall resistance values.
|
|
88
|
+
hall_voltage (str, optional): The name of the column in the dataframe that contains the Hall voltage values.
|
|
89
|
+
current (str or float, optional): The name of the column in the dataframe that contains the current values if it's a string,
|
|
90
|
+
or a constant current value if it's a float.
|
|
91
|
+
thickness (float, optional): The thickness of the material.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
pandas.Series: A series containing the calculated Hall resistivity values.
|
|
95
|
+
"""
|
|
96
|
+
if hall_resistance is None:
|
|
97
|
+
if hall_voltage is not None and current is not None:
|
|
98
|
+
hall_resistance = calculate_hall_resistance(df, hall_voltage, current)
|
|
99
|
+
else:
|
|
100
|
+
raise ValueError("Either hall_resistance or both hall_voltage and current must be provided.")
|
|
101
|
+
else:
|
|
102
|
+
hall_resistance = df[hall_resistance]
|
|
103
|
+
|
|
104
|
+
if thickness is None:
|
|
105
|
+
raise ValueError("Thickness must be provided.")
|
|
106
|
+
|
|
107
|
+
hall_resistivity = hall_resistance * thickness
|
|
108
|
+
return hall_resistivity
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quantalyze
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Requires-Dist: matplotlib>=3.9.4
|
|
7
|
+
Requires-Dist: numpy>=2.0.2
|
|
8
|
+
Requires-Dist: pandas>=2.2.3
|
|
9
|
+
Requires-Dist: pytest>=8.3.5
|
|
10
|
+
Requires-Dist: scipy>=1.13.1
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# Quantalyze
|
|
14
|
+
|
|
15
|
+
Utilities for analyzing data.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
quantalyze/__init__.py,sha256=3USGRwzlSkskP6c7CcsBI98x8kxmg4awtE9__sPpvFU,117
|
|
2
|
+
quantalyze/plotting.py,sha256=SlimI-IoUyZaUiFQB64GsICiR1fCgFLm9OTYF9Em1C4,1221
|
|
3
|
+
quantalyze/thermometry.py,sha256=O3-f4o98dgDE4A8pbYgYz-IKaGYRfjWeZdjUA-hEzlw,1971
|
|
4
|
+
quantalyze/transport.py,sha256=5zTAhjQnCeygFhh5Sl2tW6r3asB2PdeQqOfwvGM1x_c,4978
|
|
5
|
+
quantalyze/core/__init__.py,sha256=-J7Z3wnRyO8V8v05Nis0fCG2S9wF2c-YXT14ex52mTo,234
|
|
6
|
+
quantalyze/core/differentiation.py,sha256=XtOQaTwZoXl0jiKfq3cqR44q_daYsh03w6r-eolGTNg,2591
|
|
7
|
+
quantalyze/core/fft.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
quantalyze/core/fitting.py,sha256=7iVmukOzaA8WhQ2UOqSZdAtWO9-ntTLZsNavoX-Sr0g,3348
|
|
9
|
+
quantalyze/core/interpolation.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
quantalyze/core/smoothing.py,sha256=0Z0Pd5S0FyhmysrHmYnXj_UJI2Fj5HnHnCeJCI5GLuE,2781
|
|
11
|
+
quantalyze/core/symmetrize.py,sha256=KRXwAkkBrULV1rTyYVgPFAhbdYD4wZFaM2GSlaKDFt0,2488
|
|
12
|
+
quantalyze-0.1.0.dist-info/METADATA,sha256=ZLx6GGXh9UQd6YPVD8XFIIHDYsvL3C0YQ81DiXxn968,344
|
|
13
|
+
quantalyze-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
quantalyze-0.1.0.dist-info/RECORD,,
|