def potential_plot(env, model, obj_index, src_index, with_colorbar=True, with_contours=False): obj, data = model['obj,data'][obj_index] R = obj.basis.mapextent grid = obj.basis.potential_grid(data) levs = obj.basis.potential_contour_levels(data) # pl.matshow(grid, fignum=False, extent=[-R,R,-R,R], interpolation='nearest') pl.matshow(grid, fignum=False, cmap=cm.bone, extent=[-R, R, -R, R], interpolation='nearest') if with_colorbar: glspl.colorbar() # pl.contour(grid, extent=[-R,R,-R,R], origin='upper') #print levs if with_contours: for i, lev in enumerate(levs): pl.over(contour, grid, lev, colors=system_color(i), extent=[-R, R, -R, R], origin='upper', extend='both') pl.xlabel('arcsec') pl.ylabel('arcsec')
def grad_kappa_plot(env, model, obj_index, which='x', with_contours=False, only_contours=False, clevels=30, with_colorbar=True): obj, data = model['obj,data'][obj_index] R = obj.basis.mapextent grid = obj.basis.kappa_grid(data) grid = grid.copy() kw = default_kw(R) kw['vmin'] = -1 kw['vmax'] = 2 if not only_contours: print '!!!!!!', grid.shape if which == 'x': grid = np.diff(grid, axis=1) if which == 'y': grid = np.diff(grid, axis=0) print '!!!!!!', grid.shape pl.matshow(grid, **kw) if with_colorbar: glspl.colorbar() if with_contours: kw.pop('cmap') pl.over(contour, grid, clevels, extend='both', colors='k', alpha=0.7, **kw) pl.xlabel('arcsec') pl.ylabel('arcsec')
def plot(model, si, hilite=False): obj, data = model xs = [] ys = [] cs = [] for i, sys in enumerate(obj.sources): if src_index is not None and i != src_index: continue xs.append(data['src'][i].real) ys.append(data['src'][i].imag) lw, ls, c = si.next() cs.append(c) #system_color(i)) if hilite: pl.over(scatter, xs, ys, s=80, c=hilite_color, zorder=2000, marker='x', alpha=1.0, **kwargs) else: pl.scatter(xs, ys, s=80, c=cs, zorder=1000, marker='d', alpha=0.5, facecolor='none', linewidths=1, **kwargs)
def img_plot( env, **kwargs ): #src_index=None, with_maximum=True, color=None, with_guide=False, tight=False): obj_index = kwargs.pop('obj_index', 0) src_index = kwargs.pop('src_index', None) tight = kwargs.pop('tight', False) with_guide = kwargs.pop('with_guide', False) color = kwargs.pop('color', None) with_maximum = kwargs.pop('with_maximum', True) #src_index = np.atleast_1d(src_index) obj = env.objects[obj_index] oxlim, oylim = pl.xlim(), pl.ylim() rmax = 0 si = style_iterator() for i, src in enumerate(obj.sources): lw, ls, c = si.next() if src_index: if i not in np.atleast_1d(src_index): continue xs, ys, cs = [], [], [] for img in src.images: #print img.pos if not with_maximum and img.parity_name == 'max': continue xs.append(img.pos.real) ys.append(img.pos.imag) if not color: if img.parity_name == 'unk': cs.append('red') else: cs.append(c) else: cs.append(color) if xs and ys: pl.over(pl.scatter, xs, ys, s=80, c=cs, zorder=1000, alpha=1.0) if with_guide or tight: a = pl.gca() for x, y in zip(xs, ys): r = np.sqrt(x**2 + y**2) rmax = np.amax([r, rmax]) if with_guide: a.add_artist( Circle((0, 0), r, fill=False, color='lightgrey')) pl.xlim(oxlim) pl.ylim(oylim) if tight and rmax > 0: #rmax *= 1.01 pl.gca().set_xlim(-rmax, rmax) pl.gca().set_ylim(-rmax, rmax)
def img_plot(env, **kwargs): #src_index=None, with_maximum=True, color=None, with_guide=False, tight=False): obj_index = kwargs.pop('obj_index', 0) src_index = kwargs.pop('src_index', None) tight = kwargs.pop('tight', False) with_guide = kwargs.pop('with_guide', False) color = kwargs.pop('color', None) with_maximum = kwargs.pop('with_maximum', True) #src_index = np.atleast_1d(src_index) obj = env.objects[obj_index] oxlim, oylim = pl.xlim(), pl.ylim() rmax = 0 si = style_iterator() for i,src in enumerate(obj.sources): lw,ls,c = si.next() if src_index: if i not in np.atleast_1d(src_index): continue xs,ys,cs = [], [], [] for img in src.images: #print img.pos if not with_maximum and img.parity_name == 'max': continue xs.append(img.pos.real) ys.append(img.pos.imag) if not color: if img.parity_name == 'unk': cs.append('red') else: cs.append(c) else: cs.append(color) if xs and ys: pl.over(pl.scatter,xs, ys, s=80, c=cs, zorder=1000, alpha=1.0) if with_guide or tight: a = pl.gca() for x,y in zip(xs,ys): r = np.sqrt(x**2 + y**2) rmax = np.amax([r,rmax]) if with_guide: a.add_artist(Circle((0,0),r, fill=False,color='lightgrey')) pl.xlim(oxlim); pl.ylim(oylim) if tight and rmax > 0: #rmax *= 1.01 pl.gca().set_xlim(-rmax, rmax) pl.gca().set_ylim(-rmax, rmax)
def external_mass_plot(env, obj_index=0, with_maximum=True, color=None, with_guide=False, tight=False): #obj,_ = model['obj,data'][obj_index] #obj,_ = model['obj,data'][obj_index] si = style_iterator() for i in xrange(obj_index + 1): lw, ls, c = si.next() obj = env.objects[obj_index] #print obj.external_masses # if isinstance(model, (list, tuple)): # obj,_ = model # else: # obj = model oxlim, oylim = pl.xlim(), pl.ylim() rmax = 0 xs, ys, cs = [], [], [] for i, m in enumerate(obj.extra_potentials): if isinstance(m, Shear): continue xs.append(m.r.real) ys.append(m.r.imag) if not color: cs.append(c) else: cs.append(color) rmax = np.amax([np.abs(m.r), rmax]) if xs and ys: pl.over(pl.scatter, xs, ys, s=160, c=cs, zorder=1000, alpha=1.0, marker='s') pl.xlim(oxlim) pl.ylim(oylim) if tight and rmax > 0: pl.pl.gca().set_pl.xlim(-rmax, rmax) pl.pl.gca().set_pl.ylim(-rmax, rmax)
def plot(model, si, hilite=False): obj, data = model xs = [] ys = [] cs = [] for i,sys in enumerate(obj.sources): if src_index is not None and i != src_index: continue xs.append(data['src'][i].real) ys.append(data['src'][i].imag) lw,ls,c = si.next() cs.append(c) #system_color(i)) if hilite: pl.over(scatter,xs, ys, s=80, c=hilite_color, zorder=2000, marker='x', alpha=1.0, **kwargs) else: pl.scatter(xs, ys, s=80, c=cs, zorder=1000, marker='d', alpha=0.5, facecolor='none', linewidths=1, **kwargs)
def critical_curve_plot(env, model, obj_index, src_index): obj, data = model['obj,data'][obj_index] R = obj.basis.mapextent g = obj.basis.maginv_grid(data)[src_index] pl.matshow(g, fignum=False, cmap=cm.bone, extent=[-R, R, -R, R], interpolation='nearest') pl.over(contour, g, [0], colors='g', linewidths=1, extent=[-R, R, -R, R], origin='upper')
def potential_plot(env, model, obj_index, src_index, with_colorbar=True, with_contours=False): obj, data = model['obj,data'][obj_index] R = obj.basis.mapextent grid = obj.basis.potential_grid(data) levs = obj.basis.potential_contour_levels(data) # pl.matshow(grid, fignum=False, extent=[-R,R,-R,R], interpolation='nearest') pl.matshow(grid, fignum=False, cmap=cm.bone, extent=[-R,R,-R,R], interpolation='nearest') if with_colorbar: glspl.colorbar() # pl.contour(grid, extent=[-R,R,-R,R], origin='upper') #print levs if with_contours: for i,lev in enumerate(levs): pl.over(contour, grid, lev, colors = system_color(i), extent=[-R,R,-R,R], origin='upper', extend='both') pl.xlabel('arcsec') pl.ylabel('arcsec')
def external_mass_plot(env, obj_index=0, with_maximum=True, color=None, with_guide=False, tight=False): #obj,_ = model['obj,data'][obj_index] #obj,_ = model['obj,data'][obj_index] si = style_iterator() for i in xrange(obj_index+1): lw,ls,c = si.next() obj = env.objects[obj_index] #print obj.external_masses # if isinstance(model, (list, tuple)): # obj,_ = model # else: # obj = model oxlim, oylim = pl.xlim(), pl.ylim() rmax = 0 xs,ys,cs = [], [], [] for i,m in enumerate(obj.extra_potentials): if isinstance(m, Shear): continue xs.append(m.r.real) ys.append(m.r.imag) if not color: cs.append(c) else: cs.append(color) rmax = np.amax([np.abs(m.r),rmax]) if xs and ys: pl.over(pl.scatter,xs, ys, s=160, c=cs, zorder=1000, alpha=1.0, marker='s') pl.xlim(oxlim); pl.ylim(oylim) if tight and rmax > 0: pl.pl.gca().set_pl.xlim(-rmax, rmax) pl.pl.gca().set_pl.ylim(-rmax, rmax)
def critical_curve_plot(env, model, obj_index, src_index): obj, data = model['obj,data'][obj_index] R = obj.basis.mapextent g = obj.basis.maginv_grid(data)[src_index] pl.matshow(g, fignum=False, cmap=cm.bone, extent=[-R,R,-R,R], interpolation='nearest') pl.over(contour, g, [0], colors='g', linewidths=1, extent=[-R,R,-R,R], origin='upper')