IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35549


Ignore:
Timestamp:
May 9, 2013, 11:30:13 AM (13 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20130419/PS-IPP-PStamp/lib/PS/IPP/PStamp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130419/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r35398 r35549  
    5151
    5252my $default_data_groups = "";
     53
     54# old locate_images() function. Still used by dqueryparse
     55# Postage stamp server now uses locate_images_for_row()
    5356
    5457sub locate_images {
     
    172175    my $results = lookup($ipprc, $rowList, $imagedb, $req_type, $stage, $id, $tess_id, $component,
    173176        $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,
     177        0, 0,   # fwhm cuts are not applied here
    174178        undef, undef, undef, $verbose);
    175179
     
    217221    if (!iszero($mjd_min)) {
    218222        $dateobs_begin = mjd_to_dateobs($mjd_min);
     223        if (!$dateobs_begin) {
     224            $row->{error_code} = $PSTAMP_INVALID_REQUEST;
     225            print STDERR "Invalid MJD_MIN: $mjd_min\n";
     226            return undef;
     227        }
    219228    }
    220229    if (!iszero($mjd_max)) {
    221230        $dateobs_end = mjd_to_dateobs($mjd_max);
     231        if (!$dateobs_begin) {
     232            $row->{error_code} = $PSTAMP_INVALID_REQUEST;
     233            print STDERR "Invalid MJD_MAX: $mjd_max\n";
     234            return undef;
     235        }
    222236    }
    223237    if (isnull($tess_id)) {
     
    250264    }
    251265
    252     my ($release_name, $survey) = get_release_info($row);
     266    my ($release_name, $survey, $default_tess_id) = get_release_info($row);
     267    if (!$tess_id and $default_tess_id) {
     268        $tess_id = $default_tess_id;
     269    }
    253270
    254271    if ($req_type eq "bydiff") {
     
    304321    my $results = lookup($ipprc, $rowList, $imagedb, $req_type, $stage, $id, $tess_id, $component,
    305322        0, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,
     323        getValOrZero($row->{FWHM_MIN}), getValOrZero($row->{FWHM_MAX}),
    306324        undef, $release_name, $survey,
    307325        $verbose);
     
    330348    my $mjd_min = shift;
    331349    my $mjd_max = shift;
     350    my $fwhm_min = shift;
     351    my $fwhm_max = shift;
    332352    my $selectedAstrom = shift;
    333353    my $release_name = shift;
     
    365385    my $release_args;
    366386    if (($req_type eq 'byexp' and $stage ne 'raw') or ($req_type eq 'byskycell' and $stage ne 'diff')) {
    367         unless (isnull($release_name) and isnull($survey)) {
     387        if ($release_name or $survey) {
    368388            $use_releasetool = 1;
    369             $release_args = " -release_name $release_name" if $release_name;
     389            if ($release_name) {
     390                $release_args = " -release_name $release_name";
     391            } else {
     392                $release_args = " -priority_order";
     393            }
    370394            $release_args .= " -surveyName $survey" if $survey;
    371395        }
     
    402426        # choose the chips containing the center pixel by calling selectComponets() below
    403427        if ($use_releasetool) {
    404             $command = "$releasetool -dbname $imagedb -priority_order -listrelexp $release_args";
     428            $command = "$releasetool -dbname $imagedb -listrelexp $release_args";
    405429            $choose_components = 1;
    406430        } else {
     
    433457    } elsif ($stage eq 'warp') {
    434458        if ($use_releasetool) {
    435             $command = "$releasetool -dbname $imagedb -priority_order -listrelexp $release_args";
     459            $command = "$releasetool -dbname $imagedb -listrelexp $release_args";
     460            $skycell_id = $component;
    436461            $choose_components = 1;
    437462        } else {
     
    444469                }
    445470            } else {
    446                 $command = " -listrun";
     471                $command .= " -listrun";
    447472                $choose_components = 1;
    448473            }
     
    456481        $base_name    = "path_base"; # name of the field for the warptool output
    457482    } elsif ($stage eq "diff") {
    458         # XXX: is this path ever used for diff images anymore?
     483
    459484        if ($component or $use_imfile_id or !$skycenter) {
    460485            $command = "$difftool -diffskyfile -pstamp_order -dbname $imagedb";
     
    475500        $psf_name    = "PSPHOT.PSF.SKY.SAVE";
    476501        $base_name   = "path_base";
     502        my $diff_mode = getDiffMode($row->{RUN_TYPE});
     503        $command .= " -diff_mode $diff_mode" if $diff_mode;
    477504    } elsif ($stage eq "stack") {
    478505        $skycell_id = $component;
     
    480507            $command = "$releasetool -listrelstack -dbname $imagedb $release_args";
    481508            $base_name = 'stack_path_base';
     509            my $stack_type = $row->{RUN_TYPE};
     510            if (!isnull($stack_type)) {
     511                if (lc($stack_type) eq 'notnightly') {
     512                    $command .= " -stack_type deep -stack_type reference";
     513                } else {
     514                    $command .= " -stack_type $stack_type";
     515                }
     516            }
    482517        } else {
    483518            $command = "$stacktool -sumskyfile -dbname $imagedb";
     
    539574        $command .= " -dateobs_end $dateobs_end" if $dateobs_end;
    540575    } elsif ($req_type ne "byid") {
    541         $command .= " -mjd_obs_begin $mjd_min" if $mjd_min;
    542         $command .= " -mjd_obs_end $mjd_max" if $mjd_max;
     576        $command .= " -mjd_min $mjd_min" if $mjd_min;
     577        $command .= " -mjd_max $mjd_max" if $mjd_max;
    543578    }
    544579
     
    552587    }
    553588
     589    if ($use_releasetool) {
     590        # fwhm arguments are currently only supported when using releasetool for lookups
     591        $command .= " -fwhm_min $fwhm_min" if $fwhm_min;
     592        $command .= " -fwhm_max $fwhm_max" if $fwhm_max;
     593    }
     594
    554595    my $images = runToolAndParse($command, $verbose);
    555596
     
    568609        # match the coords in the rows to the components in the runs
    569610        # returns an actual list of images
    570         if ($skycenter) {
     611        if ($skycenter and $req_type ne 'byskycell') {
    571612            $images = selectComponents($ipprc, $imagedb, $req_type, $stage, $rowList, $images, $verbose);
    572613        } else {
     
    644685                $out->{data_state} = $out->{state} = $out->{stack_state};
    645686            } else {
     687                # XXX: Consider looking up skycal results even if we are
     688                # not using releasetool
    646689                $out->{data_state} = $out->{state};
    647690            }
     
    655698            if ($selectedAstrom) {
    656699                $out->{astrom} = $selectedAstrom;
    657                 $out->{cam_path_base} = basename($selectedAstrom);
     700                $out->{cam_path_base} = $selectedAstrom;
     701                if ($selectedAstrom =~ /\.smf$/) {
     702                    $out->{cam_path_base} =~ s/\.smf$//;
     703                } elsif ($selectedAstrom =~ /\.cmf$/) {
     704                    $out->{cam_path_base} =~ s/\.cmf$//;
     705                } else {
     706                    die ("ERROR: don't know how to extract cam_path_base from $selectedAstrom\n");
     707                }
    658708            } elsif (! defined $out->{astrom}) {
    659709                if (! find_astrometry($ipprc, $imagedb, $out, $verbose)) {
     
    697747
    698748    my $command = "$difftool -dbname $imagedb -pstamp_order";
    699    
     749
    700750    my $choose_components = 0;
    701751    if ($byid) {
     
    713763    }
    714764
     765    my $diff_mode = getDiffMode($rowList->[0]->{RUN_TYPE});
     766    $command .= " -diff_mode $diff_mode" if $diff_mode;
     767   
    715768    my $output = runToolAndParse($command, $verbose);
    716769
     
    742795        }
    743796
     797        # XXX: The logic below is somewhat messed up. See XXX: ... below
     798        #
    744799        # The standard way to do a diff is warp - stack
    745800        # so we interpret the requested image in that way
     
    756811        }
    757812        my $stack_id;
     813        if ($image->{diff_mode} == 2) {
     814            # XXX: .. stack_id wasn't getting set
     815            $stack_id = $stack2;
     816            $image->{stack_id} = $stack_id;
     817        }
    758818        if ($stack1 and $stack2) {
    759819            # we have a stack - stack diff (well it might be stack - warp....)
     
    850910    my $ra         = shift;
    851911    my $dec        = shift;
    852     my $dateobs_begin  = shift;
     912    my $dateobs_begin  = shift; # these are used for single frame lookups
    853913    my $dateobs_end    = shift;
    854914    my $filter     = shift;
    855915    my $data_group = shift;
    856916    my $option_mask = shift;
    857     my $mjd_min = shift;
    858     my $mjd_max = shift;
    859     my $astrom = shift;
     917    my $mjd_min = shift;        # these are used for stack lookups
     918    my $mjd_max = shift;        # these are used for stack lookups
    860919    my $verbose    = shift;
    861920
    862     my ($release_name, $survey) = get_release_info($row);
     921    my $fwhm_min = getValOrZero($row->{FWHM_MIN});
     922    my $fwhm_max = getValOrZero($row->{FWHM_MAX});
     923   
     924
     925    my ($release_name, $survey, $default_tess_id) = get_release_info($row);
     926    if (!$tess_id and $default_tess_id) {
     927        $tess_id = $default_tess_id;
     928    }
    863929
    864930    my $rowList = [$row];
     
    868934
    869935        my $chips = lookup_by_cam_id_and_coords($ipprc, $imagedb, $stage,
    870             $ra, $dec, $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $verbose, $release_name, $survey, $row->{FWHM_MIN}, $row->{FWHM_MAX});
     936            $ra, $dec, $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $verbose,
     937            $release_name, $survey, $fwhm_min, $fwhm_max);
    871938
    872939        if (!$chips or scalar @$chips == 0) {
     
    878945                    $tess_id, $chip->{component}, $need_magic,
    879946                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,
     947                    $fwhm_min, $fwhm_max,
    880948                    $chip->{astrom}, undef, undef,
    881949                    $verbose);
     
    896964            setErrorCodes($rowList, $PSTAMP_NO_IMAGE_MATCH);
    897965        } else {
     966            # XXX: We are not applying the fwhm cuts
    898967            foreach my $skycell (@$skycells) {
    899968                my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef,
    900969                    $skycell->{tess_id}, $skycell->{component}, $need_magic,
    901970                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,
     971                    $fwhm_min, $fwhm_max,
    902972                    undef, $release_name, $survey,
    903973                    $verbose);
     
    9391009    if ($release_name or $survey) {
    9401010        $command = "$releasetool -dbname $imagedb -listrelexp";
    941         if (!isnull($survey)) {
    942             $command .= " -survey_name $survey";
    943         }
    944         if (!isnull($release_name)) {
     1011        if ($survey) {
     1012            $command .= " -surveyName $survey";
     1013        }
     1014        if ($release_name) {
    9451015            $command .= " -release_name $release_name";
    9461016        } else {
     
    12681338    my $mjd = shift;
    12691339
     1340    if ($mjd < 54000) {
     1341        print STDERR "MJD value too small minimum is 54000\n";
     1342        return undef;
     1343    }
     1344
    12701345    my $ticks = ($mjd - 40587.0) * 86400;
    12711346
     
    12921367    my $val = shift;
    12931368    return (!defined($val) or ($val == 0));
     1369}
     1370
     1371sub getValOrZero {
     1372    my $val = shift;
     1373    return iszero($val) ? 0.0 : $val;
    12941374}
    12951375
     
    15251605    }
    15261606   
    1527     if (($req_type eq "byid") or ($req_type eq "byexp")) {
     1607    # XXX: Why did I make this restriction? I added byskycell
     1608    if (($req_type eq "byid") or ($req_type eq "byexp") or ($req_type eq 'byskycell')) {
    15281609        my ($last_tess_id, $tess_dir_abs, $astrom_file) = ("", "", "");
    15291610        foreach my $run (@$runList) {
     
    17571838        $release_name = "";
    17581839        # no release check for survey
    1759         $survey = $row->{SURVEY_NAME};
     1840        $survey = isnull($row->{SURVEY_NAME}) ? "" : $row->{SURVEY_NAME};
    17601841    } else {
     1842        # if release is given leave survey empty
    17611843        $survey = "";
    17621844    }
    17631845
    1764     return ($release_name, $survey);
    1765 }
     1846    my $tess_id;
     1847    if ($release_name) {
     1848        # hack to optimize bycoord and byskycell lookups for well known releases
     1849        # XXX: todo query database and return a list for the survey or release
     1850        if ($release_name eq '3PI.PV1') {
     1851            $tess_id = 'RINGS.V3';
     1852        }
     1853    }
     1854
     1855    return ($release_name, $survey, $tess_id);
     1856}
     1857
     1858sub getDiffMode {
     1859    my $run_type = shift;
     1860    my $diff_mode;
     1861    if (!isnull($run_type)) {
     1862        $run_type = lc($run_type);
     1863        if ($run_type eq 'warp_warp') {
     1864            $diff_mode = 1;
     1865        } elsif ($run_type eq 'warp_stack') {
     1866            $diff_mode = 2;
     1867        } elsif ($run_type eq 'stack_stack') {
     1868            $diff_mode = 4;
     1869        } else {
     1870            print STDERR "Ingnoring unrecognized diff RUN_TYPE : $run_type\n";
     1871        }
     1872    }
     1873    return $diff_mode;
     1874}
     1875       
    17661876
    17671877sub my_die
  • branches/eam_branches/ipp-20130419/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r35384 r35549  
    4444                    $PSTAMP_DUP_REQUEST
    4545                    $PSTAMP_INVALID_REQUEST
     46                    $PSTAMP_UNKNOWN_PROJECT
    4647                    $PSTAMP_UNKNOWN_PRODUCT
    4748                    $PSTAMP_NO_IMAGE_MATCH
     
    5253                    $PSTAMP_NO_OVERLAP
    5354                    $PSTAMP_NOT_AUTHORIZED
    54                     $PSTAMP_UNKNOWN_PROJECT
    5555                    );
    5656our %EXPORT_TAGS = (standard => [@EXPORT_OK]);
     
    8181our $PSTAMP_USE_IMFILE_ID      = 16384;
    8282our $PSTAMP_NO_WAIT_FOR_UPDATE = 32768;
     83
     84# these bits will be repurposed
    8385our $PSTAMP_REQUEST_UNCENSORED = 0x10000;
    8486our $PSTAMP_REQUIRE_UNCENSORED = 0x20000;
     
    9496our $PSTAMP_DUP_REQUEST      = 20;
    9597our $PSTAMP_INVALID_REQUEST  = 21;
    96 our $PSTAMP_UNKNOWN_PRODUCT  = 22;
     98our $PSTAMP_UNKNOWN_PROJECT  = 22;
     99our $PSTAMP_UNKNOWN_PRODUCT  = 22;  #this error code was mis-named it is left for compatabiliyt
    97100our $PSTAMP_NO_IMAGE_MATCH   = 23;
    98101our $PSTAMP_NOT_DESTREAKED   = 24;
    99102our $PSTAMP_NOT_AVAILABLE    = 25;
    100 our $PSTAMP_GONE             = 26;
     103our $PSTAMP_GONE             = 26;  # this value is used in ippTools
    101104our $PSTAMP_NO_JOBS_QUEUED   = 27;
    102105our $PSTAMP_NO_OVERLAP       = 28;
    103106our $PSTAMP_NOT_AUTHORIZED   = 29;
    104 our $PSTAMP_UNKNOWN_PROJECT  = 22;
    105107
    106108
     
    133135PSTAMP_DUP_REQUEST
    134136PSTAMP_INVALID_REQUEST
    135 PSTAMP_UNKNOWN_PRODUCT
     137PSTAMP_UNKNOWN_PROJECT
    136138PSTAMP_NO_IMAGE_MATCH
    137139PSTAMP_NOT_DESTREAKED
     
    140142PSTAMP_NO_JOBS_QUEUED
    141143PSTAMP_NO_OVERLAP
     144PSTAMP_NOT_AUTHORIZED
    142145PSTAMP_NOT_AUTHORIZED
    143146);
Note: See TracChangeset for help on using the changeset viewer.