Monday 23 May 2016

future

netatmo

Julia cheat list.

Flattening nested lists: use vec(l) DataFrames: Set data up either column or row centric as desired. If row centric, add a new row with,

using DataFrames
DF = DataFrame

In [106]:

a = DF(a = [1,2,3], b = [4,5,6])
# add a new row at the end. `;` is shorthand  for vcat, I think.
a = [a; DF(a = [7], b = [8])]
Out[106]:
        a b
1 1 4
2 2 5
3 3 6
4 7 8
Column-centric to me, often feels better:

In [109]:

a = DF(a = [1,2,3], b = [4,5,6])
a[:newColumn] = [7,8,9]

Out[109]:
a b newColumn
1 1 4 7
2 2 5 8
3 3 6 9
but then plotting with GadGly is much neater if we have three columns with all the data: c1 -> x axis; c2 -> y axis; c3 = color of plot. At plot time, rearrange so that the column title becomes the color entry:
Out[109]:
a b newColumn
1 1 4 7
2 2 5 8
3 3 6 9

In [110]: b = stack(a, [:a, :b])

Out[110]:
       variable value newColumn
1 a 1 7
2 a 2 8
3 a 3 9
4 b 4 7
5 b 5 8
6 b 6 9

Wednesday 4 May 2016

Beautiful acoustics log-log scales with GadFly


# Set up acoustics graph parameters.
drop = [log10(i) for i in [500, 700, 900, 5000, 7000, 9000, 50000, 70000, 90000]];
xlist = [[1000:1000:9000]; [10000:10000:100000]]
ylist = [[400:100:900]; [1000:1000:9000]; [10000:10000:100000]];
labx = x -> x in drop ? "": @sprintf("%0.0f", 10^(Float64(x)-3));
laby = y -> y in drop ? "": y > log10(900) ? @sprintf("%.0f", 10^(Float64(y)-3)): @sprintf("%0.1f", 10^(Float64(y)-3));
xt, yt = [log10(i) for i in xlist], [log10(i) for i in ylist]
xl, yl, tit = "f (kHz)", "|Ze| (kΩ)", "High resolution LCR measurement of Prowave device.";



int = res["20160504-1"]["int"];
plt = DataFrame(f = f, absZe=abs(int[f]))
plot(plt, x = :f, y = :absZe, Geom.line, 
  Scale.x_log10(labels=labx), Scale.y_log10(labels=laby), 
Guide.xlabel(xl), Guide.ylabel(yl), Guide.xticks(ticks = xt), Guide.yticks(ticks = yt), Guide.title(tit))
Created,