Changeset 7080 for trunk/Ohana/src/libdvo/src/coordops.c
- Timestamp:
- May 5, 2006, 5:44:26 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libdvo/src/coordops.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libdvo/src/coordops.c
r6678 r7080 312 312 313 313 status = FALSE; 314 if ( fits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) {315 status = fits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);316 status &= fits_scan (header, "CRPIX1", "%f", 1, &coords[0].crpix1);317 status &= fits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2);318 status &= fits_scan (header, "CRPIX2", "%f", 1, &coords[0].crpix2);319 320 if ( fits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1)) {321 status &= fits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);322 if ( fits_scan (header, "CROTA2", "%lf", 1, &rotate)) {314 if (gfits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) { 315 status = gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1); 316 status &= gfits_scan (header, "CRPIX1", "%f", 1, &coords[0].crpix1); 317 status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 318 status &= gfits_scan (header, "CRPIX2", "%f", 1, &coords[0].crpix2); 319 320 if (gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1)) { 321 status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2); 322 if (gfits_scan (header, "CROTA2", "%lf", 1, &rotate)) { 323 323 Lambda = coords[0].cdelt2 / coords[0].cdelt1; 324 324 coords[0].pc1_1 = cos(rotate*RAD_DEG); … … 327 327 coords[0].pc2_2 = cos(rotate*RAD_DEG); 328 328 } 329 if ( fits_scan (header, "PC001001", "%f", 1, &coords[0].pc1_1)) {330 status &= fits_scan (header, "PC001002", "%f", 1, &coords[0].pc1_2);331 status &= fits_scan (header, "PC002001", "%f", 1, &coords[0].pc2_1);332 status &= fits_scan (header, "PC002002", "%f", 1, &coords[0].pc2_2);329 if (gfits_scan (header, "PC001001", "%f", 1, &coords[0].pc1_1)) { 330 status &= gfits_scan (header, "PC001002", "%f", 1, &coords[0].pc1_2); 331 status &= gfits_scan (header, "PC002001", "%f", 1, &coords[0].pc2_1); 332 status &= gfits_scan (header, "PC002002", "%f", 1, &coords[0].pc2_2); 333 333 } 334 334 … … 337 337 338 338 if (Polynomial) { 339 if ( fits_scan (header, "NPLYTERM", "%d", 1, &itmp)) {339 if (gfits_scan (header, "NPLYTERM", "%d", 1, &itmp)) { 340 340 coords[0].Npolyterms = itmp; 341 341 } else { … … 344 344 switch (coords[0].Npolyterms) { 345 345 case 3: 346 status &= fits_scan (header, "PCA1X3Y0", "%f", 1, &coords[0].polyterms[3][0]);347 status &= fits_scan (header, "PCA1X2Y1", "%f", 1, &coords[0].polyterms[4][0]);348 status &= fits_scan (header, "PCA1X1Y2", "%f", 1, &coords[0].polyterms[5][0]);349 status &= fits_scan (header, "PCA1X0Y3", "%f", 1, &coords[0].polyterms[6][0]);350 status &= fits_scan (header, "PCA2X3Y0", "%f", 1, &coords[0].polyterms[3][1]);351 status &= fits_scan (header, "PCA2X2Y1", "%f", 1, &coords[0].polyterms[4][1]);352 status &= fits_scan (header, "PCA2X1Y2", "%f", 1, &coords[0].polyterms[5][1]);353 status &= fits_scan (header, "PCA2X0Y3", "%f", 1, &coords[0].polyterms[6][1]);346 status &= gfits_scan (header, "PCA1X3Y0", "%f", 1, &coords[0].polyterms[3][0]); 347 status &= gfits_scan (header, "PCA1X2Y1", "%f", 1, &coords[0].polyterms[4][0]); 348 status &= gfits_scan (header, "PCA1X1Y2", "%f", 1, &coords[0].polyterms[5][0]); 349 status &= gfits_scan (header, "PCA1X0Y3", "%f", 1, &coords[0].polyterms[6][0]); 350 status &= gfits_scan (header, "PCA2X3Y0", "%f", 1, &coords[0].polyterms[3][1]); 351 status &= gfits_scan (header, "PCA2X2Y1", "%f", 1, &coords[0].polyterms[4][1]); 352 status &= gfits_scan (header, "PCA2X1Y2", "%f", 1, &coords[0].polyterms[5][1]); 353 status &= gfits_scan (header, "PCA2X0Y3", "%f", 1, &coords[0].polyterms[6][1]); 354 354 case 2: 355 status &= fits_scan (header, "PCA1X2Y0", "%f", 1, &coords[0].polyterms[0][0]);356 status &= fits_scan (header, "PCA1X1Y1", "%f", 1, &coords[0].polyterms[1][0]);357 status &= fits_scan (header, "PCA1X0Y2", "%f", 1, &coords[0].polyterms[2][0]);358 status &= fits_scan (header, "PCA2X2Y0", "%f", 1, &coords[0].polyterms[0][1]);359 status &= fits_scan (header, "PCA2X1Y1", "%f", 1, &coords[0].polyterms[1][1]);360 status &= fits_scan (header, "PCA2X0Y2", "%f", 1, &coords[0].polyterms[2][1]);355 status &= gfits_scan (header, "PCA1X2Y0", "%f", 1, &coords[0].polyterms[0][0]); 356 status &= gfits_scan (header, "PCA1X1Y1", "%f", 1, &coords[0].polyterms[1][0]); 357 status &= gfits_scan (header, "PCA1X0Y2", "%f", 1, &coords[0].polyterms[2][0]); 358 status &= gfits_scan (header, "PCA2X2Y0", "%f", 1, &coords[0].polyterms[0][1]); 359 status &= gfits_scan (header, "PCA2X1Y1", "%f", 1, &coords[0].polyterms[1][1]); 360 status &= gfits_scan (header, "PCA2X0Y2", "%f", 1, &coords[0].polyterms[2][1]); 361 361 case 0: 362 362 case 1: … … 365 365 } 366 366 } else { 367 if ( fits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1)) {368 status &= fits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);369 status &= fits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);370 status &= fits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);367 if (gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1)) { 368 status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2); 369 status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1); 370 status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2); 371 371 /* renormalize */ 372 372 scale = hypot (coords[0].pc1_1, coords[0].pc1_2); … … 382 382 } else { 383 383 /* some of my thesis data uses this simple linear model - convert on read? */ 384 if ( fits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) {385 status = fits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);386 status &= fits_scan (header, "RA_Y", "%f", 1, &coords[0].pc1_2);387 status &= fits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2);388 status &= fits_scan (header, "DEC_X", "%f", 1, &coords[0].pc2_1);389 status &= fits_scan (header, "DEC_Y", "%f", 1, &coords[0].pc2_2);384 if (gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) { 385 status = gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1); 386 status &= gfits_scan (header, "RA_Y", "%f", 1, &coords[0].pc1_2); 387 status &= gfits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2); 388 status &= gfits_scan (header, "DEC_X", "%f", 1, &coords[0].pc2_1); 389 status &= gfits_scan (header, "DEC_Y", "%f", 1, &coords[0].pc2_2); 390 390 coords[0].crpix1 = coords[0].crpix2 = 0.0; 391 391 coords[0].cdelt1 = coords[0].cdelt2 = 1.0; … … 394 394 } 395 395 if (status) { 396 if (! fits_scan (header, "EQUINOX", "%lf", 1, &equinox)) {397 if (! fits_scan (header, "EPOCH", "%lf", 1, &equinox)) {396 if (!gfits_scan (header, "EQUINOX", "%lf", 1, &equinox)) { 397 if (!gfits_scan (header, "EPOCH", "%lf", 1, &equinox)) { 398 398 equinox = 2000.0; 399 399 } … … 422 422 /* modifications to the ctype? */ 423 423 OldAIPS = FALSE; 424 fits_modify (header, "CTYPE2", "%s", 1, coords[0].ctype);424 gfits_modify (header, "CTYPE2", "%s", 1, coords[0].ctype); 425 425 if (!strcmp(coords[0].ctype, "MM")) { 426 fits_modify (header, "CTYPE1", "%s", 1, "LL");426 gfits_modify (header, "CTYPE1", "%s", 1, "LL"); 427 427 OldAIPS = TRUE; 428 428 } else { … … 435 435 if (!strcmp (csys, "NONE")) return (FALSE); 436 436 sprintf (ctype, "%s-%s", csys, &coords[0].ctype[5]); 437 fits_modify (header, "CTYPE1", "%s", 1, ctype);437 gfits_modify (header, "CTYPE1", "%s", 1, ctype); 438 438 } 439 439 440 fits_modify (header, "CDELT1", "%le", 1, coords[0].cdelt1);441 fits_modify (header, "CDELT2", "%le", 1, coords[0].cdelt2);442 fits_modify (header, "CRVAL1", "%lf", 1, coords[0].crval1);443 fits_modify (header, "CRVAL2", "%lf", 1, coords[0].crval2);444 fits_modify (header, "CRPIX1", "%lf", 1, coords[0].crpix1);445 fits_modify (header, "CRPIX2", "%lf", 1, coords[0].crpix2);440 gfits_modify (header, "CDELT1", "%le", 1, coords[0].cdelt1); 441 gfits_modify (header, "CDELT2", "%le", 1, coords[0].cdelt2); 442 gfits_modify (header, "CRVAL1", "%lf", 1, coords[0].crval1); 443 gfits_modify (header, "CRVAL2", "%lf", 1, coords[0].crval2); 444 gfits_modify (header, "CRPIX1", "%lf", 1, coords[0].crpix1); 445 gfits_modify (header, "CRPIX2", "%lf", 1, coords[0].crpix2); 446 446 447 447 if (OldAIPS) { 448 448 Lambda = coords[0].cdelt2 / coords[0].cdelt1; 449 449 rotate = DEG_RAD*atan2 (coords[0].pc2_1*Lambda, coords[0].pc1_1); 450 fits_modify (header, "CROTA1", "%f", 1, rotate);451 fits_modify (header, "CROTA2", "%f", 1, rotate);450 gfits_modify (header, "CROTA1", "%f", 1, rotate); 451 gfits_modify (header, "CROTA2", "%f", 1, rotate); 452 452 return (TRUE); 453 453 } 454 454 455 fits_modify (header, "PC001001", "%le", 1, coords[0].pc1_1);456 fits_modify (header, "PC001002", "%le", 1, coords[0].pc1_2);457 fits_modify (header, "PC002001", "%le", 1, coords[0].pc2_1);458 fits_modify (header, "PC002002", "%le", 1, coords[0].pc2_2);459 fits_modify (header, "NPLYTERM", "%d", 1, coords[0].Npolyterms);455 gfits_modify (header, "PC001001", "%le", 1, coords[0].pc1_1); 456 gfits_modify (header, "PC001002", "%le", 1, coords[0].pc1_2); 457 gfits_modify (header, "PC002001", "%le", 1, coords[0].pc2_1); 458 gfits_modify (header, "PC002002", "%le", 1, coords[0].pc2_2); 459 gfits_modify (header, "NPLYTERM", "%d", 1, coords[0].Npolyterms); 460 460 461 461 /* RA Terms */ 462 462 if (coords[0].Npolyterms > 1) { 463 fits_modify (header, "PCA1X2Y0", "%le", 1, coords[0].polyterms[0][0]); /* polyterms[0]); */464 fits_modify (header, "PCA1X1Y1", "%le", 1, coords[0].polyterms[1][0]); /* polyterms[1]); */465 fits_modify (header, "PCA1X0Y2", "%le", 1, coords[0].polyterms[2][0]); /* polyterms[2]); */463 gfits_modify (header, "PCA1X2Y0", "%le", 1, coords[0].polyterms[0][0]); /* polyterms[0]); */ 464 gfits_modify (header, "PCA1X1Y1", "%le", 1, coords[0].polyterms[1][0]); /* polyterms[1]); */ 465 gfits_modify (header, "PCA1X0Y2", "%le", 1, coords[0].polyterms[2][0]); /* polyterms[2]); */ 466 466 } 467 467 if (coords[0].Npolyterms > 2) { 468 fits_modify (header, "PCA1X3Y0", "%le", 1, coords[0].polyterms[3][0]); /* polyterms[3]); */469 fits_modify (header, "PCA1X2Y1", "%le", 1, coords[0].polyterms[4][0]); /* polyterms[4]); */470 fits_modify (header, "PCA1X1Y2", "%le", 1, coords[0].polyterms[5][0]); /* polyterms[5]); */471 fits_modify (header, "PCA1X0Y3", "%le", 1, coords[0].polyterms[6][0]); /* polyterms[6]); */468 gfits_modify (header, "PCA1X3Y0", "%le", 1, coords[0].polyterms[3][0]); /* polyterms[3]); */ 469 gfits_modify (header, "PCA1X2Y1", "%le", 1, coords[0].polyterms[4][0]); /* polyterms[4]); */ 470 gfits_modify (header, "PCA1X1Y2", "%le", 1, coords[0].polyterms[5][0]); /* polyterms[5]); */ 471 gfits_modify (header, "PCA1X0Y3", "%le", 1, coords[0].polyterms[6][0]); /* polyterms[6]); */ 472 472 } 473 473 474 474 /* Dec Terms */ 475 475 if (coords[0].Npolyterms > 1) { 476 fits_modify (header, "PCA2X2Y0", "%le", 1, coords[0].polyterms[0][1]); /* polyterms[7]); */477 fits_modify (header, "PCA2X1Y1", "%le", 1, coords[0].polyterms[1][1]); /* polyterms[8]); */478 fits_modify (header, "PCA2X0Y2", "%le", 1, coords[0].polyterms[2][1]); /* polyterms[9]); */476 gfits_modify (header, "PCA2X2Y0", "%le", 1, coords[0].polyterms[0][1]); /* polyterms[7]); */ 477 gfits_modify (header, "PCA2X1Y1", "%le", 1, coords[0].polyterms[1][1]); /* polyterms[8]); */ 478 gfits_modify (header, "PCA2X0Y2", "%le", 1, coords[0].polyterms[2][1]); /* polyterms[9]); */ 479 479 } 480 480 if (coords[0].Npolyterms > 2) { 481 fits_modify (header, "PCA2X3Y0", "%le", 1, coords[0].polyterms[3][1]); /* polyterms[10]); */482 fits_modify (header, "PCA2X2Y1", "%le", 1, coords[0].polyterms[4][1]); /* polyterms[11]); */483 fits_modify (header, "PCA2X1Y2", "%le", 1, coords[0].polyterms[5][1]); /* polyterms[12]); */484 fits_modify (header, "PCA2X0Y3", "%le", 1, coords[0].polyterms[6][1]); /* polyterms[13]); */481 gfits_modify (header, "PCA2X3Y0", "%le", 1, coords[0].polyterms[3][1]); /* polyterms[10]); */ 482 gfits_modify (header, "PCA2X2Y1", "%le", 1, coords[0].polyterms[4][1]); /* polyterms[11]); */ 483 gfits_modify (header, "PCA2X1Y2", "%le", 1, coords[0].polyterms[5][1]); /* polyterms[12]); */ 484 gfits_modify (header, "PCA2X0Y3", "%le", 1, coords[0].polyterms[6][1]); /* polyterms[13]); */ 485 485 } 486 486 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
