IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12392


Ignore:
Timestamp:
Mar 9, 2007, 3:19:31 PM (19 years ago)
Author:
eugene
Message:

fixed bug in polar region definitions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libdvo/src/skyregion_gsc.c

    r12332 r12392  
    128128    /* subdivide each zone */
    129129    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);
    131131      SkyTableL2fromZone (&L2, &L3, &L4, band, &zones[j], i);
    132132    }
     
    251251}
    252252
    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
    254261SkyRegionZone *SkyRegionFindZones (SkyTable *band, int *Nzones, int parent) {
    255262 
    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;
    258265  SkyRegion *regions;
     266  SkyRegion tempregion;
    259267  SkyRegionZone *zones;
     268  char basename[64];
    260269 
    261270  regions = band[0].regions;
    262271  Nregions = band[0].Nregions;
    263272
    264   Nz = 0;
    265273  NZ = 10;
    266274  ALLOCATE (zones, SkyRegionZone, NZ);
    267275 
    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;
    273278
    274279  /* 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;
    277284  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? */
    278297    Dmin = MIN (regions[i].Dmin, Dmin);
    279298    Dmax = MAX (regions[i].Dmax, Dmax);
    280299    dDec = regions[i].Dmax - regions[i].Dmin;
    281300    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 */
    285308      Nz++;
    286309      CHECK_REALLOCATE (zones, SkyRegionZone, NZ, Nz, 10);
    287310
    288311      /* start info for the new zone */
     312      dDecZone = dDec;
    289313      zones[Nz].Rmin = regions[i].Rmin;
    290       zones[Nz].dDec = dDec;
     314      zones[Nz].dDec = dDecZone;
    291315      zones[Nz].L3start = i;
    292316      zones[Nz].L1band = parent;
     
    301325    zones[i].Dmin = Dmin;
    302326    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 ++;
    303379  }
    304380
     
    353429    *p = '/';
    354430    strcpy (L2[0].regions[Nr].name, name);
    355     if (DEBUG) SkyRegionPrint (&L2[0].regions[Nr]);
     431    if (DEBUG >= 2) SkyRegionPrint (&L2[0].regions[Nr]);
    356432
    357433    /* childS and childE are set in SkyTableL3fromL2 */
     
    389465    L3[0].regions[Nr].childE   =  0;
    390466
    391     if (DEBUG) SkyRegionPrint (&L3[0].regions[Nr]);
     467    if (DEBUG >= 3) SkyRegionPrint (&L3[0].regions[Nr]);
    392468    /* name is set for the band in SkyRegionForDecBand */
    393469
     
    413489  L3[0].childS = Nr;
    414490  L3[0].childE = L4[0].Nregions;
     491
     492  // XXX handle the pole regions just a bit differently...
    415493
    416494  /* subdivide L3 into NDIV boxes */
     
    438516      sprintf (name, "%s.%02d", L3[0].name, Nbox);
    439517      strcpy (L4[0].regions[Nr].name, name);
    440       if (DEBUG) SkyRegionPrint (&L4[0].regions[Nr]);
     518      if (DEBUG >= 4) SkyRegionPrint (&L4[0].regions[Nr]);
    441519
    442520      Nr ++;
Note: See TracChangeset for help on using the changeset viewer.