-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
52 lines (44 loc) · 1.65 KB
/
tasks.py
File metadata and controls
52 lines (44 loc) · 1.65 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from invoke import task
from pathlib import Path
basepath = r"/Users/moldor/Documents/Thesis/voltagefit_neural_ode/voltage_fitting"
open_cmd = "open"
fig_names = {
"1": "paper/data",
"2": "paper/grid_search_fit",
"3": "paper/no_diff",
"4": "paper/u_diff",
"5": "paper/fit_to_experiment",
"6": "paper/multi_fitting",
"7": "paper/pospischil",
}
@task
def convertpngpdf(c, fig):
_convertsvg2pdf(c, fig)
_convertpdf2png(c, fig)
########################################################################################
# Helpers
########################################################################################
@task
def _convertsvg2pdf(c, fig):
if fig is None:
for f in range(len(fig_names)):
_convert_svg2pdf(c, str(f + 1))
return
pathlist = Path(f"{basepath}/{fig_names[fig]}/fig/").glob("*.svg")
for path in pathlist:
output_file = str(path).replace(".svg", ".pdf")
#c.run(f"inkscape {str(path)} --export-pdf={str(path)[:-4]}.pdf")
c.run(f'inkscape "{str(path)}" --export-type=pdf --export-filename="{output_file}"')
@task
def _convertpdf2png(c, fig):
if fig is None:
for f in range(len(fig_names)):
_convert_pdf2png(c, str(f + 1))
return
pathlist = Path(f"{basepath}/{fig_names[fig]}/fig/").glob("*.pdf")
for path in pathlist:
output_file = str(path).replace(".pdf", ".png")
c.run(
#f'inkscape {str(path)} --export-png={str(path)[:-4]}.png -b "white" --export-dpi=250'
f'inkscape "{str(path)}" --export-type=png --export-filename="{output_file}" --export-dpi=250'# --background="white"'
)