● (No.1192) Marina jpg creating on Windows (2026年8月20日)
---------------------------------------------------------
Windows上で、Marina のHEXデータからJPG画像化することに成功した。PowerShell上で
ほとんどの作業を行い、その都度、出力ファイルを Geany で確認した。sequence22.rb
の結果、100%ファイルが仕上がっており、それに続く作業は編集・整形することもなく
あっという間に JPG へ画像化が完了した。LINUXとは文法が微妙に異なり、最後の HEX
から Binary に変換する文法がかなり面倒であった。全般的に、Windows よりも LINUX
の方が、作業が楽である。(→ Summary, Memo, Carry)
※ 事前に Windows に、"Geany","Ruby","Git for Windows" をインストールしておく。
※ marinaフォルダ上で、PowerShell を実行する。
(エクスプローラーでmarinaフォルダに入り、上段欄に PowerShell と入力する。)
19 Aug 2026
----------------------------------------------------------------------------
[extract20.txt]
satnogs.csvファイルの各行において、語句1または語句2または語句3のいずれかが
含まれる行を抽出し、extract20.txt と名前付け保存する。
> Select-String -Path "satnogs.csv" -Pattern "2026-08-08 23:","2026-08-08 22:","2026-08-08 21:" | ForEach-Object { $_.Line } | Set-Content "extract20.txt"
----------------------------------------------------------------------------
[extract21.txt]
extract20.txt に次の修正をして、extract21.txt と名前付け保存する。
FFD8の存在する複数行の51文字目から54文字目に 0000 を挿入する。
その真上の複数行の51文字目から54文字目を 0080 と修正する。
----------------------------------------------------------------------------
[sequence22.txt]
ruby を使って、extract21.txtの各行を検索して、51文字目から54文字目に
0000 (注) 0000(h) = 0000(d)
0080 0080(h) = 0128(d)
0100 0100(h) = 0256(d)
0180 0180(h) = 0384(d)
0200
0280 つまり、間隔はすべて 0080(h), 10進数で128。
0300
0380
:
:
EE00
EE80
までを含む行をそれぞれ一行のみこの順に並べ替えて、sequence22.txt と保存する。
----------------------------------------------------------------------------
[sequence22.rb]
# 並べ替えたい値
keys = (0x0000..0xEE80).step(0x80).map { |n| format("%04X", n) }
lines = File.readlines("extract21.txt", chomp: true)
# 51文字目~54文字目を取得して分類
groups = Hash.new { |h, k| h[k] = [] }
lines.each do |line|
key = line[50, 4] # Rubyは 0 始まりなので51文字目 = index 50
if keys.include?(key)
groups[key] << line
end
end
# 各キーについて1行だけ取り出す
result = keys.filter_map do |key|
groups[key]&.first
end
File.open("sequence22.txt", "w") do |f|
result.each do |line|
f.puts line
end
end
上記をmarinaフォルダ内に、sequence22.rb と名前付け保存する。
> ruby sequence22.rb > 60819ma1.sh
> .\60819ma1.sh
----------------------------------------------------------------------------
[sequence23.txt]
sequence22.txt の51文字目から54文字目に、
0000
0080
0100
0180
0200
0280
0300
0380
:
:
EE00
EE80
と規則正しく存在しているか確認し、その行がない時は他の.csvファイルから補充し、
sequence23.txt と名前付け保存する。
----------------------------------------------------------------------------
[sequence24.rb]
各行の最初と最後の部分をカットし、全行の主要データ範囲を抽出する。
出力ファイルの一行目の最初は FFD8 で、最終行の最後は FFD9 であることを確認する。
File.open("sequence24.txt", "w") do |out|
File.foreach("sequence23.txt") do |line|
out.puts line.chomp[58, 256]
end
end
> ruby sequence24.rb > 60819ma2.sh
> .\60819ma2.sh
----------------------------------------------------------------------------
[one_line25.txt]
sequence24.txt の FFD8~FFD9 のそれぞれの行の改行を削除して、一行に編集し、
one_line25.txt と名前付け保存する。
> (Get-Content sequence24.txt -Raw) -replace '\r?\n', '' | Set-Content one_line25.txt
----------------------------------------------------------------------------
[marina25.jpg]
FFD8~FFD9 の one_line25.txt からJPG画像化する。
> $hex = (Get-Content "one_line25.txt" -Raw).Trim()
> $bytes = for ($i = 0; $i -lt $hex.Length; $i += 2) {[Convert]::ToByte($hex.Substring($i, 2), 16)}
> [System.IO.File]::WriteAllBytes("marina25.jpg", $bytes)
----------------------------------------------------------------------------
Summary
csvファイルの各行の21文字目~26文字目が画像番号を示しているので、"87BB54"
"87BB94" の二つを指定すると、下記 [sequence32.rb](sequence32.txt) の段階
で既に欠損のないファイルが得られ、その先の処理が [marina35.jpg] へ一気に
進み、100%のJPG画像化が完了した。(marinaフォルダ上で PowerShell を実行)
"87BB54,87BB94", 21 Aug 2026
----------------------------------------------------------------------------
[extract30.txt] ... 抽出
> Select-String -Path "satnogs.csv" -Pattern "87BB54","87BB94" | ForEach-Object { $_.Line } | Set-Content "extract30.txt"
----------------------------------------------------------------------------
[extract31.txt] ... FFD8の2バイト前に 0000 追加
----------------------------------------------------------------------------
[sequence32.rb] ... 全行上下入れ替え&各キー1行のみ抽出
keys = (0x0000..0xEE80).step(0x80).map { |n| format("%04X", n) }
lines = File.readlines("extract31.txt", chomp: true)
groups = Hash.new { |h, k| h[k] = [] }
lines.each do |line|
key = line[50, 4]
if keys.include?(key)
groups[key] << line
end
end
result = keys.filter_map do |key|
groups[key]&.first
end
File.open("sequence32.txt", "w") do |f|
result.each do |line|
f.puts line
end
end
> ruby sequence32.rb > 60821ma1.sh
> .\60821ma1.sh
----------------------------------------------------------------------------
[sequence33.txt] ... 欠損行追加
----------------------------------------------------------------------------
[sequence34.rb] ... 全行の主要データ範囲を抽出
File.open("sequence34.txt", "w") do |out|
File.foreach("sequence33.txt") do |line|
out.puts line.chomp[58, 256]
end
end
> ruby sequence34.rb > 60821ma2.sh
> .\60821ma2.sh
----------------------------------------------------------------------------
[one_line35.txt] ... FFD8~FFD9 に一行連結
> (Get-Content sequence34.txt -Raw) -replace '\r?\n', '' | Set-Content one_line35.txt
----------------------------------------------------------------------------
[marina35.jpg] ... JPG画像化
> $hex = (Get-Content "one_line35.txt" -Raw).Trim()
> $bytes = for ($i = 0; $i -lt $hex.Length; $i += 2) {[Convert]::ToByte($hex.Substring($i, 2), 16)}
> [System.IO.File]::WriteAllBytes("marina35.jpg", $bytes)
"87BB54,87BB94", 21 Aug 2026
Memo
[#1] on PowerShell
> Select-String -Path "satnogs.csv" -Pattern "87BB54","87BB94" | ForEach-Object { $_.Line } | Set-Content "extract40.txt"
[#2] in Ruby
Add "0000" front FFD8 in extract40.txt and edit it as extract41.txt.
[#3] Save the following as sequence42.rb
keys = (0x0000..0xEE80).step(0x80).map { |n| format("%04X", n) }
lines = File.readlines("extract41.txt", chomp: true)
groups = Hash.new { |h, k| h[k] = [] }
lines.each do |line|
key = line[50, 4]
if keys.include?(key)
groups[key] << line
end
end
result = keys.filter_map do |key|
groups[key]&.first
end
File.open("sequence42.txt", "w") do |f|
result.each do |line|
f.puts line
end
end
[#4] on PowerShell
> ruby sequence42.rb > 60822ma1.sh
> .\60822ma1.sh
[#5] in Ruby
Add the missing lines to sequence42.txt and save it as sequence43.txt.
[#6] Save the following as sequence44.rb
File.open("sequence44.txt", "w") do |out|
File.foreach("sequence43.txt") do |line|
out.puts line.chomp[58, 256]
end
end
[#7] on PowerShell
> ruby sequence44.rb > 60822ma2.sh
> .\60822ma2.sh
[#8] on PowerShell
> (Get-Content sequence44.txt -Raw) -replace '\r?\n', '' | Set-Content one_line45.txt
[#9] on PowerShell
> $hex = (Get-Content "one_line45.txt" -Raw).Trim()
> $bytes = for ($i = 0; $i -lt $hex.Length; $i += 2) {[Convert]::ToByte($hex.Substring($i, 2), 16)}
> [System.IO.File]::WriteAllBytes("marina45.jpg", $bytes)
"87BA94,87BAD4", 19 Aug 2026
"87BE94", 23 Aug 2026
Carry
"2026-08-23 07:09:03|87BE94" の画像データは非常に大きく、行番号の規則性が、
次のように "D1190000FF80" の次は、"D11A00010000" のように繰り上がっていた。
この大小関係をプログラム的に認識させ、全体を並べ替えることに大変苦労した。
"87BE94"の画像データは量的には多かったが、欠損箇所が半分近くあり画像化は
ほとんど出来なかった。プログラム化はほぼ出来ているので、次回の作業は楽だ。
:
:
D1190000FF00
D1190000FF80
D11A00010000
D11A00010080
:
:
[#1] on PowerShell
> Get-Content .\satnogs.csv | Where-Object { $_ -like '*87BE94*' -and $_ -like '*UX5UL-KO50ei*' } | Set-Content .\extract60.txt
[#2] in PowerShell
Get-Content .\extract60.txt | ForEach-Object {
if ($_.Length -ge 50 -and $_.Substring(46,4) -eq "D119") {
$_.Substring(0,50) + "0000" + $_.Substring(50)
} else {
$_
}
} | Set-Content .\extract61.txt -Encoding ASCII
Add "00000000" front FFD8 in extract60.txt and save and overwrite it as extract61.txt.
[#3] Save the following as sequence62.rb
input_file = "extract61.txt"
output_file = "sequence62.txt"
records = {}
File.foreach(input_file) do |line|
key = line[53, 5]
records[key] ||= line
end
File.open(output_file, "w") do |out|
records.keys
.sort_by { |key| key.to_i(16) }
.each do |key|
out.write(records[key])
end
end
[#4] on PowerShell
> ruby sequence62.rb > 60824ma1.sh
> .\60824ma1.sh
[#5] in Ruby
Add the missing lines to sequence62.txt and save it as sequence63.txt.
[#6] Save the following as sequence64.rb
File.open("sequence64.txt", "w") do |out|
File.foreach("sequence63.txt") do |line|
out.puts line.chomp[62, 256]
end
end
[#7] on PowerShell
> ruby sequence64.rb > 60824ma2.sh
> .\60824ma2.sh
[#8] on PowerShell
> (Get-Content sequence64.txt -Raw) -replace '\r?\n', '' | Set-Content one_line65.txt
[#9] on PowerShell
> $hex = (Get-Content "one_line65.txt" -Raw).Trim()
> $bytes = for ($i = 0; $i -lt $hex.Length; $i += 2) {[Convert]::ToByte($hex.Substring($i, 2), 16)}
> [System.IO.File]::WriteAllBytes("marina65.jpg", $bytes)
トップ へ戻る.
前のページ へ戻る.
次のページ へ移る.
ホームページ(目次) へ戻る.