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 :
$(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 $^ > $@
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"
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)
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);