def plot_2comp(tem1=1e4, tem2=1e4, dens1=3e2, dens2=5e5, mass1=1, mass2=5e-4): # List of diagnostics used to analyze the region diags = pn.Diagnostics() diags.addDiag([ '[NI] 5198/5200', '[NII] 5755/6548', '[OII] 3726/3729', '[OII] 3727+/7325+', '[OIII] 4363/5007', '[ArIII] 5192/7136', '[ArIII] 5192/7300+', '[ArIV] 4740/4711', '[ArIV] 7230+/4720+', '[SII] 6731/6716', '[SII] 4072+/6720+', '[SIII] 6312/9069', '[ClIII] 5538/5518' ]) """ for diag in pn.diags_dict: if diag[0:7] != '[FeIII]': diags.addDiag(diag) print('Adding', diag) diags.addClabel('[SIII] 6312/9069', '[SIII]A') diags.addClabel('[OIII] 4363/5007', '[OIII]A') """ # Define all the ions that are involved in the diagnostics adict = diags.atomDict pn.log_.message('Atoms built') obs = pn.Observation(corrected=True) for atom in adict: # Computes all the intensities of all the lines of all the ions considered for line in pn.LINE_LABEL_LIST[atom]: if line[-1] == 'm': wavelength = float(line[:-1]) * 1e4 else: wavelength = float(line[:-1]) elem, spec = parseAtom(atom) intens1 = adict[atom].getEmissivity( tem1, dens1, wave=wavelength) * dens1 * mass1 intens2 = adict[atom].getEmissivity( tem2, dens2, wave=wavelength) * dens2 * mass2 obs.addLine( pn.EmissionLine( elem, spec, wavelength, obsIntens=[intens1, intens2, intens1 + intens2], obsError=[0.0, 0.0, 0.0])) pn.log_.message('Virtual observations computed') emisgrids = pn.getEmisGridDict(atomDict=adict) pn.log_.message('EmisGrids available') # Produce a diagnostic plot for each of the two regions and another one for the # (misanalyzed) overall region f, axes = plt.subplots(2, 2) diags.plot(emisgrids, obs, i_obs=0, ax=axes[0, 0]) diags.plot(emisgrids, obs, i_obs=1, ax=axes[0, 1]) diags.plot(emisgrids, obs, i_obs=2, ax=axes[1, 0])
def p1(): # Set restore to True if the emission maps have already been generated, False otherwise ### General settings # Setting verbosity level. Enter pn.my_logging? for details pn.log_.level = 3 # Adopt an extinction law #extinction_law = 'CCM 89' # Define the data file obs_data = 'IC2165.dat' ### Read observational data # define an Observation object and assign it to name 'obs' obs = pn.Observation() # fill obs with data read from file obs_data, with lines varying across rows and a default percent error on line intensities obs.readData(obs_data, fileFormat='lines_in_rows', err_default=0.05, corrected=True) ### Include the diagnostics of interest # instantiate the Diagnostics class diags = pn.Diagnostics() # include in diags the relevant line ratios diags.getAllDiagLabels() diags.getAllDiags() diags.addDiag([ '[NI] 5198/5200', '[NII] 5755/6584', '[OI] 5579/6302', '[OII] 3726/3729', '[OII] 3727+/7325+', '[OIII] 4363/5007+', '[SII] 6731/6716', '[SII] 4072+/6720+', '[SIII] 6312/9069', '[ArIII] 5192/7136', '[ArIV] 4740/4711', '[ClIII] 5538/5518', ]) diags.addDiag('[ClIV] 5323/7531', ('Cl4', 'L(5323)/L(7531)', 'RMS([E(7531),E(5323)])')) # Create the emission maps to be compared to the observation data # To see the default parameters, do pn.getEmisGridDict? in ipython # The files go to ~/.pypics emisgrids = pn.getEmisGridDict(atomDict=diags.atomDict, den_max=1e6) ### Plot plt.figure(1) # Create the contour plot as the intersection of tem-den emission maps with dereddened line ratios diags.plot(emisgrids, obs) # Put the title plt.title('IC 2165 Optical diagnostics') # Display the plot plt.show() plt.savefig('IC2165-diag-opt.pdf')
def plot_2comp(tem1=1e4, tem2=1e4, dens1=3e2, dens2=5e5, mass1=1, mass2=5e-4): # List of diagnostics used to analyze the region diags = pn.Diagnostics() for diag in pn.diags_dict: if diag[0:7] != '[FeIII]': diags.addDiag(diag) diags.addClabel('[SIII] 6312/9069', '[SIII]A') diags.addClabel('[OIII] 4363/5007', '[OIII]A') # Define all the ions that are involved in the diagnostics all_atoms = diags.atomDict pn.log_.message('Atoms built') obs = pn.Observation(corrected=True) for atom in all_atoms: # Computes all the intensities of all the lines of all the ions considered for wavelength in all_atoms[atom].lineList: elem, spec = parseAtom(atom) intens1 = all_atoms[atom].getEmissivity( tem1, dens1, wave=wavelength) * dens1 * mass1 intens2 = all_atoms[atom].getEmissivity( tem2, dens2, wave=wavelength) * dens2 * mass2 obs.addLine( pn.EmissionLine( elem, spec, wavelength, obsIntens=[intens1, intens2, intens1 + intens2], obsError=[0.0, 0.0, 0.0])) pn.log_.message('Virtual observations computed') emisgrids = pn.getEmisGridDict(atomDict=all_atoms) pn.log_.message('EmisGrids available') # Produce a diagnostic plot for each of the two regions and another one for the (misanalyzed) overall region plt.subplot(2, 2, 1) diags.plot(emisgrids, obs, i_obs=0) plt.subplot(2, 2, 2) diags.plot(emisgrids, obs, i_obs=1) plt.subplot(2, 1, 2) pn.log_.level = 3 diags.plot(emisgrids, obs, i_obs=2)
# ionic abundance (intensity, temperature, density, transition) O2.getIonAbundance(100, 1.5e4, 100., wave=3727) # printout as in old nebular O2.printIonic( ) # only prints transitions and corresponding wavelengths. Useful for a quick glance at the atom. O2.printIonic(tem=10000, den=100) # also prints line emissivities O2.printIonic(tem=10000, den=100, printA=True, printPop=True, printCrit=True) # also prints populations and critical densities # Compute Hb emissivity at T=10000K pn.getRecEmissivity(10000, 1e2, 4, 2, atom='H1') # simultaneously compute temperature and density from pairs of line ratios # First of all, a Diagnostics object must be created and initialized with the relevant diagnostics. diags = pn.Diagnostics() # this creates the object diags.getAllDiags() # see what Diagnostics exist tem, den = diags.getCrossTemDen('[NII] 5755/6548', '[SII] 6731/6716', 50, 1.0, guess_tem=10000, tol_tem=1., tol_den=1., max_iter=5) #TO BE CONTINUED FROM HERE print(tem, den) ####################################################################### # HANDLING OBSERVATIONS
import os ### General settings # Setting verbosity level. Enter pn.log_? for details pn.log_.level = 2 # Set to True if the emission maps have already been generated restore = True # Adopt IRAF atomic data set pn.atomicData.setDataFileDict('IRAF_09') # Define where emission maps are to be stored (restore = False) or read from (restore = True) pypic_path = './pypics/' # Adopt an extinction law extinction_law = 'CCM 89' # Instantiate the Diagnostics class diags = pn.Diagnostics() # Include in diags the relevant line ratios diags.addDiag([ '[NI] 5198/5200', '[NII] 5755/6548', '[OIII] 4363/5007', '[ArIII] 5192/7136', '[ArIII] 5192/7300+', '[ArIV] 4740/4711', '[ArIV] 7230+/4720+', '[SII] 6731/6716', '[NeIII] 15.6m/36.0m', '[NeV] 14.3m/24.2m' ]) # Create the emission maps to be compared to the observation data (some overkill here) emisgrids = pn.getEmisGridDict(atom_list=diags.getUniqueAtoms(), den_max=1e6, pypic_path=pypic_path)
def p3(restore=True, fignum=3, pypic_path=pn.config.pypic_path): # --- pregunta 3 Adding IR lines------------------------------- # Define where emission maps are to be stored (restore = False) or read from (restore = True) # Create the directory before running this program obs_data = 'IC2165_IR.dat' obs = pn.Observation() # fill obs with data read from file obs_data, with lines varying across rows and a default percent error on line intensities obs.readData(obs_data, fileFormat='lines_in_rows', err_default=0.05, corrected=True) temp = 14000 dens = 10**3.5 # Compute theoretical H5-4/Hbeta ratio from Hummer and Storey IR2Opt_theo = pn.getRecEmissivity(temp, dens, 5, 4) / pn.getRecEmissivity( temp, dens, 4, 2) IR2Opt_obs = obs.getLine(label='H1_4.1m').corrIntens / obs.getLine( label='H1_4861A').corrIntens for line in obs.lines: if line.label[-1] == 'm': line.corrIntens *= IR2Opt_theo / IR2Opt_obs diags = pn.Diagnostics() diags.addDiag([ '[NI] 5198/5200', '[NII] 5755/6584', '[OI] 5579/6302', '[OII] 3726/3729', '[OII] 3727+/7325+', '[OIII] 4363/5007', '[SII] 6731/6716', '[SII] 4072+/6720+', '[SIII] 6312/9069', '[ArIII] 5192/7136', '[ArIV] 4740/4711', '[ClIII] 5538/5518', '[CIII] 1909/1907', '[OIII] 1666/5007', '[NeV] 1575/3426', '[OIII] 51m/88m', '[NeIII] 15.6m/36.0m', '[NeV] 14.3m/24.2m', '[SIII] 18.7m/33.6m', '[NeIII] 3869/15.6m', '[OIII] 5007/88m', '[ArIII] 7136/9m', '[SIII] 6312/18.7m', ]) diags.addDiag('[ClIV] 5323/7531', ('Cl4', 'L(5323)/L(7531)', 'RMS([E(7531),E(5323)])')) # Create the emission maps to be compared to the observation data # To see the default parameters, do pn.getEmisGridDict? in ipython emisgrids = pn.getEmisGridDict(atomDict=diags.atomDict, den_max=1e6, pypic_path=pypic_path) ### Plot plt.figure(fignum) # Create the contour plot as the intersection of tem-den emission maps with dereddened line ratios diags.plot(emisgrids, obs) # Put the title plt.title('IC 2165 Optical + UV + IR diagnostics') # Display the plot plt.show() plt.savefig('IC6165-diag-opt+UV+IR.pdf')
def p1(obs, do_plot=True): # Change the atomic data: pn.atomicData.setDataFile('s_iii_coll_TG99.fits') pn.atomicData.setDataFile('s_iii_atom_MZ82b-HSC95-LL93.fits') #Instanciate the Diagnostic object diags = pn.Diagnostics() # We will use the following diagnostics diags.addDiag([ '[NII] 5755/6584', #'[OII] 3727+/7325+', '[OIII] 4363/5007', '[SII] 6731/6716', '[SIII] 6312/9069', # '[SII] 4072+/6720+', ]) # we can choose to do the diagnostic plots of the whole set of observations if do_plot: emisgrids = pn.getEmisGridDict(atomDict=diags.atomDict, restore=False, save=False, n_tem=150, n_den=150, tem_min=5000., tem_max=20000., den_min=10., den_max=1e5) plt.figure(figsize=(30, 30)) for i, obs_name in enumerate(obs.names): plt.subplot(6, 5, i + 1) diags.plot(emisgrids, obs, i_obs=i) plt.title(obs_name) plt.savefig('diags.pdf') plt.close() # Determination of Te and Ne by intersection of 2 diagnostics: pn.log_.level = 3 temp_O3, dens_S2a = diags.getCrossTemDen('[OIII] 4363/5007', '[SII] 6731/6716', obs=obs) temp_S3, dens_S2b = diags.getCrossTemDen('[SIII] 6312/9069', '[SII] 6731/6716', obs=obs) temp_N2, dens_S2c = diags.getCrossTemDen('[NII] 5755/6584', '[SII] 6731/6716', obs=obs) # temp_S2, dens_S2d = diags.getCrossTemDen('[SII] 4072+/6720+', '[SII] 6731/6716', obs=obs) pn.log_.level = 1 #In the cases the density is not defined, we choose to set it to 10 and compute new Te tt = np.isnan(dens_S2a) dens_S2a[tt] = 10. O3 = pn.Atom('O', 3) temp_O3[tt] = O3.getTemDen((obs.getLine(label='O3_4363A').corrIntens / obs.getLine(label='O3_5007A').corrIntens)[tt], den=10, wave1=4363, wave2=5007) tt = np.isnan(dens_S2b) dens_S2b[tt] = 10. S3 = pn.Atom('S', 3) temp_S3[tt] = S3.getTemDen((obs.getLine(label='S3_6312A').corrIntens / obs.getLine(label='S3_9069A').corrIntens)[tt], den=10, wave1=6312, wave2=9069) tt = np.isnan(dens_S2c) dens_S2c[tt] = 10. N2 = pn.Atom('N', 2) temp_N2[tt] = N2.getTemDen((obs.getLine(label='N2_5755A').corrIntens / obs.getLine(label='N2_6583A').corrIntens)[tt], den=10, wave1=5755, wave2=6583) # Here we adopt an average value of the density mean_dens = (dens_S2a + dens_S2b + dens_S2c) / 3 O2 = pn.Atom('O', 2) temp_O2 = O2.getTemDen( (obs.getLine(label='O2_3727A+').corrIntens / obs.getLine(label='O2_7325A+').corrIntens), den=mean_dens, to_eval='(L(3726)+L(3729))/(I(4,2)+I(5,2)+I(4,3)+I(5,3))') S2 = pn.Atom('S', 2) temp_S2 = S2.getTemDen((obs.getLine(label='S2_4072A+').corrIntens / obs.getLine(label='S2_6716A').corrIntens), den=mean_dens, to_eval='(L(4076)+L(4069))/L(6716)') return mean_dens, temp_O2, temp_S2, temp_N2, temp_O3, temp_S3