Changeset 26492
- Timestamp:
- Dec 29, 2009, 11:06:35 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryWCS.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryWCS.c
r25876 r26492 378 378 // XXX make it optional to write out CDi_j terms, or other versions 379 379 // apply CDELT1,2 (degrees / pixel) to yield PCi,j terms of order unity 380 if (! (wcs->wcsCDkeys)) {380 if (!wcs->wcsCDkeys) { 381 381 382 382 double cdelt1 = wcs->cdelt1; … … 419 419 psMetadataRemoveKey(header, "CD2_2"); 420 420 } 421 } 422 if (wcs->wcsCDkeys) { 421 } else { 423 422 424 423 psMetadataAddF64 (header, PS_LIST_TAIL, "CD1_1", PS_META_REPLACE, "", wcs->trans->x->coeff[1][0]); … … 845 844 int k=0; 846 845 for (int j=0; j<nSamples; j++) { 847 double y = j * deltaY / nSamples;846 double y = bounds->y0 + (j * deltaY / nSamples); 848 847 for (int i=0; i<nSamples; i++) { 849 848 psPlane *s = psPlaneAlloc(); 850 s->x = i * deltaX / nSamples;849 s->x = bounds->x0 + (i * deltaX / nSamples); 851 850 s->y = y; 852 851 psArraySet(src, k, s); 853 852 psPlane *d = psPlaneTransformApply(NULL, trans, s); 854 853 psArraySet(dst, k, d); 855 psFree(s); 854 psFree(s); // drop our refs to s and d 856 855 psFree(d); 857 856 ++k; … … 869 868 // compare the computed coordintes from this transform with the original 870 869 psPlane *new = psPlaneAlloc(); 870 printf(" i chip_x fpa_x fpa_x_fit dx chip_y fpa_y fpa_y_fit dy dx > 0.5 || dy > 0.5\n"); 871 871 for (int i=0; i<psArrayLength(dst); i++) { 872 872 psPlane *d = (psPlane *) psArrayGet(dst, i); … … 875 875 new = psPlaneTransformApply(new, newTrans, s); 876 876 877 printf("%4d %f %f\n", i, 100.*(new->x - d->x)/d->x, 100.*(new->y - d->y)/d->y); 877 double xerr = new->x - d->x; 878 double yerr = new->y - d->y; 879 bool bigerr = (fabs(xerr) > .5) || (fabs(yerr) > .5); 880 printf("%4d %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %s\n" 881 , i, s->x, new->x, d->x, xerr, s->y, new->y, d->y, yerr, bigerr ? "BIGERR" : ""); 878 882 } 879 883 psFree(new); … … 891 895 psRegion *chipBounds = pmChipPixels(chip); 892 896 893 psPlaneTransform *newToFPA = linearFitToTransform(chip->toFPA, chipBounds); 897 #ifdef TESTING_CAMRUN_14728 898 chipBounds->y0 = 1874.; 899 chipBounds->x1 = 2387.; 900 #endif 901 902 // First combine the chip to FPA and FPA to TPA into a single transformation 903 psPlaneTransform *chipToTPA = psPlaneTransformCombine(NULL, chip->toFPA, fpa->toTPA, *chipBounds, 50); 904 if (!chipToTPA) { 905 psFree(chipBounds); 906 psError(PS_ERR_UNKNOWN, false, "failed to create chipToTPA"); 907 return false; 908 } 909 910 // Next do a linear fit 911 psPlaneTransform *newToFPA = linearFitToTransform(chipToTPA, chipBounds); 912 psFree(chipToTPA); 894 913 if (!newToFPA) { 895 914 psFree(chipBounds); 896 psError(PS_ERR_UNKNOWN, false, "linear fit for toFPA failed"); 897 return false; 898 } 915 psError(PS_ERR_UNKNOWN, false, "linear fit of chip to TPA transform failed"); 916 return false; 917 } 918 919 psPlaneTransform *newFromFPA = psPlaneTransformInvert(NULL, newToFPA, *chipBounds, 50); 920 psFree(chipBounds); 921 if (!newFromFPA) { 922 psFree(newToFPA); 923 psError(PS_ERR_UNKNOWN, false, "inversion of fit of chip to TPA transform failed"); 924 return false; 925 } 926 927 // Success. Now set the fpa's toTPA and fromTPA to identity and replace the chip's transforms. 928 929 psPlaneTransform *newToTPA = psPlaneTransformIdentity(1); 930 psFree(fpa->toTPA); 931 fpa->toTPA = newToTPA; 932 933 psPlaneTransform *newFromTPA = psPlaneTransformIdentity(1); 934 psFree(fpa->fromTPA); 935 fpa->fromTPA = newFromTPA; 899 936 900 937 psFree(chip->toFPA); … … 902 939 903 940 psFree(chip->fromFPA); 904 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *chipBounds, 50); 905 if (!chip->fromFPA) { 906 psError(PS_ERR_UNKNOWN, false, "failed to invert linear fit for toFPA"); 907 return false; 908 } 909 910 psPlane *chip0 = psPlaneAlloc(); 911 chip0->x = 0; 912 chip0->y = 0; 913 psPlane *chip1 = psPlaneAlloc(); 914 chip1->x = chipBounds->x1; 915 chip1->y = chipBounds->y1; 916 917 // compute bounding region for fpa 918 psPlane *fpa0 = psPlaneTransformApply(NULL, newToFPA, chip0); 919 psPlane *fpa1 = psPlaneTransformApply(NULL, newToFPA, chip1); 920 921 psRegion *fpaBounds = psRegionAlloc(fpa0->x, fpa1->x, fpa0->y, fpa1->y); 922 psFree(chip0); 923 psFree(chip1); 924 psFree(fpa0); 925 psFree(fpa1); 926 927 psPlaneTransform *newToTPA = linearFitToTransform(fpa->toTPA, fpaBounds); 928 if (!newToTPA) { 929 psError(PS_ERR_UNKNOWN, false, "failed to perform linear fit to toTPA"); 930 psFree(fpaBounds); 931 return false; 932 } 933 psFree(fpa->toTPA); 934 fpa->toTPA = newToTPA; 935 936 // XXX: is this region ok? 937 psFree(fpa->fromTPA); 938 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *fpaBounds, 50); 939 if (!fpa->fromTPA) { 940 psError(PS_ERR_UNKNOWN, false, "failed to invert linear fit to toTPA"); 941 return false; 942 } 943 941 chip->fromFPA = newFromFPA; 942 943 // Finally change the type for the projection. 944 944 fpa->toSky->type = PS_PROJ_TAN; 945 946 psFree(chipBounds);947 psFree(fpaBounds);948 945 949 946 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
