IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 6, 2015, 10:03:51 AM (11 years ago)
Author:
bills
Message:

use mana to get stats of the delta columns and complain about possible outliers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bills/comparestackdetections

    r39014 r39055  
    77use Pod::Usage qw( pod2usage );
    88use File::Basename;
    9 
     9use File::Temp qw( tempdir  tempfile );
     10use PS::IPP::Config 1.01 qw( :standard );
    1011
    1112my $joinType = '1and2';
     
    2122my $testdata;
    2223
    23 my ($verbose, $save_temps);
     24my ($checkdeltas, $verbose, $save_temps);
     25
     26my $label = 'SAS.20141118.sc8';
    2427
    2528GetOptions(
     29    "label=s"           =>  \$label,
    2630    "testdata=s"        =>  \$testdata,
    2731    "join=s"            =>  \$joinType,
     32    "check"             =>  \$checkdeltas,
    2833    "verbose|v"         =>  \$verbose,
    2934    "save-temps"        =>  \$save_temps,
    3035) or pod2usage( 2 );
    3136
    32 die "usage: $0 <stack batch file> <out> [--testdata <location of testdata directory]\n" unless (scalar @ARGV == 2);
     37die "usage: $0 <stack batch file> <out> --label <skycal label> | --testdata <location of testdata directory\n" unless (scalar @ARGV == 2);
    3338
    3439$in = shift;
     
    5358
    5459my @cmfs;
    55 if ($testdata) {
    56     for (my $i=1; $i<=5; $i++) {
    57         my $stack_id = $stackIDs[$i];
    58         my $cmf = 'none';
    59         if ($stack_id > 0) {
     60for (my $i=1; $i<=5; $i++) {
     61    my $stack_id = $stackIDs[$i];
     62    my $cmf = 'none';
     63    if ($stack_id > 0) {
     64        if ($testdata) {
    6065            $cmf = sprintf "%s/stack.%02d.cmf", $testdata, $stack_id;
     66        } else {
     67            my $path_base = `staticskytool -skycalresult -label $label -stack_id $stack_id | grep path_base | awk '{print \$3}'`;
     68            chomp $path_base;
     69            die "failed to find skycal result for $stack_id $label\n" unless $path_base;
     70            $cmf = $path_base . ".cmf";
    6171        }
    62         $cmfs[$i] = $cmf;
    63         print "$filters[$i] $stack_id $cmf\n" if $verbose;
    64     }
    65 } else {
    66     # XXX: look up the cmf for this stack here
    67     die "this program only works in test mode right now\n";
    68 }
    69 
     72    }
     73    $cmfs[$i] = $cmf;
     74    print "$filters[$i] $stack_id $cmf\n" if $verbose;
     75}
    7076
    7177my $outfile;
     
    7581    next if $cmf eq 'none';
    7682
     83    my $base = basename($cmf);
     84
    7785    my $filter = $filters[$i];
    78     my $ippjoined = $filter . "_joined" . basename($cmf);
     86    my $ippjoined = $filter . "_joined" . $base;
    7987
    8088    $command = "joinstackcmf $cmf $ippjoined";
    8189    $command .= " --ofmt fits";
    8290    $command .= " --test" if $testdata;
     91    $command .= " --verbose" if $verbose;
    8392
    8493    runcommand($command);
     
    8695    my $stackColumn = $filter . "stackImageID";
    8796    my $idColumn    = $filter . "ippDetectID";
    88     $outfile = $filter . "_matched" . basename($cmf);
     97    $outfile = $filter . "_matched" . $base;
    8998
    9099    $command = "$stilts tmatch2 in1=$input'#StackObjectAttributes' in2=$ippjoined matcher=2d out=$outfile ofmt=fits"
     
    104113}
    105114
     115my @deltas;
    106116my $list = getStackColumns();
    107117my $cmd = "'";
     
    121131    my $dcol = "d_$col";
    122132    $cmd .= "addcol -after $col $dcol $equation;";
     133    push @deltas, $dcol;
    123134}
    124135$cmd .= "'";
     
    128139runcommand($command);
    129140unlink($outfile) unless $save_temps;
     141
     142if ($checkdeltas) {
     143    $save_temps = 1;
     144    my ($manafile, $mananame) = tempfile( "/var/tmp/manacmds.XXXX", UNLINK => !$save_temps);
     145    print "$mananame\n" if $save_temps;
     146    print $manafile (<<HERE);
     147\$limit = 1e-9
     148output /dev/null
     149macro checkdelta
     150    \$col = \$1
     151    \$thislimit = \$limit
     152    subset good = \$col where \$col != -999
     153    \$length = good[]
     154    for i 0 10
     155        subset d = good where abs(good) > \$thislimit
     156        \$noutliers = d[]
     157        if (\$noutliers > 0)
     158            echo \$col has \$noutliers out of \$length with difference > \$thislimit
     159            \$thislimit = \$thislimit * 10
     160        else
     161            return
     162        end
     163    end
     164end
     165HERE
     166
     167    print $manafile "\nmacro dotests\n";
     168    foreach my $col (@deltas) {
     169        print $manafile "    checkdelta $col\n";
     170    }
     171    print $manafile "end\n";
     172
     173    print $manafile "datafile $out\n";
     174    print $manafile "read -fits StackObjectAttributes";
     175    foreach my $col (@deltas) {
     176        print $manafile " $col";
     177    }
     178    print $manafile "\n";
     179
     180
     181    print $manafile "output stdout\n";
     182    print $manafile "dotests\n";
     183    close $manafile;
     184
     185    system "echo input $mananame | mana";
     186}
    130187
    131188exit 0;
     
    188245x_apFlux          AP_FLUX               *x_zpFactor/x_expTime
    189246x_apFluxErr       AP_FLUX_SIG           *x_zpFactor/x_expTime
    190 x_apFillFac       AP_NPIX               /(3.14159265359*pow(AP_MAG_RADIUS_x-0.5,2))
     247x_apFillFac       AP_NPIX               /(3.14159265359*AP_MAG_RADIUS_x*AP_MAG_RADIUS_x)
    191248x_apRadius        AP_MAG_RADIUS         *abs(PLTSCALE_x)
    192249x_KronFlux        KRON_FLUX             *x_zpFactor/x_expTime
Note: See TracChangeset for help on using the changeset viewer.