def regular_spectrum_graph(line): allspec = ('PHOENIX/%(allspec)s' %{'allspec' : line}) contspec = ('PHOENIXcont/%(cont)s' %{'cont' : cont_file[0]}) a = line.split('-') #Calls in the file from the directory spectrum = load_spec(allspec) conspec = load_spec(contspec) newgrid = np.arange(3000,12000,0.01) conspecflux = np.interp(newgrid, conspec[:,0], conspec[:,1]) specflux = np.interp(newgrid, spectrum[:,0], spectrum[:,1]) conspecflux = convolve(conspecflux, 0.15) specflux = convolve(specflux, 0.15) divflux = specflux/conspecflux plt.title('Spectrum Comparison For nlte and lte Effects \n On a T_eff = 4500K Star \n Smoothed by convolution with gaussian curve FWHM = 0.15 Angstroms'.format(a[1])) plt.xlabel('Wavelength (Angstroms)') plt.ylabel('Normalized Flux $(Flux/1.2*10^{14})$') plt.grid(True) #plt.plot(spectrum[:,0], spectrum[:,1]) plt.plot(newgrid, divflux) # ,label = '%(type)s, $[Fe/H]$ = -%(metal)s' %{ 'type' :a[0], 'metal' :a[3][0:3]})
def Relative_spec(nltespec, ltespec): ''' FUNCTION CURRENTLY DOES NOT WORK PROPERLY!!! THIS IS AN ARTIFACT OF ME CREATING THE .norm.7 FILES TO INCREASE PROGRAM SPEED. ''' model = array(Spec_Normalize(nltespec, ltespec)).T a = nltespec.split('-') #b = ltespec.split('-') #Modelspecfile = ('PHOENIX/%(allspec)s' %{'allspec' : model}) Arcturusspec = ltespec specgrid = np.arange(3000, 12000, 0.01) ModelSpec = model Arcturus = Arcturusspec ModelSpecFlux = np.interp(specgrid, ModelSpec[:, 0], ModelSpec[:, 1]) ArcturusFlux = np.interp(specgrid, Arcturus[:, 0], Arcturus[:, 1]) print 'Plotting {} model, Teff= {}K '.format( a[0], a[1]), '[Fe/H]= -{}'.format(a[3][0:3]), 'iter=', i ModelSpec2 = convolve(ModelSpecFlux, macroturb, 0.01) #Macroturbulence ModelSpec3 = convolve(ModelSpec2, 2, 0.01) #Spectrograph RelativeSpec = 100. * (ModelSpec3 - ArcturusFlux) / ArcturusFlux Unity = array((specgrid, RelativeSpec)).T Unity2 = Unity[(Unity[:, 0] <= 7300)] SpecSigma = np.std(Unity2[:, 1]) SpecMean = np.mean(Unity[:, 1]) print 'Spectrum Mean= ', SpecMean print 'Standard Deviation= ', SpecSigma plt.plot(Unity2[:, 0], Unity2[:, 1], label='[Teff] = {}K, model={}, cTeff= {}K'.format( a[1], a[0], b[1])) #plt.ylim(-100,1000) plt.xlim(linecentre - dx, linecentre + dx) plt.grid(True) plt.legend() plt.ylabel('$(F_{NLTE} - F_{OBS})/F_{OBS}$ (%)') plt.xlabel('Wavelength, ($\AA$)') plt.title( 'Relative Spectrum Differences \n Between Model and Observed Spectra for Arcturus \n ' ) return RelativeSpec
def Relative_spec(xmin, xmax, i): scales = [0.995,1.02,0.997,1.02,0.997,1.02] ModelSpec = array(Spec_Normalize(file_list[i],cont_file[i//2])).T Arcturus = arcturus_link() a = file_list[i].split('-') #Modelspecfile = ('PHOENIX/%(allspec)s' %{'allspec' : model}) specgrid = np.arange(xmin, xmax, 0.01) Arcturus = Arcturus[(Arcturus[:,0] >= xmin) & (Arcturus[:,0] <= xmax)] ModelSpec = ModelSpec[(ModelSpec[:,0] >= xmin) & (ModelSpec[:,0] <= xmax) ] ModelSpecFlux = np.interp(specgrid, ModelSpec[:,0], ModelSpec[:,1]) ArcturusFlux = np.interp(specgrid, Arcturus[:,0] , Arcturus[:,1]) ModelSpec2 = convolve(ModelSpecFlux, 6 , 0.01) RelativeSpec = 100.*(ModelSpec2/scales[i] - ArcturusFlux)/ArcturusFlux Unity = array((specgrid, RelativeSpec )).T #Unity = Unity[(Unity[:,1] <= 1000 ) & (Unity[:,1] >= -1000)] plt.plot(Unity[:,0], Unity[:,1], label = 'Type: {}, T = {}K'.format(a[0],a[1])) plt.ylim(-100,1000) plt.grid(True) plt.legend() plt.ylabel('Relative Flux') plt.xlabel('Wavelength, ($\AA$)')
def Relative_spec(nltespec, ltespec): model = array(Spec_Normalize(file_list[i], cont_file[i // 2])).T observed = ltespec a = file_list[i].split("-") b = cont_file[i // 2].split("-") # Modelspecfile = ('PHOENIX/%(allspec)s' %{'allspec' : model}) Arcturusspec = observed specgrid = np.arange(3000, 12000, 0.01) ModelSpec = model Arcturus = Arcturusspec ModelSpecFlux = np.interp(specgrid, ModelSpec[:, 0], ModelSpec[:, 1]) ArcturusFlux = np.interp(specgrid, Arcturus[:, 0], Arcturus[:, 1]) print "Plotting {} model, Teff= {}K ".format(a[0], a[1]), "[Fe/H]= -{}".format(a[3][0:3]), "iter=", i ModelSpec2 = convolve(ModelSpecFlux, macroturb, 0.01) # Macroturbulence ModelSpec3 = convolve(ModelSpec2, 2, 0.01) # Spectrograph RelativeSpec = 100.0 * (ModelSpec3 - ArcturusFlux) / ArcturusFlux Unity = array((specgrid, RelativeSpec)).T Unity2 = Unity[(Unity[:, 0] <= 7300)] SpecSigma = np.std(Unity2[:, 1]) SpecMean = np.mean(Unity[:, 1]) print "Spectrum Mean= ", SpecMean print "Standard Deviation= ", SpecSigma plt.plot(Unity2[:, 0], Unity2[:, 1], label="[Teff] = {}K, model={}, cTeff= {}K".format(a[1], a[0], b[1])) # plt.ylim(-100,1000) plt.xlim(linecentre - dx, linecentre + dx) plt.grid(True) plt.legend() plt.ylabel("$(F_{NLTE} - F_{OBS})/F_{OBS}$ (%)") plt.xlabel("Wavelength, ($\AA$)") plt.title("Relative Spectrum Differences \n Between Model and Observed Spectra for Arcturus \n ") return RelativeSpec
def regular_spectrum_graph(specfile,continuum): allspec = ('%(allspec)s' %{'allspec' : specfile}) contspec = ('%(cont)s' %{'cont' : continuum}) scalefactor = [0.995,1.02,0.997,1.02,0.997,1.02] a = specfile.split('-') #Calls in the file from the directory spectrum = load_spec(allspec,'PHOENIX') conspec = load_spec(contspec, 'PHOENIXcont') newgrid = np.arange(3000,12000,0.01) conspecflux = np.interp(newgrid, conspec[:,0], conspec[:,1]) specflux = np.interp(newgrid, spectrum[:,0], spectrum[:,1]) macroturb = 6 spectrograph = 2 conspecflux2 = convolve(conspecflux, macroturb,0.01) #Macroturbulence conspecflux3 = convolve(conspecflux2, spectrograph,0.01) #Spectrograph resolution specflux2 = convolve(specflux, FWHM,0.01) specflux3 = convolve(specflux2, FWHM2, 0.01) divflux = specflux3/conspecflux3 plt.title('Observed Arcturus Spectrum \n With 4250K Alpha enhanced model comparison \n Smoothed by convolution with gaussian curve FWHM = 5/150 Angstroms') plt.xlabel('Wavelength ($\AA$)') plt.ylabel('Normalized Flux (unitless)') plt.grid(True) plt.plot(newgrid, divflux/scalefactor[i], label = '%(type)s, $T_{eff}$ = %(metal)sK' %{ 'type' :a[0], 'metal' :a[1]}) plt.xlim(7149,7150.8) plt.legend()
def Spec_Graph(): allspec2 = ('PHOENIX/%(allspec)s' %{'allspec' : file_list[2*i]}) #nlte Spectrum allspec1 = ('PHOENIX/%(allspec)s' %{'allspec' : file_list[2*i +1]}) #lte Spectrum g = file_list[2*i].split('-') Spec1 = np.genfromtxt(allspec1, dtype ='str', usecols = (0,1)) DtoE(Spec1[:,0]) DtoE(Spec1[:,1]) Spec1 = np.array(Spec1, dtype = float) Spec2 = np.genfromtxt(allspec2, dtype = 'str', usecols = (0,1)) DtoE(Spec2[:,0]) DtoE(Spec2[:,1]) Spec2 = np.array(Spec2, dtype = float) Spec1[:,1] = Spec1[:,1][np.argsort(Spec1[:,0])] Spec1[:,0] = np.sort(Spec1[:,0]) Spec2[:,1] = Spec2[:,1][np.argsort(Spec2[:,0])] Spec2[:,0] = np.sort(Spec2[:,0]) Spec1[:,1] = 10**Spec1[:,1] Spec2[:,1] = 10**Spec2[:,1] newgrid = np.arange(3000,12000, 0.01) #Uniform grid space for each spectra NewSpec1 = np.interp(newgrid, Spec1[:,0], Spec1[:,1]) NewSpec2 = np.interp(newgrid, Spec2[:,0], Spec2[:,1]) ##### Fast Fourier Transform convolution function ##### FWHM = 0.15 smooth1 = convolve(NewSpec1,FWHM) smooth2 = convolve(NewSpec2,FWHM) RelativeSpectrum = ( (smooth1 - smooth2)/smooth2 ) * 100. #Relative fluxes as a percent SpecAvg = np.mean(RelativeSpectrum) SpecSigma = np.std(RelativeSpectrum) #top lines plt.hlines(SpecAvg + SpecSigma, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 1.0) plt.hlines(SpecAvg - SpecSigma, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 1.0) plt.hlines(SpecAvg, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 2.0) SmoothedSpec = np.array([newgrid, RelativeSpectrum], dtype= float) SmoothedSpec = SmoothedSpec.T SpecFeatures = list() for q in range(0,len(SmoothedSpec)): if (SmoothedSpec[q,1] >= SpecAvg + SpecSigma) or (SmoothedSpec[q,1] <= SpecAvg - SpecSigma): SpecFeatures.append([SmoothedSpec[q,0],SmoothedSpec[q,1]]) SpecFeatures = np.array(SpecFeatures, dtype=float) ##### This finds where the important lines are located on the convolved relative spectrum. nothing = [] # Temporary list that is not useful after plotting for m in range(0,len(Linelist)): a = Linelist['wavelength'][m] - 0.005 b = Linelist['wavelength'][m] + 0.005 linefile = SmoothedSpec[:,0] nothing = np.append(nothing, np.where((linefile >= a) & (linefile <= b))) ##### Array made from y-value at line wavelength on each spectrum. arrowlines = [] for n in range(0,len(nothing)): #arrowlines.append([Linelist['wavelength'][n], SmoothedSpec[nothing[n],1], Linelist['element'][n], Linelist['ion'][n]]) arrowlines.append([Linelist['wavelength'][n], SmoothedSpec[nothing[n],1]]) #arrowlines = np.array(arrowlines, dtype= ([('wavelength','f8'), ('percent','f8'), ('element','a2'), ('ion','a2') ])) arrowlines = np.array(arrowlines, dtype= float) arrowlines[:,1] = arrowlines[:,1][np.argsort(arrowlines[:,0])] arrowlines[:,0] = np.sort(arrowlines[:,0]) #plt.plot(arrowlines[:,0], arrowlines[:,1], c= colourstring[i], linewidth= 2.0, # label = ' Fe/H = -%(fehs)s ' %{'fehs' : g[3][0:3]} ) plt.scatter(arrowlines[:,0], arrowlines[:,1], c=colourstring[i]) if (g[3][0:3] == '0.5'): for r in range(len(Linelist)): #if (arrowlines[r,1] >= 10.): plt.annotate('%(element)s - %(ion)s, %(wave)s' %{ 'element' : Linelist['element'][r], 'ion' : Linelist['ion'][r], 'wave' : Linelist['wavelength'][r] } , xy=(Linelist['wavelength'][r], SmoothedSpec[nothing[r],1]), xytext=(Linelist['wavelength'][r], SmoothedSpec[nothing[r],1] + 3 ), arrowprops=dict(facecolor='black',arrowstyle ='->')) ''' for s in range(len(stronglines)): plt.annotate(atomlist[s] + ', {}'.format(stronglines[s,0]) , xy=(stronglines[s,0], 0), xytext=(stronglines[s,0],80), arrowprops=dict(facecolor='black', arrowstyle= '->')) ''' plt.title('Locations of the Important Spectral Lines and the Changes due to NLTE Effects' '\n $T_{eff}$ = %(teff)sK ' '\n %(fwhm)s$\AA$ Convolution' %{ 'teff' : g[1] , 'fwhm': FWHM}) plt.grid(True) plt.ylabel('$(F_{nlte} - F_{lte})/F_{lte}$ * 100%') plt.xlabel('Wavelength ($\AA$)') #Overplotting the locations of important spectral lines in the spectral range. #for j in range(len(Linelist)): # plt.annotate('%(element)s - %(ion)s' %{ 'element' : Linelist['element'][j], 'ion' : Linelist['ion'][j] } , # xy=(Linelist['wavelength'][j], -10), # xytext=(Linelist['wavelength'][j], 80), # arrowprops=dict(facecolor='red', headwidth = 0, linewidth = 0) # ) plt.fill_between(newgrid,y1=SpecAvg + SpecSigma, y2 = SpecAvg-SpecSigma,color = 'y') plt.plot(newgrid, RelativeSpectrum, c= colourstring[i], label = ' Fe/H = -%(fehs)s ' %{'fehs' : g[3][0:3]}, linewidth = 2.0) plt.scatter(SpecFeatures[:,0], SpecFeatures[:,1], c = 'r') #plt.plot(SpecFeatures[:,0], SpecFeatures[:,1], c = 'b', label = 'Significant lines') plt.legend() plt.xlim(3000, 9000) return array(SpecFeatures), array(arrowlines)
def Relative_spec(nltespec, ltespec): ''' FUNCTION CURRENTLY DOES NOT WORK PROPERLY!!! THIS IS AN ARTIFACT OF ME CREATING THE .norm.7 FILES TO INCREASE PROGRAM SPEED. ''' model = array(Spec_Normalize(nltespec,ltespec)).T a = nltespec.split('-') #b = ltespec.split('-') #Modelspecfile = ('PHOENIX/%(allspec)s' %{'allspec' : model}) Arcturusspec = ltespec specgrid =np.arange(3000,12000,0.01) ModelSpec = model Arcturus = Arcturusspec ModelSpecFlux = np.interp(specgrid, ModelSpec[:,0], ModelSpec[:,1]) ArcturusFlux = np.interp(specgrid, Arcturus[:,0] , Arcturus[:,1]) print 'Plotting {} model, Teff= {}K '.format(a[0],a[1]), '[Fe/H]= -{}'.format(a[3][0:3]) ,'iter=', i ModelSpec2 = convolve(ModelSpecFlux, macroturb , 0.01) #Macroturbulence ModelSpec3 = convolve(ModelSpec2, 2 , 0.01) #Spectrograph RelativeSpec = 100.*(ModelSpec3 - ArcturusFlux)/ArcturusFlux Unity = array((specgrid, RelativeSpec )).T Unity2 = Unity[(Unity[:,0] <= 7300 )] SpecSigma = np.std(Unity2[:,1]) SpecMean = np.mean(Unity[:,1]) print 'Spectrum Mean= ',SpecMean print 'Standard Deviation= ',SpecSigma plt.plot(Unity2[:,0], Unity2[:,1], label = '[Teff] = {}K, model={}, cTeff= {}K'.format(a[1],a[0],b[1])) #plt.ylim(-100,1000) plt.xlim(linecentre - dx, linecentre + dx) plt.grid(True) plt.legend() plt.ylabel('$(F_{NLTE} - F_{OBS})/F_{OBS}$ (%)') plt.xlabel('Wavelength, ($\AA$)') plt.title('Relative Spectrum Differences \n Between Model and Observed Spectra for Arcturus \n ') return RelativeSpec
def Spec_Graph(spectra): allspec1 = ('%(allspec)s' % {'allspec': spectra[1]}) #nlte Spectrum allspec2 = ('%(allspec)s' % {'allspec': spectra[0]}) #lte Spectrum g = allspec1.split('-') gg = allspec2.split('-') print 'plotting F_{} - F_{} / F{} relative difference.'.format( g[0], gg[0], gg[0]) Spec1 = load_spec(allspec1, 'PHOENIX') Spec2 = load_spec(allspec2, 'PHOENIX') newgrid = np.arange(3000, 12000, 0.01) #Uniform grid space for each spectra NewSpec1 = np.interp(newgrid, Spec1[:, 0], Spec1[:, 1]) NewSpec2 = np.interp(newgrid, Spec2[:, 0], Spec2[:, 1]) ##### Fast Fourier Transform convolution function ##### FWHM = 0.015 smooth1 = convolve(NewSpec1, FWHM, 0.01) smooth2 = convolve(NewSpec2, FWHM, 0.01) RelativeSpectrum = ( (smooth1 - smooth2) / smooth2) * 100. #Relative fluxes as a percent SpecAvg = np.mean(RelativeSpectrum) SpecSigma = np.std(RelativeSpectrum) #top lines #plt.hlines(SpecAvg + SpecSigma, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 1.0) #plt.hlines(SpecAvg - SpecSigma, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 1.0) #plt.hlines(SpecAvg, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 2.0) SmoothedSpec = np.array([newgrid, RelativeSpectrum], dtype=float) SmoothedSpec = SmoothedSpec.T SpecFeatures = list() for q in range(0, len(SmoothedSpec)): if (SmoothedSpec[q, 1] >= SpecAvg + SpecSigma) or ( SmoothedSpec[q, 1] <= SpecAvg - SpecSigma): SpecFeatures.append([SmoothedSpec[q, 0], SmoothedSpec[q, 1]]) SpecFeatures = np.array(SpecFeatures, dtype=float) ##### This finds where the important lines are located on the convolved relative spectrum. nothing = [] # Temporary list that is not useful after plotting for m in range(0, len(Linelist)): a = Linelist['wavelength'][m] - 0.005 b = Linelist['wavelength'][m] + 0.005 linefile = SmoothedSpec[:, 0] nothing = np.append(nothing, np.where((linefile >= a) & (linefile <= b))) ##### Array made from y-value at line wavelength on each spectrum. arrowlines = [] for n in range(0, len(nothing)): #arrowlines.append([Linelist['wavelength'][n], SmoothedSpec[nothing[n],1], Linelist['element'][n], Linelist['ion'][n]]) arrowlines.append( [Linelist['wavelength'][n], SmoothedSpec[nothing[n], 1]]) #arrowlines = np.array(arrowlines, dtype= ([('wavelength','f8'), ('percent','f8'), ('element','a2'), ('ion','a2') ])) arrowlines = np.array(arrowlines, dtype=float) arrowlines[:, 1] = arrowlines[:, 1][np.argsort(arrowlines[:, 0])] arrowlines[:, 0] = np.sort(arrowlines[:, 0]) #plt.plot(arrowlines[:,0], arrowlines[:,1], c= colourstring[i], linewidth= 2.0, # label = ' Fe/H = -%(fehs)s ' %{'fehs' : g[3][0:3]} ) #plt.scatter(arrowlines[:,0], arrowlines[:,1], c=colourstring[i]) ''' if (g[3][0:3] == '0.5'): for r in range(len(Linelist)): #if (arrowlines[r,1] >= 10.): plt.annotate('%(element)s - %(ion)s, %(wave)s' %{ 'element' : Linelist['element'][r], 'ion' : Linelist['ion'][r], 'wave' : Linelist['wavelength'][r] } , xy=(Linelist['wavelength'][r], SmoothedSpec[nothing[r],1]), xytext=(Linelist['wavelength'][r], SmoothedSpec[nothing[r],1] + 60 ), arrowprops=dict(facecolor='black',arrowstyle ='->')) ''' ''' for s in range(len(stronglines)): plt.annotate(atomlist[s] + ', {}'.format(stronglines[s,0]) , xy=(stronglines[s,0], 0), xytext=(stronglines[s,0],80), arrowprops=dict(facecolor='black', arrowstyle= '->')) ''' plt.title('Teff = {}K ' ' {}$\AA$ Convolution'.format(g[1], FWHM)) plt.grid(True) plt.ylabel('Relative Flux (%)') plt.xlabel('Wavelength ($\AA$)') #Overplotting the locations of important spectral lines in the spectral range. ''' for j in range(len(Linelist)): plt.annotate('%(element)s - %(ion)s' %{ 'element' : Linelist['element'][j], 'ion' : Linelist['ion'][j] } , xy=(Linelist['wavelength'][j], -10), xytext=(Linelist['wavelength'][j], 80), arrowprops=dict(facecolor='black', headwidth = 0, linewidth = 0) ) ''' #plt.fill_between(newgrid,y1=SpecAvg + SpecSigma, y2 = SpecAvg-SpecSigma,color = 'y') plt.plot(newgrid, RelativeSpectrum, c=colourstring[i], label=' Fe/H = -%(fehs)s ' % {'fehs': g[3][0:3]}, linewidth=2.0) #plt.scatter(SpecFeatures[:,0], SpecFeatures[:,1], c = 'r') #plt.plot(SpecFeatures[:,0], SpecFeatures[:,1], label = 'Significant lines') plt.legend() plt.xlim(3000, 9000) return array(SpecFeatures), array(arrowlines)
def Spec_Graph(spectra): allspec1 = ('%(allspec)s' %{'allspec' : spectra[1]}) #nlte Spectrum allspec2 = ('%(allspec)s' %{'allspec' : spectra[0]}) #lte Spectrum g = allspec1.split('-') gg = allspec2.split('-') print 'plotting F_{} - F_{} / F{} relative difference.'.format(g[0],gg[0],gg[0]) Spec1 = load_spec(allspec1,'PHOENIX') Spec2 = load_spec(allspec2,'PHOENIX') newgrid = np.arange(3000,12000, 0.01) #Uniform grid space for each spectra NewSpec1 = np.interp(newgrid, Spec1[:,0], Spec1[:,1]) NewSpec2 = np.interp(newgrid, Spec2[:,0], Spec2[:,1]) ##### Fast Fourier Transform convolution function ##### FWHM = 0.015 smooth1 = convolve(NewSpec1,FWHM,0.01) smooth2 = convolve(NewSpec2,FWHM,0.01) RelativeSpectrum = ( (smooth1 - smooth2)/smooth2 ) * 100. #Relative fluxes as a percent SpecAvg = np.mean(RelativeSpectrum) SpecSigma = np.std(RelativeSpectrum) #top lines #plt.hlines(SpecAvg + SpecSigma, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 1.0) #plt.hlines(SpecAvg - SpecSigma, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 1.0) #plt.hlines(SpecAvg, 3000,9000, linestyle = '--', colors = colourstring[i], lw = 2.0) SmoothedSpec = np.array([newgrid, RelativeSpectrum], dtype= float) SmoothedSpec = SmoothedSpec.T SpecFeatures = list() for q in range(0,len(SmoothedSpec)): if (SmoothedSpec[q,1] >= SpecAvg + SpecSigma) or (SmoothedSpec[q,1] <= SpecAvg - SpecSigma): SpecFeatures.append([SmoothedSpec[q,0],SmoothedSpec[q,1]]) SpecFeatures = np.array(SpecFeatures, dtype=float) ##### This finds where the important lines are located on the convolved relative spectrum. nothing = [] # Temporary list that is not useful after plotting for m in range(0,len(Linelist)): a = Linelist['wavelength'][m] - 0.005 b = Linelist['wavelength'][m] + 0.005 linefile = SmoothedSpec[:,0] nothing = np.append(nothing, np.where((linefile >= a) & (linefile <= b))) ##### Array made from y-value at line wavelength on each spectrum. arrowlines = [] for n in range(0,len(nothing)): #arrowlines.append([Linelist['wavelength'][n], SmoothedSpec[nothing[n],1], Linelist['element'][n], Linelist['ion'][n]]) arrowlines.append([Linelist['wavelength'][n], SmoothedSpec[nothing[n],1]]) #arrowlines = np.array(arrowlines, dtype= ([('wavelength','f8'), ('percent','f8'), ('element','a2'), ('ion','a2') ])) arrowlines = np.array(arrowlines, dtype= float) arrowlines[:,1] = arrowlines[:,1][np.argsort(arrowlines[:,0])] arrowlines[:,0] = np.sort(arrowlines[:,0]) #plt.plot(arrowlines[:,0], arrowlines[:,1], c= colourstring[i], linewidth= 2.0, # label = ' Fe/H = -%(fehs)s ' %{'fehs' : g[3][0:3]} ) #plt.scatter(arrowlines[:,0], arrowlines[:,1], c=colourstring[i]) ''' if (g[3][0:3] == '0.5'): for r in range(len(Linelist)): #if (arrowlines[r,1] >= 10.): plt.annotate('%(element)s - %(ion)s, %(wave)s' %{ 'element' : Linelist['element'][r], 'ion' : Linelist['ion'][r], 'wave' : Linelist['wavelength'][r] } , xy=(Linelist['wavelength'][r], SmoothedSpec[nothing[r],1]), xytext=(Linelist['wavelength'][r], SmoothedSpec[nothing[r],1] + 60 ), arrowprops=dict(facecolor='black',arrowstyle ='->')) ''' ''' for s in range(len(stronglines)): plt.annotate(atomlist[s] + ', {}'.format(stronglines[s,0]) , xy=(stronglines[s,0], 0), xytext=(stronglines[s,0],80), arrowprops=dict(facecolor='black', arrowstyle= '->')) ''' plt.title('Teff = {}K '' {}$\AA$ Convolution'.format(g[1],FWHM)) plt.grid(True) plt.ylabel('Relative Flux (%)') plt.xlabel('Wavelength ($\AA$)') #Overplotting the locations of important spectral lines in the spectral range. ''' for j in range(len(Linelist)): plt.annotate('%(element)s - %(ion)s' %{ 'element' : Linelist['element'][j], 'ion' : Linelist['ion'][j] } , xy=(Linelist['wavelength'][j], -10), xytext=(Linelist['wavelength'][j], 80), arrowprops=dict(facecolor='black', headwidth = 0, linewidth = 0) ) ''' #plt.fill_between(newgrid,y1=SpecAvg + SpecSigma, y2 = SpecAvg-SpecSigma,color = 'y') plt.plot(newgrid, RelativeSpectrum, c= colourstring[i], label = ' Fe/H = -%(fehs)s ' %{'fehs' : g[3][0:3]}, linewidth = 2.0) #plt.scatter(SpecFeatures[:,0], SpecFeatures[:,1], c = 'r') #plt.plot(SpecFeatures[:,0], SpecFeatures[:,1], label = 'Significant lines') plt.legend() plt.xlim(3000, 9000) return array(SpecFeatures), array(arrowlines)