Skip to content

Commit 927b07a

Browse files
authored
#4 Merge pull request from a-lab-nagoya/astropenguin/issue3
Update docs
2 parents 592ff63 + 9da6e13 commit 927b07a

File tree

1 file changed

+224
-0
lines changed

1 file changed

+224
-0
lines changed

docs/index.md

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,227 @@
11
---
22
marp: true
3+
theme: gaia
4+
paginate: true
5+
backgroundImage: url('https://marp.app/assets/hero-background.jpg')
36
---
7+
8+
# Introduction to the programming language Python in radio astronomy
9+
10+
- 2023-04-13 @ Python tutorials #1
11+
- Presented by: Akio Taniguchi (Tamura group)
12+
13+
![bg right:25% 75%](https://openastronomy.org/pyastro/images/pyastro_logo_150px.png)
14+
15+
---
16+
17+
# Contents
18+
19+
- なぜ天文学でPythonを学ぶのか
20+
- (電波)天文学とプログラミング
21+
- プログラミング言語Python
22+
- Pythonを学ぶ上で知っておきたいこと
23+
- Pythonだけで全てを解決しないようにしよう
24+
- 公式の機能・ドキュメントを知る癖をつけよう
25+
- 他者への技術的な思いやりを持った開発をしよう
26+
- 「分からないこと」はどんどん質問をしよう
27+
28+
---
29+
30+
# なぜ天文学でPythonを学ぶのか
31+
32+
![bg blur](https://blueskyproject.io/_assets/scipy-ecosystem.png)
33+
<!-- _footer: https://speakerdeck.com/jakevdp/the-unexpected-effectiveness-of-python-in-science -->
34+
35+
---
36+
37+
# (電波)天文学とプログラミング
38+
39+
- データ解析
40+
- リダクション:生データから画像・スペクトルデータを生成
41+
- 要約・可視化:観測データのプロット・統計量への要約など
42+
- シミュレーション:理論モデルの生成・観測データとの比較
43+
- 装置開発
44+
- 望遠鏡制御:装置間の通信制御・データ取得・観測計画立案
45+
- 性能評価:装置の仕様と実観測データの比較・考察
46+
47+
---
48+
49+
![bg](https://static.projects.iq.harvard.edu/files/styles/os_files_xlarge/public/eht/files/20190410-78m-800x466.png?m=1554877319&itok=ogdRX6BW)
50+
<!-- _footer: https://eventhorizontelescope.org/blog/first-ever-image-black-hole-published-event-horizon-telescope-collaboration -->
51+
52+
---
53+
54+
![bg](https://user-images.githubusercontent.com/5890484/74090463-a0865580-4ad1-11ea-964f-0fd1ef07a851.png)
55+
<!-- _footer: https://github.com/numpy/numpy.org/pull/160 -->
56+
57+
---
58+
59+
# プログラミング言語Python
60+
61+
- 特徴
62+
- 高水準の汎用スクリプト言語(オブジェクト指向言語)
63+
- シンプルで習得しやすい文法とデータ構造
64+
- 豊富な標準ライブラリ(battery included)
65+
- 科学用途の豊富な外部ライブラリ
66+
- 用途
67+
- 科学計算・機械学習・ウェブ開発・通信制御など
68+
- 天文学に限らずプログラム初学者が学ぶ言語の筆頭候補
69+
70+
---
71+
72+
![bg fit](https://qph.fs.quoracdn.net/main-qimg-e75e13d665984b797b2f8401f7e03c1d)
73+
<!-- _footer: https://qph.fs.quoracdn.net/main-qimg-e75e13d665984b797b2f8401f7e03c1d -->
74+
75+
---
76+
77+
# プログラミング言語Python
78+
79+
```python
80+
import tkinter as tk
81+
from datetime import datetime as dt
82+
83+
root = tk.Tk()
84+
clock = tk.StringVar()
85+
label = tk.Label(textvariable=clock)
86+
label.pack()
87+
88+
def update():
89+
clock.set(dt.now().strftime('%H:%M:%S'))
90+
root.after(1000, update)
91+
92+
update()
93+
root.mainloop()
94+
```
95+
96+
---
97+
98+
# プログラミング言語Python
99+
100+
- 2023年4月時点でのPython
101+
- 最新バージョン:[3.11](https://docs.python.org/ja/3.11/)(2023年10月に[3.12がリリース予定](https://peps.python.org/pep-0693/)
102+
- Google Colaboratoryでは[3.9が採用されている](https://colab.research.google.com/notebooks/relnotes.ipynb#scrollTo=nsyNmf0OSEPc)
103+
- これから始めるなら3.9以上を使いましょう
104+
- 参考:バージョン2.x系のPython
105+
- 3.x系とは文法等が互換ではないことに注意
106+
- 例:`3/2 -> 1` (2.x), `3/2 -> 1.5` (3.x)
107+
- [CASA](http://casa.nrao.edu/)など一部の天文ソフトウェアで必要になることも
108+
109+
---
110+
111+
# プログラミング言語Python
112+
113+
- 科学計算ライブラリ
114+
- NumPy, xarray, pandas: 多次元配列・表データの処理
115+
- SciPy, scikit-learn: 科学計算ライブラリ
116+
- Astropy: 天文計算ライブラリ
117+
- 可視化ライブラリ
118+
- Matplotlib: 1-2次元データプロット
119+
- その他
120+
- Jupyter: ブラウザ+ノートブックのPython対話実行環境
121+
122+
---
123+
124+
![bg](https://blueskyproject.io/_assets/scipy-ecosystem.png)
125+
<!-- _footer: https://speakerdeck.com/jakevdp/the-unexpected-effectiveness-of-python-in-science -->
126+
127+
---
128+
129+
# Pythonを学ぶ上で知っておきたいこと
130+
131+
![bg blur](https://cdn.sstatic.net/insights/Img/Survey/2019/tech_network-1.svg)
132+
<!-- _footer: https://insights.stackoverflow.com/survey/2019 -->
133+
134+
---
135+
136+
# Pythonだけで全てを解決しないように
137+
138+
- Pythonにも得意不得意があります
139+
- 実行速度はそこまで高速ではないことが多い→外部ライブラリ
140+
- 文字列操作など、かえってシンプルに書きづらいことも
141+
- 外部ライブラリが使えないかを検討する
142+
- 例えばNumPyの配列計算は高速な科学計算では必須
143+
- 最適な他のプログラミング言語を検討する
144+
- 例えばウェブ関連の開発ならJavaScriptなど
145+
- (ただし、学習コスト・引継ぎコストと要相談)
146+
147+
---
148+
149+
# Pythonだけで全てを解決しないように
150+
151+
- シェルスクリプト(UNIXコマンド)の理解も大事
152+
- パイプライン:簡潔なデータ連続処理
153+
- 正規表現:効率的な文字列検索
154+
- よく使われる一般的なデータ形式を知っておく
155+
- FITS, netCDF: 多次元配列
156+
- JSON, YAML, TOML: データ記述言語
157+
- CSV: 表形式
158+
- オリジナルのデータ形式は極力作らないようにしましょう
159+
160+
---
161+
162+
![bg](https://cdn.sstatic.net/insights/Img/Survey/2019/tech_network-1.svg)
163+
<!-- _footer: https://insights.stackoverflow.com/survey/2019 -->
164+
165+
---
166+
167+
# 公式の機能・ドキュメントを知る
168+
169+
- [標準ライブラリ](https://docs.python.org/ja/3/library/index.html):これだけでかなりのことができます
170+
- 時刻計算・並列計算・OS操作などなど
171+
- 全部覚える必要はないが、機能を探す癖を付けておく
172+
- [言語ドキュメント](https://docs.python.org/ja/3/)
173+
- 標準ライブラリのヘルプ(引数の意味など)を全て網羅
174+
- Pythonのインタプリタでは`help(<関数名>)`でも見られる
175+
- 外部ライブラリドキュメント(英語)
176+
- 例えば`astropy documentation`などで検索してみましょう
177+
178+
---
179+
180+
# 他者への技術的な思いやり(難しい)
181+
182+
- Pythonらしい標準的な書き方→tutorialsで学びましょう
183+
- Pythonには[標準の書き方の指針](https://pep8-ja.readthedocs.io/ja/latest/)がある
184+
- Pythonicな文法を使いこなす(例えばイテレータ)
185+
- 可読性の高いコードの書き方を理解する
186+
- コードを複雑にしない書き方(例えば早期リターン)
187+
- 変数の命名方法(例えば`end``last`はどっちを使うべき?)
188+
- ドキュメントを残す(例えば[Azely](https://github.com/astropenguin/azely)のdocstrings)
189+
- **重要:ここでいう他者には「数ヶ月後の自分」も含まれます**
190+
191+
---
192+
193+
# 「分からないこと」は質問しよう
194+
195+
- 調べたら分かること
196+
- エラー(例外)の意味(大抵は検索すればヒットする)
197+
- ライブラリの使い方(大抵はドキュメントがある)
198+
- 調べても分からないこと
199+
- ある目的に対するライブラリの使い所(技術選定)
200+
- 専門知識(天体物理学)を必要とするコード
201+
- ただ、最初のうちはあまり気にせず質問した方が良いかも
202+
- M1以上は「○○が分からない」的な質問から脱却しましょう
203+
204+
---
205+
206+
# 参考文献・書籍
207+
208+
- Python documentation
209+
- [Python 標準ライブラリ](https://docs.python.org/ja/3/library/index.html)
210+
- [Python コードのスタイルガイド](https://pep8-ja.readthedocs.io/ja/latest/)
211+
- Python books
212+
- [これから学ぶPython(初版)](https://amzn.asia/d/8jxRQsO)→今回使うテキスト
213+
- [入門 Python 3(第2版)](https://amzn.asia/d/apjIPL9)
214+
- [科学技術計算のためのPython入門](https://www.amazon.co.jp/dp/4774183881/ref=cm_sw_r_tw_dp_U_x_k0TUEbVANHNQMj)
215+
- (自分が読みやすいものなら正直何でも良いので1冊通読)
216+
217+
---
218+
219+
# 参考文献・書籍
220+
221+
- Library references
222+
- [NumPy](https://numpy.org), [pandas](https://pandas.pydata.org), [xarray](https://xarray.pydata.org/en/stable/index.html)
223+
- [Matplotlib](https://matplotlib.org)
224+
- [SciPy](https://www.scipy.org), [Astropy](https://www.astropy.org)
225+
- Other books
226+
- [リーダブルコード](https://www.amazon.co.jp/dp/4873115655/ref=cm_sw_r_tw_dp_U_x_WATUEbR6S95N0)
227+
- [UNIXコマンドブック 第4版](https://www.amazon.co.jp/dp/4797372281/ref=cm_sw_em_r_mt_dp_U_V8pUDbKDTPHAY)

0 commit comments

Comments
 (0)