From 41b3866b4c42539c1d18a2feb134c0f599262a50 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 1 May 2010 22:06:21 -0400 Subject: [PATCH] Convert kappa-sawteeth from Gnuplot to Asymptote. Also: * Cleanup Asymptote scanner rules and add descriptive comments. * Asymptote scanner rules no longer match directories (e.g. "."). --- tex/site_cons/site_tools/asymptote.py | 10 ++-- tex/src/figures/kappa-sawteeth/SConscript | 22 +++++++- tex/src/figures/kappa-sawteeth/fig.gp | 53 ------------------- .../{data-0.001 => k-0.001.dat} | 0 .../kappa-sawteeth/{data-0.01 => k-0.01.dat} | 0 .../kappa-sawteeth/{data-0.05 => k-0.05.dat} | 0 .../kappa-sawteeth/{data-0.1 => k-0.1.dat} | 0 .../kappa-sawteeth/{data-0.5 => k-0.5.dat} | 0 .../kappa-sawteeth/{data-1 => k-1.dat} | 0 .../kappa-sawteeth/{data-10 => k-10.dat} | 0 .../figures/kappa-sawteeth/kappa-sawteeth.asy | 43 +++++++++++++++ tex/src/sawsim/discussion.tex | 5 +- 12 files changed, 73 insertions(+), 60 deletions(-) delete mode 100644 tex/src/figures/kappa-sawteeth/fig.gp rename tex/src/figures/kappa-sawteeth/{data-0.001 => k-0.001.dat} (100%) rename tex/src/figures/kappa-sawteeth/{data-0.01 => k-0.01.dat} (100%) rename tex/src/figures/kappa-sawteeth/{data-0.05 => k-0.05.dat} (100%) rename tex/src/figures/kappa-sawteeth/{data-0.1 => k-0.1.dat} (100%) rename tex/src/figures/kappa-sawteeth/{data-0.5 => k-0.5.dat} (100%) rename tex/src/figures/kappa-sawteeth/{data-1 => k-1.dat} (100%) rename tex/src/figures/kappa-sawteeth/{data-10 => k-10.dat} (100%) create mode 100644 tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy diff --git a/tex/site_cons/site_tools/asymptote.py b/tex/site_cons/site_tools/asymptote.py index 707d91d..1ad5466 100644 --- a/tex/site_cons/site_tools/asymptote.py +++ b/tex/site_cons/site_tools/asymptote.py @@ -44,10 +44,14 @@ def asymptote_scan(node, env, path, arg=None): contents = node.get_contents() # for older versions of SCons, fall back on binary read ret = [] for string in double_quoted_string_re.findall(contents): + if string in ret: + continue # we've already added this dependency + if len(string) == 0: + continue # empty string not much of a dependency ;) p = os.path.join(node.dir.srcnode().abspath, string) - if len(string) > 0 and \ - ((string not in ret and os.path.exists(p)) - or string.endswith('.dat')): + if os.path.exists(p) and os.path.isfile(p): # probably an include file + ret.append(string) + elif string.endswith('.dat'): # marker for auto-generated include files ret.append(string) return ret diff --git a/tex/src/figures/kappa-sawteeth/SConscript b/tex/src/figures/kappa-sawteeth/SConscript index d8ff28f..6ea6c9f 100644 --- a/tex/src/figures/kappa-sawteeth/SConscript +++ b/tex/src/figures/kappa-sawteeth/SConscript @@ -1,8 +1,26 @@ +from site_cons.site_init import link_wtk_graph + + +FIGURES = ['kappa-sawteeth'] + # Get the passed in environment. Import('env') -for gp in Glob('*.gp'): - env.Gnuplot(gp) +# we generate include files on the fly in kappa-sawteeth.asy, my +# default Asymptote scanner won't work. As a fallback, we set the +# dependencies explicitly. +kappa_sawteeth_data = env.Glob("k-*.dat"); + +wtk_graph = link_wtk_graph(env) + +for fig in FIGURES: + asyfile = '%s.asy' % fig # static .asy file + pyfig = fig.replace('-', '_') + data = '%s_data' % (pyfig) + asydata = [] + if data in globals(): # generated data dependencies + asydata = globals()[data] + env.Asymptote([asyfile, wtk_graph] + asydata) # Pass back the modified environment. Return('env') diff --git a/tex/src/figures/kappa-sawteeth/fig.gp b/tex/src/figures/kappa-sawteeth/fig.gp deleted file mode 100644 index 19c74d2..0000000 --- a/tex/src/figures/kappa-sawteeth/fig.gp +++ /dev/null @@ -1,53 +0,0 @@ -set terminal pdf enhanced font 'Times,7' size 9cm, 9cm -set output 'fig.pdf' -unset key -set style data lines -set xrange [-40:250] -set yrange [0:400] -set ytics 0,200 -set xtics nomirror -set ytics nomirror -# border 3 = bottom & left -set border 3 -set lmargin 9 - -set multiplot - -set size 1,0.22; -set origin 0.0,0.0; -set xlabel 'Extension (nm)' -set label 1 "{/Symbol k}_c = 1 pN/nm" at -35,300 -plot 'data-0.001' using (($1-$2/0.001)*1e9):($2*1e12) - -set size 1,0.13 -set bmargin 0 -unset xlabel -set xtics format "" - -set origin 0.0,0.22; -set label 1 "{/Symbol k}_c = 10 pN/nm" at -35,300 -plot 'data-0.01' using (($1-$2/0.01)*1e9):($2*1e12) - -set origin 0.0,0.35; -set label 1 "{/Symbol k}_c = 50 pN/nm" at -35,300 -plot 'data-0.05' using (($1-$2/0.05)*1e9):($2*1e12) - -set origin 0.0,0.48; -set ylabel "Force (pN)" -set label 1 "{/Symbol k}_c = 100 pN/nm" at -35,300 -plot 'data-0.1' using (($1-$2/0.1)*1e9):($2*1e12) - -set origin 0.0,0.61; -unset ylabel -set label 1 "{/Symbol k}_c = 500 pN/nm" at -35,300 -plot 'data-0.5' using (($1-$2/0.5)*1e9):($2*1e12) - -set origin 0.0,0.74; -set label 1 "{/Symbol k}_c = 1 nN/nm" at -35,300 -plot 'data-1' using (($1-$2/1)*1e9):($2*1e12) - -set origin 0.0,0.87; -set label 1 "{/Symbol k}_c = 10 nN/nm" at -35,300 -plot 'data-10' using (($1-$2/10)*1e9):($2*1e12) - -unset multiplot diff --git a/tex/src/figures/kappa-sawteeth/data-0.001 b/tex/src/figures/kappa-sawteeth/k-0.001.dat similarity index 100% rename from tex/src/figures/kappa-sawteeth/data-0.001 rename to tex/src/figures/kappa-sawteeth/k-0.001.dat diff --git a/tex/src/figures/kappa-sawteeth/data-0.01 b/tex/src/figures/kappa-sawteeth/k-0.01.dat similarity index 100% rename from tex/src/figures/kappa-sawteeth/data-0.01 rename to tex/src/figures/kappa-sawteeth/k-0.01.dat diff --git a/tex/src/figures/kappa-sawteeth/data-0.05 b/tex/src/figures/kappa-sawteeth/k-0.05.dat similarity index 100% rename from tex/src/figures/kappa-sawteeth/data-0.05 rename to tex/src/figures/kappa-sawteeth/k-0.05.dat diff --git a/tex/src/figures/kappa-sawteeth/data-0.1 b/tex/src/figures/kappa-sawteeth/k-0.1.dat similarity index 100% rename from tex/src/figures/kappa-sawteeth/data-0.1 rename to tex/src/figures/kappa-sawteeth/k-0.1.dat diff --git a/tex/src/figures/kappa-sawteeth/data-0.5 b/tex/src/figures/kappa-sawteeth/k-0.5.dat similarity index 100% rename from tex/src/figures/kappa-sawteeth/data-0.5 rename to tex/src/figures/kappa-sawteeth/k-0.5.dat diff --git a/tex/src/figures/kappa-sawteeth/data-1 b/tex/src/figures/kappa-sawteeth/k-1.dat similarity index 100% rename from tex/src/figures/kappa-sawteeth/data-1 rename to tex/src/figures/kappa-sawteeth/k-1.dat diff --git a/tex/src/figures/kappa-sawteeth/data-10 b/tex/src/figures/kappa-sawteeth/k-10.dat similarity index 100% rename from tex/src/figures/kappa-sawteeth/data-10 rename to tex/src/figures/kappa-sawteeth/k-10.dat diff --git a/tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy b/tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy new file mode 100644 index 0000000..f5d0b7a --- /dev/null +++ b/tex/src/figures/kappa-sawteeth/kappa-sawteeth.asy @@ -0,0 +1,43 @@ +import wtk_graph; + +size(15cm,10cm,IgnoreAspect); + +scale(Linear, Linear); +real xscale=1e9; +real fscale=1e12; + +void graphSawtooth(string file="datafile", real k, + int xcol=0, int fcol=1, + real xscale=1, real fscale=1, real dx=0, real df=0, + pen p=red, string t="Title") { + file fin=input(file).line(); + real[][] a=fin.dimension(0,0); + a=transpose(a); + real[] x=a[xcol]; + real[] f=a[fcol]; + x = x - f/k; /* Remove cantilever extension */ + graphData(x=x, y=f, xscale=xscale, yscale=fscale, + dx=dx, dy=df, p=p, t=t, dots=false); +} + +real[] k = {0.001, 0.01, 0.05, 0.1, 0.5, 1, 10}; +int i; +for (i=k.length-1; i>=0; --i) {/* count down so legend and plot orders match */ + string file = format("k-%f", k[i])+"."+"dat"; + /* We break up .dat so the Asymptote scanner doesn't pick up + * .dat as a dependency (which obviously doesn't exist). */ + string label = format("$k=%f\mbox{ pN/nm}$", k[i]*1e3); + if (k[i] >= 1) + label = format("$k=%f\mbox{ nN/nm}$", k[i]); + // TODO: rainbow pen(N, i) + graphSawtooth(file=file, k=k[i], xscale=xscale, fscale=fscale, + df=300e-12*i, p=psoft, t=label); +} + +xlimits(0, 300e-9*xscale, crop=true); +xaxis(sLabel("Distance (nm)"), BottomTop, LeftTicks); +yaxis(sLabel("Force (pN)"), LeftRight, RightTicks); +label(sLabel("Simulated force curves"), point(N), N); + +add(legend(), point(E), 20E); +//add(lengend(). point(E), 20E); //, UnFill); diff --git a/tex/src/sawsim/discussion.tex b/tex/src/sawsim/discussion.tex index df48689..9f9123c 100644 --- a/tex/src/sawsim/discussion.tex +++ b/tex/src/sawsim/discussion.tex @@ -216,12 +216,13 @@ to WLC\index{WLC} or other polymer models (\cref{fig:expt-sawtooth}). \begin{figure} \begin{center} -\includegraphics{figures/kappa-sawteeth/fig} +\asyfig{figures/kappa-sawteeth/kappa-sawteeth} \caption{Simulated force curves obtained from pulling a polymer with eight protein molecules using cantilevers with different force constants $\kappa_c$. Parameters used in generating these curves are the same as those used in \cref{fig:sawsim:sim-all}, except the - cantilever force constant.\label{fig:sawsim:kappa-sawteeth}} + cantilever force constant. Successive force curves are offset by + $300\U{pN}$ for clarity.\label{fig:sawsim:kappa-sawteeth}} \end{center} \end{figure} -- 2.26.2