File size: 1,575 Bytes
e38de99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from core.signal.phases import analyze_dcrm_data
import pandas as pd

# Load data
try:
    df = pd.read_excel('data/dcrm_waveform (1).xlsx')
    print(f"Loaded data: {df.shape[0]} samples, {df.shape[1]} channels")
except FileNotFoundError:
    print("Data file not found, skipping data load.")
    # Create dummy data
    import numpy as np
    df = pd.DataFrame({
        'Time_ms': np.linspace(0, 200, 200),
        'Resistance': [100]*200,
        'Current': [10]*200,
        'Travel': [50]*200,
        'Close_Coil': [0]*200,
        'Trip_Coil_1': [0]*200,
        'Trip_Coil_2': [0]*200
    })

# Run segmentation
result = analyze_dcrm_data(df)

# Print results
print("\n" + "="*60)
print("SEGMENTATION RESULTS")
print("="*60)

if 'phaseWiseAnalysis' in result:
    for phase in result['phaseWiseAnalysis']:
        phase_num = phase['phaseNumber']
        name = phase['name']
        start = phase.get('startTime', 0)
        end = phase.get('endTime', 0)
        duration = end - start
        
        print(f"\nPhase {phase_num}: {name}")
        print(f"  Time: {start:.1f} - {end:.1f} ms")
        print(f"  Duration: {duration:.1f} ms")
else:
    print("No phaseWiseAnalysis found in result.")
    print(result.keys())

print("\n" + "="*60)
print("METADATA")
print("="*60)
# analyze_dcrm_data doesn't return metadata in the same way, so we skip specific metadata checks
print("Segmentation completed.")