diff options
| author | shivesh <s.p.mandalia@qmul.ac.uk> | 2019-09-23 18:41:22 +0100 |
|---|---|---|
| committer | shivesh <s.p.mandalia@qmul.ac.uk> | 2019-09-23 18:41:22 +0100 |
| commit | 7f20ccfb7dddc0d7d498a9bcd56e1285f999afb6 (patch) | |
| tree | 6ec25d3c260a7611e376f809cfe7c368c1894b85 /utils | |
| parent | f0189cde321f9fa91109829f7430ecfc06c96e97 (diff) | |
| download | GolemFlavor-7f20ccfb7dddc0d7d498a9bcd56e1285f999afb6.tar.gz GolemFlavor-7f20ccfb7dddc0d7d498a9bcd56e1285f999afb6.zip | |
undo overwrite of thesis.ipynb
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/plot.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/utils/plot.py b/utils/plot.py index 6b10521..aa3b57d 100644 --- a/utils/plot.py +++ b/utils/plot.py @@ -307,8 +307,9 @@ def alpha_shape(points, alpha): def flavour_contour(frs, nbins, coverage, ax=None, smoothing=0.4, - hist_smooth=0.05, plot=True, fill=False, oversample=1, - delaunay=False, d_alpha=1.5, d_gauss=0.08, **kwargs): + hist_smooth=0.05, plot=True, fill=False, oversample=1., + delaunay=False, d_alpha=1.5, d_gauss=0.08, debug=False, + **kwargs): """Plot the flavour contour for a specified coverage.""" # Histogram in flavour space os_nbins = nbins * oversample @@ -341,6 +342,8 @@ def flavour_contour(frs, nbins, coverage, ax=None, smoothing=0.4, interp_dict[(i, j, k)] = H_s[i, j, k] vertices = np.array(heatmap(interp_dict, os_nbins)) points = vertices.reshape((len(vertices)*3, 2)) + if debug: + ax.scatter(*(points/float(oversample)).T, marker='o', s=3, alpha=1.0, color=kwargs['color'], zorder=9) pc = geometry.MultiPoint(points) if not delaunay: @@ -365,16 +368,19 @@ def flavour_contour(frs, nbins, coverage, ax=None, smoothing=0.4, # Spline again to smooth if smoothing != 0: tck, u = splprep([xi, yi], s=smoothing, per=1, k=3) - xi, yi = map(np.array, splev(np.linspace(0, 1, 300), tck)) + xi, yi = map(np.array, splev(np.linspace(0, 1, 600), tck)) + xi /= float(oversample) + yi /= float(oversample) ev_polygon = np.dstack((xi, yi))[0] # Remove points interpolated outside flavour triangle - f_ev_polygon = np.array(map(lambda x: project_toflavour(x, os_nbins), ev_polygon)) + f_ev_polygon = np.array(map(lambda x: project_toflavour(x, nbins), ev_polygon)) + xf, yf, zf = f_ev_polygon.T - mask = np.array((xf < 0) | (yf < 0) | (zf < 0) | (xf > os_nbins) | - (yf > os_nbins) | (zf > os_nbins)) - ev_polygon = np.dstack((xi[~mask], yi[~mask]))[0] / oversample + mask = np.array((xf < 0) | (yf < 0) | (zf < 0) | (xf > nbins) | + (yf > nbins) | (zf > nbins)) + ev_polygon = np.dstack((xi[~mask], yi[~mask]))[0] # Plot if plot: |
