2024,江端さんの忘備録

(国際的な観点から)日本の物価が安い ―― これは、地味に私にインパクトを与えています。

The low cost of living in Japan (from an international perspective) -- has had a sobering impact on me.

インバンド需要によって、海外観光客の取り込みという点では良いことでしょう。

This would be a good thing for attracting international tourists due to in-band demand.

しかし、エネルギー輸入大国日本は、ご存知の通り、大打撃を受けています。

However, as you know, Japan, a major energy importer, has been hit hard.

-----

30年程前、私が一人でアジアを放浪していたというお話は何度かしたと思います。

携帯やメールのない時代の連絡方法

I have told you several times that about 30 years ago, I was wandering alone in Asia.

未整備なインフラ、清潔とは言えない環境、通じない言葉などの問題はありましたが、アジアは私の心の拠り所でした。

Despite the problems of undeveloped infrastructure, unclean environment, and language barriers, Asia was my spiritual home.

特に中国(大陸の方)は、「私の心の支え」といっても過言ではありませんでした。

In particular, China (the mainland) was "my heart and soul".

―― 何もかもが嫌になったら、中国大陸に逃げて、姉から毎月5000円を送金して貰いながら生きていこう

"If I get sick of everything, I'll run away to mainland China and live off my sister's monthly remittance of 5,000 yen."

当時の中国は、5000円もあれば、一ヶ月間くらいなら、余裕で宿泊と飲食を賄えるほど「安い国」だったのです。

At that time, China was such a "cheap country" that one could afford to stay, eat, and drink for a month or so with as little as \5,000.

-----

今、凄い勢いで、「私の心の支え」は壊れつつあります。

Now, "my heart and soul" is breaking down at a terrific rate.

今や日本は、経済大国第2位の国から、私の生きている間に、ランク外まで落ち込む可能性も出てきています。

Japan has gone from being the second-largest economy to possibly falling out of the ranks in my lifetime.

私の「換金レート差額を使った不労所得戦略」は完全に瓦解し、もはや逃げ場がないという事実が、今の私を苦しめています。

The fact that my "unearned income strategy using the exchange rate difference" has completely fallen apart, and there is no longer any way out is now hurting me.

-----

「お金に愛されないエンジニア」シリーズで、この「換金レート差額を使った不労所得戦略」の、過去と現在の話を書きたいのですが ―― 今、そんな時間は、全くありません。

I want to write about the past and present of this "unearned income strategy using the difference in exchange rates" in the "Engineers Unloved by Money" series -- but I don't have time for that right now.

2013,江端さんの忘備録

私が、リュックを背負って、アジアを歩き回っていた時のことです(「バックパッカー」と言われていました)。

バックパッカーの旅行者と一緒に、タイのバンコクを回っていた時、彼の仲間との待ち合わせに付きあったことがあります。

しかし、所定の時間になっても、その仲間は姿を現わしませんでした。このような旅では、よくあることでした。

しかし、その待ち合わせでは、確か「帰国フライトのチケット」の手渡しという重要な内容で、下手すると、彼は、帰国する手段を失うかもしれないという事態でした。

-----

私が驚いたのは、その後です。

「必ず何かのメッセージを残しているはずだ」と言いながら、彼はその周辺を探し出して、電柱から飛び出している針金に引っかかっている紙を見つけました。

「お、これだ、これだ」

その紙には、『落ち合う時間と場所の変更』を記載した手書きの文章が記載されていました。

-----

携帯電話もメールもない時代、ましてや海外における連絡手段が絶無であった時代において、

我々、海外一人旅の旅行者は、ほとんどこのような、―― 現代にあっては信じられないような原始的な方法で ―― 海外の旅を生き延びていたのです。

2024,江端さんの技術メモ

※fastapiの場合、スレッドでは上手くコンロールできない(らしい)ので、プロセス単位で管理します
(1)execute-commandというAPIから、pingを行う回数Xをjson形式入力して、"ping -n X kobore.net"を起動します。返り値はプロセス番号(pid)がjson形式で戻ります。
curl -X POST -H "Content-Type: application/json" -d "{\"count\": \"5\"}" http://localhost:8000/execute-command
(2)terminate-processというAPIから、上記のpidをjson形式で入力して、プロセスを強制終了します。返り値は、この成否(1/-1)がjson形式で戻ります。
curl -X POST -H "Content-Type: application/json" -d "{\"pid\": \"10164\"}" http://localhost:8000/terminate-process
(3)以下のファイルをtest.pyとして、uvicorn test:app --host 0.0.0.0 --reload を投入してfastapiサーバを起動します。
# curl -X POST -H "Content-Type: application/json" -d "{\"count\": \"5\"}" http://localhost:8000/execute-command
# curl -X POST -H "Content-Type: application/json" -d "{\"pid\": \"10164\"}" http://localhost:8000/terminate-process

import subprocess
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class ExecuteRequest(BaseModel):
    count: int  # pingコマンドの実行回数を指定

class TerminateRequest(BaseModel):
    pid: int  # 終了させるプロセスのPID

# 実行中のプロセスを格納する辞書
running_processes = {}

@app.post("/execute-command")
def execute_command(request: ExecuteRequest):
    count = request.count

    try:
        command = f"ping -n {count} kobore.net"  # pingコマンドの回数をcountに指定
        # コマンドを非同期で実行し、プロセスを取得
        process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        pid = process.pid  # プロセスのPIDを取得
        running_processes[pid] = process

        return {"pid": pid}  # PIDのみを返す
    except Exception as e:
        return {"message": f"コマンドの実行中にエラーが発生しました: {str(e)}"}


@app.post("/terminate-process")
def terminate_process(request: TerminateRequest):
    pid = request.pid
    print("pid in terminate-process", pid)

    try:
        # プロセスを取得し、終了させる
        process = running_processes.get(pid)

        process.terminate()  # プロセスを終了させる(SIGTERMを送信)
        process.wait()
        del running_processes[pid]  # プロセスを辞書から削除

        # 成功の場合は1を返す
        return {"status": 1}
    except Exception as e:
        return {"status": -1}  # 失敗の場合は-1を返す

if __name__ == "__main__":
    # FastAPIサーバーを開始
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

出力結果
C:\Users\ebata\fastapi7>curl -X POST -H "Content-Type: application/json" -d "{\"count\": \"100\"}" http://localhost:8000/execute-command
{"pid":1784}
C:\Users\ebata\fastapi7>curl -X POST -H "Content-Type: application/json" -d "{\"pid\": \"1784\"}" http://localhost:8000/terminate-process
{"status":1}
C:\Users\ebata\fastapi7>curl -X POST -H "Content-Type: application/json" -d "{\"pid\": \"1784\"}" http://localhost:8000/terminate-process
{"status":-1}


起動したプロセスを監視して、プロセスが予定通り/突然停止した場合、それを通知する仕組みを追加しました。

# curl -X POST -H "Content-Type: application/json" -d "{\"count\": \"5\"}" http://localhost:8000/execute-command
# curl -X POST -H "Content-Type: application/json" -d "{\"pid\": \"10164\"}" http://localhost:8000/terminate-process
# C:\Users\ebata\fastapi7>uvicorn test:app --host 0.0.0.0 --reload

import subprocess
import os
import time
import multiprocessing  # multiprocessingモジュールを追加
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class ExecuteRequest(BaseModel):
    count: int  # pingコマンドの実行回数を指定

class TerminateRequest(BaseModel):
    pid: int  # 終了させるプロセスのPID

# 実行中のプロセスを格納する辞書
running_processes = {}
process_monitor_processes = {}

@app.post("/execute-command")
def execute_command(request: ExecuteRequest):
    count = request.count

    try:
        command = f"ping -n {count} kobore.net"  # pingコマンドの回数をcountに指定
        # コマンドを非同期で実行し、プロセスを取得
        process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        pid = process.pid  # プロセスのPIDを取得
        running_processes[pid] = process

        # プロセスを監視するプロセスを起動
        monitor_process = multiprocessing.Process(target=monitor_process_status, args=(pid,))
        monitor_process.start()
        process_monitor_processes[pid] = monitor_process

        return {"pid": pid}  # PIDのみを返す
    except Exception as e:
        return {"message": f"コマンドの実行中にエラーが発生しました: {str(e)}"}


@app.post("/terminate-process")
def terminate_process(request: TerminateRequest):
    pid = request.pid
    print("pid in terminate-process", pid)

    try:
        # プロセスを取得し、終了させる
        process = running_processes.get(pid)

        process.terminate()  # プロセスを終了させる(SIGTERMを送信)
        process.wait()
        del running_processes[pid]  # プロセスを辞書から削除

        # 成功の場合は1を返す
        return {"status": 1}
    except Exception as e:
        return {"status": -1}  # 失敗の場合は-1を返す

def monitor_process_status(pid):
    while True:
        if not is_process_running(pid):
            # プロセスが存在しない場合
            # メッセージを生成して出力(または送信)
            message = {
                "status": "Process Disappeared",
                "pid": pid
            }
            print("Process Disappeared:", message)

            # プロセス監視プロセスを停止
            ### del process_monitor_processes[pid]
            break

        # 一定の待機時間を設定して監視を継続
        time.sleep(10)  # 10秒ごとに監視

def is_process_running(pid):
    #try:
    #    os.kill(pid, 0)  # PIDを使ってプロセスにシグナルを送信し、存在を確認
    #    return True
    #except OSError:
    #    return False
    try:
        # ここの部分Windows特有のやりかたなので、後で、例の、os.kill(pid,0)を試してみること
        # tasklistコマンドを実行してプロセス一覧を取得
        result = subprocess.check_output(["tasklist", "/fi", f"PID eq {pid}"], universal_newlines=True)

        # 結果から指定したPIDの行を検索
        lines = result.splitlines()
        for line in lines:
            if f"{pid}" in line:
                return True

        # 指定したPIDが見つからない場合
        # ここに、停止時のメッセージ送信を組み込めばO.K.のはず   

        return False
    except Exception as e:
        return False





if __name__ == "__main__":
    # FastAPIサーバーを開始
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

2024,江端さんの技術メモ

指定されたコマンド "ping -100 kobore.net" をFastAPIのエンドポイントから実行し、それが終了したらAPIを正常に終了させるコードは以下のようになります:

test.py

import subprocess
import threading
import os
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class CommandRequest(BaseModel):
    command: str

@app.post("/execute-command")
def execute_command(request: CommandRequest):
    command = request.command
    # コマンドを非同期で実行
    execution_thread = threading.Thread(target=execute_command_async, args=(command,))
    execution_thread.start()
    return {"message": f"コマンド '{command}' の実行を開始しました"}

def execute_command_async(command):
    process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    process.wait()  # コマンドの終了を待つ
    print(f"コマンド '{command}' の実行が終了しました")
    # os._exit(0)  # FastAPIサーバーを終了させる

if __name__ == "__main__":
    # FastAPIサーバーを開始
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

$ uvicorn test:app --host 0.0.0.0 --reload

 

C:\Users\ebata\fastapi7>curl -X POST -H "Content-Type: application/json" -d "{\"command\": \"ping -n 20 kobore.net\"}" http://localhost:8000/execute-command

2024,江端さんの忘備録

「働き方改革」に対して、「働き方改悪」というものもあるんじゃないか、と思うのです。

In contrast to "work style reform," there is also something called "work style deterioration."

私、ここ1年半の間の全ての平日と休日の間、一日も休んだことがありません。年末年始も、GWも、夏季休暇も。

 I have not missed a single day during all the weekdays and holidays in the last one and a half years. No New Year's holidays, no GW, no summer vacation.

時間の長短こそあれ、必ず、論文書いていますし、プログラミングをしていますし、データベースを作っています。

I am always writing papers, programming, and creating databases, no matter how long or short the working time.

『大学での研究は、労働ではない』と言われたら、もう仕方がないのですが。

If you say, 'Research at a university is not labor,' it cannot be helped anymore.

仕事と勉学の両立は「大変」ではありません ―― 「地獄」です。

Balancing work and study is not "hard" -- it is "hell.

-----

月1回でリリースしていたコラムは、今や完全休止状態です。

The column we used to release once a month is now wholly dormant.

コラムの執筆もも大変だったと思うのですが、コラムは、私の頭の中と計算結果を原稿の上にぶちまける、という作業でしたので、それなりに楽しかったと思います。

Writing the column was hard work, too, but it was fun because it was a process of putting my mind and the results of my calculations all over the manuscript.

多くの人に読んで貰って、色々な意見を貰えるのは、 ―― 腹の立つことも多いですが、嬉しいことも多いです。

To have so many people read it and get so many different opinions is a lot to be angry about, but it's also a lot to be happy about.

「コラムの執筆」と「勉学」は、同じようなものだと思っていたのですが、全く違いました。

I used to think that "writing a column" and "studying" were the same, but they were pretty different.

見積りを誤った、としか思えません。

I can only assume that the estimate was incorrect.

-----

"自分で選んだことをやっているなら、文句を言うな"

"If you are doing what you choose, don't complain."

"自分の"夢"の為にやっていることで、他人に迷惑をかけるな"

"Don't bother others with what you do for your 'dream.'"

これらは、絶対に反論できない定番の「世間のご意見」です。

These are standard "public opinions" that can never be refuted.

ただ、世間がどう言おうとも、この「自業自得の呪縛」―― 「サンクコストの呪い」で苦しんでいる人は、少なくない、と思っています。

However, no matter what the world says, many people suffer from this "curse of deservedness" - the "curse of sunk costs.

誰からも同情して貰えなくとも。

Even if I am not getting sympathy from anyone like me.

―― エジソン、バカ

2024,江端さんの忘備録

今回の震災で、マスコミ各局のレポータの皆さんが、現地からの報告を行って頂いております(特にNHK)。

Reporters from various media outlets have been reporting from the disaster site (especially NHK).

大変お疲れ様でございます。

Thank you very much for your hard work.

辛い現場をご覧になって、心底疲れられているものと、推察申し上げます。

I assume that you are genuinely exhausted after seeing the painful scene.

そのような、お疲れのところ、このようなことを申し上げるのは、大変心苦しいのですが、それでも一言申し上げたいと思います。

It pains me greatly to say this at such a weary time, but I would like to say something nonetheless.

―― 生中継のレポートでスマホを見ながら、その文面を読み上げるだけのレポートなら、それ、スマホの「音声AI」に読み上げさせればいいんじゃない?

"If it's a live report and you're just looking at your phone and reading the text of the report, why not just have the "voice AI" on your phone read that out loud?"

-----

私は、災害現場のレポーターというのは、災害現場の代弁者と思っています。

I consider a disaster site reporter to be the disaster site's voice.

ならば、現場の状態を言語化して、御自分の目で見て、御自分で感じたことを、御自分の選んだ言葉と、御自分の肉声でで語って頂くことこそが、その任務だと思います。

Then, I believe that you must verbalize the conditions on the ground, to speak what you see and feel with your own eyes, in your own words of your choosing, and in your voice.

もちろん「レポーターは役者ではない」というのであれば、それはそれで納得できます。

Of course, if you say reporters are not actors, that makes sense.

それなら、『スマホの音声AI機能』を使って、報告して頂いて結構です。

Then, you can use the "voice AI function of your smartphone" to report back to us.

しゃべる時間も、予定通りピッタリと収まるでしょう。

The speaking time will also fit perfectly into the schedule.

-----

ただ、私たち視聴者は、そういうものを聞きたい訳ではないのです。

But we, the viewers, do not want to hear those things.

現場を直接見た人の、肚の底から絞り出される、生きている人間の感情が入りつつも、それでも冷静に客観的な報告を行いつづける ―― そういう姿を見て、私たちは被災者の皆さんの状況に寄り添えると思うのです。

The person who saw the disaster site firsthand, who squeezed out from the depths of their heart the emotions of a living person, and yet continued to report calmly and objectively - I believe we can be close to the tragedy of the disaster victims by seeing this.

私に、報道のプロのレポータとしての技と矜持を見せて下さい。

Please show me the skill and pride of being a professional press reporter.

リビングのテレビをつけたら、アナウンサーが、恐しい声で避難を叫んでいました ―― 息も切れんばかりの勢いで。

2024,江端さんの忘備録

NHK紅白歌合戦の視聴率が、史上最低の30%になったとのことで、批判されいるようです。

NHK's Kohaku Uta Gassen has been criticized for its viewership ratings, which are at an all-time low of 30%.

でも、私は、"30%"って、結構、凄い数値だと思っています。

But I think "30%" is a pretty impressive figure.

だって、全世代向けの歌をメインとする番組ですよ。

Because it is a program that focuses on songs for all generations.

全世代向け歌番組というコンテンツ縛りで、30%を叩き出すなんて、たいしたものだと思います。

I think it's quite a feat to hit 30% for an all-generational singing program.

ちなみに、過去のNHK紅白歌合戦の最高視聴率は、1963年(昭和38年)の視聴率81.4%だそうです。これは、恐るべき数値です。

Incidentally, the highest viewership rating for NHK's Kohaku Uta Gassen in the past was 81.4% in 1963 (Showa 38). This is a frightening figure.

-----

私は、NHK紅白歌合戦を楽しく試聴するには、ちゃんとした「訓練」が必要で、さらには「才能」も必要であると思っています。

I believe proper "training" and even more "talent" are required to enjoy listening to NHK Kohaku Uta Gassen.

普段から、ちゃんと歌番組を繰り返し試聴し、自分の中で熟成させるだけの時間が必要になります。

You will usually need to listen to the song program properly and repeatedly and only allow time for it to mature in your mind.

これは、自分の時間を、テレビなどの歌番組などのメディアに費すことができる、いわゆる『時間富裕層』にのみ許された特権です。

This privilege is reserved for the so-called "time rich" who can spend their time on TV and other media such as singing shows.

つまり、NHK紅白歌合戦は、時間富裕層という特権的階級であって、楽曲を楽しめる楽曲リテラシーを有する、エリート向けの番組なんですよ。

In other words, NHK Kohaku Uta Gassen is a program for the elite, the privileged class of time-rich people with music literacy, to enjoy the songs.

NHK紅白歌合戦と同じ時間帯に行っていた、N響「第9」演奏会とクラシック名演・名舞台と同じ位置付けになっているのです。

It is in the same position as the NHK Symphony Orchestra's "9th" concert, classic masterpieces, and famous performances, which were held at the same time as the NHK Kohaku Uta Gassen.

つまりクラッシック音楽を楽しむ為には、クラッシック音楽のリテラシーが必要となるように、NHK紅白歌合戦を楽しむ為には、NHK紅白歌合戦のリテラシーが必要となる ―― そういう時代になったのだと思います。

In other words, just as classical music literacy is necessary to enjoy classical music, NHK Kohaku Uta Gassen literacy is required to enjoy the NHK Kohaku Uta Gassen -- I think we are in such an era now.

-----

私、録画で、YOASOBIの「アイドル」だけ見ました(それしか、知っている楽曲がなかったので)。

On the recording, I only watched "Idol" by YOASOBI (since that was the only song I knew).

私がティーンエイジャだったころ、バックダンサーやっていたアイドルたちは、実にヘラヘラした踊りをしていました(だいたい歌が下手で聞いていられなかった)が、今のアイドルって、本当に凄いんですね。

When I was a teenager, the idols who were backup dancers were goofy dancers (and usually sang so badly that I couldn't even listen to them).

精錬されたパフォーマンスを楽しませて頂きました。

I enjoyed the refined performance.

アイドルという名のプロの矜持を見せつけられた気がします。

I feel like I was shown the pride of being a professional in the name of an idol.

この多様性を理解するためには、私自身が『アイドルの追っかけ』に参入しなければならない、と。

2024,江端さんの忘備録

震災になると、物資が来ないだけでなく、水もガスも来なくなります。

When the earthquake strikes, not only will supplies not come, but also water and gas will not come.

せめて情報だけでも入手したいと思っても、電気が来ないので、テレビは使えません。インターネットは言うまでもありません。

Even if you want to get some information, you cannot use the TV because there is no electricity. Not to mention the Internet. Smartphones are just a matter of time.

私は、一応、手回し発電機を入手しています。

I am getting a hand-cranked generator.

残った情報取得手段は、ラジオくらいですが、数年前に購入したラジオは、多分、電池から液漏れを起こしていて、動かなくなっています(あれは、定期的にスイッチを入れないと、ダメなものなのです)。

The only remaining means of obtaining information is a radio. Still, the radio I bought a few years ago has probably stopped working because the batteries are leaking (that thing is no good unless you turn it on regularly).

しかし、電源不要で、半永久に動き続けるラジオというものがあります。

However, some radios do not require a power source and work semi-permanently.

「ゲルマニウムラジオ」です。

"Germanium Radio."

受信アンテナからのラジオ波をゲルマニウムダイオード(整流器)を使用して検波し、それによって音声信号を取り出します。つまり、電源供給が不要で、単にアンテナとスピーカー(またはヘッドフォン)を接続するだけで動作します。

Radio waves from the receiving antenna are detected using a germanium diode (rectifier), extracting the audio signal. This means no power supply is required; simply connecting the antenna and speakers (or headphones) is all that is needed to operate.

基本的には検波が簡単なAM放送に使われますが、災害情報は、現時点ではNHKラジオ放送だけが頼りです。

It is used for AM broadcasts, which are easier to detect, but NHK radio broadcasts are the only reliable source for disaster information.

(ちょっと驚いたのですが、無電源のFMラジオを試している方がいらっしゃるようです)

(I was surprised that some people are trying out the powerless FM radio.)

私がNHK受信料を支払っている理由の一つには、この「災害情報インフラへの継続的投資」があります。

One of the reasons I pay NHK subscription fees is this "ongoing investment in disaster information infrastructure."

個人的な見解ですが、我が家のNHK受信料の支払いは、ある種の保険料であって、災害大国日本では、十分に『元が取れている』と思っています。

In my opinion, the NHK subscription fee paid by my family is a kind of insurance premium, and in Japan, a disaster-prone country, I believe it is well "paid for."

-----

ゲルマニウムラジオを製品化して販売した売れるんじゃないかな、と思っているのですが、見つけられていません。

I think a Germanium radio could be commercialized and sold, but I have not found one.

(子どもの科学向けのキットがありますが、ちゃんとパッケージ化された製品は見つかりません)。

(There are kits for children's science, but I can't find an adequately packaged product.)

まあ、あまり利益が出せそうにはないのですが。

Well, it is not going to be very profitable.

私なら、そのラジオを、天井の火災報知器の横に貼りつけておきます。

I would stick that radio following the fire alarm in the ceiling.

-----

そういう訳で、私、NHKラジオ第1・第2の統合は良いと思っているのですが、FM局への全転換は、よくよく考えた方が良いと思っています。

Integrating NHK Radio 1 and 2 is a good idea, but the total conversion to an FM station should be well thought out.

もう一度、あの日の恐怖を思い出してみましょう。

 

 

未分類

先日国会で成立した、国土強靭化基本法を熟読しています。

I read letters of the law named "Basic Law of National Land Enhancement."

一見無味乾燥な法令に見えますが、これは読み方によっては、とても面白いです。

At first glance, it looks like monotony law, but it is exciting from another perspective.

「省庁の縦割りを解消し」などという識者もいるようですが、私は、まったく逆に「縦割りを明文化した」というくらいに読めました(第11条~21条)。

Though some analysts tell us that this law results in compartmentalized public administration, I think it is the opposite; the law defines it.

私は、シミュレーション結果で、100年後に現在の人口の20%にまで落ち込むと予想しているので、人口を大都市に集中して社会インフラを集結することを考えていました。

I estimate that the population in Japan has decreased by 20% from the present after 100 years ago. I am afraid we must migrate to urban areas and integrate social infrastructures.

つまり、「地域を切り捨てる」しか日本が生き残る道はない、と思っていたのですが、この法律では、完全にその逆を唱えています(第2条:多極分散型の国土の形成)。

I mean, "Discarding rural areas." I think it is a final decision to survive in this country. But this law says the opposition against my opinion(Article 2: multiple cities)

といいつつ、その分散を3つに定義しています。具体的には、(1)首都圏、(2)近畿圏、(3)中部圏です(第8条)。

On the other hand, the law also defines the three decentralized areas: "Tokyo Metropolitan District," "Osaka Metropolitan District," and "Chuubu Metropolitan District"(Article 8).

―― という話を、後輩にしたところ、

I told the above issue to a junior fellow,

後輩:「江端さん。そりゃ分散のアプローチが間違っていませんか? 南海トラフで、その3つの分散は、纏めて全滅ですよ」

Ebata-san, I think there seems to be a wrong approach. The big earthquake in the Pacific zone will hit the three areas at the same time.

江端:「ま、一気に撃たれることはない、という見込みなのだろうと思う。でも、災害を想定した本当に分散する気があるなら、札幌圏、首都圏、高松圏、福岡圏の4つかなぁ」

Probably, I think they estimate not to do it simultaneously. If I were an administration, I would define four areas, "Sapporo," "Tokyo," "Takamatsu," and "Fukuoka."

まあ、「地域を捨てる」などという方針が出たとすれば、法案が潰されるのは当然として、政権与党の存続だって危ういだろうな、とは思うのです。

If "discarding rural areas" were included in the law, the Diet refused the bill and upset the regime.

それに、まだ「地域を切り捨てる」という決断をするには早いかもしれません。少子化の問題だって、何かの奇跡が起きて、持ち直すかもしれないじゃないですか ―― その奇跡に、全く心辺りがないとしても、です。

And it seems to be too early to judge it. The problem of a society with fewer children might be resolved in some miracle works -- I don't know them at all.

-----

なぜ、このような法律を調べているかというと、災害時を想定したシステムの提案資料を作る為です。

I investigated the law to make a proposal material for the system against some kinksters in Japan maJapan'sd.

で、その他の資料も色々見付けているのですが、これはいいですよ。是非御一読を。

I strongly encourage you to read the following paper.

その辺の小説より、ドキドキできます。

You must be excited, more than crisis novels around you.

-----

特に、地震直後に、停電→テレビ・ラジオ・PC全滅→情報ゼロ という状況は、リアルです。

Significantly, the story of a blackout, inactivate of TV, radio, and PC, and no information is authentic.

震災の時も、電池式のラジオだけが、最後の砦でした。

The cell radio is the last straw on the day of the earthquake disaster.

これも何かの機会です。もう一度、あの日の恐怖を思い出してみましょう。

This is a good change. Let us try to remember the fear of the day.

2023,江端さんの技術メモ

以下のtest.csvファイルを、gunplotで3D表示させたくて、色々やっています。

test.csv
#lat,lng,datetime,distance,speed
35.681100,139.758600,2023-05-22 02:10:30,313.307785,37.596934
35.683300,139.759900,2023-05-22 02:11:00,271.347933,32.561752
35.685300,139.760900,2023-05-22 02:11:30,240.030143,28.803617
35.685400,139.761000,2023-05-22 02:12:00,14.325264,1.719032
35.685400,139.761000,2023-05-22 02:12:30,0.000000,0.000000
35.685400,139.761100,2023-05-22 02:13:00,9.031610,1.083793
35.685200,139.763500,2023-05-22 02:13:30,217.896760,26.147611
35.684700,139.765700,2023-05-22 02:14:00,206.328362,24.759403
35.684200,139.768000,2023-05-22 02:14:30,215.040983,25.804918
35.685400,139.768400,2023-05-22 02:15:00,138.238013,16.588562

で、まあ、こんなgpファイルを使って試していましたが、上手く動きませんでした。

# Function to parse datetime string into a numerical value
strptime_datetime(x) = strptime('%Y-%m-%d %H:%M:%S', x)

# Set the output terminal to a 3D plot (you can change the output format if needed)
set terminal pngcairo enhanced size 800,600

# Set the data file separator to a comma
set datafile separator ','

# Set the axis labels
set xlabel 'Longitude (lng)'
set ylabel 'Latitude (lat)'
set zlabel 'Date and Time (datetime)'

# Set the view to a 3D perspective
set view 50,30,1,1


# Get the minimum and maximum datetime values from the data
stats 'test.csv' using (strptime_datetime(stringcolumn(3))) nooutput
min_datetime = STATS_min
max_datetime = STATS_max

# Set the range for the Z axis (datetime)
set zrange [min_datetime:max_datetime]

# Plot the data using the specified columns
#splot 'test.csv' using 2:1:(timecolumn(stringcolumn(3))) with points pointtype 7 pointsize 1 title 'Data Points'
#splot 'test.csv' using 2:1:(timecolumn(stringcolumn(3))) with points pointtype 7 pointsize 1 title 'Data Points'
#splot 'test.csv' using 2:1:(timecolumn(stringcolumn(3))):(0) with points pointtype 7 pointsize 1 title 'Data Points'

splot 'test.csv' using 2:1:(timecolumn(stringcolumn(3)))

時間のパース(strptime_datetime(x) = strptime('%Y-%m-%d %H:%M:%S', x))がやっぱり上手く動きませんでした。

でまあ、しょうがないので、"2023-05-22 02:10:30"を秒数に変換するプログラムを作成しました。

/* "2023-05-22 02:10:30"を秒数に変換するプログラムを作成しました
   c:\Users\ebata\gnuplot\convert_datetime.go
*/
package main

import (
	"encoding/csv"
	"fmt"
	"os"
	"time"
)

func main() {
	// 入力ファイル名と出力ファイル名を指定
	inputFileName := "test.csv"
	outputFileName := "formatted_test.csv"

	// 入力ファイルを開く
	inputFile, err := os.Open(inputFileName)
	if err != nil {
		fmt.Println("ファイルを開けませんでした:", err)
		return
	}
	defer inputFile.Close()

	// 出力ファイルを作成または上書き
	outputFile, err := os.Create(outputFileName)
	if err != nil {
		fmt.Println("ファイルを作成できませんでした:", err)
		return
	}
	defer outputFile.Close()

	// CSVリーダーとライターを作成
	reader := csv.NewReader(inputFile)
	writer := csv.NewWriter(outputFile)

	// ヘッダーを読み込み、書き込み
	header, err := reader.Read()
	if err != nil {
		fmt.Println("ヘッダーを読み込めませんでした:", err)
		return
	}
	writer.Write(header)

	// データを読み込んで秒数に変換して書き込み
	for {
		record, err := reader.Read()
		if err != nil {
			break
		}

		// datetime列をパースして秒数に変換
		datetime := record[2] // datetime列のインデックスを確認してください
		parsedTime, err := time.Parse("2006-01-02 15:04:05", datetime)
		if err != nil {
			fmt.Println("日時をパースできませんでした:", err)
			return
		}
		seconds := parsedTime.Unix()

		// 秒数に変換した値を新しい列として書き込み
		record = append(record, fmt.Sprintf("%d", seconds))
		writer.Write(record)
	}

	// ライターをフラッシュしてクローズ
	writer.Flush()

	if err := writer.Error(); err != nil {
		fmt.Println("書き込みエラー:", err)
		return
	}

	fmt.Println("変換が完了しました。出力ファイル:", outputFileName)
}

で、こんなのができました。
formatted_test.csv

#lat,lng,datetime,distance,speed
35.681100,139.758600,2023-05-22 02:10:30,313.307785,37.596934,1684721430
35.683300,139.759900,2023-05-22 02:11:00,271.347933,32.561752,1684721460
35.685300,139.760900,2023-05-22 02:11:30,240.030143,28.803617,1684721490
35.685400,139.761000,2023-05-22 02:12:00,14.325264,1.719032,1684721520
35.685400,139.761000,2023-05-22 02:12:30,0.000000,0.000000,1684721550
35.685400,139.761100,2023-05-22 02:13:00,9.031610,1.083793,1684721580
35.685200,139.763500,2023-05-22 02:13:30,217.896760,26.147611,1684721610
35.684700,139.765700,2023-05-22 02:14:00,206.328362,24.759403,1684721640

スクリプトではなく、コマンドで一つづつ入れていきました。

gnuplot> set datafile separator ','   ← これ凄く重要
gnuplot> splot "formatted_test.csv" using 2:1:6
の結果は以下の通りでした。

エリア限定
# x軸の範囲を指定
set xrange [139.6119000:139.6312000]

# y軸の範囲を指定
set yrange [35.3627000:35.3737000] ←これだと、地図のイメージと逆転するので
set yrange [35.3737000:35.3627000]  ← y軸の範囲を逆転させる

上記のxrangeとyrangeの範囲を地図で示すと、

の範囲となる。
領域の範囲内でのトラッキングデータの様子

gnuplotでx軸とy軸の範囲を指定解除するには、以下のコマンドを使用する。

gnuplot> set xrange [*:*]
gnuplot> set yrange [*:*]

gnuplot> splot "2023-topLatLngCounts4-1.csv" using 2:1:3
gnuplot> set yrange [35.3737000:35.3627000]    ← 軸の大小を引っくり返す
gnuplot> splot "2023-topLatLngCounts4-1.csv" using 2:1:3 ← 点を表示
gnuplot> replot "2023-topLatLngCounts4-1.csv" using 2:1:3 with impulses ← 縦軸表示

ちなみに、文字列が入っているcsvだと表示されないことが多いようだ。