本文整理汇总了Python中scipy.interpolate.UnivariateSpline方法的典型用法代码示例。如果您正苦于以下问题:Python interpolate.UnivariateSpline方法的具体用法?Python interpolate.UnivariateSpline怎么用?Python interpolate.UnivariateSpline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.interpolate
的用法示例。
在下文中一共展示了interpolate.UnivariateSpline方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: smooth_elevation
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def smooth_elevation(df, smooth=4):
if not present(df, Names.ELEVATION):
log.debug(f'Smoothing {Names.RAW_ELEVATION} to get {Names.ELEVATION}')
unique = df.loc[~df[Names.DISTANCE].isna() & ~df[Names.RAW_ELEVATION].isna(),
[Names.DISTANCE, Names.RAW_ELEVATION]].drop_duplicates(Names.DISTANCE)
# the smoothing factor is from eyeballing results only. maybe it should be a parameter.
# it seems better to smooth along the route rather that smooth the terrain model since
# 1 - we expect the route to be smoother than the terrain in general (roads / tracks)
# 2 - smoothing the 2d terrain is difficult to control and can give spikes
# 3 - we better handle errors from mismatches between terrain model and position
# (think hairpin bends going up a mountainside)
# the main drawbacks are
# 1 - speed on loading
# 2 - no guarantee of consistency between routes (or even on the same routine retracing a path)
spline = UnivariateSpline(unique[Names.DISTANCE], unique[Names.RAW_ELEVATION], s=len(unique) * smooth)
df[Names.ELEVATION] = spline(df[Names.DISTANCE])
df[Names.GRADE] = (spline.derivative()(df[Names.DISTANCE]) / 10) # distance in km
df[Names.GRADE] = df[Names.GRADE].rolling(5, center=True).median().ffill().bfill()
# avoid extrapolation / interpolation
df.loc[df[Names.RAW_ELEVATION].isna(), [Names.ELEVATION]] = None
return df
示例2: linewidth
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def linewidth(f, a):
"""Calculate the full-width at half maximum (FWHM) of an absorption line.
Parameters:
f (ndarray): Frequency grid.
a (ndarray): Line properties
(e.g. absorption coefficients or cross-sections).
Returns:
float: Linewidth.
Examples:
>>> f = np.linspace(0, np.pi, 100)
>>> a = np.sin(f)**2
>>> linewidth(f, a)
1.571048056449009
"""
s = interpolate.UnivariateSpline(f, a - np.max(a)/2, s=0)
return float(np.diff(s.roots()))
示例3: compute_depth_gravity_profiles
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def compute_depth_gravity_profiles(pressures, densities, surface_gravity, outer_radius):
gravity = [surface_gravity] * len(pressures) # starting guess
n_gravity_iterations = 5
for i in range(n_gravity_iterations):
# Integrate the hydrostatic equation
# Make a spline fit of densities as a function of pressures
rhofunc = UnivariateSpline(pressures, densities)
# Make a spline fit of gravity as a function of depth
gfunc = UnivariateSpline(pressures, gravity)
# integrate the hydrostatic equation
depths = np.ravel(odeint((lambda p, x: 1./(gfunc(x) * rhofunc(x))), 0.0, pressures))
radii = outer_radius - depths
rhofunc = UnivariateSpline(radii[::-1], densities[::-1])
poisson = lambda p, x: 4.0 * np.pi * burnman.constants.G * rhofunc(x) * x * x
gravity = np.ravel(odeint(poisson, surface_gravity*radii[0]*radii[0], radii))
gravity = gravity / radii / radii
return depths, gravity
# BEGIN USER INPUTS
# Declare the rock we want to use
示例4: _compute_gravity
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def _compute_gravity(self, density, gravity_bottom):
"""
Computes the gravity of a layer
Used by _evaluate_eos()
"""
# Create a spline fit of density as a function of radius
rhofunc = UnivariateSpline(self.radii, density)
# Numerically integrate Poisson's equation
def poisson(p, x): return 4.0 * np.pi * \
constants.G * rhofunc(x) * x * x
grav = np.ravel(
odeint( poisson, gravity_bottom *
self.radii[0] * self.radii[0], self.radii))
if self.radii[0] == 0:
grav[0] = 0
grav[1:] = grav[1:] / self.radii[1:] / self.radii[1:]
else:
grav[:] = grav[:] / self.radii[:] / self.radii[:]
return grav
示例5: _compute_pressure
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def _compute_pressure(self, density, gravity, pressure_top):
"""
Calculate the pressure profile based on density and gravity. This integrates
the equation for hydrostatic equilibrium P = rho g z.
Used by _evaluate_eos()
"""
# flip radius, density and gravity to increasing pressure
depthfromtop = -self.radii[::-1] + max(self.radii)
density = density[::-1]
gravity = gravity[::-1]
# Make a spline fit of density as a function of depth
rhofunc = UnivariateSpline(depthfromtop, density)
# Make a spline fit of gravity as a function of depth
gfunc = UnivariateSpline(depthfromtop, gravity)
# integrate the hydrostatic equation
pressure = np.ravel(
odeint((lambda p, x: gfunc(x) * rhofunc(x)), pressure_top, depthfromtop))
return pressure[::-1]
示例6: fit_policy_function
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def fit_policy_function(self,PF):
'''
Fits the policy functions PF using the points xgrid using UnivariateSpline
'''
xgrid,S = self.xgrid,self.S
Vf,cf,nf,xprimef = {},{},{},{}
for s in range(S):
PFvec = np.vstack(map(lambda x:PF(x,s),xgrid))
Vf[s] = UnivariateSpline(xgrid,PFvec[:,0],s=0)
cf[s] = UnivariateSpline(xgrid,PFvec[:,1],s=0,k=1)
nf[s] = UnivariateSpline(xgrid,PFvec[:,2],s=0,k=1)
for sprime in range(S):
xprimef[s,sprime] = UnivariateSpline(xgrid,PFvec[:,3+sprime],s=0,k=1)
return Vf,[cf,nf,xprimef]
示例7: fit_policy_function
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def fit_policy_function(self, PF):
'''
Fits the policy functions PF using the points xgrid using UnivariateSpline
'''
xgrid, S = self.xgrid, self.S
Vf, cf, nf, xprimef = {}, {}, {}, {}
for s in range(S):
PFvec = np.vstack(map(lambda x: PF(x, s), xgrid))
Vf[s] = UnivariateSpline(xgrid, PFvec[:, 0], s=0)
cf[s] = UnivariateSpline(xgrid, PFvec[:, 1], s=0, k=1)
nf[s] = UnivariateSpline(xgrid, PFvec[:, 2], s=0, k=1)
for sprime in range(S):
xprimef[s, sprime] = UnivariateSpline(
xgrid, PFvec[:, 3 + sprime], s=0, k=1)
return Vf, [cf, nf, xprimef]
示例8: fit_policy_function
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def fit_policy_function(self,PF):
'''
Fits the policy functions PF using the points xgrid using UnivariateSpline
'''
xgrid,S = self.xgrid,self.S
Vf,cf,nf,xprimef = {},{},{},{}
for s in range(S):
PFvec = np.vstack(map(lambda x:PF(x,s),xgrid))
Vf[s] = UnivariateSpline(xgrid,PFvec[:,0],s=0)
cf[s] = UnivariateSpline(xgrid,PFvec[:,1],s=0,k=1)
nf[s] = UnivariateSpline(xgrid,PFvec[:,2],s=0,k=1)
for sprime in range(S):
xprimef[s,sprime] = UnivariateSpline(xgrid,PFvec[:,3+sprime],s=0,k=1)
return Vf,[cf,nf,xprimef]
示例9: set_table
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def set_table(self, n=100, dx=None):
r'''Method to set an interpolation table of liquids levels versus
volumes in the tank, for a fully defined tank. Normally run by the
h_from_V method, this may be run prior to its use with a custom
specification. Either the number of points on the table, or the
vertical distance between steps may be specified.
Parameters
----------
n : float, optional
Number of points in the interpolation table, [-]
dx : float, optional
Vertical distance between steps in the interpolation table, [m]
'''
if dx:
self.heights = linspace(0.0, self.h_max, int(self.h_max/dx)+1)
else:
self.heights = linspace(0.0, self.h_max, n)
self.volumes = [self.V_from_h(h) for h in self.heights]
from scipy.interpolate import UnivariateSpline
self.interp_h_from_V = UnivariateSpline(self.volumes, self.heights, ext=3, s=0.0)
self.table = True
示例10: _residual
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def _residual(param, radial, profile, previous):
""" `scipy.optimize.leastsq` residuals function.
Evaluate the difference between a radial-scaled intensity profile
and its adjacent "previous" angular slice.
"""
radial_scaling, amplitude = param[0], param[1]
newradial = radial * radial_scaling
spline_prof = UnivariateSpline(newradial, profile, s=0, ext=3)
newprof = spline_prof(radial) * amplitude
# residual cf adjacent slice profile
return newprof - previous
示例11: roc
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def roc():
'''
Plots an ROC curve illustrating the performance of the classifier used in
grain detection.
'''
n_classes = 2
clf = get_model()
(train_data, train_targets, test_data, test_targets) = Helper.unserialize("../Datasets/new_data_glcm_d1_a4_75_25.data")
y_score = clf.decision_function(test_data)
fpr, tpr, thresholds = metrics.roc_curve(test_targets, y_score)
xnew = np.linspace(fpr.min(),fpr.max(),300)
spl = UnivariateSpline(fpr,tpr)
plt.figure()
plt.plot(fpr, tpr, label='Exact ROC curve')
plt.plot(xnew, spl(xnew), label='Smoothed ROC curve', color='red', linestyle='--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('1 - Specificity (False Positive Rate)')
plt.ylabel('Sensitivity (True Positive Rate)')
plt.title('Receiver Operating Characteristic curve')
plt.legend(loc="lower right")
plt.show()
示例12: fit_inv_pdf
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def fit_inv_pdf(ladder_energies):
""" Fit an interpolant to the inverse pdf of ladder energies
Nasty hack to allow drawing energies from arbitrary distributions of ladder_energies
Args:
ladder_energies: array, output of ladder_numerical_err_hist
Returns:
interp_inv_pdf: inverse pdf interpolant
"""
hist, bin_edges = np.histogram(ladder_energies, bins='auto')
bin_mdpts = (np.diff(bin_edges) / 2) + bin_edges[:-1]
# interpolation backward using slope bin_mdpts[1] - bin_mdpts[0]
zero_interp_mdpt = -2 * bin_mdpts[0] + bin_mdpts[1]
pdf = np.cumsum(hist) / np.sum(hist)
# we add zero so that the interpolation is defined everywhere on [0, 1]
pdf = np.concatenate([[0], pdf])
bin_mdpts = np.concatenate([[zero_interp_mdpt], bin_mdpts])
return UnivariateSpline(pdf, bin_mdpts, bbox=[0, 1], k=1)
示例13: on_iteration_end
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def on_iteration_end(self, iteration, status=None):
y = status['unfolded']
x = np.arange(len(y), dtype=float)
if self.groups is None:
spline = UnivariateSpline(x, y, k=self.degree, s=self.smooth)
fitted_unfolded = spline(x)
else:
# Check that a group is specified for each cause bin
if len(self.groups) != len(y):
err_msg = ('Invalid groups array. There should be an entry '
'for each cause bin. However, got len(groups)={} '
'while there are {} cause bins.'.format(len(self.groups), len(y)))
raise ValueError(err_msg)
fitted_unfolded = np.empty(len(y))
group_ids = np.unique(self.groups)
for group in group_ids:
group_mask = self.groups == group
x_group = x[group_mask]
y_group = y[group_mask]
spline_group = UnivariateSpline(x_group, y_group, k=self.degree, s=self.smooth)
fitted_unfolded_group = spline_group(x_group)
fitted_unfolded[group_mask] = fitted_unfolded_group
status['unfolded'] = fitted_unfolded
示例14: test_Zukauskas_tube_row_correction_refit
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def test_Zukauskas_tube_row_correction_refit():
from scipy.interpolate import UnivariateSpline
from ht.conv_tube_bank import Zukauskas_Czs_low_Re_staggered, Zukauskas_Czs_high_Re_staggered, Zukauskas_Czs_inline
# Commands used to obtain the fitted data:
Zukauskas_Cz_Zs = [0.968219, 1.01968, 1.04164, 1.04441, 1.07539, 1.09332, 1.13914, 1.16636, 1.23636, 1.2394, 1.24505, 1.3125, 1.33358, 1.38554, 1.43141, 1.48282, 1.4876, 1.55352, 1.58004, 1.60466, 1.65726, 1.67493, 1.70188, 1.79682, 1.91823, 1.99323, 1.99665, 2.04002, 2.16306, 2.18556, 2.19045, 2.30691, 2.3086, 2.36006, 2.45272, 2.45413, 2.57543, 2.59826, 2.72341, 2.7451, 2.8896, 2.91482, 2.98759, 3.1572, 3.23203, 3.25334, 3.3511, 3.42295, 3.4499, 3.52072, 3.6168, 3.83565, 3.9076, 3.9826, 4.02939, 4.17411, 4.20042, 4.44242, 4.48937, 4.61023, 4.82811, 4.95071, 5.07038, 5.28825, 5.31232, 5.3621, 5.50606, 5.53014, 5.60405, 5.74801, 5.74807, 5.82181, 5.99012, 5.99017, 6.13636, 6.23207, 6.23212, 6.37826, 6.44983, 6.44988, 6.62015, 6.69183, 6.69188, 6.95807, 6.95812, 6.98312, 7.1767, 7.20001, 7.41772, 7.41848, 7.65967, 7.87743, 7.90156, 7.95003, 7.97416, 7.97476, 8.21606, 8.2166, 8.45795, 8.60365, 8.67571, 8.79712, 8.91809, 8.96597, 9.18368, 9.20824, 9.42551, 9.45013, 9.66741, 9.69197, 10.0786, 10.3208, 10.5623, 10.5626, 10.7803, 10.9737, 10.9978, 11.2398, 11.2399, 11.4574, 11.4575, 11.6993, 11.7478, 11.9653, 11.9896, 12.2072, 12.2315, 12.4491, 12.691, 12.7152, 12.9812, 13.2231, 13.2715, 13.465, 13.7068, 13.9246, 13.9487, 14.1905, 14.4324, 14.6743, 14.9161, 14.9887, 15.2305, 15.4724, 15.7142, 15.787, 15.811, 15.8835, 16.0046, 16.0287, 16.2465, 16.3673, 16.4883, 16.5124, 16.706, 16.7301, 16.9477, 16.9479, 17.1897, 17.2138, 17.4315, 17.6734, 17.9152, 17.9636, 18.2054, 18.2055, 18.4473, 18.6891, 18.9068, 18.931, 18.9793, 19.2212, 19.4631, 19.5599, 19.7049, 19.9467, 19.9952]
low_Re_staggered_Cz = [0.828685, 0.831068, 0.832085, 0.832213, 0.833647, 0.834478, 0.836599, 0.83786, 0.8411, 0.841241, 0.841503, 0.845561, 0.84683, 0.849956, 0.852715, 0.855808, 0.856096, 0.859148, 0.860376, 0.861516, 0.863952, 0.864828, 0.866165, 0.870874, 0.876897, 0.880617, 0.880787, 0.882293, 0.886566, 0.887348, 0.887517, 0.89214, 0.892207, 0.894249, 0.897396, 0.897444, 0.901563, 0.902338, 0.906589, 0.907258, 0.911719, 0.912497, 0.914744, 0.91998, 0.92229, 0.922729, 0.92474, 0.926218, 0.926772, 0.928561, 0.930987, 0.936514, 0.938332, 0.940226, 0.940947, 0.943179, 0.943584, 0.946941, 0.947769, 0.9499, 0.95374, 0.955902, 0.957529, 0.960492, 0.96082, 0.961497, 0.962826, 0.963048, 0.96373, 0.965208, 0.965208, 0.965965, 0.967759, 0.96776, 0.969318, 0.969757, 0.969758, 0.970428, 0.970757, 0.970757, 0.971538, 0.972422, 0.972422, 0.975703, 0.975704, 0.976012, 0.978249, 0.978139, 0.977115, 0.977111, 0.977585, 0.978013, 0.97806, 0.978155, 0.978202, 0.978204, 0.97819, 0.97819, 0.979578, 0.980416, 0.980411, 0.980405, 0.981521, 0.981333, 0.980478, 0.980382, 0.981379, 0.981492, 0.981479, 0.981478, 0.982147, 0.982566, 0.982553, 0.982553, 0.98254, 0.981406, 0.98171, 0.98476, 0.984762, 0.98475, 0.98475, 0.984736, 0.984733, 0.985732, 0.985843, 0.986842, 0.986953, 0.985817, 0.986825, 0.986926, 0.986911, 0.987834, 0.988018, 0.988008, 0.987994, 0.991353, 0.991148, 0.98909, 0.9902, 0.990187, 0.991297, 0.991293, 0.991279, 0.991266, 0.992054, 0.992292, 0.99237, 0.992366, 0.992359, 0.992358, 0.993068, 0.993463, 0.993456, 0.993454, 0.994443, 0.994566, 0.994553, 0.994553, 0.99454, 0.994539, 0.996774, 0.99676, 0.996746, 0.996744, 0.99673, 0.99673, 0.997466, 0.998201, 0.998863, 0.998936, 0.99902, 0.999439, 0.999857, 1.00002, 1.00002, 1, 1]
high_Re_staggered_Cz = [0.617923, 0.630522, 0.635897, 0.636344, 0.64134, 0.644232, 0.651621, 0.654452, 0.661728, 0.662045, 0.662632, 0.669643, 0.671835, 0.683767, 0.694302, 0.704706, 0.705673, 0.719014, 0.721221, 0.72327, 0.727649, 0.729119, 0.73359, 0.749337, 0.759443, 0.770509, 0.771014, 0.777413, 0.785006, 0.786394, 0.786756, 0.795376, 0.795545, 0.800697, 0.809975, 0.810062, 0.817547, 0.818955, 0.829084, 0.830839, 0.842534, 0.843935, 0.847977, 0.857398, 0.861555, 0.862739, 0.866619, 0.869471, 0.870563, 0.873432, 0.877325, 0.886614, 0.889668, 0.89251, 0.894282, 0.899765, 0.900781, 0.910119, 0.911931, 0.916595, 0.921077, 0.925619, 0.930052, 0.932064, 0.932286, 0.933053, 0.935273, 0.935644, 0.937165, 0.940127, 0.940128, 0.941835, 0.945731, 0.945731, 0.947081, 0.947964, 0.947965, 0.949465, 0.950199, 0.9502, 0.952562, 0.953557, 0.953558, 0.958036, 0.958037, 0.958267, 0.960054, 0.96027, 0.961381, 0.961388, 0.963615, 0.964614, 0.964725, 0.965472, 0.965844, 0.965847, 0.966954, 0.966957, 0.968064, 0.96956, 0.970299, 0.970762, 0.971224, 0.971406, 0.972518, 0.972516, 0.972504, 0.972617, 0.973614, 0.97368, 0.974715, 0.975264, 0.975811, 0.975814, 0.978048, 0.980033, 0.980281, 0.982515, 0.982515, 0.982502, 0.982503, 0.983612, 0.98361, 0.983597, 0.983709, 0.984707, 0.984819, 0.985817, 0.985804, 0.985896, 0.986911, 0.986898, 0.98712, 0.988008, 0.987994, 0.988994, 0.989104, 0.98909, 0.9902, 0.990187, 0.991297, 0.991293, 0.991279, 0.991266, 0.991252, 0.995742, 0.994903, 0.992366, 0.99573, 0.995729, 0.995716, 0.99571, 0.995703, 0.995826, 0.996814, 0.996813, 0.996801, 0.996801, 0.996787, 0.996786, 0.996774, 0.99676, 0.997682, 0.997867, 0.997854, 0.997854, 0.99784, 0.997826, 0.997814, 0.997813, 0.99781, 0.99892, 0.998907, 0.998901, 0.998893, 0.998879, 0.998877]
inline_Cz = [0.658582, 0.681965, 0.69194, 0.6932, 0.700314, 0.704433, 0.710773, 0.714541, 0.724228, 0.724649, 0.725518, 0.735881, 0.738799, 0.74599, 0.751285, 0.75722, 0.757717, 0.76457, 0.767327, 0.776314, 0.781783, 0.783619, 0.786421, 0.794105, 0.803931, 0.81, 0.810227, 0.813093, 0.821227, 0.822615, 0.822917, 0.830103, 0.830207, 0.833383, 0.839101, 0.839188, 0.847046, 0.848103, 0.853898, 0.854902, 0.862547, 0.863881, 0.868371, 0.875104, 0.878568, 0.879555, 0.884081, 0.886933, 0.888003, 0.890813, 0.894236, 0.902032, 0.904114, 0.906285, 0.907639, 0.910812, 0.911389, 0.916696, 0.917725, 0.92029, 0.924912, 0.927513, 0.930052, 0.934534, 0.934906, 0.935673, 0.937893, 0.938227, 0.939252, 0.941249, 0.94125, 0.942957, 0.946853, 0.946854, 0.948204, 0.949088, 0.949088, 0.950588, 0.951322, 0.951323, 0.953685, 0.954679, 0.95468, 0.959159, 0.95916, 0.959274, 0.960163, 0.96027, 0.961381, 0.961388, 0.963615, 0.96585, 0.966222, 0.966969, 0.966968, 0.966968, 0.966954, 0.966957, 0.968064, 0.96956, 0.970299, 0.970762, 0.971224, 0.971406, 0.972518, 0.972516, 0.972504, 0.972617, 0.973614, 0.973737, 0.975675, 0.976888, 0.978099, 0.9781, 0.979191, 0.98016, 0.980281, 0.982515, 0.982515, 0.982502, 0.982503, 0.983612, 0.98361, 0.983597, 0.983709, 0.984707, 0.984819, 0.985817, 0.985804, 0.985896, 0.986911, 0.986898, 0.98712, 0.988008, 0.987994, 0.988994, 0.989104, 0.98909, 0.9902, 0.990187, 0.991297, 0.991293, 0.991279, 0.991266, 0.991252, 0.995742, 0.994903, 0.992366, 0.99573, 0.995729, 0.995716, 0.99571, 0.995703, 0.995826, 0.996814, 0.996813, 0.996801, 0.996801, 0.996787, 0.996786, 0.996774, 0.99676, 0.997682, 0.997867, 0.997854, 0.997854, 0.99784, 0.997826, 0.997814, 0.997813, 0.99781, 0.99892, 0.998907, 0.998901, 0.998893, 0.998879, 0.998877]
# hand tuned smoothing
Zukauskas_Cz_low_Re_staggered_obj = UnivariateSpline(Zukauskas_Cz_Zs, low_Re_staggered_Cz, s=0.0001)
Zukauskas_Cz_high_Re_staggered_obj = UnivariateSpline(Zukauskas_Cz_Zs, high_Re_staggered_Cz, s=0.0005)
Zukauskas_Cz_inline_obj = UnivariateSpline(Zukauskas_Cz_Zs, inline_Cz, s=0.0005)
Zukauskas_Czs_inline2 = np.round(Zukauskas_Cz_inline_obj(range(1, 20)), 4).tolist()
assert_allclose(Zukauskas_Czs_inline, Zukauskas_Czs_inline2)
Zukauskas_Czs_low_Re_staggered2 = np.round(Zukauskas_Cz_low_Re_staggered_obj(range(1, 20)), 4).tolist()
assert_allclose(Zukauskas_Czs_low_Re_staggered, Zukauskas_Czs_low_Re_staggered2)
Zukauskas_Czs_high_Re_staggered2 = np.round(Zukauskas_Cz_high_Re_staggered_obj(range(1, 20)), 4).tolist()
assert_allclose(Zukauskas_Czs_high_Re_staggered, Zukauskas_Czs_high_Re_staggered2)
示例15: test_baffle_correction_Bell_fit
# 需要导入模块: from scipy import interpolate [as 别名]
# 或者: from scipy.interpolate import UnivariateSpline [as 别名]
def test_baffle_correction_Bell_fit():
from ht.conv_tube_bank import Bell_baffle_configuration_tck
# 125 us to create.
spl = splrep(Bell_baffle_configuration_Fcs, Bell_baffle_configuration_Jcs, s=8e-5)
[assert_allclose(i, j) for (i, j) in zip(spl, Bell_baffle_configuration_tck)]
Bell_baffle_configuration_obj = UnivariateSpline(Bell_baffle_configuration_Fcs,
Bell_baffle_configuration_Jcs,
s=8e-5)
# import matplotlib.pyplot as plt
# plt.plot(Bell_baffle_configuration_Fcs, Bell_baffle_configuration_Jcs)
# pts = np.linspace(0, 1, 5000)
# plt.plot(pts, [Bell_baffle_configuration_obj(i) for i in pts])
# plt.plot(pts, [0.55 + 0.72*i for i in pts]) # Serth and HEDH 3.3.6g misses the tip
# plt.show()
#