IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25212


Ignore:
Timestamp:
Aug 26, 2009, 6:31:31 PM (17 years ago)
Author:
watersc1
Message:

merging trunk into czw_branch

Location:
branches/czw_branch/cleanup
Files:
22 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup

  • branches/czw_branch/cleanup/Ohana/src/getstar/include/dvoImagesAtCoords.h

    r24951 r25212  
    1818Coords *MOSAIC;         // carries the mosaic into ReadImageHeader
    1919
     20typedef struct {
     21    int     id;
     22    double  ra;
     23    double  dec;
     24    int     Nmatches;
     25    int     *matches;
     26    int     arrayLength;
     27} Point;
     28
    2029int WITH_PHU;
    2130int SOLO_PHU;
     
    3342Image *ReadImageFiles (char *filename, int *Nimages);
    3443int ReadImageHeader (Header *header, Image *image);
    35 int *MatchCoords(Image *, int, double, double, int *);
     44int MatchCoords(Image *, int, Point *, int);
    3645
    3746int GetFileMode (Header *header);
    38 // int edge_check (double *x1, double *y1, double *x2, double *y2);
    39 // double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3);
  • branches/czw_branch/cleanup/Ohana/src/getstar/src/MatchCoords.c

    r25152 r25212  
    55
    66/* given coordinate, find images in list that contain the point */
    7 int *MatchCoords (Image *dbImages, int NdbImages, double ra, double dec, int *Nmatch) {
     7int MatchCoords (Image *dbImages, int NdbImages, Point *points, int Npoints) {
    88 
    9   int i, j, N, addtolist, status;
    10   int NMATCH, nmatch, *match;
     9  int i, j, N;
     10  int totalMatches = 0;
    1111  Coords tcoords;
    1212  double r, d;
     
    1515  double xmin, xmax, ymin, ymax;
    1616
    17   *Nmatch = 0;
    18 
    19   /* match represents the subset of overlapping images */
    20   nmatch = 0;
    21   NMATCH = 20;
    22   ALLOCATE (match, int, NMATCH);
    2317
    2418  /* setup links for mosaic WRP and DIS entries */
     
    4943    }
    5044
    51     // transform input point to image coords
    52     double x, y;
    53     int status = RD_to_XY(&x, &y, ra, dec, &dbImages[i].coords);
     45    for (j = 0; j < Npoints; j++) {
     46        Point *pt = points + j;
    5447
    55     if (!status) {
    56         // avoid matching antipodal skycells
    57         continue;
    58     }
     48        // transform input point to image coords
     49        double x, y;
     50        int status = RD_to_XY(&x, &y, pt->ra, pt->dec, &dbImages[i].coords);
    5951
    60     if ((x >= xmin && x <= xmax) && (y >= ymin && y <= ymax)) {
     52        if (!status) {
     53            // avoid matching antipodal skycells
     54            continue;
     55        }
    6156
    62         match[nmatch] = i;
    63         nmatch ++;
    64         if (nmatch == NMATCH) {
    65           NMATCH += 20;
    66           REALLOCATE (match, int, NMATCH);
     57        if ((x >= xmin && x <= xmax) && (y >= ymin && y <= ymax)) {
     58            totalMatches++;
     59
     60            pt->matches[pt->Nmatches] = i;
     61            pt->Nmatches ++;
     62
     63            if (pt->Nmatches == pt->arrayLength) {
     64                pt->arrayLength += 20;
     65                REALLOCATE (pt->matches, int, pt->arrayLength);
     66            }
    6767        }
    6868    }
    69      
    70   }
    71   if (VERBOSE) fprintf (stderr, "found %d overlapping images\n", nmatch);
     69 }
     70 if (VERBOSE) fprintf (stderr, "found %d overlapping images\n", totalMatches);
    7271 
    73   *Nmatch = nmatch;
    74   return (match);
     72 return (totalMatches);
    7573}
    7674 
  • branches/czw_branch/cleanup/Ohana/src/getstar/src/dvoImagesAtCoords.c

    r24951 r25212  
    11# include "dvoImagesAtCoords.h"
    22
    3 typedef struct {
    4     int     id;
    5     double  ra;
    6     double  dec;
    7 } Point;
    8 
    93static int readPoints(char *filename, Point **pointsOut);
    10 static int ListImagesAtCoords (Image *dbImages, int id, double ra, double dec, int *matches, int Nmatches);
     4static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints);
    115
    126int main (int argc, char **argv) {
     
    3024  if (astromFile) {
    3125      dbImages = ReadImageFiles(astromFile, &NdbImages);
    32     } else {
     26  } else {
    3327    /*** update the image table ***/
    3428    /* setup image table format and lock */
     
    5347  }
    5448 
    55   Point *pt;
    56   for (i = 0, pt = points; i < Npoints; i++, pt++) {
    57     matches = MatchCoords (dbImages, NdbImages, pt->ra, pt->dec, &Nmatches);
    58     ListImagesAtCoords(dbImages, pt->id, pt->ra, pt->dec, matches, Nmatches);
     49  if (MatchCoords (dbImages, NdbImages, points, Npoints)) {
     50    ListImagesAtCoords(dbImages, points, Npoints);
    5951  }
    60 
     52  // XXX: should we exit with nonzero status if no matches were found?
    6153  exit (0);
    6254}
     
    8375
    8476    while ((Nread = fscanf(f, "%d %lf %lf\n", &pts[Npoints].id, &pts[Npoints].ra, &pts[Npoints].dec)) == 3) {
    85         Npoints++;
    86         if (Npoints >= LEN) {
     77        pts[Npoints].Nmatches = 0;
     78        ALLOCATE(pts[Npoints].matches, int, 20);
     79        pts[Npoints].arrayLength = 20;
     80
     81        if (++Npoints >= LEN) {
    8782            LEN += 20;
    8883            REALLOCATE(pts, Point, LEN);
     
    9994}
    10095
    101 static int ListImagesAtCoords (Image *dbImages, int id, double ra, double dec, int *matches, int Nmatches)
     96static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints)
    10297{
     98  int j;
    10399  int i;
    104   for (i = 0; i < Nmatches; i++) {
    105     int N = matches[i];
     100  for (j = 0; j < Npoints; j++) {
     101      Point *pt = points + j;
     102      for (i = 0; i < pt->Nmatches; i++) {
     103        int N = pt->matches[i];
    106104
    107     char *name;
    108     // output of lookup is filename[class_id.hdr] for astrometry files
    109     char *left_bracket = rindex(dbImages[N].name, '[');
    110     if (left_bracket) {
    111         name = strdup(left_bracket + 1);
    112         // zap the .hdr]
    113         char *dot = index(name, '.');
    114         if (dot) {
    115             *dot = 0;
     105        char *name;
     106        char *copy = NULL;
     107        // output of lookup is filename[class_id.hdr] for astrometry files
     108        char *left_bracket = rindex(dbImages[N].name, '[');
     109        if (left_bracket) {
     110            copy = strdup(left_bracket + 1);
     111            name = copy;
     112            // zap the .hdr]
     113            char *dot = index(name, '.');
     114            if (dot) {
     115                *dot = 0;
     116            }
     117        } else {
     118            name = dbImages[N].name;
    116119        }
    117     } else {
    118         name = dbImages[N].name;
     120        fprintf (stdout, "%d %lf %lf %s\n", pt->id, pt->ra, pt->dec, name);
     121        if  (copy) {
     122            free(copy);
     123        }
    119124    }
    120     fprintf (stdout, "%d %lf %lf %s\n", id, ra, dec, name);
    121125  }
    122126 
  • branches/czw_branch/cleanup/doc/misc/docgen.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/czw_branch/cleanup/ippScripts/scripts/ipp_image_path.pl

    r22429 r25212  
    108108            # remove the leading "file://" if present
    109109            $path =~ s/^file\:\/\///;
     110            $nfiles++;
     111            print "$path\n";
    110112        }
    111         $nfiles++;
    112         print "$path\n";
    113113    }
    114114    if (!$nfiles) {
  • branches/czw_branch/cleanup/ippScripts/scripts/magic_destreak_revert.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/czw_branch/cleanup/ippTools/share/Makefile.am

    r25158 r25212  
    184184     pstamptool_pendingreq.sql \
    185185     pstamptool_project.sql \
     186     pstamptool_revertjob.sql \
     187     pstamptool_revertreq.sql \
     188     pstamptool_revertreq_deletejobs.sql \
    186189     pxadmin_create_tables.sql \
    187190     pxadmin_create_mirror_tables.sql \
  • branches/czw_branch/cleanup/ippTools/share/pstamptool_pendingjob.sql

    r25149 r25212  
    1 SELECT *
    2  FROM pstampJob
    3  WHERE state = 'run'
    4     AND fault = 0
     1SELECT pstampJob.*
     2FROM pstampJob
     3    JOIN pstampRequest using(req_id)
     4WHERE pstampRequest.state = 'run'
     5    AND pstampRequest.fault = 0
     6    AND pstampJob.state = 'run'
     7    AND pstampJob.fault = 0
  • branches/czw_branch/cleanup/ippTools/share/pstamptool_pendingreq.sql

    r21413 r25212  
    77    USING(ds_id)
    88 WHERE pstampRequest.state = 'new'
     9    AND pstampRequest.fault = 0
  • branches/czw_branch/cleanup/ippTools/src/pstamptool.c

    r25158 r25212  
    4444static bool pendingjobMode(pxConfig *config);
    4545static bool updatejobMode(pxConfig *config);
     46static bool revertjobMode(pxConfig *config);
    4647static bool addprojectMode(pxConfig *config);
    4748static bool projectMode(pxConfig *config);
     
    8081        MODECASE(PSTAMPTOOL_MODE_PENDINGJOB, pendingjobMode);
    8182        MODECASE(PSTAMPTOOL_MODE_UPDATEJOB, updatejobMode);
     83        MODECASE(PSTAMPTOOL_MODE_REVERTJOB, revertjobMode);
    8284        MODECASE(PSTAMPTOOL_MODE_ADDPROJECT, addprojectMode);
    8385        MODECASE(PSTAMPTOOL_MODE_MODPROJECT, modprojectMode);
     
    485487    PS_ASSERT_PTR_NON_NULL(config, false);
    486488
    487     PXOPT_LOOKUP_S64(req_id,     config->args, "-req_id",     true, false);
    488 
    489     // printf("Revert request %" PRId64 "\n", req_id);
     489    psMetadata *where = psMetadataAlloc();
     490
     491    PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "==");
     492    PXOPT_COPY_S64(config->args, where, "-fault", "req_id", "==");
     493    PXOPT_COPY_STR(config->args, where, "-state", "pstampRequest.state", "==");
     494
     495    if (!psListLength(where->list)) {
     496        psFree(where);
     497        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     498        return false;
     499    }
     500
     501    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     502    psFree(where);
     503
     504    // delete any jobs that were queued by requests that didn't complete parsing (pstampRequest.state = 'new'
     505    // If state =  'run' was supplied this will be a no-op
     506    psString query = pxDataGet("pstamptool_revertreq_deletejobs.sql");
     507    psStringAppend(&query, " AND %s", whereClause);
     508    if (!p_psDBRunQuery(config->dbh, query)) {
     509        psError(PS_ERR_UNKNOWN, false, "database error");
     510        return false;
     511    }
     512    psFree(query);
     513
     514    // clear fault for requests
     515    query = pxDataGet("pstamptool_revertreq.sql");
     516    psStringAppend(&query, " AND %s", whereClause);
    490517   
    491     if (!p_psDBRunQueryF(config->dbh, "DELETE FROM pstampJob where req_id = %" PRId64, req_id)) {
    492         psError(PS_ERR_UNKNOWN, false, "database error");
    493         return false;
    494     }
    495     if (!p_psDBRunQueryF(config->dbh,
    496         "UPDATE pstampRequest set state ='new', name=NULL, reqType=NULL, fault=0 where req_id = %" PRId64, req_id)) {
    497         psError(PS_ERR_UNKNOWN, false, "database error");
    498         return false;
    499     }
     518    psFree(whereClause);
     519
     520    if (!p_psDBRunQuery(config->dbh, query)) {
     521        psError(PS_ERR_UNKNOWN, false, "database error");
     522        return false;
     523    }
     524    psFree(query);
    500525
    501526    return true;
     
    728753    return true;
    729754}
     755
     756static bool revertjobMode(pxConfig *config)
     757{
     758    PS_ASSERT_PTR_NON_NULL(config, false);
     759
     760    psMetadata *where = psMetadataAlloc();
     761
     762    PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "==");
     763    PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "==");
     764    PXOPT_COPY_S64(config->args, where, "-fault",  "fault", "==");
     765
     766    if (!psListLength(where->list)) {
     767        psFree(where);
     768        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     769        return false;
     770    }
     771
     772    psString query = pxDataGet("pstamptool_revertjob.sql");
     773    psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampJob");
     774    psStringAppend(&query, " AND %s", whereClause);
     775    psFree(whereClause);
     776    psFree(where);
     777   
     778    if (!p_psDBRunQuery(config->dbh, query)) {
     779        psError(PS_ERR_UNKNOWN, false, "database error");
     780        return false;
     781    }
     782
     783    return true;
     784}
    730785static bool addprojectMode(pxConfig *config)
    731786{
  • branches/czw_branch/cleanup/ippTools/src/pstamptool.h

    r19760 r25212  
    3939    PSTAMPTOOL_MODE_JOBRESULT,
    4040    PSTAMPTOOL_MODE_UPDATEJOB,
     41    PSTAMPTOOL_MODE_REVERTJOB,
    4142    PSTAMPTOOL_MODE_ADDPROJECT,
    4243    PSTAMPTOOL_MODE_MODPROJECT,
  • branches/czw_branch/cleanup/ippTools/src/pstamptoolConfig.c

    r25158 r25212  
    9797    // -revertreq
    9898    psMetadata *revertreqArgs = psMetadataAlloc();
    99     psMetadataAddS64(revertreqArgs, PS_LIST_TAIL, "-req_id", 0,            "req_id for which to revert", 0);
     99    psMetadataAddS64(revertreqArgs, PS_LIST_TAIL, "-req_id", 0,     "req_id to revert", 0);
     100    psMetadataAddS16(revertreqArgs, PS_LIST_TAIL, "-fault",  0,     "fault to revert", 0);
     101    psMetadataAddStr(revertreqArgs, PS_LIST_TAIL, "-state", 0,      "state to revert", NULL);
    100102
    101103    // -addjob
     
    129131    psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-fault", 0,            "new result", NULL);
    130132
     133    // -revertjob
     134    psMetadata *revertjobArgs = psMetadataAlloc();
     135    psMetadataAddS64(revertjobArgs, PS_LIST_TAIL, "-req_id", 0,     "req_id to revert", 0);
     136    psMetadataAddS64(revertjobArgs, PS_LIST_TAIL, "-job_id", 0,     "job_id to revert", 0);
     137    psMetadataAddS16(revertjobArgs, PS_LIST_TAIL, "-fault",  0,     "fault to revert", 0);
     138
    131139    // -addproject
    132140    psMetadata *addprojectArgs = psMetadataAlloc();
     
    159167    PXOPT_ADD_MODE("-addreq",          "", PSTAMPTOOL_MODE_ADDREQ,       addreqArgs);
    160168    PXOPT_ADD_MODE("-pendingreq",      "", PSTAMPTOOL_MODE_PENDINGREQ,   pendingreqArgs);
    161     PXOPT_ADD_MODE("-updatereq",    "", PSTAMPTOOL_MODE_UPDATEREQ, updatereqArgs);
     169    PXOPT_ADD_MODE("-updatereq",       "", PSTAMPTOOL_MODE_UPDATEREQ, updatereqArgs);
    162170    PXOPT_ADD_MODE("-listreq",         "", PSTAMPTOOL_MODE_LISTREQ,      listreqArgs);
    163171    PXOPT_ADD_MODE("-completedreq",    "", PSTAMPTOOL_MODE_COMPLETEDREQ, completedreqArgs);
     
    167175    PXOPT_ADD_MODE("-listjob",         "", PSTAMPTOOL_MODE_LISTJOB,      listjobArgs);
    168176    PXOPT_ADD_MODE("-pendingjob",      "", PSTAMPTOOL_MODE_PENDINGJOB,   pendingjobArgs);
    169     PXOPT_ADD_MODE("-updatejob",    "", PSTAMPTOOL_MODE_UPDATEJOB, updatejobArgs);
     177    PXOPT_ADD_MODE("-updatejob",       "", PSTAMPTOOL_MODE_UPDATEJOB,    updatejobArgs);
     178    PXOPT_ADD_MODE("-revertjob",       "", PSTAMPTOOL_MODE_REVERTJOB,    revertjobArgs);
    170179
    171180    PXOPT_ADD_MODE("-adddatastore",    "", PSTAMPTOOL_MODE_ADDDATASTORE, adddatastoreArgs);
  • branches/czw_branch/cleanup/magic/remove/src/streaksio.c

    r25158 r25212  
    654654            streaksExit("", PS_EXIT_DATA_ERROR);
    655655        }
     656
     657        // Ensure input is of the expected type
     658        psDataType expected = isMask ? PS_TYPE_IMAGE_MASK : PS_TYPE_F32; // Expected type for image
     659        for (int i = 0; i < in->imagecube->n; i++) {
     660            psImage *image = in->imagecube->data[i]; // Image of interest
     661            if (image->type.type != expected) {
     662                psImage *temp = psImageCopy(NULL, image, expected);
     663                psFree(image);
     664                in->imagecube->data[i] = temp;
     665            }
     666        }
    656667    }
    657668    setDataExtent(stage, in, (stage == IPP_STAGE_RAW) && !isMask);
     
    670681    sfile->fits->options = psFitsOptionsAlloc();
    671682    sfile->fits->options->scaling = PS_FITS_SCALE_MANUAL;
     683    sfile->fits->options->fuzz = false;
    672684    sfile->fits->options->bitpix = bitpix;
    673685    sfile->fits->options->bscale = bscale;
     
    11141126                // these gets are not necessary, we could just set the pixels to nan
    11151127                // but I want to get the counts
    1116                 double imageVal  = psImageGet(image, x, y);
     1128                double imageVal  = image->data.F32[y][x];
    11171129                psU32 maskVal;
    11181130                if (sfiles->stage == IPP_STAGE_RAW) {
    11191131                    unsigned int xChip, yChip;
    11201132                    cellToChipInt(&xChip, &yChip, sfiles->astrom, x, y);
    1121                     maskVal = psImageGet(mask, xChip, yChip);
     1133                    maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
    11221134                } else {
    1123                     maskVal = psImageGet(mask, x, y);
     1135                    maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
    11241136                }
    11251137                if (maskVal & maskMask) {
     
    11271139                    if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {
    11281140                        ++nandPixels;
    1129                         psImageSet(image, x, y, exciseValue);
     1141                        image->data.F32[y][x] = exciseValue;
    11301142                    }
    11311143                    if (weight) {
    1132                         double weightVal = weight ? psImageGet(weight, x, y) : 0;
     1144                        double weightVal = weight ? weight->data.F32[y][x] : 0;
    11331145                        if (!isnan(weightVal)) {
    11341146                            ++nandWeights;
    1135                             psImageSet(weight, x, y, NAN);
     1147                            weight->data.F32[y][x] = NAN;
    11361148                        }
    11371149                    }
  • branches/czw_branch/cleanup/magic/remove/src/streaksremove.c

    r25158 r25212  
    1212static pmConfig *parseArguments(int argc, char **argv);
    1313static bool readAndCopyToOutput(streakFiles *sf, bool exciseAll);
    14 static void exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue);
     14static void exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue);
    1515static bool warpedPixel(streakFiles *sfiles, int x, int y);
    16 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue);
     16static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue);
    1717static void writeImages(streakFiles *sf, bool exciseImageCube);
    1818static void updateAstrometry(streakFiles *sfiles);
    19 static void censorSources(streakFiles *sfiles, psU32 maskStreak);
     19static void censorSources(streakFiles *sfiles, psImageMaskType maskStreak);
     20static long censorPixels(streakFiles *sfiles, psImage * pixels, bool checkNonWarpedPixels, psU16 maskStreak);
    2021
    2122int
     
    146147                }
    147148
    148 
    149149                psTimerStart("REMOVE_STREAKS");
    150150
    151                 for (int y=0 ; y < sfiles->inImage->numRows; y++) {
    152                     for (int x = 0; x < sfiles->inImage->numCols; x++) {
    153                         if (psImageGet(pixels, x, y)) {
    154                             ++totalStreakPixels;
    155                             if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) {
    156 
    157                                 excisePixel(sfiles, x, y, true, maskStreak);
    158 
    159                             } else {
    160                                 // This pixel was not included in any warp and has thus already excised
    161                                 // by exciseNonWarpedPixels
    162                             }
    163                         }
    164                     }
    165                 }
     151                totalStreakPixels += censorPixels(sfiles, pixels, checkNonWarpedPixels, maskStreak);
    166152
    167153                psLogMsg("streaksremove", PS_LOG_INFO, "time to remove streak pixels: %f\n", psTimerClear("REMOVE_STREAKS"));
     
    254240
    255241    return 0;
     242}
     243
     244static long
     245censorPixels(streakFiles *sfiles, psImage *pixels, bool checkNonWarpedPixels, psU16 maskStreak)
     246{
     247    long streakPixels = 0;
     248
     249    for (int y=0 ; y < sfiles->inImage->numRows; y++) {
     250        for (int x = 0; x < sfiles->inImage->numCols; x++) {
     251            if (psImageGet(pixels, x, y)) {
     252                ++streakPixels;
     253                if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) {
     254
     255                    excisePixel(sfiles, x, y, true, maskStreak);
     256
     257                } else {
     258                    // This pixel was not included in any warp and has thus already excised
     259                    // by exciseNonWarpedPixels
     260                }
     261            }
     262        }
     263    }
     264    return streakPixels;
    256265}
    257266
     
    665674
    666675static void
    667 excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue)
     676excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue)
    668677{
    669678    double exciseValue = sfiles->inImage->exciseValue;
     
    674683    }
    675684
    676     double imageValue  = psImageGet (sfiles->inImage->image,  x, y);
     685    float imageValue  = sfiles->inImage->image->data.F32[y][x];
    677686    if (sfiles->recImage && !isExciseValue(imageValue, sfiles->inImage->exciseValue) ) {
    678         psImageSet (sfiles->recImage->image,  x, y, imageValue);
     687        sfiles->recImage->image->data.F32[y][x] = imageValue;
    679688    }
    680689
    681690    if (sfiles->transparentStreaks == 0) {
    682         psImageSet (sfiles->outImage->image,  x, y, exciseValue);
     691        sfiles->outImage->image->data.F32[y][x] = exciseValue;
    683692    } else {
    684693        if (streak) {
    685694            // as a visualization aid don't mask the pixel, just change the intensity
    686             psImageSet (sfiles->outImage->image,  x, y, imageValue + sfiles->transparentStreaks);
     695            sfiles->outImage->image->data.F32[y][x] = imageValue + sfiles->transparentStreaks;
    687696        } else {
    688             psImageSet (sfiles->outImage->image,  x, y, exciseValue);
     697            sfiles->outImage->image->data.F32[y][x] = exciseValue;
    689698        }
    690699    }
     
    692701    if (sfiles->outWeight) {
    693702        if (sfiles->recWeight) {
    694             double weightValue = psImageGet (sfiles->inWeight->image, x, y);
    695             psImageSet (sfiles->recWeight->image, x, y, weightValue);
     703            sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x];
    696704        }
    697705        // Assume that weight images are always a floating point type
    698         psImageSet (sfiles->outWeight->image, x, y, NAN);
     706        sfiles->outWeight->image->data.F32[y][x] = NAN;
    699707    }
    700708    if (sfiles->outMask) {
    701709        if (sfiles->recMask) {
    702             double maskValue   = psImageGet (sfiles->inMask->image,   x, y);
    703             psImageSet (sfiles->recMask->image,   x, y, maskValue);
    704         }
    705         psImageSet (sfiles->outMask->image,   x, y, newMaskValue);
     710            sfiles->recMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] =
     711                sfiles->inMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
     712        }
     713        sfiles->outMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] =
     714            sfiles->inMask->image->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | newMaskValue;
    706715    }
    707716}
    708717
    709718static void
    710 exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue)
     719exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue)
    711720{
    712721    int cell_x0 = sfiles->astrom->cell_x0;
     
    784793// streak mask
    785794static void
    786 censorSources(streakFiles *sfiles, psU32 maskStreak)
     795censorSources(streakFiles *sfiles, psImageMaskType maskStreak)
    787796{
    788797    if ((!sfiles->inSources) || (!sfiles->outMask)) {
     
    855864            psF32 y = psMetadataLookupF32(NULL, row, "Y_PSF");
    856865
    857             psU32 mask = psImageGet(maskImage, x, y);
     866            psImageMaskType mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x];
    858867
    859868            // Key the source if the center pixel is not masked with maskStreak
  • branches/czw_branch/cleanup/pstamp/scripts/pstamp_finish.pl

    r25158 r25212  
    254254        # register the fileset
    255255        my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS";
    256         $command .= " --link --datapath $out_dir";
     256        $command .= " --link --datapath $out_dir --ps0 $req_id";
    257257        $command .= " --dbname $dbname" if $dbname;
    258258
  • branches/czw_branch/cleanup/pstamp/scripts/pstamp_parser_run.pl

    r25158 r25212  
    1414use File::Basename qw( basename dirname);
    1515use POSIX qw( strftime );
     16use Carp;
     17use IPC::Cmd 0.36 qw( can_run run );
     18
     19use PS::IPP::Metadata::Config;
     20use PS::IPP::Metadata::Stats;
     21use PS::IPP::Metadata::List qw( parse_md_list );
     22
     23use PS::IPP::Config qw( :standard );
    1624
    1725my $req_id;
     
    3947}
    4048
    41 die "--req_id --uri --product are required"
     49my_die("--req_id --uri --product are required", $req_id, $PS_EXIT_CONFIG_ERROR)
    4250    if !defined($req_id) or
    4351       !defined($uri) or
    4452       !defined($product);
    45 
    46 use IPC::Cmd 0.36 qw( can_run run );
    47 
    48 use PS::IPP::Metadata::Config;
    49 use PS::IPP::Metadata::Stats;
    50 use PS::IPP::Metadata::List qw( parse_md_list );
    51 
    52 use PS::IPP::Config qw($PS_EXIT_SUCCESS
    53                        $PS_EXIT_UNKNOWN_ERROR
    54                        $PS_EXIT_SYS_ERROR
    55                        $PS_EXIT_CONFIG_ERROR
    56                        $PS_EXIT_PROG_ERROR
    57                        $PS_EXIT_DATA_ERROR
    58                        $PS_EXIT_TIMEOUT_ERROR
    59                        metadataLookupStr
    60                        metadataLookupBool
    61                        caturi
    62                        );
    6353
    6454my $ipprc = PS::IPP::Config->new(); # IPP Configuration
     
    8070my $datedir = "$pstamp_workdir/$datestr";
    8171if (! -e $datedir ) {
    82     mkdir $datedir or die "failed to create working directory $datedir for request id $req_id";
     72    mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id,
     73        $PS_EXIT_CONFIG_ERROR);
    8374}
    8475
    8576my $workdir = "$datedir/$req_id";
    8677if (! -e $workdir ) {
    87     mkdir $workdir or die "failed to create working directory $workdir for request id $req_id";
     78    mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id,
     79        $PS_EXIT_CONFIG_ERROR);
    8880}
    8981
     
    119111        run(command => $command, verbose => $verbose);
    120112    unless ($success) {
    121         die("Unable to perform $command error code: $error_code");
     113        my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8);
    122114    }
    123115} elsif ($uri ne $new_uri) {
    124116    # put a link to the file into the workdir
    125117    if (-e $new_uri) {
    126         unlink $new_uri or die "failed to unlink $new_uri";
     118        unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR);
    127119    }
    128120    if (! symlink $uri, $new_uri) {
    129         die ("failed to link request file $uri to workdir $workdir");
     121        my_die ("failed to link request file $uri to workdir $workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);
    130122    }
    131123}
    132124$uri = $new_uri;
    133125
    134 die "request file $uri not found" if ! -e $uri;
     126my_die("request file $uri not found", $req_id, $PS_EXIT_UNKNOWN_ERROR) if ! -e $uri;
    135127
    136128#  if product was not defined (in database), use the default
     
    263255    }
    264256}
     257
     258sub my_die {
     259    my $msg = shift;
     260    my $req_id = shift;
     261    my $fault = shift;
     262
     263    carp($msg);
     264
     265    my $command = "$pstamptool -updatereq -req_id $req_id  -fault $fault";
     266    $command   .= " -dbname $dbname" if $dbname;
     267    $command   .= " -dbserver $dbserver" if $dbserver;
     268    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     269        run(command => $command, verbose => $verbose);
     270    unless ($success) {
     271        die("Unable to perform $command error code: $error_code");
     272    }
     273    exit $fault;
     274}
  • branches/czw_branch/cleanup/pstamp/scripts/pstampparse.pl

    r25158 r25212  
    1414use PS::IPP::PStamp::Job qw( :standard );
    1515use File::Temp qw(tempfile);
     16use Carp;
    1617
    1718my $verbose;
     
    9697my_die("wrong EXTVER $extver found in $request_file_name", $PS_EXIT_PROG_ERROR) if ($extver ne "1");
    9798
    98 {
     99# check for duplicate request name
     100if (!$no_update) {
    99101    my $command = "$pstamptool -listreq  -name $req_name";
    100102    $command .= " -dbname $dbname" if $dbname;
    101103    $command .= " -dbserver $dbserver" if $dbserver;
     104    # no verbose so that error message about request not found doesn't appear in parse_error.txt
    102105    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    103         run(command => $command, verbose => $verbose);
     106        run(command => $command, verbose => 0);
    104107    my $exitStatus = $error_code >> 8;
    105108    if ($success) {
     
    183186
    184187    my $option_mask= $row->{OPTION_MASK};
     188    my $inverse = ($option_mask & $PSTAMP_SELECT_INVERSE) ? 1 : 0;
     189    $row->{inverse} = $inverse;
    185190
    186191    my $skycenter = $row->{skycenter} = ! ($row->{COORD_MASK} & $PSTAMP_CENTER_IN_PIXELS);
     
    214219    $need_magic = $proj_hash->{need_magic};
    215220
     221    # Temporary hack so that MOPS can get at non-magicked data
     222    if ($product eq "mops-pstamp-results") {
     223        $need_magic = 0;
     224    }
     225
    216226    # collect rows with the same images of interest in a list so that they
    217227    # can be looked up together
     
    247257        next;
    248258    } else {
    249         # Call PS::IPP::PStamp::Job's locate_images subroutine to get the parameters for this
     259        # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this
    250260        # request specification. An array reference is returned.
    251261        my ($x, $y);
     262
    252263        $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $search_component,
    253                 $skycenter, $x, $y, $mjd_min, $mjd_max, $filter, $verbose);
     264                $inverse, $skycenter, $x, $y, $mjd_min, $mjd_max, $filter, $verbose);
     265
    254266        if (!$imageList or !@$imageList) {
    255267            print STDERR "no matching images found for row $rownum\n" if $verbose;
     
    283295    my $need_magic = shift;
    284296
     297    my $num_jobs = 0;
    285298    my $rownum = $row->{ROWNUM};
    286 
    287299    my $components = $row->{components};
    288     my $numComponents = scalar keys %$components;
    289     if ( $numComponents == 0 ) {
    290         print STDERR "no jobs for row $rownum\n" if $verbose;
    291         insertFakeJobForRow($row, 1, $PSTAMP_NO_JOBS_QUEUED);
    292         return 1;
    293     }
    294300
    295301    my $roi_string;
     
    332338        if (($stage ne "stack") and ($need_magic and !$image->{magicked})) {
    333339            # XXX: should we add a faulted job so the client can know what happened if no images come back?
    334             print STDERR "skippping non-magicked image $imagefile\n" if $verbose;
     340            print STDERR "skipping non-magicked image $imagefile\n" if $verbose;
    335341
    336342            # for now assume yes.
    337343
    338344            insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED);
     345            $num_jobs++;
    339346
    340347            next;
     
    372379        my $fault = 0;
    373380
    374 if (0) {
    375         # XXX this doesn't work because not all ippTools outputs include data_state
    376         # fix chipTool also need to not make this test for raw stage
    377         if ((($stage ne 'stack') and ($image->{data_state} ne 'full')) or $image->{state} ne 'full' ){
    378             # XXX here is where we need to queue an update job
    379             # for now just say that the image is not available
    380             $newState = 'stop';
    381             $fault = 49;
    382         }
    383 }
     381        if (($stage ne 'stack') and ($stage ne 'raw')) {
     382            if (($image->{state} eq 'goto_purged') or ($image->{data_state} eq 'purged')) {
     383                $newState = 'stop';
     384                $fault = $PSTAMP_GONE;
     385            } elsif (($image->{data_state} ne 'full') or ($image->{state} ne 'full' )) {
     386                # XXX here is where we need to queue an update job
     387                # for now just say that the image is not available
     388                $newState = 'stop';
     389                $fault = $PSTAMP_NOT_AVAILABLE;
     390            }
     391        }
    384392
    385393        $num_jobs++;
     
    410418        }
    411419    }
     420    if ( $num_jobs == 0 ) {
     421        print STDERR "no jobs for row $rownum\n" if $verbose;
     422        insertFakeJobForRow($row, 1, $PSTAMP_NO_OVERLAP);
     423        $num_jobs = 1;
     424    }
    412425    return $num_jobs;
    413426}
     
    480493            if ($npoints) {
    481494                # we collected a set of sky coordintates above filter the images so that only
    482                 # those tat contain the centers are processed
     495                # those that contain the centers are processed
    483496                my $command = "$dvoImagesAtCoords $pointsListName";
    484497                if ($have_skycells) {
     
    511524                    my ($rownum, undef, undef, $component) = split " ", $line;
    512525
    513                     # I guess since we need this function we should be useing a hash for rowList
     526                    # I guess since we need this function we should be using a hash for rowList
    514527                    my $row = findRow($rownum, $rowList);
    515528                    $row->{components}->{$component} = 1;
     
    616629    return 0 if ($r1->{IMG_TYPE} ne $r2->{IMG_TYPE});
    617630    return 0 if ($r1->{ID} ne $r2->{ID});
     631    return 0 if ($r1->{inverse} ne $r2->{inverse});
    618632
    619633    if (defined($r1->{COMPONENT})) {
  • branches/czw_branch/cleanup/pstamp/src/ppstamp.c

    r16132 r25212  
    2929
    3030    // find the pixels that we need to copy, setup the output image
    31     if (ppstampMakeStamp(config, options)) {
    32         exitCode = 0;
    33     } else {
    34         exitCode = PS_EXIT_DATA_ERROR;
    35     }
     31    exitCode = ppstampMakeStamp(config, options);
    3632
    3733    psLogMsg ("ppstamp", 3, "Complete ppstamp run: %f sec\n", psTimerMark(TIMERNAME));
  • branches/czw_branch/cleanup/pstamp/src/ppstamp.h

    r16132 r25212  
    2020bool ppstampParseCamera(pmConfig *config);
    2121
    22 bool ppstampMakeStamp(pmConfig *config, ppstampOptions *);
     22int ppstampMakeStamp(pmConfig *config, ppstampOptions *);
    2323pmFPAfile * ppstampBuildMosaic(pmConfig *config, pmFPAfile *input, pmFPAview *view);
    2424
  • branches/czw_branch/cleanup/pstamp/src/ppstampMakeStamp.c

    r25143 r25212  
    174174static psImage *extractStamp(psImage *image, psRegion region, double value)
    175175{
    176     int width  = region.x1 - region.x0;
    177     int height = region.y1 - region.y0;
     176    int width  = region.x1 - region.x0 + 0.5;
     177    int height = region.y1 - region.y0 + 0.5;
    178178
    179179    if (width < 0) {
     
    252252// Build the postage stamp output file
    253253
    254 static bool makeStamp(pmConfig *config, ppstampOptions *options, pmFPAfile *input,
     254static int makeStamp(pmConfig *config, ppstampOptions *options, pmFPAfile *input,
    255255                pmChip *inChip, pmFPAview *view)
    256256{
     
    260260    if (!output) {
    261261        psError(PS_ERR_UNKNOWN, false, "Can't find output data\n");
    262         return false;
     262        return PS_EXIT_DATA_ERROR;
    263263    }
    264264    char *fpaName = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.OBS"); // Name of FPA
     
    284284        pmFPAfile *mosaic = ppstampBuildMosaic(config, input, view);
    285285        if (mosaic == NULL) {
    286             return false;
     286            return PS_EXIT_UNKNOWN_ERROR;
    287287        }
    288288        srcFile = mosaic;
     
    362362        status = copyMetadata(output, input, inChip, options);
    363363    }
    364     return status;
     364    return status ? PS_EXIT_SUCCESS : PS_EXIT_UNKNOWN_ERROR;
    365365}
    366366
     
    574574}
    575575
    576 bool ppstampMakeStamp (pmConfig *config, ppstampOptions *options)
     576int ppstampMakeStamp (pmConfig *config, ppstampOptions *options)
    577577{
    578578    bool        status = false;
    579     bool        returnval = false;;
     579    int        returnval = PS_EXIT_SUCCESS;;
    580580    bool        foundOverlap = false;
    581581
     
    583583    if (!status) {
    584584        psError(PS_ERR_UNKNOWN, true, "Can't find input file!\n");
    585         return false;
     585        return PS_EXIT_DATA_ERROR;
    586586    }
    587587
     
    591591    } else if (astrom->camera != input->camera) {
    592592        psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match");
    593         return false;
     593        return PS_EXIT_CONFIG_ERROR;
    594594    }
    595595
     
    600600        psError(PS_ERR_UNKNOWN, false, "Failed to load input.");
    601601        psFree (view);
    602         return false;
     602        return PS_EXIT_DATA_ERROR;
    603603    }
    604604    bool bilevelAstrometry  = false;
     
    614614            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
    615615            psFree(view);
    616             return false;
     616            return PS_EXIT_DATA_ERROR;
    617617        }
    618618    }
     
    647647            break;
    648648        case PSTAMP_ERROR:
    649             returnval = false;
     649            returnval = PS_EXIT_UNKNOWN_ERROR;
    650650            allDone = true;
    651651            break;
     
    667667    psFree(view);
    668668
    669     if (!foundOverlap) {
     669    if (!foundOverlap && (returnval == PS_EXIT_SUCCESS)) {
    670670        fprintf(stderr, "ROI not found in input\n");
     671        returnval = PSTAMP_NO_OVERLAP;
    671672    }
    672673
  • branches/czw_branch/cleanup/pstamp/src/pstamp.h

    r25158 r25212  
    4242        PSTAMP_NOT_AVAILABLE    = 25,
    4343        PSTAMP_GONE             = 26,
    44         PSTAMP_NO_JOBS_QUEUED   = 27
     44        PSTAMP_NO_JOBS_QUEUED   = 27,
     45        PSTAMP_NO_OVERLAP       = 28
    4546} pstampJobErrors;
    4647
Note: See TracChangeset for help on using the changeset viewer.