Commit 42a923f0 authored by LUSTIG Peter's avatar LUSTIG Peter

added map plot

parent faee374a
......@@ -39,31 +39,6 @@ os.getcwd()
plt.ion()
def Plot_CompPur(completness, purity, threshold, nsim=None, savename=None,
flux=None):
threshold_bins = completness.shape[-1]
fig, axes = plt.subplots(nrows=2, ncols=threshold_bins, sharex=True,
sharey=True)
for i in range(threshold_bins):
axes[0, i].imshow(completness[:, :, i], vmin=0, vmax=1)
im = axes[1, i].imshow(purity[:, :, i], vmin=0, vmax=1)
axes[1, i].set_xlabel("thresh={:.2f}".format(threshold[i]))
if i == (threshold_bins-1):
# print('-----------')
divider = make_axes_locatable(axes[1, i])
cax = divider.append_axes('right', size='5%', pad=0.0)
fig = plt.gcf()
fig.colorbar(im, cax=cax, orientation='vertical')
if nsim is not None:
axes[0, 0].set_title("{} simulations".format(nsim))
if flux is not None:
axes[0, 1].set_title("{}".format(flux))
axes[0, 0].set_ylabel("completness")
axes[1, 0].set_ylabel("purity")
if savename is not None:
plt.savefig(savename)
def add_axis(name, range, bins, unit=None, i_axe=3, log=False):
"""Define a dictionnary for additionnal wcs axes (linear or log)"""
......@@ -312,12 +287,12 @@ plt.close('all')
DATA_DIR = "/home/peter/Dokumente/Uni/Paris/Stage/data/v_1"
data = NikaMap.read(Path(DATA_DIR) / '..' / 'map.fits')
bins = 9
bins = 19
flux_bins = 2
flux_range = [0.1, 10]
threshold_bins = 10
threshold_bins = 5
threshold_range = [2, 5]
threshold_range = [3, 7.5]
......@@ -378,13 +353,7 @@ for isimu in range(nfluxes):
'''
# helpfunc = partial(Evaluate, **{'hdul': hdul})
p = Pool(cpu_count())
# print(hdul)
#hdul = []
# f = partial(Evaluate2, hdul=hdul)
# print(flux)
# res = p.map(f, flux)
# print(flux)
# sys.exit()
res = p.map(Evaluate, indata)
res = list(zip(*res))
FLUX = np.array(res[0])
......@@ -452,19 +421,23 @@ def PlotEvaluation(data, title='', flux=np.array([]), thresh=[],
plt.imshow(data, origin='lower', **kwargs)
cbar = plt.colorbar()
cbar.ax.tick_params(labelsize=tickfs)
plt.show(block=True)
PlotEvaluation(COMPLETNESS[:, midbin, midbin, :], title='Completness',
flux=np.array(FLUX), thresh=threshold, cmap='bone',
nfluxlabels=10, nthreshlabels=5, aspect='auto')
PlotEvaluation(PURITY[:, midbin, midbin, :], title='Purity',
flux=np.array(FLUX), thresh=threshold, cmap='bone',
nfluxlabels=10, nthreshlabels=5, aspect='auto')
plt.show(block=True)
# %% 2D plot
def PlotFixedThreshold(thresholds, bin, completness, allthresholds, flux,
nfluxlabels=None, hlines=None):
nfluxlabels=None, hlines=None):
linestyles = ['-', '--', '-.', ':']
real_thresholds = find_nearest(allthresholds, thresholds)
......@@ -498,3 +471,52 @@ def PlotFixedThreshold(thresholds, bin, completness, allthresholds, flux,
PlotFixedThreshold(np.array((3, 5, 7)), (midbin, midbin), COMPLETNESS,
threshold, np.array(FLUX), nfluxlabels=None,
hlines=[.5, .8, .9])
# %% Plot map
# Plot_CompPur(completness, purity, threshold, nsim=None, savename=None,
# flux=None):
plotidx = np.array([24, 30, 40, 49])
# plotthreshidx = np.array([0, 4, 8])
plotcomp = COMPLETNESS[plotidx]
plotpur = PURITY[plotidx]
print(plotpur.shape)
# plotthresh = threshold[plotthreshidx]
plotflux = np.array(FLUX[plotidx])
def Plot_CompPur(completness, purity, threshold, nsim=None, savename=None,
flux=None):
threshold_bins = completness.shape[-1]
print('subplots:', threshold_bins)
fig, axes = plt.subplots(nrows=2, ncols=threshold_bins, sharex=True,
sharey=True)
print('axes shape', axes.shape)
print('completness shape', completness.shape)
for i in range(threshold_bins):
print(i)
axes[0, i].imshow(completness[:, :, i], vmin=0, vmax=1)
im = axes[1, i].imshow(purity[:, :, i], vmin=0, vmax=1)
axes[1, i].set_xlabel("thresh={:.2f}".format(threshold[i]))
if i == (threshold_bins-1):
# print('-----------')
divider = make_axes_locatable(axes[1, i])
cax = divider.append_axes('right', size='5%', pad=0.0)
fig = plt.gcf()
fig.colorbar(im, cax=cax, orientation='vertical')
if nsim is not None:
axes[0, 0].set_title("{} simulations".format(nsim))
if flux is not None:
axes[0, 1].set_title("{}".format(flux))
axes[0, 0].set_ylabel("completness")
axes[1, 0].set_ylabel("purity")
if savename is not None:
plt.savefig(savename)
for i in range(len(plotidx)):
_comp = plotcomp[i]
_pur = plotpur[i]
Plot_CompPur(_comp, _pur, threshold, flux=plotflux[i])
plt.show(block=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment