本文整理汇总了Python中numpy.arcsinh函数的典型用法代码示例。如果您正苦于以下问题:Python arcsinh函数的具体用法?Python arcsinh怎么用?Python arcsinh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arcsinh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int_pot_2D_moi
def int_pot_2D_moi(self, xp, yp, x, R, h, basis_func):
"""FWD model function. Incorporates the Method of Images.
Returns contribution of a point xp,yp, belonging to a basis source
support centered at (0,0) to the potential measured at (x,0),
integrated over xp,yp gives the potential generated by a
basis source element centered at (0,0) at point (x,0)
#Eq 20, Ness(2015)
Parameters
----------
xp, yp : floats or np.arrays
point or set of points where function should be calculated
x : float
position at which potential is being measured
R : float
The size of the basis function
h : float
thickness of slice
basis_func : method
Fuction of the basis source
Returns
-------
pot : float
"""
L = ((x-xp)**2 + yp**2)**(0.5)
if L < 0.00001:
L = 0.00001
correction = np.arcsinh((h-(2*h*self.iters))/L) + np.arcsinh((h+(2*h*self.iters))/L)
pot = np.arcsinh(h/L) + np.sum(self.iter_factor*correction)
dist = np.sqrt(xp**2 + yp**2)
pot *= basis_func(dist, R) # Eq 20, Ness et.al.
return pot
示例2: plot_IQU
def plot_IQU(solution, title, col, ncol=6, coord='C'):
# Es=solution[np.array(final_index).tolist()].reshape((4, len(final_index)/4))
# I = Es[0] + Es[3]
# Q = Es[0] - Es[3]
# U = Es[1] + Es[2]
IQUV = sol2map(solution)
IQUV.shape = (4, IQUV.shape[0] / 4)
I = IQUV[0]
Q = IQUV[1]
U = IQUV[2]
V = IQUV[3]
pangle = 180 * np.arctan2(Q, U) / 2 / PI
plotcoordtmp = coord
hpv.mollview(np.log10(I), min=0, max=4, coord=plotcoordtmp, title=title, nest=True, sub=(4, ncol, col))
hpv.mollview((Q ** 2 + U ** 2) ** .5 / I, min=0, max=1, coord=plotcoordtmp, title=title, nest=True,
sub=(4, ncol, ncol + col))
from matplotlib import cm
cool_cmap = cm.hsv
cool_cmap.set_under("w") # sets background to white
hpv.mollview(pangle, min=-90, max=90, coord=plotcoordtmp, title=title, nest=True, sub=(4, ncol, 2 * ncol + col),
cmap=cool_cmap)
hpv.mollview(np.arcsinh(V) / np.log(10), min=-np.arcsinh(10. ** 4) / np.log(10),
max=np.arcsinh(10. ** 4) / np.log(10), coord=plotcoordtmp, title=title, nest=True,
sub=(4, ncol, 3 * ncol + col))
if col == ncol:
plt.show()
开发者ID:jeffzhen,项目名称:simulate_visibilities,代码行数:28,代码来源:map_making_dynamic_polarized_fast_cholesky.py
示例3: Scale_asinh
def Scale_asinh(inputArray, scale_min=None, scale_max=None, non_linear=2.0):
"""Scale_asinh(inputArray, scale_min=None, scale_max=None, non_linear=2.0)
Performs asinh scaling of the input numpy array.
(from Min-Su Shin, Princeton)
inputArray: image data array
scale_min (None): minimum data value
use inputArray.min() if None
scale_max (None): maximum data value
use inputArray.max() if None
non_linear (2.0): non-linearity factor
>>> scaledArray = Scale_asinh(inputArray)
"""
imageData=numpy.array(inputArray, copy=True)
if scale_min == None:
scale_min = imageData.min()
if scale_max == None:
scale_max = imageData.max()
factor = numpy.arcsinh((scale_max - scale_min)/non_linear)
indices0 = numpy.where(imageData < scale_min)
indices1 = numpy.where((imageData >= scale_min) & (imageData <= scale_max))
indices2 = numpy.where(imageData > scale_max)
imageData[indices0] = 0.0
imageData[indices2] = 1.0
imageData[indices1] = numpy.arcsinh((imageData[indices1] - scale_min)/non_linear)/factor
return imageData
示例4: imstretch
def imstretch(self):
data = np.clip(self.data_array, self.threshold[0], self.threshold[1])
if self.mode == "linear":
pass
elif self.mode == "logarithmic":
data = np.reciprocal(1 + np.power(0.5 / data, self.factor))
elif self.mode == "gamma":
data = np.power(data, self.factor)
elif self.mode == "arcsinh":
mn = np.nanmin(data)
mx = np.nanmax(data)
tmp = bytescale(data, high=1.0)
beta = np.clip(self.factor, 0.0, self.factor)
sclbeta = (beta - mn) / (mx - mn)
sclbeta = np.clip(sclbeta, 1.0e-12, sclbeta)
nonlinearity = 1.0 / sclbeta
extrema = np.arcsinh(np.array([0.0, nonlinearity]))
data = np.clip(np.arcsinh(data * nonlinearity), extrema[0], extrema[1])
elif self.mode == "square root":
data = np.sqrt(np.fabs(data)) * np.sign(data)
elif self.mode == "histogram equalization":
imhist, bins = np.histogram(data.flatten(), 256, normed=True)
cdf = imhist.cumsum() # cumulative distribution function
cdf = 255 * cdf / cdf[-1] # normalize
im2 = np.interp(data.flatten(), bins[:-1], cdf)
data = im2.reshape(data.shape)
self.scaled = bytescale(data).flatten().tolist()
示例5: asinh
def asinh(inputArray, scale_min=None, scale_max=None, non_linear=2.0):
"""Performs asinh scaling of the input numpy array.
@type inputArray: numpy array
@param inputArray: image data array
@type scale_min: float
@param scale_min: minimum data value
@type scale_max: float
@param scale_max: maximum data value
@type non_linear: float
@param non_linear: non-linearity factor
@rtype: numpy array
@return: image data array
"""
print "img_scale : asinh"
imageData=numpy.array(inputArray, copy=True)
if scale_min == None:
scale_min = imageData.min()
if scale_max == None:
scale_max = imageData.max()
factor = numpy.arcsinh((scale_max - scale_min)/non_linear)
indices0 = numpy.where(imageData < scale_min)
indices1 = numpy.where((imageData >= scale_min) & (imageData <= scale_max))
indices2 = numpy.where(imageData > scale_max)
imageData[indices0] = 0.0
imageData[indices2] = 1.0
imageData[indices1] = numpy.arcsinh((imageData[indices1] - \
scale_min)/non_linear)/factor
return imageData
示例6: load_minibatch
def load_minibatch(self, filepath, nimg, farts, gridsize, cg, num,cg_additional=1,twoclasses=False):
"""
Load a mini batch of images and their labels.
Labels need to be converted to tensorflow
format
inputs:
filepath -- Path where the files are located
nimg -- Number of images in the total batch
farts -- Fraction of artifacts
gridsize -- Number of pixels to a side
cg -- Coarsegraining factor
num -- The minibatch number
cg_additional -- additional coursegraining to perform on the fly
"""
X = np.load('{0}/X_{1}_{2}_{3}_{4}_mb{5}.npy'.format(filepath, nimg, farts, gridsize, cg, num))
y = np.load('{0}/y_{1}_{2}_{3}_{4}_mb{5}.npy'.format(filepath, nimg, farts, gridsize, cg, num))
X[X==-99] = np.nan
if cg_additional!=1:
X = np.mean(np.mean(X.reshape([X.shape[0],gridsize//cg,gridsize//cg//cg_additional,cg_additional]),axis=3).T.reshape(gridsize//cg//cg_additional,gridsize//cg//cg_additional,cg_additional,X.shape[0]),axis=2).T.reshape([X.shape[0],(gridsize//cg//cg_additional)**2])
X = 255*(np.arcsinh(X)-np.atleast_2d(np.arcsinh(np.nanmin(X,axis=1))).T)/np.atleast_2d((np.arcsinh(np.nanmax(X,axis=1))-np.arcsinh(np.nanmin(X,axis=1)))).T
X[np.isnan(X)] = 0
#X -= np.atleast_2d(np.mean(X,axis=1)).T
#print(np.nanmean(X, axis=1))
ey = self.convert_labels(y, twoclasses)
return X, ey
示例7: test_arcsinh
def test_arcsinh(self):
import math
from numpy import arcsinh
for v in [float("inf"), float("-inf"), 1.0, math.e]:
assert math.asinh(v) == arcsinh(v)
assert math.isnan(arcsinh(float("nan")))
示例8: test_asinh
def test_asinh(self):
"""Test arcsinh scaling."""
img = scale_image(DATA, scale='asinh')
mean, median, stddev = sigmaclip_stats(DATA, sigma=3.0)
z = (mean + (2.0 * stddev)) / 2.
ref = np.arcsinh(DATASCL / z) / np.arcsinh(1.0 / z)
assert_allclose(img, ref, atol=0, rtol=1.e-5)
示例9: __call__
def __call__(self, value):
self.autoscale_None(value) # set vmin, vmax if unset
inverted = self.vmax <= self.vmin
hi, lo = max(self.vmin, self.vmax), min(self.vmin, self.vmax)
ra = hi - lo
mid = lo + ra * self.bias
mn = mid - ra * self.contrast
mx = mid + ra * self.contrast
if self.stretch == "linear":
result = (value - mn) * (1.0 / (mx - mn))
result = np.clip(result, 0, 1)
elif self.stretch == "arcsinh":
b = max(self.bias, 1e-5)
c = self.contrast
result = (value - lo) / (1.0 * (hi - lo))
result = np.arcsinh(result / b) / np.arcsinh((b + c) / b)
result = np.clip(result, 0, 1)
elif self.stretch == "sqrt":
result = (value - mn) * (1.0 / (mx - mn))
result = np.clip(result, 0, 1)
result = np.sqrt(result)
else:
raise TypeError("Invalid stretch: %s" % self.stretch)
if inverted:
result = 1 - result
return result
示例10: scale_two_arcsinh
def scale_two_arcsinh(x,up1,up2,down1,down2,m="normal"):
if m != "inverse":
if x >= 0: return up1*np.arcsinh(x*up2)
if x < 0: return down1*np.arcsinh(x*down2)
else:
if x >= 0: return 1./up2*np.sinh(x/up1)
if x < 0: return 1./down2*np.sinh(x/down1)
示例11: newspace
def newspace(high):
Smax = high
K = exact
deps = 1./size * (np.arcsinh((Smax - K)*(1/density)) - np.arcsinh(-K/density))
eps = np.arcsinh(-K/density) + np.arange(size)*deps
space = K + density * np.sinh(eps)
space -= min(space)
return space
示例12: test_arcsinh
def test_arcsinh():
a = afnumpy.random.random((2,3))
b = numpy.array(a)
fassert(afnumpy.arcsinh(a), numpy.arcsinh(b))
c = afnumpy.random.random((2,3))
d = numpy.array(a)
fassert(afnumpy.arcsinh(a, out=c), numpy.arcsinh(b, out=d))
fassert(c, d)
示例13: __call__
def __call__(self, values, out=None, clip=True):
values = _prepare(values, out=out, clip=clip)
np.true_divide(values, self.a, out=values)
np.arcsinh(values, out=values)
np.true_divide(values, np.arcsinh(1. / self.a), out=values)
return values
示例14: elec_catenary_hyperbolic_lowest_proj
def elec_catenary_hyperbolic_lowest_proj ( T0, w, l, h):
Lh0 = elec_catenary_hyperbolic_length_equal_high (T0, w, l)
if Lh0 != 0.:
a = l/2. - T0/w*np.arcsinh(h/Lh0)
b = l/2. + T0/w*np.arcsinh(h/Lh0)
else:
a = l/2.
b = l/2.
return a
示例15: asinh
def asinh(x):
"""
Inverse hyperbolic sine
"""
if isinstance(x, UncertainFunction):
mcpts = np.arcsinh(x._mcpts)
return UncertainFunction(mcpts)
else:
return np.arcsinh(x)