Changeset 31664
- Timestamp:
- Jun 22, 2011, 12:35:53 AM (15 years ago)
- Location:
- trunk/Ohana/src/relastro
- Files:
-
- 5 edited
-
include/relastro.h (modified) (3 diffs)
-
src/ImageOps.c (modified) (3 diffs)
-
src/args.c (modified) (2 diffs)
-
src/bcatalog.c (modified) (4 diffs)
-
src/load_images.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relastro/include/relastro.h
r31642 r31664 120 120 int PLOTDELAY; 121 121 int CHIPORDER; 122 123 int MaxDensityUse; 124 double MaxDensityValue; 122 125 123 126 int UserCatalog; … … 363 366 364 367 int GetScatterRawRef(float *dLsig, float *dMsig, float *dRsig, int *nKeep, StarData *raw, StarData *ref, int Nstars, float SigmaLimit); 368 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog); 365 369 366 370 int initializeConstraints(); … … 368 372 int applyConstraintsB(Catalog *catalog, off_t i); 369 373 void setupAreaSelection(SkyRegion *region); 370 -
trunk/Ohana/src/relastro/src/ImageOps.c
r30616 r31664 115 115 Nlist[i] = 0; 116 116 NLIST[i] = 100; 117 ALLOCATE (clist[i], int, NLIST[i]);118 ALLOCATE (mlist[i], off_t, NLIST[i]);117 clist[i] = NULL; // we allocate these iff they are needed in matchImage 118 mlist[i] = NULL; // we allocate these iff they are needed in matchImage 119 119 } 120 120 … … 141 141 free (bin); 142 142 for (i = 0; i < Nimage; i++) { 143 free (clist[i]);144 free (mlist[i]);143 if (clist[i]) { free (clist[i]); } 144 if (mlist[i]) { free (mlist[i]); } 145 145 } 146 146 free (clist); … … 191 191 // index for (catalog, measure) -> image 192 192 bin[cat][meas] = idx; 193 194 // if we need to allocate an image index table, do so here 195 if (!clist[idx]) { 196 ALLOCATE (clist[idx], int, NLIST[idx]); 197 } 198 if (!mlist[idx]) { 199 ALLOCATE (mlist[idx], off_t, NLIST[idx]); 200 } 193 201 194 202 // index for image, Nentry -> catalog -
trunk/Ohana/src/relastro/src/args.c
r31637 r31664 102 102 remove_argument (N, &argc, argv); 103 103 USE_BASIC_CHECK = TRUE; 104 } 105 106 MaxDensityUse = FALSE; 107 if ((N = get_argument (argc, argv, "-max-density"))) { 108 remove_argument (N, &argc, argv); 109 MaxDensityValue = atof(argv[N]); 110 remove_argument (N, &argc, argv); 111 MaxDensityUse = TRUE; 104 112 } 105 113 … … 315 323 fprintf (stderr, " -plotdelay (seconds)\n"); 316 324 fprintf (stderr, " -statmode (mode)\n"); 317 fprintf (stderr, " -reset ");318 fprintf (stderr, " -nloop (N) : number of image-fit iterations ");325 fprintf (stderr, " -reset\n"); 326 fprintf (stderr, " -nloop (N) : number of image-fit iterations\n"); 319 327 fprintf (stderr, " -update : apply new fit to database\n"); 320 328 fprintf (stderr, " -params\n"); -
trunk/Ohana/src/relastro/src/bcatalog.c
r30616 r31664 70 70 // allowed. 71 71 72 // CopyMeasureTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]); 73 74 subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset]; 72 75 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_SKIP_ASTROM; 73 76 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_NOCAL; 74 subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset];75 77 subcatalog[0].measure[Nmeasure].averef = Naverage; 76 78 if (RESET) { … … 96 98 REALLOCATE (subcatalog[0].average, Average, MAX (Naverage, 1)); 97 99 REALLOCATE (subcatalog[0].measure, Measure, MAX (Nmeasure, 1)); 98 REALLOCATE (subcatalog[0].secfilt, SecFilt, Nsecfilt*MAX (Naverage, 1));100 REALLOCATE (subcatalog[0].secfilt, SecFilt, MAX (Naverage, 1)*Nsecfilt); 99 101 subcatalog[0].Naverage = Naverage; 100 102 subcatalog[0].Nmeasure = Nmeasure; … … 103 105 assert (Nsecfilt == catalog[0].Nsecfilt); 104 106 107 // limit the total number of stars in the catalog 108 if (MaxDensityUse) { 109 LimitDensityCatalog (subcatalog, catalog); 110 } 111 105 112 if (VERBOSE) { 106 113 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures) for catalog\n", i, subcatalog[0].Naverage, subcatalog[0].Nmeasure); … … 108 115 return (TRUE); 109 116 } 117 118 /* this version does NOT use AverageTiny, MeasureTiny */ 119 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog) { 120 121 Catalog tmpcatalog; 122 123 double Rmin, Rmax, Dmin, Dmax; 124 125 int Nsecfilt = GetPhotcodeNsecfilt (); 126 127 gfits_scan (&catalog[0].header, "RA0", "%lf", 1, &Rmin); 128 gfits_scan (&catalog[0].header, "DEC0", "%lf", 1, &Dmin); 129 gfits_scan (&catalog[0].header, "RA1", "%lf", 1, &Rmax); 130 gfits_scan (&catalog[0].header, "DEC1", "%lf", 1, &Dmax); 131 132 if (VERBOSE2) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax); 133 134 float AREA = fabs(Dmax - Dmin) * fabs(Rmax - Rmin) * cos (0.5*RAD_DEG*(Dmax + Dmin)); 135 assert (AREA > 0); 136 137 off_t Nmax = MaxDensityValue * AREA; 138 if (subcatalog[0].Naverage <= Nmax) { 139 if (VERBOSE) { 140 fprintf (stderr, "subcatalog has less than the max density\n"); 141 } 142 return (TRUE); 143 } 144 145 off_t Naverage = subcatalog[0].Naverage; 146 147 // select a random subset of Nmax stars from subcatalog using Fisher-Yates 148 149 // we are going to select Nmax entries by generating a random-sorted index list 150 off_t *index, tmp, i, j, ave; 151 ALLOCATE (index, off_t, Naverage); 152 for (i = 0; i < Naverage; i++) { 153 index[i] = i; 154 } 155 for (i = 0; i < Naverage; i++) { 156 j = (Naverage - i) * drand48() + i; // a number between i and Naverage 157 tmp = index[j]; 158 index[j] = index[i]; 159 index[i] = tmp; 160 } 161 162 // count the number of measurements this selection will yield 163 off_t NMEASURE = 0; 164 for (i = 0; i < Nmax; i++) { 165 ave = index[i]; 166 NMEASURE += subcatalog[0].average[ave].Nmeasure; 167 } 168 169 // allocate the output data 170 ALLOCATE (tmpcatalog.average, Average, Nmax); 171 ALLOCATE (tmpcatalog.measure, Measure, NMEASURE); 172 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nmax * Nsecfilt); 173 174 off_t Nmeasure = 0; 175 176 // copy the Nmax selected entries from subcatalog to tmpcatalog (adjusting links) 177 for (i = 0; i < Nmax; i++) { 178 ave = index[i]; 179 tmpcatalog.average[i] = subcatalog[0].average[ave]; 180 tmpcatalog.average[i].measureOffset = Nmeasure; 181 for (j = 0; j < tmpcatalog.average[i].Nmeasure; j++) { 182 off_t offset = subcatalog[0].average[ave].measureOffset + j; 183 tmpcatalog.measure[Nmeasure] = subcatalog[0].measure[offset]; 184 tmpcatalog.measure[Nmeasure].averef = i; 185 Nmeasure ++; 186 } 187 } 188 189 if (VERBOSE) { 190 fprintf (stderr, "limited to "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measures) for catalog %s\n", 191 Nmax, subcatalog[0].Naverage, Nmeasure, subcatalog[0].Nmeasure, catalog[0].filename); 192 } 193 194 free (subcatalog[0].average); 195 free (subcatalog[0].measure); 196 free (subcatalog[0].secfilt); 197 198 subcatalog[0].average = tmpcatalog.average; 199 subcatalog[0].measure = tmpcatalog.measure; 200 subcatalog[0].secfilt = tmpcatalog.secfilt; 201 subcatalog[0].Naverage = Nmax; 202 subcatalog[0].Nmeasure = Nmeasure; 203 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 204 subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt; 205 206 return (TRUE); 207 } 208 -
trunk/Ohana/src/relastro/src/load_images.c
r29001 r31664 44 44 MARKTIME(" select images: %f sec\n", dtime); 45 45 46 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 46 // generate db->vtable from db->ftable based on the selection 47 // XXX does this simply duplicate the memory needlessly? we recreate these lines 48 // in reload_images. If we had saved the line numbers, we could avoid this 49 // vtable points *another* copy of the subset rows 50 // (the later call to 'reload_images' copies the subset elements back on top of 51 // the rows of the vtable) 52 // gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 53 // MARKTIME("converted ftable to vtable: %f sec\n", dtime); 47 54 48 55 initImages (subset, Nsubset);
Note:
See TracChangeset
for help on using the changeset viewer.
