IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33521 for trunk


Ignore:
Timestamp:
Mar 14, 2012, 8:20:30 AM (14 years ago)
Author:
bills
Message:

added option --deasin which uses ppstamp -wholefile to read the input stacks
and write the file to either a temporary file or a user specified output directory.
The resulting image does not have the ASIN scaling so the pixels are representitive
of what psphot is analyzing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/dlapstacks

    r33438 r33521  
    2020use DBI;
    2121use PS::IPP::Config 1.01 qw( :standard );
     22use File::Temp qw( tempfile tempdir );
     23use File::Basename;
     24use IPC::Cmd 0.36 qw( can_run run );
     25
    2226
    2327my $ipprc = PS::IPP::Config->new();
     
    2529
    2630my ($requested_filter, $no_display, $skycell_id, $verbose, $ra, $dec, $convolved);
    27 my ($singleframe);
     31my ($singleframe, $fitToFrame, $deasin, $save_temps);
     32
     33my $temproot = '/local/ipp/tmp';
     34my $outdir;
     35
    2836
    2937GetOptions(
    3038    'filter|f=s'    => \$requested_filter,  # restrict to a single filter
    31     'skycell_id=s'  => \$skycell_id,        # don't bother with
    32     'convolved'     => \$convolved,         # display convolved stack images instead of unconvolved
    33     'label=s'       => \$label,             # use a different label (careful!)
    34     'tess_id=s'     => \$tess_id,           #
     39    'skycell_id|s=s'=> \$skycell_id,        # don't bother with
     40    'convolved|c'   => \$convolved,         # display convolved stack images instead of unconvolved
     41    'fit'           => \$fitToFrame,
     42    'deasin|d'      => \$deasin,
     43    'label|l=s'     => \$label,             # use a different label (careful!)
     44    'tess_id|t=s'   => \$tess_id,           #
     45    'outdir|o=s'    => \$outdir,
    3546    'no-display|n'  => \$no_display,        # don't run ds9 just print the filenames
    3647    'single'        => \$singleframe,
     48    'save-temps'    => \$save_temps,
    3749    'verbose|v'     => \$verbose,
    3850) or pod2usage( 2 );
     
    4658pod2usage( -msg => 'if ra is suplied <dec> must be supplied as well', -exitval => 2)
    4759    if (defined $ra and ! defined $dec);
     60
     61my $missing_tools;
     62my $ppstamp;
     63if ($deasin) {
     64    $ppstamp = can_run('ppstamp') or (warn "Can't find ppstamp") and $missing_tools = 1;
     65}
     66if ($missing_tools) {
     67    # warn("Can't find required tools.");
     68    exit($PS_EXIT_CONFIG_ERROR);
     69}
    4870
    4971my $extension;
     
    154176        $imagesize = 680;
    155177    }
     178    if ($deasin) {
     179        if ($outdir) {
     180            print "Saving deasined files to $outdir\n";
     181            # user specified output directory save the files there
     182            if (!-d $outdir) {
     183                mkdir $outdir or die "failed to mkdir $outdir\n";
     184            }
     185        } else {
     186            # otherwise use a temporary directory
     187            $outdir = tempdir ("$temproot/dlapstacks.temp.XXXX", CLEANUP => !$save_temps);
     188            print "deasined files will be saved to $outdir\n" if $save_temps;
     189        }
     190    }
    156191    # Build the ds9 argument list
    157192    my @args;
     
    159194    foreach my $f (@files) {
    160195        next if ! $f;
    161         my $filename = $f->{path_base} . ".$extension";
    162         my $resolved = $ipprc->file_resolve($filename);
    163         next if !$resolved;
     196        my $pathname = $f->{path_base} . ".$extension";
     197        my $filename = $ipprc->file_resolve($pathname);
     198        next if !$filename;
     199        # run ppstamp to undo the asin scaling. The output from ppstamp is linear F32 images
     200        if ($deasin) {
     201            my $base = basename($pathname);
     202            my $destbase = $base;
     203
     204            # drop the .fits for the output path for ppstamp
     205            $destbase =~ s/\.fits//g;
     206
     207            my $command = "$ppstamp -wholefile -file $filename $outdir/$destbase";
     208            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     209                run(command => $command, verbose => $verbose);
     210            unless ($success) {
     211                print STDERR join "", @$stderr_buf;
     212                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     213                die("Unable to perform ppstamp: $error_code\n");
     214            }
     215
     216            # new filename for ds9
     217            $filename = "$outdir/$base";
     218        }
    164219
    165220        if ($f->{X} > 0) {
     
    184239        # loaded. pan thatone and then matching the wcs for the frames.
    185240        # Also that allows V0 and V3 skycells to have east to the left orientation
    186         # push @args, ($resolved, $panargs);
    187         push @args, $resolved;
     241        # push @args, ($filename, $panargs);
     242        push @args, $filename;
    188243    }
    189244    my $ds9cmd = "ds9 -geom 1024x1024 @args $panargs";
    190245    $ds9cmd .= " -single" if $singleframe;
     246    $ds9cmd .= " -zoom to fit" if $fitToFrame;
    191247    $ds9cmd .= " -match frames wcs";
     248    $ds9cmd .= " -frame first" if $singleframe;
    192249    print "$ds9cmd\n" if $verbose;
    193250    system $ds9cmd;
Note: See TracChangeset for help on using the changeset viewer.