Archive for June, 2010

Starlink has its own image format (the NDF format, .sdf extension) which is not perhaps so convenient as the fits format. Nevertheless, there are ways to read the contents of the fits headers of your .sdf files, depending on the program you are working with.

With KAPPA you can use the command:
$ fitslist file.sdf
while with FIGARO you can use the:
$ fitskeys file.sdf.

In any case you should first invoke the appropriate application (either KAPPA of FIGARO).

In order to get the mean value of column 1 (or any other) you type:
$ awk 'BEGIN{s=0;}{s=s+$1;}END{print s/NR;}' file

In order to get the standard deviation of column 1 you type:
$ awk '{sum+=$1; sumsq+=$1*$1} END {print sqrt(sumsq/NR - (sum/NR)^2)}' file

or

$ awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }' file

The second option is working better with large numbers of data, without having the possibility for overflow.

Sources: utah.edu/awk , commandlinefu.com/standard deviation with awk

Useful small things for c-shell

Posted June 2, 2010 By grigoris

> When using if statement in c-shell you have to be careful with the syntax:

if (condition) then
(commands)
endif

or if you want to add another case then

if (condition) then
(commands)
else
(commands)
endif

Important to remember that after “then” you must continue to a new line.

> “exit” is the one option to work with if statement, since “break” works only with foreach/while

> If you want to assign the output of a command to a variable the \n you have to place this into backticks ` … ` like:
set test = `grep "test text" temp`