● (No.1191)Marina jpg creating on LINUX (2026年8月8日)
-----------------------------------------------------
https://community.libre.space/t/observation-14707468-marina-98293/15148
> Download as satnogs.csv (2026-08-07 09:37:xx UTC)
> Take the parts starting with the string: 87 BF 54
> there are missing lines for the sequences: 19 13 00, 19 15 00, 19 16 80, 19 18 80
> there are repair parts starting with string 87 BF 94 and 87 BF D4 to replace the
> missing lines / sequences.
> (Details are under analysis.)
> right_sequence.txt
> only_payload.txt
$ cat only_payload.txt | tr -d ' ' > space_cut.txt
$ cat space_cut.txt | tr -d '\r\n' > oneline.txt
$ cat oneline.txt | xxd -r -p > marina.jpg
Marina jpg Automatic experiment #1
JPG自動化にほぼ完成した。全データ数の少ない、行頭"87BF54"にこだわり実験
してみて、これらの手法で100%JPG画像化できることを確認した。ここに一連の
作業を解説する。satnogs.csvは直近のものを使用。実験途中で各出力ファイル
を多少、整形する必要がある。
----------------------------------------------------------------------------------------------
[extract1.rb] ... satnogs.csv から行頭 "87BF54" の行を抜粋
> File.open("extract1.txt", "w") do |out|
> File.foreach("satnogs.csv") do |line|
> out.puts line if line.include?("87BF54")
> end
> end
$ ruby extract1.rb > 60811ma1.sh
$ sh 60811ma1.sh
----------------------------------------------------------------------------------------------
[sequence1.rb] ... 上図赤枠の部分になるよう、2行づつ "[i]80,[i]00" と並べ替え
> for i in 0..0x0b2
> printf("grep 87BF5400841B00000007A7CB63A...%02X extract1.txt | head -2 >> sequence1.txt\n", i)
> end
$ ruby sequence1.rb > 60811ma2.sh
$ sh 60811ma2.sh
----------------------------------------------------------------------------------------------
[reverse1.rb] ,,, その2行づつを [i]80, [i]00 → [i]00, [i]80 と上下入れ替え
全行[i]順を確認。特に1行目にFFD8, 最終行にFFD9の存在を確認
修正後、下記sequence2.txt → reverse1.txt とリネーム保存
> lines = File.readlines("sequence1.txt")
> File.open("sequence2.txt", "w") do |file|
> lines.each_slice(2) do |pair|
> pair.reverse_each { |line| file.print line }
> end
> end
$ ruby reverse1.rb > 60811ma3.sh
$ sh 60811ma3.sh
----------------------------------------------------------------------------------------------
[reverse2.rb] ... 各行の最初と最後の部分をカットし、全行の主要データ範囲を抽出
1行目の最初は FFD8 で、最終行の最後は FFD9 であることを確認
> File.open("reverse2.txt", "w") do |out|
> File.foreach("reverse1.txt") do |line|
> out.puts line.chomp[58, 256]
> end
> end
$ ruby reverse2.rb > 60811ma4.sh
$ sh 60811ma4.sh
----------------------------------------------------------------------------------------------
[one_line1.txt] ... reverse2.txtの FFD8~FFD9 を一行に編集し、JPG画像化
$ tr -d '\n' < reverse2.txt > one_line1.txt
$ cat one_line1.txt | xxd -r -p > marina.jpg
Marina jpg Automatic experiment #2
各出力ファイルの補正 (特に、下記"sequence16.txt"から"reverse17.txt"への整形)に、膨大な
時間を要した。以下は半自動化の手法であるが、これを完全自動化するのは、ほぼ不可能と思う。
----------------------------------------------------------------------------------------------
[extract11.rb] ... Extract lines starting with "2026-08-08 23:" in satnogs.csv
> File.open("extract11.txt", "w") do |out|
> File.foreach("satnogs.csv") do |line|
> out.puts line if line.include?("2026-08-08 23:")
> end
> end
$ ruby extract11.rb > 60816ma1.sh
$ sh 60816ma1.sh
----------------------------------------------------------------------------------------------
[extract12.rb] ... Extract lines starting with "DUS-NORD-UHF-JO31jg" in extract11.txt
> File.open("extract12.txt", "w") do |out|
> File.foreach("extract11.txt") do |line|
> out.puts line if line.include?("DUS-NORD-UHF-JO31jg")
> end
> end
$ ruby extract12.rb > 60816ma2.sh
$ sh 60816ma2.sh
----------------------------------------------------------------------------------------------
[extract13.txt] ... Extract incloding lines from FFD8 to FFD9 in extract12.txt
> Extract time stamp from "2026-08-08 23:00:36" to "2026-08-08 23:01:33"
> Insert 0000 and 0080 into the bottom two lines, respectively.
> Save as extract13.txt
----------------------------------------------------------------------------------------------
[sequence14.rb] ... Rearrange the lines in pairs of "[i]80,[i]00" to match
the area outlined in red in the top figure.
> for i in 0..0x164
> printf("grep 87BBD400841B000000088E2D923...%02X extract13.txt | head -2 >> sequence14.txt\n", i)
> end
$ ruby sequence14.rb > 60816ma3.sh
$ sh 60816ma3.sh
----------------------------------------------------------------------------------------------
[sequence15.txt] ... Fill in the missing parts of "[i]80,[i]00" and save it again with a new name.
----------------------------------------------------------------------------------------------
[reverse16.rb] ,,, Swap the top and bottom lines of each pair changing from
"[i]80,[i]00" to "[i]00,[i]80". Check the [i] sequences for all lines.
In particular, verify the presence of FFD8 in the first line and FFD9
in the last line. After making the corrections, rename the file from
"sequence16.txt" to "reverse17.txt" and save it.
> lines = File.readlines("sequence15.txt")
> File.open("sequence16.txt", "w") do |file|
> lines.each_slice(2) do |pair|
> pair.reverse_each { |line| file.print line }
> end
> end
$ ruby reverse16.rb > 60816ma4.sh
$ sh 60816ma4.sh
----------------------------------------------------------------------------------------------
[reverse17.txt] ... Add the necessary corrections to sequence16.txt.
----------------------------------------------------------------------------------------------
[reverse18.rb] ... Trim the beginning and end of each line, and extract the core data
range from all lines. The first letter in the first line is FFD8,
and the last letter in the last line is FFD9.
> File.open("reverse18.txt", "w") do |out|
> File.foreach("reverse17.txt") do |line|
> out.puts line.chomp[58, 256]
> end
> end
$ ruby reverse18.rb > 60816ma5.sh
$ sh 60816ma5.sh
----------------------------------------------------------------------------------------------
[one_line19.txt] ... Edit the FFD8~FFD9 range in reverse18.txt into one single line and convert it.
$ tr -d '\n' < reverse18.txt > one_line19.txt
$ cat one_line19.txt | xxd -r -p > marina.jpg
----------------------------------------------------------------------------------------------
ChatGPT に聞いてみた。
うーむ、こんな技があったか。これらを使えば、完全自動化への道筋が見えて来る。
-----------------------------------------------------------------------------
[Q1]
ruby を使って、各行に複数の特定の文字列を含む行を抽出して保存するには?
[A1]
keywords = ["apple", "orange"]
File.open("output.txt", "w") do |out|
File.foreach("input.txt") do |line|
if keywords.all? { |keyword| line.include?(keyword) }
out.write(line)
end
end
end
-----------------------------------------------------------------------------
[Q2]
ruby を使って、各行を検索して例えば20文字目から23文字目に
0000
0080
0100
0180
0200
0280
0300
0380
を含む行を、この順に並べ替えて保存するには?
[A2]
order = %w[
0000
0080
0100
0180
0200
0280
0300
0380
]
rank = order.each_with_index.to_h
lines = File.readlines("input.txt", chomp: true)
sorted = lines
.select { |line| rank.key?(line[19, 4]) }
.sort_by { |line| rank[line[19, 4]] }
File.write("output.txt", sorted.join("\n") + "\n")
-----------------------------------------------------------------------------
注. Rubyの文字列は 0 始まりなので、
line[19, 4]
で20文字目から4文字、つまり20~23文字目を取得できる。
-----------------------------------------------------------------------------
[Q3]
ruby を使って、各行を検索して例えば51文字目から54文字目に
0000
0080
0100
0180
0200
0280
0300
0380
の規則性を維持して
EE00
EE80
までを含む行をそれぞれ一行のみ、この順に並べ替えて保存するには?
[A3]
# 並べ替えたい値
keys = (0x0000..0xEE80).step(0x80).map { |n| format("%04X", n) }
lines = File.readlines("input.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("output.txt", "w") do |f|
result.each do |line|
f.puts line
end
end
トップ へ戻る.
前のページ へ戻る.
次のページ へ移る.
ホームページ(目次) へ戻る.