Changeset 27489
- Timestamp:
- Mar 27, 2010, 10:39:57 AM (16 years ago)
- Location:
- branches/eam_branches/relastro.20100326
- Files:
-
- 9 edited
-
Makefile (modified) (1 diff)
-
include/relastro.h (modified) (7 diffs)
-
src/CoordOps.c (modified) (3 diffs)
-
src/FitChip.c (modified) (2 diffs)
-
src/FixProblemImages.c (modified) (1 diff)
-
src/ImageOps.c (modified) (14 diffs)
-
src/UpdateObjectOffsets.c (modified) (1 diff)
-
src/fitpoly.c (modified) (1 diff)
-
src/relastro.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/relastro.20100326/Makefile
r24308 r27489 56 56 $(SRC)/save_catalogs.$(ARCH).o \ 57 57 $(SRC)/write_coords.$(ARCH).o \ 58 $(SRC)/CoordOps.$(ARCH).o \ 59 $(SRC)/FixProblemImages.$(ARCH).o \ 58 60 $(SRC)/relastroVisual.$(ARCH).o 59 61 -
branches/eam_branches/relastro.20100326/include/relastro.h
r27435 r27489 151 151 void dump_grid PROTO((void)); 152 152 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 153 void findImages PROTO((Catalog *catalog, int Ncatalog ));153 void findImages PROTO((Catalog *catalog, int Ncatalog, int MATCHCAT)); 154 154 int findMosaics PROTO((Catalog *catalog, int Ncatalog)); 155 155 Image *find_images PROTO((FITS_DB *db, GSCRegion *region, off_t Nregion, off_t *Nimage, off_t **LineNum)); … … 166 166 void free_catalogs PROTO((Catalog *catalog, int Ncatalog)); 167 167 int gcatalog PROTO((Catalog *catalog, int FINAL)); 168 Coords *getCoords PROTO((off_t meas, int cat));168 // Coords *getCoords PROTO((off_t meas, int cat)); 169 169 float getMcal PROTO((off_t meas, int cat)); 170 170 float getMgrid PROTO((off_t meas, int cat)); … … 178 178 void initGrid PROTO((int dX, int dY)); 179 179 void initGridBins PROTO((Catalog *catalog, int Ncatalog)); 180 void initImageBins PROTO((Catalog *catalog, int Ncatalog ));180 void initImageBins PROTO((Catalog *catalog, int Ncatalog, int FULLINIT)); 181 181 void initImages PROTO((Image *input, off_t N)); 182 182 void initMosaicBins PROTO((Catalog *catalog, int Ncatalog)); … … 199 199 int main PROTO((int argc, char **argv)); 200 200 void mark_images PROTO((Image *image, off_t Nimage, Image *timage, off_t Ntimage)); 201 void matchImage PROTO((Catalog *catalog, off_t meas, int cat ));201 void matchImage PROTO((Catalog *catalog, off_t meas, int cat, int MATCHCAT)); 202 202 void matchMosaics PROTO((Catalog *catalog, off_t meas, int cat)); 203 203 GSCRegion *name_region PROTO((char *name, off_t *Nregions)); … … 250 250 void fit_free (CoordFit *fit); 251 251 void fit_add (CoordFit *fit, double x1, double y1, double x2, double y2, double wt); 252 voidfit_eval (CoordFit *fit);252 int fit_eval (CoordFit *fit); 253 253 void fit_apply (CoordFit *fit, double *x2, double *y2, double x1, double y1); 254 254 double **poly2d_dx (double **poly, int Nx, int Ny); … … 256 256 double **poly2d_copy (double **poly, int Nx, int Ny); 257 257 double poly2d_eval (double **poly, int Nx, int Ny, double x, double y); 258 CoordFit *fit_apply_coords (CoordFit *fit, Coords *coords);258 int fit_apply_coords (CoordFit *fit, Coords *coords); 259 259 int CoordsGetCenter (CoordFit *fit, double tol, double *xo, double *yo); 260 260 CoordFit *CoordsSetCenter (CoordFit *input, double Xo, double Yo); 261 voidFitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords);261 int FitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 262 262 void FitMosaic (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 263 263 void FitSimple (StarData *raw, StarData *ref, int Nmatch, Coords *coords); … … 303 303 StatType statsR, StatType statsD, double thresh); 304 304 305 306 307 int FixProblemImages (SkyList *skylist); 308 int *getCatlist (int *N, off_t im); 309 310 void initCoords (void); 311 void getOffsets (double *dPos, off_t *nPos, off_t N); 312 void saveOffsets (double dPos, off_t nPos, off_t N); 313 void setBadCoords (off_t N); 314 int badCoords (off_t N); 315 Coords *getCoords (off_t N); 316 int saveCoords (Coords *coords, off_t N); 317 void resetImageRaw (Catalog *catalog, int Ncatalog, off_t im); -
branches/eam_branches/relastro.20100326/src/CoordOps.c
r27488 r27489 10 10 void initCoords (void) { 11 11 12 images = getImages (&N); 12 off_t N; 13 Image *images; 14 15 images = getimages (&N); 13 16 14 17 NoldCoords = N; … … 32 35 } 33 36 34 Coords getCoords (off_t N) {37 Coords *getCoords (off_t N) { 35 38 36 39 if (N < 0) return NULL; … … 68 71 } 69 72 73 void getOffsets (double *dPos, off_t *nPos, off_t N) { 74 75 if (N < 0) return; 76 if (N >= NoldCoords) return; 77 78 *dPos = dPosSum[N]; 79 *nPos = nPosSum[N]; 80 81 return; 82 } 83 -
branches/eam_branches/relastro.20100326/src/FitChip.c
r27488 r27489 17 17 // XXX save measurements of the fit quality (scatter, chisq) in the image table 18 18 19 voidFitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords) {19 int FitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords) { 20 20 21 21 int i, Nscatter, Niter, skip; 22 22 CoordFit *fit; 23 23 double dL, dM, dR, dRmax, *values; 24 Coords oldCoords;25 24 26 25 ALLOCATE (values, double, Nmatch); … … 91 90 fit_free (fit); 92 91 free (values); 93 return ;92 return FALSE; 94 93 } 95 94 -
branches/eam_branches/relastro.20100326/src/FixProblemImages.c
r27488 r27489 4 4 // original coordinates and recalculate the positions 5 5 6 int FixProblemImages ( ) {6 int FixProblemImages (SkyList *skylist) { 7 7 8 off_t i m, Nimage;8 off_t i, Nimage; 9 9 Image *image; 10 SkyList sublist; 11 12 // allocate so we can reallocate below 13 ALLOCATE (sublist.regions, SkyRegion *, 1); 14 ALLOCATE (sublist.filename, char *, 1); 10 15 11 16 image = getimages (&Nimage); 12 17 18 // first check on the dPos reported for each image 13 19 for (i = 0; i < Nimage; i++) { 14 20 double dPosSum, dPos; 21 off_t nPos; 22 getOffsets (&dPosSum, &nPos, i); 23 dPos = sqrt(dPosSum / nPos); 24 if (dPos > 4.0) { 25 setBadCoords (i); 26 } 27 } 28 29 for (i = 0; i < Nimage; i++) { 30 int j, cat, Ncat, *catlist, Ncatlist; 31 Catalog *catalog; 32 15 33 // check if this image should be fixed 16 34 if (!badCoords(i)) continue; 17 35 18 // get list of catalogs containing measurements for the bad images: 19 catlist = getCatList(im, &Ncat); 20 measlist = getMeasList(im, &Nmeas); 36 // I need a list of the catalogs for this image 37 catlist = getCatlist(&Ncatlist, i); 21 38 22 for (i = 0; i < Nlist[im]; i++) { 23 m = mlist[im][i]; 24 c = clist[im][i]; 25 39 // allocate Ncatlist skylist regions 40 REALLOCATE (sublist.regions, SkyRegion *, Ncatlist); 41 REALLOCATE (sublist.filename, char *, Ncatlist); 42 sublist.Nregions = Ncatlist; 43 sublist.ownElements = FALSE; // this list is only holding a view to the elements 26 44 27 28 // set up the basic catalog info 29 catalog.filename = skylist[0].filename[i]; 30 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 31 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 32 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 33 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 34 35 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { 36 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 37 exit (1); 38 } 39 if (!catalog.Naves_disk) { 40 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 41 dvo_catalog_unlock (&catalog); 42 dvo_catalog_free (&catalog); 43 continue; 45 // copy the desired catalogs from skylist to skylistSubset 46 for (j = 0; j < Ncatlist; j++) { 47 cat = catlist[j]; 48 sublist.filename[j] = skylist[0].filename[cat]; 49 sublist.regions[j] = skylist[0].regions[cat]; 44 50 } 45 51 52 catalog = load_catalogs (&sublist, &Ncat, FALSE); 53 assert (Ncat == Ncatlist); 54 46 55 // match measurements with images 47 initImageBins ( &catalog, 1);48 findImages ( &catalog, 1);56 initImageBins (catalog, Ncat, FALSE); 57 findImages (catalog, Ncat, FALSE); 49 58 50 59 // update the detection coordinates using the new image parameters 51 UpdateMeasures (&catalog, 1);60 resetImageRaw (catalog, Ncat, i); 52 61 53 freeImageBins ( 1);62 freeImageBins (Ncat); 54 63 55 64 // write the updated detections to disk 56 save_catalogs ( &catalog, 1);65 save_catalogs (catalog, Ncat); 57 66 } 58 67 -
branches/eam_branches/relastro.20100326/src/ImageOps.c
r27488 r27489 11 11 static Image *image; // list of available images 12 12 static off_t Nimage; // number of available images 13 14 static int *Ncatlist; // catalogs associated with each image 15 static int *NCATLIST; // catalogs associated with each image 16 static int **catlist; // catalogs associated with each image 13 17 14 18 // if we search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted … … 32 36 } 33 37 38 int *getCatlist (int *N, off_t im) { 39 40 *N = Ncatlist[im]; 41 return (catlist[im]); 42 } 43 34 44 void initImages (Image *input, off_t N) { 35 45 … … 86 96 } 87 97 88 void initImageBins (Catalog *catalog, int Ncatalog) { 98 // these are really image & catalog indexes 99 void initImageBins (Catalog *catalog, int Ncatalog, int FULLINIT) { 89 100 90 101 off_t i, j; … … 102 113 103 114 for (i = 0; i < Nimage; i++) { 104 Nlist[i] = 0;115 Nlist[i] = 0; 105 116 NLIST[i] = 100; 106 117 ALLOCATE (clist[i], int, NLIST[i]); 107 118 ALLOCATE (mlist[i], off_t, NLIST[i]); 119 } 120 121 if (FULLINIT) { 122 ALLOCATE (Ncatlist, int, Nimage); 123 ALLOCATE (NCATLIST, int, Nimage); 124 ALLOCATE (catlist, int *, Nimage); 125 126 for (i = 0; i < Nimage; i++) { 127 Ncatlist[i] = 0; 128 NCATLIST[i] = 32; 129 ALLOCATE (catlist[i], int, NCATLIST[i]); 130 } 108 131 } 109 132 } … … 126 149 127 150 /* match measurements to images */ 128 void findImages (Catalog *catalog, int Ncatalog ) {151 void findImages (Catalog *catalog, int Ncatalog, int MATCHCAT) { 129 152 130 153 off_t i, j; … … 136 159 // ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode); 137 160 // if (photcode[0].code != ecode) continue; 138 matchImage (catalog, j, i );161 matchImage (catalog, j, i, MATCHCAT); 139 162 } 140 163 } … … 149 172 # if USE_IMAGE_ID 150 173 // this is the imageID-based match 151 void matchImage (Catalog *catalog, off_t meas, int cat ) {174 void matchImage (Catalog *catalog, off_t meas, int cat, int MATCHCAT) { 152 175 153 176 off_t idx, ID; 154 177 Measure *measure; 178 int i, found; 155 179 156 180 measure = &catalog[cat].measure[meas]; … … 178 202 REALLOCATE (mlist[idx], off_t, NLIST[idx]); 179 203 } 204 205 if (MATCHCAT) { 206 // index for image -> catalog list 207 found = FALSE; 208 for (i = 0; !found && (i < Ncatlist[idx]); i++) { 209 if (catlist[idx][i] == cat) found = TRUE; 210 } 211 if (!found) { 212 catlist[idx][Ncatlist[idx]] = cat; 213 Ncatlist[idx] ++; 214 if (Ncatlist[idx] == NCATLIST[idx]) { 215 NCATLIST[idx] += 32; 216 REALLOCATE (catlist[idx], int, NCATLIST[idx]); 217 } 218 } 219 } 220 180 221 return; 181 222 } … … 183 224 # else 184 225 // this is the time-based match 185 void matchImage (Catalog *catalog, off_t meas, int cat ) {226 void matchImage (Catalog *catalog, off_t meas, int cat, int MATCHCAT) { 186 227 187 228 off_t i; … … 221 262 # endif 222 263 264 /* 223 265 Coords *getCoords (off_t meas, int cat) { 224 266 … … 229 271 return (&image[i].coords); 230 272 } 273 */ 231 274 232 275 void plot_images () { … … 280 323 void fixImageRaw (Catalog *catalog, int Ncatalog, off_t im) { 281 324 282 off_t i, m, c, n ;325 off_t i, m, c, n, nPos; 283 326 double X, Y, L, M, P, Q, R, D, dR, dD; 327 double dPos; 284 328 285 329 Mosaic *mosaic; … … 325 369 dD = 3600.0*(catalog[c].average[n].D - D); 326 370 327 if (fabs(catalog[c].measure[m].dR - dR) > 10.0) {371 if (fabs(catalog[c].measure[m].dR - dR) > 2.0) { 328 372 fprintf (stderr, "!"); 329 373 setBadCoords (im); // report a failure for this image 330 374 return; 331 375 } 332 if (fabs(catalog[c].measure[m].dD - dD) > 10.0) {376 if (fabs(catalog[c].measure[m].dD - dD) > 2.0) { 333 377 fprintf (stderr, "*"); 334 378 setBadCoords (im); // report a failure for this image … … 355 399 356 400 saveOffsets (dPos, nPos, im); 401 402 return; 403 } 404 405 // return StarData values for detections in the specified image, converting coordinates from the 406 // chip positions: X,Y -> L,M -> P,Q -> R,D 407 void resetImageRaw (Catalog *catalog, int Ncatalog, off_t im) { 408 409 off_t i, m, c, n; 410 double X, Y, L, M, P, Q, R, D, dR, dD; 411 412 Mosaic *mosaic; 413 Coords *moscoords, *imcoords, *oldcoords; 414 415 // check if this image is bad and should be skipped 416 if (!badCoords(im)) { 417 fprintf (stderr, "ERROR: inconsistent result?"); 418 exit (1); 419 } 420 421 // replace the current coords with the old coords: 422 oldcoords = getCoords (im); 423 memcpy (&image[im].coords, oldcoords, sizeof(Coords)); 424 425 moscoords = NULL; 426 mosaic = getMosaicForImage (im); 427 if (mosaic != NULL) { 428 moscoords = &mosaic[0].coords; 429 } 430 imcoords = &image[im].coords; 431 432 for (i = 0; i < Nlist[im]; i++) { 433 m = mlist[im][i]; 434 c = clist[im][i]; 435 436 X = catalog[c].measure[m].Xccd; 437 Y = catalog[c].measure[m].Yccd; 438 n = catalog[c].measure[m].averef; 439 440 dR = dD = 0.0; 441 if (moscoords == NULL) { 442 // this is a Simple image (not a mosaic) 443 // note that for a Simple image, L,M = P,Q 444 XY_to_LM (&L, &M, X, Y, imcoords); 445 LM_to_RD (&R, &D, L, M, imcoords); 446 } else { 447 XY_to_LM (&L, &M, X, Y, imcoords); 448 XY_to_LM (&P, &Q, L, M, moscoords); 449 LM_to_RD (&R, &D, P, Q, moscoords); 450 } 451 452 catalog[c].measure[m].dR = dR; 453 catalog[c].measure[m].dD = dD; 454 455 if (catalog[c].measure[m].dR > +180.0*3600.0) { 456 // average on high end of boundary, move star up 457 R += 360.0; 458 catalog[c].measure[m].dR = 3600.0*(catalog[c].average[n].R - R); 459 } 460 if (catalog[c].measure[m].dR < -180.0*3600.0) { 461 // average on low end of boundary, move star down 462 R -= 360.0; 463 catalog[c].measure[m].dR = 3600.0*(catalog[c].average[n].R - R); 464 } 465 } 357 466 358 467 return; -
branches/eam_branches/relastro.20100326/src/UpdateObjectOffsets.c
r27488 r27489 34 34 35 35 // match measurements with images 36 initImageBins (&catalog, 1 );37 findImages (&catalog, 1 );36 initImageBins (&catalog, 1, FALSE); 37 findImages (&catalog, 1, FALSE); 38 38 39 39 // update the detection coordinates using the new image parameters -
branches/eam_branches/relastro.20100326/src/fitpoly.c
r27488 r27489 146 146 // ix, iy, vector[i][0], ix, iy, vector[i][1]); 147 147 } 148 149 status = dgaussjordan (matrix, vector, fit[0].Nelems, 2); 150 if (!status) { 148 149 if (!dgaussjordan (matrix, vector, fit[0].Nelems, 2)) { 151 150 return (FALSE); 152 151 } -
branches/eam_branches/relastro.20100326/src/relastro.c
r27488 r27489 47 47 48 48 /* match measurements with images */ 49 initImageBins (catalog, Ncatalog );49 initImageBins (catalog, Ncatalog, TRUE); 50 50 MARKTIME("make image bins: %f sec\n", dtime); 51 51 52 findImages (catalog, Ncatalog );52 findImages (catalog, Ncatalog, TRUE); 53 53 MARKTIME("set up image indexes: %f sec\n", dtime); 54 54 … … 86 86 87 87 // iterate over catalogs to make detection coordinates consistant 88 FixProblemImages ( );88 FixProblemImages (skylist); 89 89 90 90 // save the updated image parameters
Note:
See TracChangeset
for help on using the changeset viewer.
