Beispiel #1
0
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])
Beispiel #2
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')
Beispiel #3
0
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)
Beispiel #4
0
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)


# Object to be analyzed (could be a list with more than one element)
ngc_list = ['ngc650_R1']

# Loops over items in list (only one in this example)
for ngc in ngc_list:
	
	# Define the data file
	obs_data = ngc +'.dat'
	# Define title
	title = ngc.upper()
	 
	### Read and deredden observational data
Beispiel #5
0
    )
    diags.addClabel(
        '[NII] 5755/6584+',
        r'$T_{e}\left[NII\right]\left(\frac{\lambda6548\AA+\lambda6584\AA}{\lambda5577\AA}\right)$'
    )
    diags.addClabel(
        '[OIII] 4363/5007+',
        r'$T_{e}\left[OIII\right]\left(\frac{\lambda4959\AA+\lambda5007\AA}{\lambda4363\AA}\right)$'
    )
    diags.addClabel(
        '[SII] 4072+/6720+',
        r'$T_{e}\left[SII\right]\left(\frac{\lambda4069\AA+\lambda4076\AA}{\lambda6716\AA+\lambda6731\AA}\right)$'
    )

    #Generate the observation grid
    emisgrids = pn.getEmisGridDict(atomDict=diags.atomDict)

    #Generate a figure for the plot
    Fig1 = plt.figure(figsize=(16, 16))
    Fig1.set_dpi(600)
    Axis1 = Fig1.add_subplot(111)

    #Load emissivity grid
    diags.plot(emisgrids, obs, i_obs=0, ax=Axis1)

    #Load Change the format of the plot
    Adjust_Pyneb_DiagsPlot_format(CodeName, Fig1, Axis1)

    #Save the figure
    plt.savefig(FileFolder + CodeName + '_pyneb_diagnostics.png',
                bbox_inches='tight',
                Te_list.append(Te)
                ne_list.append(math.log10(Ne))
                PairTitle = "WHTDiag_" + Density_Diags[i].replace(" ","_") + "_" + Temperature_Diags[j].replace(" ", "_")
                PairMagnitude = "Te_"+str(Te)+"_ne_"+str(Ne)
                astro.Parameter_2_Log(FolderName, CodeName, PairTitle, PairMagnitude)
    
    #print "Physical properties derived", PhysicalProperties
    
    for diag in myDiagnostics:
        OldName = diag
        NewName = diag.replace(" ","_")
        Diags.addClabel(OldName,NewName)
    
    DiagnosticsString = ",".join(myDiagnostics).replace(" ", "_")
    astro.Parameter_2_Log(FolderName, CodeName, "WHT_PyNeb_Diagnostics", DiagnosticsString)
    Emisgrids = pn.getEmisGridDict(atomDict=Diags.atomDict, pypic_path = FolderName + 'PyNeb')

#3) Diagnostics diagram:

    font = {'family' : 'ubuntu','size' : 22}
    rc('font', **font)

    Fig1=plt.figure(figsize=(20,20))
        
    for i, obs_name in enumerate(Obs.names):
        Diags.plot(Emisgrids, Obs, i_obs=i)
        plt.title("Object " + CodeName)
        
    Fig1.set_dpi(600)
    Axis1 = Fig1.add_subplot(111)
    Axis1.plot(ne_list,Te_list,'o',color="red")
Beispiel #7
0
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')
        r"$T_{e}\left[SIII\right]\left(\frac{\lambda9069\AA+\lambda9531\AA}{\lambda6312\AA}\right)$",
    )
    diags.addClabel(
        "[NII] 5755/6584+", r"$T_{e}\left[NII\right]\left(\frac{\lambda6548\AA+\lambda6584\AA}{\lambda5577\AA}\right)$"
    )
    diags.addClabel(
        "[OIII] 4363/5007+",
        r"$T_{e}\left[OIII\right]\left(\frac{\lambda4959\AA+\lambda5007\AA}{\lambda4363\AA}\right)$",
    )
    diags.addClabel(
        "[SII] 4072+/6720+",
        r"$T_{e}\left[SII\right]\left(\frac{\lambda4069\AA+\lambda4076\AA}{\lambda6716\AA+\lambda6731\AA}\right)$",
    )

    # Generate the observation grid
    emisgrids = pn.getEmisGridDict(atomDict=diags.atomDict)

    # Generate a figure for the plot
    Fig1 = plt.figure(figsize=(16, 16))
    Fig1.set_dpi(600)
    Axis1 = Fig1.add_subplot(111)

    # Load emissivity grid
    diags.plot(emisgrids, obs, i_obs=0, ax=Axis1)

    # Load Change the format of the plot
    Adjust_Pyneb_DiagsPlot_format(CodeName, Fig1, Axis1)

    # Save the figure
    plt.savefig(FileFolder + CodeName + "_pyneb_diagnostics.png", bbox_inches="tight", pad_inches=0.1)
Beispiel #9
0
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
Beispiel #10
0
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)


# Object to be analyzed (could be a list with more than one element)
ngc_list = ['ngc650_R1']

# Loops over items in list (only one in this example)
for ngc in ngc_list:
    
    # Define the data file
    obs_data ="/home/vital/Desktop/Astrophysics/Tools/PyNeb/sample_scripts/" + ngc +'.dat'
    # Define title
    title = ngc.upper()
     
    ### Read and deredden observational data