-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemissivityplotter.py
38 lines (32 loc) · 1.16 KB
/
emissivityplotter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import numpy as np
import matplotlib.pyplot as plt
# Create a single figure before the loop
plt.figure(figsize=(10, 6))
def plot_data(file_path):
wavelengths = []
values = []
with open(file_path, 'r') as file:
for line in file:
parts = line.strip().split(',')
if len(parts) == 2:
wavelength, value = map(float, parts)
wavelengths.append(wavelength)
values.append(value)
# Plot on the existing figure
site_name = os.path.basename(file_path).split('.')[0]
plt.plot(wavelengths, values, label=site_name)
# Directory containing the data files
data_dir = "/Users/emmabelhadfa/Documents/Oxford/spectrometer/size" # Replace with your folder path
file_paths = [os.path.join(data_dir, f) for f in os.listdir(data_dir) if f.endswith('.dpt')]
# Plot all files
for file_path in file_paths:
plot_data(file_path)
# Add labels and show the plot after all data is plotted
plt.xlabel('Wavenumber (cm⁻¹)')
plt.ylabel('Emissivity')
plt.title('Emissivity Spectra of San Carlos Olivine - Grain Size Comparison')
plt.legend()
plt.grid(True)
plt.gca().invert_xaxis()
plt.show()