Changeset 27609
- Timestamp:
- Apr 5, 2010, 3:30:27 PM (16 years ago)
- Location:
- trunk/ppViz/src/ppCoord
- Files:
-
- 4 edited
-
ppCoord.h (modified) (1 diff)
-
ppCoordArguments.c (modified) (3 diffs)
-
ppCoordData.c (modified) (2 diffs)
-
ppCoordLoop.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppViz/src/ppCoord/ppCoord.h
r27605 r27609 16 16 psString chipName; // Name of chip of interest 17 17 psString radecName; // Filename with sky coordinates 18 psString streaksName; // Filename with streaks (sky coordinates) 18 19 pmConfig *config; // Configuration 19 20 bool radians; // RA,Dec are in radians? -
trunk/ppViz/src/ppCoord/ppCoordArguments.c
r27606 r27609 51 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-chip", 0, "Chip for pixel coordinates", NULL); 52 52 psMetadataAddStr(arguments, PS_LIST_TAIL, "-radec", 0, "Filename with RA,Dec (default decimal degrees)", NULL); 53 psMetadataAddStr(arguments, PS_LIST_TAIL, "-streaks", 0, "Filename with streaks", NULL); 53 54 psMetadataAddBool(arguments, PS_LIST_TAIL, "-radians", 0, "RA,Dec in radians?", NULL); 54 55 psMetadataAddBool(arguments, PS_LIST_TAIL, "-all", 0, "Output all coordinates?", NULL); … … 65 66 data->chipName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-chip")); 66 67 data->radecName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-radec")); 68 data->streaksName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-streaks")); 67 69 data->radians = psMetadataLookupBool(NULL, arguments, "-radians"); 68 70 data->all = psMetadataLookupBool(NULL, arguments, "-all"); … … 88 90 } 89 91 90 if (!data->pixelsName && !data->radecName ) {92 if (!data->pixelsName && !data->radecName && !data->streaksName) { 91 93 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Neither -pixels nor -radec provided."); 92 94 return false; -
trunk/ppViz/src/ppCoord/ppCoordData.c
r27608 r27609 18 18 psFree(data->chipName); 19 19 psFree(data->radecName); 20 psFree(data->streaksName); 20 21 psFree(data->config); 21 22 psFree(data->ds9name); … … 38 39 data->chipName = NULL; 39 40 data->radecName = NULL; 41 data->streaksName = NULL; 40 42 data->config = NULL; 41 43 data->radians = false; -
trunk/ppViz/src/ppCoord/ppCoordLoop.c
r27608 r27609 23 23 NULL; // File with raw image 24 24 25 psArray *pixels = NULL, *radec = NULL ; // Array of vectors with coordinates26 psArray *radecOut = NULL ;// Output for sky coordinates25 psArray *pixels = NULL, *radec = NULL, *streaks = NULL; // Array of vectors with coordinates 26 psArray *radecOut = NULL, *streaksOut = NULL; // Output for sky coordinates 27 27 if (data->pixelsName) { 28 28 pixels = psVectorsReadFromFile(data->pixelsName, "%f %f"); … … 47 47 psVectorInit(radecOut->data[1], NAN); 48 48 psVectorInit(radecOut->data[2], NAN); 49 } 50 51 if (data->streaksName) { 52 FILE *streaksFile = fopen(data->streaksName, "r"); // File handle for streaks 53 if (!streaksFile) { 54 psError(PS_ERR_IO, true, "Unable to open streaks file %s", data->streaksName); 55 return false; 56 } 57 int numStreaks = 0; // Number of streaks 58 if (fscanf(streaksFile, "%d", &numStreaks) != 1) { 59 psError(PS_ERR_IO, true, "Unable to read number of streaks from %s", data->streaksName); 60 return false; 61 } 62 63 streaks = psArrayAlloc(4); 64 psVector *ra1 = streaks->data[0] = psVectorAlloc(numStreaks, PS_TYPE_F64); 65 psVector *dec1 = streaks->data[1] = psVectorAlloc(numStreaks, PS_TYPE_F64); 66 psVector *ra2 = streaks->data[2] = psVectorAlloc(numStreaks, PS_TYPE_F64); 67 psVector *dec2 = streaks->data[3] = psVectorAlloc(numStreaks, PS_TYPE_F64); 68 69 for (int i = 0; i < numStreaks; i++) { 70 if (fscanf(streaksFile, "%lf %lf %lf %lf %*d", 71 &ra1->data.F64[i], &dec1->data.F64[i], &ra2->data.F64[i], &dec2->data.F64[i]) != 4) { 72 psError(PS_ERR_IO, true, "Unable to read streak %d of %d from %s", 73 i, numStreaks, data->streaksName); 74 return false; 75 } 76 } 77 streaksOut = psArrayAlloc(4); 78 streaksOut->data[0] = psVectorAlloc(numStreaks, PS_TYPE_F32); 79 streaksOut->data[1] = psVectorAlloc(numStreaks, PS_TYPE_F32); 80 streaksOut->data[2] = psVectorAlloc(numStreaks, PS_TYPE_F32); 81 streaksOut->data[3] = psVectorAlloc(numStreaks, PS_TYPE_F32); 82 psVectorInit(streaksOut->data[0], NAN); 83 psVectorInit(streaksOut->data[1], NAN); 84 psVectorInit(streaksOut->data[2], NAN); 85 psVectorInit(streaksOut->data[3], NAN); 49 86 } 50 87 … … 282 319 } 283 320 321 if (streaks && data->chipName && !rawFile) { 322 psVector *xPix1 = streaksOut->data[0]; // x coordinate for point 1 323 psVector *yPix1 = streaksOut->data[1]; // y coordinate for point 1 324 psVector *xPix2 = streaksOut->data[2]; // x coordinate for point 2 325 psVector *yPix2 = streaksOut->data[3]; // y coordinate for point 2 326 327 psVector *ra1 = streaks->data[0]; // RA coordinate for point 1 328 psVector *dec1 = streaks->data[1]; // Dec coordinate for point 1 329 psVector *ra2 = streaks->data[2]; // RA coordinate for point 2 330 psVector *dec2 = streaks->data[3]; // Dec coordinate for point 2 331 332 psPlane *pix = psPlaneAlloc(); // Pixel coordinates on chip 333 psPlane *fp = psPlaneAlloc(); // Focal plane coordinates 334 psPlane *tp = psPlaneAlloc(); // Tangent plane coordinates 335 psSphere *sky = psSphereAlloc(); // Sky coordinates 336 for (long i = 0; i < xPix1->n; i++) { 337 sky->r = ra1->data.F64[i]; 338 sky->d = dec1->data.F64[i]; 339 psProject(tp, sky, astromFile->fpa->toSky); 340 psPlaneTransformApply(fp, astromFile->fpa->fromTPA, tp); 341 psPlaneTransformApply(pix, chip->fromFPA, fp); 342 xPix1->data.F32[i] = pix->x; 343 yPix1->data.F32[i] = pix->y; 344 345 sky->r = ra2->data.F64[i]; 346 sky->d = dec2->data.F64[i]; 347 psProject(tp, sky, astromFile->fpa->toSky); 348 psPlaneTransformApply(fp, astromFile->fpa->fromTPA, tp); 349 psPlaneTransformApply(pix, chip->fromFPA, fp); 350 xPix2->data.F32[i] = pix->x; 351 yPix2->data.F32[i] = pix->y; 352 } 353 } 354 284 355 // Chip 285 356 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { … … 323 394 } 324 395 396 if (streaksOut) { 397 psVector *xPix1 = streaksOut->data[0]; // x coordinate for point 1 398 psVector *yPix1 = streaksOut->data[1]; // y coordinate for point 1 399 psVector *xPix2 = streaksOut->data[2]; // x coordinate for point 2 400 psVector *yPix2 = streaksOut->data[3]; // y coordinate for point 2 401 402 psVector *ra1 = streaks->data[0]; // RA coordinate for point 1 403 psVector *dec1 = streaks->data[1]; // Dec coordinate for point 1 404 psVector *ra2 = streaks->data[2]; // RA coordinate for point 2 405 psVector *dec2 = streaks->data[3]; // Dec coordinate for point 2 406 407 for (long i = 0; i < xPix1->n; i++) { 408 if (data->ds9) { 409 fprintf(data->ds9, "image;line(%f,%f,%f,%f) # line= 0 0 color=%s\n", 410 xPix1->data.F32[i], yPix1->data.F32[i], xPix2->data.F32[i], yPix2->data.F32[i], 411 data->ds9color); 412 } else { 413 fprintf(stdout, "%.10lf %.10lf %.10lf %.10lf --> %.3f %.3f %.3f %.3f\n", 414 ra1->data.F64[i], dec1->data.F64[i], 415 ra2->data.F64[i], dec2->data.F64[i], 416 xPix1->data.F32[i], yPix1->data.F32[i], 417 xPix2->data.F32[i], yPix2->data.F32[i]); 418 } 419 } 420 } 421 325 422 psFree(pixels); 326 423 psFree(radec); 327 424 psFree(radecOut); 425 psFree(streaks); 426 psFree(streaksOut); 328 427 329 428 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
