Commit f05393de authored by teresa.bister's avatar teresa.bister
Browse files

[simulation] generalise plotting for not ordered cr sets and fix lint (hopefully)

parent a91c49eb
Pipeline #217694 passed with stages
in 4 minutes and 36 seconds
......@@ -798,18 +798,25 @@ class SourceBound(BaseSimulation):
import matplotlib.pyplot as plt
from astrotools import skymap
idx = self._select_representative_set() if idx is None else idx
ns = np.array([np.sum(self.crs['source_labels'][idx] == k) for k in range(self.universe.n_src)])
charges = self.crs['charge'][idx, :]
cmap = plt.get_cmap('jet_r', np.amax(charges))
n_scr = self.crs['inside_fraction']*self.crs.ncrs
skymap.eventmap(self.crs['vecs'][:, idx, 0:int(n_scr)], c=charges[0:int(n_scr)],
ns = np.array([np.sum(self.crs['source_labels'][idx] == k) for k in range(self.universe.n_src)])
n_more_3 = ns >= 3
src_idx = np.squeeze(np.argwhere(n_more_3))[np.argsort(ns[n_more_3])]
labels_p = np.copy(self.crs['source_labels'][idx])
labels_p[~np.in1d(labels_p, src_idx) & (labels_p >= 0)] = 10*self.universe.n_src
for j, idxj in enumerate(src_idx):
labels_p[labels_p == idxj] = j
skymap.eventmap(self.crs['vecs'][:, idx, labels_p >= 0], c=charges[labels_p >= 0],
cmap=cmap, cblabel='Z',
cticks=np.array([1, 2, 6, 12, 20, 26]), vmin=0.5, vmax=26.5,
s=25, alpha=0.65, marker='v')
lons, lats = coord.vec2ang(self.crs['vecs'][:, idx, int(n_scr)::])
lons, lats = coord.vec2ang(self.crs['vecs'][:, idx, labels_p < 0])
plt.scatter(-lons, lats, c=charges[int(n_scr)::],
plt.scatter(-lons, lats, c=charges[labels_p < 0],
cmap=cmap, s=15, alpha=0.4, marker='o', vmin=0.5, vmax=26.5,)
lon_src, lat_src = coord.vec2ang(self.universe.sources[:, idx])
......@@ -817,7 +824,8 @@ class SourceBound(BaseSimulation):
ns = np.sort(ns)[::-1]
plt.title('Strongest sources: (%i, %i, %i)' % (ns[0], ns[1], ns[2]), fontsize=15)
if opath is None:
opath = '/tmp/arrival_charge%s__emin_%s__ecut_%s.pdf' % (self._get_charge_id(), self.energy_setting['log10e_min'],
opath = '/tmp/arrival_charge%s__emin_%s__ecut_%s.pdf' % (self._get_charge_id(),
self.energy_setting['log10e_min'],
self.energy_setting['log10_cut'])
plt.savefig(opath, bbox_inches='tight')
plt.close()
......
Supports Markdown
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