mirror of https://github.com/phonopy/phono3py.git
--xmax is implemented for kdeplot.
This commit is contained in:
parent
42251d5eb4
commit
5835dcef93
|
@ -277,12 +277,19 @@ Gaussian-KDE. Normally increasing this value from the chosen value
|
|||
without specifying this option does nothing since automatic control of
|
||||
drawing area cuts high lifetime (frequency) side if the density is low.
|
||||
|
||||
``--ymax``
|
||||
^^^^^^^^^^^
|
||||
``--xmax`` and ``--ymax``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Maximum value of drawing region of lifetime (y) axis. This switches
|
||||
off automatic determination of drawing area, therefore as a side
|
||||
effect, the computation will be roughly twice faster.
|
||||
**New**: The latest version of ``kdeplot`` is download at
|
||||
https://github.com/atztogo/phono3py/blob/develop/scripts/kdeplot.)
|
||||
|
||||
Maximum values of drawing region of phonon frequency (x-axis) and
|
||||
lifetime (y-axis) are specified by ``--xmax`` and ``--ymax``,
|
||||
respectively.
|
||||
|
||||
``--ymax`` switches off automatic determination of maximum value
|
||||
of drawing region along y-axis, therefore as a side effect, the
|
||||
computation will be roughly twice faster.
|
||||
|
||||
::
|
||||
|
||||
|
@ -291,11 +298,9 @@ effect, the computation will be roughly twice faster.
|
|||
``--cmap``
|
||||
^^^^^^^^^^^
|
||||
|
||||
**New** (``kdeplot`` is a stand-alone script. The latest version is
|
||||
download at
|
||||
**New**: The latest version of ``kdeplot`` is download at
|
||||
https://github.com/atztogo/phono3py/blob/develop/scripts/kdeplot.)
|
||||
|
||||
|
||||
Color map to be used for the density plot. It's given by the name
|
||||
presented at the matplotlib documentation,
|
||||
https://matplotlib.org/users/colormaps.html.
|
||||
|
@ -309,8 +314,7 @@ https://matplotlib.org/users/colormaps.html.
|
|||
``--dr``, ``--density_ratio``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**New** (``kdeplot`` is a stand-alone script. The latest version is
|
||||
download at
|
||||
**New**: The latest version of ``kdeplot`` is download at
|
||||
https://github.com/atztogo/phono3py/blob/develop/scripts/kdeplot.)
|
||||
|
||||
The density threshold is specified by the ratio with respect to
|
||||
|
|
|
@ -35,12 +35,15 @@ def collect_data(gamma, weights, frequencies, t_index, cutoff, max_freq):
|
|||
|
||||
return x, y
|
||||
|
||||
def run_KDE(x, y, nbins, y_max=None, density_ratio=0.1):
|
||||
def run_KDE(x, y, nbins, x_max=None, y_max=None, density_ratio=0.1):
|
||||
"""Running Gaussian-KDE by scipy
|
||||
"""
|
||||
|
||||
x_min = 0
|
||||
x_max = np.rint(x.max() * 1.1)
|
||||
if x_max is None:
|
||||
_x_max = np.rint(x.max() * 1.1)
|
||||
else:
|
||||
_x_max = x_max
|
||||
y_min = 0
|
||||
if y_max is None:
|
||||
_y_max = np.rint(y.max())
|
||||
|
@ -49,7 +52,7 @@ def run_KDE(x, y, nbins, y_max=None, density_ratio=0.1):
|
|||
values = np.vstack([x.ravel(), y.ravel()])
|
||||
kernel = stats.gaussian_kde(values)
|
||||
|
||||
xi, yi = np.mgrid[x_min:x_max:nbins*1j, y_min:_y_max:nbins*1j]
|
||||
xi, yi = np.mgrid[x_min:_x_max:nbins*1j, y_min:_y_max:nbins*1j]
|
||||
positions = np.vstack([xi.ravel(), yi.ravel()])
|
||||
zi = np.reshape(kernel(positions).T, xi.shape)
|
||||
|
||||
|
@ -64,7 +67,7 @@ def run_KDE(x, y, nbins, y_max=None, density_ratio=0.1):
|
|||
short_nbinds = len(indices)
|
||||
|
||||
ynbins = nbins ** 2 // short_nbinds
|
||||
xi, yi = np.mgrid[x_min:x_max:nbins*1j, y_min:_y_max:ynbins*1j]
|
||||
xi, yi = np.mgrid[x_min:_x_max:nbins*1j, y_min:_y_max:ynbins*1j]
|
||||
positions = np.vstack([xi.ravel(), yi.ravel()])
|
||||
zi = np.reshape(kernel(positions).T, xi.shape)
|
||||
else:
|
||||
|
@ -129,6 +132,9 @@ parser.add_argument('--temperature', type=float, default=300.0,
|
|||
dest='temperature',
|
||||
help='Temperature to output data at')
|
||||
parser.add_argument("--title", dest="title", default=None, help="Plot title")
|
||||
parser.add_argument("--xmax",
|
||||
help="Set maximum x of draw area",
|
||||
type=float, default=None)
|
||||
parser.add_argument("--ymax",
|
||||
help="Set maximum y of draw area",
|
||||
type=float, default=None)
|
||||
|
@ -200,6 +206,7 @@ for gamma, s in zip(gammas, symbols):
|
|||
x, y = collect_data(gamma, weights, frequencies,
|
||||
t_index, args.cutoff, args.fmax)
|
||||
xi, yi, zi, short_nbinds = run_KDE(x, y, args.nbins,
|
||||
x_max=args.xmax,
|
||||
y_max=args.ymax,
|
||||
density_ratio=args.density_ratio)
|
||||
fig = plot(plt, xi, yi, zi, x, y, short_nbinds, args.nbins,
|
||||
|
|
Loading…
Reference in New Issue