2013年4月29日月曜日

明日の天気を過去の似た日から合成して可視化してみよう

in one word...

明日の気象予報値(気温、気圧、降水、雲量など)に一番似ている過去の時間を検索し、その時撮られたベランダからの定点観測画像を表示することで、明日の天気を分かりやすく可視化する試みです。


明日の予報を過去画像から合成して可視化する
(左端が5時、右端が21時)

概要

GWなので色々作ろう第一弾です。
最近は気象予報技術の進歩が目覚ましく、明日の天気予報ならばそこそこ信用できるようになってきています。
一方で、天気の伝え方はいつまでも進化がありません。

例えば明日の天気は「晴後曇、最高気温21℃、最低気温12℃、南の風やや強く」だそうですが、これだけ見ても明日の具体的なイメージは湧いてきません。
天気予報はよう分からん
  • 晴れってどれぐらい、いつまで晴れるの?
  • 曇りって、花見が楽しめないぐらいに曇るの?日は射さないの?
  • やや強い風ってなによ
例えばこんなデバイスを使って天気予報を実感させる試みとかも以前に行ったわけですが、

もっと手っ取り早い方法として、今回は「過去の似た気象状態」の画像を合成することで明日の天気予報を分かりやすく可視化してみよう、という実験です。

方法

ステップ1: ベランダ定点観測写真データ
うちのベランダから武蔵国分寺公園に向けて2011年4月以降、ほぼ無間欠に30秒置きに写真を撮っています。

街の長期的な変化や・・・
予期していない気象イベント(黄砂)など・・・
色々なものが撮られてきました。

これと、その時の気象データを紐づければ、
 どんな気象状況(天気、気圧、雲量・・・)の時に、
 どんな景色(空模様、木のなびき方、明るさ・・・)か、
というデータが作れるわけです。

ステップ2: GSM全球数値予報データ
気象庁が6時間毎に発行する、地球を20kmグリッドに分け、先84時間の1時間毎の気象状況を予報したデータです。
内容としては:
  • 気温
  • 気圧
  • 湿度
  • 雲量(低層/中層/高層)
  • 雨量
  • 風向き/風力
等が含まれます。

(↓こんな感じ)

このデータから、過去のベランダ写真に気象状況の数値(9次元のベクトル)を割当て、
さらに明日の気象予報値を取得します。

ステップ3: Nearest Neighbourで似た状況を探す
次に、明日の各時刻における気象予報値(9次元のベクトル)と、それぞれ最もよく似た過去の瞬間を検索します。
今回は、KD木を使います。
木は時刻毎に別に作りましょう。
検索時間はベンチマークしてませんが、一瞬です。

ステップ4: 合成する
合成といっても大したことするわけじゃありません。
こうやって一時間毎に並べてみたり:
明日の予報画像
ちょっと凝った出し方をしたりします:
明日の予報画像:左から右に向けて時間の流れを表す
ちなみに、マッチングは時刻毎に行われているので、時刻によって持ってくる日が違ったりします。
冬なのに春なみの暖かい昼があったりすると、唐突に桜が咲いてたりもします。


分かりやすくなったか?

過去の日で、実際に撮影された画像と合成した画像を比べてみた
■2012/12/22 (雨のち晴れの日)
実測画像
合成:朝は雨が降ってて
夕方から日が射しつつも高層雲が
出てる感じは再現できてる
 ■2012/08/13(全日晴れの日)

実測
合成:朝は遠くに層雲が見えていて、
昼以降は気持ちのよい積雲が
ポツポツしている感じは実装とそっくり。














■2013/02/06(朝は雪の日)


実測
合成:ちゃんと雪も再現できているのが喜ばしい
(気温が低くて雨量が存在したから?)










好きな天気ジェネレータ

気象状況を入力すると、似た時の景色が観察できるツール。気象の勉強に使えますかね。


高層雲だけの日
雲たくさん、雨降ってる日






低層雲だけある日
雲たくさん、風強い
雲のない、寒めの日
















まとめ

・こんなに少ない気象状況の数値をマッチングさせるだけでも、視覚的にそこそこ納得間のある景観予測ができた
・景色のどういう特徴にどういう値が効いているのかは要調査。
 雪: 雨量+気温?(でも高層の温度までは特徴量に入れてない)
雲形: 雲量+気圧傾度+湿度?
・他にどういう情報を入れたらより再現性が増すだろう?
・暇を見つけてウェブサービス化しよう。




2013年4月6日土曜日

Short Note on the Use of Twitter for Demonstrating Link between Headaches and Low Barometric Pressure

Background


The link between headaches and barometric pressure is frequently stated in daily conversations, yet few studies have given conclusive evidence correlating the two.

  • Mukamal et al [1] studied records of 7054 patients seen over a 7 year period in a hospital emergency department with a primary discharge diagnosis of headache, concluding that high ambient temperature and low barometric pressure led to a significant increase in the risk of headache requiring emergency department evaluation
  • ...and many others to do with migrane tbf.
The scope of many of these studies is limited to the link between barometric pressure and severe migrane cases requiring medical attention, in part due to the availability of such medical diagnostic records.  No studies in the past have targeted cases of light to moderate headaches that previously would have passed unrecorded in medical data repositories.

Objectives
The purpose of this study is to determine the correlation between barometric pressure and cases of self-reported headaches.

Methods
Collection of headache self-reports
  We collected self reports of headaches by scraping tweets containing the keyword “頭痛” (headache) originating in Japan between 2013/3/23~2013/4/6 (13 days).  This dataset contains 262587 tweets, with about an average of 19000 headache tweets per day.  We were unable to collect data from some times within this period due to technical difficulties.  Fig1 shows the number of occurrence of headache tweets for every hour in the time period.  Note that the geographical distribution of tweets inside Japan is unknown, since most tweets do not contain location data finer than country level.


The number of tweets has a circadian rhythm that rises steadily from 5 in the morning to a peak at midnight (Fig2).  
By normalizing the raw number of tweets by this hourly average and standard deviation, we derive the normalized headache risk which, intuitively, tells us how much more headache tweets there were in that hour than usual.




Collection of barometric pressure data
  We collected barometric pressure data from the Japan Meteorological Agency website.  For our study, we use the hourly sea-level pressure data for Tokyo (lat: 35.69 lng: 139.76

We compare the absolute value of the barometric pressure with the number of tweets, as well as the change in the barometric pressure over a time window (the gradient of the pressure curve for the past n hours).  Fig.5 shows the differential over the past 12 hours, an arbitrarily chosen time window.




Results

We compare the barometric pressure with the normalized number of tweets for every hour, and calculate the correlation for n=262 points.
○ Absolute pressure vs normalized number of tweets
 We only found very weak negative correlation (R=-0.19, p<0.01). 

○ Change in pressure vs normalized number of tweets
  Comparing the change in pressure over the past 12 hours with the relative number of headache tweets, we found moderate negative correlation (R=-0.31, p<0.001)

Discussion+Results

  While the correlation is relatively low, this result suggests that increase in the occurrence of headaches is related to the decrease of barometric pressure, while it is less related to the actual value of the pressure.  These findings agree with previous findings[1].
  or something.


References
[1] Kenneth J. Mukamal, MD, Gregory A. Wellenius, ScD, Helen H. Suh, ScD and Murray A. Mittleman, MD, DrPH, Weather and air pollution as triggers of severe headaches, Neurology March 10, 2009 vol. 72 no. 10 922-927

2012年11月15日木曜日

Prototyping "Tempescope", an ambient weather display

(Updated 2013/5/5: A new opensourced version of Tempescope is available here: http://tempescope.com !!!)



The Objective

Finding out tomorrow's weather forecast usually involves actively searching on the web, waiting on the news channel, or resorting to widgets.
How great would it be if this was as easy as looking outside the window?
This thought led me to build Tempescope, a physical display that can reproduce (and ambiently notify) weather conditions, inside your room.
Tempescope fits snuggly in your bookeshelf.

The Prototype

After several weekends' work, I ended up with this prototype which can simulate four weather conditions: rain, clouds, sunshine, and lightning.
It can also reproduce various colours of the sky, giving visual cues for the time of day.

Clouds
Lightning
Sunrise!
Rain

The device is controlled by an Arduino, which interfaces with a PC via USB or Bluetooth.
There are currently two modes of operation, both of which run as PC programs:
"World Weather" mode interface
© OpenStreetMap contributors
"Tomorrow's weather"- which animates tomorrow's weather forecast, and
"World weather"- which reproduces the current weather of any location in the world.

While the former is what I originally intended to make, the latter may be what makes Tempescope interesting, and really worth working on in the future.
One can view the device as containing a teleported slice of a remote world, a little Barbados in your room.
It paves a way for all sorts of applications, some nostalgic (e.g have a slice of your hometown in your office), and some practical (e.g watching out for your loved ones halfway across the globe).

There are many extensions that I could make on the device, including snow, wind, real lightning, and showing land features.
I'd be grateful for opinions, or suggestions for uses.

Some References

There are several past projects/ideas I believe I'd been inspired by:
    • A light stand that changes colour according to tomorrow's weather lookouts.
    • An aluminium cube that reproduces the temperature outside, giving a haptic feedback for the weather.
  • Bonsai
    • A 1000 year old example of having "a piece of wild nature in your room".


The Making

Mechanics

Weather conditions are reproduced by using 2 pumps, an ultrasound diffuser, and an LED:
  • rain- the water pump pushes water from the lower chamber to the upper chamber, allowing water to fall through holes drilled at the bottom of the chamber.
  • cloud- the ultrasound diffuser in the lower chamber turns on, creating mist.  An external air pump pushes air (and mist) up from the lower chamber into the cylinder stage.
  • lightning- the full-color LED is turned on at random intervals
  • sunlight- the full-color LED changes colour from off to red to blueish white, depending on the time of day.
Electronics
The electronics involved is not very much: an Arduino Uno controlling 3 SSRs and a full-color LED.
There is also attached an SD card, which allows animation sequences to be saved and replayed without a PC.


Arduino and 3xSSRs
AC electronics (moderately) safely packaged
The final product
















Here's the list of hardware used:

  • Ultrasonic Diffuser (Denshi Trade) ¥3,500=$43 


  • Water pump e-ROKA PF-381 (Gex) ¥1000=$12 


  • Air pump Ei (Kotobuki) ¥1000=$12



Software
Arduino side: also not very much, though saving+loading from SD card takes some work

PC side:
Both modes of operation ("Tomorrow's weather" and "World weather") are based on data acquired from Wunderground's API.
This API allows requesting the current weather, or forecasted weather from global coordinates.
Both apps have been written as a Java application, but really anything would suffice.

Again, I'd be grateful for feedback.
Ken
@kenkawakenkenke
2012/11/15

2012年11月13日火曜日

優しく天気を教えてくれるアンビエントディスプレイ「Tempescope」を作ってみた

はじめに

最近気象予報の勉強をする中で、日常生活で天気予報を知る手段について考えるようになりました。
明日の天気を知るためには気象庁のページを調べたり、ニュースの時間を待ったりなど様々な手段が現在でも用意されていますが、
「窓の外を見てみる」ぐらいの簡便さで明日の天気も分かればいいのになぁ、と考えて始めたのがこのプロジェクトです。

天候を小さな箱に再現し、インテリアの一部としてそれとなく明日の天気を教えてくれる(ことを目指した)Tempescopeを紹介します。



従来技術

多分こういった先人達から発想を受けた気がします:
  • 天気図つ- @endorno, @yuki_B, @include_bababa
    • クックパッドの24時間コンテスト入賞作品、明日の天気予報を光で再生してくれる素敵なオブジェ。
  • cryoscope- Robb Godshaw
    • 外の気温を「再生」してくれるオブジェ。触ると外の気温が分かる。超おしゃれ。
  • Rain Room- Random International
    • 雨が降り注ぐ部屋。入っている人の位置を検知して、雨が人にあたらないように制御するっつー素敵なアート。スケールが違うけど、天気を室内に持ってくるという意味では同じ。
  • 箱庭盆栽
    • 大自然をミニチュア化して、自分の制御出来る形にして上から眺める、というところの面白さのルーツはこういうとこですよね。

作成イメージ

箱庭的な感じで箱の中に雨、雲などのリアルな気象状況を再現し、PCやスマホ経由で制御できるようにすることで天気予報を再生したり、その他のアプリと連携させる。
それぞれの気象状況はこんな方法で再現する:
  • - 水中ポンプで水をくみ上げて、上から降らせる
  • - 霧発生装置
  • 日照- フルカラーLEDで日照量や、夕焼けの色を再現
  • - LEDを点滅させる。(放電とかバチバチ出来ないだろうか。。?)

開発

材料
合計:¥7063

構成
Tempescope(塗装前)の構造
右図のような構造。
下部ケースに水が溜まっていて、水中ポンプと霧発生モジュールが浸かっている。上部ケースにはポンプに繋がったチューブとLEDが入っており、ポンプが駆動すると水が上部ケースにくみ上げられ、開けられた穴を通じて雨が降る仕組み。

  • 曇り下部ケースの霧発生装置を駆動しただけでは、霧がシャンプーボトルまで達しない(空気の流れ自体はないため)ため、どうにかして下部ケースの内圧を上げる必要がある。5Vで動くファンも実験したのだが、パワー不足のため使えなかった。結局手元に転がっていた外部電源のエアーポンプで空気を下部ケースに送り込み、内圧を上げて霧をシャンプーボトルまで送り込む方式にした。これは騒音が大きく、外部装置も大きくなるため次回は霧発生装置を上部ケースに置くことも検討したい。ちなみに曇り状態が解除されたあと、一分ほどエアポンプを駆動させておき、霧を流すという制御もしている。
  • :水中ポンプのみを動かし、上部ケースに水をくみ上げて雨を降らせる。
  • 日照:フルカラーLEDの色と輝度を変化させて、昼と夜、夕焼けなどを表現する。(動画00:13)
  • :フルカラーLEDをランダムにフラッシュさせる(動画00:05)
ポンプ2種、霧発生体はSSR経由でArduinoから制御される。

作った
  • プロトなので、ケース類は超適当に接着した。
  • 水をかぶる部分は若干気を使って、風呂用の充填材等で固めた。
  • 回路は適当。AC回路だけは露出部がないように固めまくってプラケースに納める。
塗る。
塗装完了。100均臭は簡単には消えない。
電子制御関係は全て100均のクリアボックスに
納めた。AC電源の回路だけ二重に保護。



























完成。本棚にだって置けるよ。













ソフト:Arduino側
シリアルで雨の有無、雷の有無、照明の具合などを受け取ってコントロールするだけ。特に難しいことはない

ソフト:PC側
今のところ2つのアプリを作った:

  • 明日の天気再生アプリ
    • WundergroundのAPIで現在地の次24時間の天気予報がとってこれる。これに基づき一日の天気をTempescopeで再生。
  • 世界の天気アプリ
    • 地図上の位置がクリックされると、Wundergroundから位置情報に紐ついた天気をとってきてTempescopeに送る。
    世界の天気コントローラ © OpenStreetMap contributors


で、冒頭の動画みたいになります。

考察とか今後やることとか


  • アンビエントに天気を知る、という意味では目的は達成出来ている。インテリアとしても結構素敵だと思う。ただ、いくつかの細かい問題のせいで常時ONにしておくには至っていない:
    • 動作音がうるさい。雨降らせる時ポンプが空回りしてビビる。
    • 外部装置がでかい。
    • 水とAC電源を扱う装置なので、目を離すのが怖い。
  • アプリとして、色々作ったら楽しい気がする
    • デジタルフォトスタンドの隣に置いて、表示してる写真を撮影したときの天気を再生するとか
    • Skypeで話している相手の天気を表示して、「一緒に居る感」を出すとか
    • ずっとサイパンの天気を再生しておいて、海行きたい気持ちをもてあそぶとか
  • 雪も降らせたい! →水凍らせる?霧使って疑似雪みたいなの出来ないかな。
  • 稲妻バチバチ出したい! →アーク放電!
  • 風吹かせたい! →空気吹き込むだけだけど、雲や雨が無いときの表現は難しい。
  • 今のところ雲量や雨量の制御はしていない。雨量は簡単だが、雲量は難しい?出てる霧の量をセンシングする手段を設けないといけない?
  • 小さくしたい。できればUSBだけで動かせる装置にしたい。
  • ¥7000はちと高い。Arduinoは実際は色々安い代替があるし、エアポンプは要らない構成にも出来るので、もう¥2000ぐらいは安く出来る。誰か初号期買い取ってくれたらもっと安く作れるよ。

以上。
ken 12/11/13