Changeset 42788 for trunk/Ohana/src/relphot
- Timestamp:
- Feb 7, 2025, 3:07:30 PM (17 months ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 1 added
- 5 edited
-
Makefile (modified) (1 diff)
-
include/relphot.h (modified) (3 diffs)
-
src/DumpAllMags.c (added)
-
src/GridIO.c (modified) (1 diff)
-
src/GridOps.c (modified) (9 diffs)
-
src/relphot_images.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/Makefile
r42112 r42788 82 82 $(SRC)/setExclusions.$(ARCH).o \ 83 83 $(SRC)/setMrelFinal.$(ARCH).o \ 84 $(SRC)/setMrelCatalog.$(ARCH).o \ 85 $(SRC)/BoundaryTreeOps.$(ARCH).o \ 84 $(SRC)/setMrelCatalog.$(ARCH).o \ 85 $(SRC)/BoundaryTreeOps.$(ARCH).o \ 86 $(SRC)/DumpAllMags.$(ARCH).o \ 86 87 $(SRC)/write_coords.$(ARCH).o 87 88 -
trunk/Ohana/src/relphot/include/relphot.h
r42389 r42788 160 160 float dY; // bin = int(Ychip * dY), dY = Ny / NyChip 161 161 // NxChip, NyChip = 4900,4900 for now 162 163 int **nAlloc; // allocated vector length 164 double ***dMval; // values used to calculate corrections 162 165 } GridCorrectionType; 163 166 … … 607 610 void initGridBins PROTO((void)); 608 611 GridCorrectionType *getGridCorrByCode PROTO((int code)); 612 GridCorrectionType *newGridCorrByCode PROTO((int code)); 609 613 GridCorrectionType *getGridCorrNext PROTO((int *Nlast)); 610 614 int GridCorrectionSave PROTO((void)); … … 894 898 double get_median_zpt_tgroups (short photcode); 895 899 void set_median_zpt_tgroups (short photcode, double zpt); 900 901 int DumpAllMags(char *filename, Catalog *catalog, int Ncatalog); -
trunk/Ohana/src/relphot/src/GridIO.c
r41647 r42788 151 151 152 152 if (!gfits_scan (&header, "PHOTCODE", "%d", 1, &photcode)) myAbort ("failed to get PHOTCODE"); 153 GridCorrectionType *GridCorr = getGridCorrByCode (photcode);153 GridCorrectionType *GridCorr = newGridCorrByCode (photcode); 154 154 GridCorr->photcode = photcode; 155 155 -
trunk/Ohana/src/relphot/src/GridOps.c
r41664 r42788 30 30 # define NX_CHIP_DEFAULT 1000 31 31 # define NY_CHIP_DEFAULT 1000 32 # define NX_BIN_DEFAULT 233 # define NY_BIN_DEFAULT 232 # define NX_BIN_DEFAULT 4 33 # define NY_BIN_DEFAULT 4 34 34 35 35 void initGridBins (void) { … … 76 76 if (GridCorr[code]->dMgrid) FREE (GridCorr[code]->dMgrid[ix]); 77 77 if (GridCorr[code]->nMgrid) FREE (GridCorr[code]->nMgrid[ix]); 78 if (GridCorr[code]->nAlloc) FREE (GridCorr[code]->nAlloc[ix]); 79 80 // dMval is a 2D array of vectors 81 for (int iy = 0; iy < GridCorr[code]->Ny; iy++) { 82 FREE (GridCorr[code]->dMval[ix][iy]); 83 } 84 FREE (GridCorr[code]->dMval[ix]); 78 85 } 79 86 … … 81 88 FREE (GridCorr[code]->dMgrid); 82 89 FREE (GridCorr[code]->nMgrid); 90 FREE (GridCorr[code]->nAlloc); 91 FREE (GridCorr[code]-> dMval); 83 92 84 93 FREE(GridCorr[code]); … … 109 118 } 110 119 111 GridCorrectionType *getGridCorrByCode (int code) { 120 // generate a new GridCorr structure in the array 121 GridCorrectionType *newGridCorrByCode (int code) { 112 122 113 123 if (GridCorr == NULL) return NULL; … … 116 126 if (code < 0) return NULL; 117 127 128 myAssert (GridCorr[code] == NULL, "oops, should not already be allocated!"); 118 129 ALLOCATE(GridCorr[code], GridCorrectionType, 1) 130 GridCorrectionType *result = GridCorr[code]; 131 return result; 132 } 133 134 // return the GridCode structure corresponding to 'code' 135 GridCorrectionType *getGridCorrByCode (int code) { 136 137 if (GridCorr == NULL) return NULL; 138 139 if (code >= NGridCorr) return NULL; 140 if (code < 0) return NULL; 141 119 142 GridCorrectionType *result = GridCorr[code]; 120 143 return result; … … 163 186 // we are normally accessing this array randomly, so there is no advantage to 164 187 // doing Mgrid[y][x] vs Mgrid[x][y] 188 ALLOCATE (GridCorr[code]-> dMval, double **, NX_BIN); 165 189 ALLOCATE (GridCorr[code]-> Mgrid, float *, NX_BIN); 166 190 ALLOCATE (GridCorr[code]->dMgrid, float *, NX_BIN); 167 191 ALLOCATE (GridCorr[code]->nMgrid, int *, NX_BIN); 192 ALLOCATE (GridCorr[code]->nAlloc, int *, NX_BIN); 168 193 for (int ix = 0; ix < NX_BIN; ix++) { 169 194 ALLOCATE (GridCorr[code]-> Mgrid[ix], float, NY_BIN); 170 195 ALLOCATE (GridCorr[code]->dMgrid[ix], float, NY_BIN); 171 196 ALLOCATE (GridCorr[code]->nMgrid[ix], int, NY_BIN); 197 ALLOCATE (GridCorr[code]->nAlloc[ix], int, NY_BIN); 198 199 // when we first allocate this array, set the elements to 0 (NULL) 200 // these arrays will be allocated or reallocated in resetMgrid 201 ALLOCATE_ZERO (GridCorr[code]-> dMval[ix], double *, NX_BIN); 172 202 } 173 203 } … … 190 220 GridCorr[code]->dMgrid[ix][iy] = 0.0; 191 221 GridCorr[code]->nMgrid[ix][iy] = 0; 222 GridCorr[code]->nAlloc[ix][iy] = 100; 223 224 // allocate or reset vector length to default 225 if (GridCorr[code]->dMval[ix][iy]) { 226 REALLOCATE (GridCorr[code]->dMval[ix][iy], double, GridCorr[code]->nAlloc[ix][iy]); 227 } else { 228 ALLOCATE (GridCorr[code]->dMval[ix][iy], double, GridCorr[code]->nAlloc[ix][iy]); 229 } 192 230 } 193 231 } … … 263 301 if (fabs(dM) > 0.5) continue; 264 302 265 grid-> Mgrid[ix][iy] += dM;266 grid-> dMgrid[ix][iy] += dM*dM;303 int ival = grid->nMgrid[ix][iy]; 304 grid-> dMval[ix][iy][ival] = dM; 267 305 grid->nMgrid[ix][iy] ++; 306 CHECK_REALLOCATE (grid-> dMval[ix][iy], double, grid->nAlloc[ix][iy], grid->nMgrid[ix][iy], 100); 307 308 /* XXX old code to calculate simple means: 309 grid-> Mgrid[ix][iy] += dM; 310 grid->dMgrid[ix][iy] += dM*dM; 311 grid->nMgrid[ix][iy] ++; 312 */ 268 313 } 269 314 } 270 315 } 316 317 StatType stats; 318 liststats_setmode (&stats, "MEDIAN"); 319 320 // now calculate Mgrid, dMgrid, nMgrid from Sum, Sum, Npt 321 for (int code = 0; code < NGridCorr; code++) { 322 if (!GridCorr[code]) continue; 323 324 for (int ix = 0; ix < GridCorr[code]->Nx; ix++) { 325 for (int iy = 0; iy < GridCorr[code]->Ny; iy++) { 326 327 // cells without sufficient coverage stay at 0.0 328 if (GridCorr[code]->nMgrid[ix][iy] < 5) { 329 GridCorr[code]-> Mgrid[ix][iy] = 0.0; 330 GridCorr[code]->dMgrid[ix][iy] = 0.0; 331 continue; 332 } 333 334 liststats_init (&stats); 335 336 liststats (GridCorr[code]->dMval[ix][iy], NULL, NULL, GridCorr[code]->nMgrid[ix][iy], &stats); 337 double altSigma = (stats.Upper80 - stats.Lower20) / 1.6; // 20% to 80% encompasses 60% of the values, corresponds to the range (-0.85 sigma : +0.85 sigma) 338 339 GridCorr[code]-> Mgrid[ix][iy] = stats.median; 340 GridCorr[code]->dMgrid[ix][iy] = altSigma; // sample stdev 341 } 342 } 343 } 344 return; 345 } 346 347 # if (0) 271 348 272 349 // now calculate Mgrid, dMgrid, nMgrid from Sum, Sum, Npt … … 300 377 // float GridAve = GridSum / GridCnt; 301 378 // fprintf (stderr, "grid average: %f\n", GridAve); 302 } 303 return; 304 } 379 # endif 305 380 306 381 float getMgrid (Measure *measure) { -
trunk/Ohana/src/relphot/src/relphot_images.c
r42132 r42788 147 147 MagResidSave ("mag.resid.fits", catalog); 148 148 149 // DumpAllMags ("all.mags.fits", catalog, Ncatalog); 150 149 151 save_images_updates (&db); 150 152
Note:
See TracChangeset
for help on using the changeset viewer.
