Wednesday, 29 July 2009

Using ipcluster etc with IPython.

Fire up the cluster, then run IPython and copy/paste the code below.


$ ipcluster -n 8



# Set up the parallel function:
from IPython.kernel import client; tc = client.TaskClient()

@tc.parallel() # define parallel load and return data
def go(x):
import numpy, reference
x.load()
f, p = x.PAFECffp[0, 1:], 20 * numpy.log10(abs(x.PAFECffp[1, 1:]) / 20E-6)
return((f, p))

# Create a list of things to throw at the cluster:
ii = [0, 1, 2, 3, 4, 5] # filename extensions.
a = [mfile.File('/full/path/morph_a' + str(i) + '.O07') for i in ii]

# Engage!
res = go(a)


res should now contain a list of results.

Thursday, 23 July 2009

Data extraction from graphical plots

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]))
# -------------------------------------------------------------

Wednesday, 22 July 2009

ssh non standard ports and general security

Edit /etc/ssh/ssd_config

Change the listening port number

port 22
port 12345

Restart the ssh server:

sudo /etc/init.d/ssh restart


Access it, by

ssh -p xxxx user@192.16x.xxx.xxx

After making these changes, rsync may not work. Use the new port as:

rsync -vzP --port=1234 user@192.168.1.12:/home/user/work/m78/others_from_archive/*.ps ./


------------------------------

from http://forums.devshed.com/bsd-help-31/blocking-a-range-of-ip-s-in-hosts-deny-322368.html

the users allowed to login can be specified in

/etc/ssh/sshd_config

by adding,

# List of user names allowed to log in
AllowUsers sam kim bob mary pete

and

PermitRootLogin no

-----------------------------------------------------

Block specific ip addresses: Edit /etc/hosts.deny and add,

ALL: 64.40.110.235, 64.40.150.235

etc etc. No carriage returns allowed, though i presume line-feed is ok.
Ranges are possible: more reading required.

Friday, 17 July 2009

Constants

Reynolds number: Re = rho * u * d / mu

Dynamic viscosity of air:

μ = 1.7894E − 5 N sm−2 ; note the units: Newton seconds per metre squared. The
units are like those for resistance, except this is over an area.

Sunday, 12 July 2009

Monday, 6 July 2009

Spaces in fstab

Honestly, who puts spaces in directory names?

Anyway, ubuntu fstab needs the following:

//192.168.1.1/No\040Spaces\040Please /mnt/P smbfs credentials=/etc/cifspw 0 0

Sunday, 5 July 2009

Append column or array to numpy array

Troubles remembering this, as it is not a part of the array object, but a numpy function. Anyway, to append a column:

Make sure the array is two dimensional and of expected form:

a = a.reshape(len(a), 1)
b = numpy.append(a, a, axis = 1)

or, if the column to be added is currently looking row-like:

b = numpy.append(a, c.transpose(), axis = 1)


To append a row:
b = numpy.append(a, a, axis = 0)

Wednesday, 1 July 2009

Two monitor ubuntu

sudo nvidia-xconfig --probe-all-gpus -a --twinview-orientation=Clone

worked. man nvidia-xconfig for other options. This was with two cards.

Now fiddle with ~/.fluxbox/init to change the behaviour of session.screen1

Interogating a linux machine

from http://www.linuxjournal.com/content/interrogating-linux-machine

ifconfig
ifconfig -a # network sans loopback

route -a # gateway check

cat /proc/cpuinfo # cpu

ls -lha /proc/kcore # memory

lspci # graphics

cat /proc/interrupts # problems with interupts?

fdisk -l /dev/?d? # HDD. DO NOT USE FDISK! 2TB MBR limits. use parted.

cat /proc/ide/hda/model # HDD model

cat /proc/filesystems # compatible filesystems

lsmod # drivers loaded

lsusb # usb devices

rpm -qa # rpm installed software
dpkg -l # another flavour