forked from CRPropa/CRPropa3-notebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.py
31 lines (28 loc) · 925 Bytes
/
convert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from subprocess import call
from sys import argv
def convert(fname):
"""
Convert ipython notebook from nbformat=4 to 3
jupyter-nbconvert --to=notebook --nbformat=3 xxx --output=yyy
"""
ofname = fname.replace('.v4','.v3')
call(['jupyter-nbconvert', '--to=notebook', '--nbformat=3', fname, '--output=%s'%ofname])
files = (
'basics/basics.v4.ipynb',
'galactic_backtracking/galactic_backtracking.v4.ipynb',
'galactic_lensing/lensing_cr.v4.ipynb',
'galactic_lensing/lensing_maps.v4.ipynb',
'galactic_trajectories/galactic_trajectories.v4.ipynb',
'secondaries/neutrinos.v4.ipynb',
'secondaries/photons.v4.ipynb',
'sim1D/sim1D.v4.ipynb',
'trajectories/trajectories.v4.ipynb'
)
if len(argv) == 1:
# convert all listed notebooks from v4 to v3
for f in files:
convert(f)
else:
# convert specific notebooks
for f in argv[1:]:
convert(f)