Skip to content

Instantly share code, notes, and snippets.

@JVital2013
Created April 7, 2025 12:23
Show Gist options
  • Save JVital2013/9c04fbed6cc395dfffb3e766a4362d38 to your computer and use it in GitHub Desktop.
Save JVital2013/9c04fbed6cc395dfffb3e766a4362d38 to your computer and use it in GitHub Desktop.
# Converts GOES-R HRIT CADU (ex, from SatDump) to LRIT packets (ex, for goestools)
$inputPath = "C:\Users\jvita\Desktop\goes19\goes_hrit.cadu"
$outputPath = "C:\Users\jvita\Desktop\goes19\goes_hrit.bin"
$caduSize = 1024
$packetSize = 892
$inputStream = [System.IO.FileStream]::new($inputPath, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read)
$outputStream = [System.IO.FileStream]::new($outputPath, [System.IO.FileMode]::Create)
$binaryWriter = New-Object System.IO.BinaryWriter($outputStream)
$buffer = [byte[]]::new($caduSize)
while (($bytesRead = $inputStream.Read($buffer, 0, $caduSize)) -gt 0)
{
if($bytesRead -ne $caduSize)
{
Write-Output "ERROR - buffer underrun!"
break
}
$binaryWriter.Write($buffer, 4, $packetSize)
}
$binaryWriter.Close()
$inputStream.Close()
$outputStream.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment