IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34800 for trunk/ippScripts


Ignore:
Timestamp:
Dec 11, 2012, 2:04:31 PM (14 years ago)
Author:
watersc1
Message:

Merge from my branch including background restoration and stack stage projection cell binned images.

Location:
trunk
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippScripts/Build.PL

    r33627 r34800  
    128128        scripts/listvideocells.pl
    129129        scripts/skycalibration.pl
     130        scripts/regenerate_background.pl
    130131    )],
    131132    dist_abstract => 'Scripts for running the Pan-STARRS IPP',
  • trunk/ippScripts/MANIFEST

    r31435 r34800  
    4646scripts/skycell_jpeg.pl
    4747scripts/lap_science.pl
     48scripts/regenerate_background.pl
    4849t/00_distribution.t
  • trunk/ippScripts/scripts/destreak_restore_camera.pl

  • trunk/ippScripts/scripts/detrend_process_imfile.pl

    r33666 r34800  
    2727my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    2828my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     29my $nebrepair = can_run('neb-repair') or (warn "Can't find neb-repair" and $missing_tools = 1);
     30
    2931if ($missing_tools) {
    3032    warn("Can't find required tools.");
     
    124126# Run ppImage
    125127unless ($no_op) {
     128    my $repair_cmd = "$nebrepair $input_uri";
     129    my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
     130    unless ($repair_success) {
     131        &my_die("Unable to attempt repair: $input_uri $repair_error_code", $det_id, $exp_id, $class_id $PS_EXIT_SYS_ERROR);
     132    }
     133
     134
    126135    my $command = "$ppImage -file $input_uri $outroot";
    127136    $command .= " -recipe PPIMAGE $ppimage_recipe";
  • trunk/ippScripts/scripts/ipp_apply_burntool_single.pl

  • trunk/ippScripts/scripts/magic_destreak.pl

  • trunk/ippScripts/scripts/skycell_jpeg.pl

    r28403 r34800  
    268268
    269269    my %tangents = ();
     270
     271    my %products = ('image' => "PPSTACK.UNCONV",
     272                    'mask'  => "PPSTACK.UNCONV.MASK",
     273                    'variance' => "PPSTACK.UNCONV.VARIANCE",
     274                    'exp'   => "PPSTACK.UNCONV.EXP",
     275                    'num'   => "PPSTACK.UNCONV.EXPNUM",
     276                    'bkg'   => "PPSTACK.OUTPUT.BKGMODEL"
     277        );
    270278   
    271279    foreach my $imfile (@$imfiles) {
     
    281289
    282290        $projection_cell =~ s/^(.*)\..*$/$1/;
    283        
     291
    284292        unless (exists($tangents{$projection_cell})) {
    285293            # Make a temp file and fill, but be sure to save
    286             ($tempFile, $tempName) = tempfile("/tmp/skycell.$projection_cell.XXXX",
    287                                                  UNLINK => !$save_temps);
    288             $tangents{$projection_cell}{FILE} = $tempFile;
    289             $tangents{$projection_cell}{NAME} = $tempName;
    290             if ($masks) {
    291                 my ($maskFile, $maskName) = tempfile("/tmp/skycell.$projection_cell.masks.XXXX",
    292                                                      UNLINK => !$save_temps);
    293                 $tangents{$projection_cell}{MFILE} = $maskFile;
    294                 $tangents{$projection_cell}{MNAME} = $maskName;
    295             }           
    296         }
    297         print "$skycell_id $projection_cell\n";
    298         my $file = $ipprc->filename("PPSTACK.OUTPUT", $path_base, $skycell_id);
    299         print "$file $state $quality\n";
    300         my $f_fh = $tangents{$projection_cell}{FILE};
    301         print $f_fh "$file\n";
    302         if ($masks) {
    303             my $mask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $path_base, $skycell_id);
    304             print "$mask\n";
    305             my $m_fh = $tangents{$projection_cell}{MFILE};
    306             print $m_fh "$mask\n";
     294            foreach my $key (keys %products) {
     295                ($tempFile, $tempName) = tempfile("/tmp/skycell.$projection_cell.$key.XXXX",
     296                                                  UNLINK => !$save_temps);
     297                $tangents{$projection_cell}{$key}{FILE} = $tempFile;
     298                $tangents{$projection_cell}{$key}{NAME} = $tempName;
     299            }
     300        }
     301        foreach my $key (keys %products) {
     302            print "$skycell_id $projection_cell\n";     
     303            my $file = $ipprc->filename($products{$key}, $path_base, $skycell_id);
     304            print "$file $state $quality\n";
     305            my $f_fh = $tangents{$projection_cell}{$key}{FILE};
     306            print $f_fh "$file\n";
    307307        }
    308308    }
    309309    foreach my $projection_cell (keys %tangents) {
    310         $command = "$ppSkycell -images $tangents{$projection_cell}{NAME}";
    311         if ($masks) {
    312             $command .= " -masks $tangents{$projection_cell}{MNAME} ";
    313         }
    314         $command .= " ${outroot}.${projection_cell} ";
    315         print "$command\n";
    316         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
    317         unless ($success) {
    318             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    319             &my_die("unable to perform ppSkycell: $error_code", $stage_id, $error_code);
    320         }
     310        ## Loop over results here.
     311        # Images
     312        # Masks
     313        # Variances
     314        # Nexptime
     315        # Nexp
     316        # Backgrounds
     317       
     318        foreach my $key (keys %products) {
     319            $command = "$ppSkycell -images $tangents{$projection_cell}{$key}{NAME}";
     320            $command .= " ${outroot}.${projection_cell}.${key} ";
     321            if ($key eq 'bkg') {
     322                $command .= " -Di BIN1 1 -Di BIN2 1 ";
     323            }
     324            elsif ($key eq 'image') {
     325                $command .= " -masks $tangents{$projection_cell}{mask}{NAME} ";
     326            }
     327            elsif ($key eq 'mask') {
     328                next; # This should be made with the images.
     329            }
     330            print "$command\n";
     331            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     332            unless ($success) {
     333                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     334                &my_die("unable to perform ppSkycell: $error_code", $stage_id, $error_code);
     335            }
     336        }
     337
    321338        # Update database:
    322339        $command = "$stacktool -addsummary -sass_id $stage_id -projection_cell $projection_cell -path_base $outroot";
  • trunk/ippScripts/scripts/stack_skycell.pl

    r32562 r34800  
    229229    my $sources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base}); # Sources name
    230230
     231    my $bkgmodel = $ipprc->filename("PSWARP.OUTPUT.BKGMODEL", $file->{path_base});
     232
    231233    &my_die("Image $image does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image );
    232234    &my_die("Mask $mask does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $mask );
     
    240242    print $listFile "\tPSF\tSTR\t" . $psf . "\n" if $convolve;
    241243    print $listFile "\tSOURCES\tSTR\t" . $sources . "\n";
     244    print $listFile "\tBKGMODEL\tSTR\t" . $bkgmodel . "\n" if $ipprc->file_exists( $bkgmodel );
    242245
    243246    print $listFile "END\n\n";
  • trunk/ippScripts/scripts/warp_skycell.pl

    r33053 r34800  
    128128# Where do we get the astrometry source from?
    129129my $astromSource;               # The astrometry source
     130my $doBackground;               # Do we want to make background models?
    130131{
    131132    my $command = "$ppConfigDump -camera $camera -recipe PSWARP $recipe_pswarp -dump-recipe PSWARP -";
     
    139140        &my_die("Unable to parse metadata config doc", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR);
    140141    $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE');
     142    $doBackground = metadataLookupBool($metadata, 'BACKGROUND.MODEL');   
    141143}
    142144
     
    168170if ($do_stats) {
    169171    $outputStats = prepare_output ("SKYCELL.STATS", $outroot, $skycell_id, 1) if $do_stats;
     172}
     173my $outputBKGs;
     174if ($doBackground) {
     175    $outputBKGs = prepare_output ("PSWARP.OUTPUT.BKGMODEL", $outroot, $skycell_id, 1);
    170176}
    171177my $configuration;
     
    209215my ($weightFile, $weightName) = tempfile( "$tempOutRoot.weight.list.XXXX", UNLINK => !$save_temps);
    210216my ($astromFile, $astromName) = tempfile( "$tempOutRoot.astrom.list.XXXX", UNLINK => !$save_temps);
    211 
     217my ($bkgFile, $bkgName);
     218if ($doBackground) {
     219    ($bkgFile, $bkgName) = tempfile( "$tempOutRoot.bkg.list.XXXX", UNLINK => !$save_temps);
     220}
    212221my $wrote_astrom = 0;
    213222foreach my $imfile (@$imfiles) {
     
    235244    print $maskFile   "$mask\n";
    236245    print $weightFile "$weight\n";
     246    my $bkg;
     247    if ($doBackground) {
     248        $bkg    = $ipprc->filename("PSPHOT.BACKMDL", $imfile->{chip_path_base}, $imfile->{class_id});
     249        print $bkgFile "$bkg\n";
     250    }
    237251
    238252    if (!$wrote_astrom) {
     
    245259close $weightFile;
    246260close $astromFile;
    247 
     261if ($doBackground) {
     262    close($bkgFile);
     263}
    248264# We need the recipe to determine if we care whether the PSF is generated or not
    249265my $recipe;
     
    269285    $command .= " -variancelist $weightName";
    270286    $command .= " -astromlist $astromName";
     287    $command .= " -bkglist $bkgName" if ($doBackground);
    271288    $command .= " $outroot $skyFile";
    272289    $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE";
Note: See TracChangeset for help on using the changeset viewer.