Markdown Cell

Sub heading this is big text

Smaller subheadings

This is just a paragraph.


In [4]:
# code cell
name = "Jonathan"

Tips and Tricks

A markdown cell lets you do many useful things.


In [6]:
import numpy as np

# don't do:
# from numpy import *

In [7]:
max("a")


Out[7]:
'a'

In [8]:
np.max("a")


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-4005723e4b17> in <module>
----> 1 np.max("a")

<__array_function__ internals> in amax(*args, **kwargs)

~/miniconda3/envs/dspy3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in amax(a, axis, out, keepdims, initial, where)
   2666     """
   2667     return _wrapreduction(a, np.maximum, 'max', axis, None, out,
-> 2668                           keepdims=keepdims, initial=initial, where=where)
   2669 
   2670 

~/miniconda3/envs/dspy3/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
     88                 return reduction(axis=axis, out=out, **passkwargs)
     89 
---> 90     return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
     91 
     92 

TypeError: cannot perform reduce with flexible type

Imports


In [9]:
# %matplotlib inline
# %config InlineBackend.figure_format='retina'

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import os
from pivottablejs import pivot_ui
import sys
import warnings

warnings.filterwarnings("ignore")

Keyboard shortcuts

Practice doing these a few times and try to force yourself to use them whenever you can.

Help (h)

For help in the Notebook, ESC + h (doesn't work in Lab)

Select multiple cells

j, k, and arrow keys while holding shift selects multiple cells.


In [ ]:
first = 1

In [ ]:
second = 2

In [ ]:
third = 3

Split a cell with -

Well, ctrl + shift + -, but remember it by horizontal.


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

Add a new cell (a)bove


In [ ]:


In [ ]:


In [ ]:

Add a new cell (b)elow


In [ ]:
print("oops")

(d)(d)elete

unD(z)o


In [ ]:


In [ ]:

(c)opy cells

(v)aste cells

Pivot Tables w/ pandas

A library and example from: http://nicolas.kruchten.com/content/2015/09/jupyter_pivottablejs/


In [10]:
# df = pd.read_csv("../data/mps.csv", encoding="ISO-8859-1")
# canadian_politics = pd.read_csv("../data/montreal_2014.csv",)
canadian_politics = pd.read_csv("../data/mps2.csv")

In [11]:
# recommend using .head()
canadian_politics.head(10)


Out[11]:
Name Party Province Age Gender
0 Liu, Laurin NDP Quebec 22.0 Female
1 Mourani, Maria Bloc Quebecois Quebec 43.0 Female
2 Sellah, Djaouida NDP Quebec NaN Female
3 St-Denis, Lise NDP Quebec 72.0 Female
4 Fry, Hedy Liberal British Columbia 71.0 Female
5 Turmel, Nycole NDP Quebec 70.0 Female
6 Sgro, Judy Liberal Ontario 68.0 Female
7 Raynault, Francine NDP Quebec 67.0 Female
8 Davidson, Patricia Conservative Ontario 66.0 Female
9 Smith, Joy Conservative Manitoba 65.0 Female

In [14]:
sns.distplot(canadian_politics["Age"].dropna());



In [15]:
sns.set_context("poster", font_scale=1.3)

In [16]:
fig, ax = plt.subplots(figsize=(12, 8))
sns.distplot(canadian_politics["Age"].dropna())
fig.tight_layout()


Enhanced Pandas Dataframe Display


In [ ]:
# Province, Party, Average, Age, Heatmap

In [20]:
pivot_ui(canadian_politics)


Out[20]:

In [22]:
canadian_politics['Age-bin'] = pd.cut(canadian_politics['Age'], [x for x in range(10, 100, 5)])
# pd.qcut(canadian_politics['Age'], [x for x in range(10, 100, 5)])

In [21]:
pd.read_clipboard(sep='\t')


Out[21]:
pd.cut(canadian_politics['Age'], [x for x in range(10, 100, 5)])

Tab -- Your Friend


In [23]:
import numpy as np

In [ ]:
from numpy.random import choice, chisquare

In [ ]:
np.random.chisquare()

In [ ]:
# pure tab right ↓ less useful
np.random.choice()

In [ ]:


In [ ]:


In [ ]:

shift-tab


In [ ]:
# shift-tab right ↓ more useful
np.linspace(start=50, stop=100, endpoint=False)

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

shift-tab-tab


In [ ]:
np.linspace()

In [ ]:


In [ ]:


In [ ]:


In [ ]:

shift-tab-tab-tab


In [ ]:
np.linspace(50, 150, num=100, endpoint=False)

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

shift-tab-tab-tab-tab


In [ ]:
plt.plot(np.linspace(start, stop))

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

?


In [24]:
np.linspace?

In [25]:
?np.linspace

??

(Lab can scroll if you click)


In [26]:
np.linspace??

In [27]:
!subl ~/miniconda3/envs/dspy3/lib/python3.6/site-packages/numpy/core/function_base.py

Random stuff


In [29]:
import textwrap
def example_function():
    """Docstring for example function"""
    
    print(textwrap.dedent("""
    This is a multi-lined string
    that I want to write inside of a function.
    Notice what happens when I print this.
        And when something is indented more."""))


example_function()


This is a multi-lined string
that I want to write inside of a function.
Notice what happens when I print this.
    And when something is indented more.

Inspect everything and Find and Replace


In [44]:
# But first find and replace
def silly_function(xval):
    """Takes a value and returns the value."""
    xval_sq = xval ** 2.0
    3 + 15
    xval_abs = np.sqrt(xval_sq)
    return xval_abs

In [45]:
silly_function(-2,)


---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-45-6ca3ec01f750> in <module>
----> 1 silly_function(-2,)

<ipython-input-44-4ab2b052d8c6> in silly_function(xval)
      4     xval_sq = xval ** 2.0
      5     3 + 15
----> 6     7/0
      7     xval_abs = np.sqrt(xval_sq)
      8     return xval_abs

ZeroDivisionError: division by zero

In [37]:
silly_function?

In [38]:
silly_function??

In [39]:
!ls ../data/


coal_prod_2008.csv           collincountyforeclosures.csv
coal_prod_2009.csv           example.csv
coal_prod_2010.csv           montreal_2014.csv
coal_prod_2011.csv           mps.csv
coal_prod_2012.csv           mps2.csv
coal_prod_cleaned.csv        nbextensions.png
coal_prod_cleaned.csv.zip    raw_players.csv.gz
coalpublic2012.xls

In [40]:
coal_years = !ls ../data/coal_prod_20*.csv

In [41]:
coal_years


Out[41]:
['../data/coal_prod_2008.csv',
 '../data/coal_prod_2009.csv',
 '../data/coal_prod_2010.csv',
 '../data/coal_prod_2011.csv',
 '../data/coal_prod_2012.csv']

In [42]:
from glob import glob

In [43]:
for filename in glob("../data/coal_prod_20*.csv"):
    print(filename)


../data/coal_prod_2012.csv
../data/coal_prod_2011.csv
../data/coal_prod_2010.csv
../data/coal_prod_2009.csv
../data/coal_prod_2008.csv

Line numbers (lowercase "L")

Type lowercase "L" to have line numbers; shift-L for line numbers notebook-wide.

Move blocks of code around

Indent/dedent

Cmd + [
Cmd + ]

Comment

Cmd + /

In [46]:
ex_dictionary22 = {}

# Indent/dedent/comment
for index in range(5):
    ex_dictionary22["integer_one"] = 1
    ex_dictionary22["integer_two"] = 2
    ex_dictionary22["integer_three"] = 3
    ex_dictionary22["integer_four"] = 4

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

Multicursor magic

Hold down option, click and drag (for big cursor).

cmd + click == wherever you click.

Shift command P -- command palette Classic Notebook Shift command C -- command palette in JupyterLab

Hide left bar (CMD + B)

Full screen CMD + Shift + D (but CTRL + CMD F for browser fullscreen)

Move cells around mouse


In [ ]:
example["one_better_neat"] = 1
example["two_better_neat"] = 2
example["three_better_neat"] = 3
example["four_better_neat"] = 4

Monospace

You can also get monospaced fonts by indenting 4 spaces:

mkdir toc
cd toc

Syntax Highlighting

Wrap with triple-backticks and language:

mkdir toc
cd toc
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
SELECT first_name,
       last_name,
       year_of_birth
FROM presidents
WHERE year_of_birth > 1800;

Headings and LaTeX

With text and $\LaTeX$ support.

$$\begin{align} B'&=-\nabla \times E,\\ E'&=\nabla \times B - 4\pi j \end{align}$$

Magics

  • % $\equiv$ inline magic
  • %% $\equiv$ cell magic

In [47]:
%%latex

If you want to get crazier$\ldots$

\begin{equation}
\oint_S {E_n dA = \frac{1}{{\varepsilon _0 }}} Q_\textrm{inside}
\end{equation}


If you want to get crazier$\ldots$ \begin{equation} \oint_S {E_n dA = \frac{1}{{\varepsilon _0 }}} Q_\textrm{inside} \end{equation}

In [48]:
%%python2
print "hi"


hi

In [49]:
%%bash
wget http://www.ast.cam.ac.uk/%7Erfc/vpfit12.2.tar.gz
mkdir -p vpfit12
cd vpfit12
tar -xvzf ../vpfit11.1.tar.gz


--2020-06-01 17:00:52--  http://www.ast.cam.ac.uk/%7Erfc/vpfit12.2.tar.gz
Resolving www.ast.cam.ac.uk (www.ast.cam.ac.uk)... 131.111.68.64
Connecting to www.ast.cam.ac.uk (www.ast.cam.ac.uk)|131.111.68.64|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.ast.cam.ac.uk:443/~rfc/vpfit12.2.tar.gz [following]
--2020-06-01 17:00:53--  https://www.ast.cam.ac.uk/~rfc/vpfit12.2.tar.gz
Connecting to www.ast.cam.ac.uk (www.ast.cam.ac.uk)|131.111.68.64|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://people.ast.cam.ac.uk/~rfc/vpfit12.2.tar.gz [following]
--2020-06-01 17:00:53--  https://people.ast.cam.ac.uk/~rfc/vpfit12.2.tar.gz
Resolving people.ast.cam.ac.uk (people.ast.cam.ac.uk)... 2001:630:212:800:5054:ff:fed7:b805, 131.111.69.227
Connecting to people.ast.cam.ac.uk (people.ast.cam.ac.uk)|2001:630:212:800:5054:ff:fed7:b805|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7747458 (7.4M) [application/x-gzip]
Saving to: ‘vpfit12.2.tar.gz.1’

     0K .......... .......... .......... .......... ..........  0%  143K 52s
    50K .......... .......... .......... .......... ..........  1%  320K 38s
   100K .......... .......... .......... .......... ..........  1% 1.32M 27s
   150K .......... .......... .......... .......... ..........  2%  710K 23s
   200K .......... .......... .......... .......... ..........  3%  333K 22s
   250K .......... .......... .......... .......... ..........  3% 9.70M 19s
   300K .......... .......... .......... .......... ..........  4%  641K 17s
   350K .......... .......... .......... .......... ..........  5% 1.35M 16s
   400K .......... .......... .......... .......... ..........  5%  255K 17s
   450K .......... .......... .......... .......... ..........  6% 1.34M 16s
   500K .......... .......... .......... .......... ..........  7% 1.39M 15s
   550K .......... .......... .......... .......... ..........  7% 1.46M 14s
   600K .......... .......... .......... .......... ..........  8% 1.40M 13s
   650K .......... .......... .......... .......... ..........  9%  438K 13s
   700K .......... .......... .......... .......... ..........  9% 1.08M 13s
   750K .......... .......... .......... .......... .......... 10% 1.09M 12s
   800K .......... .......... .......... .......... .......... 11% 1.13M 12s
   850K .......... .......... .......... .......... .......... 11% 79.6K 16s
   900K .......... .......... .......... .......... .......... 12% 97.1M 15s
   950K .......... .......... .......... .......... .......... 13%  132M 14s
  1000K .......... .......... .......... .......... .......... 13%  111M 13s
  1050K .......... .......... .......... .......... .......... 14%  157M 12s
  1100K .......... .......... .......... .......... .......... 15%  155M 12s
  1150K .......... .......... .......... .......... .......... 15%  133M 11s
  1200K .......... .......... .......... .......... .......... 16%  125M 11s
  1250K .......... .......... .......... .......... .......... 17% 7.21M 10s
  1300K .......... .......... .......... .......... .......... 17%  115M 10s
  1350K .......... .......... .......... .......... .......... 18%  156M 9s
  1400K .......... .......... .......... .......... .......... 19%  103M 9s
  1450K .......... .......... .......... .......... .......... 19% 53.6M 9s
  1500K .......... .......... .......... .......... .......... 20% 5.31M 8s
  1550K .......... .......... .......... .......... .......... 21%  135K 9s
  1600K .......... .......... .......... .......... .......... 21% 1.22M 9s
  1650K .......... .......... .......... .......... .......... 22%  140K 10s
  1700K .......... .......... .......... .......... .......... 23%  932K 10s
  1750K .......... .......... .......... .......... .......... 23%  370K 10s
  1800K .......... .......... .......... .......... .......... 24% 13.7M 9s
  1850K .......... .......... .......... .......... .......... 25% 63.2M 9s
  1900K .......... .......... .......... .......... .......... 25% 73.6M 9s
  1950K .......... .......... .......... .......... .......... 26%  776K 9s
  2000K .......... .......... .......... .......... .......... 27%  813K 9s
  2050K .......... .......... .......... .......... .......... 27%  667K 9s
  2100K .......... .......... .......... .......... .......... 28%  314K 9s
  2150K .......... .......... .......... .......... .......... 29%  859K 9s
  2200K .......... .......... .......... .......... .......... 29%  976K 8s
  2250K .......... .......... .......... .......... .......... 30% 1005K 8s
  2300K .......... .......... .......... .......... .......... 31%  364K 8s
  2350K .......... .......... .......... .......... .......... 31%  716K 8s
  2400K .......... .......... .......... .......... .......... 32%  918K 8s
  2450K .......... .......... .......... .......... .......... 33%  820K 8s
  2500K .......... .......... .......... .......... .......... 33%  303K 8s
  2550K .......... .......... .......... .......... .......... 34%  666K 8s
  2600K .......... .......... .......... .......... .......... 35%  925K 8s
  2650K .......... .......... .......... .......... .......... 35%  614K 8s
  2700K .......... .......... .......... .......... .......... 36%  453K 8s
  2750K .......... .......... .......... .......... .......... 37%  578K 8s
  2800K .......... .......... .......... .......... .......... 37%  392K 8s
  2850K .......... .......... .......... .......... .......... 38%  546K 8s
  2900K .......... .......... .......... .......... .......... 38%  496K 8s
  2950K .......... .......... .......... .......... .......... 39%  458K 7s
  3000K .......... .......... .......... .......... .......... 40%  956K 7s
  3050K .......... .......... .......... .......... .......... 40%  507K 7s
  3100K .......... .......... .......... .......... .......... 41%  765K 7s
  3150K .......... .......... .......... .......... .......... 42%  538K 7s
  3200K .......... .......... .......... .......... .......... 42% 1.04M 7s
  3250K .......... .......... .......... .......... .......... 43%  730K 7s
  3300K .......... .......... .......... .......... .......... 44%  915K 7s
  3350K .......... .......... .......... .......... .......... 44% 1.17M 7s
  3400K .......... .......... .......... .......... .......... 45% 1.41M 7s
  3450K .......... .......... .......... .......... .......... 46% 1.37M 6s
  3500K .......... .......... .......... .......... .......... 46% 1.44M 6s
  3550K .......... .......... .......... .......... .......... 47% 1.03M 6s
  3600K .......... .......... .......... .......... .......... 48%  997K 6s
  3650K .......... .......... .......... .......... .......... 48% 1.40M 6s
  3700K .......... .......... .......... .......... .......... 49% 1.31M 6s
  3750K .......... .......... .......... .......... .......... 50%  863K 6s
  3800K .......... .......... .......... .......... .......... 50% 1.40M 6s
  3850K .......... .......... .......... .......... .......... 51% 1.37M 5s
  3900K .......... .......... .......... .......... .......... 52% 1.48M 5s
  3950K .......... .......... .......... .......... .......... 52% 1.09M 5s
  4000K .......... .......... .......... .......... .......... 53% 1.05M 5s
  4050K .......... .......... .......... .......... .......... 54% 1.36M 5s
  4100K .......... .......... .......... .......... .......... 54% 1.46M 5s
  4150K .......... .......... .......... .......... .......... 55%  965K 5s
  4200K .......... .......... .......... .......... .......... 56% 1.47M 5s
  4250K .......... .......... .......... .......... .......... 56%  952K 5s
  4300K .......... .......... .......... .......... .......... 57% 1.35M 5s
  4350K .......... .......... .......... .......... .......... 58% 1.43M 4s
  4400K .......... .......... .......... .......... .......... 58%  993K 4s
  4450K .......... .......... .......... .......... .......... 59% 1.56M 4s
  4500K .......... .......... .......... .......... .......... 60% 1.08M 4s
  4550K .......... .......... .......... .......... .......... 60% 1.36M 4s
  4600K .......... .......... .......... .......... .......... 61% 1.43M 4s
  4650K .......... .......... .......... .......... .......... 62% 1.41M 4s
  4700K .......... .......... .......... .......... .......... 62%  682K 4s
  4750K .......... .......... .......... .......... .......... 63% 1.66M 4s
  4800K .......... .......... .......... .......... .......... 64% 1.05M 4s
  4850K .......... .......... .......... .......... .......... 64% 1.38M 4s
  4900K .......... .......... .......... .......... .......... 65% 1.37M 4s
  4950K .......... .......... .......... .......... .......... 66%  982K 3s
  5000K .......... .......... .......... .......... .......... 66% 1.34M 3s
  5050K .......... .......... .......... .......... .......... 67% 1.43M 3s
  5100K .......... .......... .......... .......... .......... 68% 1.39M 3s
  5150K .......... .......... .......... .......... .......... 68% 1.36M 3s
  5200K .......... .......... .......... .......... .......... 69%  795K 3s
  5250K .......... .......... .......... .......... .......... 70% 1.38M 3s
  5300K .......... .......... .......... .......... .......... 70% 1.09M 3s
  5350K .......... .......... .......... .......... .......... 71% 1.47M 3s
  5400K .......... .......... .......... .......... .......... 72% 1.37M 3s
  5450K .......... .......... .......... .......... .......... 72% 1.21M 3s
  5500K .......... .......... .......... .......... .......... 73% 1.60M 3s
  5550K .......... .......... .......... .......... .......... 74% 1.15M 3s
  5600K .......... .......... .......... .......... .......... 74%  547K 2s
  5650K .......... .......... .......... .......... .......... 75% 12.5M 2s
  5700K .......... .......... .......... .......... .......... 75% 1.53M 2s
  5750K .......... .......... .......... .......... .......... 76% 1.35M 2s
  5800K .......... .......... .......... .......... .......... 77% 1.06M 2s
  5850K .......... .......... .......... .......... .......... 77%  589K 2s
  5900K .......... .......... .......... .......... .......... 78% 1.37M 2s
  5950K .......... .......... .......... .......... .......... 79% 1.51M 2s
  6000K .......... .......... .......... .......... .......... 79% 1.06M 2s
  6050K .......... .......... .......... .......... .......... 80%  224K 2s
  6100K .......... .......... .......... .......... .......... 81% 27.6M 2s
  6150K .......... .......... .......... .......... .......... 81%  106M 2s
  6200K .......... .......... .......... .......... .......... 82%  107M 2s
  6250K .......... .......... .......... .......... .......... 83% 34.4M 2s
  6300K .......... .......... .......... .......... .......... 83%  871K 2s
  6350K .......... .......... .......... .......... .......... 84%  787K 1s
  6400K .......... .......... .......... .......... .......... 85%  538K 1s
  6450K .......... .......... .......... .......... .......... 85%  831K 1s
  6500K .......... .......... .......... .......... .......... 86%  758K 1s
  6550K .......... .......... .......... .......... .......... 87%  732K 1s
  6600K .......... .......... .......... .......... .......... 87%  890K 1s
  6650K .......... .......... .......... .......... .......... 88%  674K 1s
  6700K .......... .......... .......... .......... .......... 89%  971K 1s
  6750K .......... .......... .......... .......... .......... 89% 1.04M 1s
  6800K .......... .......... .......... .......... .......... 90%  803K 1s
  6850K .......... .......... .......... .......... .......... 91%  754K 1s
  6900K .......... .......... .......... .......... .......... 91%  993K 1s
  6950K .......... .......... .......... .......... .......... 92% 1.35M 1s
  7000K .......... .......... .......... .......... .......... 93%  936K 1s
  7050K .......... .......... .......... .......... .......... 93%  592K 1s
  7100K .......... .......... .......... .......... .......... 94% 1.77M 1s
  7150K .......... .......... .......... .......... .......... 95%  943K 0s
  7200K .......... .......... .......... .......... .......... 95%  784K 0s
  7250K .......... .......... .......... .......... .......... 96%  901K 0s
  7300K .......... .......... .......... .......... .......... 97% 1.32M 0s
  7350K .......... .......... .......... .......... .......... 97% 1.49M 0s
  7400K .......... .......... .......... .......... .......... 98%  692K 0s
  7450K .......... .......... .......... .......... .......... 99% 1.51M 0s
  7500K .......... .......... .......... .......... .......... 99% 1.40M 0s
  7550K .......... .....                                      100% 1.59M=9.3s

2020-06-01 17:01:04 (817 KB/s) - ‘vpfit12.2.tar.gz.1’ saved [7747458/7747458]

x ./
x ./#temp2#
x ./atom.dat
x ./atomtab.f
x ./autovpin.f
x ./bintofits.f
x ./calcn.f
x ./case.f
x ./chanwav.f
x ./chisum26.f
x ./cmax1.f
x ./cms_src.f
x ./com_cons.f
x ./dcholin.f
x ./dexpf.f
x ./dlycabscft.f
x ./docs/
x ./dotick.f
x ./dpoly.f
x ./dsepvar.f
x ./eigen.f
x ./erfcc.f
x ./externals.f
x ./fl_gen.f
x ./gen_vpin.f
x ./ginsert.f
x ./gu_tabsort.f
x ./hedit.f
x ./linfit.f
x ./lm_udchole.f
x ./lyregset.f
x ./makefile
x ./medianv.f
x ./MMatomdat_atom_noiso.dat
x ./pda_che2d.f
x ./pda_dp1vlu.f
x ./pda_dpcoef.f
x ./pda_dpolft.f
x ./pda_qsiad.f
x ./pda_src.f
x ./pda_xermsg.f
x ./pgfiles/
x ./pldef.f
x ./plset.f
x ./pr_mdian1.f
x ./prg_polyd.f
x ./probks.f
x ./rd_ablin.f
x ./rd_adnois.f
x ./rd_advprof.f
x ./rd_alias.f
x ./rd_bclimsreset.f
x ./rd_comalias.f
x ./rd_compreset.f
x ./rd_cuchstr.f
x ./rd_cufilnm.f
x ./rd_cuplot.f
x ./rd_cuwvrest.f
x ./rd_cydata.f
x ./rd_daswap.f
x ./rd_dblid.f
x ./rd_dmanip.f
x ./rd_drebin.f
x ./rd_drebing.f
x ./rd_dsetbad.f
x ./rd_dvcont.f
x ./rd_esoftread.f
x ./rd_estcolb.f
x ./rd_ewwav.f
x ./rd_extabs.f
x ./rd_fluxbb.f
x ./rd_flxval.f
x ./rd_gen.f
x ./rd_gprof.f
x ./rd_gprofe.f
x ./rd_gpsim.f
x ./rd_hdust.f
x ./rd_intinfo.f
x ./rd_intvtab.f
x ./rd_jbsim.f
x ./rd_markreg.f
x ./rd_mattrd.f
x ./rd_meantau.f
x ./rd_medvp.f
x ./rd_moderrs.f
x ./rd_multiset.f
x ./rd_pgannot.f
x ./rd_plcset.f
x ./rd_pmpset.f
x ./rd_prhelp.dat
x ./rd_prhelp.f
x ./rd_qdatafiles.f
x ./rd_readlinwav.f
x ./rd_sclsig.f
x ./rd_scrng.f
x ./rd_scwval.f
x ./rd_seekmax2.f
x ./rd_setintv.f
x ./rd_sizes.f
x ./rd_splvtick.f
x ./rd_stackz.f
x ./rd_start.dat
x ./rd_stplot.f
x ./rd_taueff.f
x ./rd_tgplots.f
x ./rd_tickvpfl.f
x ./rd_ulimse.f
x ./rd_ulinfo.f
x ./rd_wrfits.f
x ./rd_wrwcfits.f
x ./rd_wvnewt.f
x ./rd_wvsc.f
x ./rd_xcdc.f
x ./rd_zcorr.f
x ./rd_ztabcf.f
x ./rhedit.f
x ./sepvar.f
x ./splot.f
x ./spvoigt.f
x ./svbksbd.f
x ./svdajc.f
x ./svdcmpd.f
x ./svdfit.f
x ./tempccc.f
x ./tickpg.f
x ./tikset.f
x ./tstfit3d.f
x ./udchole.f
x ./varythis.f
x ./voigt_king.f
x ./voigt_subroutine.f
x ./vp_abfind.f
x ./vp_abundset.f
x ./vp_addline.f
x ./vp_addxlink.f
x ./vp_archwav.f
x ./vp_asciin.f
x ./vp_ationsep.f
x ./vp_atomass.f
x ./vp_blfixf.f
x ./vp_cfcopy.f
x ./vp_chanwav.f
x ./vp_charlims.f
x ./vp_chdisprof.f
x ./vp_checkb.f
x ./vp_checkn.f
x ./vp_chipconv.f
x ./vp_chsation.f
x ./vp_chspread.f
x ./vp_cmssrc.f
x ./vp_curse.f
x ./vp_cval.f
x ./vp_dattim.f
x ./vp_dattim_alt.f
x ./vp_deriv.f
x ./vp_dlinin.f
x ./vp_dlset.f
x ./vp_dlyccft.f
x ./vp_dotick.f
x ./vp_emlsmry.f
x ./vp_empval.f
x ./vp_emscchk.f
x ./vp_emtset.f
x ./vp_endorder.f
x ./vp_endrej.f
x ./vp_errej.f
x ./vp_ewred.f
x ./vp_f13fin.f
x ./vp_f13finx.f
x ./vp_f13read.f
x ./vp_f_sigscl.f
x ./vp_fgf13write.f
x ./vp_flchderivs.f
x ./vp_fnzbin.f
x ./vp_getargs.f
x ./vp_getres.f
x ./vp_gglwcoeff.f
x ./vp_gsclfts.f
x ./vp_gwatfits.f
x ./vp_initval.f
x ./vp_ionregcheck.f
x ./vp_ksvnorm.f
x ./vp_lineid.f
x ./vp_linlim.f
x ./vp_listfiles.f
x ./vp_lycont.f
x ./vp_lyconte.f
x ./vp_minpol.f
x ./vp_minquad.f
x ./vp_nearlin.f
x ./vp_newtfxl.f
x ./vp_pareorder.f
x ./vp_parmcest.f
x ./vp_pgbegin.f
x ./vp_pgcurs.f
x ./vp_plcset.f
x ./vp_poisson.f
x ./vp_presetsys.f
x ./vp_psfinterp.f
x ./vp_rdbwvfts.f
x ./vp_rdfitsext.f
x ./vp_rdlines.f
x ./vp_rdspecial.f
x ./vp_rdwaveval.f
x ./vp_readfits.f
x ./vp_runstst.f
x ./vp_rwlims.f
x ./vp_scontf.f
x ./vp_setintv.f
x ./vp_setoptn.f
x ./vp_setup.dat
x ./vp_sizes.f
x ./vp_smry.f
x ./vp_spdatin.f
x ./vp_splot.dat
x ./vp_spread.f
x ./vp_spvoigte.f
x ./vp_srcpath.f
x ./vp_startval.f
x ./vp_stration.f
x ./vp_stripcmt.f
x ./vp_subchspread.f
x ./vp_sumlinclear.f
x ./vp_sysdel.f
x ./vp_tdcolset.f
x ./vp_tiedb.f
x ./vp_tiedrop.f
x ./vp_tieval.f
x ./vp_trimattab.f
x ./vp_tsetxref.f
x ./vp_ucheck.f
x ./vp_ucoptv.f
x ./vp_ucprinerr.f
x ./vp_ucprinit.f
x ./vp_usdef.f
x ./vp_vreset.f
x ./vp_wrt25.f
x ./vp_wval.f
x ./vp_wvalch.f
x ./vp_wvalsubch.f
x ./vp_wverass.f
x ./vpbrentres.f
x ./vpf_bvalsp.f
x ./vpf_dvresn.f
x ./vpfit.f
x ./vpgti.f
x ./vppreset.cmd
x ./vpreset.awk
x ./wcor.f
x ./wval.f
x ./xmakefile
x ./pgfiles/Al.pg
x ./pgfiles/AlSi.pg
x ./pgfiles/CaII.pg
x ./pgfiles/CI2.pg
x ./pgfiles/CIH2.pg
x ./pgfiles/CII.pg
x ./pgfiles/CII.pg~
x ./pgfiles/CIIOI.pg
x ./pgfiles/CIIOI.pg~
x ./pgfiles/CIISi.pg
x ./pgfiles/CIV.pg
x ./pgfiles/CIVSiIV.pg
x ./pgfiles/CrZn.pg
x ./pgfiles/FeII.pg
x ./pgfiles/FeIIhi.pg
x ./pgfiles/hc.pg
x ./pgfiles/HC4.pg
x ./pgfiles/HC4.pg~
x ./pgfiles/HCNlo.pg
x ./pgfiles/hcnosi.pg
x ./pgfiles/hcsi.pg
x ./pgfiles/HD.pg
x ./pgfiles/HDs.pg
x ./pgfiles/HHC4N5O6.pg
x ./pgfiles/HHC4O6.pg
x ./pgfiles/HHC4O6Si4.pg
x ./pgfiles/HHC4Si4.pg
x ./pgfiles/HHCSi34.pg
x ./pgfiles/HHCSi34.pg~
x ./pgfiles/HHO6.pg
x ./pgfiles/hiHCNO.pg
x ./pgfiles/hiHCOSi.pg
x ./pgfiles/hiion.pg
x ./pgfiles/hiSi.pg
x ./pgfiles/HNI.pg
x ./pgfiles/HOhi.pg
x ./pgfiles/HQhi.pg
x ./pgfiles/HSSi.pg
x ./pgfiles/Hvhi.pg
x ./pgfiles/LaCIV.pg
x ./pgfiles/LaN.pg
x ./pgfiles/laonly.pg
x ./pgfiles/LL.pg
x ./pgfiles/LLO.pg
x ./pgfiles/llyman.pg
x ./pgfiles/loc.pg
x ./pgfiles/local.pg
x ./pgfiles/lohi.pg
x ./pgfiles/lointhi.pg
x ./pgfiles/lointz.pg
x ./pgfiles/loion.pg
x ./pgfiles/loloz.pg
x ./pgfiles/lorare.pg
x ./pgfiles/lowz.pg
x ./pgfiles/lowzFeII.pg
x ./pgfiles/ly4.pg
x ./pgfiles/lyabg.pg
x ./pgfiles/lyman.pg
x ./pgfiles/lyman8.pg
x ./pgfiles/MgFeMn.pg
x ./pgfiles/MgICI.pg
x ./pgfiles/MgII.pg
x ./pgfiles/MgIIFeII.pg
x ./pgfiles/NaCa.pg
x ./pgfiles/NiII.pg
x ./pgfiles/nitrogen.pg
x ./pgfiles/NV.pg
x ./pgfiles/OI.pg
x ./pgfiles/OIArI.pg
x ./pgfiles/oneline.pg
x ./pgfiles/OSipair.pg
x ./pgfiles/OVI.pg
x ./pgfiles/OVIHI.pg
x ./pgfiles/range.pg
x ./pgfiles/sdlaion.pg
x ./pgfiles/SiII.pg
x ./pgfiles/SiIIfs.pg
x ./pgfiles/SiIIl.pg
x ./pgfiles/SiIV.pg
x ./pgfiles/stloion.pg
x ./pgfiles/strong.pg
x ./pgfiles/TiII.pg
x ./pgfiles/ultralow.pg
x ./pgfiles/vhiHCNO.pg
x ./docs/rdgen11.1.pdf
x ./docs/sample.txt.gz
x ./docs/vpfit11.1.pdf

Scripting


In [50]:
normal_argument = 12.4
second_argument = 98.4

arg_with_spaces = "the secret to life"

In [51]:
%%bash -s {normal_argument} {second_argument}
echo "This script knows the value of the argument: $1"
echo "It also has no trouble with the second argument: $2"


This script knows the value of the argument: 12.4
It also has no trouble with the second argument: 98.4

In [52]:
%%bash -s "$arg_with_spaces"
echo "This bash script knows $1."


This bash script knows the secret to life.

In [ ]:
ls

In [ ]:
!ls

In [ ]:
ls vpfit10/

In [ ]:
tailthing = "*.ipynb"

In [ ]:
tailthing

In [ ]:
!ls {tailthing}

In [ ]:
output = !ls

In [ ]:
output

Need to set or change environment variables


In [53]:
%env


Out[53]:
{'SSH_AGENT_PID': '700',
 'TERM_PROGRAM': 'iTerm.app',
 'TERM': 'xterm-color',
 'SHELL': '/bin/bash',
 'initials': 'jbw',
 'CLICOLOR': '1',
 'TMPDIR': '/var/folders/yk/2rgr0zrj0614jntythcnlyvw0000gn/T/',
 'CONDA_SHLVL': '2',
 'CONDA_PROMPT_MODIFIER': '(dspy3) ',
 'BASH': '/Users/jonathan/.dotfiles',
 'TERM_PROGRAM_VERSION': '3.3.9',
 'GSETTINGS_SCHEMA_DIR_CONDA_BACKUP': '',
 'TERM_SESSION_ID': 'w0t1p0:9DEDDCCC-1848-46DB-9007-8706A7A36E5E',
 'USER': 'jonathan',
 'COMMAND_MODE': 'unix2003',
 'CONDA_EXE': '/Users/jonathan/miniconda3/bin/conda',
 'SSH_AUTH_SOCK': '/var/folders/yk/2rgr0zrj0614jntythcnlyvw0000gn/T//ssh-CrMdMiwyP1Of/agent.690',
 '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0',
 '_CE_CONDA': '',
 'CONDA_PREFIX_1': '/Users/jonathan/miniconda3',
 'PATH': '/Users/jonathan/miniconda3/envs/dspy3/bin:/Users/jonathan/miniconda3/condabin:/Users/jonathan/miniconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/usr/local/opt/fzf/bin',
 'GSETTINGS_SCHEMA_DIR': '/Users/jonathan/miniconda3/envs/dspy3/share/glib-2.0/schemas',
 'LaunchInstanceID': '749E6537-5696-41D5-92C9-8E4021679A05',
 'CONDA_PREFIX': '/Users/jonathan/miniconda3/envs/dspy3',
 'PWD': '/Users/jonathan/github/jupyter-tips-and-tricks',
 'EDITOR': 'vim',
 'LANG': 'en_US.UTF-8',
 'ITERM_PROFILE': 'Default',
 'XPC_FLAGS': '0x0',
 'ITERM_ORIG_PS1': '(dspy3) \\n# \\w\\n# \\[\\e[0;32m\\]\\h \\[\\e[0m\\]\\[\\e[0;36m\\]${git_branch}\\[\\e[0;31m\\]$git_dirty\\[\\e[0m\\]$ ',
 'PS1': '(dspy3) \\n# \\w\\n# \\[\\e[0;32m\\]\\h \\[\\e[0m\\]\\[\\e[0;36m\\]${git_branch}\\[\\e[0;31m\\]$git_dirty\\[\\e[0m\\]$ ',
 'PS3': '#? ',
 '_CE_M': '',
 'HISTCONTROL': 'ignoreboth',
 'PS2': '> ',
 'XPC_SERVICE_NAME': '0',
 'GITAWAREPROMPT': '/Users/jonathan/.bash/git-aware-prompt',
 'SHLVL': '1',
 'PS4': '+',
 'HOME': '/Users/jonathan',
 'COLORFGBG': '15;0',
 'LC_TERMINAL_VERSION': '3.3.9',
 'ITERM_PREV_PS1': '\\[\x1b]133;D;$?\x07\x1b]133;A\x07\\](dspy3) \\n# \\w\\n# \\[\\e[0;32m\\]\\h \\[\\e[0m\\]\\[\\e[0;36m\\]${git_branch}\\[\\e[0;31m\\]$git_dirty\\[\\e[0m\\]$ \\[\x1b]133;B\x07\\]',
 'ITERM_SESSION_ID': 'w0t1p0:9DEDDCCC-1848-46DB-9007-8706A7A36E5E',
 'CONDA_PYTHON_EXE': '/Users/jonathan/miniconda3/bin/python',
 'LOGNAME': 'jonathan',
 'CONDA_DEFAULT_ENV': 'dspy3',
 'PROMPT_COMMAND': '__bp_precmd_invoke_cmd; __bp_interactive_mode',
 'LC_TERMINAL': 'iTerm2',
 'DISPLAY': '/private/tmp/com.apple.launchd.krK29PyijB/org.macosforge.xquartz:0',
 'SECURITYSESSIONID': '186a6',
 '_fzf_orig_completion_git': 'complete -o bashdefault -o default -o nospace -F %s git #__git_wrap__git_main',
 'COLORTERM': 'truecolor',
 '_': '/Users/jonathan/miniconda3/envs/dspy3/bin/jupyter',
 'KERNEL_LAUNCH_TIMEOUT': '40',
 'GIT_PYTHON_REFRESH': 'quiet',
 'JPY_PARENT_PID': '97701',
 'PAGER': 'cat',
 'GIT_PAGER': 'cat',
 'MPLBACKEND': 'module://ipykernel.pylab.backend_inline',
 'KMP_INIT_AT_FORK': 'FALSE'}

In [ ]:
%env

Danger zone

_, _N and _iN

In [54]:
!pwd


/Users/jonathan/github/jupyter-tips-and-tricks/notebooks

In [55]:
a = 3
a


Out[55]:
3

In [56]:
2345 * 97543


Out[56]:
228738335

In [57]:
_


Out[57]:
228738335

In [58]:
_55


Out[58]:
3

In [59]:
print(_i55)


a = 3
a

In [ ]:


In [ ]:
saved = _27

In [ ]:
saved

In [ ]:
_

In [ ]:
_i55

In [ ]:
%history -f alex.ipynb

Check out gather (microsoft)


In [ ]: