- Timestamp:
- Oct 11, 2021, 11:33:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-dev-20210817/psLib/src/astro/psCoord.c
r41531 r41831 40 40 #include "psMinimizePolyFit.h" 41 41 42 # define TEST_SAVE_INVERSE_TRANSFORM 0 43 44 # if (TEST_SAVE_INVERSE_TRANSFORM) 45 # include "psBinaryOp.h" 46 # endif 47 42 48 # define ELIXIR_CODE 1 43 49 … … 86 92 } 87 93 88 psPlaneTransform *out = psPlaneTransformAlloc(1, 1); 94 // since the output polynomial is 1st order, a Chebyshev is not really useful 95 psPlaneTransform *out = psPlaneTransformAlloc(1, 1, PS_POLYNOMIAL_ORD); 89 96 90 97 psF64 r12 = 0.0; … … 191 198 } 192 199 193 psPlaneTransform* psPlaneTransformAlloc(int order1, int order2 )200 psPlaneTransform* psPlaneTransformAlloc(int order1, int order2, psPolynomialType type) 194 201 { 195 202 PS_ASSERT_INT_NONNEGATIVE(order1, NULL); … … 198 205 psPlaneTransform *pt = psAlloc(sizeof(psPlaneTransform)); 199 206 200 pt->x = psPolynomial2DAlloc( PS_POLYNOMIAL_ORD, order1, order2);201 pt->y = psPolynomial2DAlloc( PS_POLYNOMIAL_ORD, order1, order2);207 pt->x = psPolynomial2DAlloc(type, order1, order2); 208 pt->y = psPolynomial2DAlloc(type, order1, order2); 202 209 203 210 psMemSetDeallocator(pt, (psFreeFunc) planeTransformFree); … … 797 804 } 798 805 806 // both polynomials in both input transforms must match type -- and for now be ORD 807 psAssert (trans1->x->type == PS_POLYNOMIAL_ORD, "fix for CHEB"); 808 psAssert (trans1->y->type == PS_POLYNOMIAL_ORD, "fix for CHEB"); 809 psAssert (trans2->x->type == PS_POLYNOMIAL_ORD, "fix for CHEB"); 810 psAssert (trans2->y->type == PS_POLYNOMIAL_ORD, "fix for CHEB"); 811 799 812 // 800 813 // Determine the size of the new psPlaneTransform. … … 814 827 psPlaneTransform *myPT = NULL; 815 828 if (out == NULL) { 816 myPT = psPlaneTransformAlloc(orderX, orderY);829 myPT = psPlaneTransformAlloc(orderX, orderY, PS_POLYNOMIAL_ORD); 817 830 } else { 818 831 if ((out->x->nX == orderX) && … … 834 847 } else { 835 848 psFree(out); 836 myPT = psPlaneTransformAlloc(orderX, orderY );849 myPT = psPlaneTransformAlloc(orderX, orderY, PS_POLYNOMIAL_ORD); 837 850 } 838 851 } … … 1037 1050 psPlaneTransform *myPT = NULL; 1038 1051 if (out == NULL) { 1039 myPT = psPlaneTransformAlloc(order, order);1052 myPT = psPlaneTransformAlloc(order, order, PS_POLYNOMIAL_CHEB); 1040 1053 } else { 1041 1054 // the user has supplied a model with a specific order : fit that order … … 1071 1084 result &= psVectorFitPolynomial2D(myPT->x, NULL, 0, xOut, NULL, xIn, yIn); 1072 1085 result &= psVectorFitPolynomial2D(myPT->y, NULL, 0, yOut, NULL, xIn, yIn); 1086 1087 # if (TEST_SAVE_INVERSE_TRANSFORM) 1088 1089 psVector *xFit = psPolynomial2DEvalVector (myPT->x, xIn, yIn); 1090 psVector *xRes = (psVector *) psBinaryOp (NULL, xOut, "-", xFit); 1091 1092 psVector *yFit = psPolynomial2DEvalVector (myPT->y, xIn, yIn); 1093 psVector *yRes = (psVector *) psBinaryOp (NULL, yOut, "-", yFit); 1094 1095 static int nOut = 0; 1096 char filename[1024]; 1097 snprintf (filename, 1024, "test.fit.%03d.ply", nOut); 1098 FILE *fp = fopen (filename, "w"); 1099 1100 fprintf (fp, " ---- xFit ---- \n"); 1101 1102 for (int ix = 0; ix < myPT->x->nX + 1; ix++) { 1103 for (int iy = 0; iy < myPT->x->nY + 1; iy++) { 1104 fprintf (fp, "%18.12e ", myPT->x->coeff[ix][iy]); 1105 } 1106 fprintf (fp, "\n"); 1107 } 1108 fprintf (fp, " ---- yFit ---- \n"); 1109 1110 for (int ix = 0; ix < myPT->y->nX + 1; ix++) { 1111 for (int iy = 0; iy < myPT->y->nY + 1; iy++) { 1112 fprintf (fp, "%18.12e ", myPT->y->coeff[ix][iy]); 1113 } 1114 fprintf (fp, "\n"); 1115 } 1116 fclose (fp); 1117 1118 snprintf (filename, 1024, "test.fit.%03d.dat", nOut); nOut ++; 1119 FILE *f1 = fopen (filename, "w"); 1120 for (int i = 0; i < xFit->n; i++) { 1121 fprintf (f1, "%d : %f %f : %f %f : %f %f : %f %f\n", i, 1122 xIn->data.F64[i], yIn->data.F64[i], 1123 xOut->data.F64[i], yOut->data.F64[i], 1124 xFit->data.F64[i], yFit->data.F64[i], 1125 xRes->data.F64[i], yRes->data.F64[i]); 1126 } 1127 fclose (f1); 1128 1129 psStats *myStats = psStatsAlloc (PS_STAT_SAMPLE_STDEV); 1130 psVectorStats (myStats, xRes, NULL, NULL, 0); float dX = myStats->sampleStdev; 1131 psVectorStats (myStats, yRes, NULL, NULL, 0); float dY = myStats->sampleStdev; 1132 fprintf (stderr, "xRes Sigma: %f -- yRes Sigma %f\n", dX, dY); 1133 1134 psFree (myStats); 1135 psFree (xFit); 1136 psFree (yFit); 1137 psFree (xRes); 1138 psFree (yRes); 1139 1140 # endif 1073 1141 1074 1142 psFree(inCoord);
Note:
See TracChangeset
for help on using the changeset viewer.
