2011年12月19日 星期一

calling GNUPLOT from a c++ program

calling GNUPLOT from a c++ program
  • 底下透過popen() 進行,但在windows系統下,僅console application能夠用,欲在windows application 下執行,不能用popen() ,詳細請看最後面的Note說明
  • 欲在windows application 下執行,最簡單的方法還是將gnuplot 指令輸出成一個檔案,再用system () 呼叫



class GNUplot {
public:
GNUplot() throw(string);
~GNUplot();
void operator ()(const string& command);
// send any command to gnuplot
protected:
FILE *gnuplotpipe;
};

GNUplot::GNUplot() throw(string) {
gnuplotpipe=popen("gnuplot","w");
if (!gnuplotpipe) {
throw("Gnuplot not found !");
}
}

GNUplot::~GNUplot() {
fprintf(gnuplotpipe,"exit\n");
pclose(gnuplotpipe);
}

void GNUplot:operator() (const string& command) {
fprintf(gnuplotpipe,"%s\n",command.c_str());
fflush(gnuplotpipe);
// flush is necessary, nothing gets plotted else
};


You simply construct one object and invoke it with operator () like

GNUplot plotter;
plotter("plot sin(x)");

Note that GNUplot will be killed as soon as your program terminates. So
you need to wait for keystroke or similar, otherwise you will only see
short flashing of the graph. If you need that the graph window stays on
screen after your pragram fnished, then instead of "gnuplot" in the
constructor invoke "gnuplot -persist".


Ref.
http://www.velocityreviews.com/forums/t278698-calling-gnuplot-from-a-c-program.html
http://nxforce.blogspot.com/2008/07/cc-calling-gnuplot-in-c.html


Note Note
If used in a Windows program, the _popen function returns an invalid file pointer that causes the program to stop responding indefinitely. _popen works properly in a console application. To create a Windows application that redirects input and output, see Creating a Child Process with Redirected Input and Output in the Windows SDK.

  • _popen()
http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28POPEN%29;k%28DevLang-%22C%2B%2B%22%29;k%28TargetOS-WINDOWS%29&rd=true

  • C++ interface to Gnuplot via POSIX pipes
http://code.google.com/p/gnuplot-cpp/
此方法還是一樣用_popen(), windows program 可能不適用

  • 欲在 windows application中呼叫gnuplot 請參考底下這篇
http://code10111.blogspot.com/2011/06/call-gnuplot-from-c-program-in-windows.html
他的做法跟  Creating a Child Process with Redirected Input and Output 有些雷同




2011年11月3日 星期四

Garmisch 到 Linderhof, Fussen


 Garmisch 有 RVO公車可以坐到 Fussen (新天鵝堡), 或坐到Linderhof (林達霍夫宮),但班次不多,要事先查好,RVO公車 Bayern ticket可以用,或買RVO一日票,Bayern ticket在DB火車站自動售票機買,RVO車票上車跟司機買

  • Garmisch 往返Fussen 都坐9606





  • Garmisch要到Linderhof,要先坐9606 到 Oberammergau,在公車站換  9622 就可以坐到 Linderhof









慕尼黑機場到市區


機場到市中心最方便的方法是坐軌道交通S-Bahn (S1及S8都可以),約40分鐘。順著S的標記就可找到(車站是地下的)大約10分鐘左右就有一班車可以坐到市中心,慕尼黑機場在13圈,機場到市區要跨4 zones
根據下面票價表機場到市區的車票單程10歐/ 人,但可以考慮買全區的Day Ticket 10.8歐/人,人多的話可買Partner Day Ticket 19.6歐一起共用(五人以內)。

市區到慕尼黑機場︰
 
價格同上。S1/S8由於在市區的行駛方向是對向的,也就是去機場方向S1和S8是相反的,注意站台的目的地標記,別坐錯了。其中S1到了Neufahrn 後會分成2段,前段駛向Freising,後段去機場,注意車箱上方的顯示板, 顯示是往Freising, 還是開往機場 Flughafen Munchen。所以如果你坐S1,要留心車廂上的標記,S8 則没有這種困擾直達機場 

慕尼黑有三個火車站,最主要的當然是中央車站Hauptbahnhof / 縮寫HBF。另外還有Pasing火車站和火車站Ostbahnhof,買車票的時候看清楚自己是在哪個站,別弄錯了。

市區交通
慕尼黑市區的交通由MVV公司經營,所有關於慕尼黑市內交通的訊息都能在MVV網上找到


慕尼黑以古城區為中心向城外被劃分為四個zones, 每個zone 再分為四個 circles,總共有16 circles
Before purchasing your Single Ticket (Einzelfahrkarte) you need to know the exact number of zones. This ticket is available for one, two, three or four zones.

例如: 
慕尼黑機場在13圈,機場到市區要跨4 zones,根據下面票價表機場到市區的車票單程10歐/ 人,但可以考慮買全區的Day Ticket 10.8歐/人,人多的話可買Partner Day Ticket 19.6歐一起共用(五人以內)。

Nymphenburg 在  inner district (Innenraum) ,如果只是要在 inner district活動,可以買 Day ticket, 單人5.4, 團體 9.8

所以可以看當天要到的地方在那一圈然後買包含那一圈的日票
以下價格為 December 2010公布僅供參考,實際價格請看MVV網站比較準
Partner Day Ticket 為團體票,最多五人

Single Ticket fares

Number of zonesCashless PaymentFares
12,40 €2,50 €
24,80 €5,00 €
37,20 €7,50 €
4 and more9,60 €10,00 €
  

Day Tickets fares

Type of ticketFares for Single Day Ticket - adultsFares for Single Day Ticket - childrenFares for Partner Day Ticket - adults
Inner District (Innenraum) - white zone5,40 €-9,80 €
Munich XXL (München XXL) - white and green zone7,30 €-12,80 €
Outer District (Außenraum) - green, yellow and red zone5,40 €-9,80 €
Entire Network (Gesamtnetz) - all four zones10,80 €2,60 €19,60 €
3 Days Inner District - white zone13,30 €-22,80 €

 
買票也可以用DB的自動販賣機買,選右下角MVV 就可以了


Ref. 
http://www.wretch.cc/blog/yichin5/9039978
http://www.mvv-muenchen.de/

2011年10月21日 星期五

Salzburg 冰洞 Eisriesenwelt Werfen

Eisriesenwelt Werfen 官方網站 http://www.eisriesenwelt.at



Opening times
Caves and cable-car service: daily from 1. May to 26. October. Opening times : 9.00 - 15.30 (last guided tour) or 16.30 (last guided tour in July and August). Tours last 75 minutes. Visitors should allow 3-4 hours for the whole visit.

Photography (冰洞不能拍照)
Both photography and filming are forbidden, but it should be mentioned here that this is not to increase postcard sales, but is for organisational reasons and an attempt to preserve the original character of the caves. 

交通
由薩爾茲堡搭火車到Werfen 約40分鐘,出火車站直走過橋,看到指標,往右邊河岸小路一直走,大概五分鐘就到停車場(就是上圖最下面的P),然後就有小巴士在那邊等了(大概25min一班),上車買票,票是來回的,要注意下山的最後一班車時間,Bus開約20分鐘直接載到冰洞售票口(上圖 "i"的位置),買票進去,接著就得靠著雙腳爬山(20min),換纜車(票要有含纜車才能坐),之後再爬20min 就到冰洞了,接著等導覽員來接你進去,然後又是痛苦的開始,冰洞基本上是一個往上爬的山洞,所以沿途都是樓梯階一直往上爬,體力不好的話,其實不建議去。

  • For drivers unfamiliar with mountain driving there is a local bus service from Werfen for a small charge for this service call 0043/(0)6468/5293 or mail: eisriesenwelt.linie@aon.at.
  • This service departs regularly from Parkplatz Gries/Werfen (approx. every 25 minutes) and from Werfen Station (the station is only a 5 minutes walk away from Parkplatz Gries) at the following times: 8.20, 10.20, 12.20 and 14.20 and also by prior arrangement. 

▲由Salzburg坐到這一站Werfen

▲出火車站過橋右轉直走,也就是沿上圖左邊的河岸一直走

 ▲然後會到停車場,幸運的話會看到這台小巴在等你,上面山頭就是 Hohenwerfen 城堡

 

▲小巴直接載到這裡,進去買票,然後開始爬山,坐纜車,再爬山







▲爬山真的很累






冰洞裏面就像一個久未除霜的大的冷凍庫一樣, 有冰山,冰柱,還把冰鑿成一個隧道讓人通過,裡面黑黑的,導覽員每到一個景點會點鎂條照亮,然後開始解說,也會發給遊客一些煤油燈提著走,剛開始也很希望 能拿到煤油燈,不過拿了一陣子後就開始後悔了,因為蠻重的,沿途又都是爬梯子上上下下,很麻煩,裡面其實沒有想像中的冷,大概是一直爬樓梯的關係吧,走了 一陣子後,我外套拉鍊就不拉了,毛帽也不用戴,手套也不用,因為一直在走路,身體會熱起來。比較建議冬天去,至少就不用再為了去冰洞,而帶一堆衣服了。

 ▲ 就是這煤油燈,剛拿到很興奮,但其實不輕,拿到後來就後悔了

冰洞裡面規定不能照相,不過我看我前面那個外國遊客拿單眼掛在腰間,直接按快門盲拍,我也就跟著盲拍了,所以沒有在對焦,有些是行進間直接按,就拍得不是很好







 ▲以上幾張其實是走在一個冰塊中間穿鑿的隧道裡





最好是早一點去冰洞,這樣下午還會有時間去逛山下的一個城堡 Hohenwerfen,拿冰洞的票去,有打折喔。
http://www.salzburg-burgen.at/en/werfen/index.htm
▲ Hohenwerfen 城堡

 ▲ 下面中間的黃色字寫說 Price reduction with ice-cave-ticket

▲上下山小巴時刻表,參考看看

OBB 火車時刻 http://www.oebb.at/en/index.jsp
 Salzburg Hbf ->Werfen 火車時間:


Salzburg Hbf Get free WI-FI in the ÖBB Club Lounges
Werfen
22.10.11
08:15 dep
08:55 arr
0:40 0 IC 513 47 Tariff km
Ticket and prices

Salzburg Hbf Get free WI-FI in the ÖBB Club Lounges
Werfen
22.10.11
08:19 dep
09:12 arr
0:53 0 S 3 47 Tariff km
Ticket and prices

Salzburg Hbf Get free WI-FI in the ÖBB Club Lounges
Werfen
22.10.11
09:10 dep
09:48 arr
0:38 0 REX 1504 47 Tariff km
Ticket and prices

Salzburg Hbf Get free WI-FI in the ÖBB Club Lounges
Werfen
22.10.11
09:19 dep
10:12 arr
0:53 0 S 3 47 Tariff km
Ticket and prices

Salzburg Hbf Get free WI-FI in the ÖBB Club Lounges
Werfen
22.10.11
10:15 dep
10:55 arr
0:40 0 OIC 542 47 Tariff km
Ticket and prices