#Define the maximum sigma for the fitting from the Hbeta line Sigma = ImportDispersionVelocity(lineslog_frame) UpperDispersionVelocity_Limit = str(round(Sigma, 1)) + ' [vd_upp (km/s)] = upper allowed vd\n' dz.replace_line(GridFileAddress, 21, UpperDispersionVelocity_Limit) #Launch starlight print '--Initiating starlight for ', fits_name, Sigma #dz.Starlight_Launcher(Grid_FileName, dz.RootFolder) print '--Starlight finished succesfully ended:', Sl_OutputFile #Get stellar spectrum from starlight file Input_Wavelength, Input_Flux, Output_Flux, MaskPixels, ClippedPixels, FlagPixels, Parameters = dz.File_to_data(Sl_OutputFolder, Sl_OutputFile) #Export data to fits file stellar_cont_fits = objName + '_StellarContinuum.fits' Flux_stellar_redd = dz.reddening_continuum(Input_Wavelength, Output_Flux, cHbeta.nominal_value) dz.Data_2_Fits(ouput_folder, stellar_cont_fits, header_0, Input_Wavelength, Flux_stellar_redd, NewKeyWord = ['STALIGHT', 'Basic Treatment']) #Plot the data dz.data_plot(Input_Wavelength, Input_Flux, "Input Spectra") dz.data_plot(Input_Wavelength, Output_Flux, "Stellar absorption") dz.data_plot(Input_Wavelength, Flux_stellar_redd, "Stellar absorption redened") #Set titles and legend PlotTitle = 'Object ' + objName + ' emission and stellar and spectra' dz.FigWording(r'Wavelength $(\AA)$', 'Flux' + r'$(erg\,cm^{-2} s^{-1} \AA^{-1})$', PlotTitle) mean_flux = Input_Flux.mean() dz.Axis.set_ylim(-0.05*mean_flux, 15*mean_flux) dz.Axis.set_xlim(3500, 5250)
Halpha_Flux = lineslog_frame.loc['H1_6563A', 'line_Int'] print '--Using physical parameters', Te, nHeII_HII, nHeIII_HII, Hbeta_Flux, Halpha_Flux #-- Calculate nebular continuum nebCalc.PropertiesfromUser(Te, Hbeta_Flux.nominal_value, nHeII_HII, nHeIII_HII, wave, Calibration = 'Zanstra') #-- Calculate continuous emissino coefficients: Gamma_Total, Gamma_lambda, Gamma_FB_HI, Gamma_FB_HeI, Gamma_FB_HeII, Gamma_2q, Gamma_FF = nebCalc.Calculate_Nebular_gamma() #-- Caculate nebular flux with different calibration methods NebularInt_Hbeta = nebCalc.Zanstra_Calibration('Hbeta', Hbeta_Flux.nominal_value, Gamma_Total) #Removing nebular component Int_dedNeb = spectrum_dered - NebularInt_Hbeta Flux_deNeb = dz.reddening_continuum(wave, Int_dedNeb, cHbeta.nominal_value) nebularFlux_cont = dz.derreddening_continuum(wave, NebularInt_Hbeta, cHbeta.nominal_value) #Plotting the data dz.data_plot(wave, flux, 'Reduced spectrum') dz.data_plot(wave, Flux_deNeb, 'Removed Nebular continuum') dz.data_plot(wave, nebularFlux_cont, 'Nebular flux') #Format the graphs PlotTitle = r'Object {} Nebular continuum substraction'.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)