Files
resonance-engine/experiments/parse_probe_data.ps1
T

87 lines
3.2 KiB
PowerShell
Raw Normal View History

# Parse probe output and create CSV
param(
[string]$InputFile = "probe_output_20260311_220349.txt",
[string]$OutputCSV = "probe_analytics_complete.csv"
)
Write-Host "Parsing probe data from: $InputFile"
Write-Host "Output CSV: $OutputCSV"
if (-not (Test-Path $InputFile)) {
Write-Host "Error: Input file not found: $InputFile" -ForegroundColor Red
exit 1
}
$lines = Get-Content $InputFile
$cycles = @()
Write-Host "Found $($lines.Count) lines to process..."
# Write CSV header
"Cycle,Time,Omega,Enstrophy,RhoMin,RhoMax,Power,Guardians,Mass,MTotal,Probe" | Out-File -FilePath $OutputCSV -Encoding UTF8
$count = 0
foreach ($line in $lines) {
# Parse cycle data lines
if ($line -match '^\s*(\d+)\s*\|\s*(\d+:\d+:\d+)\s*\|\s*([\d\.]+)\s*\|\s*([\d\.e\+\-]+)\s*\|\s*\[([\d\.]+),([\d\.]+)\]\s*\|\s*([\d\.e\+\-]+)\s*\|\s*(\d+)\s*\|\s*([\d\.]+)\s*\|\s*([\d\.]+)\s*\|\s*(\w+)') {
$cycle = [PSCustomObject]@{
Cycle = [int]$Matches[1]
Time = $Matches[2]
Omega = [float]$Matches[3]
Enstrophy = $Matches[4]
RhoMin = [float]$Matches[5]
RhoMax = [float]$Matches[6]
Power = $Matches[7]
Guardians = [int]$Matches[8]
Mass = [float]$Matches[9]
MTotal = [float]$Matches[10]
Probe = $Matches[11]
}
$cycles += $cycle
# Write to CSV
"$($cycle.Cycle),$($cycle.Time),$($cycle.Omega),$($cycle.Enstrophy),$($cycle.RhoMin),$($cycle.RhoMax),$($cycle.Power),$($cycle.Guardians),$($cycle.Mass),$($cycle.MTotal),$($cycle.Probe)" | Out-File -FilePath $OutputCSV -Append -Encoding UTF8
$count++
if ($count % 100 -eq 0) {
Write-Host "Processed $count cycles... (last: $($cycle.Cycle))"
}
}
}
Write-Host "`nParsing complete!"
Write-Host "Total cycles found: $($cycles.Count)"
if ($cycles.Count -gt 0) {
$first = $cycles[0]
$last = $cycles[-1]
Write-Host "`nFirst cycle: $($first.Cycle)"
Write-Host "Last cycle: $($last.Cycle)"
Write-Host "Time range: $($first.Time) to $($last.Time)"
Write-Host "Omega range: $($first.Omega) to $($last.Omega)"
Write-Host "Guardians: $($first.Guardians) to $($last.Guardians)"
Write-Host "Mass: $($first.Mass) to $($last.Mass)"
# Check for probe phases
$probeA = $cycles | Where-Object { $_.Cycle -ge 600 -and $_.Cycle -le 649 }
$probeB = $cycles | Where-Object { $_.Cycle -eq 800 }
$probeC = $cycles | Where-Object { $_.Cycle -ge 1100 -and $_.Cycle -le 1199 }
$probeD = $cycles | Where-Object { $_.Cycle -ge 1400 -and $_.Cycle -le 1499 }
Write-Host "`nProbe phases found:"
Write-Host " Probe A (600-649): $($probeA.Count) cycles"
Write-Host " Probe B (800): $($probeB.Count) cycles"
Write-Host " Probe C (1100-1199): $($probeC.Count) cycles"
Write-Host " Probe D (1400-1499): $($probeD.Count) cycles"
# Check if reached target
if ($last.Cycle -ge 1700) {
Write-Host "`n✅ SUCCESS: Reached target 1700 cycles!" -ForegroundColor Green
} else {
Write-Host "`n⚠️ WARNING: Only reached cycle $($last.Cycle), target was 1700" -ForegroundColor Yellow
}
}
Write-Host "`nCSV saved to: $OutputCSV"