IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25712


Ignore:
Timestamp:
Oct 1, 2009, 10:07:51 AM (17 years ago)
Author:
bills
Message:

implement REQ_TYPE byskycell and various other features

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r25323 r25712  
    3434    my $img_type = shift;   # required
    3535    my $id       = shift;   # required unless req_type eq bycoord or byskycell
     36    my $tess_id  = shift;
    3637    my $component= shift;   # class_id or skycell_id
    3738    my $inverse  = shift;
     39    my $need_magic = shift;
    3840    my $x        = shift;
    3941    my $y        = shift;
     
    4143    my $mjd_max  = shift;
    4244    my $filter   = shift;
     45    my $label    = shift;
    4346    my $verbose  = shift;
    4447
    4548
    4649    # we die in response to bad data in request files
    47     die "Unknown req_type: $req_type" if ($req_type ne "byid") and ($req_type ne "byexp")
    48                                         and ($req_type ne "bycoord") and ($req_type ne "bydiff");
     50    die "Unknown req_type: $req_type"
     51        if ($req_type ne "byid") and
     52           ($req_type ne "byexp") and
     53           ($req_type ne "bycoord") and
     54           ($req_type ne "bydiff") and
     55           ($req_type ne "byskycell");
     56
     57    my $dateobs_begin;
     58    my $dateobs_end;
     59    if (!iszero($mjd_min)) {
     60        $dateobs_begin = mjd_to_dateobs($mjd_min);
     61    }
     62    if (!iszero($mjd_max)) {
     63        $dateobs_end = mjd_to_dateobs($mjd_max);
     64    }
    4965
    5066    if (($req_type eq "byid") and ($img_type eq "diff")) {
     
    95111        # regtool -dbname $image_db -processedimfile -time_begin $mjd_min -time_end = $mjd_max -filter $filter
    96112        #
    97         my $results = lookup_bycoord($ipprc, $image_db, $x, $y, $mjd_min, $mjd_max, $filter, $verbose);
     113        my $results = lookup_bycoord($ipprc, $image_db, $x, $y, $dateobs_begin, $dateobs_end, $filter, $verbose);
    98114
    99115        # now take the results and lookup byexp
     
    102118        $req_type = "byexp";
    103119        $id = $results->{exp_name};
    104     }
    105 
    106     my $results = lookup($ipprc, $image_db, $req_type, $img_type, $id, $component, $verbose);
     120    } elsif ($req_type eq "byskycell") {
     121        if (($img_type eq "raw") or ($img_type eq "chip")) {
     122            print STDERR "REQ_TYPE byskycell not supported for IMG_TYPE raw or chip\n";
     123            return undef;
     124        }
     125        if (!$tess_id or !$component) {
     126            print STDERR "component and tess_id are required for REQ_TYPE byskycell\n";
     127            return undef;
     128        }
     129    }
     130
     131    my $results = lookup($ipprc, $image_db, $req_type, $img_type, $id, $tess_id, $component, $need_magic, $dateobs_begin, $dateobs_end, $filter, $label, $verbose);
    107132
    108133    return $results;
     
    115140    my $img_type = shift;
    116141    my $id       = shift;
     142    my $tess_id  = shift;
    117143    my $component= shift;
     144    my $need_magic = shift;
     145    my $dateobs_begin = shift;
     146    my $dateobs_end   = shift;
     147    my $filter = shift;
     148    my $label = shift;
    118149    my $verbose  = shift;
    119150
     
    139170    my $skycell_id;
    140171
    141     # special class_id value "null" means ignore
    142     if ($component and ($component eq "null")) {
     172    if (isnull($component)) {
    143173        $component = undef;
    144174    }
    145175
     176    my $magic_arg = $need_magic ? " -destreaked" : "";
    146177    if ($img_type eq "raw") {
    147178        $class_id = $component;
     
    196227    } elsif ($req_type eq "byexp") {
    197228        $command .= " -exp_name $id";
     229    } elsif ($req_type eq "byskycell") {
     230        $command .= " -tess_id $tess_id -skycell_id $skycell_id";
    198231    } else {
    199232        die "Unknown req_type supplied: $req_type";
    200233    }
     234
     235    if ($img_type ne "stack") {
     236        $command .= $magic_arg;
     237        $command .= " -dateobs_begin $dateobs_begin" if $dateobs_begin;
     238        $command .= " -dateobs_end $dateobs_end" if $dateobs_end;
     239    }
     240
     241    $command .= " -filter $filter" if !isnull($filter);
     242    $command .= " -label $label" if !isnull($label);
    201243
    202244    # run the tool and parse the output
     
    386428    my $x        = shift;
    387429    my $y        = shift;
    388     my $mjd_min  = shift;
    389     my $mjd_max  = shift;
     430    my $dateobs_begin  = shift;
     431    my $dateobs_end  = shift;
    390432    my $filter   = shift;
    391433    my $verbose  = shift;
     
    403445
    404446    my $args;
    405     if ($mjd_min) {
    406         my $dateobs_min = mjd_to_dateobs($mjd_min);
    407         $args .= " -dateobs_begin $dateobs_min";
    408     }
    409     if ($mjd_max) {
    410         my $dateobs_max = mjd_to_dateobs($mjd_max);
    411         $args .= " -dateobs_end $dateobs_max";
    412     }
    413     if ($filter) {
     447    if (!isnull($dateobs_begin)) {
     448        $args .= " -dateobs_begin $dateobs_begin";
     449    }
     450    if (!isnull($dateobs_end)) {
     451        $args .= " -dateobs_end $dateobs_end";
     452    }
     453    if (!isnull($filter)) {
    414454        $args .= " -filter $filter";
    415455    }
     
    567607    my ($sec, $min, $hr, $day, $mon, $year) = gmtime($ticks);
    568608
    569     return sprintf "'%4d-%02d-%02d %02d:%02d:%02d'", $year+1900, $mon+1, $day, $hr, $min, $sec;
     609    return sprintf "'%4d-%02d-%02dT%02d:%02d:%02dZ'", $year+1900, $mon+1, $day, $hr, $min, $sec;
     610}
     611
     612sub isnull {
     613    my $val = shift;
     614
     615    return (!defined($val) or (lc($val) eq "null"));
     616}
     617
     618sub iszero {
     619    my $val = shift;
     620    return (!defined($val) or ($val == 0));
    570621}
    571622
  • trunk/pstamp/scripts/pstamp_finish.pl

    r25540 r25712  
    8181    my $fileset = $req_name;
    8282
    83 
    84     # Here we invoke the assumption that the output for the request is placed in the
    85     # fileset directory directly
    86 #    my $out_dir = "$outputDataStoreRoot/$product/$fileset";
    87 
    88     # now we are assuming that the output directory is the dirname of the request file
    89     # XXX: put this in the database
    90 
    9183    print STDERR "product: $product  REQ_NAME: $req_name $out_dir\n" if $verbose;
    9284
     
    216208
    217209                    # ra_deg and dec_deg are the coordinates of center of the stamp
    218                     # XXX: parse the stamp header to find it
    219                     print $tdf "0.0|0.0|";
     210                    # XXX do this more cleanly
     211                    my (undef, $ra_deg, $dec_deg) = split " ", `echo $out_dir/$img_name | fields RA_DEG DEC_DEG`;
     212                    $ra_deg = 0.0 if (!$ra_deg);
     213                    $dec_deg = 0.0 if (!$dec_deg);
     214                    print $tdf "$ra_deg|$dec_deg|";
    220215
    221216                    print $tdf "$exp_info|";
  • trunk/pstamp/scripts/pstamp_job_run.pl

    r25369 r25712  
    1616use PS::IPP::PStamp::RequestFile qw( :standard );
    1717use IPC::Cmd 0.36 qw( can_run run );
     18use POSIX;
    1819
    1920use PS::IPP::Metadata::Config;
     
    9394        run(command => $command, verbose => $verbose);
    9495
    95     if ($success) {
     96    my $exitStatus;
     97    if (WIFEXITED($error_code)) {
     98        $exitStatus = WEXITSTATUS($error_code);
     99    } else {
     100        print STDERR "ppstamp failed error_code: $error_code\n";
     101        $exitStatus = $PS_EXIT_SYS_ERROR;
     102    }
     103
     104    if ($exitStatus == 0) {
    96105        my $dir = dirname($outputBase);
    97106
     
    133142        close F;
    134143        $jobStatus = $PS_EXIT_SUCCESS;
    135     } else {
    136         $jobStatus = $error_code >> 8;
    137         my_die( "ppstamp failed with error code: $jobStatus", $job_id, $jobStatus);
     144    } elsif ($exitStatus == $PSTAMP_NO_OVERLAP) {
     145        $jobStatus = $PSTAMP_NO_OVERLAP
     146    } else {
     147        my_die( "ppstamp failed with error code: $exitStatus", $job_id, $exitStatus);
    138148    }
    139149} elsif ($jobType eq "get_image") {
     
    162172{
    163173    my $command = "$pstamptool -updatejob -job_id $job_id -state stop";
     174    $command .= " -fault $jobStatus" if $jobStatus;
    164175    $command .= " -dbname $dbname" if $dbname;
    165176    $command .= " -dbserver $dbserver" if $dbserver;
  • trunk/pstamp/scripts/pstampparse.pl

    r25540 r25712  
    1616use File::Basename qw(basename);
    1717use Carp;
    18 use POSIX qw( strftime );
     18use POSIX;
    1919
    2020my $verbose;
     
    7272}
    7373
     74# list_job is a deugging mode
    7475$no_update = 1 if $mode eq "list_job";
    7576
     
    185186    }
    186187    my $req_type = $row->{REQ_TYPE};
    187     $stage = $row->{IMG_TYPE};
    188     my $id       = $row->{ID};
     188    $stage       = $row->{IMG_TYPE};
     189    my $id      = $row->{ID};
    189190    my $component = $row->{COMPONENT};
    190 
    191     my $filter   = $row->{REQFILT};
     191    my $tess_id = $row->{TESS_ID};
     192
     193    my $filter  = $row->{REQFILT};
    192194    my $mjd_min = $row->{MJD_MIN};
    193195    my $mjd_max = $row->{MJD_MAX};
     196    my $label   = $row->{LABEL};
    194197
    195198    my $option_mask= $row->{OPTION_MASK};
     
    222225    my_die("job_type is list_uri but mode is $mode", $PS_EXIT_PROG_ERROR) if ($job_type eq "list_uri") and ($mode ne "list_uri");
    223226
    224 
    225227    my $image_db   = $proj_hash->{dbname};
    226228    my $camera     = $proj_hash->{camera};
     
    228230
    229231    # Temporary hack so that MOPS can get at non-magicked data
    230     if ($product eq "mops-pstamp-results") {
     232    if ($product and ($product eq "mops-pstamp-results")) {
    231233        $need_magic = 0;
    232234    }
     
    269271        my ($x, $y);
    270272
    271         $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $search_component,
    272                 $inverse, $skycenter, $x, $y, $mjd_min, $mjd_max, $filter, $verbose);
     273        $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $tess_id, $search_component,
     274                $inverse, $need_magic, $x, $y, $mjd_min, $mjd_max, $filter, $label, $verbose);
    273275
    274276        if (!$imageList or !@$imageList) {
     
    305307    my $num_jobs = 0;
    306308    my $rownum = $row->{ROWNUM};
     309    my $option_mask = $row->{OPTION_MASK};
    307310    my $components = $row->{components};
    308311
     
    346349        if (($stage ne "stack") and ($need_magic and !$image->{magicked})) {
    347350            # XXX: should we add a faulted job so the client can know what happened if no images come back?
     351            # This test is made in locate_images now so this code never runs. This leads to no feedback
     352            # to users, but speeds up processing significatnly
    348353            print STDERR "skipping non-magicked image $imagefile\n" if $verbose;
    349354
     
    369374        $args .= " -file $imagefile";
    370375
    371         if (($row->{OPTION_MASK} & $PSTAMP_SELECT_MASK) &&  $image->{mask} ) {
     376        if (($option_mask & $PSTAMP_SELECT_MASK) &&  $image->{mask} ) {
    372377            $args .= " -mask $image->{mask}";
    373378        }
    374         if (($row->{OPTION_MASK} & $PSTAMP_SELECT_WEIGHT) and $image->{weight} ) {
     379        if (($option_mask & $PSTAMP_SELECT_WEIGHT) and $image->{weight} ) {
    375380            $args .= " -variance $image->{weight}";
    376381        }
     
    407412        $num_jobs++;
    408413        my $command = "$pstamptool -addjob  -req_id $req_id -job_type $row->{JOB_TYPE}"
    409                         . " -outputBase $output_base -rownum $rownum -state $newState";
     414                        . " -outputBase $output_base -rownum $rownum -state $newState -options $option_mask";
    410415        $command .= " -fault $fault" if $fault;
    411416        $command .= " -exp_id $exp_id" if $exp_id;
     
    542547                    run(command => $command, verbose => $verbose);
    543548                unless ($success) {
    544                     print STDERR @$stderr_buf;
    545                     my $rc = $error_code >> 8;
    546                     my_die( "dvoImagesAtCoords failed: $rc", $PS_EXIT_UNKNOWN_ERROR);
     549                    # don't fail if the program exited normally and exit status was PSTAMP_NO_OVERLAP
     550                    # That just means that the coordinate didn't match any image/skycell
     551                    if (!WIFEXITED($error_code) || (WEXITSTATUS($error_code) ne $PSTAMP_NO_OVERLAP)) {
     552                        print STDERR @$stderr_buf;
     553                        my $rc = WIFEXITED($error_code) ? WEXITSTATUS($error_code) : $PS_EXIT_SYS_ERROR;
     554                        my_die( "dvoImagesAtCoords failed: $rc", $rc);
     555                    }
    547556                }
    548557                # now we have a list of row numbers and components
Note: See TracChangeset for help on using the changeset viewer.