IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36827


Ignore:
Timestamp:
Jun 7, 2014, 5:37:10 AM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20140423
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140423/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r36133 r36827  
    5656                    $PSTAMP_NOT_AUTHORIZED
    5757                    $PSTAMP_NO_VALID_PIXELS
     58                    $PSTAMP_BG_RESTORE_NOT_AVAILABLE
    5859                    );
    5960our %EXPORT_TAGS = (standard => [@EXPORT_OK]);
     
    112113our $PSTAMP_NOT_AUTHORIZED   = 29;
    113114our $PSTAMP_NO_VALID_PIXELS  = 30;
     115our $PSTAMP_BG_RESTORE_NOT_AVAILABLE = 31;
    114116
    115117
  • branches/eam_branches/ipp-20140423/ppBackground/src/ppBackgroundStackCamera.c

    r36642 r36827  
    267267            psString solutionFileName = psStringCopy(data->OTApath);
    268268            psStringAppend(&solutionFileName, ".%s.fits",chipName);
    269             psFits *solutionFits = psFitsOpen(solutionFileName,"r");
     269            psString resolvedFileName = pmConfigConvertFilename(solutionFileName,config,false,false);
     270            psFits *solutionFits = psFitsOpen(resolvedFileName,"r");
    270271            psImage *solution = psFitsReadImage(solutionFits,psRegionSet(0,0,0,0),0);
    271272            psMetadataAddImage(data->OTA_solutions,PS_LIST_TAIL,
  • branches/eam_branches/ipp-20140423/ppBackground/src/ppBackgroundStackMath.c

    r36649 r36827  
    204204 
    205205  pmFPAview *view    = pmFPAviewAlloc(0);
    206   psStats *stats     = psStatsAlloc( PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV );
     206  psStats *stats     = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV );
    207207
    208208  psMetadataIterator *expIter = psMetadataIteratorAlloc(data->models, PS_LIST_HEAD, NULL);
  • branches/eam_branches/ipp-20140423/psLib/src/fits/psFitsScale.c

    r35980 r36827  
    10221022                       /* Add random factor [-0.5,0.5): adds a variance of 1/12, */ \
    10231023                       /* but preserves the expectation value */ \
    1024                         value += psRandomUniform(rng) - 0.5; \
     1024                        value += psRandomUniform(rng) ; \
    10251025                    } \
    10261026                    /* Check for underflow and overflow; set either to max */ \
    1027                     (OUT)->data.OUTTYPE[y][x] = (value < min || value > max ? max : value); \
     1027                    (OUT)->data.OUTTYPE[y][x] = (value < min || value > max ? max : floor(value)); \
    10281028                } \
    10291029            } \
  • branches/eam_branches/ipp-20140423/pstamp/scripts/psmkreq

    r36250 r36827  
    2929my ($ra, $dec, $x, $y, $list, $output, $req_name, $req_name_base);
    3030
    31 my ($image, $mask, $variance, $jpeg, $cmf, $psf, $backmdl, $inverse);
     31my ($image, $mask, $variance, $jpeg, $cmf, $psf, $backmdl, $inverse, $restorebackground);
    3232my ($convolved, $unconvolved, $uncompressed, $use_imfile_id, $no_wait);
    3333
     
    120120    'convolved'         => \$convolved,
    121121    'uncompressed'      => \$uncompressed,
     122    'restorebackground' => \$restorebackground,
    122123    'use_imfile_id'     => \$use_imfile_id,
    123124    'do_not_wait'       => \$no_wait,
     
    224225        $option_mask |= $PSTAMP_USE_IMFILE_ID   if $use_imfile_id;
    225226        $option_mask |= $PSTAMP_SELECT_INVERSE  if $inverse;
     227        $option_mask |= $PSTAMP_RESTORE_BACKGROUND  if $restorebackground;
    226228    }
    227229    $option_mask |= $PSTAMP_NO_WAIT_FOR_UPDATE if $no_wait;
  • branches/eam_branches/ipp-20140423/pstamp/scripts/pstamp_checkdependent.pl

    r36688 r36827  
    2121use Carp;
    2222
    23 my $disable_3PI_updates = 1;
     23my $disable_3PI_updates = 0;
     24my $ra_max_3PI_hours = 22.5;  # disable updates for skycells with ra greater than this (hours)
     25my $ra_max_3PI = $ra_max_3PI_hours * 15 * 3.14149 / 180.; # rawExp.ra is in radians
    2426
    2527# XXX: put this in a module somewhere
     
    260262
    261263        if ($disable_3PI_updates && ($chip->{data_group} =~ /ThreePi/)) {
    262             # we are getting close to the end of PV2. Do not update PV1 chips.
    263             print "3PI updates are currently disabled\n";
    264             return $PSTAMP_NOT_AVAILABLE;
     264            # we are getting close to the end of PV2. Do not update PV1 chips if RA is above the limit.
     265            my $ra = $chip->{ra};
     266            if (!defined($ra) or ($ra > $ra_max_3PI)) {
     267                print "3PI updates are currently disabled for RA $ra > $ra_max_3PI (radians)\n";
     268                return $PSTAMP_NOT_AVAILABLE;
     269            } else {
     270                print "allowing 3PI updates RA $ra\n";
     271            }
    265272        }
    266273
     
    381388    # we are getting close to the end of PV2. optionally do not update 3Pi data.
    382389    if ($disable_3PI_updates && ($metadata->{data_group} =~ /ThreePi/)) {
    383         print "3PI updates are currently disabled\n";
    384         return $PSTAMP_NOT_AVAILABLE;
     390        my $ra = $metadata->{ra};
     391        if (!defined $ra or ($ra > $ra_max_3PI)) {
     392            print "3PI updates are currently disabled for RA $ra > $ra_max_3PI (radians)\n";
     393            return $PSTAMP_NOT_AVAILABLE;
     394        } else {
     395            print "allowing 3PI updates RA $ra\n";
     396        }
    385397    }
    386398
     
    465477        }
    466478        $chip_id = $chip->{chip_id};
     479        # XXX: -scmap doesn't have ra and dec. Copy it from the warp
     480        $chip->{ra} = $metadata->{ra};
     481        $chip->{decl} = $metadata->{decl};
    467482
    468483        # if chip has been magicked before require it to be magicked again
  • branches/eam_branches/ipp-20140423/pstamp/scripts/pstamp_finish.pl

    r35409 r36827  
    211211                        chomp $line;
    212212                        my ($img_name, $reported_size, $reported_sum, $filetype) = split '\|', $line;
    213                         # ... instead let dsreg compute the paramters by leaving them blank
    214                         print $rlf "$img_name|||$filetype|\n";
     213                        my $use_supplied_size = 1;
     214                        if ($use_supplied_size) {
     215                            print $rlf "$img_name|$reported_size|$reported_sum|$filetype|\n";
     216                        } else {
     217                            # ... instead let dsreg compute the paramters by leaving them blank
     218                            print $rlf "$img_name|||$filetype|\n";
     219                        }
    215220
    216221                        # add line to the table definition file
  • branches/eam_branches/ipp-20140423/pstamp/scripts/pstamp_job_run.pl

    r36142 r36827  
    2929my ($job_id, $redirect_output, $outputBase, $rownum, $jobType, $options);
    3030my ($verbose, $dbname, $dbserver, $no_update, $save_temps);
     31my $very_verbose = 0; # for debugging
    3132
    3233GetOptions(
     
    6768}
    6869
     70if ($verbose && $save_temps) {
     71    # we're probably debugging turn up the verbosity
     72    $very_verbose = 1;
     73}
     74
    6975if (!$dbserver) {
    7076    $dbserver =  metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER');
    7177}
    7278
     79my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR");
     80$temproot = "/tmp" if !defined $temproot;
     81
    7382my $missing_tools;
    7483
    7584my $pstamptool = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
    76 my $ppstamp    = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1);
    77 my $pstamp_get_image_job    = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1);
    78 my $psgetcalibinfo    = can_run('psgetcalibinfo') or (warn "Can't find psgetcalibinfo" and $missing_tools = 1);
     85my $ppstamp = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1);
     86my $pstamp_get_image_job = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1);
     87my $psgetcalibinfo = can_run('psgetcalibinfo') or (warn "Can't find psgetcalibinfo" and $missing_tools = 1);
    7988my $dquery_job_run = can_run('dquery_job_run.pl') or (warn "Can't find dquery_job_run.pl" and $missing_tools = 1);
    8089my $whichnode = can_run('whichnode') or (warn "can't find whichnode" and $missing_tools = 1);
     90my $ppBackground = can_run('ppBackground') or (warn "Can't find ppBackground" and $missing_tools = 1);
     91my $ppBackgroundStack = can_run('ppBackgroundStack') or (warn "Can't find ppBackgroundStack" and $missing_tools = 1);
     92my $stack_bkg_mk_mdc = can_run('stack_bkg_mk_mdc.pl') or (warn "Can't find stack_bkg_mk_mdc.pl" and $missing_tools = 1);
    8193
    8294if ($missing_tools) {
     
    120132    }
    121133
     134    if ($options & $PSTAMP_RESTORE_BACKGROUND) {
     135        #  this subroutine creates a background restored version of the image or fails.
     136        # upon success params->{image} is replaced with the new (temporary) version
     137        my $error_code = create_background_restored_images($params);
     138        if ($error_code) {
     139            # if error code is one of the permanant ones set state of job to stop
     140            my_die("failed to create background restored images", $job_id, $error_code,
     141                $error_code >= $PSTAMP_FIRST_ERROR_CODE ? 'stop' : undef);
     142        }
     143    }
     144
    122145    my $image = $params->{image};
    123146    my $mask;
    124147    my $variance;
     148
     149    # We need to background restore HERE
     150    # and change the image file supplied to ppstamp
     151
    125152    my $fileArgs = " -file $params->{image}";
    126153    my @file_list = ($params->{image});
     
    665692}
    666693
     694# use ppBackground or ppBackgroundStack to produce background restored images
     695sub create_background_restored_images {
     696    my $params = shift;
     697    my $stage = $params->{stage};
     698
     699    if ($stage ne 'stack' and $stage ne 'chip') {
     700        # this function is only supported for chip and stack stage
     701        # perhaps the parser should catch this ...
     702        print STDERR "background restoration not currently supported for stage $params->{stage}\n";
     703        return $PSTAMP_BG_RESTORE_NOT_AVAILABLE;
     704    }
     705
     706    my $tempdir = tempdir("$temproot/pstamp.$job_id.XXXX", CLEANUP => !$save_temps);
     707    my $imagedb = $params->{imagedb};
     708    my $camera = $params->{camera};
     709
     710    # reinstantiate IPP Configuration using the now known camera so that we get the applicable file rules
     711    $ipprc = PS::IPP::Config->new($camera);
     712
     713    my $input_image = $params->{image};
     714    my $input_mask = $params->{mask};
     715    my $input_variance = $params->{weight};
     716
     717    if ($stage eq 'stack') {
     718        my $stack_id = $params->{stack_id};
     719        my $mdcfile = "$tempdir/stk.$stack_id.bkg_input.mdc";
     720        {
     721            my $command = "$stack_bkg_mk_mdc --stack_id $stack_id --camera $camera --dbname $imagedb > $mdcfile";
     722            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     723                run(command => $command, verbose => $verbose);
     724            unless ($success) {
     725                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     726                &my_die("Unable to perform stack_bg_mk_mdc.pl: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run');
     727            }
     728        }
     729
     730        my $outroot = "$tempdir/stk.$stack_id";
     731
     732        # XXX: get otapath from a config file or detrend system
     733        my $otapath = "neb:///detrends/background_OTA_models.20140527/test_solutions";
     734        {
     735            my $command = "$ppBackgroundStack $outroot -input $mdcfile -image $input_image"
     736               . " -OTApath $otapath" ;
     737            $command .= " -mask $input_mask" if $input_mask;
     738            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     739                run(command => $command, verbose => $very_verbose);
     740            unless ($success) {
     741                # we turned off verbosity because ppBackgroundStack emits too much output
     742                # XXX: perhaps use a log file and save it with the job data
     743                print STDERR join "", @$stderr_buf;
     744                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     745                &my_die("Unable to perform ppBackgroundStack: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run');
     746            }
     747        }
     748        # it's all good change the image to be passed to ppstamp
     749        $params->{image} = $ipprc->filename('PPBACKGROUND.STACK.OUTPUT', $outroot) or
     750                &my_die("Unable to resolve ppBackgroundStack output file name", $job_id, $PS_EXIT_UNKNOWN_ERROR, 'run');
     751
     752    } elsif ($stage eq 'chip') {
     753        my $input_mdl = $params->{backmdl};
     754        my $chip_id = $params->{chip_id};
     755        my $class_id = $params->{class_id};
     756        my $outroot = "$tempdir/bgrestored.ch.$chip_id";
     757        {
     758            my $command = "$ppBackground $outroot -background $input_mdl -image $input_image";
     759            # XXX: I think ppBackground might always require mask and variance images
     760            $command .= " -mask $input_mask";
     761            $command .= " -variance $input_variance";
     762
     763            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     764                run(command => $command, verbose => $verbose);
     765            unless ($success) {
     766                print STDERR join "", @$stderr_buf;
     767                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     768                &my_die("Unable to perform ppBackground: $error_code", $job_id, $PS_EXIT_CONFIG_ERROR, 'run');
     769            }
     770        }
     771        $params->{image} = $ipprc->filename('PPBACKGROUND.OUTPUT', $outroot, $class_id) or
     772                &my_die("Unable to resolve ppBackgroundStack output image name", $job_id, $PS_EXIT_CONFIG_ERROR, 'run');
     773        $params->{mask} = $ipprc->filename('PPBACKGROUND.OUTPUT.MASK', $outroot, $class_id) or
     774                &my_die("Unable to resolve ppBackgroundStack output mask name", $job_id, $PS_EXIT_CONFIG_ERROR, 'run');
     775        $params->{weight} = $ipprc->filename('PPBACKGROUND.OUTPUT.VARIANCE', $outroot, $class_id) or
     776                &my_die("Unable to resolve ppBackgroundStack output variance name", $job_id, $PS_EXIT_CONFIG_ERROR, 'run');
     777
     778    } else {
     779        # can't get here
     780        &my_die( "background restoration not currently supported for stage $params->{stage}\n",
     781            $job_id, $PS_EXIT_PROG_ERROR, 'stop'); ;
     782    }
     783
     784    return 0;
     785}
     786
    667787sub my_die
    668788{
  • branches/eam_branches/ipp-20140423/pstamp/scripts/pstamp_save_server_status.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20140423/pstamp/scripts/pstampparse.pl

    r36687 r36827  
    182182        $label = 'NCU';
    183183        $label_changed = 1;
    184     } elsif (($lcname =~ /mpe_/) or ($lcname =~ /sd_/)) {
     184    } elsif (($lcname =~ /mpe_/) or ($lcname =~ /sd_/) or ($lcname =~ /^jk/)) {
    185185        $label = 'MPE';
    186186        $label_changed = 1;
  • branches/eam_branches/ipp-20140423/pstamp/src/pstamp.h

    r36060 r36827  
    2424        PSTAMP_NOT_AUTHORIZED   = 29,
    2525        PSTAMP_NO_VALID_PIXELS  = 30,
     26        PSTAMP_BG_RESTORE_NOT_AVAILABLE = 31,
    2627} pstampJobErrors;
    2728
Note: See TracChangeset for help on using the changeset viewer.