IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35118 for trunk/ippScripts


Ignore:
Timestamp:
Feb 7, 2013, 1:40:20 PM (13 years ago)
Author:
bills
Message:

Changes to the chip backround and warp background stages.
In chip background stage

Apply an auxillary mask selected for now from hard coded location.
Read input variance and include it in the output data products

In warp background stage

Read and write variance images
Get smf from alternate camRun. For now using a hard coded label
eventually from the warpBackgroundRun

Location:
trunk/ippScripts/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/background_chip.pl

    r34422 r35118  
    1414use DateTime;
    1515my $mjd_start = DateTime->now->mjd;   # MJD of starting script
     16use File::Basename;
    1617
    1718use vars qw( $VERSION );
     
    123124my $in_image = $ipprc->filename("PPIMAGE.CHIP", $in_path, $class_id);
    124125my $in_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $in_path, $class_id);
     126my $in_wt = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $in_path, $class_id);
    125127my $in_bg = $ipprc->filename("PSPHOT.BACKMDL", $in_path, $class_id);
    126128my $in_pattern = $ipprc->filename("PPIMAGE.PATTERN", $in_path, $class_id);
     
    148150}
    149151
     152# XXX: M31 TEST turn off restoring pattern correction
     153$apply_pattern = 0;
     154
    150155# Set up files
    151156&my_die("Couldn't find input file: $in_image\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_image);
    152157&my_die("Couldn't find input file: $in_mask\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_mask);
     158&my_die("Couldn't find input file: $in_wt\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_wt);
    153159&my_die("Couldn't find input file: $in_bg\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_bg) or !$apply_bg;
    154160&my_die("Couldn't find input file: $in_pattern\n", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($in_pattern) or !$apply_pattern;
     
    163169my $out_image = prepare_output("PPBACKGROUND.OUTPUT", $outroot, $class_id, 1);
    164170my $out_mask = prepare_output("PPBACKGROUND.OUTPUT.MASK", $outroot, $class_id, 1);
     171my $out_wt = prepare_output("PPBACKGROUND.OUTPUT.VARIANCE", $outroot, $class_id, 1);
    165172my $out_stats = prepare_output("PPBACKGROUND.STATS", $outroot, $class_id, 1);
    166173my $out_config = prepare_output("PPBACKGROUND.CONFIG", $outroot, $class_id, 1);
    167174my $traceDest = prepare_output("TRACE.IMFILE", $outroot, $class_id, 1);
     175
     176my $auxmask;
     177
     178my $apply_auxiliary_mask = 1;
     179if ($apply_auxiliary_mask) {
     180    my @auxmask_start_date = qw(
     181    0000
     182    5178
     183    5218
     184    5403
     185    5424
     186    5455
     187    5485
     188    5512
     189    5545
     190    5770
     191    5797
     192    5825
     193    5854
     194    5881
     195    6138
     196    6153
     197    6197
     198    6214
     199    );
     200    my @auxmask_end_date = qw(
     201    5177
     202    5217
     203    5402
     204    5423
     205    5454
     206    5484
     207    5511
     208    5544
     209    5769
     210    5796
     211    5824
     212    5853
     213    5880
     214    6137
     215    6152
     216    6196
     217    6213
     218    9999
     219    );
     220
     221    my $outroot_base = basename($outroot);
     222
     223    # Assume that outroot base begins with exp_name: fix by passing in exp_name
     224    my $mjd = substr($outroot_base, 1, 4);
     225    if ($mjd =~ /\D/) {
     226            my $error_code = 1;
     227            &my_die("unexpected outroot base: $outroot_base: $error_code", $chip_bg_id, $class_id, $error_code);
     228    }
     229
     230    my $i = 0;
     231    while ($auxmask_end_date[$i] < $mjd) {
     232        $i++;
     233    }
     234
     235    my $auxmask_base = "/data/ipp064.0/bills/m31-masks/www.usm.uni-muenchen.de/people/arri/PAndromeda/masks_fits/mask";
     236
     237    $auxmask = sprintf "%s_%04d-%04d_%s.fits", $auxmask_base, $auxmask_start_date[$i], $auxmask_end_date[$i], $class_id;
     238    print "Auxililary mask file is $auxmask\n";
     239}
     240   
     241
     242
    168243
    169244# Run ppImage
     
    172247    $command .= " -image $in_image";
    173248    $command .= " -mask $in_mask";
     249    $command .= " -variance $in_wt";
     250    $command .= " -auxmask $auxmask" if $auxmask;
    174251    $command .= " -stats $out_stats" if $do_stats;
    175252    $command .= " -background $in_bg" if $apply_bg;
  • trunk/ippScripts/scripts/background_warp.pl

    r34592 r35118  
    2929my $missing_tools;
    3030my $bgtool = can_run('bgtool') or (warn "Can't find bgtool" and $missing_tools = 1);
     31my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
    3132my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1);
    3233my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     
    3839
    3940my ($warp_bg_id, $skycell_id, $tess_dir, $reduction, $camera, $dbname, $outroot, $threads, $verbose, $no_update, $no_op, $redirect, $save_temps);
    40 my ($astrometry, $imageName, $maskName, $magicked);
     41my ($astrometry, $imageName, $maskName, $weightName, $magicked);
    4142GetOptions(
    4243    'warp_bg_id|i=s'      => \$warp_bg_id, # Warp identifier
     
    117118# Get list of filenames
    118119my $tempOutRoot = "/tmp/background.warp.$warp_bg_id.$skycell_id";
     120
     121# XXX: get this from recipe
     122my $alternate_astrometry_label = 'M31.test.20130206.bgsub';
     123# XXX: get exp_id from command line
     124my $exp_id = 196758;
     125
    119126if (!defined $imageName) {
    120127    # go find our inputs
    121     my ($imageFile, $maskFile);
     128    my $astrom_path_base;
     129    if (defined $alternate_astrometry_label) {
     130        my $command = "$camtool -processedexp -exp_id $exp_id -label $alternate_astrometry_label";
     131        $command .= " -dbname $dbname" if $dbname;
     132        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     133            run(command => $command, verbose => $verbose);
     134        unless ($success) {
     135            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     136            &my_die("Unable to perform camtool -processedexp: $error_code", $warp_bg_id, $error_code);
     137        }
     138        my $entries = $mdcParser->parse_list(join "", @$stdout_buf) or
     139            &my_die("Unable to parse metadata config doc", $warp_bg_id, $PS_EXIT_PROG_ERROR);
     140        my $entry = $entries->[0];
     141        $astrom_path_base = $entry->{path_base};
     142    }
     143
     144    my ($imageFile, $maskFile, $weightFile);
    122145    ($imageFile, $imageName) = tempfile( "$tempOutRoot.image.list.XXXX",  UNLINK => !$save_temps);
    123146    ($maskFile, $maskName) = tempfile( "$tempOutRoot.mask.list.XXXX",   UNLINK => !$save_temps);
     147    ($weightFile, $weightName) = tempfile( "$tempOutRoot.wt.list.XXXX",   UNLINK => !$save_temps);
    124148    my $command = "$bgtool -warpinputs";
    125149    $command .= " -warp_bg_id $warp_bg_id";
     
    139163        my $image = $ipprc->filename("PPBACKGROUND.OUTPUT", $chip_path, $class_id);
    140164        my $mask = $ipprc->filename("PPBACKGROUND.OUTPUT.MASK", $chip_path, $class_id );
     165        my $wt = $ipprc->filename("PPBACKGROUND.OUTPUT.VARIANCE", $chip_path, $class_id );
    141166        print $imageFile "$image\n";
    142167        print $maskFile "$mask\n";
     168        print $weightFile "$wt\n";
    143169        &my_die("Can't find input image: $image", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($image);
    144170        &my_die("Can't find input mask: $mask", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($mask);
     171        &my_die("Can't find input mask: $wt", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($wt);
    145172
    146173        &my_die("Magic status don't match: $magicked vs $file->{magicked}", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) if defined $magicked and $magicked != $file->{magicked};
    147174        $magicked = $file->{magicked};
    148175
    149         my $cam_path = $file->{cam_path_base};
    150         my $astrom = $ipprc->filename($astromSource, $cam_path);
    151         &my_die("Astrometry files don't match: $astrom vs $astrometry", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) if defined $astrometry and $astrom ne $astrometry;
    152         $astrometry = $astrom;
     176        if (!$astrom_path_base) {
     177            my $cam_path = $file->{cam_path_base};
     178            my $astrom = $ipprc->filename($astromSource, $cam_path);
     179            &my_die("Astrometry files don't match: $astrom vs $astrometry", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) if defined $astrometry and $astrom ne $astrometry;
     180            $astrometry = $astrom;
     181        } elsif (!$astrometry) {
     182            # using alternate astrometry
     183            $astrometry = $ipprc->filename($astromSource, $astrom_path_base);
     184        }
    153185    }
    154186    close $imageFile;
    155187    close $maskFile;
     188    close $weightFile;
    156189}
    157190
     
    166199my $out_image = prepare_output("PSWARP.OUTPUT", $outroot, $skycell_id,  1);
    167200my $out_mask = prepare_output("PSWARP.OUTPUT.MASK", $outroot, $skycell_id, 1);
     201my $out_wt = prepare_output("PSWARP.OUTPUT.VARIANCE", $outroot, $skycell_id, 1);
    168202my $out_stats = prepare_output("SKYCELL.STATS", $outroot, $skycell_id, 1);
    169203my $out_config = prepare_output("PSWARP.CONFIG", $outroot, $skycell_id, 1);
     
    179213    $command .= " -list $imageName";
    180214    $command .= " -masklist $maskName";
     215    $command .= " -variancelist $weightName";
    181216    $command .= " -astrom $astrometry";
    182217    $command .= " $outroot $skyFile";
     
    220255        &my_die("Couldn't find expected output file: $out_image", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_image);
    221256        &my_die("Couldn't find expected output file: $out_mask", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_mask);
     257        &my_die("Couldn't find expected output file: $out_wt", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_wt);
    222258        &my_die("Couldn't find expected output file: $out_config", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_config);
    223259    }
Note: See TracChangeset for help on using the changeset viewer.