Changeset 21421
- Timestamp:
- Feb 8, 2009, 5:32:23 PM (17 years ago)
- Location:
- branches/cnb_branch_20090113/psModules/src
- Files:
-
- 3 edited
-
astrom/pmAstrometryVisual.c (modified) (20 diffs)
-
extras/pmVisual.c (modified) (2 diffs)
-
extras/pmVisual.h (modified) (1 diff)
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 -
branches/cnb_branch_20090113/psModules/src/extras/pmVisual.c
r21208 r21421 33 33 *kapid = KapaOpenNamedSocket("kapa", name); 34 34 if (*kapid == -1) { 35 fprintf (stderr, " failure to open kapa; visual mode disabled.\n");35 fprintf (stderr, "Failure to open kapa.\n"); 36 36 return false; 37 37 } … … 181 181 182 182 183 bool pmVisualResidPlot (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe,184 char *title, int *kapa, int *kapa2) {185 186 //set up the first window187 if (!pmVisualInitWindow(kapa, "plots")) return false;188 189 //initialize graph information190 Graphdata graphdata;191 KapaSection section;192 193 KapaInitGraph (&graphdata);194 KapaClearPlots (*kapa);195 196 graphdata.color = KapaColorByName ("black");197 graphdata.ptype = 7;198 graphdata.size = 0.5;199 graphdata.style = 2;200 201 section.dx = 0.4;202 section.dy = 0.4;203 204 //initialize and populate the plotting vectors205 bool status = false;206 float iMagMin = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.INST.MAG.MIN");207 float iMagMax = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.INST.MAG.MAX");208 float rMagMin = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.REF.MAG.MIN");209 float rMagMax = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLOT.REF.MAG.MAX");210 211 psVector *xVec = psVectorAlloc (match->n, PS_TYPE_F32);212 psVector *yVec = psVectorAlloc (match->n, PS_TYPE_F32);213 psVector *zVec = psVectorAlloc (match->n, PS_TYPE_F32);214 215 // X vs dX216 section.x = 0.0;217 section.y = 0.5;218 section.name = NULL;219 psStringAppend (§ion.name, "a0");220 KapaSetSection (*kapa, §ion);221 psFree (section.name);222 223 int n = 0;224 for (int i = 0; i < match->n; i++) {225 pmAstromMatch *pair = match->data[i];226 pmAstromObj *raw = rawstars->data[pair->raw];227 pmAstromObj *ref = refstars->data[pair->ref];228 229 if (!isfinite(raw->Mag)) continue;230 if (raw->Mag < iMagMin) continue;231 if (raw->Mag > iMagMax) continue;232 if (ref->Mag < rMagMin) continue;233 if (ref->Mag > rMagMax) continue;234 235 xVec->data.F32[n] = raw->chip->x;236 yVec->data.F32[n] = raw->chip->x - ref->chip->x;237 zVec->data.F32[n] = raw->Mag;238 n++;239 }240 xVec->n = yVec->n = zVec->n = n;241 242 KapaSendLabel (*kapa, "X", KAPA_LABEL_XM);243 KapaSendLabel (*kapa, "dX", KAPA_LABEL_YM);244 pmVisualTriplePlot (*kapa, &graphdata, xVec, yVec, zVec, false);245 246 // X vs dY247 section.x = 0.5;248 section.y = 0.5;249 section.name = NULL;250 psStringAppend (§ion.name, "a1");251 KapaSetSection (*kapa, §ion);252 psFree (section.name);253 254 n = 0;255 for (int i = 0; i < match->n; i++) {256 pmAstromMatch *pair = match->data[i];257 pmAstromObj *raw = rawstars->data[pair->raw];258 pmAstromObj *ref = refstars->data[pair->ref];259 260 if (!isfinite(raw->Mag)) continue;261 if (raw->Mag < iMagMin) continue;262 if (raw->Mag > iMagMax) continue;263 if (ref->Mag < rMagMin) continue;264 if (ref->Mag > rMagMax) continue;265 266 xVec->data.F32[n] = raw->chip->x;267 yVec->data.F32[n] = raw->chip->y - ref->chip->y;268 zVec->data.F32[n] = raw->Mag;269 n++;270 }271 xVec->n = yVec->n = zVec->n = n;272 273 KapaSendLabel (*kapa, "X", KAPA_LABEL_XM);274 KapaSendLabel (*kapa, "dY", KAPA_LABEL_YM);275 pmVisualTriplePlot (*kapa, &graphdata, xVec, yVec, zVec, false);276 277 // Y vs dX278 section.x = 0.0;279 section.y = 0.0;280 section.name = NULL;281 psStringAppend (§ion.name, "a2");282 KapaSetSection (*kapa, §ion);283 psFree (section.name);284 285 n = 0;286 for (int i = 0; i < match->n; i++) {287 pmAstromMatch *pair = match->data[i];288 pmAstromObj *raw = rawstars->data[pair->raw];289 pmAstromObj *ref = refstars->data[pair->ref];290 291 if (!isfinite(raw->Mag)) continue;292 if (raw->Mag < iMagMin) continue;293 if (raw->Mag > iMagMax) continue;294 if (ref->Mag < rMagMin) continue;295 if (ref->Mag > rMagMax) continue;296 297 xVec->data.F32[n] = raw->chip->y;298 yVec->data.F32[n] = raw->chip->x - ref->chip->x;299 zVec->data.F32[n] = raw->Mag;300 n++;301 }302 xVec->n = yVec->n = zVec->n = n;303 304 KapaSendLabel (*kapa, "Y", KAPA_LABEL_XM);305 KapaSendLabel (*kapa, "dX", KAPA_LABEL_YM);306 pmVisualTriplePlot (*kapa, &graphdata, xVec, yVec, zVec, false);307 308 // Y vs dY309 section.x = 0.5;310 section.y = 0.0;311 section.name = NULL;312 psStringAppend (§ion.name, "a3");313 KapaSetSection (*kapa, §ion);314 psFree (section.name);315 316 n = 0;317 for (int i = 0; i < match->n; i++) {318 pmAstromMatch *pair = match->data[i];319 pmAstromObj *raw = rawstars->data[pair->raw];320 pmAstromObj *ref = refstars->data[pair->ref];321 322 if (!isfinite(raw->Mag)) continue;323 if (raw->Mag < iMagMin) continue;324 if (raw->Mag > iMagMax) continue;325 if (ref->Mag < rMagMin) continue;326 if (ref->Mag > rMagMax) continue;327 328 xVec->data.F32[n] = raw->chip->y;329 yVec->data.F32[n] = raw->chip->y - ref->chip->y;330 zVec->data.F32[n] = raw->Mag;331 n++;332 }333 xVec->n = yVec->n = zVec->n = n;334 335 KapaSendLabel (*kapa, "Y", KAPA_LABEL_XM);336 KapaSendLabel (*kapa, "dY", KAPA_LABEL_YM);337 pmKapaPlotVectorTriple_AutoLimits_OpenGraph (*kapa, &graphdata, xVec, yVec, zVec, false);338 339 section.x = 0.0;340 section.y = 0.0;341 section.dx = 0.95;342 section.dy = 0.95;343 section.name = NULL;344 psStringAppend (§ion.name, "a5");345 KapaSetSection (*kapa, §ion);346 KapaSendLabel (*kapa, title, KAPA_LABEL_XP);347 psFree (section.name);348 349 350 // X vs Y plot (different window)351 if (!pmVisualInitWindow( kapa2, "psastro:plots"))352 return false;353 354 KapaInitGraph (&graphdata);355 KapaClearPlots (*kapa2);356 357 graphdata.color = KapaColorByName ("black");358 graphdata.ptype = 2;359 graphdata.style = 2;360 361 psFree (xVec);362 psFree (yVec);363 psFree (zVec);364 365 xVec = psVectorAlloc (rawstars->n, PS_TYPE_F32);366 yVec = psVectorAlloc (rawstars->n, PS_TYPE_F32);367 zVec = psVectorAlloc (rawstars->n, PS_TYPE_F32);368 369 // X vs Y by mag (raw)370 n = 0;371 for (int i = 0; i < rawstars->n; i++) {372 pmAstromObj *raw = rawstars->data[i];373 if (!isfinite(raw->Mag)) continue;374 if (raw->Mag < iMagMin) continue;375 if (raw->Mag > iMagMax) continue;376 377 xVec->data.F32[n] = raw->chip->x;378 yVec->data.F32[n] = raw->chip->y;379 zVec->data.F32[n] = raw->Mag;380 n++;381 }382 xVec->n = yVec->n = zVec->n = n;383 384 KapaSendLabel (*kapa2, "X", KAPA_LABEL_XM);385 KapaSendLabel (*kapa2, "Y", KAPA_LABEL_YM);386 KapaSendLabel (*kapa2,387 "Chip Coordinates. Black = Raw Stars. Red = Ref Stars. Blue = Matched Stars"388 , KAPA_LABEL_XP);389 pmVisualTriplePlot (*kapa2, &graphdata, xVec, yVec, zVec, false);390 391 // X vs Y by mag (ref)392 psFree (xVec);393 psFree (yVec);394 psFree (zVec);395 396 xVec = psVectorAlloc (refstars->n, PS_TYPE_F32);397 yVec = psVectorAlloc (refstars->n, PS_TYPE_F32);398 zVec = psVectorAlloc (refstars->n, PS_TYPE_F32);399 400 graphdata.color = KapaColorByName ("red");401 graphdata.ptype = 7;402 graphdata.style = 2;403 404 n = 0;405 for (int i = 0; i < refstars->n; i++) {406 pmAstromObj *ref = refstars->data[i];407 if (!isfinite(ref->Mag)) continue;408 if (ref->Mag < rMagMin) continue;409 if (ref->Mag > rMagMax) continue;410 411 xVec->data.F32[n] = ref->chip->x;412 yVec->data.F32[n] = ref->chip->y;413 zVec->data.F32[n] = ref->Mag;414 n++;415 }416 xVec->n = yVec->n = zVec->n = n;417 pmVisualTripleOverplot (*kapa2, &graphdata, xVec, yVec, zVec, false);418 419 //rescale the graph to include all points420 float xmin = graphdata.xmin;421 float ymin = graphdata.ymin;422 float xmax = graphdata.xmax;423 float ymax = graphdata.ymax;424 pmVisualScaleGraphdata(&graphdata, xVec, yVec, true);425 graphdata.xmin = PS_MIN(xmin, graphdata.xmin);426 graphdata.ymin = PS_MIN(ymin, graphdata.ymin);427 graphdata.xmax = PS_MAX(xmax, graphdata.xmax);428 graphdata.ymax = PS_MAX(ymax, graphdata.ymax);429 KapaSetLimits (*kapa2, &graphdata);430 431 //overplot matched stars in blue432 psFree (xVec);433 psFree (yVec);434 psFree (zVec);435 436 xVec = psVectorAlloc (match->n, PS_TYPE_F32);437 yVec = psVectorAlloc (match->n, PS_TYPE_F32);438 zVec = psVectorAlloc (match->n, PS_TYPE_F32);439 440 graphdata.color = KapaColorByName ("blue");441 n = 0;442 for (int i = 0; i < match->n; i++) {443 pmAstromMatch *pair = match->data[i];444 pmAstromObj *raw = rawstars->data[pair->raw];445 pmAstromObj *ref = refstars->data[pair->ref];446 if (raw->Mag < iMagMin) continue;447 if (raw->Mag > iMagMax) continue;448 if (ref->Mag < rMagMin) continue;449 if (ref->Mag > rMagMax) continue;450 451 xVec->data.F32[n] = raw->chip->x;452 yVec->data.F32[n] = raw->chip->y;453 zVec->data.F32[n] = iMagMin;454 n++;455 }456 xVec->n = yVec->n = zVec->n = n;457 pmVisualTripleOverplot (*kapa2, &graphdata, xVec, yVec, zVec, false);458 459 psFree (xVec);460 psFree (yVec);461 psFree (zVec);462 return true;463 }464 465 466 183 bool pmVisualScaleImage(int kapaFD, psImage *inImage, const char *name, int channel, bool clip) { 467 184 -
branches/cnb_branch_20090113/psModules/src/extras/pmVisual.h
r21208 r21421 77 77 78 78 79 /** Given a set of matched raw and reference stars, plot the astrometric errors in a number of coordinate systems80 * @param rawStars set or raw stars81 * @param refStars set of reference stars82 * @param match the match between raw and ref stars83 * @param recipe the psastro recipe being used84 * @param title of the plot85 * @param kapa the index of the first kapa window86 * @param kapa2 the index of the second kapa window87 * @returns true for successful completion88 */89 bool pmVisualResidPlot (psArray *rawstars, psArray *refstars, psArray *match,90 psMetadata *recipe, char *title, int *kapa, int *kapa2);91 92 93 79 /** Use x and y data to determine appropriate values for a Graphdata structure. 94 80 * This procedure sets the max and min keywords of a Graphdata structure to encompass
Note:
See TracChangeset
for help on using the changeset viewer.
