From: W. Trevor King Date: Mon, 15 Mar 2010 20:18:03 +0000 (-0400) Subject: Fixed cantilever-data figure Makefile dependencies (again :p) X-Git-Tag: v1.0~418 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3a58b8aaf61dbe4e249b436ed67c93364cbf63b1;p=thesis.git Fixed cantilever-data figure Makefile dependencies (again :p) --- diff --git a/tex/src/figures/cantilever-data/Makefile b/tex/src/figures/cantilever-data/Makefile index f08f706..fa4881d 100644 --- a/tex/src/figures/cantilever-data/Makefile +++ b/tex/src/figures/cantilever-data/Makefile @@ -8,11 +8,15 @@ V_DEP_DATA = v-dep.d/v_dep_131.98.dat \ v-dep.d/v_dep_131.98.fit \ v-dep.d/v_dep_24.33.dat \ v-dep.d/v_dep_24.33.fit -LOADING_RATE_DATA = loading-rate.d/loading_rate_131.98 \ - loading-rate.d/loading_rate_24.33 +LOADING_RATE_DATA = loading-rate.d/loading_rate_131.98.dat \ + loading-rate.d/loading_rate_24.33.dat DATA = $(V_DEP_DATA) $(LOADING_RATE_DATA) DATA_DIRS = data v-dep.d loading-rate.d +# Never delete intermediates. (`info make` 10.4 Chains of Implicit Rules) +.SECONDARY : + + all : $(FIGS:%=%_.tex) clean : @@ -25,17 +29,25 @@ clean : $(DATA_DIRS) : mkdir $@ -data/raw : extract_f_v_k_data.sh $(DATA_DIRS) +data/raw : extract_f_v_k_data.sh | data touch data/raw # ./$< > $@ -data/spring-constants data/averaged-data : avg_data.py data/raw +data/avg : avg_data.py data/raw + touch $@ # "avg" marks the time of last avg_data.py run python $< -v-dep.d/v_dep_%.dat : \ - get_v_dep.sh data/spring-constants data/averaged-data +data/spring-constants data/averaged-data : data/avg + @echo "$@ already build for target data/avg" + +v-dep.d/dat : get_v_dep.sh data/spring-constants data/averaged-data \ + | v-dep.d + touch $@ # "dat" marks the time of last *.dat file generation ./$< +v-dep.d/v_dep_%.dat : v-dep.d/dat + @echo "$@ already build for target v-dep.d/dat" + v-dep.d/v_dep_%.fit : fit_data.py v-dep.d/v_dep_%.dat python $^ > $@ @@ -51,5 +63,10 @@ v-dep.eps : v-dep.pdf v-dep-rotated.pdf : v-dep.pdf pdftk $< cat 1E output $@ -loading-rate.d/loading_rate_% : get_loading_rates.py avg_data.py data/raw +loading-rate.d/dat : get_loading_rates.py avg_data.py data/raw \ + | loading-rate.d + touch $@ # "dat" marks the time of last *.dat file generation python $< + +loading-rate.d/loading_rate_%.dat : loading-rate.d/dat + @echo "$@ already build for target loading-rate.d/dat" diff --git a/tex/src/figures/cantilever-data/avg_data.py b/tex/src/figures/cantilever-data/avg_data.py index b422291..73bab0d 100755 --- a/tex/src/figures/cantilever-data/avg_data.py +++ b/tex/src/figures/cantilever-data/avg_data.py @@ -8,59 +8,69 @@ AVGFILE='./data/averaged-data' KCUTS=[45, 90] -FofV = {} -Ks = [] -for i in range(len(KCUTS)+1): - Ks.append([]) +def read_raw(Kcuts=KCUTS, datafile=DATAFILE): + FofV = {} + Ks = [] + for i in range(len(Kcuts)+1): + Ks.append([]) + for line in file(datafile, 'r'): + if line[0] == '#': + continue # ignore comments + fields = line.strip().split('\t') + force = float(fields[0]) + rate = float(fields[1]) + spring = float(fields[2]) -for line in file(DATAFILE, 'r'): - if line[0] == '#': - continue # ignore comments - fields = line.strip().split('\t') - force = float(fields[0]) - rate = float(fields[1]) - spring = float(fields[2]) - - ispring = 0 - while ispring < len(KCUTS) and spring > KCUTS[ispring]: - ispring += 1 - Ks[ispring].append(spring) - if rate not in FofV.keys(): - FofV[rate]=[] - for i in range(len(Ks)): - FofV[rate].append([]) - FofV[rate][ispring].append(force) + ispring = 0 + while ispring < len(Kcuts) and spring > Kcuts[ispring]: + ispring += 1 + Ks[ispring].append(spring) + if rate not in FofV.keys(): + FofV[rate]=[] + for i in range(len(Ks)): + FofV[rate].append([]) + FofV[rate][ispring].append(force) + return (Ks, FofV) -avgK = [0]*len(Ks) -stdK = [0]*len(Ks) -numK = [0]*len(Ks) -kf = file(KFILE, 'w') -for i in range(len(Ks)): - K = numpy.array(Ks[i]) - avgK[i] = K.mean() - stdK[i] = K.std() - numK[i] = len(K) - - if i == 1: - continue # poor calibration bumps for the older cantilevers - print >> kf, "K(%d) = %g +/- %g, (# %d)" % (i, avgK[i], stdK[i], numK[i]) -kf.close() +def write_k_file(Ks, kfile=KFILE): + avgK = [0]*len(Ks) + stdK = [0]*len(Ks) + numK = [0]*len(Ks) + kf = file(kfile, 'w') + for i in range(len(Ks)): + K = numpy.array(Ks[i]) + avgK[i] = K.mean() + stdK[i] = K.std() + numK[i] = len(K) - -Vs = FofV.keys() -Vs.sort() -af = file(AVGFILE, 'w') -print >> af, '#'+'\t'.join(['Pulling speed (nm/s)','Spring constant (pN/nm)', - 'Mean force (pN)','Std. force (pN)','Events (#)']) -for V in Vs: - for i,k in enumerate(avgK): if i == 1: continue # poor calibration bumps for the older cantilevers - F = numpy.array(FofV[V][i]) - if len(F) == 0: - continue - outs= [V, k, F.mean(), F.std(), len(F)] - souts = ["%.2f" % (x) for x in outs] - souts[-1] = "%d" % outs[-1] # special treatment for the integer - print >> af, '\t'.join(souts) -af.close() + print >> kf, "K(%d) = %g +/- %g, (# %d)" \ + % (i, avgK[i], stdK[i], numK[i]) + kf.close() + return (avgK, stdK, numK) + +def write_average_file(FofV, avgK, avgfile=AVGFILE): + Vs = FofV.keys() + Vs.sort() + af = file(AVGFILE, 'w') + print >> af, '#'+'\t'.join(\ + ['Pulling speed (nm/s)','Spring constant (pN/nm)', + 'Mean force (pN)','Std. force (pN)','Events (#)']) + for V in Vs: + for i,k in enumerate(avgK): + if i == 1: + continue # poor calibration bumps for the older cantilevers + F = numpy.array(FofV[V][i]) + if len(F) == 0: + continue + outs= [V, k, F.mean(), F.std(), len(F)] + souts = ["%.2f" % (x) for x in outs] + souts[-1] = "%d" % outs[-1] # special treatment for the integer + print >> af, '\t'.join(souts) + af.close() + +if __name__ == '__main__': + Ks,FofV = read_raw() + avgK,stdK,numK = write_k_file(Ks) + write_average_file(FofV, avgK) diff --git a/tex/src/figures/cantilever-data/get_loading_rates.py b/tex/src/figures/cantilever-data/get_loading_rates.py index bf3c569..efb310c 100755 --- a/tex/src/figures/cantilever-data/get_loading_rates.py +++ b/tex/src/figures/cantilever-data/get_loading_rates.py @@ -14,7 +14,7 @@ OFILEs = [None, None, None] for i,K in enumerate(Ks): if K == None: continue - OFILEs[i] = file('loading-rate.d/loading_rate_%.2f' % K, 'w') + OFILEs[i] = file('loading-rate.d/loading_rate_%.2f.dat' % K, 'w') for line in file(DATA, 'r'): if line[0] == '#': diff --git a/tex/src/figures/cantilever-data/loading-rate.asy b/tex/src/figures/cantilever-data/loading-rate.asy index 114c548..ce6ef9e 100644 --- a/tex/src/figures/cantilever-data/loading-rate.asy +++ b/tex/src/figures/cantilever-data/loading-rate.asy @@ -6,9 +6,9 @@ scale(Log, Linear); real xscale=1; real yscale=1; -graphFile("loading-rate.d/loading_rate_131.98", xscale, yscale, phard, m8, +graphFile("loading-rate.d/loading_rate_131.98.dat", xscale, yscale, phard, m8, t=units("131.98","pN/nm"), dots=true); -graphFile("loading-rate.d/loading_rate_24.33", xscale, yscale, red, m8, +graphFile("loading-rate.d/loading_rate_24.33.dat", xscale, yscale, red, m8, t=units("24.33","pN/nm"), dots=true); xlimits(1,3e3);