全フレームリストのフォーマットを以前の形式に戻す.

開発初期からフォーマットが変わってしまったので,開発初期のフォーマットを想定している処理系に入れるためには以下のようにしてフォーマットを戻してやる必要があります.

wget http://smoka.nao.ac.jp/status/obslog/SUP_2006.txt -O /dev/stdout -q | sed -e 's/^\(SUPA[0-9]*\)X/\10/g' > SUP_2006.cat

あとは雑多なメモ

SM○KA フォーマットから csv に書き換える.

#!/usr/bin/perl 

chomp (my @in=<STDIN>);

#
# ヘッダ行を読んで各項目の先頭の位置及びそれに割り当てられている文字数を調べる
#
$head=shift @in;
@items=split(/[\s\t]+/,$head);
undef @wcs;
foreach my $item ( @items ) { 
    $wc=index($head,$item);
    push @wcs, $wc;
}

for($i=0;$i<$#wcs;$i++) {
    $nc[$i]=$wcs[$i+1]-$wcs[$i]-1;
}
$nc[$i]=length($head)-$wcs[$i];

#
# 整形して stdout に表示
#
foreach my $line ( @in ) { 
    if($line!~/^SUPA/) {
        next;
    }   
    out($line);
}

sub out {
    my ($line) = @_; 
    for($i=0;$i<=$#wcs;$i++) {
        $result[$i]=substr($line,$wcs[$i],$nc[$i]);
        $result[$i]=~s/^\s+//g;
        $result[$i]=~s/\s+$//g;
        if($result[$i]=~/[\w]+/) {
            print "\"$result[$i]\"";
        } else {
            print ""; 
        }   
        if($i!=$#wcs) {
            print ",";  # 可読性がよいようにスペースを入れちゃダメ絶対.
        }   
    }   
    print "\n";
}
cat SUP_200?.cat | insert2smoka.pl | psql -d suprime -c 'COPY smoka ("FRAMEID", "DATE_OBS", "FILTER", "RA2000", "DEC2000", "UT_START", "EXPTIME", "ALTITUDE", "DATA_TYPE", "OBJECT", "PSF_SIGMA", "PSF_ELLIP", "SKY_LEVEL" ) FROM stdin csv;'
find /home -name '*.pl' -exec grep INSERT \{\} \; -print | less

いつかちゃんと書くけど 2012 年版

cat datalist/SUP_20??.cat | insert2smoka.pl | awk -F , -v OFS=, '{print $1, $2, $4, $5, $6, $11, $12, $13, $14, $16, $17, $18, $19}' | psql -d suprime2012 -c 'COPY smoka ("FRAMEID", "DATE_OBS", "FILTER", "RA2000", "DEC2000", "UT_START", "EXPTIME", "ALTITUDE", "DATA_TYPE", "OBJECT", "PSF_SIGMA", "PSF_EVEL" ) FROM stdin csv;'

出力形式コロコロ変えるのやめてほしい