def plot_trans_vs_U(iZ, iNHI, grid, trans, ax): atoms,nums = zip(*[split_trans_name(t) for t in trans]) count = dict((k, 0) for k in COLORS) for atom, num in zip(atoms, nums): col = COLORS[atom] N = grid.N[atom][iNHI, :, iZ, roman_map[num]] pl.plot(grid.nH, N, lw=3, ls=LS[count[atom] % len(LS)], color=col,label=atom+num) count[atom] += 1 ax.legend(frameon=0, ncol=2) ax.set_ylabel('$\log_{10}\ N\ (\mathrm{cm}^{-2})$') ax.set_xlabel('$\log_{10}\ n_\mathrm{H}\ (\mathrm{cm}^{-3})$') puttext(0.05, 0.05, '$\log_{10}\ N_\mathrm{HI}=%.3g,\ Z=%.3g$' % ( grid.NHI[iNHI],grid.Z[iZ]),ax) ax.set_xlim(grid.nH[0]+0.01, grid.nH[-1]-0.01) ax1 = ax.twiny() x0,x1 = ax.get_xlim() const = (grid.U + grid.nH)[0] assert np.allclose(const, grid.U + grid.nH) ax1.set_xlim(const - x0, const - x1) ax1.set_xlabel('$\log_{10}\ U$')
def calc_kappa(idep, inodep, obs): eldep, elnodep = (split_trans_name(k)[0] for k in (idep, inodep)) Ndep = obs[idep][0] Nnodep = obs[inodep][0] NH = obs['HI'][0] Ndeplo = obs[idep][0] - obs[idep][1] Nnodeplo = obs[inodep][0] - obs[inodep][1] NHlo = obs['HI'][0] - obs['HI'][1] Ndephi = obs[idep][0] + obs[idep][2] Nnodephi = obs[inodep][0] + obs[inodep][2] NHhi = obs['HI'][0] + obs['HI'][2] t1 = 10**calc_abund(elnodep, 'H', Nnodep, NH) t2 = (1 - 10**calc_abund(eldep, elnodep, Ndep, Nnodep)) kappa = t1 * t2 # upper limit t1 = 10**calc_abund(elnodep, 'H', Nnodephi, NHlo) t2 = (1 - 10**calc_abund(eldep, elnodep, Ndeplo, Nnodephi)) kappahi = t1 * t2 # lower limit t1 = 10**calc_abund(elnodep, 'H', Nnodeplo, NHhi) t2 = (1 - 10**calc_abund(eldep, elnodep, Ndephi, Nnodeplo)) kappalo = t1 * t2 return np.array([kappa, kappalo, kappahi])
def plot_trans_vs_NHI(iZ, inH, grid, trans, ax): atoms,nums = zip(*[split_trans_name(t) for t in trans]) count = dict((k, 0) for k in COLORS) for atom, num in zip(atoms, nums): col = COLORS[atom] N = grid.N[atom][:, inH, iZ, roman_map[num]] pl.plot(grid.NHI, N, lw=2, ls=LS[count[atom] % len(LS)], color=col,label=atom+num) count[atom] += 1 pl.legend(frameon=0, ncol=3) pl.ylabel('$\log_{10}\ N (\mathrm{cm}^{-2}$') pl.xlabel('$\log_{10}\ N_\mathrm{HI} (\mathrm{cm}^{-2})$') puttext(0.05, 0.95, '$n_{H}=%.3g\ Z=%.3g$' % ( grid.nH[inH], grid.Z[iZ]), ax)
def model(par, for_plot=False): """ This will interpolate between cloudy models and apply the relative abundance variation multipliers and return a bunch of column densities. par = all the ks then NHI, nH, Z or par = all the ks then NHI, nH, Z, aUV Returns ------- Nmodel : list The model log10 column density for each transition. """ if for_plot: trvals = tr_plot else: trvals = trans try: coord = par[IND_PAR['NHI']], par[IND_PAR['nH']], par[IND_PAR['Z']], \ par[IND_PAR['aUV']] except: import pdb pdb.set_trace() Nmodel = [] for tr in trvals: atom, stage = split_trans_name(tr) N = Ncloudy[tr](coord) if atom in IND_KPAR: N += par[IND_KPAR[atom]] Nmodel.append(N) return np.array(Nmodel)
def model(par, for_plot=False): """ This will interpolate between cloudy models and apply the relative abundance variation multipliers and return a bunch of column densities. par = all the ks then NHI, nH, Z or par = all the ks then NHI, nH, Z, aUV Returns ------- Nmodel : list The model log10 column density for each transition. """ if for_plot: trvals = tr_plot else: trvals = trans try: coord = par[IND_PAR['NHI']], par[IND_PAR['nH']], par[IND_PAR['Z']], \ par[IND_PAR['aUV']] except: import pdb; pdb.set_trace() Nmodel = [] for tr in trvals: atom, stage = split_trans_name(tr) N = Ncloudy[tr](coord) if atom in IND_KPAR: N += par[IND_KPAR[atom]] Nmodel.append(N) return np.array(Nmodel)
def make_interpolators_uvbtilt(trans, simnames): """ Make interpolators including different UV slopes, given by the simulation names. simname naming scheme should be (uvb_k00, uvb_k01, uvb_k02, ...), uvb k values must be sorted in ascending order! """ Models = [] aUV = [] for simname in simnames: # need to define prefix, SIMNAME gridname = os.path.join(simname, 'grid.cfg') print 'Reading', gridname cfg = parse_config(gridname) aUV.append(cfg.uvb_tilt) name = os.path.join(simname, cfg.prefix + '_grid.sav.gz') print 'Reading', name M = loadobj(name) M = adict(M) Uconst = (M.U + M.nH)[0] print 'Uconst', Uconst, cfg.uvb_tilt assert np.allclose(Uconst, M.U + M.nH) Models.append(M) ########################################################################## # Interpolate cloudy grids onto a finer scale for plotting and # likelihood calculation ########################################################################## roman_map = {'I':0, 'II':1, 'III':2, 'IV':3, 'V':4, 'VI':5, 'VII':6, 'VIII':7, 'IX':8, 'X':9, '2':2} Ncloudy = {} Ncloudy_raw = {} print 'Interpolating...' for tr in trans + ['NH']: shape = len(M.NHI), len(M.nH), len(M.Z), len(aUV) Nvals = np.zeros(shape) if tr in ['CII*']: for i,M in enumerate(Models): Nvals[:,:,:,i] = M.Nex[tr][:,:,:] elif tr == 'NH': for i,M in enumerate(Models): logNHI = M.N['H'][:,:,:,0] logNHII = M.N['H'][:,:,:,1] logNHtot = np.log10(10**logNHI + 10**logNHII) Nvals[:,:,:,i] = logNHtot else: atom, stage = split_trans_name(tr) ind = roman_map[stage] for i,M in enumerate(Models): Nvals[:,:,:,i] = M.N[atom][:,:,:,ind] # use ndimage.map_coordinates (which is spline interpolation) coord = M.NHI, M.nH, M.Z, aUV try: Ncloudy[tr] = MapCoord_Interpolator(Nvals, coord) except: import pdb; pdb.set_trace() Ncloudy_raw[tr] = Nvals print 'done' return Ncloudy, Ncloudy_raw, Models, np.array(aUV, np.float)
z = Ncloudy[tr]((nH1, Z1)) arrplot(z.T, x=nH, y=Z, ax=ax1, colorbar=0) ax0.set_title(tr) pl.show() if 1: ###################################################### # Work out which parameters we're estimating ###################################################### vals = [] # Only estimate the multipliers we can fit for, based on the observed # transitions atoms = set(split_trans_name(tr)[0] for tr in trans) #if any(atom in ALPHA_ELEMENTS for atom in atoms): # vals.append( ('k_alpha', -1, 1) ) if 'C' in atoms and 'k_C' not in dont_use: vals.append( ('k_C', priors['min k_C'], priors['max k_C']) ) if 'Al' in atoms and 'k_Al' not in dont_use: vals.append( ('k_Al', priors['min k_Al'], priors['max k_Al']) ) if 'N' in atoms and 'k_N' not in dont_use: vals.append( ('k_N' , priors['min k_N'], priors['max k_N']) ) if any(atom in FEPEAK_ELEMENTS for atom in atoms) \ and 'k_Fe' not in dont_use: vals.append( ('k_Fe', priors['min k_Fe'], priors['max k_Fe']) ) # These limits will be set later on, based on the grids used to generate # the cloudy models.
Fnu = np.log10(10**starburst.logfnu * np.exp(-ext.tau)) F = Fnu[::-1] ax2.semilogx(X, convolve_psf(F - F[ind] + N0, 50), 'r', lw=0.5, label='$\mathrm{starburst},\ E(B-V)=0.2$') ax2.legend(frameon=0, loc='lower left', fontsize=12) #plt.grid(ls='solid', lw=0.5, color='0.7') xvals = (IP * u.eV).to(u.Ry).value y = np.interp(xvals, ref.energy, ref.log10jnu) from barak.absorb import split_trans_name ax1.vlines(xvals, y + 0.1, y + 0.3, lw=0.5, color='0.5')#, ls=':') for i in xrange(len(xvals)): atom,stage = split_trans_name(trans[i]) t = atom + ' ' + stage align = 'left' if trans[i] in 'SiIV AlIII'.split(): align = 'center' ax1.text(xvals[i], y[i]+0.35, t, fontsize=9, rotation=90, ha=align, va='bottom') c = 'k' puttext(0.79, 0.59, r'$\alpha_\mathrm{UV}=1$', color=c,ax=ax1, rotation=-5) puttext(0.78, 0.41, r'$\alpha_\mathrm{UV}=0$', color=c,ax=ax1, rotation=-13) puttext(0.76, 0.30, r'$\alpha_\mathrm{UV}=-1$',color=c,ax=ax1, rotation=-15) puttext(0.76, 0.12, r'$\alpha_\mathrm{UV}=-2$',color=c,ax=ax1, rotation=-18) for ax in (ax1,ax2): ax.set_xlabel('$\mathrm{Energy\ (Rydbergs)}$')
ind = np.arange(len(xvals))[direction =='down'] previouslong = False for i in xrange(len(ind) - 1): i += 1 if (xvals[ind[i]] - xvals[ind[i-1]]) < 0.04 and not previouslong: length[ind[i]] = 'long' previouslong = True else: previouslong = False offset = 0.003 xoff = {t:offset for t in trans} #xoff.update(SiIV=0, CIII=0.01) for i in xrange(len(xvals)): tr = trans[i] atom,stage = split_trans_name(tr) t = atom + ' ' + stage halign = 'center' valign = 'bottom' dx = xoff[tr] dy0 = 0.1 dy1 = 0.4 if length[i] == 'long': dy1 = 1.2 dy2 = dy1 + 0.05 if direction[i] == 'down': dy0 = -dy0 dy1 = -dy1 dy2 = -dy2 valign = 'top'
def make_interpolators_uvbtilt(trans, simnames): """ Make interpolators including different UV slopes, given by the simulation names. simname naming scheme should be (uvb_k00, uvb_k01, uvb_k02, ...), uvb k values must be sorted in ascending order! """ Models = [] aUV = [] for simname in simnames: # need to define prefix, SIMNAME gridname = os.path.join(simname, 'grid.cfg') print 'Reading', gridname cfg = parse_config(gridname) aUV.append(cfg.uvb_tilt) name = os.path.join(simname, cfg.prefix + '_grid.sav.gz') print 'Reading', name M = loadobj(name) M = adict(M) Uconst = (M.U + M.nH)[0] print 'Uconst', Uconst, cfg.uvb_tilt assert np.allclose(Uconst, M.U + M.nH) Models.append(M) ########################################################################## # Interpolate cloudy grids onto a finer scale for plotting and # likelihood calculation ########################################################################## roman_map = { 'I': 0, 'II': 1, 'III': 2, 'IV': 3, 'V': 4, 'VI': 5, 'VII': 6, 'VIII': 7, 'IX': 8, 'X': 9, '2': 2 } Ncloudy = {} Ncloudy_raw = {} print 'Interpolating...' for tr in trans + ['NH']: shape = len(M.NHI), len(M.nH), len(M.Z), len(aUV) Nvals = np.zeros(shape) if tr in ['CII*']: for i, M in enumerate(Models): Nvals[:, :, :, i] = M.Nex[tr][:, :, :] elif tr == 'NH': for i, M in enumerate(Models): logNHI = M.N['H'][:, :, :, 0] logNHII = M.N['H'][:, :, :, 1] logNHtot = np.log10(10**logNHI + 10**logNHII) Nvals[:, :, :, i] = logNHtot else: atom, stage = split_trans_name(tr) ind = roman_map[stage] for i, M in enumerate(Models): Nvals[:, :, :, i] = M.N[atom][:, :, :, ind] # use ndimage.map_coordinates (which is spline interpolation) coord = M.NHI, M.nH, M.Z, aUV try: Ncloudy[tr] = MapCoord_Interpolator(Nvals, coord) except: import pdb pdb.set_trace() Ncloudy_raw[tr] = Nvals print 'done' return Ncloudy, Ncloudy_raw, Models, np.array(aUV, np.float)
arrplot(Ncloudy_raw[tr].T, x=M.nH, y=M.Z, ax=ax0, colorbar=0) z = Ncloudy[tr]((nH1, Z1)) arrplot(z.T, x=nH, y=Z, ax=ax1, colorbar=0) ax0.set_title(tr) pl.show() if 1: ###################################################### # Work out which parameters we're estimating ###################################################### vals = [] # Only estimate the multipliers we can fit for, based on the observed # transitions atoms = set(split_trans_name(tr)[0] for tr in trans) #if any(atom in ALPHA_ELEMENTS for atom in atoms): # vals.append( ('k_alpha', -1, 1) ) if 'C' in atoms and 'k_C' not in dont_use: vals.append(('k_C', priors['min k_C'], priors['max k_C'])) if 'Al' in atoms and 'k_Al' not in dont_use: vals.append(('k_Al', priors['min k_Al'], priors['max k_Al'])) if 'N' in atoms and 'k_N' not in dont_use: vals.append(('k_N', priors['min k_N'], priors['max k_N'])) if any(atom in FEPEAK_ELEMENTS for atom in atoms) \ and 'k_Fe' not in dont_use: vals.append(('k_Fe', priors['min k_Fe'], priors['max k_Fe'])) # These limits will be set later on, based on the grids used to generate # the cloudy models.
def update(self, z): if self.opt.f26 is not None: wa, nfl, ner, nco, model, artists, options = (self.wa, self.nfl, self.ner, self.co, self.model, self.artists, self.opt) else: wa, nfl, ner, nco, artists, options = (self.wa, self.nfl, self.ner, self.co, self.artists, self.opt) self.z = z ymult = self.ymult zp1 = z + 1 betamin = self.vmin / c_kms betamax = self.vmax / c_kms for t in artists['ticklabels']: t.remove() for t in artists['ticks']: t.remove() artists['ticklabels'] = [] artists['ticks'] = [] if artists['ew'] is not None: artists['ew'].remove() artists['ew'] = None for r in artists['regions']: r.remove() for s in artists['sky']: s.remove() for s in artists['aod']: s.remove() artists['regions'] = [] artists['sky'] = [] artists['aod'] = [] # want plots to appear from top down, so we need reversed() for i, trans in enumerate(reversed(options.linelist)): atom, ion = split_trans_name(trans['name'].split()[0]) iax, ioff = divmod(i, self.num_per_panel) ax = self.axes[iax] offset = ioff * 1.5 #if i >= self.num_per_panel: # offset = (i - self.num_per_panel) * 1.5 # ax = self.axes[1] watrans = trans['wa'] obswa = watrans * zp1 wmin = obswa * (1 + 3 * betamin) wmax = obswa * (1 + 3 * betamax) if self.opt.showticks and len(self.allticks) > 0: ticks = self.allticks tickwmin = obswa * (1 + betamin) tickwmax = obswa * (1 + betamax) wticks = ticks.wa cond = between(wticks, tickwmin, tickwmax) if cond.any(): vel = (wticks[cond] / obswa - 1) * c_kms for j, t in enumerate(ticks[cond]): T, Tlabels = plot_tick_vel(ax, vel[j], offset, t, tickz=options.tickz) artists['ticklabels'].extend(Tlabels) artists['ticks'].extend(T) cond = between(wa, wmin, wmax) #good = ~np.isnan(fl) & (er > 0) & ~np.isnan(co) # remove ultra-low S/N regions to help plotting cond &= ner < 1.5 cond &= ymult * (nfl - 1) + 1 > -0.1 fl = nfl[cond] co = nco[cond] vel = (wa[cond] / obswa - 1) * c_kms if options.f26 is not None and options.f26.regions is not None: artists['regions'].extend( plot_velocity_regions(wmin, wmax, options.f26.regions.wmin, options.f26.regions.wmax, obswa, ax, offset, vel, ymult * (fl - 1) + 1)) #import pdb; pdb.set_trace() if hasattr(options, 'aod'): # print ranges used for AOD calculation. # find the right transition c0 = ((np.abs(options.aod['wrest'] - trans['wa']) < 0.01) & (options.aod['atom'] == atom)) itrans = np.flatnonzero(c0) for row in options.aod[itrans]: c0 = between(wa[cond], row['wmin'], row['wmax']) if np.any(c0): artists['aod'].append( ax.fill_between(vel[c0], offset, offset + 1.5, facecolor='0.8', lw=0, zorder=0)) vranges = [] for w0, w1 in unrelated: c0 = between(wa[cond], w0, w1) if c0.any(): vranges.append(c0) for w0, w1 in ATMOS: c0 = between(wa[cond], w0, w1) if c0.any(): artists['sky'].append( ax.fill_between(vel[c0], offset, offset + 1.5, facecolor='0.9', lw=0)) if self.smoothby > 1: if len(fl) > 3 * self.smoothby: fl = convolve_psf(fl, self.smoothby) artists['fl'][i].set_xdata(vel) artists['fl'][i].set_ydata(ymult * (fl - 1) + 1 + offset) artists['co'][i].set_xdata(vel) artists['co'][i].set_ydata(ymult * (co - 1) + 1 + offset) #pdb.set_trace() if self.opt.residuals: resid = (fl - model[cond]) / ner[cond] c0 = np.abs(resid) < 5 artists['resid'][i].set_xdata(vel[c0]) artists['resid'][i].set_ydata(resid[c0] * 0.05 + offset - 0.1) if self.opt.f26 is not None: artists['model'][i].set_xdata(vel) artists['model'][i].set_ydata(ymult * (model[cond] - 1) + 1 + offset) tr_id = trans['name'], tuple(trans['tr']) #import pdb; pdb.set_trace() art = self.artists['models'][tr_id] for line in self.models: m = self.models[line] if line not in art: art[line] = ax.plot(vel, ymult * (m[cond] - 1) + 1 + offset, 'k', lw=0.2)[0] else: art[line].set_xdata(vel) art[line].set_ydata(ymult * (m[cond] - 1) + 1 + offset) for ax in self.axes: ax.set_xlim(self.vmin, self.vmax) ax.set_ylim(-0.5, self.num_per_panel * 1.5) self.artists['title'].set_text('$z = %.5f$' % self.z) if not self.opt.ticklabels: for t in artists['ticklabels']: t.set_visible(False) self.fig.canvas.draw() self.artists = artists
wa0 = regions.wmin[isort[i0 - 1]] - expand_cont_adjustment wa1 = regions.wmax[isort[i1]] + expand_cont_adjustment c0 = between(sp.wa, wa0, wa1) mult = level + linterm * (sp.wa[c0]/wav0 - 1) sp.co[c0] = sp.co[c0] * mult if 1: fig,AX = get_fig_axes(10, 2, len(transitions), aspect=0.24, width=6.3) #fig,AX = get_fig_axes(7, 2, len(transitions), aspect=0.26, width=6.3) fig.subplots_adjust(hspace=1e-5, wspace=1e-5, bottom=0.06, right=0.99, left=0.08, top=0.97) label = [] for tr in transitions: ion,wa = tr[0].split() atom,stage = split_trans_name(ion) if tr[0] == 'HI 926': label.append('H I') elif tr[0] == 'DI 937': label.append('D I\nLy-$\epsilon$') else: label.append(atom + ' ' + stage + '\n' + wa) print vp.lines c0 = ((vp.lines.name == 'C IV') & ~np.in1d(vp.lines.zpar,('AR','AS','AQ','AU','AT', 'AV'))) zvals = vp.lines[c0].z is_low = np.array([np.any(abs(z - zvals) < 1e-5) for z in lines.z]) tvel = c_kms * (zvals - cfg.v0redshift) / (1 + cfg.v0redshift)
def update(self, z): if self.opt.f26 is not None: wa, nfl, ner, nco, model, artists, options = ( self.wa, self.nfl, self.ner, self.co, self.model, self.artists, self.opt) else: wa, nfl, ner, nco, artists, options = ( self.wa, self.nfl, self.ner, self.co, self.artists, self.opt) self.z = z ymult = self.ymult zp1 = z + 1 betamin = self.vmin / c_kms betamax = self.vmax / c_kms for t in artists['ticklabels']: t.remove() for t in artists['ticks']: t.remove() artists['ticklabels'] = [] artists['ticks'] = [] if artists['ew'] is not None: artists['ew'].remove() artists['ew'] = None for r in artists['regions']: r.remove() for s in artists['sky']: s.remove() for s in artists['aod']: s.remove() artists['regions'] = [] artists['sky'] = [] artists['aod'] = [] # want plots to appear from top down, so we need reversed() for i, trans in enumerate(reversed(options.linelist)): atom, ion = split_trans_name(trans['name'].split()[0]) iax, ioff = divmod(i, self.num_per_panel) ax = self.axes[iax] offset = ioff * 1.5 #if i >= self.num_per_panel: # offset = (i - self.num_per_panel) * 1.5 # ax = self.axes[1] watrans = trans['wa'] obswa = watrans * zp1 wmin = obswa * (1 + 3*betamin) wmax = obswa * (1 + 3*betamax) if self.opt.showticks and len(self.allticks) > 0: ticks = self.allticks tickwmin = obswa * (1 + betamin) tickwmax = obswa * (1 + betamax) wticks = ticks.wa cond = between(wticks, tickwmin, tickwmax) if cond.any(): vel = (wticks[cond] / obswa - 1) * c_kms for j,t in enumerate(ticks[cond]): T,Tlabels = plot_tick_vel(ax, vel[j], offset, t, tickz=options.tickz) artists['ticklabels'].extend(Tlabels) artists['ticks'].extend(T) cond = between(wa, wmin, wmax) #good = ~np.isnan(fl) & (er > 0) & ~np.isnan(co) # remove ultra-low S/N regions to help plotting cond &= ner < 1.5 cond &= ymult*(nfl-1) + 1 > -0.1 fl = nfl[cond] co = nco[cond] vel = (wa[cond] / obswa - 1) * c_kms if options.f26 is not None and options.f26.regions is not None: artists['regions'].extend(plot_velocity_regions( wmin, wmax, options.f26.regions.wmin, options.f26.regions.wmax, obswa, ax, offset, vel, ymult*(fl-1) + 1)) #import pdb; pdb.set_trace() if hasattr(options, 'aod'): # print ranges used for AOD calculation. # find the right transition c0 = ((np.abs(options.aod['wrest'] - trans['wa']) < 0.01) & (options.aod['atom'] == atom)) itrans = np.flatnonzero(c0) for row in options.aod[itrans]: c0 = between(wa[cond], row['wmin'], row['wmax']) if np.any(c0): artists['aod'].append( ax.fill_between(vel[c0], offset, offset+1.5, facecolor='0.8', lw=0, zorder=0) ) vranges = [] for w0, w1 in unrelated: c0 = between(wa[cond], w0, w1) if c0.any(): vranges.append(c0) for w0, w1 in ATMOS: c0 = between(wa[cond], w0, w1) if c0.any(): artists['sky'].append( ax.fill_between(vel[c0], offset, offset + 1.5, facecolor='0.9', lw=0)) if self.smoothby > 1: if len(fl) > 3 * self.smoothby: fl = convolve_psf(fl, self.smoothby) artists['fl'][i].set_xdata(vel) artists['fl'][i].set_ydata(ymult*(fl-1) + 1 + offset) artists['co'][i].set_xdata(vel) artists['co'][i].set_ydata(ymult*(co-1) + 1 + offset) #pdb.set_trace() if self.opt.residuals: resid = (fl - model[cond]) / ner[cond] c0 = np.abs(resid) < 5 artists['resid'][i].set_xdata(vel[c0]) artists['resid'][i].set_ydata(resid[c0] * 0.05 + offset - 0.1) if self.opt.f26 is not None: artists['model'][i].set_xdata(vel) artists['model'][i].set_ydata(ymult*(model[cond]-1) + 1 + offset) tr_id = trans['name'], tuple(trans['tr']) #import pdb; pdb.set_trace() art = self.artists['models'][tr_id] for line in self.models: m = self.models[line] if line not in art: art[line] = ax.plot(vel, ymult*(m[cond]-1) + 1 + offset, 'k', lw=0.2)[0] else: art[line].set_xdata(vel) art[line].set_ydata(ymult*(m[cond]-1) + 1 + offset) for ax in self.axes: ax.set_xlim(self.vmin, self.vmax) ax.set_ylim(-0.5, self.num_per_panel * 1.5) self.artists['title'].set_text('$z = %.5f$' % self.z) if not self.opt.ticklabels: for t in artists['ticklabels']: t.set_visible(False) self.fig.canvas.draw() self.artists = artists
mult = level + linterm * (sp.wa[c0] / wav0 - 1) sp.co[c0] = sp.co[c0] * mult if 1: fig, AX = get_fig_axes(10, 2, len(transitions), aspect=0.24, width=6.3) #fig,AX = get_fig_axes(7, 2, len(transitions), aspect=0.26, width=6.3) fig.subplots_adjust(hspace=1e-5, wspace=1e-5, bottom=0.06, right=0.99, left=0.08, top=0.97) label = [] for tr in transitions: ion, wa = tr[0].split() atom, stage = split_trans_name(ion) if tr[0] == 'HI 926': label.append('H I') elif tr[0] == 'DI 937': label.append('D I\nLy-$\epsilon$') else: label.append(atom + ' ' + stage + '\n' + wa) print vp.lines c0 = ((vp.lines.name == 'C IV') & ~np.in1d(vp.lines.zpar, ('AR', 'AS', 'AQ', 'AU', 'AT', 'AV'))) zvals = vp.lines[c0].z is_low = np.array([np.any(abs(z - zvals) < 1e-5) for z in lines.z]) tvel = c_kms * (zvals - cfg.v0redshift) / (1 + cfg.v0redshift)
def calc_abund_range(k1, k2, obs): el1, el2 = (split_trans_name(k)[0] for k in (k1, k2)) best = calc_abund(el1, el2, obs[k1][0], obs[k2][0]) lo = calc_abund(el1, el2, obs[k1][0]-obs[k1][1], obs[k2][0]+obs[k2][1]) hi = calc_abund(el1, el2, obs[k1][0]+obs[k1][1], obs[k2][0]-obs[k2][1]) return np.array([best, lo, hi])