IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33383


Ignore:
Timestamp:
Feb 28, 2012, 1:49:45 PM (14 years ago)
Author:
bills
Message:

Add an option to the postage stamp request format to produce a
JPEG image of the postage stamp

Location:
tags/ipp-20120216
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20120216/PS-IPP-PStamp

  • tags/ipp-20120216/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r33249 r33383  
    850850    {
    851851        my $command = "$whichimage $ra $dec";
     852        $command .= " --tess_id $requested_tess_id" if $requested_tess_id;
    852853        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    853854                    run(command => $command, verbose => $verbose);
  • tags/ipp-20120216/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r32635 r33383  
    2727                    $PSTAMP_SELECT_PSF
    2828                    $PSTAMP_SELECT_BACKMDL
     29                    $PSTAMP_SELECT_JPEG
    2930                    $PSTAMP_SELECT_INVERSE
    3031                    $PSTAMP_SELECT_UNCONV
     
    6465our $PSTAMP_SELECT_PSF       = 16;
    6566our $PSTAMP_SELECT_BACKMDL   = 32;
     67our $PSTAMP_SELECT_JPEG      = 64;
    6668our $PSTAMP_SELECT_INVERSE   = 1024;
    6769our $PSTAMP_SELECT_UNCONV    = 2048;
  • tags/ipp-20120216/ippconfig/recipes/filerules-mef.mdc

    r32950 r33383  
    311311PPSTAMP.OUTPUT.MASK     OUTPUT {OUTPUT}.mk.fits                  MASK      COMP_MASK  FPA        TRUE      NONE
    312312PPSTAMP.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits                  VARIANCE  COMP_WT    FPA        TRUE      NONE
     313PPSTAMP.OUTPUT.JPEG     OUTPUT {OUTPUT}.jpg                      JPEG      NONE       FPA        TRUE      NONE
     314PPSTAMP.OUTPUT.JPEG.FLIP OUTPUT {OUTPUT}.jpg                     JPEG      NONE       FPA        TRUE      NONE
    313315PPSTAMP.CHIP.MEF        OUTPUT {OUTPUT}.ch.fits                  IMAGE     NONE       CHIP       FALSE     MEF
    314316                                                                                     
  • tags/ipp-20120216/ippconfig/recipes/filerules-simple.mdc

    r32751 r33383  
    291291PPSTAMP.OUTPUT.MASK          OUTPUT {OUTPUT}.mk.fits              MASK            COMP_MASK  FPA        TRUE      NONE
    292292PPSTAMP.OUTPUT.VARIANCE      OUTPUT {OUTPUT}.wt.fits              VARIANCE        COMP_WT    FPA        TRUE      NONE
     293PPSTAMP.OUTPUT.JPEG          OUTPUT {OUTPUT}.jpg                  JPEG            NONE       FPA        TRUE      NONE
     294PPSTAMP.OUTPUT.JPEG.FLIP     OUTPUT {OUTPUT}.jpg                  JPEG            NONE       FPA        TRUE      NONE
    293295PPSTAMP.CHIP                 OUTPUT {OUTPUT}.ch.fits              IMAGE           NONE       CHIP       FALSE     NONE
    294296                                                     
  • tags/ipp-20120216/ippconfig/recipes/filerules-split.mdc

    r32950 r33383  
    322322PPSTAMP.OUTPUT.MASK          OUTPUT {OUTPUT}.mk.fits                  MASK            COMP_MASK  FPA        TRUE      NONE
    323323PPSTAMP.OUTPUT.VARIANCE      OUTPUT {OUTPUT}.wt.fits                  VARIANCE        COMP_WT    FPA        TRUE      NONE
     324PPSTAMP.OUTPUT.JPEG         OUTPUT {OUTPUT}.jpg                      JPEG            NONE       FPA        TRUE      NONE
     325PPSTAMP.OUTPUT.JPEG.FLIP    OUTPUT {OUTPUT}.jpg                      JPEG            NONE       FPA        TRUE      NONE
    324326# mosaic image used for making stamps of raw images. Not saved.
    325327PPSTAMP.CHIP                 OUTPUT {OUTPUT}.ch.fits                  IMAGE           NONE       CHIP       FALSE     MEF
    326 PPSTAMP.OUTPUT.JPEG1         OUTPUT {OUTPUT}.jpg                      JPEG            NONE       FPA        TRUE      NONE
    327328                                                                                                             
    328329PPSIM.OUTPUT                 OUTPUT {OUTPUT}.{CHIP.NAME}.fits         IMAGE           NONE       CHIP       TRUE      SPLIT
  • tags/ipp-20120216/ippconfig/recipes/jpeg.mdc

    r29554 r33383  
    254254END
    255255
     256PPSTAMP.OUTPUT.JPEG             METADATA
     257        COLORMAP        STR     greyscale
     258        SCALE.MODE      STR     RANGE
     259        SCALE.MIN       F32      -5.0
     260        SCALE.MAX       F32     +10.0
     261        OPTIONS         STR     -SB,+X,+Y
     262END
     263
     264PPSTAMP.OUTPUT.JPEG.FLIP        METADATA
     265        COLORMAP        STR     greyscale
     266        SCALE.MODE      STR     RANGE
     267        SCALE.MIN       F32      -5.0
     268        SCALE.MAX       F32     +10.0
     269        OPTIONS         STR     -SB,-X,+Y
     270END
  • tags/ipp-20120216/pstamp

  • tags/ipp-20120216/pstamp/scripts/dqueryparse.pl

    r33342 r33383  
    1717use Pod::Usage qw( pod2usage );
    1818use File::Temp qw( tempfile tempdir);
     19use POSIX;  # for strftime
    1920
    2021use PS::IPP::PStamp::RequestFile qw( :standard );
     
    9899my_die("$request_file is version $extver expecting 1 or 2", $PS_EXIT_PROG_ERROR)
    99100    if ($extver ne 1) and ($extver ne 2);
     101
     102if ($req_id) {
     103    my $command = "$pstamptool -listreq  -name $req_name -not_req_id $req_id";
     104    # set verbose to false so that error message about request not found doesn't appear in parse_error.txt
     105    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     106        run(command => $command, verbose => 0);
     107    if ($success) {
     108        # -listreq succeeded duplicate request name
     109        print STDERR "QUERY_ID $req_name has already been used\n";
     110        $command = "$pstamptool -addjob -job_type none -rownum 0 -state stop -fault $PSTAMP_DUP_REQUEST -req_id $req_id";
     111        unless ($no_update) {
     112            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     113                run(command => $command, verbose => $verbose);
     114            if (!$success) {
     115                my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     116            }
     117        } else {
     118            print STDERR "skipping $command\n";
     119        }
     120       
     121        my $datestr = strftime "%Y%m%d%H%M%S.$req_id", gmtime;
     122        $req_name = "ERROR.$datestr";
     123    }
     124    $command = "$pstamptool -updatereq -req_id $req_id  -set_name $req_name -set_outProduct $product";
     125    unless ($no_update) {
     126        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     127            run(command => $command, verbose => $verbose);
     128        unless ($success) {
     129            my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     130        }
     131    } else {
     132        print STDERR "skipping $command\n";
     133    }
     134    exit (0);
     135}
     136
    100137
    101138
     
    357394            my $component = $query{$fpa_id}{COMPONENT_ID}[$i];
    358395            print "Need to UPDATE $stage $stage_id $component from $data_state\n";
    359     ####                           my ($req_id, $outdir, $label, $state, $stage, $stage_id, $component, $need_magic, $imagedb) = @_;
    360396            $dep_id = queue_update_run($req_id, $outdir, $label, $data_state, $stage, $stage_id, $component, 0, $imagedb);
    361397        }
     
    413449}
    414450
    415 # XXX: flesh this out once we have a request without duplicate ROWNUMS
    416451foreach my $rownum (keys %faulted_rows ) {
     452    my $outputBase = "$outdir/$job_num" . "_";
    417453    my $fault = $faulted_rows{$rownum};
    418454    $fault = $PSTAMP_NO_IMAGE_MATCH if ($fault eq 'no_fault');
    419455    print STDERR "insert faulted job for $rownum: $fault\n";
     456    my $command = "$pstamptool -addjob -req_id $req_id -outputBase $outputBase -job_type detect_query -state stop -rownum $rownum -fault $fault";
     457    unless ($no_update) {
     458        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     459            run(command => $command, verbose => $verbose);
     460        if ($success) {
     461            my $job_id = join "", @$stdout_buf;
     462            print "   Queued job: $job_id\n";
     463        } else {
     464            my $exit_status = $error_code >> 8;
     465            $exit_status = $PS_EXIT_UNKNOWN_ERROR unless $exit_status;
     466            my_die("Unable to perform $command error code: $error_code", $exit_status);
     467        }
     468    } else {
     469        print STDERR "skipping $command\n";
     470    }
     471    $job_num++;
    420472}
    421473
  • tags/ipp-20120216/pstamp/scripts/pstamp_job_run.pl

    r33342 r33383  
    225225
    226226    my $command = "$ppstamp $outputBase $argString $fileArgs";
     227    $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG);
    227228    $command .= " -dbname $dbname" if $dbname;
    228229    $command .= " -dbserver $dbserver" if $dbserver;
     
    249250
    250251        # Note: we are assuming the contents of the PSTAMP filerules here.
    251         my %extensions = ( $PSTAMP_SELECT_IMAGE  => "fits",
    252                            $PSTAMP_SELECT_MASK   => "mk.fits",
    253                            $PSTAMP_SELECT_VARIANCE => "wt.fits");
    254 
    255         my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE);
     252        my %extensions = ( $PSTAMP_SELECT_IMAGE    => "fits",
     253                           $PSTAMP_SELECT_MASK     => "mk.fits",
     254                           $PSTAMP_SELECT_VARIANCE => "wt.fits",
     255                           $PSTAMP_SELECT_JPEG     => "jpg");
     256
     257        my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE | $PSTAMP_SELECT_JPEG);
    256258
    257259        foreach my $key (keys (%extensions)) {
  • tags/ipp-20120216/pstamp/src/ppstampArguments.c

    r29885 r33383  
    2121    fprintf(stderr, "\n");
    2222    fprintf(stderr, "Optional arguments:\n");
    23     fprintf(stderr, "   [-class_id class_id]     selects class_id (only used with -pixcenter)\n");
    24     fprintf(stderr, "   [-astrom astrom.cmp] :   provide an alternative astrometry calibration\n");
    25     fprintf(stderr, "   [-mask   mk_image] :     mask image\n");
    26     fprintf(stderr, "   [-variance var_image] :  variance image\n");
    27     fprintf(stderr, "   [-no_censor_masked] : do not set masked pixels to NAN\n");
     23    fprintf(stderr, "   [-class_id class_id]  : selects class_id (only used with -pixcenter)\n");
     24    fprintf(stderr, "   [-astrom astrom.cmp]  : provide an alternative astrometry calibration\n");
     25    fprintf(stderr, "   [-mask   mk_image]    : mask image\n");
     26    fprintf(stderr, "   [-variance var_image] : variance image\n");
     27    fprintf(stderr, "   [-stage stage]        : stage of input image (raw, chip, warp, stack, diff)\n");
     28    fprintf(stderr, "   [-write_jpeg]         : write a JPEG  format of the image stamp\n");
     29    // fprintf(stderr, "   [-no_censor_masked]   : do not set masked pixels to NAN\n");
    2830    fprintf(stderr, "\n");
    2931
     
    8486        psArgumentRemove(argnum, &argc, argv);
    8587    }
     88    if ((argnum = psArgumentGet(argc, argv, "-write_jpeg"))) {
     89        psArgumentRemove(argnum, &argc, argv);
     90        options->writeJPEG = true;
     91    } else {
     92        options->writeJPEG = false;
     93    }
    8694
    8795    pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist");
  • tags/ipp-20120216/pstamp/src/ppstampOptions.h

    r29885 r33383  
    1616    psRegion    roi;            // roi in chip coordinates
    1717    bool        censorMasked;
    18 
     18    bool        writeJPEG;
    1919} ppstampOptions;
    2020
  • tags/ipp-20120216/pstamp/src/ppstampParseCamera.c

    r29379 r33383  
    88
    99// Set up the ppstamp output Image file
    10 bool setupOutput(pmConfig *config, pmFPAfile *input, psString stage, bool doMask, bool doWeight)
     10bool setupOutput(pmConfig *config, pmFPAfile *input, psString stage, bool doMask, bool doWeight, pmFPAfile **pOutput)
    1111{
    1212    pmFPAfile *output;
     
    2222        return false;
    2323    }
     24    *pOutput = output;
    2425
    2526    output->save = true;
     
    3334        outWeight->save = true;
    3435    }
     36
    3537
    3638    return true;
     
    7678       
    7779
    78 
    7980    // XXX: create a filerule for PPSTAMP.ASTROM
    8081    pmFPAfile *astrom = pmFPAfileDefineFromArgs(&status, config, "PSWARP.ASTROM", "ASTROM");
     
    9596
    9697    // Set up the output target
    97     if (!setupOutput(config, input, options->stage, doMask, doWeight)) {
     98    pmFPAfile *output;
     99    if (!setupOutput(config, input, options->stage, doMask, doWeight, &output)) {
    98100        psError(PS_ERR_UNKNOWN, false, "Unable to setup output.");
    99101        return false;
    100102    }
    101103
    102     pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPSTAMP.CHIP");
     104    pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, output->fpa, "PPSTAMP.CHIP");
    103105    if (!chipImage) {
    104106        psError(PS_ERR_IO, false, _("Unable to generate new file from PPSTAMP.CHIP"));
     
    108110        psError(PS_ERR_IO, true, "PPSTAMP.CHIP is not of type IMAGE");
    109111        return NULL;
     112    }
     113
     114    if (options->writeJPEG) {
     115        char *filerule;
     116        // If stage is chip flip the X axis otherwise don't flip.
     117        // XXX: is this the right thing to do?
     118        // Shouldn't the JPEG match the stamp even for chip stage?
     119        if (!options->stage || strcmp(options->stage, "chip")) {
     120            filerule = "PPSTAMP.OUTPUT.JPEG";
     121        } else {
     122            filerule = "PPSTAMP.OUTPUT.JPEG.FLIP";
     123        }
     124        pmFPAfile *jpg = pmFPAfileDefineOutput(config, output->fpa, filerule);
     125        if (!jpg) {
     126            psError(PS_ERR_IO, false, "Unable to generate new file from %s", filerule);
     127            return NULL;
     128        }
     129        if (jpg->type != PM_FPA_FILE_JPEG) {
     130            psError(PS_ERR_IO, true, "%s is not of type JPEG", filerule);
     131            return NULL;
     132        }
     133        jpg->save = true;
    110134    }
    111135
Note: See TracChangeset for help on using the changeset viewer.