Changeset 38183
- Timestamp:
- Apr 24, 2015, 3:40:47 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150419/Ohana/src/libdvo
- Files:
-
- 2 edited
-
include/libdvo_astro.h (modified) (1 diff)
-
src/coordops.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/include/libdvo_astro.h
r37807 r38183 26 26 PROJ_GLS, // pseudocyl 27 27 PROJ_PAR, // pseudocyl 28 PROJ_ZPN, // zenithal 28 29 } OhanaProjection; 29 30 -
branches/eam_branches/ipp-20150419/Ohana/src/libdvo/src/coordops.c
r37807 r38183 1 1 # include <dvo.h> 2 # define UKIRT_ONLY 1 2 3 3 4 /* note that Coords.ctype carries the DEC (ctype2) value */ … … 81 82 82 83 /** extra polynomial terms **/ 83 if ( coords[0].Npolyterms > 1) {84 if ((coords[0].Npolyterms > 1) && (proj != PROJ_ZPN)) { 84 85 X2 = X*X; 85 86 Y2 = Y*Y; … … 171 172 stht = cos (RAD_DEG * R); 172 173 break; 174 175 case PROJ_ZPN: 176 // R = 90 - theta (degrees) 177 // this is wrong because we are ignoring the distortion 178 // XXX For now, just solve for terms up to n = 3 179 180 // Ro = (pi/180)(90 - theta) 181 // R = (180/pi)sum (P_i R^i) 182 183 if (UKIRT_ONLY) { 184 double Ro = RAD_DEG * R; 185 double P1 = coords[0].polyterms[0][1]; 186 double P3 = coords[0].polyterms[0][3]; 187 188 // find the roots of f(gamma) = P1 gamma + P3 gamma^3 - Ro 189 // starting guess for gamma is Ro / P1 190 double gamma = Ro / P1; 191 192 int i; 193 for (i = 0; i < 5; i++) { 194 double F = P1*gamma + P3*gamma*gamma*gamma - Ro; 195 double dFdgamma = P1 + 3.0*P3*gamma*gamma; 196 197 double gamma_new = gamma - F / dFdgamma; 198 gamma = gamma_new; 199 } 200 201 double theta = 90.0 - gamma * DEG_RAD ; 202 ctht = cos (RAD_DEG * theta); 203 stht = sin (RAD_DEG * theta); 204 break; 205 } 206 173 207 case PROJ_ZEA: 174 208 case PROJ_ZPL: … … 238 272 int RD_to_LM (double *L, double *M, double ra, double dec, Coords *coords) { 239 273 274 int i; 240 275 double phi, theta; 241 276 double sphi, cphi, stht, ctht; … … 303 338 *M = -DEG_RAD * cphi; 304 339 return (stht > 0); 340 305 341 case PROJ_ARC: 306 342 // R = 90 - theta … … 311 347 *M = (ctht == 0.0) ? 0.0 : -Rc * cphi / ctht ; 312 348 return (TRUE); 349 350 case PROJ_ZPN: 351 // Ro = (pi/180)(90 - theta) 352 // R = (180/pi)sum (P_i R^i) 353 ctht = hypot(sphi, cphi); 354 theta = atan2 (stht, ctht); 355 356 double Rc; 357 if (UKIRT_ONLY) { 358 double P1 = coords[0].polyterms[0][1]; 359 double P3 = coords[0].polyterms[0][3]; 360 double gamma = RAD_DEG * (90 - DEG_RAD * theta); 361 Rc = P1*gamma + P3*gamma*gamma*gamma; 362 } else { 363 double Ro = RAD_DEG * (90 - DEG_RAD * theta); 364 365 // i = 0 .. Npolyterms - 1 (1 <= Npolyterms <= 21) 366 i = coords[0].Npolyterms - 1; 367 Rc = 0.0; 368 while (i > 0) { 369 if (i < 7) { 370 Rc = (Rc + coords[0].polyterms[0][i])*Ro; 371 } else { 372 Rc = (Rc + coords[0].polyterms[1][i-7])*Ro; 373 } 374 i --; 375 } 376 Rc += coords[0].polyterms[0][i]; 377 } 378 Rc = DEG_RAD * Rc; 379 380 *L = (ctht == 0.0) ? 0.0 : +Rc * sphi / ctht ; 381 *M = (ctht == 0.0) ? 0.0 : -Rc * cphi / ctht ; 382 return (TRUE); 383 313 384 case PROJ_ZEA: 314 385 case PROJ_ZPL: … … 386 457 387 458 /** extra polynomial terms **/ 388 if (coords[0].Npolyterms > 1) { 459 // polyterm values are only valid for some projections. for PROJ_ZPN, they are applied to R, not X,Y 460 if ((coords[0].Npolyterms > 1) && (proj != PROJ_ZPN)) { 389 461 for (i = 0; i < 10; i++) { 390 462 // find derivatives at Xo, Yo … … 531 603 int GetCoords (Coords *coords, Header *header) { 532 604 533 int status, status1, status2, itmp, Polynomial, Polyterm;605 int i, status, status1, status2, itmp, Polynomial, Polyterm; 534 606 double Lambda, rotate, rotate1, rotate2, scale; 535 607 double equinox; … … 663 735 coords[0].pc2_1 /= scale; 664 736 coords[0].pc2_2 /= scale; 737 738 if (!strcmp (&coords[0].ctype[4], "-ZPN")) { 739 int found; 740 for (i = 0; i < 14; i++) { 741 char name[64]; 742 sprintf (name, "PV2_%d", i); 743 if (i < 7) { 744 found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[0][i]); 745 } else { 746 found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[1][i-7]); 747 } 748 if ((i == 0) && !found) { 749 coords[0].polyterms[0][0] = 0.0; 750 continue; 751 } 752 if ((i == 1) && !found) { 753 coords[0].polyterms[0][1] = 1.0; 754 continue; 755 } 756 if (!found) { 757 coords[0].Npolyterms = i; 758 break; 759 } 760 } 761 } 665 762 break; 666 763 … … 895 992 if (!strcmp(&ctype[4], "-ZEA")) return PROJ_ZEA; 896 993 if (!strcmp(&ctype[4], "-ZPL")) return PROJ_ZPL; 994 if (!strcmp(&ctype[4], "-ZPN")) return PROJ_ZPN; 897 995 if (!strcmp(&ctype[4], "-ARC")) return PROJ_ARC; 898 996 if (!strcmp(&ctype[4], "-STG")) return PROJ_STG; … … 916 1014 case PROJ_ZEA: strcpy(&ctype[4], "-ZEA"); return TRUE; 917 1015 case PROJ_ZPL: strcpy(&ctype[4], "-ZPL"); return TRUE; 1016 case PROJ_ZPN: strcpy(&ctype[4], "-ZPN"); return TRUE; 918 1017 case PROJ_ARC: strcpy(&ctype[4], "-ARC"); return TRUE; 919 1018 case PROJ_STG: strcpy(&ctype[4], "-STG"); return TRUE; … … 937 1036 case PROJ_ZEA: 938 1037 case PROJ_ZPL: 1038 case PROJ_ZPN: 939 1039 case PROJ_ARC: 940 1040 case PROJ_STG:
Note:
See TracChangeset
for help on using the changeset viewer.
