Created
April 7, 2025 12:23
-
-
Save JVital2013/9c04fbed6cc395dfffb3e766a4362d38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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