Changeset 28003 for branches/pap/ppViz/src/ppCoord/ppCoordLoop.c
- Timestamp:
- May 18, 2010, 12:49:05 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ppViz/src/ppCoord/ppCoordLoop.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ppViz/src/ppCoord/ppCoordLoop.c
r27618 r28003 71 71 { 72 72 pmConfig *config = data->config; // Configuration data 73 pmFPAfile *astromFile = pmFPAfileSelectSingle(config->files, "P SWARP.ASTROM", 0); // File with astrometry73 pmFPAfile *astromFile = pmFPAfileSelectSingle(config->files, "PPCOORD.ASTROM", 0); // File with astrometry 74 74 75 75 if (astromFile->fpa->chips->n > 0 && data->pixelsName && !data->chipName) { … … 77 77 } 78 78 79 pmFPAfile *rawFile = data->rawName ? pmFPAfileSelectSingle(config->files, "PP IMAGE.INPUT", 0) :79 pmFPAfile *rawFile = data->rawName ? pmFPAfileSelectSingle(config->files, "PPCOORD.RAW", 0) : 80 80 NULL; // File with raw image 81 81 82 psArray *pixels = NULL, *radec = NULL, *streaks = NULL ; // Array of vectors with coordinates83 psArray *radecOut = NULL, *streaksOut = NULL ;// Output for sky coordinates82 psArray *pixels = NULL, *radec = NULL, *streaks = NULL, *clusters = NULL; // Array of coordinate vectors 83 psArray *radecOut = NULL, *streaksOut = NULL, *clustersOut = NULL; // Output for sky coordinates 84 84 if (data->pixelsName) { 85 85 pixels = psVectorsReadFromFile(data->pixelsName, "%f %f"); … … 145 145 psVectorInit(streaksOut->data[6], NAN); 146 146 psVectorInit(streaksOut->data[7], NAN); 147 } 148 149 if (data->clustersName) { 150 psString file = psSlurpFilename(data->clustersName); // Contents of clusters file 151 if (!file) { 152 psError(psErrorCodeLast(), false, "Unable to read clusters file %s", data->clustersName); 153 return false; 154 } 155 psArray *lines = psStringSplitArray(file, "\n", false); // Lines of clusters 156 psFree(file); 157 158 int num = lines->n - 1; // Number of clusters 159 clusters = psArrayAlloc(2); 160 psVector *ra = clusters->data[0] = psVectorAlloc(num, PS_TYPE_F64); 161 psVector *dec = clusters->data[1] = psVectorAlloc(num, PS_TYPE_F64); 162 163 // Skip the first line 164 for (int i = 1; i < lines->n; i++) { 165 const char *line = lines->data[i]; // Line of interest 166 if (sscanf(line, "%lf %lf", &ra->data.F64[i-1], &dec->data.F64[i-1]) != 2) { 167 psError(PS_ERR_IO, true, "Unable to read line %d of %s", i, data->clustersName); 168 return false; 169 } 170 } 171 psFree(lines); 172 173 clustersOut = psArrayAlloc(4); 174 clustersOut->data[0] = psArrayAlloc(num); 175 clustersOut->data[1] = psVectorAlloc(num, PS_TYPE_F32); 176 clustersOut->data[2] = psVectorAlloc(num, PS_TYPE_F32); 177 clustersOut->data[3] = psArrayAlloc(num); 178 psVectorInit(clustersOut->data[1], NAN); 179 psVectorInit(clustersOut->data[2], NAN); 147 180 } 148 181 … … 369 402 float x1, y1; // Coordinates of point 1 370 403 coordSky2Chip(&x1, &y1, ra1->data.F64[i], dec1->data.F64[i], 371 data->radians, astromFile->fpa, chip);404 true, astromFile->fpa, chip); 372 405 if ((x1 >= 0 && x1 < numCols && y1 >= 0 && y1 < numRows)) { 373 406 if (rawChip) { … … 384 417 float x2, y2; // Coordinates of point 2 385 418 coordSky2Chip(&x2, &y2, ra2->data.F64[i], dec2->data.F64[i], 386 data->radians, astromFile->fpa, chip);419 true, astromFile->fpa, chip); 387 420 if ((x2 >= 0 && x2 < numCols && y2 >= 0 && y2 < numRows)) { 388 421 if (rawChip) { … … 396 429 yPix2->data.F32[i] = y2; 397 430 } 431 } 432 } 433 434 if (clusters) { 435 psVector *ra = clusters->data[0], *dec = clusters->data[1]; // Pixel coordinates 436 long num = ra->n; // Number of coordinates 437 438 int numCols = psMetadataLookupS32(NULL, hdu->header, "IMNAXIS1"); // Number of columns 439 int numRows = psMetadataLookupS32(NULL, hdu->header, "IMNAXIS2"); // Number of rows 440 if (numCols <= 0 || numRows <= 0) { 441 psError(psErrorCodeLast(), false, "Unable to read size of chip."); 442 return false; 443 } 444 445 psArray *chipPix = clustersOut->data[0]; // Chip for pixels 446 psVector *xPix = clustersOut->data[1]; // x coordinate for pixels 447 psVector *yPix = clustersOut->data[2]; // y coordinate for pixels 448 psArray *cellPix = clustersOut->data[3]; // Cell for pixels 449 450 for (long i = 0; i < num; i++) { 451 float x, y; // Pixel coordinates 452 coordSky2Chip(&x, &y, ra->data.F64[i], dec->data.F64[i], 453 false, astromFile->fpa, chip); 454 if ((x < 0 || x > numCols || y < 0 || y > numRows)) { 455 // Not on this chip 456 continue; 457 } 458 459 if (rawChip) { 460 psString cellName = NULL; // Name of cell 461 coordChip2Cell(&cellName, &x, &y, x, y, cellNames, cellBounds, 462 cellX0, cellY0, cellParityX, cellParityY, cellBinX, cellBinY); 463 cellPix->data[i] = cellName; 464 } 465 466 chipPix->data[i] = psStringCopy(chipName); 467 xPix->data.F32[i] = x; 468 yPix->data.F32[i] = y; 398 469 } 399 470 } … … 482 553 data->ds9color); 483 554 } else { 484 fprintf(stdout, " %.10lf %.10lf %.10lf %.10lf --> %.3f %.3f %s%s%s %.3f %.3f %s%s%s\n",555 fprintf(stdout, "Streak %.10lf %.10lf %.10lf %.10lf --> %.3f %.3f %s%s%s %.3f %.3f %s%s%s\n", 485 556 ra1->data.F64[i], dec1->data.F64[i], 486 557 ra2->data.F64[i], dec2->data.F64[i], … … 498 569 } 499 570 571 if (clustersOut) { 572 psArray *chipPix = clustersOut->data[0]; // Chip for pixels 573 psVector *xPix = clustersOut->data[1]; // x coordinate for pixels 574 psVector *yPix = clustersOut->data[2]; // y coordinate for pixels 575 psArray *cellPix = clustersOut->data[3]; // Cell for pixels 576 psVector *ra = clusters->data[0]; // RA coordinate 577 psVector *dec = clusters->data[1]; // Dec coordinate 578 579 for (long i = 0; i < chipPix->n; i++) { 580 const char *chipName = chipPix->data[i]; // Name of chip 581 const char *cellName = cellPix->data[i]; // Name of cell, or NULL 582 if (!data->all && (!isfinite(xPix->data.F32[i]) || !isfinite(yPix->data.F32[i]) || 583 !chipName || (rawFile && !cellName))) { 584 continue; 585 } 586 if (!rawFile && data->ds9) { 587 // Region file is only appropriate if we're not mapping all the way back to cell coordinates 588 fprintf(data->ds9, "image;circle(%f,%f,%f) # color=%s\n", 589 xPix->data.F32[i], yPix->data.F32[i], data->ds9radius, data->ds9color); 590 } else { 591 fprintf(stdout, "Cluster %.10lf %.10lf --> %.3f %.3f %s%s%s\n", 592 ra->data.F64[i], dec->data.F64[i], xPix->data.F32[i], yPix->data.F32[i], 593 chipName ? chipName : "UNKNOWN", 594 rawFile ? " " : "", 595 rawFile && cellName ? cellName : (rawFile ? "UNKNOWN" : "")); 596 } 597 } 598 } 599 500 600 psFree(pixels); 501 601 psFree(radec); … … 503 603 psFree(streaks); 504 604 psFree(streaksOut); 605 psFree(clusters); 606 psFree(clustersOut); 505 607 506 608 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
