def plots(self, pltType, extra_name=''): self.log.info('Plotting.') header = self.kind + sd.phase2( self.pdif ) + ' injections on ' + self.detector + ' data for ' + self.psr + ' ' + extra_name getattr(psrplot, pltType)(hinj=self.h.index, hrec=self.h, s=self.s, methods=self.methods) plt.title(header) pltdir = paths.plots + self.detector + '/' + self.kind + '/' + pltType + '/' pltname = self.detector + '_' + self.kind + '_' + sd.phase2( self.pdif) + '_' + pltType + extra_name save_to = pltdir + pltname try: os.makedirs(pltdir) except OSError: pass plt.savefig(save_to, bbox_inches='tight') plt.close() self.log.info('Plot saved to:\n %(save_to)s' % locals())
def __init__(self, detector, psr, methods=[], hinj=[], pdif_s=None, kind=None, pdif=None): # system self.detector = detector self.psr = psr # search self.methods = methods # injection self.hinj = hinj self.kind = kind self.pdif = pdif self.pdif_s = pdif_s # containers self.h = pd.DataFrame(columns=methods, index=range(len(hinj))) self.s = pd.DataFrame(columns=methods, index=range(len(hinj))) self.stats = pd.DataFrame(index=sd.statkinds, columns=methods) # saving self.dir = paths.results + self.psr + '/' + self.detector + '/' self.name = self.psr + '_' + self.detector + '_' + self.kind + '_' + sd.phase2( pdif) self.path = self.dir + self.name self.issaved = False self.log = logging.getLogger('Results')
def __init__(self, detector, psr, methods=[], hinj=[], pdif_s=None, kind=None, pdif=None): # system self.detector = detector self.psr = psr # search self.methods = methods # injection self.hinj = hinj self.kind = kind self.pdif = pdif self.pdif_s = pdif_s # containers self.h = pd.DataFrame(columns = methods, index=range(len(hinj))) self.s = pd.DataFrame(columns = methods, index=range(len(hinj))) self.stats = pd.DataFrame(index=sd.statkinds, columns = methods) # saving self.dir = paths.results + self.detector + '/' + self.psr + '/' self.name = self.psr + '_' + self.detector + '_' + self.kind + '_' + sd.phase2(pdif) self.path = self.dir + self.name self.issaved = False
def __init__(self, detector, psr, dinj=[], hinj=[], pdif='p', extra_name=''): # system self.detector = detector self.psr = psr # search self.methods = ['GR'] # injection self.dinj = dinj self.hinj = hinj self.kind = 'GR' self.pdif = pdif # containers self.delta = pd.DataFrame(columns = dinj, index = hinj) # saving self.extra_name = extra_name self.dir = paths.results + self.detector + '/' + self.psr + '/' self.name = 'drec_' + self.psr + '_' + self.detector + '_' + sd.phase2(pdif) + '_' + extra_name self.path = self.dir + self.name self.issaved = False
def plots(self, pltType, extra_name=''): header = self.kind + sd.phase2(self.pdif) + ' injections on ' + self.detector + ' data for ' + self.psr + ' ' + extra_name getattr(psrplot, pltType)(hinj=self.h.index, hrec=self.h, s=self.s, methods=self.methods) plt.title(header) pltdir = paths.plots + self.detector + '/' + self.kind + '/' + pltType + '/' pltname = self.detector + '_' + self.kind + '_' + sd.phase2(self.pdif) + '_' + pltType + extra_name save_to = pltdir + pltname try: os.makedirs(pltdir) except OSError: pass plt.savefig(save_to, bbox_inches='tight') plt.close() print 'Plot saved to:\n %(save_to)s' % locals()
def plot(self, kind='2D', extra_name='', save=True, style='-', lgloc=4): header = 'Recovered $\delta=c/c_{gw}$ for different injection strengths ' + extra_name results = self.delta h0 = results.index dinj = results.columns.tolist() if kind == '2D': # plot 2D plt.figure() for h in h0: plt.plot(dinj, results.ix[h], style, label=str(h)) plt.xlim(min(dinj), max(dinj)) plt.ylim(results.min().min()-.001, results.max().max()+.001) plt.legend(numpoints=1,ncol=2, loc=lgloc) plt.ylabel('Recovered $\delta$') plt.xlabel('Injected $\delta$') elif kind == '3D': fig = plt.figure() ax = fig.add_subplot(111, projection='3d') for h in h0: x = [h] * len(dinj) y = dinj z = results.ix[h].tolist() ax.scatter(x, y, z) xLabel = ax.set_xlabel('$h_0$') yLabel = ax.set_ylabel('Injected $\delta$') zLabel = ax.set_zlabel('Recovered $\delta$') else: print 'Error: supply kind 2D or 3D.' raise NameError plt.title(header) plt.show() if save: pltdir = paths.plots + self.detector + '/detection/' pltname = 'delta_' + self.detector + '_' + self.psr + '_' + sd.phase2(self.pdif) + '_' + kind + '_' + extra_name save_to = pltdir + pltname print 'Plot saved to:\n %(save_to)s' % locals() try: os.makedirs(pltdir) except OSError: pass plt.savefig(save_to, bbox_inches='tight') plt.close()