obj_red_region = array(range(idx_obj_join, idx_obj_join + len_red_region))
            mean_flux = mean(flux_obs)

            # Loop through the diagnostic lines
            obj_dict = {}
            for line in lines_interest:
                if line in lick_idcs_df.index:

                    dz.Current_Label = lick_idcs_df.loc[line].name
                    dz.Current_Ion = lick_idcs_df.loc[line].Ion
                    dz.Current_TheoLoc = redshift_factor * lick_idcs_df.loc[line].TheoWavelength
                    selections = redshift_factor * lick_idcs_df.loc[line][3:9].values

                    # Measure the line intensity
                    line_fit_orig = dz.measure_line(wave_obs, flux_obs, selections, None, "lmfit", store_data=False)

                    # Area to plot
                    subwave, subflux, lineHeight, LineExpLoc = Emission_Threshold(
                        dz.Current_TheoLoc, wave_obs, flux_obs
                    )
                    obj_dict[line + "_x_reduc"] = line_fit_orig["x_resample"]
                    obj_dict[line + "_y_reduc"] = line_fit_orig["y_resample"]
                    obj_dict[line + "_flux_reduc"] = line_fit_orig["flux_intg"]
                    obj_dict[line + "_fluxEr_reduc"] = line_fit_orig["flux_intg_er"]
                    obj_dict[line + "_Peak"] = line_fit_orig["A0"]
                    obj_dict[line + "_continuum"] = line_fit_orig["zerolev_mean"]
                    obj_dict[line + "_Emis_reduc"] = ufloat(line_fit_orig["flux_intg"], line_fit_orig["flux_intg_er"])

            # Measure the lines after the telluric correction for each case
            for star in objects:
Пример #2
0
       
     obj_red_region = array(range(idx_obj_join,idx_obj_join + len_red_region))
     mean_flux = mean(flux_obs)
 
     #Loop through the diagnostic lines   
     obj_dict = {}
     for line in lines_interest:
         if line in lick_idcs_df.index:
 
             dz.Current_Label    = lick_idcs_df.loc[line].name
             dz.Current_Ion      = lick_idcs_df.loc[line].Ion
             dz.Current_TheoLoc  = redshift_factor * lick_idcs_df.loc[line].lambda_theo
             selections          = redshift_factor * lick_idcs_df.loc[line][3:9].values
                  
             #Measure the line intensity
             line_fit_orig = dz.measure_line(wave_obs, flux_obs, selections, None, 'lmfit', store_data = False)
                  
             #Area to plot
             subwave, subflux, lineHeight, LineExpLoc = Emission_Threshold(dz.Current_TheoLoc, wave_obs, flux_obs)    
             obj_dict[line + '_x_reduc']        = line_fit_orig['x_resample']
             obj_dict[line + '_y_reduc']        = line_fit_orig['y_resample']
             obj_dict[line + '_flux_reduc']     = line_fit_orig['flux_intg']
             obj_dict[line + '_fluxEr_reduc']   = line_fit_orig['flux_intg_er']
             obj_dict[line + '_Peak']           = line_fit_orig['A0']
             obj_dict[line + '_continuum']      = line_fit_orig['zerolev_mean']
             obj_dict[line + '_Emis_reduc']     = ufloat(line_fit_orig['flux_intg'], line_fit_orig['flux_intg_er'])
 
     #Measure the lines after the telluric correction for each case 
     for star in objects:
         star_red_region = array(range(star_dict['{}_idx_join'.format(star)], star_dict['{}_idx_join'.format(star)] + len_red_region))
         wave_tell, flux_tell = wave_obs, flux_obs / star_dict[star + '_flux']
Пример #3
0
    #Start to loop through recorded line
    for i in range(len(lick_idcs_df.index)):

        try:

            print '-- Treating line:', lick_idcs_df.iloc[i].name

            #Establish current line
            dz.Current_Label = lick_idcs_df.iloc[i].name
            dz.Current_Ion = lick_idcs_df.iloc[i].Ion
            dz.Current_TheoLoc = lick_idcs_df.iloc[i].lambda_theo
            selections = lick_idcs_df.iloc[i][3:9].values

            #Proceed to measure
            line_data = dz.measure_line(wave,
                                        flux,
                                        selections,
                                        lineslog_df,
                                        Measuring_Method='MC_lmfit',
                                        store_data=True)

        except:
            dz.log_emLine_error(objName, dz.Current_Label)

    dz.save_lineslog_dataframe(lineslog_df, lines_log_address)
    print '-', lines_log_address, 'saving'

print "\nAll data treated", dz.display_errors('emLine measurement',
                                              extra_verbose=True)
    #Spectrum data
    wave, flux, header_0 = dz.get_spectra_data(fits_file)
    subwave, subflux, lineHeight, LineExpLoc = Emission_Threshold(
        6548.0, wave, flux)

    #Establish current line
    dz.Current_Label = 'N2_6548A'
    dz.Current_Ion = 'N2'
    dz.Current_TheoLoc = 6548.050
    selections = array(
        [6497.701, 6522.331, 6537.998, 6591.29, 6592.324, 6610.83])

    #Proceed to measure
    line_data = dz.measure_line(wave,
                                flux,
                                selections,
                                lines_dataframe=None,
                                store_data=False)

    #Plot Global component
    dz.data_plot(subwave,
                 subflux,
                 label='Spectrum',
                 linestyle='step',
                 color=dz.colorVector['silver'])
    dz.data_plot(line_data['x_resample'],
                 line_data['y_resample'],
                 'Gaussian mixture',
                 linewidth=2.0,
                 color=dz.colorVector['yellow'])
     
        #Start to loop through recorded line 
        for i in range(len(lick_idcs_df.index)):
             
            try:
                
                print '-- Treating line:', lick_idcs_df.iloc[i].name  
                          
                #Establish current line
                dz.Current_Label    = lick_idcs_df.iloc[i].name
                dz.Current_Ion      = lick_idcs_df.iloc[i].Ion
                dz.Current_TheoLoc  = lick_idcs_df.iloc[i].lambda_theo
                selections = lick_idcs_df.iloc[i][3:9].values
                
                #Proceed to measure
                line_data = dz.measure_line(wave, flux, selections, lineslog_df, Measuring_Method = 'MC_lmfit', store_data = True)
                
            except:
                dz.log_emLine_error(objName, dz.Current_Label)
                
            
        dz.save_lineslog_dataframe(lineslog_df, lines_log_address)
        print '-', lines_log_address, 'saving'
                                                                 
print "\nAll data treated", dz.display_errors('emLine measurement', extra_verbose=True)





#Declare line to measure
line = 'N2_6548A'

#Establish current line
dz.Current_Label = lick_idcs_df.loc[line].name
dz.Current_Ion = lick_idcs_df.loc[line].Ion
dz.Current_TheoLoc = lick_idcs_df.loc[line].lambda_theo
selections = lick_idcs_df.loc[line][3:9].values

#Proceed to measure

# print '--Single fit'
# start = timer()
line_data = dz.measure_line(wave,
                            flux,
                            selections,
                            None,
                            Measuring_Method='lmfit',
                            store_data=False)
# end = timer()
# print 'lmfit', (end - start)

#Plot features
dz.Axis.plot(line_data.x_resample, line_data.y_resample, linestyle='--')
dz.Axis.step(wave[dz.fit_dict.idx0 - 5:dz.fit_dict.idx5 + 5],
             flux[dz.fit_dict.idx0 - 5:dz.fit_dict.idx5 + 5],
             label='Line: {}'.format(line),
             where='mid')
dz.Axis.fill_between(wave[dz.fit_dict.idx0:dz.fit_dict.idx1],
                     dz.fit_dict.zerolev_mean,
                     flux[dz.fit_dict.idx0:dz.fit_dict.idx1],
                     facecolor=dz.colorVector['green'],
    ouput_folder    = '{}{}/'.format(catalogue_dict['Obj_Folder'], objName) 

    print '-- Treating {} @ {}'.format(objName, fits_file)
      
    #Spectrum data
    wave, flux, header_0 = dz.get_spectra_data(fits_file)
    subwave, subflux, lineHeight, LineExpLoc = Emission_Threshold(6548.0, wave, flux)
    
    #Establish current line
    dz.Current_Label    = 'N2_6548A'
    dz.Current_Ion      = 'N2'
    dz.Current_TheoLoc  = 6548.050
    selections          = array([6497.701, 6522.331, 6537.998, 6591.29, 6592.324, 6610.83])
    
    #Proceed to measure
    line_data = dz.measure_line(wave, flux, selections, lines_dataframe=None, store_data = False)
    
    #Plot Global component
    dz.data_plot(subwave, subflux, label='Spectrum', linestyle='step', color = dz.colorVector['silver'])
    dz.data_plot(line_data['x_resample'], line_data['y_resample'], 'Gaussian mixture', linewidth=2.0, color = dz.colorVector['yellow'])
    
    #Plot individual components
    for i in range(line_data['line_number']):
        dz.data_plot(line_data['x_resample'], line_data['y_comps'][i], 'Components', linestyle = '--', color=dz.colorVector['orangish'], linewidth=1.0)
    
    #Plot peaks
    #dz.data_plot(line_data['peak_waves'], line_data['peak_Maxima'], 'Input values', markerstyle='o', color = dz.colorVector['pink'])

    dz.Axis.set_xlim([subwave[0],subwave[-1]])
    dz.Axis.set_ylim(median(subflux)/10, lineHeight*2)
    dz.FigWording(r'Wavelength $(\AA)$', 'Flux' + r'$(erg\,cm^{-2} s^{-1} \AA^{-1})$', r'Object {} $H\alpha$ wide component'.format(objName))