Changeset 12392
- Timestamp:
- Mar 9, 2007, 3:19:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libdvo/src/skyregion_gsc.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libdvo/src/skyregion_gsc.c
r12332 r12392 128 128 /* subdivide each zone */ 129 129 for (j = 0; j < Nzones; j++) { 130 if (DEBUG ) fprintf (stderr, "zone: %d : %f - %f : %f - %f\n", j, zones[j].Rmin, zones[j].Rmax, zones[j].Dmin, zones[j].Dmax);130 if (DEBUG >= 1) fprintf (stderr, "zone: %d : %f - %f : %f - %f\n", j, zones[j].Rmin, zones[j].Rmax, zones[j].Dmin, zones[j].Dmax); 131 131 SkyTableL2fromZone (&L2, &L3, &L4, band, &zones[j], i); 132 132 } … … 251 251 } 252 252 253 /* give a complete set of regions in a Dec band, subdivide into zones of equal-sized regions */ 253 /* given a complete set of regions in a Dec band, subdivide into zones of equal-sized regions. 254 * this function assumes the DEC band is sliced first by lines of constant RA, then subdivided 255 * with lines of constant DEC. Groups ('zones') of these smaller boxes have the same size in 256 * delta-Dec. We are trying to fine the boundaries of these zones. The initial assumption 257 * breaks down for the pole region (86.25 < DEC < 90), where the entire range is divided into a 258 * single circular patch. we need to treat it differently. 259 */ 260 254 261 SkyRegionZone *SkyRegionFindZones (SkyTable *band, int *Nzones, int parent) { 255 262 256 float Dmin, Dmax, dDec ;257 int i, Nz, NZ, Nregions;263 float Dmin, Dmax, dDec, dDecZone; 264 int i, j, Nz, NZ, Nregions, poleRegion; 258 265 SkyRegion *regions; 266 SkyRegion tempregion; 259 267 SkyRegionZone *zones; 268 char basename[64]; 260 269 261 270 regions = band[0].regions; 262 271 Nregions = band[0].Nregions; 263 272 264 Nz = 0;265 273 NZ = 10; 266 274 ALLOCATE (zones, SkyRegionZone, NZ); 267 275 268 zones[0].dDec = regions[0].Dmax - regions[0].Dmin; 269 zones[0].Rmin = regions[0].Rmin; 270 zones[0].L3start = 0; 271 zones[0].L1band = parent; 272 zones[0].Nset = NsetForDecRange (zones[0].dDec); 276 /* the pole regions need to be separately handled. skip in analysis below */ 277 poleRegion = 0; 273 278 274 279 /* search for transitions in the region dDec, find the max Dec range */ 275 Dmin = regions[0].Dmin; 276 Dmax = regions[0].Dmax; 280 Nz = -1; 281 dDecZone = -1; 282 Dmin = +90; 283 Dmax = -90; 277 284 for (i = 0; i < Nregions; i++) { 285 if ((regions[i].Dmin >= +86.00) || (regions[i].Dmax <= -86.00)) { 286 /* drop the pole region (re-generated below) */ 287 poleRegion = SIGN(regions[i].Dmin); 288 Nregions --; 289 tempregion = regions[i]; 290 for (j = i; j < Nregions; j++) { 291 regions[j] = regions[j+1]; 292 } 293 i--; 294 continue; 295 } 296 /* is this region in the current zone? */ 278 297 Dmin = MIN (regions[i].Dmin, Dmin); 279 298 Dmax = MAX (regions[i].Dmax, Dmax); 280 299 dDec = regions[i].Dmax - regions[i].Dmin; 281 300 if (fabs(dDec - zones[Nz].dDec) > 0.001) { 282 /* we've found the end of the current zone */ 283 zones[Nz].L3end = i; 284 zones[Nz].Rmax = regions[i-1].Rmax; 301 /* we've found the end of the current zone; set the ending info */ 302 if (Nz >= 0) { 303 zones[Nz].L3end = i; 304 zones[Nz].Rmax = regions[i-1].Rmax; 305 } 306 307 /* go to the next zone */ 285 308 Nz++; 286 309 CHECK_REALLOCATE (zones, SkyRegionZone, NZ, Nz, 10); 287 310 288 311 /* start info for the new zone */ 312 dDecZone = dDec; 289 313 zones[Nz].Rmin = regions[i].Rmin; 290 zones[Nz].dDec = dDec ;314 zones[Nz].dDec = dDecZone; 291 315 zones[Nz].L3start = i; 292 316 zones[Nz].L1band = parent; … … 301 325 zones[i].Dmin = Dmin; 302 326 zones[i].Dmax = Dmax; 327 } 328 329 /* the pole region is mis-allocated in the gsc table to L3. elevate it 330 to L2 (zone) and subdivide */ 331 if (poleRegion) { 332 CHECK_REALLOCATE (zones, SkyRegionZone, NZ, Nz, 10); 333 /* pole region @ L2 */ 334 zones[Nz].Rmin = 0.0; 335 zones[Nz].Rmax = 360.0; 336 if (poleRegion > 0) { 337 zones[Nz].Dmin = +86.25; 338 zones[Nz].Dmax = +90.00; 339 strcpy (basename, "n8230/pole"); 340 } else { 341 zones[Nz].Dmin = -90.00; 342 zones[Nz].Dmax = -86.25; 343 strcpy (basename, "s8230/pole"); 344 } 345 zones[Nz].dDec = 90.00 - 86.25; 346 zones[Nz].L3start = Nregions; 347 zones[Nz].L3end = Nregions + 5; 348 zones[Nz].L1band = parent; 349 350 band[0].Nregions += 4; 351 REALLOCATE (band[0].regions, SkyRegion, band[0].Nregions); 352 for (i = 0; i < 4; i++) { 353 band[0].regions[Nregions + i].Rmin = i * 90.0; 354 band[0].regions[Nregions + i].Rmax = i * 90.0 + 90.0; 355 if (poleRegion > 0) { 356 band[0].regions[Nregions + i].Dmin = +86.250; 357 band[0].regions[Nregions + i].Dmax = +88.125; 358 } else { 359 band[0].regions[Nregions + i].Dmin = -88.125; 360 band[0].regions[Nregions + i].Dmax = -86.250; 361 } 362 sprintf (band[0].regions[Nregions + i].name, "%s.%d", basename, i); 363 } 364 band[0].regions[Nregions + i].Rmin = 0.0; 365 band[0].regions[Nregions + i].Rmax = 360.0; 366 if (poleRegion > 0) { 367 band[0].regions[Nregions + i].Dmin = +88.125; 368 band[0].regions[Nregions + i].Dmax = +90.000; 369 } else { 370 band[0].regions[Nregions + i].Dmin = -90.000; 371 band[0].regions[Nregions + i].Dmax = -88.125; 372 } 373 sprintf (band[0].regions[Nregions + i].name, "%s.%d", basename, i); 374 375 zones[0].Nset = 6; 376 zones[1].Nset = 5; 377 378 Nz ++; 303 379 } 304 380 … … 353 429 *p = '/'; 354 430 strcpy (L2[0].regions[Nr].name, name); 355 if (DEBUG ) SkyRegionPrint (&L2[0].regions[Nr]);431 if (DEBUG >= 2) SkyRegionPrint (&L2[0].regions[Nr]); 356 432 357 433 /* childS and childE are set in SkyTableL3fromL2 */ … … 389 465 L3[0].regions[Nr].childE = 0; 390 466 391 if (DEBUG ) SkyRegionPrint (&L3[0].regions[Nr]);467 if (DEBUG >= 3) SkyRegionPrint (&L3[0].regions[Nr]); 392 468 /* name is set for the band in SkyRegionForDecBand */ 393 469 … … 413 489 L3[0].childS = Nr; 414 490 L3[0].childE = L4[0].Nregions; 491 492 // XXX handle the pole regions just a bit differently... 415 493 416 494 /* subdivide L3 into NDIV boxes */ … … 438 516 sprintf (name, "%s.%02d", L3[0].name, Nbox); 439 517 strcpy (L4[0].regions[Nr].name, name); 440 if (DEBUG ) SkyRegionPrint (&L4[0].regions[Nr]);518 if (DEBUG >= 4) SkyRegionPrint (&L4[0].regions[Nr]); 441 519 442 520 Nr ++;
Note:
See TracChangeset
for help on using the changeset viewer.
