# Format the graphs plotTitle = r"Object {} Nebular continuum calculation".format(objName) dz.FigWording(r"Wavelength $(\AA)$", "Flux" + r"$(erg\,cm^{-2} s^{-1} \AA^{-1})$", plotTitle) mean_flux = spectrum_dered.mean() dz.Axis.set_ylim(-0.05 * mean_flux, 15 * mean_flux) dz.Axis.set_xlim(3500, 5250) output_pickle = "{objFolder}{stepCode}_{objCode}_{ext}".format( objFolder=ouput_folder, stepCode=dz.ScriptCode, objCode=objName, ext="NebularContinuum_Comparison" ) dz.save_manager(output_pickle, save_pickle=True) except: dz.log_error(objName) print "All data treated", dz.display_errors() # from dazer_methods import Dazer # from libraries.Astro_Libraries.Nebular_Continuum import NebularContinuumCalculator # # def nebular_continua_calculation_plots(): # # #Plotting the data # dz.data_plot(Wave, Int, 'Reduced spectrum', dz.ColorVector[2][0]) # dz.data_plot(NebWave, NebularInt_Hbeta, 'Nebular continuum - Hbeta calibration', dz.ColorVector[2][1]) # dz.data_plot(NebWave, NebularInt_Halpha, 'Nebular continuum - Halfa calibration', dz.ColorVector[2][2]) # dz.data_plot(x_trendline, y_trendline, 'Balmer jump regression', dz.ColorVector[2][3], linestyle='--') # # #Format the graphs # PlotTitle = r'Object '+ CodeName + ' Nebular continuum calculation' # dz.FigWording(r'Wavelength $(\AA)$', 'Flux' + r'$(erg\,cm^{-2} s^{-1} \AA^{-1})$', PlotTitle)
# Annotate the 2nd position with another image (a Grace Hopper portrait) fn = get_sample_data('/home/vital/Dropbox/Astrophysics/Papers/Yp_AlternativeMethods/extra_files/{}.png'.format(quick_reference), asfileobj=False) arr_img = plt.imread(fn, format='png') imagebox = OffsetImage(arr_img, **global_offset) imagebox.image.axes = ax ab = AnnotationBbox(imagebox, **annotationBbox) ax.add_artist(ab) ax.update({'xlabel':r'Wavelength $(\AA)$', 'ylabel':'Flux ' + r'$(10^{-15} erg\,cm^{-2} s^{-1} \AA^{-1})$'}) saving_location = '/home/vital/Dropbox/Astrophysics/Papers/Yp_AlternativeMethods/supplementary material online/{}.png'.format(quick_reference) plt.savefig(saving_location, dpi=150, bbox_inches='tight') plt.cla() #----------------------------------------------------------------------------------------------------- print 'All data treated', dz.display_errors() # # Loop through files # for i in range(len(catalogue_df.index)): # # print '-- Treating {}'.format(catalogue_df.iloc[i].name) # # if catalogue_df.iloc[i].name not in ['IZW18_A2', 'AGC198691', '6', '70', '4_n2', '3', '27', '71', '0564', # 'SHOC575_n1', 'SHOC593', 'J2225']: # # Locate the objects # codeName = catalogue_df.iloc[i].quick_index # objName = catalogue_df.iloc[i].name # # ouput_folder = '{}{}/'.format(catalogue_dict['Obj_Folder'], objName)
#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)
#Oxygen dz.oxygen_abundance_scheme(T_low, T_high, ne) #Nitrogen dz.nitrogen_abundance_scheme(T_low, ne) print '-Helium abundances' if 'neSII' in dz.abunData: dz.helium_abundance_elementalScheme(T_high, ne, lineslog_frame, metal_ext='O') dz.helium_abundance_elementalScheme(T_high, ne, lineslog_frame, metal_ext='S') #Store the abundances dz.store_abundances_excel(objName, catalogue_df, extension=extensioin_table[i]) dz.save_excel_DF( catalogue_df, '/home/vital/Dropbox/Astrophysics/Data/WHT_observations/WHT_Galaxies_properties.xlsx', df_sheet_format='catalogue_data') print '\nAll data treated\n', dz.display_errors()
print '-- Treating {}'.format(catalogue_df.iloc[i].name) try: #Locate the objects objName = catalogue_df.iloc[i].name ouput_folder = '{}{}/'.format(catalogue_dict['Obj_Folder'], objName) fits_file = catalogue_df.iloc[i].reduction_fits #Declare the ouput file from starlight Sl_OutputFile = objName + '_' + Catalogue_Dic['Datatype'] + ".slOutput" LogMass = Calculate_Total_Mass(objName, ouput_folder, Sl_OutputFolder + Sl_OutputFile, catalogue_df.iloc[i].z_Blue) #Converting starlight population output into a series of histograms Light_fraction = dz.CumulativeHistogram_One(Sl_OutputFolder, Sl_OutputFile, PlotType = 'Light_fraction', Color_Vector = list_colors) Mass_fraction = dz.CumulativeHistogram_One(Sl_OutputFolder, Sl_OutputFile, PlotType = 'Mass_fraction', Color_Vector = list_colors) #Generating light fraction histogram light_fraction_plot(Light_fraction, objName, ouput_folder, script_code) #Generating light fraction histogram mass_fraction_plot(Mass_fraction, objName, ouput_folder, dz.ScriptCode[0] + str(int(dz.ScriptCode[1]) + 1)) except: dz.log_error(objName) #----------------------------------------------------------------------------------------------------- print 'All data treated', dz.display_errors()
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)
print 'Oxygen abundance' dz.oxygen_abundance_scheme() print 'Nitrogen abundance' dz.nitrogen_abundance_scheme() print 'Helium abundance' dz.helium_abundance_scheme_Oxygen(lineslog_frame) dz.helium_abundance_scheme_Sulfur(lineslog_frame) #Store the abundances frame_address = catalogue_dict['Obj_Folder'].replace('objects/', 'catalogue_df') dz.store_abundances(objName, catalogue_df, frame_address) print '\nAll data treated\n', dz.display_errors() # from dazer_methods import Dazer # from numpy import isnan # # #Generate dazer object # dz = Dazer() # dz.load_elements() # # #Load catalogue dataframe # catalogue_dict = dz.import_catalogue() # catalogue_df = dz.load_dataframe(catalogue_dict['dataframe']) # # #Declare data for the analisis # AbundancesFileExtension = '_' + catalogue_dict['Datatype'] + '_LinesLog_MC.txt'