Thursday, April 22, 2010

Gildas CLASS

It's absurdly difficult to find help on GILDAS Class, probably because you can't google "class" and most people probably don't label every piece of code with "GILDAS class".

Anyway, here are some scripts that I refer back to often:

file in August2009BGPS.dat
file out August2009fits.dat multiple
on error "file out August2009fits.dat"
say "READ IN FILES"
define character sourcelist*10[300]
accept sourcelist /column observed_sources.txt
on error "continue"
get 1001
set window -100 160
set mask -400 -100 160 400
set mode x -400 400
set align velocity
for i 1 to 161
say "Working on SOURCE "'i'
find /source 'sourcelist[i]' /telescope "CSO 4GHZ IF1" /offset 0 0 /quality 5
average
on error "@avplot2 'sourcelist[i]' 'i'; next"
base 3
line 0
min
plot
vis
write i
! on error "continue"
next


and


file in araya-2004.cls
find
define character filename*20
for i 1 to 20
say "Working on source "'i'
get next
let filename "araya-2004_"'i'".fits"
say "fits write "'filename'" /mode spectrum"
fits write 'filename' /mode spectrum
next

!file in araya-2002.cls
!find
!define character filename*20
!for i 1 to 42
! say "Working on source "'i'
! get i
! let filename "araya-2002_"'i'".fits"
! say "fits write "'filename'" /mode spectrum"
! fits write 'filename' /mode spectrum
!next

Thursday, April 15, 2010

Montage wrapper

(I'm going to try to gradually shift my blogging to this one...)

I wrote a bash wrapper for Tom Robitaille's montage wrapper to allow fits wildcards.


#!/bin/bash

origdir=`pwd`

#echo $# $*

if [ $# -gt 0 ]
then
for ii in $*
do
if [ ${ii%=*} == 'header' ]
then
/usr/local/bin/montage/mGetHdr ${ii#*=} mosaic.hdr
elif [ ${ii%=*} == 'outfile' ]
then
outfile=${ii#*=}
elif [ `echo $ii | grep =` ]
then
params="$params,${ii%=*}='${ii#*=}'"
elif [ `echo $ii | grep ".fits"` ]
then
files=( ${files[@]} $ii )
fi
done
fi
echo ${files[@]} ${#files}
if [ ${#files} -gt 0 ]
then
mkdir tmp
cp ${files[@]} tmp/
cp mosaic.hdr tmp/
cd tmp/
fi

if [ -f mosaic.hdr ]
then
echo "mosaic.hdr exists, continuing"

dir=`pwd`
echo python -c "import montage; montage.wrappers.mosaic('$dir','$dir/mosaic',header='$dir/mosaic.hdr'$params)"
python -c "import montage; montage.wrappers.mosaic('$dir','$dir/mosaic',header='$dir/mosaic.hdr'$params)"

cd $origdir
if [ -d tmp ]
then
if [ $outfile ]
then
mv tmp/mosaic/mosaic.fits $outfile
else
mv tmp/mosaic mosaic
fi
rm -r tmp
fi

else
echo "mosaic.hdr does not exist. Quitting."
cd $origdir
fi