Changeset 23344
- Timestamp:
- Mar 17, 2009, 11:03:01 AM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro
- Files:
-
- 7 edited
-
include/relastro.h (modified) (1 diff)
-
src/ConfigInit.c (modified) (1 diff)
-
src/FitChip.c (modified) (5 diffs)
-
src/ImageOps.c (modified) (1 diff)
-
src/bcatalog.c (modified) (7 diffs)
-
src/relastroVisual.c (modified) (10 diffs)
-
src/relastroVisual.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/include/relastro.h
r22724 r23344 87 87 88 88 double SIGMA_LIM; 89 int MIN_SRC_FIT;89 int SRC_MEAS_TOOFEW; //catalog objects wich fewer detections then this are ignored 90 90 double MIN_ERROR; 91 91 -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/ConfigInit.c
r22724 r23344 20 20 21 21 GetConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM); 22 GetConfig (config, "RELASTRO_ MIN_SRC_FIT", "%d", 0, &MIN_SRC_FIT);22 GetConfig (config, "RELASTRO_SRC_MEAS_TOOFEW", "%d", 0, &SRC_MEAS_TOOFEW); 23 23 24 24 // XXX these are used in relphot to identify poor stars / images -- define -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/FitChip.c
r22724 r23344 6 6 # define FIT_CHIP_NITER 3 7 7 # define FIT_CHIP_NSIGMA 3.0 8 8 9 9 10 // XXX we should test if the fit is sufficiently constrained across the chip, or if the … … 28 29 for (i = Nscatter = 0; i < Nmatch; i++) { 29 30 if (raw[i].mask) continue; 30 if ( raw[i].dMag > FIT_CHIP_MAX_ERROR) continue;31 if (isnan(raw[i].dMag) || raw[i].dMag > FIT_CHIP_MAX_ERROR) continue; 31 32 32 33 dL = raw[i].L - ref[i].L; … … 41 42 dsort (values, Nscatter); 42 43 dRmax = FIT_CHIP_NSIGMA*values[(int)(0.40*Nscatter)]; 44 relastroVisualPlotScatter(values, dRmax, Nscatter); 43 45 relastroVisualPlotRawRef(raw, ref, dRmax, Nmatch); 44 46 … … 52 54 for (i = 0; i < Nmatch; i++) { 53 55 if (raw[i].mask) continue; 56 if (isnan(raw[i].dMag) || raw[i].dMag > FIT_CHIP_MAX_ERROR) continue; 54 57 55 58 // only keep objects within dRmax … … 96 99 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, coords); 97 100 } 98 99 relastroVisualPlotRawRef(fit, coords, dRmax, Nmatch);100 101 101 102 } -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/ImageOps.c
r22724 r23344 293 293 // an object with only one detection provides no information about the image calibration 294 294 raw[i].mask = FALSE; 295 if (catalog[c].average[n].Nmeasure < MIN_SRC_FIT) { 296 raw[i].mask = TRUE; 297 } 295 int mask = FALSE; 296 if (catalog[c].average[n].Nmeasure <= SRC_MEAS_TOOFEW) { 297 mask = TRUE; 298 } 299 raw[i].mask = mask; 300 298 301 299 302 switch (mode) { -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/bcatalog.c
r21508 r23344 2 2 3 3 int bcatalog (Catalog *subcatalog, Catalog *catalog) { 4 4 5 5 int i, j, k, offset, found; 6 6 int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm, Nsecfilt; … … 23 23 /* exclude stars not in range or with too few measurements */ 24 24 for (i = 0; i < catalog[0].Naverage; i++) { 25 if (catalog[0].average[i].Nmeasure < 2) continue;25 if (catalog[0].average[i].Nmeasure <= SRC_MEAS_TOOFEW) continue; 26 26 27 27 /* start with all stars good */ … … 47 47 /* select measurements by photcode, or equiv photcode, if specified */ 48 48 if (NphotcodesKeep > 0) { 49 found = FALSE;50 for (k = 0; (k < NphotcodesKeep) && !found; k++) {51 if (photcodesKeep[k][0].code == catalog[0].measure[offset].photcode) found = TRUE;52 if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE;53 }54 if (!found) continue;49 found = FALSE; 50 for (k = 0; (k < NphotcodesKeep) && !found; k++) { 51 if (photcodesKeep[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 52 if (photcodesKeep[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 53 } 54 if (!found) continue; 55 55 } 56 56 if (NphotcodesSkip > 0) { 57 found = FALSE;58 for (k = 0; (k < NphotcodesSkip) && !found; k++) {59 if (photcodesSkip[k][0].code == catalog[0].measure[offset].photcode) found = TRUE;60 if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE;61 }62 if (found) continue;57 found = FALSE; 58 for (k = 0; (k < NphotcodesSkip) && !found; k++) { 59 if (photcodesSkip[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 60 if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 61 } 62 if (found) continue; 63 63 } 64 64 65 65 /* select measurements by time */ 66 66 if (TimeSelect) { 67 if (catalog[0].measure[offset].t < TSTART) continue;68 if (catalog[0].measure[offset].t > TSTOP) continue;67 if (catalog[0].measure[offset].t < TSTART) continue; 68 if (catalog[0].measure[offset].t > TSTOP) continue; 69 69 } 70 70 … … 75 75 /* select measurements by quality */ 76 76 if (PhotFlagSelect) { 77 if (PhotFlagBad) {78 mask = PhotFlagBad;79 } else {80 code = GetPhotcodebyCode (catalog[0].measure[offset].photcode);81 mask = code[0].astromBadMask;82 }83 if (mask & catalog[0].measure[offset].photFlags) continue;77 if (PhotFlagBad) { 78 mask = PhotFlagBad; 79 } else { 80 code = GetPhotcodebyCode (catalog[0].measure[offset].photcode); 81 mask = code[0].astromBadMask; 82 } 83 if (mask & catalog[0].measure[offset].photFlags) continue; 84 84 } 85 85 … … 89 89 /* select measurements by mag limit */ 90 90 if (ImagSelect) { 91 mag = PhotInst (&catalog[0].measure[offset]);92 if (mag < ImagMin) continue;93 if (mag > ImagMax) continue;91 mag = PhotInst (&catalog[0].measure[offset]); 92 if (mag < ImagMin) continue; 93 if (mag > ImagMax) continue; 94 94 } 95 95 … … 110 110 subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset]; 111 111 subcatalog[0].measure[Nmeasure].averef = Naverage; 112 if (RESET) { 113 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_POOR_ASTROM;114 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_AREA;112 if (RESET) { 113 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_POOR_ASTROM; 114 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_AREA; 115 115 } 116 116 Nmeasure ++; 117 117 Nm ++; 118 118 if (Nmeasure == NMEASURE) { 119 NMEASURE += 1000;120 REALLOCATE (subcatalog[0].measure, Measure, NMEASURE);119 NMEASURE += 1000; 120 REALLOCATE (subcatalog[0].measure, Measure, NMEASURE); 121 121 } 122 122 } … … 139 139 140 140 if (VERBOSE) { 141 fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i, 142 subcatalog[0].Naverage, subcatalog[0].Nmeasure);141 fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i, 142 subcatalog[0].Naverage, subcatalog[0].Nmeasure); 143 143 } 144 144 return (TRUE); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/relastroVisual.c
r22726 r23344 6 6 #include "relastro.h" 7 7 8 #define TESTING 9 8 10 #define KAPAX 700 9 11 #define KAPAY 700 … … 11 13 static int kapa = -1; 12 14 static int kapa2 = -1; 13 14 static int isVisual = 1; 15 static int plotRawRef = 1; 15 static int kapa3 = -1; 16 17 static int isVisual = FALSE; 18 static int plotRawRef = TRUE; 19 static int plotScatter = TRUE; 20 static int plotResid = TRUE; 21 static int plotVector = TRUE; 16 22 17 23 /** Spawn a kapa window */ … … 24 30 return 0; 25 31 } 26 KapaResize (*kapid, KAPAX, KAPAY);32 // KapaResize (*kapid, KAPAX, KAPAY); 27 33 } 28 34 return 1; … … 46 52 47 53 /** Size graphdata to encompass all points */ 48 static void scaleGraphdata(float x[], float y[], Graphdata *graphdata, int n) { 49 float xlo = 9999999, xhi = -9999999, ylo = 9999999, yhi = -9999999; 50 int i; 51 for(i = 0; i < n; i++) { 52 if(x[i] < xlo) xlo = x[i]; 53 if(x[i] > xhi) xhi = x[i]; 54 if(y[i] < ylo) ylo = y[i]; 55 if(y[i] > yhi) yhi = y[i]; 56 } 57 graphdata->xmin = xlo; 58 graphdata->ymin = ylo; 59 graphdata->xmax = xhi; 60 graphdata->ymax = yhi; 61 } 54 static int scaleGraphdata(float x[], float y[], Graphdata *graphdata, int n) { 55 float xlo = FLT_MAX, xhi = -FLT_MAX, ylo = FLT_MAX, yhi = -FLT_MAX; 56 int i; 57 int goodData = 0; 58 for(i = 0; i < n; i++) { 59 goodData++; 60 if(!finite(x[i]) || !finite(y[i])) continue; 61 if(x[i] < xlo) xlo = x[i]; 62 if(x[i] > xhi) xhi = x[i]; 63 if(y[i] < ylo) ylo = y[i]; 64 if(y[i] > yhi) yhi = y[i]; 65 } 66 if (goodData < 2) return 0; 67 graphdata->xmin = xlo; 68 graphdata->ymin = ylo; 69 graphdata->xmax = xhi; 70 graphdata->ymax = yhi; 71 return 1; 72 } 73 74 static int residPlot(float x[], float y[], 75 float xVec[], float yVec[], 76 int npts, int *kapaID) { 77 if (!plotResid) return 1; 78 Graphdata graphdata; 79 KapaSection section; 80 81 if (!initWindow(kapaID)) return 0; 82 83 KapaInitGraph(&graphdata); 84 KapaClearPlots(*kapaID); 85 KapaSetFont(*kapaID, "helvetica", 14); 86 87 section.name = "0"; 88 section.x = 0.0; section.y = 0.0; 89 section.dx = .45, section.dy = .45; 90 graphdata.ptype = 7; 91 graphdata.style = 2; 92 93 KapaSetSection(*kapaID, §ion); 94 if(!scaleGraphdata(x, xVec, &graphdata, npts)) return 0; 95 KapaSetLimits(*kapaID, &graphdata); 96 KapaBox(*kapaID, &graphdata); 97 KapaSendLabel(*kapaID, "x", KAPA_LABEL_XM); 98 KapaSendLabel(*kapaID, "dx", KAPA_LABEL_YM); 99 KapaPrepPlot(*kapaID, npts, &graphdata); 100 KapaPlotVector(*kapaID, npts, x, "x"); 101 KapaPlotVector(*kapaID, npts, xVec, "y"); 102 103 section.x = .5; section.y = 0; section.name="1"; 104 KapaSetSection(*kapaID, §ion); 105 if(!scaleGraphdata(x, yVec, &graphdata, npts)) return 0; 106 KapaSetLimits(*kapaID, &graphdata); 107 KapaBox(*kapaID, &graphdata); 108 KapaSendLabel(*kapaID, "x", KAPA_LABEL_XM); 109 KapaSendLabel(*kapaID, "dy", KAPA_LABEL_YP); 110 KapaPrepPlot(*kapaID, npts, &graphdata); 111 KapaPlotVector(*kapaID, npts, x, "x"); 112 KapaPlotVector(*kapaID, npts, yVec, "y"); 113 114 section.x = .0; section.y = .5; section.name="2"; 115 KapaSetSection(*kapaID, §ion); 116 if(!scaleGraphdata(y, xVec, &graphdata, npts)) return 0;; 117 KapaSetLimits(*kapaID, &graphdata); 118 KapaBox(*kapaID, &graphdata); 119 KapaSendLabel(*kapaID, "y", KAPA_LABEL_XM); 120 KapaSendLabel(*kapaID, "dx", KAPA_LABEL_YM); 121 KapaPrepPlot(*kapaID, npts, &graphdata); 122 KapaPlotVector(*kapaID, npts, y, "x"); 123 KapaPlotVector(*kapaID, npts, xVec, "y"); 124 125 section.x = .5; section.y = .5; section.name="3"; 126 KapaSetSection(*kapaID, §ion); 127 if(!scaleGraphdata(y, yVec, &graphdata, npts)) return 0; 128 KapaSetLimits(*kapaID, &graphdata); 129 KapaBox(*kapaID, &graphdata); 130 KapaSendLabel(*kapaID, "y", KAPA_LABEL_XM); 131 KapaSendLabel(*kapaID, "dy", KAPA_LABEL_YP); 132 KapaPrepPlot(*kapaID, npts, &graphdata); 133 KapaPlotVector(*kapaID, npts, y, "x"); 134 KapaPlotVector(*kapaID, npts, yVec, "y"); 135 136 return 1; 137 } 138 62 139 63 140 /**Plot a vector field*/ 64 141 static int plotVectorField(float x[], float y[], 65 142 float xVec[], float yVec[], 66 int npts, int *kapaID) { 67 68 Graphdata graphdata; 69 float singleX[2], singleY[2]; 70 float maxVecLength, vecScaleFactor; 71 float graphSize; 72 int i; 143 int npts, int *kapaID, double maxVecLength) { 144 145 if(!plotVector) return 1; 146 147 Graphdata graphdata; 148 float singleX[2], singleY[2]; 149 float vecScaleFactor; 150 float graphSize; 151 int i; 152 char plotTitle[50]; 153 sprintf(plotTitle, "Maximum Vector Size = %5.1e", maxVecLength); 73 154 74 155 if (!initWindow(kapaID)) return 0; … … 76 157 KapaInitGraph(&graphdata); 77 158 KapaClearPlots(*kapaID); 78 scaleGraphdata(x, y, &graphdata, npts); 79 80 //scale the raw xvec, yvecs down to fit into the window 81 maxVecLength = 0; 82 for(i = 0; i < npts; i++) { 83 if (fabs(xVec[i]) > maxVecLength) { 84 maxVecLength = fabs(xVec[i]); 85 } 86 if (fabs(yVec[i]) > maxVecLength) { 87 maxVecLength = fabs(yVec[i]); 88 } 89 } 159 if(!scaleGraphdata(x, y, &graphdata, npts)) return 0; 160 90 161 graphSize = graphdata.xmax - graphdata.xmin; 91 162 if ((graphdata.ymax - graphdata.ymin) > graphSize) { 92 163 graphSize = graphdata.ymax - graphdata.ymin; 93 164 } 94 vecScaleFactor = graphSize * 0.1 / maxVecLength; 165 166 vecScaleFactor = graphSize * 0.02 / (float)maxVecLength; 167 #ifdef TESTING 168 fprintf(stderr, "GraphSize: %e\n maxVecLength: %e\n vecScaleFactor: %e\n", 169 graphSize, maxVecLength, vecScaleFactor); 170 #endif 171 95 172 96 173 KapaSetFont (*kapaID, "helvetica", 14); 97 174 KapaSetLimits(*kapaID, &graphdata); 98 175 KapaBox(*kapaID, &graphdata); 99 176 KapaSendLabel(*kapaID, plotTitle, KAPA_LABEL_XP); 177 100 178 graphdata.ptype = 7; 101 179 graphdata.style = 2; … … 107 185 graphdata.ptype = 0; 108 186 graphdata.style = 0; 187 graphdata.color = KapaColorByName("blue"); 109 188 for(i = 0; i < npts; i++) { 110 189 singleX[0] = x[i]; 111 190 singleY[0] = y[i]; 112 singleX[1] = xVec[i] * vecScaleFactor; 113 singleY[1] = yVec[i] * vecScaleFactor; 114 191 singleX[1] = x[i] + xVec[i] * vecScaleFactor; 192 singleY[1] = y[i] + yVec[i] * vecScaleFactor; 115 193 KapaPrepPlot(*kapaID, 2, &graphdata); 116 194 KapaPlotVector(*kapaID, 2, singleX, "x"); … … 119 197 return 1; 120 198 } 199 200 int relastroVisualPlotScatter(double values[], double thresh, int npts) { 201 float *x, *data; 202 int i; 203 float xline[2], yline[2]; 204 if (!isVisual || !plotScatter) return 1; 205 if (!initWindow(&kapa2)) return 0; 206 207 ALLOCATE(x, float, npts); 208 ALLOCATE(data, float, npts); 209 210 for(i = 0; i < npts; i++) { 211 x[i] = i; 212 data[i] = (float) values[i]; 213 } 214 215 Graphdata graphdata; 216 KapaSection section; 217 section.x = 0; section.y = 0; section.dx = 1; section.dy = 1; 218 section.name = "junk"; 219 220 KapaInitGraph(&graphdata); 221 KapaClearPlots(kapa2); 222 KapaSetSection(kapa2, §ion); 223 224 graphdata.ptype = 0; 225 graphdata.style = 0; 226 graphdata.xmin = 0; 227 graphdata.xmax = npts; 228 graphdata.ymin = 0; 229 graphdata.ymax = data[npts-1]; 230 231 KapaSetFont(kapa2, "helvetica", 14); 232 KapaSetLimits(kapa2, &graphdata); 233 KapaBox(kapa2, &graphdata); 234 KapaSendLabel( kapa2, "Object", KAPA_LABEL_XM); 235 KapaSendLabel( kapa2, "Offset(pixels)", KAPA_LABEL_YM); 236 KapaSendLabel( kapa2, "Astrometric Offset with fit cutoff", 237 KAPA_LABEL_XP); 238 KapaPrepPlot(kapa2, npts, &graphdata); 239 KapaPlotVector(kapa2, npts, x, "x"); 240 KapaPlotVector(kapa2, npts, data, "y"); 241 242 graphdata.color = KapaColorByName("red"); 243 KapaPrepPlot(kapa2, 2, &graphdata); 244 yline[0] = (float) thresh; 245 yline[1] = (float) thresh; 246 xline[0] = graphdata.xmin; 247 xline[1] = graphdata.xmax; 248 KapaPlotVector(kapa2, 2, xline, "x"); 249 KapaPlotVector(kapa2, 2, yline, "y"); 250 251 askUser(&plotScatter); 252 return 1; 253 } 254 121 255 122 256 … … 173 307 } 174 308 175 ALLOCATE(xVec, float, numFit); 176 ALLOCATE(yVec, float, numFit); 309 if (numFit == 0) return 0; 177 310 178 311 Graphdata graphdata; … … 184 317 graphdata.style = 2; 185 318 186 scaleGraphdata(rawXfit, rawYfit, &graphdata, numFit); 187 // scaleGraphdata(refXfit, refYfit, &graphdata, numFit); 188 189 //plot the fitted objects as vectors 190 for(i = 0; i < numFit; i++) { 191 xVec[i] = rawXfit[i] - refXfit[i]; 192 yVec[i] = rawYfit[i] - refYfit[i]; 193 } 194 195 plotVectorField(refX, refY, xVec, yVec, numFit, &kapa2); 319 if(!scaleGraphdata(rawXfit, rawYfit, &graphdata, numFit)) { 320 fprintf(stderr, "Not enough finite points for plotting"); 321 return 0; 322 } 196 323 197 324 KapaSetFont(kapa, "helvetica", 14); … … 227 354 KapaPlotVector(kapa, numFit, refYfit, "y"); 228 355 356 ALLOCATE(xVec, float, numFit); 357 ALLOCATE(yVec, float, numFit); 358 359 //plot the fitted objects as vectors 360 for(i = 0; i < numFit; i++) { 361 xVec[i] = rawXfit[i] - refXfit[i]; 362 yVec[i] = rawYfit[i] - refYfit[i]; 363 } 364 365 plotVectorField(rawXfit, rawYfit, xVec, yVec, numFit, &kapa3, dRmax); 366 if(!residPlot(rawXfit, rawYfit, xVec, yVec, numFit, &kapa2)) { 367 fprintf(stderr, "Unable to plot residuals"); 368 return 0; 369 } 370 371 FREE(xVec); 372 FREE(yVec); 229 373 230 374 askUser(&plotRawRef); -
branches/cnb_branches/cnb_branch_20090301/Ohana/src/relastro/src/relastroVisual.h
r22725 r23344 3 3 4 4 int relastroVisualPlotRawRef(StarData *raw, StarData *ref, double dRmax, int numObj); 5 int relastroVisualPlotScatter(double values[], double thresh, int npts); 5 6 6 7 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
