def test_diag_list(): diags = [ '[ArIII] 5192/7136', '[ArIII] 9.0m/21.8m', '[ArIV] 4740/4711', '[CIII] 1909/1907', '[ClIII] 5538/5518', '[NII] 121m/20.5m', '[NII] 5755/6584', '[NeIII] 15.6m/36.0m', '[NeIII] 3343/3930+', '[NeV] 14.3m/24.2m', '[NeV] 2973/3370+', '[OI] 5577/6300+', '[OI] 63m/147m', '[OII] 3726/3729', '[OII] 3727+/7325+', '[OIII] 1664+/5007', '[OIII] 5007/88m', '[OIII] 4363/5007', '[OIV] 1400+/25.9m', '[OIV] 1401/1405', '[SII] 4072+/6720+', '[SII] 4069/4076', '[SII] 6731/6716', '[SIII] 6312/9069', '[SIII] 18.7m/33.5m' ] # Build the 25 subplots f, axes = plt.subplots(5, 5, figsize=(20, 20)) # loop on the diagnostics for i, d in enumerate(diags): # extract from the diagnostic dictionnary # the expression to be evaluated to_eval = pn.diags_dict[d][1] atom = pn.diags_dict[d][0] # split e.g. obtain 'O', 3 from 'O3' elem, spec = pn.utils.misc.parseAtom(atom) # instantiate the EmisGrid object for the given ion EG = pn.EmisGrid(elem, spec) # select the axis in which to plot ax = axes.ravel()[i] # make the plot EG.plotContours(to_eval=to_eval, ax=ax) plt.close()
def plot_all(save=False): pn.log_.level = 1 AA = pn.getAtomDict(OmegaInterp='Linear') for diag in pn.diags_dict: atom, diag_eval, err = pn.diags_dict[diag] if atom in AA: plt.figure() grid = pn.EmisGrid(atomObj=AA[atom]) grid.plotContours(to_eval=diag_eval) if save: plt.savefig('{0}_{1}.pdf'.format(atom, diag_eval.replace('/', '_')))
def plot_all(save=False): pn.log_.level = 1 AA = pn.getAtomDict(OmegaInterp='Linear') # Loop over all the diags stored in pn.core.diags.diags_dict for diag in diags_dict: atom, diag_eval, err = diags_dict[diag] # Skip Fe III as they are so many if (atom in AA) and (atom != 'Fe3'): print atom plt.figure() grid = pn.EmisGrid(atomObj=AA[atom]) grid.plotContours(to_eval=diag_eval) if save: plt.savefig('{0}_{1}.pdf'.format(atom, diag_eval.replace('/', '_')))
def p2(diag): # get the ion, and diagnostic description from the dictionary: ion, diag_eval, err = pn.diags_dict[diag] # split ion into elem and spec, e.g 'O3' into 'O' and 3 elem, spec = parseAtom(ion) # prepare a new figure plt.figure() # create a grid of emissivities #NB: one can use a pypic file containing all the emissivities, if already made # in that case set restore_file to the name of the pypic file. grid = pn.EmisGrid(elem, spec, restore_file=None, OmegaInterp='Linear') # plot the contours grid.plotContours(to_eval=diag_eval, low_level=None, high_level=None, n_levels=20, linestyles='-', clabels=True, log_levels=True, title='{0} {1}'.format(ion, diag_eval)) # save the plot into pdf files plt.savefig('{0}_{1}.pdf'.format(ion, diag_eval.replace('/', '_')))
# EmisGrid example script # Shows how to produce, save, restore and plot emission maps import pyneb as pn import matplotlib.pyplot as plt plt.figure() O3map = pn.EmisGrid('O', 3, n_tem=30, n_den=30) # Instantiate an O III atom and computes the emissivity of all its lines in a 30x30 grid print "Plot the 4363/5007 ratio map with a 30x30 Ne-Te grid" O3map.plotImage(wave1=4363, wave2=5007) # Plot plt.figure() O3map = pn.EmisGrid('O', 3, n_tem=100, n_den=100) # Increase the grid resolution print "Increase the grid resolution to 100x100" O3map.plotImage(wave1=4363, wave2=5007) # Plot plt.figure() O3map = pn.EmisGrid('O', 3, n_tem=100, n_den=100, tem_max=1.5e4, den_max=1e5) # Change the axes limits print "Change the axes limits" O3map.plotImage(wave1=4363, wave2=5007) # Plot O3map.save('O3_1k.pypic') # Save for later use plt.figure() O3map = pn.EmisGrid(restore_file='O3_1k.pypic') # Recover the map from a previous computation print "Plot with a different color map" O3map.plotImage(wave1=4363, wave2=5007, cmap=plt.cm.bone) # Plot with a different color map plt.figure() print "Plot the 4363/88m line ratio" O3map.plotImage(wave1=4363, wave2=884000) # Plot a different line ratio
obs = pn.Observation('Fe3.dat', fileFormat='lines_in_rows', err_default=0.01, corrected=True) # Build an atom with default values from Quinet 1996, two kinds of interpolation pn.atomicData.setDataFile('fe_iii_atom_Q96_J00.dat') pn.atomicData.setDataFile('fe_iii_coll_Z96.dat') Fe3_Z = pn.Atom('Fe', 3) Fe3EM_Q_C = { 'Fe3': pn.EmisGrid(n_tem=100, n_den=100, tem_min=5000., tem_max=15000., den_min=100., den_max=1.e5, atomObj=Fe3_Z) } Fe3EM_Q_L = { 'Fe3': pn.EmisGrid(n_tem=100, n_den=100, tem_min=5000., tem_max=15000., den_min=100., den_max=1.e5, OmegaInterp='Linear', atomObj=Fe3_Z) }
# Sample script # Produces contour plots of OIII and SII line ratios # Two versions of the SII plot are produced with two different sets of collision strengths # A colormap and a plot of the ratio of the two SII determinations is also shown import numpy as np import matplotlib.pyplot as plt import pyneb as pn # Compute emission grids EM_O3 = pn.EmisGrid('O', 3, n_den=100, n_tem=100) EM_S2 = pn.EmisGrid('S', 2, n_den=100, n_tem=100) pn.atomicData.setDataFile('s_ii_coll_RBS96.dat') EM_S2_GR = pn.EmisGrid('S', 2, n_den=100, n_tem=100) pn.atomicData.resetDataFileDict() # Print populations a la ionic EM_O3.atom.printIonic() # Contour plots for OIII and the two versions of the SII ratios EM_O3.plotContours('L(4363)/L(4959)') plt.show() EM_S2.plotContours('L(6731)/L(6716)', linestyles='--', low_level= -0.3, high_level=0.15) plt.show() EM_S2_GR.plotContours('L(6731)/L(6716)', linestyles=':', low_level= -0.3, high_level=0.15) plt.show() # Image of the ratio between the two SII computations plt.imshow(EM_S2.getGrid(to_eval='L(6731) / L(6716)') / EM_S2_GR.getGrid(to_eval='L(6731) / L(6716)')) plt.colorbar()