IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36612


Ignore:
Timestamp:
Mar 21, 2014, 11:42:48 AM (12 years ago)
Author:
eugene
Message:

handle 0,360 boundary correctly

Location:
branches/eam_branches/ipp-20140206/Ohana/src/relphot
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/include/relphot.h

    r36558 r36612  
    473473int select_images_hostregion (RegionHostTable *hosts, Image *image, off_t Nimage);
    474474int find_host_for_coords (RegionHostTable *regionHosts, double R, double d);
    475 int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax);
     475int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid);
    476476
    477477int launch_region_hosts (RegionHostTable *regionHosts);
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MosaicOps.c

    r36611 r36612  
    575575      image[m].Xm    = NAN_S_SHORT;
    576576    }
     577
    577578    if (Nc > 0) {
    578579      dsort (Rc, Nc);
     580      if (Rc[Nc-1] - Rc[0] > 180.0) {
     581        // in our list, Rc is in the range 0.0 to 360.0. 
     582        // any mosaic which is close to the 0.0, 360.0 boundary may have some on
     583        // one side or the other.  count how many have values more than Rc[0] + 180.
     584        // if more than half are at the large end, re-normalize to that range
     585        int Nbig = 0;
     586        for (j = 1; j < Nc; j++) {
     587          if (Rc[j] - Rc[0] > 180.0) Nbig ++;
     588        }
     589        if (Nbig  > 0.5*Nc) {
     590          for (j = 0; j < Nc; j++) {
     591            Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 360.0);
     592          }
     593          dsort (Rc, Nc);
     594        } else if (Nbig > 0) {
     595          for (j = 0; j < Nc; j++) {
     596            Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 0.0);
     597          }
     598          dsort (Rc, Nc);
     599        }
     600      }
    579601      dsort (Dc, Nc);
     602
    580603      Rmid = Rc[(int)(0.5*Nc)];
    581604      Dmid = Dc[(int)(0.5*Nc)];
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/assign_images.c

    r36611 r36612  
    4040  // even faster would be to use a tree to get to the real regions...
    4141  select_images_hostregion (regionHosts, image, Nimage);
    42 
    43   // calculate_host_image_bounds (regionHosts);
    4442
    4543  return TRUE;
     
    120118    image[j].DECo = Dc;
    121119
     120    // NOTE: if we are NOT using mosaic centers, we don't need to keep chips with centers
     121    // on opposite sides of 0,360 together.  in which case, it is OK for the range of Rc
     122    // to be 0.0 to 360.0.  also NOTE: RAo,DECo are only used for debugging reference.
     123
    122124    if (MOSAIC_ZEROPT) {
    123125      // use the coords of the associated mosaic to select
     
    125127      Rc = mosaic->coords.crval1;
    126128      Dc = mosaic->coords.crval2;
     129      // NOTE : have defined mosaic Rc,Dc to choose the side of 0,360 on which most of the
     130      // chips are located.  but, for host assignment, we rationalize to 0.0 - 360.0
    127131      Rc = ohana_normalize_angle_to_midpoint (Rc, 180.0);
    128132    }
     
    134138    RegionHostInfo *host = &regionHosts->hosts[i];
    135139
     140    // image bounds are defined for a range centered on the mosaic center thus, a mosaic
     141    // with center 0.5 will have chips bounds ranging from ~ -1.5 to +2.5 or so, while a mosaic
     142    // with center 359.5 will have chips bounds ranging from ~ 357.5 to 361.5 or so
    136143    double Rmin, Rmax, Dmin, Dmax;
    137     calculate_image_bounds (&image[j], &Rmin, &Rmax, &Dmin, &Dmax);
     144    calculate_image_bounds (&image[j], &Rmin, &Rmax, &Dmin, &Dmax, Rc);
    138145
    139146    host->RminCat = MIN(Rmin, host->RminCat);
     
    168175double Yf[] = {0.0, 0.0, 1.0, 1.0};
    169176
    170 int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax) {
     177int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid) {
    171178
    172179  int n;
     
    183190    Yc = Yf[n]*image->NY;
    184191    XY_to_RD (&Rc, &Dc, Xc, Yc, &image->coords);
    185     Rc = ohana_normalize_angle_to_midpoint (Rc, 180.0);
     192    Rc = ohana_normalize_angle_to_midpoint (Rc, Rmid);
    186193     
    187194    Rmin = MIN (Rmin, Rc);
     
    199206}
    200207
    201 int calculate_host_image_bounds (RegionHostTable *regionHosts) {
     208int calculate_host_image_bounds (RegionHostTable *regionHosts, double Rmid) {
    202209
    203210  int i, n;
     
    212219    BuildChipMatch (host->image, host->Nimage);
    213220
    214     double Rmin = 360.0;
    215     double Rmax =   0.0;
    216     double Dmin = +90.0;
     221    double Rmin =  720.0;
     222    double Rmax = -360.0;
     223    double Dmin =  +90.0;
    217224    double Dmax = -90.0;
    218225
     
    232239        Yc = Yf[n]*image->NY;
    233240        XY_to_RD (&Rc, &Dc, Xc, Yc, &image->coords);
    234         Rc = ohana_normalize_angle_to_midpoint (Rc, 180.0);
     241        Rc = ohana_normalize_angle_to_midpoint (Rc, Rmid);
    235242     
    236243        Rmin = MIN (Rmin, Rc);
     
    243250    }
    244251
     252    // RminCat, RmaxCat may extended beyond 0.0 - 360.0
    245253    host->RminCat = Rmin;
    246254    host->DminCat = Dmin;
     
    259267
    260268
    261 // XXX add a search tree to speed this up?
     269// Rc is in range 0.0 - 360.0, hosts Rmin,Rmax in range 0.0 - 360.0
    262270int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc) {
    263271
  • branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c

    r36611 r36612  
    5050  SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    5151  SkyTableSetFilenames (sky, CATDIR, "cpt");
     52
     53  // UserPatch.Rmin,Rmax may have range from a few degrees < 0.0 to few degrees > 360.0.
     54  // the following function correctly chooses the sky regions on the 0,360 boundary
    5255  SkyList *skylist = SkyListByBounds (sky, -1, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    5356
Note: See TracChangeset for help on using the changeset viewer.