ltunify – Failed to send pair request

If you get the error message “Failed to send pair request” when using “ltunify pair” it may be due to that the number of devices you have paired has reached the maximum number.

Check this by typing

ltunify list

If you have 6 paired devices (at least on my computer running Arch) you will get the error message. You may find the maximum number by typing “ltunify”.

Just unpair one of the devices you are not using

ltunify unpair idx

Where idx is the number of the device to be unpaired.

Then try pairing your device again.

How to split a string using Awk

Using Awk a string may be split at least using two different methods.

Let’s split the strings given in file foo. The file consists of 5 columns separated by a comma (,) so we will split the lines at “,”.

Split
awk ‘{split($0,array,”,”)}{print array[1],array[2],array[3],array[4],array[5]} foo

-F
awk -F “,” ‘{print $1,$2,$3,$4,$5}’ foo

Where foo is a file such as this e.g:
1005.709115,-3.974680,0.081765,3.265020,Wed 23 Nov 2011 11:27:14 AM UTC
1006.709004,-3.974761,0.084558,3.265004,Wed 23 Nov 2011 11:27:15 AM UTC
1007.708987,-3.973002,0.087218,3.265001,Wed 23 Nov 2011 11:27:16 AM UTC
1008.709055,-3.969182,0.089719,3.265034,Wed 23 Nov 2011 11:27:17 AM UTC

Soldiagram

Soldiagram benyttes for å visualisere hvordan skyggene kastes fra feks bygninger. Dette er aktuelt ved nybygg og påbygning.
Jeg kan beregne soldiagram og hvordan Solen beveger seg over himmelen sett fra et gitt ståsted feks Oslo.

Kontakt ove at azimuth dot biz for mer informasjon.
Tlf: 90523434

Visiting Reykjavik

Geodesy at work in Reykjavik, Iceland

Iceland
My visit to Reykjavik, this time – mid September 2010, was work related.
My original working plan was to make a gravity tie and then demobilize a sea gravimeter.
Prior to my arrival, my contact person at Iceland had informed me that there would possible be a strike by the ship engineers starting sometime after they have arrived in the harbor. However, there was no information when the strike would begin.

After arriving at Keflavik airport, I took a taxi to the Reykjavik harbor to pick up the land gravimeter and do the gravity tie before the boat arrived. However, the boat was already there.
So the measurements of the gravity tie was postponed and I started demobilizing the sea gravimeter hoping to be finished before the strike would begin.
Working as fast as possible, after less than one hour, I was ready to put the instrument into the wooden travel boxes and bring then off the ship.

Then, the strike started!

So, instead, I did the gravity tie, connecting the measurements made by the sea gravimeter to land measurements.

Gravity tie at the harbour

Find minimum and maximum using AWK

Let’s assume you want to find the minimum and/or maximum of a column of numbers in a given file using AWK.

Assume we have an input file foo with f.ex. line number in first column and in the second ($2) and third column ($3 in awk) we have the values of interest.

File: foo

1 2 40
2 3 23
3 15 -12
4 8 -1
5 11 0

Use the following awk commando find minimum and maximum of the columns of interest:

awk ‘NR == 1 {max=$2 ; min=$2} $2 >= max {max = $2} $2 <= min {min = $2} END { print "Min: "min,"Max: "max }' foo

or

awk ‘BEGIN{ max = -999999999 ; min = 9999999999 } $2 > max {max = $2} $2 < min {min = $2} END{ print "Min: ",min, "Max: ",max }' foo

The result will be for column 2:

Min: 2 Max: 15

and for column 3:

Min: -12 Max: 40

Standard deviation

Here you may see how to calculate the standard deviation using AWK.

Average or arithmetic mean

Here you may see how to calculate the average or arithmetic mean using AWK.

Harstad og sommersolverv

Jeg fikk et lite oppdrag her om dagen.
Rundt sommersolverv skal noen gjøre filmopptak i Harstad.
I den forbindelse var det ønsket å finne når Solen står i nord og sør for 21. og 22. juni 2010. Altså for dagene rundt sommersolverv.

Harstad kirke Nord Sør
21.06.2010 00:55 12:55
22.06.2010 00:56 12:56

Sommersolverv inntreffer 13:28 (norsk sommertid!) den 21. juni 2010. Dette gjelder for hele verden!

Ønsker du å få beregnet Solens posisjon, eller hvordan skyggen beveger seg over tomten din pga naboens nybygg?
Da kan jeg beregne dette for deg!

Ta kontakt på: ove at azimuth dot biz
Eller legg igjen en beskjed i kommentarfeltet.

Pythons Simple HTTP Server

There is a nice little feature in Python that a friend of mine showed me. You may use Python as a Web Server… and that is right out of the box. No additional programs to install or any tweaking at all 🙂

Move to the folder you want to make available for others to see.
Then type
python -m SimpleHTTPServer

If you want to use a special port you may type something like this:

python -m SimpleHTTPServer 8713

Others may browse your directory and directories below.
If you haven’t specified a port, in your browser type :
http://your.ip:8000/

Or, if you have specified a port
http://your.ip:8713/

Enjoy 🙂

Calculate standard deviation using AWK

The standard deviation ? (sigma) is the square root of the average value of (X – ?)2.

In the case where X takes random values from a finite data set x1, x2, …, xN, with each value having the same probability, the standard deviation is

  where mu

Assume we have an input file foo with f.ex. line number in first column and in the second column ($2 in awk) we have the values of interest.

File: foo

1 2
2 3
3 6
4 8
5 11

Use the one of the following awk commandos to calculate the standard deviation

awk ‘{sum+=$2; array[NR]=$2} END {for(x=1;x<=NR;x++){sumsq+=((array[x]-(sum/NR))^2);}print sqrt(sumsq/NR)}’ foo

awk ‘{sum+=$2;sumsq+=$2*$2} END {print sqrt(sumsq/NR – (sum/NR)^2)}’ foo

The result is

3.28634

Average

Here you may find how to calculate the average or arithmetic mean using AWK.

Minimum and maximum

Here you may find how to calculate the minimum and maximum values using AWK.