Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #imports
- import numpy as np
- import matplotlib.pyplot as plt
- import plotly.graph_objects as go
- from scipy.signal import find_peaks
- from tabulate import tabulate
- #silicon standard
- SiNIST = np.loadtxt('SiNIST.csv', delimiter=',')
- SiX = SiNIST[:,0]
- SiY = SiNIST[:,1]
- SiIndices = find_peaks(SiY, prominence = 200)[0]
- fig = go.Figure()
- fig.add_trace(go.Scatter(
- y = SiY,
- mode = 'lines',
- line = dict(
- color ='firebrick',
- width = 1,
- ),
- showlegend = False
- )
- )
- fig.add_trace(go.Scatter(
- x = SiIndices,
- y = [SiY[j] for j in SiIndices],
- mode ='markers',
- marker = dict(
- size = 5,
- color = 'black',
- symbol = 'x'
- ),
- name = 'Detected Peaks'
- )
- )
- fig.update_layout(
- title = ({
- 'text': 'Silicon Standard Diffractogram',
- 'y': 0.9,
- 'x': 0.5,
- 'xanchor': 'center',
- 'yanchor': 'top'}),
- xaxis_title = "2θ",
- yaxis_title = "Intensity",
- xaxis_showgrid = False,
- font = dict(
- family = 'Courier New, monospace',
- size = 12,
- color = '#000000'
- )
- )
- fig.update_xaxes(showticklabels = False),
- fig.show()
- plt.xlabel('2θ')
- plt.ylabel('Intensity')
- hideAxes = plt.gca()
- hideAxes.axes.get_xaxis().set_ticks([])
- hideAxes.axes.get_yaxis().set_ticks([])
- plt.plot(SiX, SiY, linewidth = '.5', color = 'black')
- plt.show()
- for i, x, y in zip(SiIndices, SiX[SiIndices], SiY[SiIndices]):
- headers = ['Peak', '2θ', 'Intensity']
- table = zip(SiIndices, SiX[SiIndices], SiY[SiIndices])
- print('\033[1m' + 'Detected Peaks:' + '\033[0m')
- print(tabulate(table, headers, tablefmt = 'pretty'))
- #silicon standard full list
- peakSi = []
- for i, (x, y) in enumerate(zip(SiX, SiY)):
- peakSi.append(i)
- headers = ['Peak', '2θ', 'Intensity']
- table = zip(peakSi, SiX, SiY)
- np.set_printoptions(threshold = np.inf)
- print(tabulate(table, headers, tablefmt = 'pretty'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement