Changeset 35287
- Timestamp:
- Mar 9, 2013, 3:00:20 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130307/Ohana/src/relastro
- Files:
-
- 1 added
- 6 edited
-
Makefile (modified) (2 diffs)
-
include/relastro.h (modified) (2 diffs)
-
src/args.c (modified) (6 diffs)
-
src/hpm_catalogs.c (added)
-
src/hpm_objects.c (modified) (13 diffs)
-
src/relastro.c (modified) (1 diff)
-
src/relastro_client.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130307/Ohana/src/relastro/Makefile
r33652 r35287 64 64 $(SRC)/high_speed_objects.$(ARCH).o \ 65 65 $(SRC)/high_speed_utils.$(ARCH).o \ 66 $(SRC)/hpm_catalogs.$(ARCH).o \ 67 $(SRC)/hpm_objects.$(ARCH).o \ 66 68 $(SRC)/relastro_merge_source.$(ARCH).o \ 67 69 $(SRC)/resort_catalog.$(ARCH).o \ … … 106 108 $(SRC)/high_speed_objects.$(ARCH).o \ 107 109 $(SRC)/high_speed_utils.$(ARCH).o \ 110 $(SRC)/hpm_catalogs.$(ARCH).o \ 111 $(SRC)/hpm_objects.$(ARCH).o \ 108 112 $(SRC)/relastro_merge_source.$(ARCH).o \ 109 113 $(SRC)/resort_catalog.$(ARCH).o \ -
branches/eam_branches/ipp-20130307/Ohana/src/relastro/include/relastro.h
r35105 r35287 20 20 typedef enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR} FitMode; 21 21 22 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS } FitTarget;22 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS, TARGET_HPM} FitTarget; 23 23 24 24 typedef enum { … … 442 442 443 443 PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes, int needAve); 444 445 int hpm_catalogs (SkyTable *sky, SkyList *skylist, int hostID, char *hostpath); 446 int hpm_catalogs_parallel (SkyList *skylist); 447 int hpm_objects (SkyRegion *region, Catalog *catalog); -
branches/eam_branches/ipp-20130307/Ohana/src/relastro/src/args.c
r34749 r35287 89 89 if ((N = get_argument (argc, argv, "-high-speed"))) { 90 90 // XXX include a parallax / no-parallax option 91 if (N >= argc - 5) usage(); 92 FIT_TARGET = TARGET_HIGH_SPEED; 93 remove_argument (N, &argc, argv); 94 PHOTCODE_A_LIST = strcreate(argv[N]); 95 remove_argument (N, &argc, argv); 96 PHOTCODE_B_LIST = strcreate(argv[N]); 97 remove_argument (N, &argc, argv); 98 RADIUS = atof(argv[N]); 99 remove_argument (N, &argc, argv); 100 HIGH_SPEED_DIR = abspath(argv[N], DVO_MAX_PATH); 101 remove_argument (N, &argc, argv); 102 } 103 104 if ((N = get_argument (argc, argv, "-hpm"))) { 91 105 if (N >= argc - 3) usage(); 92 FIT_TARGET = TARGET_HIGH_SPEED; 93 remove_argument (N, &argc, argv); 94 PHOTCODE_A_LIST = strcreate(argv[N]); 95 remove_argument (N, &argc, argv); 96 PHOTCODE_B_LIST = strcreate(argv[N]); 106 FIT_TARGET = TARGET_HPM; 97 107 remove_argument (N, &argc, argv); 98 108 RADIUS = atof(argv[N]); … … 106 116 remove_argument (N, &argc, argv); 107 117 PARALLEL_OUTPUT = TRUE; 108 if ( FIT_TARGET != TARGET_HIGH_SPEED) {109 fprintf (stderr, "-parallel-output only valid for -high-speed mode\n");118 if ((FIT_TARGET != TARGET_HIGH_SPEED) && (FIT_TARGET != TARGET_HPM)) { 119 fprintf (stderr, "-parallel-output only valid for -high-speed or -hpm modes\n"); 110 120 exit (1); 111 121 } … … 456 466 if ((N = get_argument (argc, argv, "-high-speed"))) { 457 467 // XXX include a parallax / no-parallax option 458 if (N >= argc - 3) usage_client();468 if (N >= argc - 5) usage_client(); 459 469 FIT_TARGET = TARGET_HIGH_SPEED; 460 470 remove_argument (N, &argc, argv); … … 466 476 remove_argument (N, &argc, argv); 467 477 HIGH_SPEED_DIR = strcreate(argv[N]); 478 remove_argument (N, &argc, argv); 479 } 480 481 if ((N = get_argument (argc, argv, "-hpm"))) { 482 if (N >= argc - 3) usage(); 483 FIT_TARGET = TARGET_HPM; 484 remove_argument (N, &argc, argv); 485 RADIUS = atof(argv[N]); 486 remove_argument (N, &argc, argv); 487 HIGH_SPEED_DIR = abspath(argv[N], DVO_MAX_PATH); 468 488 remove_argument (N, &argc, argv); 469 489 } … … 668 688 fprintf (stderr, " OR: relastro -update-objects [options]\n"); 669 689 fprintf (stderr, " OR: relastro -high-speed [options]\n"); 690 fprintf (stderr, " OR: relastro -hpm [options]\n"); 670 691 fprintf (stderr, " OR: relastro -merge-source [options]\n\n"); 671 692 … … 679 700 fprintf (stderr, " -update-mosaics\n"); 680 701 fprintf (stderr, " -high-speed (code[,code,code]) (code[,code,code]) (radius) (output catdir)\n"); 702 fprintf (stderr, " -hpm (radius) (output catdir)\n"); 681 703 fprintf (stderr, " -merge-source (objID) (catID) into (objID) (catID)\n\n"); 682 704 -
branches/eam_branches/ipp-20130307/Ohana/src/relastro/src/hpm_objects.c
r35286 r35287 1 1 # include "relastro.h" 2 # define MAX_TRANGE 180.0 3 # define MIN_PS1_DET 3 4 # define MAX_CHISQ_PM 10.0 5 # define MIN_NPOS_FRAC 0.8 2 6 3 7 # define NEXT_I { if (Ngroup < 2) slowMoving[ni] = TRUE; newI = TRUE; i++; continue; } … … 6 10 int hpm_objects (SkyRegion *region, Catalog *catalog) { 7 11 8 off_t i, j, m, J, ni, nj, *N1; 9 off_t Nslow, Ninvalid, NgroupA, NgroupB, NgroupAbad, NgroupBbad; 10 off_t l, i1, NAVERAGE, NMEASURE; 11 int *slowMoving, *groupA, *groupB, status, Nmatch, Nmatchmeas, Nepoch, nv[2], Nmatchmeasobj; 12 int foundA, foundB, XVERB; 12 off_t i, j, J, ni, nj, *N1, k, m; 13 int *slowMoving; 13 14 double *X1, *Y1; 14 15 double dX, dY, dR, RADIUS2; 15 16 Coords tcoords; 16 Catalog catalogOut; 17 Catalog testcat; 17 Catalog catalogOut, testcat; 18 18 19 19 int Nsecfilt; 20 20 char filename[1024]; 21 21 22 // XXX are we saving these in an hpm dvodb? 22 // we need at least 2 objects if we are going to match anything... 23 if (catalog[0].Naverage < 2) return (TRUE); 24 if (VERBOSE) fprintf (stderr, "checking "OFF_T_FMT" objects\n", catalog[0].Naverage); 25 26 // we save the best objects in an hpm dvodb 23 27 snprintf (filename, 1024, "%s/%s.cpt", HIGH_SPEED_DIR, region[0].name); 24 fprintf (stderr, "%s\n",filename); 25 26 dvo_catalog_init (&catalogOut, TRUE); /*initialise new catalogue*/ 28 29 dvo_catalog_init (&catalogOut, TRUE); /* init new catalog */ 27 30 catalogOut.filename = strcreate(filename); 28 31 29 SIGMA_LIM = 0.0;30 31 32 Nsecfilt = GetPhotcodeNsecfilt(); 32 // off_t Naverage = catalog[0].Naverage; 33 // off_t Nmeasure = catalog[0].Nmeasure; 34 catalogOut.filename = filename; // based on the input name, need to keep everything below the catdir portion 33 catalogOut.filename = filename; 35 34 catalogOut.Nsecfilt = Nsecfilt; 36 35 catalogOut.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; // load all data … … 45 44 } 46 45 47 NAVERAGE = 1000;48 NMEASURE = 10000;46 off_t NAVERAGE = 1000; 47 off_t NMEASURE = 10000; 49 48 REALLOCATE (catalogOut.average, Average, NAVERAGE); 50 49 REALLOCATE (catalogOut.measure, Measure, NMEASURE); 51 50 REALLOCATE (catalogOut.secfilt, SecFilt, NAVERAGE*Nsecfilt); 51 catalogOut.Naverage = 0; 52 catalogOut.Nmeasure = 0; 52 53 53 54 // testcat is used to determine the fit for a single object group … … 55 56 dvo_catalog_init (&testcat, TRUE); 56 57 testcat.Naverage = 1; // this is fixed -- only one obj in testcat 57 NMEASURE_TEST = 1000;58 off_t NMEASURE_TESTCAT = 1000; 58 59 REALLOCATE (catalogOut.average, Average, 1); 59 REALLOCATE (catalogOut.measure, Measure, NMEASURE_TEST );60 REALLOCATE (catalogOut.measure, Measure, NMEASURE_TESTCAT); 60 61 REALLOCATE (catalogOut.secfilt, SecFilt, Nsecfilt); 61 62 // we need at least 2 objects if we are going to match anything...63 if (catalog[0].Naverage < 2) return (TRUE);64 62 65 63 // mask with which to mark objects to be ignored 66 64 ALLOCATE (slowMoving, int, catalog[0].Naverage); 67 65 memset (slowMoving, 0, catalog[0].Naverage*sizeof(int)); 68 69 if (VERBOSE) fprintf (stderr, "checking "OFF_T_FMT" objects\n", catalog[0].Naverage); 70 Nslow = 0; 71 Ninvalid = 0; 72 NgroupAbad = 0; 73 NgroupBbad = 0; 74 75 // mark (exclude) objects with both sets of target photcodes 66 off_t Nslow = 0; 67 68 // mark (exclude) objects which do not meet the selection criterion 76 69 for (i = 0; i < catalog[0].Naverage; i++) { 77 70 78 XVERB = (catalog[0].average[i].objID == OBJ_ID_SRC) && (catalog[0].average[i].catID == CAT_ID_SRC); 71 int XVERB = FALSE; 72 XVERB |= (catalog[0].average[i].objID == OBJ_ID_SRC) && (catalog[0].average[i].catID == CAT_ID_SRC); 79 73 XVERB |= (catalog[0].average[i].objID == OBJ_ID_DST) && (catalog[0].average[i].catID == CAT_ID_DST); 80 74 if (XVERB) { … … 82 76 } 83 77 84 // selection criteria: 85 // (Nps1 > 2) && (Trange < 180) 78 // selection criteria : (Nps1 > 2) && (Trange < 180) 86 79 if (catalog[0].average[i].Trange > MAX_TRANGE) { 87 80 slowMoving[i] = TRUE; … … 129 122 /* build spatial index (RA sort) referencing input array sequence */ 130 123 for (i = 0; i < catalog[0].Naverage; i++) { 131 status = RD_to_XY (&X1[i], &Y1[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords);124 int status = RD_to_XY (&X1[i], &Y1[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords); 132 125 N1[i] = i; 133 126 assert (status); … … 135 128 sort_coords_index (X1, Y1, N1, catalog[0].Naverage); 136 129 137 Nmatch = 0;138 Nmatchmeas = 0;139 130 RADIUS2 = SQ(RADIUS); 140 131 141 132 // group is a list of objects that are within a clump. this set will be tested 142 133 // via a clipped fit to the measurements after the group is identified 143 Ngroup = 0; 144 NGROUP = 100; 134 int Ngroup = 0; 135 int NGROUP = 100; 136 int *group = NULL; 145 137 ALLOCATE (group, int, NGROUP); 146 138 147 139 // in the loop below, we need to do a bunch of things when we go to the next main object 148 newI = TRUE;140 int newI = TRUE; 149 141 150 142 // mark (skip) objects with both sets of target photcodes … … 159 151 160 152 if (newI) { 161 Nmatch = 0;162 153 Ngroup = 1; 163 154 group[0] = ni; … … 165 156 } 166 157 167 XVERB = (catalog[0].average[ni].objID == OBJ_ID_SRC) && (catalog[0].average[ni].catID == CAT_ID_SRC); 158 int XVERB = FALSE; 159 XVERB |= (catalog[0].average[ni].objID == OBJ_ID_SRC) && (catalog[0].average[ni].catID == CAT_ID_SRC); 168 160 XVERB |= (catalog[0].average[nj].objID == OBJ_ID_DST) && (catalog[0].average[nj].catID == CAT_ID_DST); 169 161 if (XVERB) { … … 186 178 if (dX >= +1.02*RADIUS) NEXT_J; // positive dX: j is too small 187 179 188 // within match range; look for valid matches 180 // within match range; look for valid matches & accumulate the group 189 181 for (J = j; (dX > -1.02*RADIUS) && (J < catalog[0].Naverage); J++) { 190 182 if (J == i) continue; // avoid auto-matches … … 219 211 // the mean object will start with info from the primary object 220 212 // remember: testcat.Naverage = 1 -- does not change 221 testcat.average[0] = catalog[0].average[group[0]]; 213 ni = group[0]; 214 int Nmatchmeas = 0; 215 testcat.average[0] = catalog[0].average[ni]; 222 216 testcat.average[0].measureOffset = 0; 223 Nmatchmeas = 0;224 I = group[0];225 217 for (J = 0; J < Ngroup; J++) { 226 J= group[J];227 m = catalog[0].average[ Nj].measureOffset;228 for (k = 0; k < catalog[0].average[ Nj].Nmeasure; k++) {218 nj = group[J]; 219 m = catalog[0].average[nj].measureOffset; 220 for (k = 0; k < catalog[0].average[nj].Nmeasure; k++) { 229 221 testcat.measure[Nmatchmeas] = catalog[0].measure[m+k]; 230 222 /* Set offset RA and Dec wrt correct average value*/ 231 testcat.measure[Nmatchmeas].dR = catalog[0].measure[m+k].dR + 3600.0*(catalog[0].average[ I].R - catalog[0].average[J].R);232 testcat.measure[Nmatchmeas].dD = catalog[0].measure[m+k].dD + 3600.0*(catalog[0].average[ I].D - catalog[0].average[J].D);223 testcat.measure[Nmatchmeas].dR = catalog[0].measure[m+k].dR + 3600.0*(catalog[0].average[ni].R - catalog[0].average[nj].R); 224 testcat.measure[Nmatchmeas].dD = catalog[0].measure[m+k].dD + 3600.0*(catalog[0].average[ni].D - catalog[0].average[nj].D); 233 225 testcat.measure[Nmatchmeas].averef = 0; 234 226 Nmatchmeas++; 235 CHECK_REALLOCATE (testcat.measure, Measure, NMEASURE_TEST , Nmatchmeas, 1000);227 CHECK_REALLOCATE (testcat.measure, Measure, NMEASURE_TESTCAT, Nmatchmeas, 1000); 236 228 } 237 229 } … … 244 236 UpdateObjects (&testcat, 1); 245 237 246 // logic for keeping the fit :247 i f (testcat.average[0].ChiSqPM < XXX) good = TRUE;248 if (testcat.average[0].Npos > 0.X * testcat.average[0].Nmeasure) good = TRUE;249 // what else?238 // logic for keeping the fit (anything else?) 239 int good = FALSE; 240 good |= (testcat.average[0].ChiSqPM < MAX_CHISQ_PM); 241 good |= (testcat.average[0].Npos > MIN_NPOS_FRAC * testcat.average[0].Nmeasure); 250 242 251 243 if (good) { 252 244 // save the new object on catalogOut 253 { 254 catalogOut.average[Nout] = testcat.average[0]; 255 catalogOut.average[Nout].measureOffset = Nmatchmeas; 256 m = testcat.average[0].measureOffset; 257 for (k = 0; k < testcat.average[0].Nmeasure; k++) { 258 catalogOut.measure[Noutmeas] = testcat.measure[m+k]; 259 catalogOut.measure[Noutmeas].averef = Nout; 260 } 261 Nout ++; 262 CHECK_REALLOCATE (catalogOut.average, Average, NAVERAGE, Nout, 100); 245 // (note: there is only one object in testcat and thus measureOffset = 0 246 catalogOut.average[catalogOut.Naverage] = testcat.average[0]; 247 catalogOut.average[catalogOut.Naverage].measureOffset = catalogOut.Nmeasure; 248 for (k = 0; k < testcat.average[0].Nmeasure; k++) { 249 catalogOut.measure[catalogOut.Nmeasure] = testcat.measure[k]; 250 catalogOut.measure[catalogOut.Nmeasure].averef = catalogOut.Naverage; 251 catalogOut.Nmeasure ++; 252 CHECK_REALLOCATE (catalogOut.measure, Measure, NMEASURE, catalogOut.Nmeasure, 100); 263 253 } 254 catalogOut.Naverage ++; 255 CHECK_REALLOCATE (catalogOut.average, Average, NAVERAGE, catalogOut.Naverage, 100); 264 256 } 265 257 NEXT_I; 266 258 } 267 268 catalogOut.Naverage=Nmatch; 269 catalogOut.Nmeasure=Nmatchmeas; 270 catalogOut.Nsecfilt=Nsecfilt; 271 catalogOut.Nsecf_mem=Nmatch*Nsecfilt; 259 catalogOut.Nsecfilt = Nsecfilt; 260 catalogOut.Nsecf_mem = Nsecfilt * catalogOut.Naverage; 272 261 273 262 populate_tiny_values (&catalogOut, DVO_TV_MEASURE); 274 263 UpdateObjects (&catalogOut, 1); 275 264 276 fprintf (stderr, "found %d matches\n", Nmatch);265 fprintf (stderr, "found "OFF_T_FMT" matches with "OFF_T_FMT" detections\n", catalogOut.Naverage, catalogOut.Nmeasure); 277 266 dvo_catalog_save (&catalogOut, VERBOSE2); 278 267 dvo_catalog_unlock (&catalogOut); 279 268 dvo_catalog_free (&catalogOut); 280 269 free (slowMoving); 281 free (groupA);282 free (groupB);283 270 free (X1); 284 271 free (Y1); … … 287 274 return TRUE; 288 275 } 289 290 // return TRUE if measure->photcode match any in the photcodeSet291 // (but, return FALSE if the measurement is bad)292 int MeasMatchesPhotcode(Measure *measure, PhotCode **photcodeSet, int Nset) {293 294 int found, k;295 296 if (!Nset) return TRUE;297 // XXX require a set or not? assert (Nset > 0);298 299 if (!finite(measure[0].dR)) return FALSE;300 if (!finite(measure[0].dD)) return FALSE;301 if (!finite(measure[0].M)) return FALSE;302 303 float dX = GetAstromError (measure, ERROR_MODE_RA);304 if (isnan(dX)) return FALSE;305 306 float dY = GetAstromError (measure, ERROR_MODE_DEC);307 if (isnan(dY)) return FALSE;308 309 /* select measurements by photcode, or equiv photcode, if specified */310 found = FALSE;311 for (k = 0; (k < Nset) && !found; k++) {312 if (photcodeSet[k][0].code == measure[0].photcode) found = TRUE;313 if (photcodeSet[k][0].code == GetPhotcodeEquivCodebyCode(measure[0].photcode)) found = TRUE;314 }315 316 return found;317 } -
branches/eam_branches/ipp-20130307/Ohana/src/relastro/src/relastro.c
r33652 r35287 19 19 /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */ 20 20 high_speed_catalogs (sky, skylist, 0, NULL); 21 exit (0); 22 23 case TARGET_HPM: 24 hpm_catalogs (sky, skylist, 0, NULL); 21 25 exit (0); 22 26 -
branches/eam_branches/ipp-20130307/Ohana/src/relastro/src/relastro_client.c
r33652 r35287 58 58 } 59 59 60 case TARGET_HPM: { 61 // USAGE: relastro_client -high-speed 62 hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR); 63 break; 64 } 65 60 66 // XXX loading the images is fairly costly -- see if we can do an image subset 61 67 case TARGET_UPDATE_OFFSETS: {
Note:
See TracChangeset
for help on using the changeset viewer.
