IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

implement REQ_TYPE byskycell and various other features

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.