IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2007, 2:46:23 PM (19 years ago)
Author:
Paul Price
Message:

Getting simulated tests running through to warping.

File:
1 edited

Legend:

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

    r13085 r13112  
    9191}
    9292
    93 # determine the imfile/skycell overlaps
     93# Set output directory
     94if (defined $workdir) {
     95    $workdir = $ipprc->convert_filename_absolute( $workdir );
     96} else {
     97    my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
     98    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
     99    $workdir = $dir;
     100}
     101system "mkdir -p $workdir" unless -d $workdir;
     102
     103
     104# Determine the imfile/skycell overlaps
    94105my @overlaps = ();
    95106
    96107unless ($no_op) {
    97     ## Calculate the overlaps between imfiles and skycells
    98 
    99     # the tess_id is the catdir used to define the tessalation
     108    # Calculate the overlaps between imfiles and skycells
     109
     110    # The tess_id is the catdir used to define the tessalation
    100111    my $command = "ppConfigDump -camera $camera -dump-recipe PSWARP -";
    101112    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    107118    my $parser = PS::IPP::Metadata::Config->new;        # Parser for metadata config files
    108119    my $recipe = $parser->parse( join '', @$stdout_buf);
    109     my $tess_id = metadataLookupStr($recipe, 'DVO.TESSALATION');
    110     print STDERR "tessalation: $tess_id\n";
    111 
    112     # we have two options for the astrometry file:
    113     # - saved by chiptool, in which case there may be a different one for each imfile
    114     # - saved by camtool, in which case there may only be a single astrom file
    115     my $psastroFile;
    116 
    117     # XXX select this value from the recipe files (psastro? maybe not...?)
    118     my $camAstrom = 1;
    119     if ($camAstrom) {
     120    my @tesselations = split(/\s+/, metadataLookupStr($recipe, 'DVO.TESSALATION')); # List of tesselations
     121    foreach my $tess_id ( @tesselations ) {
     122        print STDERR "tessalation: $tess_id\n";
     123
    120124        my $imfile = $imfiles->[0];
    121125        my $camRoot = $ipprc->convert_filename_absolute( $imfile->{cam_path_base} );
    122         $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output
    123 
     126        my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output
     127       
    124128        my @dirlist = File::Spec->splitdir( $psastroFile );
    125129        my $psastroRootFile = pop @dirlist;
    126130        print STDERR "psastroRootFile: $psastroRootFile\n";
    127 
     131       
    128132        # run the dvoImageOverlaps program to get the overlaps with this image
    129133        my $command = "dvoImageOverlaps -D CATDIR $tess_id $psastroFile";
     
    135139        }
    136140        my @matchlist = split ('\n', (join "", @$stdout_buf));
    137 
    138         #my $Nmatch = @matchlist;
    139         #print STDERR "Nmatch: $Nmatch\n";
    140         #foreach my $line (@matchlist) {
    141         #    print STDERR "line: $line\n";
    142         #}
    143 
    144         # dvoImageOverlaps -D CATDIR tessalation (megacam) :: returns:
     141       
     142        # The command "dvoImageOverlaps -D CATDIR tessalation (megacam)" returns:
    145143        # 729534pa.cmf[ccd00.hdr]  :  skycell.051.fits
    146144        # PSASTRO.OUTPUT[CMF.HEAD] : SKYCELL
    147145        # [CMF.HEAD] is optionally used for MEF files (SIMPLE or MOSAIC)
    148 
     146       
    149147        # now match the imfiles to this list
    150148        my @unique_skycells = ();
     
    159157               
    160158                print STDERR "class: $class_id, chiproot: $chipRoot, extname: $extname\n";
    161 
     159               
    162160                $entry = "$psastroRootFile\[$extname\]";
    163161            } else {
     
    173171                $overlap{fault}      = $imfile->{fault};
    174172                push @overlaps, \%overlap;
    175 
     173               
    176174                printf STDERR "overlap: %s : %s\n", $skycell, $imfile->{cam_id};
    177 
     175               
    178176                # generate a unique list of the skycells
    179177                unless ($found_skycells{$skycell}) {
     
    184182        }
    185183
    186         # extract the skycells to names of the form $camRoot.skycell...
    187         # with calls to dvoImageExtract
    188         my $skycellDir = "$camRoot/skycells";
    189         system "mkdir -p $skycellDir" unless -d $skycellDir;
    190 
    191         foreach my $skycell (@unique_skycells) {
    192             vsystem ("dvoImageExtract -D CATDIR $tess_id $skycell -o $skycellDir/$skycell");
    193         }
    194 
    195     } else {
    196         foreach my $imfile (@$imfiles) {
    197             my $class_id = $imfile->{class_id};
    198             my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} );
    199             my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $chipRoot, $class_id); # SPLIT psastro output
    200 
    201             # run the dvoImageOverlaps program to get the overlaps with this image
    202             my $command = "dvoImageOverlaps -D CATDIR $tess_id $psastroFile";
     184        # Extract the skycells to images, used as warp templates.
     185        foreach my $skycell_id (@unique_skycells) {
     186            my $skyDir = File::Spec->catdir($workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
     187            system "mkdir -p $skyDir" unless -d $skyDir;
     188            my $skyFile = File::Spec->catfile( $skyDir , $skycell_id );
     189            my $command = "dvoImageExtract -D CATDIR $tess_id $skycell_id -o $skyFile";
    203190            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    204191                run(command => $command, verbose => 1);
    205192            unless ($success) {
    206193                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    207                 &my_die("Unable to perform dvoImageOverlaps: $error_code", $warp_id, $error_code);
    208             }
    209             my @matchlist = split ('\n', $stdout_buf);
    210 
    211             # dvoImageOverlaps -D CATDIR tessalation (megacam) :: returns:
    212             # 729534pa.ccd00.cmf  :  skycell.051.fits
    213             # 729534pa.ccd00.cmf  :  skycell.052.fits
    214             # PSASTRO.OUTPUT : SKYCELL
    215 
    216             # now match the imfiles to this list
    217             my @skycells = &select_skycells ($psastroFile, @matchlist);
    218             # XXX should I check and warn if int(@skycells) != int(@matchlist) ?
    219             foreach my $skycell (@skycells) {
    220                 my %overlap = ();
    221                 $overlap{skycell_id} = $skycell;
    222                 $overlap{tess_id}    = $tess_id;
    223                 $overlap{cam_id}     = $imfile->{cam_id};
    224                 $overlap{class_id}   = $imfile->{class_id};
    225                 $overlap{fault}      = $imfile->{fault};
    226                 push @overlaps, \%overlap;
    227 
    228                 print STDERR "overlap: $skycell -> $imfile->{cam_id}\n";
     194                &my_die("Unable to perform dvoImageExtract: $error_code", $warp_id, $error_code);
    229195            }
    230196        }
     
    243209}
    244210
    245 if (defined $workdir) {
    246     $workdir = $ipprc->convert_filename_absolute( $workdir );
    247     $workdir = File::Spec->catdir( $workdir, $exp_tag );
    248 } else {
    249     my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
    250     my ($vol, $dir, $file) = File::Spec->splitpath( $example );
    251     $workdir = $dir;
    252 }
    253 system "mkdir -p $workdir" unless -d $workdir;
    254 
    255211# Generate a MDC file with the overlaps
    256 my $overlapName = File::Spec->catfile( $workdir, 'overlap.mdc' );
     212my $overlapName = File::Spec->catfile( $workdir, 'overlaps.wrp' . $warp_id . '.mdc' );
    257213open my $overlapFile, "> $overlapName" or die "Unable to open mdc file $overlapName";
    258214print $overlapFile "warpSkyCellMap MULTI\n\n";
     
    314270}
    315271
    316 sub vsystem {
    317     print STDERR "@_\n";
    318     my $status = system ("@_");
    319     $status;
    320 }
    321 
    322272END {
    323273    my $status = $?;
Note: See TracChangeset for help on using the changeset viewer.