- Timestamp:
- Feb 8, 2009, 5:32:23 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branch_20090113/psModules/src/astrom/pmAstrometryVisual.c
r21208 r21421 41 41 static int kapa2 = -1; 42 42 43 //helper prototypes 44 bool residPlot (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe, 45 char *title); 46 43 47 44 48 /* Initialization Routines */ … … 67 71 68 72 //set up plot region 69 if (!pmVisualInitWindow (&kapa, "psastro:plots")) 70 return false; 73 if (!pmVisualInitWindow (&kapa, "psastro:plots")){ 74 isVisual = false; 75 return false; 76 } 71 77 Graphdata graphdata; 72 78 KapaSection section; … … 231 237 232 238 //set up plotting variables 233 if (!pmVisualInitWindow (&kapa, "psastro:plots")) 234 return false; 239 if (!pmVisualInitWindow (&kapa, "psastro:plots")) { 240 isVisual = false; 241 return false; 242 } 235 243 236 244 Graphdata graphdata; … … 296 304 297 305 //set up plotting variables 298 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) 299 return false; 306 if ( !pmVisualInitWindow (&kapa, "psastro:plots")){ 307 isVisual = false; 308 return false; 309 } 300 310 301 311 Graphdata graphdata; … … 384 394 385 395 //set up plot variables 386 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) return false; 396 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) { 397 isVisual = false; 398 return false; 399 } 387 400 388 401 KapaSection section; … … 486 499 return true; 487 500 501 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 502 isVisual = false; 503 return false; 504 } 505 488 506 //plot the residuals 489 if (!pmVisualResidPlot(rawstars, refstars, match, recipe, "Single Chip Fit Residuals (Chip Coordinates)", &kapa, &kapa2)) 490 return false; 507 if (!residPlot(rawstars, refstars, match, recipe, "Single Chip Fit Residuals (Chip Coordinates)")) { 508 plotOneChipFit = false; 509 return false; 510 } 491 511 492 512 //ask for user input and finish … … 504 524 if(!isVisual || !plotFixChips) return true; 505 525 506 if(!pmVisualInitWindow(&kapa, "psastro:plots")) return false; 526 if(!pmVisualInitWindow(&kapa, "psastro:plots")) { 527 isVisual = false; 528 return false; 529 } 507 530 508 531 KapaSection section = {"s1", .05, .05, .9, .9}; … … 586 609 587 610 //set up graph window 588 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) 589 return false; 611 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) { 612 isVisual = false; 613 return false; 614 } 615 590 616 Graphdata graphdata; 591 617 KapaSection section; … … 670 696 { 671 697 //make sure we want to plot this 672 if (!isVisual || !plotCommonScale) return false; 673 674 if (!pmVisualInitWindow(&kapa, "psastro:plots")) return false; 698 if (!isVisual || !plotCommonScale) return true; 699 700 if (!pmVisualInitWindow(&kapa, "psastro:plots")){ 701 isVisual = false; 702 return false; 703 } 675 704 676 705 KapaSection section = {"s1", .05, .05, .9, .9}; … … 694 723 yVec->data.F32[nobj] = ptFP.y; 695 724 nobj++; 725 if (nobj == oldScale->n) break; 696 726 } 697 727 … … 707 737 708 738 pmVisualAskUser (&plotCommonScale, &isVisual); 739 740 psFree(xVec); 741 psFree(yVec); 742 709 743 return true; 710 744 } … … 716 750 717 751 //make sure we want to plot this 718 if (!isVisual || !plotMosaicOneChip) return false; 752 if (!isVisual || !plotMosaicOneChip) return true; 753 754 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 755 isVisual = false; 756 return false; 757 } 719 758 720 759 //plot the residuals 721 if (!pmVisualResidPlot(rawstars, refstars, match, recipe, "Single Chip Fit Residuals - Mosaic Mode", &kapa, &kapa2)) 722 return false; 760 if (!residPlot(rawstars, refstars, match, recipe, "Single Chip Fit Residuals - Mosaic Mode")) { 761 isVisual = false; 762 return false; 763 } 723 764 724 765 //ask for user input and finish … … 739 780 sprintf(title, "Matches found during psastroMosaicSetMatch iteration %d", iteration); 740 781 741 if (!pmVisualResidPlot(rawstars, refstars, match, recipe, title, &kapa, &kapa2)) 742 return false; 782 783 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 784 isVisual = false; 785 return false; 786 } 787 788 if (!residPlot(rawstars, refstars, match, recipe, title)){ 789 isVisual = false; 790 return false; 791 } 743 792 744 793 //ask for user input … … 759 808 //make sure we want to plot this 760 809 if (!isVisual || !plotGridMatch) return true; 761 if (!pmVisualInitWindow(&kapa, "pmAstrom:plots")) 762 return false; 810 if (!pmVisualInitWindow(&kapa, "psastro:plots")){ 811 isVisual = false; 812 return false; 813 } 763 814 764 815 KapaSection section = {"s1", 0.05, 0.05, .75, .75}; … … 768 819 Graphdata graphdata; 769 820 int nplot = raw->n * ref->n; // number of points to plot 770 float dXplot[nplot]; // x data points 771 float dYplot[nplot]; // y data points 821 psVector *dXplot = psVectorAlloc (nplot, PS_TYPE_F32); // x data points 822 psVector *dYplot = psVectorAlloc (nplot, PS_TYPE_F32); // y data points 823 772 824 pmAstromObj *ob1; pmAstromObj *ob2; // shortcuts to the data in raw and ref 773 825 psU32 **NP = gridNP->data.U32; // shortcut to the gridNP data … … 812 864 dX = ob1->FP->x - ob2->FP->x; 813 865 dY = ob1->FP->y - ob2->FP->y; 814 dXplot [(i * ref->n) + j] = dX;815 dYplot [(i * ref->n) + j] = dY;866 dXplot->data.F32[(i * ref->n) + j] = dX; 867 dYplot->data.F32[(i * ref->n) + j] = dY; 816 868 } 817 869 } … … 835 887 //Plot the offsets 836 888 KapaPrepPlot(kapa, nplot, &graphdata); 837 KapaPlotVector (kapa, nplot, dXplot , "x");838 KapaPlotVector (kapa, nplot, dYplot , "y");889 KapaPlotVector (kapa, nplot, dXplot->data.F32, "x"); 890 KapaPlotVector (kapa, nplot, dYplot->data.F32, "y"); 839 891 840 892 //Overplot bounding box, peak of distribution … … 900 952 901 953 pmVisualAskUser(&plotGridMatch, &isVisual); 954 psFree(dXplot); 955 psFree(dYplot); 902 956 return true; 903 957 } // end of pmAstromVisualPlotGridMatch … … 912 966 //make sure we want to plot this 913 967 if (!isVisual || !plotTweak) return true; 914 if (!pmVisualInitWindow(&kapa, "pmAstrom:plots")) { 968 if (!pmVisualInitWindow(&kapa, "psastro:plots")) { 969 isVisual = false; 915 970 return false; 916 971 } … … 1002 1057 } //end of pmAstromPlotTweak 1003 1058 1059 1060 bool residPlot (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe, 1061 char *title) { 1062 1063 1064 //initialize graph information 1065 Graphdata graphdata; 1066 KapaSection section; 1067 1068 KapaInitGraph (&graphdata); 1069 KapaClearPlots (kapa); 1070 1071 graphdata.color = KapaColorByName ("black"); 1072 graphdata.ptype = 7; 1073 graphdata.size = 0.5; 1074 graphdata.style = 2; 1075 1076 section.dx = 0.4; 1077 section.dy = 0.4; 1078 1079 //initialize and populate the plotting vectors 1080 bool status = false; 1081 float iMagMin = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.INST.MAG.MIN"); 1082 float iMagMax = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.INST.MAG.MAX"); 1083 float rMagMin = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.REF.MAG.MIN"); 1084 float rMagMax = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.REF.MAG.MAX"); 1085 1086 psVector *xVec = psVectorAlloc (match->n, PS_TYPE_F32); 1087 psVector *yVec = psVectorAlloc (match->n, PS_TYPE_F32); 1088 psVector *zVec = psVectorAlloc (match->n, PS_TYPE_F32); 1089 1090 // X vs dX 1091 section.x = 0.0; 1092 section.y = 0.5; 1093 section.name = NULL; 1094 psStringAppend (§ion.name, "a0"); 1095 KapaSetSection (kapa, §ion); 1096 psFree (section.name); 1097 1098 int n = 0; 1099 for (int i = 0; i < match->n; i++) { 1100 pmAstromMatch *pair = match->data[i]; 1101 pmAstromObj *raw = rawstars->data[pair->raw]; 1102 pmAstromObj *ref = refstars->data[pair->ref]; 1103 1104 if (!isfinite(raw->Mag)) continue; 1105 if (raw->Mag < iMagMin) continue; 1106 if (raw->Mag > iMagMax) continue; 1107 if (ref->Mag < rMagMin) continue; 1108 if (ref->Mag > rMagMax) continue; 1109 1110 xVec->data.F32[n] = raw->chip->x; 1111 yVec->data.F32[n] = raw->chip->x - ref->chip->x; 1112 zVec->data.F32[n] = raw->Mag; 1113 n++; 1114 } 1115 xVec->n = yVec->n = zVec->n = n; 1116 1117 KapaSendLabel (kapa, "X", KAPA_LABEL_XM); 1118 KapaSendLabel (kapa, "dX", KAPA_LABEL_YM); 1119 pmVisualTriplePlot (kapa, &graphdata, xVec, yVec, zVec, false); 1120 1121 // X vs dY 1122 section.x = 0.5; 1123 section.y = 0.5; 1124 section.name = NULL; 1125 psStringAppend (§ion.name, "a1"); 1126 KapaSetSection (kapa, §ion); 1127 psFree (section.name); 1128 1129 n = 0; 1130 for (int i = 0; i < match->n; i++) { 1131 pmAstromMatch *pair = match->data[i]; 1132 pmAstromObj *raw = rawstars->data[pair->raw]; 1133 pmAstromObj *ref = refstars->data[pair->ref]; 1134 1135 if (!isfinite(raw->Mag)) continue; 1136 if (raw->Mag < iMagMin) continue; 1137 if (raw->Mag > iMagMax) continue; 1138 if (ref->Mag < rMagMin) continue; 1139 if (ref->Mag > rMagMax) continue; 1140 1141 xVec->data.F32[n] = raw->chip->x; 1142 yVec->data.F32[n] = raw->chip->y - ref->chip->y; 1143 zVec->data.F32[n] = raw->Mag; 1144 n++; 1145 } 1146 xVec->n = yVec->n = zVec->n = n; 1147 1148 KapaSendLabel (kapa, "X", KAPA_LABEL_XM); 1149 KapaSendLabel (kapa, "dY", KAPA_LABEL_YM); 1150 pmVisualTriplePlot (kapa, &graphdata, xVec, yVec, zVec, false); 1151 1152 // Y vs dX 1153 section.x = 0.0; 1154 section.y = 0.0; 1155 section.name = NULL; 1156 psStringAppend (§ion.name, "a2"); 1157 KapaSetSection (kapa, §ion); 1158 psFree (section.name); 1159 1160 n = 0; 1161 for (int i = 0; i < match->n; i++) { 1162 pmAstromMatch *pair = match->data[i]; 1163 pmAstromObj *raw = rawstars->data[pair->raw]; 1164 pmAstromObj *ref = refstars->data[pair->ref]; 1165 1166 if (!isfinite(raw->Mag)) continue; 1167 if (raw->Mag < iMagMin) continue; 1168 if (raw->Mag > iMagMax) continue; 1169 if (ref->Mag < rMagMin) continue; 1170 if (ref->Mag > rMagMax) continue; 1171 1172 xVec->data.F32[n] = raw->chip->y; 1173 yVec->data.F32[n] = raw->chip->x - ref->chip->x; 1174 zVec->data.F32[n] = raw->Mag; 1175 n++; 1176 } 1177 xVec->n = yVec->n = zVec->n = n; 1178 1179 KapaSendLabel (kapa, "Y", KAPA_LABEL_XM); 1180 KapaSendLabel (kapa, "dX", KAPA_LABEL_YM); 1181 pmVisualTriplePlot (kapa, &graphdata, xVec, yVec, zVec, false); 1182 1183 // Y vs dY 1184 section.x = 0.5; 1185 section.y = 0.0; 1186 section.name = NULL; 1187 psStringAppend (§ion.name, "a3"); 1188 KapaSetSection (kapa, §ion); 1189 psFree (section.name); 1190 1191 n = 0; 1192 for (int i = 0; i < match->n; i++) { 1193 pmAstromMatch *pair = match->data[i]; 1194 pmAstromObj *raw = rawstars->data[pair->raw]; 1195 pmAstromObj *ref = refstars->data[pair->ref]; 1196 1197 if (!isfinite(raw->Mag)) continue; 1198 if (raw->Mag < iMagMin) continue; 1199 if (raw->Mag > iMagMax) continue; 1200 if (ref->Mag < rMagMin) continue; 1201 if (ref->Mag > rMagMax) continue; 1202 1203 xVec->data.F32[n] = raw->chip->y; 1204 yVec->data.F32[n] = raw->chip->y - ref->chip->y; 1205 zVec->data.F32[n] = raw->Mag; 1206 n++; 1207 } 1208 xVec->n = yVec->n = zVec->n = n; 1209 1210 KapaSendLabel (kapa, "Y", KAPA_LABEL_XM); 1211 KapaSendLabel (kapa, "dY", KAPA_LABEL_YM); 1212 pmKapaPlotVectorTriple_AutoLimits_OpenGraph (kapa, &graphdata, xVec, yVec, zVec, false); 1213 1214 section.x = 0.0; 1215 section.y = 0.0; 1216 section.dx = 0.95; 1217 section.dy = 0.95; 1218 section.name = NULL; 1219 psStringAppend (§ion.name, "a5"); 1220 KapaSetSection (kapa, §ion); 1221 KapaSendLabel (kapa, title, KAPA_LABEL_XP); 1222 psFree (section.name); 1223 1224 //second window 1225 1226 KapaInitGraph (&graphdata); 1227 KapaClearPlots (kapa2); 1228 1229 graphdata.color = KapaColorByName ("black"); 1230 graphdata.ptype = 2; 1231 graphdata.style = 2; 1232 1233 psFree (xVec); 1234 psFree (yVec); 1235 psFree (zVec); 1236 1237 xVec = psVectorAlloc (rawstars->n, PS_TYPE_F32); 1238 yVec = psVectorAlloc (rawstars->n, PS_TYPE_F32); 1239 zVec = psVectorAlloc (rawstars->n, PS_TYPE_F32); 1240 1241 // X vs Y by mag (raw) 1242 n = 0; 1243 for (int i = 0; i < rawstars->n; i++) { 1244 pmAstromObj *raw = rawstars->data[i]; 1245 if (!isfinite(raw->Mag)) continue; 1246 if (raw->Mag < iMagMin) continue; 1247 if (raw->Mag > iMagMax) continue; 1248 1249 xVec->data.F32[n] = raw->chip->x; 1250 yVec->data.F32[n] = raw->chip->y; 1251 zVec->data.F32[n] = raw->Mag; 1252 n++; 1253 } 1254 xVec->n = yVec->n = zVec->n = n; 1255 1256 KapaSendLabel (kapa2, "X", KAPA_LABEL_XM); 1257 KapaSendLabel (kapa2, "Y", KAPA_LABEL_YM); 1258 KapaSendLabel (kapa2, 1259 "Chip Coordinates. Black = Raw Stars. Red = Ref Stars. Blue = Matched Stars" 1260 , KAPA_LABEL_XP); 1261 pmVisualTriplePlot (kapa2, &graphdata, xVec, yVec, zVec, false); 1262 1263 // X vs Y by mag (ref) 1264 psFree (xVec); 1265 psFree (yVec); 1266 psFree (zVec); 1267 1268 xVec = psVectorAlloc (refstars->n, PS_TYPE_F32); 1269 yVec = psVectorAlloc (refstars->n, PS_TYPE_F32); 1270 zVec = psVectorAlloc (refstars->n, PS_TYPE_F32); 1271 1272 graphdata.color = KapaColorByName ("red"); 1273 graphdata.ptype = 7; 1274 graphdata.style = 2; 1275 1276 n = 0; 1277 for (int i = 0; i < refstars->n; i++) { 1278 pmAstromObj *ref = refstars->data[i]; 1279 if (!isfinite(ref->Mag)) continue; 1280 if (ref->Mag < rMagMin) continue; 1281 if (ref->Mag > rMagMax) continue; 1282 1283 xVec->data.F32[n] = ref->chip->x; 1284 yVec->data.F32[n] = ref->chip->y; 1285 zVec->data.F32[n] = ref->Mag; 1286 n++; 1287 } 1288 xVec->n = yVec->n = zVec->n = n; 1289 pmVisualTripleOverplot (kapa2, &graphdata, xVec, yVec, zVec, false); 1290 1291 //rescale the graph to include all points 1292 float xmin = graphdata.xmin; 1293 float ymin = graphdata.ymin; 1294 float xmax = graphdata.xmax; 1295 float ymax = graphdata.ymax; 1296 pmVisualScaleGraphdata(&graphdata, xVec, yVec, true); 1297 graphdata.xmin = PS_MIN(xmin, graphdata.xmin); 1298 graphdata.ymin = PS_MIN(ymin, graphdata.ymin); 1299 graphdata.xmax = PS_MAX(xmax, graphdata.xmax); 1300 graphdata.ymax = PS_MAX(ymax, graphdata.ymax); 1301 KapaSetLimits (kapa2, &graphdata); 1302 1303 //overplot matched stars in blue 1304 psFree (xVec); 1305 psFree (yVec); 1306 psFree (zVec); 1307 1308 xVec = psVectorAlloc (match->n, PS_TYPE_F32); 1309 yVec = psVectorAlloc (match->n, PS_TYPE_F32); 1310 zVec = psVectorAlloc (match->n, PS_TYPE_F32); 1311 1312 graphdata.color = KapaColorByName ("blue"); 1313 n = 0; 1314 for (int i = 0; i < match->n; i++) { 1315 pmAstromMatch *pair = match->data[i]; 1316 pmAstromObj *raw = rawstars->data[pair->raw]; 1317 pmAstromObj *ref = refstars->data[pair->ref]; 1318 if (raw->Mag < iMagMin) continue; 1319 if (raw->Mag > iMagMax) continue; 1320 if (ref->Mag < rMagMin) continue; 1321 if (ref->Mag > rMagMax) continue; 1322 1323 xVec->data.F32[n] = raw->chip->x; 1324 yVec->data.F32[n] = raw->chip->y; 1325 zVec->data.F32[n] = iMagMin; 1326 n++; 1327 } 1328 xVec->n = yVec->n = zVec->n = n; 1329 pmVisualTripleOverplot (kapa2, &graphdata, xVec, yVec, zVec, false); 1330 1331 psFree (xVec); 1332 psFree (yVec); 1333 psFree (zVec); 1334 return true; 1335 } 1336 1337 1338 1339 1004 1340 # else 1005 1341
Note:
See TracChangeset
for help on using the changeset viewer.
