Install Engauge.
Import the graphics file.
Set the axes points and limits. Set log or not in Settings / Coordinates.
In 'segment fill', click on sections of the plot, when the rotating thingy runs around them.
The sections available were probably bright green. Missed parts can be added with 'curve point'
Export the data. This generates a .csv file.
Use the following:
Generate regression data:
# import data
fn = 'filename.csv'
a = file(fn, 'r')
b = a.readlines()
c = [i.strip('\n').split(',') for i in b[1:]] # 1st line has text.
d = []
for i in c:
d.append([float(j) for j in i])
d = array(d)
plot(d[:, 0], d[:, 1])
# or do it the easy way. :)
a = mfile.File('fn'); a.load(); d = a.data
# generate regression info. 4th order polynomial
e = polyfit(d[:, 0], d[:, 1], 4)
# and plot against original data
plot(d[:, 0], d[:, 1])
plot(d[:, 0], e[0] * d[:, 0] ** 4 + e[1] * d[:, 0]**3 + e[2] *d[:, 0]**2 + e[3] * d[:, 0] + e[4])
If that's a crap fit, loglog data may look better:
# ------------------------------------------------------------
f = log10(d) # point by point log10
g = polyfit(f[:, 0], f[:, 1], 4) # polynomial fit to the loglog data
plot(f[:, 0], f[:, 1]) # plot original data, log10'd
plot(d[:, 0], 10**(g[0] * log10(d[:, 0]) ** 4 + g[1] * log10(d[:, 0])**3 + g[2] * log10(d[:, 0])**2 + g[3] * log10(d[:, 0]) + g[4]))
# -------------------------------------------------------------
No comments:
Post a Comment