IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31428


Ignore:
Timestamp:
May 3, 2011, 2:25:17 PM (15 years ago)
Author:
watersc1
Message:

difftool: add the ability to specify both the input_warp_id and the template_warp_id. This allows us to explicitly say "subtract this one from that one."
stacktool: fix stackAssociation listing to supply the information, even if stackSumSkyfile isn't populated yet.
laptool: LAP now works cleanly from -definesequence through the final stack stage for runs that do not require a quickstack.

Location:
branches/czw_branch/20110406
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20110406/ippScripts/scripts/lap_science.pl

    r31417 r31428  
    9696sub chip_mode {
    9797    my $lap_id = shift;
    98     return(queue_chips($lap_id));
    99 }
    100 
    101 # This creates the chiptool command to use for the specified parameters.
    102 sub construct_chiptool_command {
    103     my $lap_id = shift;
    104     my $label  = shift;
    105     my $tess_id = shift;
    106     my $projection_cell = shift;
    107     my $data_group = shift;
    108     my $workdir  = shift;
    109     my $exp_id = shift;
    110 
    111     my $cmd = "$chiptool -pretend";
    112     $cmd .= " -pretend " if defined $debug;
    113     $cmd .= " -dbname $dbname " if defined $dbname;
    114 
    115     $cmd .= " -definebyquery -exp_id $exp_id -set_end_stage warp -set_tess_id $tess_id ";
    116     $cmd .= " -set_label $label -set_workdir $workdir -set_dist_group $label -set_data_group $data_group ";
    117 
    118     return($cmd);
     98    my $status = queue_chips($lap_id);
     99
     100    if ($status) {
     101        my $command = "$laptool -updaterun -lap_id $lap_id";
     102        $command .= " -dbname $dbname " if defined $dbname;
     103        $command .= " -set_state run ";
     104        my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     105            run(command => $command, verbose => $verbose);
     106        unless ($success) {
     107            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     108            &my_die("Unable to perform laptool: $error_code", $lap_id);
     109        }
     110    }
     111    return($status);
    119112}
    120113
     
    181174    my $data_group = "${label}.${date}";
    182175
    183     my $chip_cmd = construct_chiptool_command($exposure->{lap_id},$exposure->{label},
    184                                               $exposure->{tess_id},$exposure->{proj_cell},
    185                                               $workdir, $data_group,
    186                                               $exposure->{exp_id});
     176
     177    my $chip_cmd = "$chiptool";
     178    $chip_cmd .= " -pretend " if defined $debug;
     179    $chip_cmd .= " -dbname $dbname " if defined $dbname;
     180    $chip_cmd .= " -definebyquery -exp_id $exposure->{exp_id} -set_end_stage warp -set_tess_id $exposure->{tess_id} ";
     181    $chip_cmd .= " -set_label $exposure->{label} -set_data_group $data_group ";
     182    $chip_cmd .= " -set_workdir $workdir -set_dist_group $exposure->{dist_group} ";
     183
    187184    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    188185        run(command => $chip_cmd, verbose => $verbose);
     
    242239                &my_die("Exposure $exp_id for $lap_id is declared pairwise without a defined pair", $lap_id);
    243240            }
     241            $matching{$object}{$comment} = $exp_id;
     242            $indexing{$exp_id} = $counter;
    244243            $counter++;
    245244            next;
     
    276275
    277276            $exp_A->{pairwise} = 1;
     277            $exp_A->{private} = 0;
    278278            $exp_A->{pair_id} = $exp_B->{chip_id};
    279279           
    280280            $exp_B->{pairwise} = 1;
     281            $exp_B->{private} = 0;
    281282            $exp_B->{pair_id} = $exp_A->{chip_id};
     283           
     284            if ($verbose) {
     285                print "LAP_DIFFS: $object: $exp_A->{exp_id} and $exp_B->{exp_id} are a pair\n";
     286            }
    282287        }
    283288    }
     
    294299        $exposure = update_this_exposure($exposure);
    295300    }
     301    return(1);
    296302}
    297303
     
    300306# Decide Things
    301307################################################################################
     308sub monitor_mode {
     309    my $lap_id = shift;
     310    return(check_status($lap_id));
     311}
     312   
    302313
    303314sub check_stack_status {  # look at lapRun associated stacks, and confirm their states.
     
    330341    my $complete_fstacks = 0;
    331342    foreach my $stack (@$stacks) {
    332         if ($stack->{quick_stack_id}) {
     343        if (($stack->{quick_stack_id})&&
     344            (S64_IS_NOT_NULL($stack->{quick_stack_id}))) {
    333345            $defined_qstack = 1;
    334346            $total_qstacks++;
    335347        }
    336         if ($stack->{final_stack_id}) {
     348        if (($stack->{final_stack_id})&&
     349            (S64_IS_NOT_NULL($stack->{final_stack_id}))) {
    337350            $defined_fstack = 1;
    338351            $total_fstacks++;
    339352        }
    340353       
    341         if ($stack->{quick_state} eq 'full') {
     354        if (($stack->{quick_state})&&
     355            ($stack->{quick_state} eq 'full')) {
    342356            $complete_qstacks++;
    343357        }
    344         if ($stack->{final_state} eq 'full') {
     358        if (($stack->{final_state})&&
     359            ($stack->{final_state} eq 'full')) {
    345360            $complete_fstacks++;
    346361        }
    347362    }
    348     if ($complete_qstacks == $total_qstacks) {
     363    if (($complete_qstacks > 0)&&
     364        ($complete_qstacks == $total_qstacks)) {
    349365        $have_qstack = 1;
    350366    }
    351     if ($complete_fstacks == $total_fstacks) {
     367    if (($complete_fstacks > 0)&&
     368        ($complete_fstacks == $total_fstacks)) {
    352369        $have_fstack = 1;
    353370    }
     371   
    354372       
    355373    return($defined_qstack,$have_qstack,$defined_fstack,$have_fstack);
    356374}
    357375sub check_status {
    358     my $proj_cell = shift;
    359     my $lap_id = get_lap_id($proj_cell);
     376    my $lap_id = shift;
    360377   
    361378    my ($defined_qstack,$have_qstack,$defined_fstack,$have_fstack) = check_stack_status($lap_id);
     
    368385    unless ($success) {
    369386        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    370         &my_die("Unable to perform laptool: $error_code", $lap_id, $proj_cell);
     387        &my_die("Unable to perform laptool: $error_code", $lap_id);
    371388    }
    372389   
     
    377394   
    378395    my $exposures = $mdcParser->parse_list(join "", @$stdout_buf) or
    379         &my_die("Unable to parse metadata from laptool", $lap_id, $proj_cell);
     396        &my_die("Unable to parse metadata from laptool", $lap_id);
    380397
    381398    # Need to prescan to see who matches whom.
     
    394411    my $needs_something_private = 0;
    395412    my $can_qstack = 0;
     413    my $have_diff = 0;
    396414    my $can_diff = 0;
    397415    my $can_fstack = 0;
     
    423441            }
    424442        }
    425         if (($exposure->{warpRun_state} eq 'full')|| # This exposure's warp is either done or impossible.
    426             ($exposure->{data_state} eq 'drop')) {
     443        if (($exposure->{warpRun_state})&&  # This exposure has a warp
     444            (($exposure->{warpRun_state} eq 'full')|| # This exposure's warp is either done or impossible.
     445             ($exposure->{data_state} eq 'drop'))) {
    427446            $can_qstack ++;
    428447            $can_diff ++;
    429448        }
    430         if (($exposure->{magicked})||  # This exposure has been magicked, so it is through with diff.
     449        if (($exposure->{magicked}&&
     450             &S64_IS_NOT_NULL($exposure->{magicked}))||  # This exposure has been magicked, so it is through with diff.
    431451            ($exposure->{data_state} eq 'drop')) {
    432452            $can_fstack ++;
    433453        }
    434     }
    435    
     454        if (($exposure->{diff_id})&&(&S64_IS_NOT_NULL($exposure->{diff_id}))) {
     455            $have_diff ++;
     456        }
     457    }
     458
     459
     460    print "STATUS: DEFINED_QSTACK:  $defined_qstack\n";
     461    print "STATUS: HAVE_QSTACK:     $have_qstack\n";
     462    print "STATUS: DEFINED_FSTACK:  $defined_fstack\n";
     463    print "STATUS: HAVE_FSTACK:     $have_fstack\n";
     464
     465    print "STATUS: NEEDS_QSTACK:    $needs_qstack\n";
     466    print "STATUS: NEEDS_REMADE:    $needs_something_remade\n";
     467    print "STATUS: NEEDS PRIVATIZE: $needs_something_private\n";
     468    print "STATUS: CAN_QSTACK:      $can_qstack\n";
     469    print "STATUS: CAN_DIFF:        $can_diff\n";
     470    print "STATUS: HAVE_DIFF:       $have_diff\n";
     471    print "STATUS: CAN_FSTACK:      $can_fstack\n";
     472
     473    print "STATUS: TOTAL_EXPOSURES: $total_exposures\n";
     474
    436475    if (($needs_qstack == 1)&&              # Do we need the quick stack?
    437476        ($defined_qstack == 0)&&            # Have we not made it already?
     
    439478        ($needs_something_remade == 0)      # Do we need to wait for a stolen exposure?
    440479        ) {
     480        print "STATUS: Will now queue quickstacks\n";
    441481        &queue_quickstack($exposures);
    442482    }
     
    444484    if (($can_diff == $total_exposures)&&   # Are all warps done?
    445485        ($needs_something_remade == 0)&&    # Do we need to wait for a stolen exposure?
     486        ($have_diff < $can_diff)&&          # We haven't already done them all.
    446487        (($needs_qstack == 0)||             # Are we just doing pairwise diffs?
    447488         ($needs_qstack == 1)&&($have_qstack == 1)) ) { # If we need a quickstack, do we have it?
     489        print "STATUS: Will now queue diffs\n";
    448490        &queue_diffs($exposures);
    449491    }
     
    452494        ($needs_something_remade == 0)&&    # Do we need to wait for a stolen exposure?
    453495        ($defined_fstack == 0)) {           # Have we not made it already?
     496        print "STATUS: Will now queue final stacks\n";
    454497        &queue_finalstack($exposures);
    455498    }
    456499
    457500    if (($have_fstack == 1)) {              # Are we all done making the final product?
     501        print "STATUS: Will now deactivate exposures for this complete lapRun.\n";
    458502        &deactivate_exposures($exposures);
    459503        $command = "$laptool -updaterun -lap_id $lap_id";
     
    464508        unless ($success) {
    465509            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    466             &my_die("Unable to perform laptool: $error_code", $lap_id, $proj_cell);
    467         }
    468     }
     510            &my_die("Unable to perform laptool: $error_code", $lap_id);
     511        }
     512    }
     513   
    469514}
    470515
    471516sub queue_quickstack {
    472     my $lap_id = shift;
    473     my $label = shift;
    474     my $filter = shift;
    475     my $proj_cell = shift;
     517    my $exposures = shift; # reference to exposure array;
     518    my $exposure = ${ $exposures }[0]; # reference to the first exposure to get run level information
     519   
     520    my $lap_id    = $exposure->{lap_id};
     521    my $label     = $exposure->{label};
     522    my $filter    = $exposure->{filter};
     523    my $proj_cell = $exposure->{projection_cell};
     524
     525    unless (defined($label) && defined($filter) && defined($proj_cell)) {
     526        &my_die("Unable to perform stacktool. Insufficient information.", $lap_id);
     527    }
    476528
    477529    my @utctime = gmtime();
     
    483535    my $data_group = "${label}.${date}";
    484536
    485     my $command = "$stacktool ";
     537    my $command = "$stacktool -pretend";
    486538    $command .= " -dbname $dbname " if defined $dbname;
    487539    $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
    488     $command .= " -set_label ${label}.quick -set_workdir $workdir -set_data_group ${proj_cell}.quick.${date} ";
     540    $command .= " -set_label ${label}.quick -set_data_group ${proj_cell}.quick.${date} ";
     541    $command .= "  -set_workdir $workdir  -set_dist_group NODIST ";
    489542    $command .= " -min_num 2 -set_reduction QUICKSTACK ";
    490543
    491544    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     545        run(command => $command, verbose => $verbose);
     546    unless ($success) {
     547        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     548        &my_die("Unable to perform chiptool: $error_code", $lap_id);
     549    }
     550
     551    $command = "$stacktool ";
     552    $command .= " -dbname $dbname " if defined $dbname;
     553    $command .= " -sassskyfile -data_group ${proj_cell}.quick.${date} ";
     554    $command .= " -filter $filter -projection_cell ${proj_cell} ";
     555
     556    ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    492557        run(command => $command, verbose => $verbose);
    493558    unless ($success) {
     
    501566    my $stack = ${ $stacks }[0];
    502567    my $sass_id = $stack->{sass_id};
    503 
     568    unless (defined($sass_id)) {
     569        &my_die("Unable to parse metadata from laptool", $lap_id, "");
     570    }
    504571    $command = "$laptool -updaterun -lap_id $lap_id -set_quick_sass_id $sass_id";
    505572    $command .= " -dbname $dbname " if defined $dbname;
     
    515582}
    516583sub queue_finalstack {
    517     my $lap_id = shift;
    518     my $label = shift;
    519     my $filter = shift;
    520     my $proj_cell = shift;
     584    my $exposures = shift; # reference to exposure array;
     585    my $exposure = ${ $exposures }[0]; # reference to the first exposure to get run level information
     586   
     587    my $lap_id    = $exposure->{lap_id};
     588    my $label     = $exposure->{label};
     589    my $filter    = $exposure->{filter};
     590    my $proj_cell = $exposure->{projection_cell};
     591
     592    unless (defined($label) && defined($filter) && defined($proj_cell)) {
     593        &my_die("Unable to perform stacktool. Insufficient information.", $lap_id);
     594    }
    521595
    522596    my @utctime = gmtime();
     
    529603
    530604    my $command = "$stacktool ";
     605    $command .= " -pretend " if defined $debug;
    531606    $command .= " -dbname $dbname " if defined $dbname;
    532607    $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
     
    541616    }
    542617   
     618   
     619    $command = "$stacktool ";
     620    $command .= " -dbname $dbname " if defined $dbname;
     621    $command .= " -sassskyfile -data_group ${proj_cell}.final.${date} ";
     622    $command .= " -filter $filter -projection_cell ${proj_cell} ";
     623
     624    ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     625        run(command => $command, verbose => $verbose);
     626    unless ($success) {
     627        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     628        &my_die("Unable to perform chiptool: $error_code", $lap_id);
     629    }
     630
    543631    my $stacks = $mdcParser->parse_list(join "", @$stdout_buf) or
    544632        &my_die("Unable to parse metadata from laptool", $lap_id, "");
    545    
     633
    546634    my $stack = ${ $stacks }[0];
    547635    my $sass_id = $stack->{sass_id};
    548 
     636    unless (defined($sass_id)) {
     637        &my_die("Unable to parse metadata from laptool", $lap_id, "");
     638    }
     639    print "FINAL_SASS_ID: $sass_id\n";
    549640    $command = "$laptool -updaterun -lap_id $lap_id -set_final_sass_id $sass_id";
    550641    $command .= " -dbname $dbname " if defined $dbname;
     
    576667            next;
    577668        }
    578         if ($exposure->{diff_id}) { # Not sure how this would happen, but still.
     669        if ($exposure->{diff_id}&&S64_IS_NOT_NULL($exposure->{diff_id})) { # Not sure how this would happen, but still.
     670            next;
     671        }
     672        if ($already_queued{$exposure->{warp_id}}) {
     673            print "STATUS: Have already queued a diff containing $exposure->{exp_id} $exposure->{chip_id} $exposure->{warp_id}\n";
    579674            next;
    580675        }
     
    591686        my $data_group = "${label}.${date}";
    592687
     688
    593689        my $command = "$difftool ";
     690        $command .= " -pretend " if defined $debug;
    594691        $command .= " -dbname $dbname " if defined $dbname;
    595692        $command .= " -set_label $label -set_workdir $workdir -set_data_group $data_group ";
    596         $command .= " -set_dist_group $dist_group ";
     693        if ($exposure->{dist_group}) {
     694            $command .= " -set_dist_group $exposure->{dist_group} ";
     695        }
    597696       
    598697        if ($exposure->{pairwise}) { # warpwarp
     
    601700            $command .= "-input_label $label -template_label $label -backwards ";
    602701            $command .= "-warp_id $exposure->{warp_id} -template_warp_id $companion->{warp_id} ";
    603 
     702            $already_queued{$exposure->{warp_id}} = 1;
     703            $already_queued{$companion->{warp_id}} = 1;
     704           
    604705        }
    605706        else { # warp-qstack
    606707            $command .= " -definewarpstack -set_reduction WARPQSTACK -available -good_frac 0.2 ";
    607708            $command .= " -warp_id $exposure->{warp_id} -stack_label ${label}.quick ";
     709            $already_queued{$exposure->{warp_id}} = 1;
    608710        }
    609711       
     
    612714        unless ($success) {
    613715            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    614             &my_die("unable to perform chiptool: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
    615         }
     716            &my_die("unable to perform difftool: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
     717        }
     718
     719       
    616720    }
    617721}
     
    726830   
    727831    my $command = "$laptool -updateexp -lap_id $lap_id -exp_id $exp_id ";
    728     if ($exposure->{chip_id}) {
     832    if (($exposure->{chip_id})&&(S64_IS_NOT_NULL($exposure->{chip_id}))) {
    729833        $command .= " -set_chip_id  $exposure->{chip_id} ";
    730834    }
    731     if ($exposure->{pair_id}) {
     835    if (($exposure->{pair_id})&&(S64_IS_NOT_NULL($exposure->{pair_id}))) {
    732836        $command .= " -set_pair_id  $exposure->{pair_id} ";
    733837    }
  • branches/czw_branch/20110406/ippTools/share/laptool_definerun.sql

    r31407 r31428  
    1 SELECT exp_id, chip_id, false as private, true as active, false as pairwise
    2   FROM rawExp
    3   LEFT JOIN
    4   (SELECT exp_id, chip_id
    5      FROM lapExp
    6      where private IS FALSE
    7      AND data_state = 'full') AS old USING(exp_id)
     1SELECT want.exp_id, have.chip_id, false as private, true as active, false as pairwise
     2  FROM
     3  (SELECT exp_id FROM rawExp
    84     WHERE rawExp.exp_type= 'OBJECT' AND
    95     rawExp.dateobs >= '2009-04-01T00:00:00.000000' AND
    106-- Position restriction goes here.
     7     @WHERE@
     8  ) AS want
     9  LEFT JOIN
     10  (SELECT *
     11     FROM lapExp
     12     where private IS FALSE
     13     AND chip_id IS NOT NULL
     14     AND active = TRUE ) AS have USING(exp_id)
     15     
     16
  • branches/czw_branch/20110406/ippTools/share/laptool_exposures.sql

    r31409 r31428  
    11SELECT DISTINCT
    22    D.*,diffRun.state,
    3     CONVERT(sum(others.private),SIGNED) AS needs_remade
     3    coalesce(CONVERT(sum(others.private),SIGNED),0) AS needs_remade
    44--      0 AS needs_remade
    55    FROM (
     
    77      W.*,CONVERT(IFNULL(diff1.diff_id,diff2.diff_id),SIGNED) AS diff_id FROM (
    88    SELECT DISTINCT
    9         lap_id,lapRun.tess_id,projection_cell,filter,lapRun.state as lapRun_state, lapRun.registered, lapRun.fault, lapRun.label,
     9        lap_id,lapRun.tess_id,projection_cell,filter,lapRun.state as lapRun_state, lapRun.registered, lapRun.fault, lapRun.label, lapRun.dist_group,
    1010        lapExp.exp_id,lapExp.chip_id,lapExp.pair_id,private,pairwise,active,lapExp.data_state,
    1111        chipRun.state as chipRun_state,
    12         CONVERT(sum(chipProcessedImfile.fault),SIGNED) as chip_faults,
    13         CONVERT(sum(chipProcessedImfile.quality),SIGNED) as chip_quality,
     12        coalesce(CONVERT(sum(chipProcessedImfile.fault),SIGNED),0) as chip_faults,
     13        coalesce(CONVERT(sum(chipProcessedImfile.quality),SIGNED),0) as chip_quality,
    1414        camRun.cam_id, camRun.state as camRun_state,   
    15         CONVERT(sum(camProcessedExp.fault),SIGNED) AS cam_faults,
    16         CONVERT(sum(camProcessedExp.quality),SIGNED) AS cam_quality,
     15        coalesce(CONVERT(sum(camProcessedExp.fault),SIGNED),0) AS cam_faults,
     16        coalesce(CONVERT(sum(camProcessedExp.quality),SIGNED),0) AS cam_quality,
    1717        fakeRun.fake_id, fakeRun.state as fakeRun_state,
    18         CONVERT(sum(fakeProcessedImfile.fault),SIGNED) as fake_faults,
     18        coalesce(CONVERT(sum(fakeProcessedImfile.fault),SIGNED),0) as fake_faults,
    1919        warpRun.warp_id, warpRun.state as warpRun_state,
    20         CONVERT(sum(warpSkyfile.fault),SIGNED) as warp_faults,
    21         CONVERT(sum(warpSkyfile.quality),SIGNED) as warp_quality,
     20        coalesce(CONVERT(sum(warpSkyfile.fault),SIGNED),0) as warp_faults,
     21        coalesce(CONVERT(sum(warpSkyfile.quality),SIGNED),0) as warp_quality,
    2222        warpRun.magicked
    2323    FROM lapRun JOIN lapExp USING(lap_id)
     
    2828    LEFT JOIN warpRun USING(fake_id) LEFT JOIN warpSkyfile USING(warp_id)
    2929    WHERE    @WHERE@
    30     AND warpSkyfile.quality != 8007 -- known cases where quality != 0, but everything's fine.
    31     AND warpSkyfile.quality != 3006 -- known cases where quality != 0, but everything's fine.
     30    AND (warpSkyfile.quality IS NULL OR
     31         (warpSkyfile.quality != 8007      -- known cases where quality != 0, but everything's fine.
     32          AND warpSkyfile.quality != 3006  -- known cases where quality != 0, but everything's fine.
     33          ))
    3234    GROUP BY lap_id,exp_id
    3335    ) AS W
     
    3739) AS D
    3840LEFT JOIN diffRun USING(diff_id)
    39 JOIN lapExp AS others ON (D.chip_id = others.chip_id AND D.lap_id != others.lap_id)
     41LEFT JOIN lapExp AS others ON (D.chip_id = others.chip_id AND D.lap_id != others.lap_id)
     42GROUP BY lap_id,exp_id
    4043
  • branches/czw_branch/20110406/ippTools/share/laptool_pendingexp.sql

    r31407 r31428  
    1 select lapRun.lap_id, lapRun.seq_id, lapRun.tess_id, lapRun.projection_cell, lapRun.filter, lapRun.state, lapRun.label,
     1select lapRun.lap_id, lapRun.seq_id, lapRun.tess_id, lapRun.projection_cell, lapRun.filter,
     2       lapRun.state, lapRun.label,
    23       lapRun.dist_group, lapRun.registered, lapRun.fault, lapRun.quick_sass_id, lapRun.final_sass_id,
    34       exp_id, chip_id, pair_id, private, pairwise, active, lapExp.data_state,
  • branches/czw_branch/20110406/ippTools/share/laptool_stacks.sql

    r31407 r31428  
    33       lapRun.state,lapRun.label,lapRun.dist_group,lapRun.registered,lapRun.fault,
    44       skycell_id,
    5        quick_sass_id,quick_data_group,quick_stack_id,quick_state,quick_fault,quick_quality,
    6        final_sass_id,final_data_group,final_stack_id,final_state,final_fault,final_quality
     5       lapRun.quick_sass_id,quick_data_group,quick_stack_id,quick_state,quick_fault,quick_quality,
     6       lapRun.final_sass_id,final_data_group,final_stack_id,final_state,final_fault,final_quality
    77       FROM
    88       lapRun LEFT JOIN
     
    9595           AND sass_id = lapRun.final_sass_id
    9696       ) AS final USING(lap_id,projection_cell,tess_id,filter,skycell_id)
    97  ) stacks USING(lap_id,projection_cell,tess_id,filter,quick_sass_id,final_sass_id)
     97 ) stacks ON (stacks.lap_id = lapRun.lap_id AND
     98             stacks.projection_cell = lapRun.projection_cell AND
     99             stacks.tess_id = lapRun.tess_id AND
     100             stacks.filter = lapRun.filter AND
     101             (lapRun.quick_sass_id IS NULL OR lapRun.quick_sass_id = stacks.quick_sass_id) AND
     102             (lapRun.final_sass_id IS NULL OR lapRun.final_sass_id = stacks.final_sass_id))
    98103WHERE 1 @WHERE@
  • branches/czw_branch/20110406/ippTools/share/stacktool_sassskyfile.sql

    r28375 r31428  
    1818        where stack_id = stackRun.stack_id limit 1
    1919    ) as camera
    20 FROM stackRun
    21 JOIN stackSumSkyfile USING(stack_id)
    22 JOIN stackAssociationMap USING(stack_id)
    23 JOIN stackAssociation USING(sass_id)
     20FROM stackAssociation
     21JOIN stackAssociationMap USING(sass_id)
     22JOIN stackRun USING(stack_id)
     23LEFT JOIN stackSumSkyfile USING(stack_id)
  • branches/czw_branch/20110406/ippTools/src/difftool.c

    r31253 r31428  
    16251625    PXOPT_COPY_S64(config->args, selectWhere, "-exp_id", "inputRawExp.exp_id", "==");
    16261626    PXOPT_COPY_S64(config->args, selectWhere, "-template_exp_id", "templateRawExp.exp_id", "==");
     1627    PXOPT_COPY_S64(config->args, selectWhere, "-template_warp_id", "templateWarpRun.warp_id", "==");
    16271628    PXOPT_COPY_STR(config->args, selectWhere, "-filter", "inputRawExp.filter", "==");
    16281629    PXOPT_COPY_STR(config->args, selectWhere, "-obs_mode", "inputRawExp.obs_mode", "==");
  • branches/czw_branch/20110406/ippTools/src/difftoolConfig.c

    r31253 r31428  
    278278    psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-not-bothways",  0, "only do the single-direction subtraction?", false);
    279279    psMetadataAddS64(definewarpwarpArgs, PS_LIST_TAIL,  "-template_exp_id",  0,  "search by template exposure ID", 0);
     280    psMetadataAddS64(definewarpwarpArgs, PS_LIST_TAIL,  "-template_warp_id",  0,  "search by template warp ID", 0);
    280281    psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-filter", 0, "search by filter", NULL);
    281282    psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-distance", 0, "limit distance between input and template (deg)", NAN);
  • branches/czw_branch/20110406/ippTools/src/laptool.c

    r31417 r31428  
    295295    return(false);
    296296  }
    297   psStringAppend(&query, " %s", whereClause);
     297
     298  if (whereClause) {
     299    psStringSubstitute(&query,whereClause,"@WHERE@");
     300  }
    298301  psFree(where);
    299302
     
    467470      }
    468471      else {
    469         return(false);
     472        return(true); // We shouldn't really fail if we didn't change anything. Maybe there's nothing to change.
    470473      }
    471474    }
    472     return(true);
    473   }
    474   else {
    475     return(false);
    476   }
     475
     476  }
     477
     478  return(true);
    477479}
    478480
     
    496498  if (psListLength(where->list)) {
    497499    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    498     psStringAppend(&query, " WHERE %s", whereClause);
     500    psStringAppend(&query, "\n AND %s", whereClause);
    499501    psFree(whereClause);
    500502  }
    501 
     503  psStringAppend(&query, " ORDER BY rawExp.dateobs ");
     504 
    502505  if (limit) {
    503506    psString limitString = psDBGenerateLimitSQL(limit);
    504     psStringAppend(&query, " %s", limitString);
     507    psStringAppend(&query, "\n %s", limitString);
    505508    psFree(limitString);
    506509  }
    507   psStringAppend(&query, " ORDER BY rawExp.dateobs ");
     510
    508511 
    509512  if (!p_psDBRunQuery(config->dbh, query)) {
     
    615618
    616619  psMetadata *where = psMetadataAlloc();
    617   PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "==");
     620  PXOPT_COPY_S64(config->args, where, "-lap_id", "lapRun.lap_id", "==");
    618621 
    619622  psString query = pxDataGet("laptool_stacks.sql");
Note: See TracChangeset for help on using the changeset viewer.