text
stringlengths 0
828
|
|---|
return self.get_xyz_2d(xcoord, x, ycoord, y, u, v)"
|
809,"def get_xyz_1d(self, xcoord, x, ycoord, y, u, v):
|
""""""Get closest x, y and z for the given `x` and `y` in `data` for
|
1d coords""""""
|
xclose = xcoord.indexes[xcoord.name].get_loc(x, method='nearest')
|
yclose = ycoord.indexes[ycoord.name].get_loc(y, method='nearest')
|
uval = u[yclose, xclose].values
|
vval = v[yclose, xclose].values
|
return xcoord[xclose].values, ycoord[yclose].values, uval, vval"
|
810,"def get_xyz_2d(self, xcoord, x, ycoord, y, u, v):
|
""""""Get closest x, y and z for the given `x` and `y` in `data` for
|
2d coords""""""
|
xy = xcoord.values.ravel() + 1j * ycoord.values.ravel()
|
dist = np.abs(xy - (x + 1j * y))
|
imin = np.nanargmin(dist)
|
xy_min = xy[imin]
|
return (xy_min.real, xy_min.imag, u.values.ravel()[imin],
|
v.values.ravel()[imin])"
|
811,"def hist2d(self, da, **kwargs):
|
""""""Make the two dimensional histogram
|
Parameters
|
----------
|
da: xarray.DataArray
|
The data source""""""
|
if self.value is None or self.value == 'counts':
|
normed = False
|
else:
|
normed = True
|
y = da.values
|
x = da.coords[da.dims[0]].values
|
counts, xedges, yedges = np.histogram2d(
|
x, y, normed=normed, **kwargs)
|
if self.value == 'counts':
|
counts = counts / counts.sum().astype(float)
|
return counts, xedges, yedges"
|
812,"def _statsmodels_bivariate_kde(self, x, y, bws, xsize, ysize, xyranges):
|
""""""Compute a bivariate kde using statsmodels.
|
This function is mainly motivated through
|
seaborn.distributions._statsmodels_bivariate_kde""""""
|
import statsmodels.nonparametric.api as smnp
|
for i, (coord, bw) in enumerate(zip([x, y], bws)):
|
if isinstance(bw, six.string_types):
|
bw_func = getattr(smnp.bandwidths, ""bw_"" + bw)
|
bws[i] = bw_func(coord)
|
kde = smnp.KDEMultivariate([x, y], ""cc"", bws)
|
x_support = np.linspace(xyranges[0][0], xyranges[0][1], xsize)
|
y_support = np.linspace(xyranges[1][0], xyranges[1][1], ysize)
|
xx, yy = np.meshgrid(x_support, y_support)
|
z = kde.pdf([xx.ravel(), yy.ravel()]).reshape(xx.shape)
|
return x_support, y_support, z"
|
813,"def check_data(cls, name, dims, is_unstructured=None):
|
""""""
|
A validation method for the data shape
|
Parameters
|
----------
|
name: str or list of str
|
The variable names (at maximum :attr:`allowed_vars` variables per
|
array)
|
dims: list with length 1 or list of lists with length 1
|
The dimension of the arrays. Only 1D-Arrays are allowed
|
is_unstructured: bool or list of bool, optional
|
True if the corresponding array is unstructured. This keyword is
|
ignored
|
Returns
|
-------
|
%(Plotter.check_data.returns)s
|
""""""
|
if isinstance(name, six.string_types) or not is_iterable(name):
|
name = [name]
|
dims = [dims]
|
N = len(name)
|
if len(dims) != N:
|
return [False] * N, [
|
'Number of provided names (%i) and dimensions '
|
'%(i) are not the same' % (N, len(dims))] * N
|
checks = [True] * N
|
messages = [''] * N
|
for i, (n, d) in enumerate(zip(name, dims)):
|
if n != 0 and not n:
|
checks[i] = False
|
messages[i] = 'At least one variable name is required!'
|
elif ((not isstring(n) and is_iterable(n) and
|
len(n) > cls.allowed_vars) and
|
len(d) != (cls.allowed_dims - len(slist(n)))):
|
checks[i] = False
|
messages[i] = 'Only %i names are allowed per array!' % (
|
cls.allowed_vars)
|
elif len(d) != cls.allowed_dims:
|
checks[i] = False
|
messages[i] = 'Only %i-dimensional arrays are allowed!' % (
|
cls.allowed_dims)
|
return checks, messages"
|
814,"def check_data(cls, name, dims, is_unstructured):
|
""""""
|
A validation method for the data shape
|
Parameters
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.