Or in short:
Compare this: https://gist.github.com/eteq/7b54c9cc1cb23cfe9a1ad1afd70bea9f
To this: https://github.com/eteq/piscdwarfs_hst/blob/master/Calibed%20Photometry.ipynb
(Start jupyter notebook
from wherever all your stuff is for a project)
Create a notebook, and start typing Python code:
from astropy import coordinates
coordinates.SkyCoord.from_name('M31')
Hit shift-enter (or control-enter)
from astropy import coordinates
coordinates.SkyCoord.from_name('M82')
<SkyCoord (ICRS): (ra, dec) in deg (148.9684583, 69.6797028)>
Pay attention to the color of the box around the cell: green means "edit" mode (typing will edit the code), blue means "Command Mode" (typing will move/insert/execute cells).
Try the "multi select" mode (hold down cmd or ctrl while clicking on different parts of text in a cell) - every keystroke goes to all of the cursors.
Use ?
to get help on a function - it appears in a pop-up bar at the bottom of the notebook
Check out the %magic
list: lots of useful productivity tools (from IPython)
To learn more, open a notebook and go to "Help"->"User interface tour" or "Help"->"Keyboard Shortcuts"
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
plt.scatter(*np.random.randn(2, 100),
s=np.pi * (15 * np.random.rand(100))**2 ,
c=np.random.randn(100), alpha=0.5,
cmap='viridis')
plt.xlabel('x')
plt.ylabel('y')
<matplotlib.text.Text at 0x11221ce10>
$M(r) = - \frac{r \sigma^2}{G}
\left[ \frac{d \ln \nu}{d \ln r} +
\frac{d \ln \sigma^2}{d \ln r} +
2 \beta(r)
\right]$
$M(r) = - \frac{r \sigma^2}{G} \left[ \frac{d \ln \nu}{d \ln r} + \frac{d \ln \sigma^2}{d \ln r} + 2 \beta(r) \right]$
from IPython import display
urltempl = ("http://skyservice.pha.jhu.edu/dr12/ImgCutout/getjpeg.aspx?"
"ra={coo.ra.deg}&dec={coo.dec.deg}&width={width}&height={height}&scale={scale}")
m101 = coordinates.SkyCoord.from_name('M101')
display.Image(url=urltempl.format(coo=m101, width=1024, height=768, scale=1.25))
%timeit np.sqrt(12)
The slowest run took 14.82 times longer than the fastest. This could mean that an intermediate result is being cached. 1000000 loops, best of 3: 1.07 µs per loop
%timeit 12**0.5
10000000 loops, best of 3: 22.4 ns per loop
from matplotlib import animation
# Details of this one's implementation are in a hidden slide
animation.FuncAnimation(lorenz_fig, func=lorenz_animate,
init_func=lorenz_init, blit=True,
frames=500, interval=30)
The one you're seeing here!