flux_star = flux_star[0][0]

                star_dict[objects[i] + "_wave"], star_dict[objects[i] + "_flux"] = wave_star, flux_star
                star_dict[objects[i] + "_idx_join"] = idx_join_region

                dz.data_plot(wave_star, flux_star, label=objects[i], graph_axis=dz.ax2)

            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"]
Пример #2
0
             flux_star = flux_star[0][0]
             
         star_dict[objects[i]+'_wave'], star_dict[objects[i]+'_flux'] = wave_star, flux_star
         star_dict[objects[i]+'_idx_join'] = idx_join_region
                      
         dz.data_plot(wave_star, flux_star, label='Standard star Feige 34', color=colorVector['green'], graph_axis=dz.ax2)
       
     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']
Пример #3
0
    lick_idcs_df = pd.read_csv(
        ouput_folder + objName + lickIndcs_extension,
        delim_whitespace=True,
        header=0,
        index_col=0,
        comment='L')  #Dirty trick to avoid the Line_label row

    #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)
for i in range(len(catalogue_df.index)):

    #Object
    objName = catalogue_df.iloc[i].name
    fits_file = catalogue_df.iloc[i].reduction_fits
    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,
        print '\n-- Treating {} @ {}'.format(objName, fits_file), i, '/', n_objects
    
        #Spectrum data
        wave, flux, header_0 = dz.get_spectra_data(fits_file)
                
        lick_idcs_df = pd.read_csv(ouput_folder + objName + lickIndcs_extension, delim_whitespace = True, header = 0, index_col = 0, comment='L') #Dirty trick to avoid the Line_label row
     
        #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)
for i in range(len(catalogue_df.index)):

    #Object
    objName = catalogue_df.iloc[i].name
    fits_file = catalogue_df.iloc[i].reduction_fits
    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(
        4363.21, wave, flux)

    #Establish current line
    dz.Current_Label = 'O2_7319A'
    dz.Current_Ion = 'O2'
    dz.Current_TheoLoc = 4363.21
    selections = array([4349.10, 4356.77, 4360.31, 4367.7, 4394.3, 4413.6])

    #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')
    dz.data_plot(line_data['x_resample'],
                 line_data['y_resample'],
#Loop through the objects
for i in range(len(catalogue_df.index)):

    #Object
    objName         = catalogue_df.iloc[i].name
    fits_file       = catalogue_df.iloc[i].reduction_fits
    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)