Monday, 23 May 2016
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,
Thursday, 28 April 2016
Pkg.update() Julia git permissions ownership error on update.
In /home/me/:
sudo chown -Rc $UID .julia/
Jupyter notebook manifested the error in update okay with git errors reported. But on reinstallation of julia the kernel died. Running Julia natively from home/user showed the git write error. Applying the command above changed masses of permissions and then in the native julia from home,
using JLD
precompiled okay....
Monday, 18 April 2016
Diet and exercise
| DateTime | Item | Energy (MJ) | Goodness | Salt RDA |
| | | Exercise, assume 25% efficient | | |
|:----------:|:----------------------------------------------:|:----------------------------------:|:-----------------------------:|:------------------------------------:|
| 18/4/16:930| Cycle to work | Estimate: 0.25*10N * 2.5km = 25kJ | 1. if 25% efficient, 100kJ | 2.4g(40%) + 1.8g(30%) + 3*0.45g(23%) |
| 18/4/16:10 | Two pot noodes, three bags nik-naks, 3 coffees | 2.2 + 1.8 + 3 * 0.7 = 6.1 | | |
| | Bowl of Alpen | 1.5 | Good. :D | 0.25g.|
| 19/6/16 | Two nik-naks, 2 bananas, five milk choc hob | | | |
Cycling to work burns about 1/5 packet of nik-naks. :(
Saturday, 19 March 2016
Guildwars 2 GW2 table
Chef Jewel
JA 400 183
KS
PS
GB
JE
DS
FE
| Material | Boon | Duration | Profession | Level |
|:------------------------:|:-------------------------------------------------:|:----------:|:----------:|:-----:|
| Furious maintenance oil | prec += 0.06Toughness + 0.04Vitality | 30 m | Huntsman | 400 |
Subscribe to:
Posts (Atom)