def make_plot(self): bindata=self.bindata bin_field=self.bin_field plt=FramedPlot() plt.uniform_limits=1 plt.xlog=True #plt.xrange=[0.5*bindata[bin_field].min(), 1.5*bindata[bin_field].max()] plt.xrange=self.s2n_range plt.xlabel=bin_field plt.ylabel = r'$\gamma$' if self.yrange is not None: plt.yrange=self.yrange xdata=bindata[bin_field] xerr=bindata[bin_field+'_err'] if self.shnum in sh1exp: g1exp=zeros(xdata.size)+sh1exp[self.shnum] g2exp=zeros(xdata.size)+sh2exp[self.shnum] g1exp_plt=Curve(xdata, g1exp) g2exp_plt=Curve(xdata, g2exp) plt.add(g1exp_plt) plt.add(g2exp_plt) xerrpts1 = SymmetricErrorBarsX(xdata, bindata['g1'], xerr) xerrpts2 = SymmetricErrorBarsX(xdata, bindata['g2'], xerr) type='filled circle' g1color='blue' g2color='red' g1pts = Points(xdata, bindata['g1'], type=type, color=g1color) g1errpts = SymmetricErrorBarsY(xdata, bindata['g1'], bindata['g1_err'], color=g1color) g2pts = Points(xdata, bindata['g2'], type=type, color=g2color) g2errpts = SymmetricErrorBarsY(xdata, bindata['g2'], bindata['g2_err'], color=g2color) g1pts.label=r'$\gamma_1$' g2pts.label=r'$\gamma_2$' key=biggles.PlotKey(0.9,0.5,[g1pts,g2pts],halign='right') plt.add( xerrpts1, g1pts, g1errpts ) plt.add( xerrpts2, g2pts, g2errpts ) plt.add(key) labels=self.get_labels() plt.add(*labels) plt.aspect_ratio=1 self.plt=plt
def make_plot_components(self, fdata, e1, e2, weights, nperbin, ymin,ymax, fmin=None, fmax=None, coeffs=None): be1 = eu.stat.Binner(fdata, e1, weights=weights) be2 = eu.stat.Binner(fdata, e2, weights=weights) print(" hist e1, nperbin: ",nperbin) be1.dohist(nperbin=nperbin, min=fmin, max=fmax) print(" stats e1") be1.calc_stats() print(" hist e2, nperbin: ",nperbin) be2.dohist(nperbin=nperbin, min=fmin, max=fmax) print(" stats e2") be2.calc_stats() # regular hist for display print(" regular fixed binsize hist") xm,xe,xstd=eu.stat.wmom(fdata, weights, sdev=True) bsize = xstd/5. hist = eu.stat.histogram(fdata, binsize=bsize, weights=weights, more=True) ph = eu.plotting.make_hist_curve(hist['low'], hist['high'], hist['whist'], ymin=ymin, ymax=ymax, color='grey50') p1 = Points( be1['wxmean'], be1['wymean'], type='filled circle', color='blue') p1err = SymErrY( be1['wxmean'], be1['wymean'], be1['wyerr2'], color='blue') p1.label = r'$e_1$' p2 = Points( be2['wxmean'], be2['wymean'], type='filled circle', color='red') p2.label = r'$e_2$' p2err = SymErrY( be2['wxmean'], be2['wymean'], be2['wyerr2'], color='red') if coeffs is not None: poly1=numpy.poly1d(coeffs['coeff_e1']) poly2=numpy.poly1d(coeffs['coeff_e2']) t1 = Curve( be1['wxmean'], poly1(be1['wxmean']), color='blue') t2 = Curve( be2['wxmean'], poly2(be2['wxmean']), color='red') return p1,p1err,p2,p2err,ph,t1,t2 else: return p1,p1err,p2,p2err,ph
def plot_sub_pixel(ellip,theta, show=False): import biggles from biggles import PlotLabel,FramedPlot,Table,Curve,PlotKey,Points from pcolors import rainbow f=subpixel_file(ellip,theta,'fits') data = eu.io.read(f) colors = rainbow(data.size,'hex') pltSigma = FramedPlot() pltSigma.ylog=1 pltSigma.xlog=1 curves=[] for j in xrange(data.size): sigest2 = (data['Irr'][j,:] + data['Icc'][j,:])/2 pdiff = sigest2/data['sigma'][j]**2 -1 nsub=numpy.array(data['nsub'][j,:]) #pc = biggles.Curve(nsub, pdiff, color=colors[j]) pp = Points(data['nsub'][j,:], pdiff, type='filled circle',color=colors[j]) pp.label = r'$\sigma: %0.2f$' % data['sigma'][j] curves.append(pp) pltSigma.add(pp) #pltSigma.add(pc) #pltSigma.yrange=[0.8,1.8] #pltSigma.add(pp) c5 = Curve(linspace(1,8, 20), .005+zeros(20)) pltSigma.add(c5) key=PlotKey(0.95,0.95,curves,halign='right',fontsize=1.7) key.key_vsep=1 pltSigma.add(key) pltSigma.xlabel='N_{sub}' pltSigma.ylabel=r'$\sigma_{est}^2 /\sigma_{True}^2 - 1$' lab=PlotLabel(0.05,0.07,r'$\epsilon: %0.2f \theta: %0.2f$' % (ellip,theta),halign='left') pltSigma.add(lab) pltSigma.yrange = [1.e-5,0.1] pltSigma.xrange = [0.8,20] if show: pltSigma.show() epsfile=subpixel_file(ellip,theta,'eps') print("Writing eps file:",epsfile) pltSigma.write_eps(epsfile)
def plot_ellip_vs_field(self, field, rmag_max=21.8, fmin=None, fmax=None, nbin=20, nperbin=50000, yrange=None, show=True): self.load_data() w=where1((self['cmodelmag_dered_r'] > 18.0) & (self['cmodelmag_dered_r'] < rmag_max) ) if w.size == 0: print("no good objects") return weights = 1.0/(0.32**2 + self['uncer_rg'][w]**2) if field == 'psf_fwhm': field_data = self['psf_fwhm'][w] fstr = 'PSF FWHM (arcsec)' elif field == 'psf_sigma': field_data = self['psf_sigma'][w] fstr = r'$\sigma_{PSF}$' elif field == 'R_rg': field_data = self['r_rg'][w] fstr = 'R_rg' else: field_data = self[field][w] fstr=field print("Plotting mean e for field:",field) fstr = fstr.replace('_','\_') be1 = eu.stat.Binner(field_data, self['e1_rg'][w], weights=weights) be2 = eu.stat.Binner(field_data, self['e2_rg'][w], weights=weights) print(" hist e1") be1.dohist(nperbin=nperbin, min=fmin, max=fmax) #be1.dohist(nbin=nbin, min=fmin, max=fmax) print(" stats e1") be1.calc_stats() print(" hist e2") be2.dohist(nperbin=nperbin, min=fmin, max=fmax) #be2.dohist(nbin=nbin, min=fmin, max=fmax) print(" stats e2") be2.calc_stats() plt = FramedPlot() p1 = Points( be1['wxmean'], be1['wymean'], type='filled circle', color='blue') p1err = SymErrY( be1['wxmean'], be1['wymean'], be1['wyerr2'], color='blue') p1.label = r'$e_1$' p2 = Points( be2['wxmean'], be2['wymean'], type='filled circle', color='red') p2.label = r'$e_2$' p2err = SymErrY( be2['wxmean'], be2['wymean'], be2['wyerr2'], color='red') key = PlotKey(0.8, 0.9, [p1,p2]) plt.add(p1, p1err, p2, p2err, key) if field != 'cmodelmag_dered_r': rmag_lab = PlotLabel(0.1,0.05,'rmag < %0.2f' % rmag_max, halign='left') plt.add(rmag_lab) plab = PlotLabel(0.1,0.1, 'CH+RM', halign='left') plt.add(plab) plt.xlabel = r'$'+fstr+'$' plt.ylabel = r'$<e>$' if yrange is not None: plt.yrange=yrange if show: plt.show() epsfile = self.plotfile(field, rmag_max) print(" Writing eps file:",epsfile) plt.write_eps(epsfile)
def plot_dsig(**keys): """ This one stands alone. """ comb=keys.get('comb',None) r=keys.get('r',None) dsig=keys.get('dsig',None) dsigerr=keys.get('dsigerr',None) color=keys.get('color','black') type=keys.get('type','filled circle') nolabel=keys.get('nolabel',False) show=keys.get('show',True) minval=keys.get('minval',1.e-3) xlog=keys.get('xlog',True) ylog=keys.get('ylog',True) aspect_ratio=keys.get('aspect_ratio',1) plt=keys.get('plt',None) label=keys.get('label',None) if comb is not None: r=comb['r'] dsig=comb['dsig'] dsigerr=comb['dsigerr'] else: if r is None or dsig is None or dsigerr is None: raise ValueError("Send a combined struct or r,dsig,dsigerr") if plt is None: plt=FramedPlot() plt.aspect_ratio=aspect_ratio plt.xlog=xlog plt.ylog=ylog if not nolabel: plt.xlabel = labels['rproj'] plt.ylabel = labels['dsig'] if ylog: od=add_to_log_plot(plt, r, dsig, dsigerr, color=color, type=type, minval=minval) plt.xrange = od['xrange'] plt.yrange = od['yrange'] if label: od['p'].label=label else: zpts=Curve(r, dsig*0) plt.add(zpts) pts=Points(r, dsig, type=type, color=color) if label: pts.label=label plt.add(pts) if dsigerr is not None: epts=SymErrY(r, dsig, dsigerr, color=color) plt.add(epts) yrng=keys.get('yrange',None) xrng=keys.get('xrange',None) if yrng: plt.yrange=yrng if xrng: plt.xrange=xrng else: if xlog: plt.xrange=eu.plotting.get_log_plot_range(r) if show: plt.show() if ylog: od['plt'] = plt return od else: return plt
def plot2dsig(r1, dsig1, dsig1err, r2, dsig2, dsig2err, **keys): """ Plot delta sigma and a second delta sigma in two plots the second of which is linear. Parameters ---------- show: bool, optional Show plot in a window, default True yrange1: [min,max] The y range of the delta sigma plot yrange2: [min,max] The y range of the ortho-delta sigma plot range4var: [min,max] The x range over which to calculate a osig variance and determine a plot range. This is overridden by range2 plot_label: string, optional a label for the top plot # label1,label2 go in a key in the bottom plot label1: string, optional a label for the first dsig label2: string, optional a label for the second dsig """ color2 = 'red' ptype1='filled circle' size1=1.5 ptype2='filled circle' size2=1.5 xmul = keys.get('xmul',1.) show = keys.get('show',True) yrange1 = keys.get('yrange1',None) yrange2 = keys.get('yrange2',None) isortho = keys.get('ortho',False) # this is a y-log plot, use more powerful range determination print dsig1 print dsig1err yrange1 = eu.plotting.get_log_plot_range(dsig1, err=dsig1err, input_range=yrange1) rr=numpy.concatenate((r1,r2)) xrng = eu.plotting.get_log_plot_range(rr) # this over-rides range4var = keys.get('range4var',None) if yrange2 is None: if range4var is not None: w=where1( (r2 >= range4var[0]) & (r2 <= range4var[1])) if w.size == 0: raise ValueError("no points in range [%d,%d]" % tuple(range4var)) sdev = dsig2[w].std() else: sdev = dsig2.std() yrange2 = [-3.5*sdev, 3.5*sdev] label = keys.get('plot_label',None) label1 = keys.get('label1',None) label2 = keys.get('label2',None) # The points and zero curve dsig1_p = Points(r1, dsig1, color='black', type=ptype1, size=size1) dsig1err_p = SymErrY(r1, dsig1, dsig1err, color='black') dsig1_p.label=label1 dsig2_p = Points(r2*xmul, dsig2, color=color2, type=ptype2, size=size2) dsig2err_p = SymErrY(r2*xmul, dsig2, dsig2err, color=color2) dsig2_p.label=label2 c=Curve([1.e-5,1.e5],[0,0], type='solid') arr = FramedArray(2,1) arr.cellspacing=1 arr.aspect_ratio=2 arr.xlabel = labels['rproj'] if isortho: arr.ylabel = labels['osig'] else: arr.ylabel = labels['dsig'] arr.xrange = xrng arr[0,0].yrange = yrange1 arr[0,0].xlog=True arr[0,0].ylog=True # biggles chokes if you give it negative data for a log plot arr[0,0].add(dsig1_p, dsig2_p) eu.plotting.add_log_error_bars(arr[0,0],'y',r1,dsig1,dsig1err,yrange1) eu.plotting.add_log_error_bars(arr[0,0],'y',r2,dsig2,dsig2err,yrange1,color=color2) if label is not None: arr[0,0].add(PlotLabel(0.9,0.9,label,halign='right')) arr[1,0].yrange = yrange2 arr[1,0].xlog=True arr[1,0].add(c) arr[1,0].add(dsig1_p, dsig1err_p, dsig2_p, dsig2err_p) if label1 is not None or label2 is not None: key = PlotKey(0.9,0.15, [dsig1_p,dsig2_p], halign='right') arr[1,0].add(key) if show: arr.show() return arr
def plot2dsig_old(r, dsig1, dsig1err, dsig2, dsig2err, **keys): """ Plot delta sigma and a second delta sigma in two plots the second of which is linear. Parameters ---------- show: bool, optional Show plot in a window, default True range1: [min,max] The y range of the delta sigma plot range2: [min,max] The y range of the ortho-delta sigma plot range2var: [min,max] The x range over which to calculate a osig variance and determine a plot range. This is overridden by range2 plot_label: string, optional a label for the top plot # label1,label2 go in a key in the bottom plot label1: string, optional a label for the first dsig label2: string, optional a label for the second dsig """ show = keys.get('show',True) range1 = keys.get('range1',None) range2 = keys.get('range2',None) # this over-rides range4var = keys.get('range4var',None) if range2 is None: if range4var is not None: w=where1( (r >= range4var[0]) & (r <= range4var[1])) if w.size == 0: raise ValueError("no points in range [%d,%d]" % tuple(range4var)) sdev = dsig2[w].std() else: sdev = dsig2.std() range2 = [-3.5*sdev, 3.5*sdev] print 'range2:',range2 label = keys.get('plot_label',None) label1 = keys.get('label1',None) label2 = keys.get('label2',None) # for overplotting dsig1_p = Points(r, dsig1, color='red') dsig1err_p = SymErrY(r, dsig1, dsig1err, color='red') dsig1_p.label=label1 dsig2_p = Points(r, dsig1, color='red') dsig2err_p = SymErrY(r, dsig1, dsig1err, color='black') dsig2_p.label=label1 arr = FramedArray(2,1) arr.aspect_ratio=2 arr.xlabel = labels['rproj'] arr.ylabel = labels['dsig'] eu.plotting.bscatter(r, dsig1, yerr=dsig1err, xlog=True, ylog=True, yrange=range1, show=False, plt=arr[0,0], **keys) if label is not None: arr[0,0].add(PlotLabel(0.9,0.9,label,halign='right')) pdict=eu.plotting.bscatter(r, dsig2, yerr=dsig2err, xlog=True, yrange=range2, label=label2, show=False, dict=True, plt=arr[1,0], **keys) c=Curve([1.e-5,1.e5],[0,0], type='solid') arr[1,0].add(c) arr[1,0].add(dsig1_p,dsig1err_p) if label1 is not None or label2 is not None: key = PlotKey(0.9,0.9, [dsig1_p,pdict['p']], halign='right') arr[1,0].add(key) if show: arr.show() return arr
def plot2dsig_over(r1,dsig1,dsig1err,r2,dsig2, dsig2err, **keys): ptype1=keys.get('ptype1','filled circle') ptype2=keys.get('ptype2','filled circle') size1=keys.get('size1',1) size2=keys.get('size2',1) color1=keys.get('color1','red') color2=keys.get('color2','blue') label = keys.get('label',None) label1 = keys.get('label1',None) label2 = keys.get('label2',None) xrng = keys.get('xrange',None) yrng = keys.get('yrange',None) show = keys.get('show',True) ylog = keys.get('ylog',True) plt=keys.get('plt',None) yall=numpy.concatenate((dsig1, dsig2)) yerrall=numpy.concatenate((dsig1err, dsig2err)) if yrng is None: if ylog: yrng = eu.plotting.get_log_plot_range(yall, err=yerrall, input_range=yrng) rr=numpy.concatenate((r1,r2)) if xrng is None: xrng = eu.plotting.get_log_plot_range(rr) if plt is None: plt=FramedPlot() plt.xlog=True plt.ylog=ylog plt.xrange=xrng plt.yrange=yrng plt.xlabel = labels['rproj'] plt.ylabel = labels['dsig'] dsig1_p = Points(r1, dsig1, color=color1, type=ptype1, size=size1) dsig1err_p = SymErrY(r1, dsig1, dsig1err, color=color2) dsig1_p.label=label1 dsig2_p = Points(r2, dsig2, color=color2, type=ptype2, size=size2) dsig2err_p = SymErrY(r2, dsig2, dsig2err, color=color2) dsig2_p.label=label2 plt.add(dsig1_p, dsig2_p) if ylog: # biggles chokes if you give it negative data for a log plot eu.plotting.add_log_error_bars(plt,'y',r1,dsig1,dsig1err,yrng, color=color1) eu.plotting.add_log_error_bars(plt,'y',r2,dsig2,dsig2err,yrng, color=color2) else: err1 = biggles.SymmetricErrorBarsY(r1,dsig1,dsig1err,color=color1) err2 = biggles.SymmetricErrorBarsY(r2,dsig2,dsig2err,color=color2) plt.add(err1,err2) zerop = biggles.Curve(xrng, [0,0]) plt.add(zerop) if label is not None: plt.add(PlotLabel(0.9,0.9,label,halign='right')) if label1 is not None or label2 is not None: key = PlotKey(0.9,0.15, [dsig1_p,dsig2_p], halign='right') plt.add(key) if show: plt.show() return plt
def plot_coverage(self, region='both', show=True, dops=True): import biggles from biggles import FramedPlot, Points, PlotKey l = self.read() w,=numpy.where( (l['ra'] >= 0.0) & (l['ra'] <= 360.0) ) if w.size != l.size: print("threw out",l.size-w.size,"with bad ra") l=l[w] llam,leta = eu.coords.eq2sdss(l['ra'],l['dec']) maskflags = l['maskflags'] lammin,lammax = (-70.,70.) if region=='ngc': # a bit high to make room for the legend emin,emax=(-40,60) biggles.configure('screen','width', 1800) biggles.configure('screen','height', 1140) elif region=='sgc': emin,emax=(100,165) biggles.configure('screen','width', 1800) biggles.configure('screen','height', 1140) else: emin,emax=(-40,165) biggles.configure('screen','width', 1140) biggles.configure('screen','height', 1140) wl=where1((leta > emin) & (leta < emax)) llam=llam[wl] leta=leta[wl] maskflags=maskflags[wl] plt=FramedPlot() plt.xlabel=r'$\lambda$' plt.ylabel=r'$\eta$' print("adding all lenses") type = 'filled circle' symsize=0.2 allp = Points(llam,leta,type=type,size=symsize) allp.label='all' plt.add(allp) wquad = es_sdsspy.stomp_maps.quad_check(maskflags) print("adding quad pass") quadp = Points(llam[wquad],leta[wquad],type=type,color='red',size=symsize) quadp.label = 'quad good' plt.add(quadp) fakepoints = eu.plotting.fake_filled_circles(['all','quad good'],['black','red']) key=PlotKey(0.95,0.95,fakepoints,halign='right') plt.add(key) es_sdsspy.stomp_maps.plot_boss_geometry(color='blue',plt=plt,show=False) xrng = (lammin, lammax) yrng = (emin, emax) plt.xrange = xrng plt.yrange = yrng plt.aspect_ratio = (yrng[1]-yrng[0])/float(xrng[1]-xrng[0]) if show: plt.show() if dops: d = lensing.files.sample_dir(type='lcat',sample=self['sample']) d = os.path.join(d,'plots') if not os.path.exists(d): os.makedirs(d) epsfile = os.path.join(d, 'lcat-%s-%s-coverage.eps' % (self['sample'],region) ) print("Writing to eps file:",epsfile) plt.write_eps(epsfile) return plt
def plot_vs_field(self, field, plot_type, rmag_min=None, rmag_max=None, fmin=None, fmax=None, nbin=20, nperbin=50000, xrng=None, yrng=None, show=True): allowed=['meane','residual'] if plot_type not in allowed: raise ValueError("plot_type should be in [%s]" % ','.join(allowed)) if plot_type == 'residual' and self.sweeptype != 'star': raise ValueError("residuals only supported for stars") if rmag_min is None: if self.sweeptype == 'gal': rmag_min=18.0 else: rmag_min=15.0 if rmag_max is None: if self.sweeptype == 'gal': rmag_max=21.8 else: rmag_max=19.0 # this will only load the main data once. self.load_data(field) print("Using rmag range: [%0.2f,%0.2f]" % (rmag_min,rmag_max)) # notes # - amflags here is really corrflags_rg for gals # - e1 is really e1_rg for gals logic = ((self['amflags'] == 0) & (self['e1'] < 4) & (self['e1'] > -4) & (self['rmag'] > rmag_min) & (self['rmag'] < rmag_max) ) if self.sweeptype == 'gal': logic = logic & (self['R'] > 1.0/3.0) & (self['R'] < 1.0) w=where1(logic) print("Number passing cuts:",w.size) minnum=31000 if w.size < minnum: print("want %d good objects, found %d" % (minnum,w.size)) return weights = 1.0/(0.32**2 + self['uncer'][w]**2) # we can try to get nice labels for some fields if field == 'fwhm_psf': field_data = self['fwhm_psf'][w] fstr = 'PSF FWHM (arcsec)' elif field == 'sigma_psf': field_data = self['sigma_psf'][w] fstr = r'\sigma_{PSF}' elif field == 'sigma': field_data = self['sigma'][w] fstr = r'\sigma_{obj+PSF}' else: field_data = self[field][w] fstr=field fstr = fstr.replace('_','\_') print("Plotting for field:",field) if plot_type == 'residual': print(' doing: residual') be1 = eu.stat.Binner(field_data, self['e1'][w]-self['e1_psf'][w], weights=weights) be2 = eu.stat.Binner(field_data, self['e2'][w]-self['e2_psf'][w], weights=weights) ylabel = r'$<e_{star}-e_{PSF}>$' else: print(' doing meane') be1 = eu.stat.Binner(field_data, self['e1'][w], weights=weights) be2 = eu.stat.Binner(field_data, self['e2'][w], weights=weights) ylabel = r'$<e>$' # regular hist for display print(" regular fixed binsize hist") xm,xe,xstd=eu.stat.wmom(field_data, weights, sdev=True) #hxmin = xm-4.0*xstd #hxmax = xm+4.0*xstd bsize = xstd/5. hist = eu.stat.histogram(field_data, binsize=bsize, weights=weights, more=True) print(" hist e1, nperbin: ",nperbin) be1.dohist(nperbin=nperbin, min=fmin, max=fmax) #be1.dohist(nbin=nbin, min=fmin, max=fmax) print(" stats e1") be1.calc_stats() print(" hist e2, nperbin: ",nperbin) be2.dohist(nperbin=nperbin, min=fmin, max=fmax) #be2.dohist(nbin=nbin, min=fmin, max=fmax) print(" stats e2") be2.calc_stats() plt = FramedPlot() if xrng is not None: plt.xrange=xrng else: if field == 'R': plt.xrange=[0.29,1.01] if yrng is not None: plt.yrange=yrng ymin = yrng[0] ymax = 0.8*yrng[1] else: ymin = min( be1['wymean'].min(),be2['wymean'].min() ) ymax = 0.8*max( be1['wymean'].max(),be2['wymean'].max() ) # this is a histogram-like object ph = eu.plotting.make_hist_curve(hist['low'], hist['high'], hist['whist'], ymin=ymin, ymax=ymax, color='grey50') plt.add(ph) p1 = Points( be1['wxmean'], be1['wymean'], type='filled circle', color='blue') p1err = SymErrY( be1['wxmean'], be1['wymean'], be1['wyerr2'], color='blue') p1.label = r'$e_1$' p2 = Points( be2['wxmean'], be2['wymean'], type='filled circle', color='red') p2.label = r'$e_2$' p2err = SymErrY( be2['wxmean'], be2['wymean'], be2['wyerr2'], color='red') key = PlotKey(0.1,0.9, [p1,p2]) plt.add(p1, p1err, p2, p2err, key) if self.camcol != 'any' and field == 'R' and plot_type=='meane': order=3 print(" getting poly order",order) coeff1 = numpy.polyfit(be1['wxmean'], be1['wymean'], order) poly1=numpy.poly1d(coeff1) coeff2 = numpy.polyfit(be2['wxmean'], be2['wymean'], order) poly2=numpy.poly1d(coeff2) ps1 = Curve( be1['wxmean'], poly1(be1['wxmean']), color='blue') ps2 = Curve( be2['wxmean'], poly2(be2['wxmean']), color='red') plt.add(ps1,ps2) polyf = self.R_polyfile(self.camcol, rmag_max) out={'coeff_e1':list([float(c) for c in coeff1]), 'coeff_e2':list([float(c) for c in coeff2])} print(" -- Writing poly coeffs to:",polyf) eu.io.write(polyf,out) if field != 'rmag': rmag_lab = \ PlotLabel(0.1,0.05,'%0.2f < rmag < %0.2f' % (rmag_min,rmag_max), halign='left') plt.add(rmag_lab) procrun_lab = PlotLabel(0.1,0.1, 'procrun: %s filter: %s' % (self.procrun, self.band), halign='left') plt.add(procrun_lab) cy=0.9 if self.run != 'any': run_lab = PlotLabel(0.9,0.9, 'run: %06i' % self.run, halign='right') plt.add(run_lab) cy=0.8 if self.camcol != 'any': run_lab = PlotLabel(0.9,cy, 'camcol: %i' % self.camcol, halign='right') plt.add(run_lab) plt.xlabel = r'$'+fstr+'$' plt.ylabel = ylabel if show: plt.show() epsfile = self.plotfile(field, rmag_max, plot_type=plot_type) eu.ostools.makedirs_fromfile(epsfile, verbose=True) print(" Writing eps file:",epsfile) plt.write_eps(epsfile) converter.convert(epsfile, verbose=True)
def doplot(run, st, s2n_field, setname, s2n_range, sratio_range, psfnums, nobj): tab=Table(2,1) color1='blue' color2='red' m1pts=Points(st['s2n'],st['m1'],type='filled circle',color=color1) m1errpts=SymmetricErrorBarsY(st['s2n'],st['m1'],st['m1_err'],color=color1) m2pts=Points(st['s2n'],st['m2'],type='filled circle',color=color2) m2errpts=SymmetricErrorBarsY(st['s2n'],st['m2'],st['m2_err'],color=color2) c1pts=Points(st['s2n'],st['c1'],type='filled circle',color=color1) c1errpts=SymmetricErrorBarsY(st['s2n'],st['c1'],st['c1_err'],color=color1) c2pts=Points(st['s2n'],st['c2'],type='filled circle',color=color2) c2errpts=SymmetricErrorBarsY(st['s2n'],st['c2'],st['c2_err'],color=color2) m1pts.label=r'$\gamma_1$' m2pts.label=r'$\gamma_2$' key=PlotKey(0.9,0.2,[m1pts,m2pts], halign='right') xrng=array( [0.5*s2n_range[0], 1.5*s2n_range[1]]) cyrng=get_symmetric_range(st['c1'],st['c1_err'],st['c2'],st['c2_err']) myrng=get_symmetric_range(st['m1'],st['m1_err'],st['m2'],st['m2_err']) mplt=FramedPlot() cplt=FramedPlot() mplt.xlog=True cplt.xlog=True mplt.xrange=xrng cplt.xrange=xrng #mplt.yrange=myrng #cplt.yrange=cyrng mplt.yrange=[-0.15,0.15] cplt.yrange=[-0.01,0.01] mplt.xlabel=s2n_field mplt.ylabel='m' cplt.xlabel=s2n_field cplt.ylabel='c' zplt=Curve(xrng, [0,0]) mallow=Curve(xrng, [-0.004, 0.004]) callow=Curve(xrng, [-0.0004, 0.0004]) mallow=FillBetween(xrng, [0.004,0.004], xrng, [-0.004,-0.004], color='grey80') callow=FillBetween(xrng, [0.0004,0.0004], xrng, [-0.0004,-0.0004], color='grey80') labels=get_labels(run, psfnums, setname, nobj, sratio_range) mplt.add( mallow, zplt, m1pts, m1errpts, m2pts, m2errpts, key ) mplt.add(*labels) cplt.add( callow, zplt, c1pts, c1errpts, c2pts, c2errpts ) tab[0,0] = mplt tab[1,0] = cplt tab.show()