pvtlib.utilities¶
MIT License
Copyright (c) 2025 Christian Hågenvik
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Functions
|
Calculates the difference between the observed value and the reference value |
|
Calculate the percentage deviation between the max and min value of an array, relative to the mean of the array |
|
Calculates the error percentage as the percentage difference between the observed value and the reference value |
|
Perform linear interpolation to estimate the value of a dependent variable y for a given independent variable x, based on a set of given x and y values. |
|
- pvtlib.utilities.linear_interpolation(x, x_values, y_values)[source]¶
Perform linear interpolation to estimate the value of a dependent variable y for a given independent variable x, based on a set of given x and y values.
If x is below lowest value in x_values the function returns the lowest value in y_values If x is above the highest value in x_values the function returns the highest value in y_values The calibration arrays must be sorted from lowest to highest x values (flow/Reynolds)
This function can for example be used for a calibration curve, where x could be the flow or Reynolds number and y could be the corresponding calibration error or discharge coefficient.
Parameters:¶
- xfloat
The independent variable value for which the dependent variable needs to be estimated.
- x_valueslist
A list of float values representing the x values of the data set used for interpolation.
- y_valueslist
A list of float values representing the y values of the data set used for interpolation.
Returns:¶
- yfloat
The estimated value of the dependent variable y for the given independent variable x.
- pvtlib.utilities.relative_difference(prop_A, prop_B)[source]¶
- Parameters:
prop_A (float) – property A
prop_B (float) – Property B
- Returns:
diff (float) – Relative difference between prop_A and prop_B [%]
- pvtlib.utilities.calculate_deviation(observed_value, reference_value)[source]¶
Calculates the difference between the observed value and the reference value
- Parameters:
observed_value (float) – Measurement by test object
reference_value (float) – Reference measurement
- Returns:
float – Difference between observed and reference value
- pvtlib.utilities.calculate_relative_deviation(observed_value, reference_value)[source]¶
Calculates the error percentage as the percentage difference between the observed value and the reference value
- Parameters:
observed_value (float) – Measurement by test object
reference_value (float) – Reference measurement
- Returns:
float – Error percentage between observed and measured value
- pvtlib.utilities.calculate_max_min_diffperc(array)[source]¶
Calculate the percentage deviation between the max and min value of an array, relative to the mean of the array
- Parameters:
array (list) – list, numpy array or similar object.
- Returns:
max_min_diff (float) – Difference percentage between max and min value of array relative to the mean of the array.