IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 24, 2010, 2:59:09 PM (16 years ago)
Author:
Paul Price
Message:

Merging trunk in advance of reintegrating into trunk.

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/ippToPsps/scripts/ippToPsps_run.pl

    r28120 r28484  
    1212
    1313# globals
    14 my ($verbose, $save_temps, $no_op, $no_update, $camera, $batchType, $output, $dvodb, $datastoreProduct, $label, $singleExpId, $no_publish, $force);
     14my ($verbose, $save_temps, $no_op, $no_update, $camera, $batchType, $output, $dvodb, $datastoreProduct, $survey, $singleExpId, $no_publish, $force, $initBatch);
    1515
    1616# default values for certain globals
     
    2525$datastoreProduct = "PSPS_test";
    2626$force = 0;
     27$initBatch = 0;
    2728
    2829# get user args
     
    3132        'batch|b=s' => \$batchType,
    3233        'dvodb|d=s' => \$dvodb,
    33         'label|l=s' => \$label,
     34        'survey|s=s' => \$survey,
    3435        'expid|e=s' => \$singleExpId,
    3536        'product|p=s' => \$datastoreProduct,
     
    4950        "--batch <init|det|diff|stack>\n".
    5051        "--output <path>\n".
    51         "--label <label> or --expid <expid>\n" .
     52        "--survey <ThreePi|MD01,2 etc|STS|SAS|SweetSpot> or --expid <expid>\n" .
    5253        "--dvodb <path>\n".
    5354        "\n   Optional:\n\n".
     
    6263defined $output and
    6364defined $dvodb and
    64 ( defined $label or defined $singleExpId );
     65(( defined $survey or defined $singleExpId ) or ( $batchType eq "init"));
     66
     67if ($batchType eq "init") {$initBatch = 1;}
    6568
    6669# check we can run programs and get camera config
     
    7073
    7174# make a temporary file for saving results
    72 my ($resultsFile, $resultsFileName) = tempfile( "/tmp/results.XXXX", UNLINK => !$save_temps);
     75my ($resultsFile, $resultsFileName) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
    7376
    7477process();
     
    8689    if ($distGroup =~ m/^MD([0-1][0-9])$/i) {return "MD$1";}
    8790    if ($distGroup =~ m/^M31$/i) {return "M31";}
    88     if ($distGroup =~ m/^sts$/i) {return "STS";}
     91    if ($distGroup =~ m/^sts$/i) {return "STS1";}
    8992    if ($distGroup =~ m/^SweetSpot$/i) {return "SSS";}
    9093    if ($distGroup =~ m/^(3PI)|(ThreePi)|(SAS)$/i) {return "3PI";}
     
    118121#######################################################################################
    119122#
    120 # Finds all exposures for the provided label and generates PSPS FITS data for them
     123# Finds all exposures for the provided TODO and generates PSPS FITS data for them
    121124#
    122125#######################################################################################
     
    130133
    131134    my $query;
    132     if (!$singleExpId) {
    133 
    134         # query to retrieve all exposures with the provided label
     135    if ($initBatch) {
     136   
    135137        $query = $gpc1Db->prepare(<<SQL);
    136138
    137         SELECT DISTINCT rawExp.exp_id, camRun.dist_group
    138             FROM camRun, chipRun, rawExp
    139             WHERE camRun.chip_id = chipRun.chip_id
    140             AND chipRun.exp_id = rawExp.exp_id
    141             AND camRun.dist_group LIKE 'ThreePi'
    142             AND rawExp.exp_id > $lastExpId
    143             ORDER BY rawExp.exp_id ASC
     139        SELECT 0, 'NULL', 'ThreePi';
    144140SQL
     141    }
     142    elsif ($singleExpId) {
     143
     144        $query = $gpc1Db->prepare(<<SQL);
     145
     146        SELECT DISTINCT rawExp.exp_id,  rawExp.exp_name, dist_group
     147            FROM rawExp, chipRun
     148            WHERE chipRun.exp_id = rawExp.exp_id
     149            AND rawExp.exp_id = $singleExpId
     150SQL
     151    }
     152    else {
     153
     154        $query = $gpc1Db->prepare(<<SQL);
     155
     156        SELECT rawExp.exp_id, rawExp.exp_name, camRun.dist_group
     157            FROM camRun, chipRun, rawExp
     158            WHERE camRun.state = 'full'
     159            AND camRun.chip_id = chipRun.chip_id
     160            AND chipRun.exp_id = rawExp.exp_id
     161            AND camRun.dist_group = '$survey'   
     162            GROUP BY  rawExp.exp_id
     163            ORDER BY rawExp.exp_id ASC;
     164SQL
     165
     166            #AND rawExp.dateobs <= '2010-03-12'
    145167            #AND rawExp.exp_id > $lastExpId
    146168            #AND camRun.label LIKE '%$label%'
     
    149171            #AND rawExp.decl >= '-0.157079633' AND rawExp.decl <= '0.157079633' Jims Dec range
    150172    }
    151     else {
    152 
    153         $query = $gpc1Db->prepare(<<SQL);
    154 
    155         SELECT DISTINCT rawExp.exp_id, dist_group FROM rawExp, chipRun WHERE chipRun.exp_id = rawExp.exp_id AND rawExp.exp_id = $singleExpId
    156 SQL
    157     }
    158173
    159174    my $batchId = 0;
     
    168183    # loop round exposures
    169184    while (my @row = $query->fetchrow_array()) {
    170         my ($expId, $distGroup) = @row;
    171 
    172         if (isExposureAlreadyProcessed($ippToPspsDb, $expId)) {
     185        my ($expId, $expName, $distGroup) = @row;
     186
     187        if (!$initBatch && isExposureAlreadyProcessed($ippToPspsDb, $expId)) {
    173188               
    174189                if ($force) {print "* Forcing....\n";}
    175190                else {next};
    176                 }
     191        }
    177192
    178193        my $surveyType = getSurveyTypeFromDistGroup($distGroup);
     
    181196        $jobId = getNewBatchId($ippToPspsDb, $expId, $surveyType);
    182197
    183 # TODO quit here if no sensible job ID
     198        # TODO quit here if no sensible job ID
    184199
    185200        # generate batch and job paths from job and batch IDs
     
    188203        my $batchDir = sprintf("B%03d", $batchId);
    189204        my $batchOutputPath = sprintf("$jobOutputPath/%s", $batchDir);
    190 
    191         print "* Preparing exposure $expId as job '$job'...\n";
    192 
    193         # make directories
    194205        mkdir($jobOutputPath, 0777);
    195206        mkdir($batchOutputPath, 0777);
    196207
     208        print "* Preparing exposure $expId as job '$job'...\n";
     209
    197210        # run IppToPsps program
    198         if (runIppToPsps($gpc1Db, $expId, $batchOutputPath, $batchType)) {
     211        if (runIppToPsps($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath, $batchType)) {
    199212
    200213            # write batch manifest and tar and zip up
     
    232245        }
    233246
    234         if ($batchType eq "init" ) {print "* Wrote initialisation batch\n"; last;}
    235 
     247        if ($initBatch) {print "* Wrote initialisation batch\n";}
    236248
    237249        print "*\n*******************************************************************************\n\n";
     
    358370#######################################################################################
    359371sub runIppToPsps {
    360     my ($gpc1Db, $expId, $batchOutputPath, $batchType) = @_;
     372    my ($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath, $batchType) = @_;
    361373
    362374    my $success = 0;
    363375
    364     # before anything else, we can publish the init batch
    365376    if ($batchType =~ /init/) {
    366377        $success = produceInit($batchOutputPath);
    367378    }
    368379    elsif ($batchType =~ /det/) {
    369         $success = produceDetections($gpc1Db, $expId, $batchOutputPath);
     380        $success = produceDetections($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath);
    370381    }
    371382    elsif ($batchType =~ /diff/) {
    372         $success = produceDiffs($gpc1Db, $expId, $batchOutputPath);
     383        $success = produceDiffs($gpc1Db, $expId, $expName, $surveyType, $batchOutputPath);
    373384    }
    374385
     
    614625    my $fullJobPath = "$path/$job";
    615626
    616     my ($tempFile, $tempName) = tempfile( "/tmp/dsregList.XXXX", UNLINK => !$save_temps);
     627    my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_dsregList.XXXX", UNLINK => !$save_temps);
    617628
    618629    # loop through all batch files in this job directory
     
    664675    my ($outputPath) = @_;
    665676
    666     my $success = runProgram( "NULL", $outputPath, 0, $batchType);
     677    my $success = runProgram("NULL", $outputPath, 0, "NULL", "NULL", $batchType);
    667678    return $success;
    668679}
     
    673684#######################################################################################
    674685sub produceDetections {
    675     my ($gpc1Db,$expId,$outputPath) = @_;
     686    my ($gpc1Db, $expId, $expName, $surveyType, $outputPath) = @_;
    676687
    677688    # query to retrieve nebulous key of camera smf file for this exposure
     
    705716
    706717        # now write the path to this file out to temp file
    707         my ($tempFile, $tempName) = tempfile( "/tmp/inputFileList.XXXX", UNLINK => !$save_temps);
     718        my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_inputFileList.XXXX", UNLINK => !$save_temps);
    708719        print $tempFile $realFile . "\n";
    709720        close $tempFile;
    710721
    711         $success = runProgram($tempName, $outputPath, $expId, $batchType);
     722        $success = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType);
    712723        return $success;
    713724    }
     
    720731#######################################################################################
    721732sub produceDiffs {
    722     my ($gpc1Db,$expId,$outputPath) = @_;
     733    my ($gpc1Db, $expId, $expName, $surveyType, $outputPath) = @_;
    723734
    724735    my $query =
     
    758769    }
    759770
    760     my $ret = runProgram($tempName, $outputPath, $expId, $batchType);
     771    my $ret = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType);
    761772
    762773    close $tempFile;
     
    771782#######################################################################################
    772783sub runProgram {
    773     my ($input, $output, $expid, $batchType) = @_;
     784    my ($input, $output, $expid, $expName, $surveyType, $batchType) = @_;
    774785
    775786    # build command
     
    780791    $command .= " -config config"; # TODO
    781792    $command .= " -expid $expid";
     793    $command .= " -expname $expName";
     794    $command .= " -survey $surveyType";
    782795    $command .= " -batch $batchType";
    783796    $command .= " -results $resultsFileName";
Note: See TracChangeset for help on using the changeset viewer.