Changeset 30616 for trunk/Ohana/src/relphot
- Timestamp:
- Feb 13, 2011, 11:30:02 AM (15 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 12 edited
- 1 copied
-
Makefile (modified) (1 diff)
-
include/relphot.h (modified) (4 diffs)
-
src/ConfigInit.c (modified) (1 diff)
-
src/ImageOps.c (modified) (5 diffs)
-
src/MosaicOps.c (modified) (4 diffs)
-
src/args.c (modified) (3 diffs)
-
src/bcatalog.c (modified) (1 diff)
-
src/help.c (copied) (copied from branches/eam_branches/ipp-20101205/Ohana/src/relphot/src/help.c )
-
src/initialize.c (modified) (1 diff)
-
src/load_catalogs.c (modified) (2 diffs)
-
src/load_images.c (modified) (3 diffs)
-
src/relphot.c (modified) (1 diff)
-
src/select_images.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/Makefile
r17242 r30616 29 29 $(SRC)/StarOps.$(ARCH).o \ 30 30 $(SRC)/args.$(ARCH).o \ 31 $(SRC)/help.$(ARCH).o \ 31 32 $(SRC)/bcatalog.$(ARCH).o \ 32 33 $(SRC)/global_stats.$(ARCH).o \ -
trunk/Ohana/src/relphot/include/relphot.h
r27586 r30616 13 13 float Mcal; 14 14 float dMcal; 15 float dMsys; 16 short nFitPhotom; 15 17 short Xm; 16 18 float secz; … … 50 52 double STAR_CHISQ; 51 53 double MIN_ERROR; 54 double IMFIT_SYS_SIGMA_LIM; 52 55 53 56 int VERBOSE; … … 103 106 SkyRegion UserPatch; 104 107 int UserPatchSelect; 108 109 int USE_BASIC_CHECK; 105 110 106 111 # ifdef GRID_V1 … … 215 220 void write_coords PROTO((Header *header, Coords *coords)); 216 221 int relphot_objects (void); 222 223 void relphot_usage (void); 224 void relphot_help (int argc, char **argv); -
trunk/Ohana/src/relphot/src/ConfigInit.c
r25757 r30616 20 20 GetConfig (config, "MAG_LIM", "%lf", 0, &MAG_LIM); 21 21 GetConfig (config, "SIGMA_LIM", "%lf", 0, &SIGMA_LIM); 22 23 if (!ScanConfig (config, "RELPHOT_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01; 24 22 25 GetConfig (config, "STAR_SCATTER", "%lf", 0, &STAR_SCATTER); 23 26 GetConfig (config, "IMAGE_SCATTER", "%lf", 0, &IMAGE_SCATTER); -
trunk/Ohana/src/relphot/src/ImageOps.c
r29001 r30616 124 124 free (clist); 125 125 free (mlist); 126 free (Nlist); 127 free (NLIST); 126 128 } 127 129 … … 299 301 300 302 off_t i, j, m, c, n, N, Nmax, mark, bad; 301 int Nfew, Nbad, Nmos, Ngrid, Nrel, Nsys ;302 float Msys, Mrel, Mmos, Mgrid ;303 int Nfew, Nbad, Nmos, Ngrid, Nrel, Nsys, Nbright; 304 float Msys, Mrel, Mmos, Mgrid, McalBright, McalBright2; 303 305 double *list, *dlist; 304 306 StatType stats; … … 318 320 319 321 Nfew = Nbad = Nmos = Ngrid = Nrel = Nsys = 0; 322 323 // counters to measure the bright-end scatter 324 McalBright = McalBright2 = 0.0; 325 Nbright = 0; 320 326 321 327 for (i = 0; i < Nimage; i++) { … … 361 367 list[N] = Msys - Mrel - Mmos - Mgrid; 362 368 dlist[N] = MAX (catalog[c].measure[m].dM, MIN_ERROR); 369 if (catalog[c].measure[m].dM < IMFIT_SYS_SIGMA_LIM) { 370 McalBright += list[N]; 371 McalBright2 += SQ(list[N]); 372 Nbright ++; 373 } 363 374 N++; 364 375 } … … 378 389 liststats (list, dlist, N, &stats); 379 390 image[i].Mcal = stats.mean; 380 image[i].dMcal = stats.sigma; 391 image[i].dMcal = stats.error; 392 image[i].dMagSys = stats.sigma; 393 image[i].nFitPhotom = N; 381 394 image[i].Xm = 100.0*log10(stats.chisq); 382 395 } -
trunk/Ohana/src/relphot/src/MosaicOps.c
r29001 r30616 73 73 mosaic[Nmosaic].Mcal = 0.0; 74 74 mosaic[Nmosaic].dMcal = 0.0; 75 mosaic[Nmosaic].dMsys = 0.0; 75 76 mosaic[Nmosaic].Xm = 0.0; 76 77 mosaic[Nmosaic].flags = image[i].flags; … … 189 190 image[im].dMcal = mosaic[i].dMcal; 190 191 image[im].Xm = mosaic[i].Xm; 192 image[im].dMagSys = mosaic[i].dMsys; 193 image[im].nFitPhotom = mosaic[i].nFitPhotom; 191 194 image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW); 192 195 image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_POOR); … … 400 403 mark = (N < IMAGE_TOOFEW) || (N < IMAGE_GOOD_FRACTION*Nlist[i]); 401 404 if (mark) { 402 fprintf (stderr, "marked mosaic %s ("OFF_T_FMT"), ("OFF_T_FMT" < %d) || ("OFF_T_FMT" < %f*"OFF_T_FMT")\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]);405 if (VERBOSE2) { fprintf (stderr, "marked mosaic %s ("OFF_T_FMT"), ("OFF_T_FMT" < %d) || ("OFF_T_FMT" < %f*"OFF_T_FMT")\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]); } 403 406 mosaic[i].flags |= ID_IMAGE_PHOTOM_FEW; 404 407 Nfew ++; … … 410 413 if (PoorImages) fprintf (stderr, "Mmos: %f %f %d "OFF_T_FMT"\n", stats.mean, stats.sigma, stats.Nmeas, N); 411 414 mosaic[i].Mcal = stats.mean; 412 mosaic[i].dMcal = stats.sigma; 415 mosaic[i].dMcal = stats.error; 416 mosaic[i].dMsys = stats.sigma; 417 mosaic[i].nFitPhotom = N; 413 418 mosaic[i].Xm = 100.0*log10(stats.chisq); 414 419 } -
trunk/Ohana/src/relphot/src/args.c
r27586 r30616 1 1 # include "relphot.h" 2 void usage (void);3 2 4 3 int args (int argc, char **argv) { … … 53 52 } 54 53 54 USE_BASIC_CHECK = FALSE; 55 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 56 remove_argument (N, &argc, argv); 57 USE_BASIC_CHECK = TRUE; 58 } 59 55 60 VERBOSE = VERBOSE2 = FALSE; 56 61 if ((N = get_argument (argc, argv, "-v"))) { … … 228 233 if (UpdateAverages && (argc == 1)) return TRUE; 229 234 if (UserPatchSelect && (argc == 2)) return TRUE; 230 if (argc != 3) usage ();235 if (argc != 3) relphot_usage (); 231 236 232 237 return TRUE; 233 238 } 234 235 void usage () {236 fprintf (stderr, "ERROR: USAGE: relphot (region) (photcode)\n");237 fprintf (stderr, " or: relphot (photcode) -region RA RA DEC DEC\n");238 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n");239 fprintf (stderr, " options: \n");240 fprintf (stderr, " -time (start) (stop)\n");241 fprintf (stderr, " -v : verbose output\n");242 fprintf (stderr, " -vv : more verbose output\n");243 fprintf (stderr, " -outroot (outroot)\n");244 fprintf (stderr, " -plot\n");245 fprintf (stderr, " -plotdelay (seconds)\n");246 fprintf (stderr, " -statmode (mode)\n");247 fprintf (stderr, " -refcode (name) : give extra weight to this photcode\n");248 fprintf (stderr, " -n (nloop)\n");249 fprintf (stderr, " -reset\n");250 fprintf (stderr, " -update\n");251 fprintf (stderr, " -params\n");252 fprintf (stderr, " -mosaic (mosaic)\n");253 fprintf (stderr, " -imfreeze\n");254 fprintf (stderr, " -grid\n");255 fprintf (stderr, " -area Xmin Xmax Ymin Ymax\n");256 fprintf (stderr, " -instmag min max\n");257 fprintf (stderr, " \n");258 exit (2);259 } -
trunk/Ohana/src/relphot/src/bcatalog.c
r28660 r30616 119 119 120 120 if (VERBOSE) { 121 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog \n",122 subcatalog[0].Naverage, subcatalog[0].Nmeasure, i);121 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog %s\n", 122 subcatalog[0].Naverage, subcatalog[0].Nmeasure, i, catalog[0].filename); 123 123 fprintf (stderr, "rejections: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d few\n", 124 124 Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew); -
trunk/Ohana/src/relphot/src/initialize.c
r29001 r30616 5 5 int N; 6 6 7 relphot_help (argc, argv); 7 8 ConfigInit (&argc, argv); 8 9 args (argc, argv); -
trunk/Ohana/src/relphot/src/load_catalogs.c
r29754 r30616 6 6 Catalog *catalog, tcatalog; 7 7 8 if (VERBOSE ) fprintf (stderr, "loading catalog data\n");8 if (VERBOSE2) fprintf (stderr, "loading catalog data\n"); 9 9 10 10 ALLOCATE (catalog, Catalog, skylist[0].Nregions); … … 22 22 tcatalog.Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog 23 23 24 if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE , "r")) {24 if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE2, "r")) { 25 25 fprintf (stderr, "ERROR: failure reading catalog %s\n", tcatalog.filename); 26 26 exit (1); 27 27 } 28 if (VERBOSE && !tcatalog.Naves_disk) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); 28 if (!tcatalog.Naves_disk) { 29 if (VERBOSE2) { fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); } 30 dvo_catalog_unlock (&tcatalog); 31 dvo_catalog_free (&tcatalog); 32 continue; 33 } 34 29 35 Nstar_total += tcatalog.Naverage; 30 36 Nmeas_total += tcatalog.Nmeasure; -
trunk/Ohana/src/relphot/src/load_images.c
r29001 r30616 1 1 # include "relphot.h" 2 3 # define MARKTIME(MSG,...) { \ 4 float dtime; \ 5 gettimeofday (&stop, (void *) NULL); \ 6 dtime = DTIME (stop, start); \ 7 fprintf (stderr, MSG, __VA_ARGS__); } 2 8 3 9 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect) { … … 6 12 off_t Nimage, Nsubset, Nchar; 7 13 off_t *LineNumber; 14 struct timeval start, stop; 8 15 9 16 SkyTable *sky = NULL; 10 17 SkyList *skylist = NULL; 18 19 gettimeofday (&start, (void *) NULL); 11 20 12 21 // load the current sky table (layout of all SkyRegions) … … 29 38 exit (2); 30 39 } 40 MARKTIME("read image table: %f sec\n", dtime); 31 41 32 42 // select the images which overlap the selected sky regions 33 43 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 44 MARKTIME("selected images: %f sec\n", dtime); 34 45 35 46 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 47 MARKTIME("converted ftable to vtable: %f sec\n", dtime); 36 48 37 49 initImages (subset, Nsubset); 50 MARKTIME("init images: %f sec\n", dtime); 51 38 52 initMosaics (subset, Nsubset); 53 MARKTIME("init mosaics: %f sec\n", dtime); 39 54 40 55 return (skylist); -
trunk/Ohana/src/relphot/src/relphot.c
r27480 r30616 85 85 if (PLOTSTUFF) { 86 86 plot_star_coords (catalog, Ncatalog); 87 plot_mosaic_fields (catalog);87 // plot_mosaic_fields (catalog); 88 88 } 89 89 -
trunk/Ohana/src/relphot/src/select_images.c
r29001 r30616 15 15 void dsortindex (double *X, off_t *Y, int N); 16 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 18 # define MARKTIME(MSG,...) { \ 19 float dtime; \ 20 gettimeofday (&stop, (void *) NULL); \ 21 dtime = DTIME (stop, start); \ 22 fprintf (stderr, MSG, __VA_ARGS__); } 17 23 18 24 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage) { … … 25 31 Coords tcoords; 26 32 SkyRegionCoords *skycoords; 27 33 struct timeval start, stop; 34 35 double RmaxSkyRegion, RminSkyRegion, DminSkyRegion, DmaxSkyRegion, RmidSkyRegion; 36 28 37 double *RmaxSky; 29 38 off_t *index; … … 35 44 return NULL; 36 45 } 46 47 gettimeofday (&start, (void *) NULL); 37 48 38 49 // the comparison is made in the catalog local projection. below we set crval1,2 … … 47 58 ALLOCATE (RmaxSky, double, skylist[0].Nregions); 48 59 ALLOCATE (index, off_t, skylist[0].Nregions); 60 61 RminSkyRegion = +360.0; 62 RmaxSkyRegion = -360.0; 63 DminSkyRegion = +90.0; 64 DmaxSkyRegion = -90.0; 49 65 50 66 /* compare with each region file */ … … 75 91 skycoords[i].Xc[3] -= dx; skycoords[i].Yc[3] += dy; 76 92 skycoords[i].Xc[4] -= dx; skycoords[i].Yc[4] -= dy; 77 } 93 94 RminSkyRegion = MIN(RminSkyRegion, skylist[0].regions[i][0].Rmin); 95 RmaxSkyRegion = MAX(RmaxSkyRegion, skylist[0].regions[i][0].Rmax); 96 DminSkyRegion = MIN(DminSkyRegion, skylist[0].regions[i][0].Dmin); 97 DmaxSkyRegion = MAX(DmaxSkyRegion, skylist[0].regions[i][0].Dmax); 98 } 99 RmidSkyRegion = 0.5*(RminSkyRegion + RmaxSkyRegion); 100 MARKTIME("create sky region coords: %f sec\n", dtime); 78 101 79 102 dsortindex (RmaxSky, index, skylist[0].Nregions); 103 MARKTIME("sort sky coords: %f sec\n", dtime); 80 104 81 105 if (VERBOSE) fprintf (stderr, "finding images\n"); 82 106 BuildChipMatch (timage, Ntimage); 107 MARKTIME("build chip match: %f sec\n", dtime); 83 108 84 109 nimage = 0; … … 100 125 } 101 126 127 // this adds 1.3 sec for 3M images 102 128 if (!FindMosaicForImage (timage, Ntimage, i)) { 103 129 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i); … … 113 139 found = FALSE; 114 140 115 /* transform corners to ra,dec */141 /* transform corners to ra,dec -- costs ~3sec for 3M images */ 116 142 double RminImage = 360.0; 143 double RmaxImage = 0.0; 144 double DminImage = +90.0; 145 double DmaxImage = -90.0; 117 146 for (j = 0; j < 5; j++) { 118 147 XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords); 148 Ri[j] = ohana_normalize_angle_to_midpoint (Ri[j], RmidSkyRegion); 149 119 150 RminImage = MIN(RminImage, Ri[j]); 120 } 121 122 // RA(nStart) is guaranteed to be < RminImage: 151 RmaxImage = MAX(RmaxImage, Ri[j]); 152 DminImage = MIN(DminImage, Di[j]); 153 DmaxImage = MAX(DmaxImage, Di[j]); 154 } 155 if (RmaxImage - RminImage > 180.0) { 156 double tmp = RminImage; 157 RmaxImage = RminImage; 158 RminImage = tmp - 360.0; 159 } 160 161 // check that this image is even in range of the searched region 162 if (DminImage > DmaxSkyRegion) continue; 163 if (DmaxImage < DminSkyRegion) continue; 164 165 // the sky region RA is defined to be 0 - 360.0 166 if (RminImage > RmaxSkyRegion) continue; 167 if (RmaxImage < RminSkyRegion) continue; 168 169 // image overlaps region, keep it 170 if (USE_BASIC_CHECK) goto found_it; 171 172 // RA(nStart) is guaranteed to be < RminImage: -- costs 0.5sec for 3M images 123 173 nStart = getRegionStartByRA (RminImage, RmaxSky, skylist[0].Nregions); 124 174 125 175 /* compare with each region file */ 126 for (iSky = 0; (iSky < skylist[0].Nregions) && !found; iSky++) {176 for (iSky = nStart; (iSky < skylist[0].Nregions) && !found; iSky++) { 127 177 128 178 m = index[iSky]; … … 142 192 for (j = 0; (j < 4) && !found; j++) { 143 193 found = corner_check (&Xi[j], &Yi[j], &skycoords[m].Xc[0], &skycoords[m].Yc[0]); 194 if (found) goto found_it; 144 195 } 145 196 /* check if catalog corner inside image */ 146 197 for (j = 0; (j < 4) && !found; j++) { 147 198 found = corner_check (&skycoords[m].Xc[j], &skycoords[m].Yc[j], &Xi[0], &Yi[0]); 199 if (found) goto found_it; 148 200 } 149 201 /* check if edges cross */ … … 151 203 for (k = 0; (k < 4) && !found; k++) { 152 204 found = edge_check (&Xi[j], &Yi[j], &skycoords[m].Xc[k], &skycoords[m].Yc[k]); 205 if (found) goto found_it; 153 206 } 154 207 } 155 if (!found) continue; 156 157 image[nimage] = timage[i]; 158 /* always allow 'few' images to succeed, if possible */ 159 if (image[nimage].flags & ID_IMAGE_PHOTOM_FEW) { 160 image[nimage].flags &= ~(ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR); 161 } 162 if (RESET) { 163 assignMcal (&image[nimage], (double *) NULL, -1); 164 image[nimage].dMcal = NAN; 165 image[nimage].flags &= ~ID_IMAGE_PHOTOM_POOR; 166 } 167 line_number[nimage] = i; 168 nimage ++; 169 if (nimage == NIMAGE) { 170 NIMAGE += 100; 171 REALLOCATE (image, Image, NIMAGE); 172 REALLOCATE (line_number, off_t, NIMAGE); 173 } 174 } 175 } 176 208 } 209 if (!found) continue; 210 211 found_it: 212 image[nimage] = timage[i]; 213 /* always allow 'few' images to succeed, if possible */ 214 if (image[nimage].flags & ID_IMAGE_PHOTOM_FEW) { 215 image[nimage].flags &= ~(ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR); 216 } 217 if (RESET) { 218 // XXX assignMcal (&image[nimage], (double *) NULL, -1); 219 // XXX this needs to be thought through a bit more 220 image[nimage].Mcal = 0.0; 221 image[nimage].dMcal = NAN; 222 image[nimage].flags &= ~ID_IMAGE_PHOTOM_POOR; 223 } 224 line_number[nimage] = i; 225 nimage ++; 226 if (nimage == NIMAGE) { 227 NIMAGE += 100; 228 REALLOCATE (image, Image, NIMAGE); 229 REALLOCATE (line_number, off_t, NIMAGE); 230 } 231 } 232 MARKTIME("finish image selection: %f sec\n", dtime); 233 177 234 if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage); 178 235 … … 295 352 return (Nlo); 296 353 } 354 355 off_t getRegionStopByRA (double R, double *Rref, off_t Nregions) { 356 357 // use bisection to find the overlapping mosaic 358 359 off_t Nlo, Nhi, N; 360 361 // find the last mosaic before start 362 Nlo = 0; Nhi = Nregions; 363 while (Nhi - Nlo > 10) { 364 N = 0.5*(Nlo + Nhi); 365 if (Rref[N] < R) { 366 Nlo = MAX(N, 0); 367 } else { 368 Nhi = MIN(N, Nregions); 369 } 370 } 371 return (Nlo); 372 }
Note:
See TracChangeset
for help on using the changeset viewer.
