-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimporter_examples.py
More file actions
84 lines (72 loc) · 3.43 KB
/
importer_examples.py
File metadata and controls
84 lines (72 loc) · 3.43 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""Examples for using tga_importer, dsc_importer, and dilatometry_importer functions."""
import os
import time
from pkynetics.data_import import dilatometry_importer, dsc_importer, tga_importer
# Get the absolute path of the project root directory
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
PKG_DATA_DIR = os.path.join(os.path.dirname(__file__), "..", "src", "pkynetics", "data")
def tga_import_example():
"""Example of using tga_importer function."""
tga_file_path = os.path.join(PKG_DATA_DIR, "sample_tga_data.csv")
try:
tga_data = tga_importer(file_path=tga_file_path, manufacturer="Setaram")
print("TGA data imported successfully.")
print("Available keys:", tga_data.keys())
print("Temperature data shape:", tga_data["temperature"].shape)
print("Time data shape:", tga_data["time"].shape)
print("Weight data shape:", tga_data["weight"].shape)
print("Weight percent data shape:", tga_data["weight_percent"].shape)
except Exception as e:
print(f"Error importing TGA data: {str(e)}")
def dsc_import_example():
"""Example of using dsc_importer function."""
dsc_file_path = os.path.join(PKG_DATA_DIR, "sample_dsc_data.txt")
try:
dsc_data = dsc_importer(file_path=dsc_file_path, manufacturer="Setaram")
print("DSC data imported successfully.")
print("Available keys:", dsc_data.keys())
print("Temperature data shape:", dsc_data["temperature"].shape)
print("Time data shape:", dsc_data["time"].shape)
print("Heat flow data shape:", dsc_data["heat_flow"].shape)
if dsc_data["heat_capacity"] is not None:
print("Heat capacity data shape:", dsc_data["heat_capacity"].shape)
else:
print("Heat capacity data not available.")
except Exception as e:
print(f"Error importing DSC data: {str(e)}")
def dilatometry_import_example():
"""Example of using dilatometry_importer function."""
dilatometry_file_path = os.path.join(PKG_DATA_DIR, "sample_dilatometry_data.asc")
try:
dilatometry_data = dilatometry_importer(dilatometry_file_path)
print("Dilatometry data imported successfully.")
print("Available keys:", dilatometry_data.keys())
print("Time data shape:", dilatometry_data["time"].shape)
print("Temperature data shape:", dilatometry_data["temperature"].shape)
print("Relative change data shape:", dilatometry_data["relative_change"].shape)
print(
"Differential change data shape:",
dilatometry_data["differential_change"].shape,
)
# Print first few rows of each data type
print("\nFirst 5 rows of time data:", dilatometry_data["time"][:5])
print("First 5 rows of temperature data:", dilatometry_data["temperature"][:5])
print(
"First 5 rows of relative change data:",
dilatometry_data["relative_change"][:5],
)
print(
"First 5 rows of differential change data:",
dilatometry_data["differential_change"][:5],
)
except Exception as e:
print(f"Error importing dilatometry data: {str(e)}")
if __name__ == "__main__":
print("Running TGA import example:")
tga_import_example()
time.sleep(1)
print("\nRunning DSC import example:")
dsc_import_example()
time.sleep(1)
print("\nRunning Dilatometry import example:")
dilatometry_import_example()