Changeset 25212
- Timestamp:
- Aug 26, 2009, 6:31:31 PM (17 years ago)
- Location:
- branches/czw_branch/cleanup
- Files:
-
- 22 edited
- 3 copied
-
. (modified) (1 prop)
-
Ohana/src/getstar/include/dvoImagesAtCoords.h (modified) (2 diffs)
-
Ohana/src/getstar/src/MatchCoords.c (modified) (3 diffs)
-
Ohana/src/getstar/src/dvoImagesAtCoords.c (modified) (5 diffs)
-
doc/misc/docgen.pl (modified) (1 prop)
-
ippScripts/scripts/ipp_image_path.pl (modified) (1 diff)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (1 prop)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/pstamptool_pendingjob.sql (modified) (1 diff)
-
ippTools/share/pstamptool_pendingreq.sql (modified) (1 diff)
-
ippTools/share/pstamptool_revertjob.sql (copied) (copied from trunk/ippTools/share/pstamptool_revertjob.sql )
-
ippTools/share/pstamptool_revertreq.sql (copied) (copied from trunk/ippTools/share/pstamptool_revertreq.sql )
-
ippTools/share/pstamptool_revertreq_deletejobs.sql (copied) (copied from trunk/ippTools/share/pstamptool_revertreq_deletejobs.sql )
-
ippTools/src/pstamptool.c (modified) (4 diffs)
-
ippTools/src/pstamptool.h (modified) (1 diff)
-
ippTools/src/pstamptoolConfig.c (modified) (4 diffs)
-
magic/remove/src/streaksio.c (modified) (4 diffs)
-
magic/remove/src/streaksremove.c (modified) (8 diffs)
-
pstamp/scripts/pstamp_finish.pl (modified) (1 diff)
-
pstamp/scripts/pstamp_parser_run.pl (modified) (5 diffs)
-
pstamp/scripts/pstampparse.pl (modified) (12 diffs)
-
pstamp/src/ppstamp.c (modified) (1 diff)
-
pstamp/src/ppstamp.h (modified) (1 diff)
-
pstamp/src/ppstampMakeStamp.c (modified) (12 diffs)
-
pstamp/src/pstamp.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup
- Property svn:mergeinfo changed
/trunk merged: 25194-25200,25207-25209
- Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/Ohana/src/getstar/include/dvoImagesAtCoords.h
r24951 r25212 18 18 Coords *MOSAIC; // carries the mosaic into ReadImageHeader 19 19 20 typedef struct { 21 int id; 22 double ra; 23 double dec; 24 int Nmatches; 25 int *matches; 26 int arrayLength; 27 } Point; 28 20 29 int WITH_PHU; 21 30 int SOLO_PHU; … … 33 42 Image *ReadImageFiles (char *filename, int *Nimages); 34 43 int ReadImageHeader (Header *header, Image *image); 35 int *MatchCoords(Image *, int, double, double, int *);44 int MatchCoords(Image *, int, Point *, int); 36 45 37 46 int 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 5 5 6 6 /* given coordinate, find images in list that contain the point */ 7 int *MatchCoords (Image *dbImages, int NdbImages, double ra, double dec, int *Nmatch) {7 int MatchCoords (Image *dbImages, int NdbImages, Point *points, int Npoints) { 8 8 9 int i, j, N , addtolist, status;10 int NMATCH, nmatch, *match;9 int i, j, N; 10 int totalMatches = 0; 11 11 Coords tcoords; 12 12 double r, d; … … 15 15 double xmin, xmax, ymin, ymax; 16 16 17 *Nmatch = 0;18 19 /* match represents the subset of overlapping images */20 nmatch = 0;21 NMATCH = 20;22 ALLOCATE (match, int, NMATCH);23 17 24 18 /* setup links for mosaic WRP and DIS entries */ … … 49 43 } 50 44 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; 54 47 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); 59 51 60 if ((x >= xmin && x <= xmax) && (y >= ymin && y <= ymax)) { 52 if (!status) { 53 // avoid matching antipodal skycells 54 continue; 55 } 61 56 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 } 67 67 } 68 68 } 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); 72 71 73 *Nmatch = nmatch; 74 return (match); 72 return (totalMatches); 75 73 } 76 74 -
branches/czw_branch/cleanup/Ohana/src/getstar/src/dvoImagesAtCoords.c
r24951 r25212 1 1 # include "dvoImagesAtCoords.h" 2 2 3 typedef struct {4 int id;5 double ra;6 double dec;7 } Point;8 9 3 static int readPoints(char *filename, Point **pointsOut); 10 static int ListImagesAtCoords (Image *dbImages, int id, double ra, double dec, int *matches, int Nmatches);4 static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints); 11 5 12 6 int main (int argc, char **argv) { … … 30 24 if (astromFile) { 31 25 dbImages = ReadImageFiles(astromFile, &NdbImages); 32 } else {26 } else { 33 27 /*** update the image table ***/ 34 28 /* setup image table format and lock */ … … 53 47 } 54 48 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); 59 51 } 60 52 // XXX: should we exit with nonzero status if no matches were found? 61 53 exit (0); 62 54 } … … 83 75 84 76 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) { 87 82 LEN += 20; 88 83 REALLOCATE(pts, Point, LEN); … … 99 94 } 100 95 101 static int ListImagesAtCoords (Image *dbImages, int id, double ra, double dec, int *matches, int Nmatches)96 static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints) 102 97 { 98 int j; 103 99 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]; 106 104 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; 116 119 } 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 } 119 124 } 120 fprintf (stdout, "%d %lf %lf %s\n", id, ra, dec, name);121 125 } 122 126 -
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 108 108 # remove the leading "file://" if present 109 109 $path =~ s/^file\:\/\///; 110 $nfiles++; 111 print "$path\n"; 110 112 } 111 $nfiles++;112 print "$path\n";113 113 } 114 114 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 184 184 pstamptool_pendingreq.sql \ 185 185 pstamptool_project.sql \ 186 pstamptool_revertjob.sql \ 187 pstamptool_revertreq.sql \ 188 pstamptool_revertreq_deletejobs.sql \ 186 189 pxadmin_create_tables.sql \ 187 190 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 1 SELECT pstampJob.* 2 FROM pstampJob 3 JOIN pstampRequest using(req_id) 4 WHERE 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 7 7 USING(ds_id) 8 8 WHERE pstampRequest.state = 'new' 9 AND pstampRequest.fault = 0 -
branches/czw_branch/cleanup/ippTools/src/pstamptool.c
r25158 r25212 44 44 static bool pendingjobMode(pxConfig *config); 45 45 static bool updatejobMode(pxConfig *config); 46 static bool revertjobMode(pxConfig *config); 46 47 static bool addprojectMode(pxConfig *config); 47 48 static bool projectMode(pxConfig *config); … … 80 81 MODECASE(PSTAMPTOOL_MODE_PENDINGJOB, pendingjobMode); 81 82 MODECASE(PSTAMPTOOL_MODE_UPDATEJOB, updatejobMode); 83 MODECASE(PSTAMPTOOL_MODE_REVERTJOB, revertjobMode); 82 84 MODECASE(PSTAMPTOOL_MODE_ADDPROJECT, addprojectMode); 83 85 MODECASE(PSTAMPTOOL_MODE_MODPROJECT, modprojectMode); … … 485 487 PS_ASSERT_PTR_NON_NULL(config, false); 486 488 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); 490 517 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); 500 525 501 526 return true; … … 728 753 return true; 729 754 } 755 756 static 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 } 730 785 static bool addprojectMode(pxConfig *config) 731 786 { -
branches/czw_branch/cleanup/ippTools/src/pstamptool.h
r19760 r25212 39 39 PSTAMPTOOL_MODE_JOBRESULT, 40 40 PSTAMPTOOL_MODE_UPDATEJOB, 41 PSTAMPTOOL_MODE_REVERTJOB, 41 42 PSTAMPTOOL_MODE_ADDPROJECT, 42 43 PSTAMPTOOL_MODE_MODPROJECT, -
branches/czw_branch/cleanup/ippTools/src/pstamptoolConfig.c
r25158 r25212 97 97 // -revertreq 98 98 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); 100 102 101 103 // -addjob … … 129 131 psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-fault", 0, "new result", NULL); 130 132 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 131 139 // -addproject 132 140 psMetadata *addprojectArgs = psMetadataAlloc(); … … 159 167 PXOPT_ADD_MODE("-addreq", "", PSTAMPTOOL_MODE_ADDREQ, addreqArgs); 160 168 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); 162 170 PXOPT_ADD_MODE("-listreq", "", PSTAMPTOOL_MODE_LISTREQ, listreqArgs); 163 171 PXOPT_ADD_MODE("-completedreq", "", PSTAMPTOOL_MODE_COMPLETEDREQ, completedreqArgs); … … 167 175 PXOPT_ADD_MODE("-listjob", "", PSTAMPTOOL_MODE_LISTJOB, listjobArgs); 168 176 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); 170 179 171 180 PXOPT_ADD_MODE("-adddatastore", "", PSTAMPTOOL_MODE_ADDDATASTORE, adddatastoreArgs); -
branches/czw_branch/cleanup/magic/remove/src/streaksio.c
r25158 r25212 654 654 streaksExit("", PS_EXIT_DATA_ERROR); 655 655 } 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 } 656 667 } 657 668 setDataExtent(stage, in, (stage == IPP_STAGE_RAW) && !isMask); … … 670 681 sfile->fits->options = psFitsOptionsAlloc(); 671 682 sfile->fits->options->scaling = PS_FITS_SCALE_MANUAL; 683 sfile->fits->options->fuzz = false; 672 684 sfile->fits->options->bitpix = bitpix; 673 685 sfile->fits->options->bscale = bscale; … … 1114 1126 // these gets are not necessary, we could just set the pixels to nan 1115 1127 // but I want to get the counts 1116 double imageVal = psImageGet(image, x, y);1128 double imageVal = image->data.F32[y][x]; 1117 1129 psU32 maskVal; 1118 1130 if (sfiles->stage == IPP_STAGE_RAW) { 1119 1131 unsigned int xChip, yChip; 1120 1132 cellToChipInt(&xChip, &yChip, sfiles->astrom, x, y); 1121 maskVal = psImageGet(mask, xChip, yChip);1133 maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip]; 1122 1134 } else { 1123 maskVal = psImageGet(mask, x, y);1135 maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]; 1124 1136 } 1125 1137 if (maskVal & maskMask) { … … 1127 1139 if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) { 1128 1140 ++nandPixels; 1129 psImageSet(image, x, y, exciseValue);1141 image->data.F32[y][x] = exciseValue; 1130 1142 } 1131 1143 if (weight) { 1132 double weightVal = weight ? psImageGet(weight, x, y): 0;1144 double weightVal = weight ? weight->data.F32[y][x] : 0; 1133 1145 if (!isnan(weightVal)) { 1134 1146 ++nandWeights; 1135 psImageSet(weight, x, y, NAN);1147 weight->data.F32[y][x] = NAN; 1136 1148 } 1137 1149 } -
branches/czw_branch/cleanup/magic/remove/src/streaksremove.c
r25158 r25212 12 12 static pmConfig *parseArguments(int argc, char **argv); 13 13 static bool readAndCopyToOutput(streakFiles *sf, bool exciseAll); 14 static void exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue);14 static void exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue); 15 15 static bool warpedPixel(streakFiles *sfiles, int x, int y); 16 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue);16 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue); 17 17 static void writeImages(streakFiles *sf, bool exciseImageCube); 18 18 static void updateAstrometry(streakFiles *sfiles); 19 static void censorSources(streakFiles *sfiles, psU32 maskStreak); 19 static void censorSources(streakFiles *sfiles, psImageMaskType maskStreak); 20 static long censorPixels(streakFiles *sfiles, psImage * pixels, bool checkNonWarpedPixels, psU16 maskStreak); 20 21 21 22 int … … 146 147 } 147 148 148 149 149 psTimerStart("REMOVE_STREAKS"); 150 150 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); 166 152 167 153 psLogMsg("streaksremove", PS_LOG_INFO, "time to remove streak pixels: %f\n", psTimerClear("REMOVE_STREAKS")); … … 254 240 255 241 return 0; 242 } 243 244 static long 245 censorPixels(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; 256 265 } 257 266 … … 665 674 666 675 static void 667 excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue)676 excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, psImageMaskType newMaskValue) 668 677 { 669 678 double exciseValue = sfiles->inImage->exciseValue; … … 674 683 } 675 684 676 double imageValue = psImageGet (sfiles->inImage->image, x, y);685 float imageValue = sfiles->inImage->image->data.F32[y][x]; 677 686 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; 679 688 } 680 689 681 690 if (sfiles->transparentStreaks == 0) { 682 psImageSet (sfiles->outImage->image, x, y, exciseValue);691 sfiles->outImage->image->data.F32[y][x] = exciseValue; 683 692 } else { 684 693 if (streak) { 685 694 // 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; 687 696 } else { 688 psImageSet (sfiles->outImage->image, x, y, exciseValue);697 sfiles->outImage->image->data.F32[y][x] = exciseValue; 689 698 } 690 699 } … … 692 701 if (sfiles->outWeight) { 693 702 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]; 696 704 } 697 705 // 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; 699 707 } 700 708 if (sfiles->outMask) { 701 709 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; 706 715 } 707 716 } 708 717 709 718 static void 710 exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue)719 exciseNonWarpedPixels(streakFiles *sfiles, psImageMaskType newMaskValue) 711 720 { 712 721 int cell_x0 = sfiles->astrom->cell_x0; … … 784 793 // streak mask 785 794 static void 786 censorSources(streakFiles *sfiles, ps U32maskStreak)795 censorSources(streakFiles *sfiles, psImageMaskType maskStreak) 787 796 { 788 797 if ((!sfiles->inSources) || (!sfiles->outMask)) { … … 855 864 psF32 y = psMetadataLookupF32(NULL, row, "Y_PSF"); 856 865 857 ps U32 mask = psImageGet(maskImage, x, y);866 psImageMaskType mask = maskImage->data.PS_TYPE_IMAGE_MASK_DATA[(int)y][(int)x]; 858 867 859 868 // Key the source if the center pixel is not masked with maskStreak -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_finish.pl
r25158 r25212 254 254 # register the fileset 255 255 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"; 257 257 $command .= " --dbname $dbname" if $dbname; 258 258 -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_parser_run.pl
r25158 r25212 14 14 use File::Basename qw( basename dirname); 15 15 use POSIX qw( strftime ); 16 use Carp; 17 use IPC::Cmd 0.36 qw( can_run run ); 18 19 use PS::IPP::Metadata::Config; 20 use PS::IPP::Metadata::Stats; 21 use PS::IPP::Metadata::List qw( parse_md_list ); 22 23 use PS::IPP::Config qw( :standard ); 16 24 17 25 my $req_id; … … 39 47 } 40 48 41 die "--req_id --uri --product are required" 49 my_die("--req_id --uri --product are required", $req_id, $PS_EXIT_CONFIG_ERROR) 42 50 if !defined($req_id) or 43 51 !defined($uri) or 44 52 !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_SUCCESS53 $PS_EXIT_UNKNOWN_ERROR54 $PS_EXIT_SYS_ERROR55 $PS_EXIT_CONFIG_ERROR56 $PS_EXIT_PROG_ERROR57 $PS_EXIT_DATA_ERROR58 $PS_EXIT_TIMEOUT_ERROR59 metadataLookupStr60 metadataLookupBool61 caturi62 );63 53 64 54 my $ipprc = PS::IPP::Config->new(); # IPP Configuration … … 80 70 my $datedir = "$pstamp_workdir/$datestr"; 81 71 if (! -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); 83 74 } 84 75 85 76 my $workdir = "$datedir/$req_id"; 86 77 if (! -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); 88 80 } 89 81 … … 119 111 run(command => $command, verbose => $verbose); 120 112 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); 122 114 } 123 115 } elsif ($uri ne $new_uri) { 124 116 # put a link to the file into the workdir 125 117 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); 127 119 } 128 120 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); 130 122 } 131 123 } 132 124 $uri = $new_uri; 133 125 134 die "request file $uri not found"if ! -e $uri;126 my_die("request file $uri not found", $req_id, $PS_EXIT_UNKNOWN_ERROR) if ! -e $uri; 135 127 136 128 # if product was not defined (in database), use the default … … 263 255 } 264 256 } 257 258 sub 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 14 14 use PS::IPP::PStamp::Job qw( :standard ); 15 15 use File::Temp qw(tempfile); 16 use Carp; 16 17 17 18 my $verbose; … … 96 97 my_die("wrong EXTVER $extver found in $request_file_name", $PS_EXIT_PROG_ERROR) if ($extver ne "1"); 97 98 98 { 99 # check for duplicate request name 100 if (!$no_update) { 99 101 my $command = "$pstamptool -listreq -name $req_name"; 100 102 $command .= " -dbname $dbname" if $dbname; 101 103 $command .= " -dbserver $dbserver" if $dbserver; 104 # no verbose so that error message about request not found doesn't appear in parse_error.txt 102 105 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 103 run(command => $command, verbose => $verbose);106 run(command => $command, verbose => 0); 104 107 my $exitStatus = $error_code >> 8; 105 108 if ($success) { … … 183 186 184 187 my $option_mask= $row->{OPTION_MASK}; 188 my $inverse = ($option_mask & $PSTAMP_SELECT_INVERSE) ? 1 : 0; 189 $row->{inverse} = $inverse; 185 190 186 191 my $skycenter = $row->{skycenter} = ! ($row->{COORD_MASK} & $PSTAMP_CENTER_IN_PIXELS); … … 214 219 $need_magic = $proj_hash->{need_magic}; 215 220 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 216 226 # collect rows with the same images of interest in a list so that they 217 227 # can be looked up together … … 247 257 next; 248 258 } else { 249 # Call PS::IPP::PStamp::Job 's locate_images subroutine to get the parameters for this259 # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this 250 260 # request specification. An array reference is returned. 251 261 my ($x, $y); 262 252 263 $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 254 266 if (!$imageList or !@$imageList) { 255 267 print STDERR "no matching images found for row $rownum\n" if $verbose; … … 283 295 my $need_magic = shift; 284 296 297 my $num_jobs = 0; 285 298 my $rownum = $row->{ROWNUM}; 286 287 299 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 }294 300 295 301 my $roi_string; … … 332 338 if (($stage ne "stack") and ($need_magic and !$image->{magicked})) { 333 339 # XXX: should we add a faulted job so the client can know what happened if no images come back? 334 print STDERR "skipp ping non-magicked image $imagefile\n" if $verbose;340 print STDERR "skipping non-magicked image $imagefile\n" if $verbose; 335 341 336 342 # for now assume yes. 337 343 338 344 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED); 345 $num_jobs++; 339 346 340 347 next; … … 372 379 my $fault = 0; 373 380 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 } 384 392 385 393 $num_jobs++; … … 410 418 } 411 419 } 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 } 412 425 return $num_jobs; 413 426 } … … 480 493 if ($npoints) { 481 494 # we collected a set of sky coordintates above filter the images so that only 482 # those t at contain the centers are processed495 # those that contain the centers are processed 483 496 my $command = "$dvoImagesAtCoords $pointsListName"; 484 497 if ($have_skycells) { … … 511 524 my ($rownum, undef, undef, $component) = split " ", $line; 512 525 513 # I guess since we need this function we should be us eing a hash for rowList526 # I guess since we need this function we should be using a hash for rowList 514 527 my $row = findRow($rownum, $rowList); 515 528 $row->{components}->{$component} = 1; … … 616 629 return 0 if ($r1->{IMG_TYPE} ne $r2->{IMG_TYPE}); 617 630 return 0 if ($r1->{ID} ne $r2->{ID}); 631 return 0 if ($r1->{inverse} ne $r2->{inverse}); 618 632 619 633 if (defined($r1->{COMPONENT})) { -
branches/czw_branch/cleanup/pstamp/src/ppstamp.c
r16132 r25212 29 29 30 30 // 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); 36 32 37 33 psLogMsg ("ppstamp", 3, "Complete ppstamp run: %f sec\n", psTimerMark(TIMERNAME)); -
branches/czw_branch/cleanup/pstamp/src/ppstamp.h
r16132 r25212 20 20 bool ppstampParseCamera(pmConfig *config); 21 21 22 boolppstampMakeStamp(pmConfig *config, ppstampOptions *);22 int ppstampMakeStamp(pmConfig *config, ppstampOptions *); 23 23 pmFPAfile * ppstampBuildMosaic(pmConfig *config, pmFPAfile *input, pmFPAview *view); 24 24 -
branches/czw_branch/cleanup/pstamp/src/ppstampMakeStamp.c
r25143 r25212 174 174 static psImage *extractStamp(psImage *image, psRegion region, double value) 175 175 { 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; 178 178 179 179 if (width < 0) { … … 252 252 // Build the postage stamp output file 253 253 254 static boolmakeStamp(pmConfig *config, ppstampOptions *options, pmFPAfile *input,254 static int makeStamp(pmConfig *config, ppstampOptions *options, pmFPAfile *input, 255 255 pmChip *inChip, pmFPAview *view) 256 256 { … … 260 260 if (!output) { 261 261 psError(PS_ERR_UNKNOWN, false, "Can't find output data\n"); 262 return false;262 return PS_EXIT_DATA_ERROR; 263 263 } 264 264 char *fpaName = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.OBS"); // Name of FPA … … 284 284 pmFPAfile *mosaic = ppstampBuildMosaic(config, input, view); 285 285 if (mosaic == NULL) { 286 return false;286 return PS_EXIT_UNKNOWN_ERROR; 287 287 } 288 288 srcFile = mosaic; … … 362 362 status = copyMetadata(output, input, inChip, options); 363 363 } 364 return status ;364 return status ? PS_EXIT_SUCCESS : PS_EXIT_UNKNOWN_ERROR; 365 365 } 366 366 … … 574 574 } 575 575 576 boolppstampMakeStamp (pmConfig *config, ppstampOptions *options)576 int ppstampMakeStamp (pmConfig *config, ppstampOptions *options) 577 577 { 578 578 bool status = false; 579 bool returnval = false;;579 int returnval = PS_EXIT_SUCCESS;; 580 580 bool foundOverlap = false; 581 581 … … 583 583 if (!status) { 584 584 psError(PS_ERR_UNKNOWN, true, "Can't find input file!\n"); 585 return false;585 return PS_EXIT_DATA_ERROR; 586 586 } 587 587 … … 591 591 } else if (astrom->camera != input->camera) { 592 592 psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match"); 593 return false;593 return PS_EXIT_CONFIG_ERROR; 594 594 } 595 595 … … 600 600 psError(PS_ERR_UNKNOWN, false, "Failed to load input."); 601 601 psFree (view); 602 return false;602 return PS_EXIT_DATA_ERROR; 603 603 } 604 604 bool bilevelAstrometry = false; … … 614 614 psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA."); 615 615 psFree(view); 616 return false;616 return PS_EXIT_DATA_ERROR; 617 617 } 618 618 } … … 647 647 break; 648 648 case PSTAMP_ERROR: 649 returnval = false;649 returnval = PS_EXIT_UNKNOWN_ERROR; 650 650 allDone = true; 651 651 break; … … 667 667 psFree(view); 668 668 669 if (!foundOverlap ) {669 if (!foundOverlap && (returnval == PS_EXIT_SUCCESS)) { 670 670 fprintf(stderr, "ROI not found in input\n"); 671 returnval = PSTAMP_NO_OVERLAP; 671 672 } 672 673 -
branches/czw_branch/cleanup/pstamp/src/pstamp.h
r25158 r25212 42 42 PSTAMP_NOT_AVAILABLE = 25, 43 43 PSTAMP_GONE = 26, 44 PSTAMP_NO_JOBS_QUEUED = 27 44 PSTAMP_NO_JOBS_QUEUED = 27, 45 PSTAMP_NO_OVERLAP = 28 45 46 } pstampJobErrors; 46 47
Note:
See TracChangeset
for help on using the changeset viewer.
