IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39488 for trunk


Ignore:
Timestamp:
Mar 28, 2016, 10:07:15 AM (10 years ago)
Author:
eugene
Message:

running slow, trying to speed things up

Location:
trunk/Ohana/src/dvolens/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/dvolens/src/WarpImageMaps.c

    r39487 r39488  
    1111  off_t *warps;
    1212  unsigned short photcode;
     13  double *Rmin;
     14  double *Rmax;
     15  double *Dmin;
     16  double *Dmax;
     17  int    *onBoundary;
    1318} WarpGroup;
    1419
     
    112117  }
    113118
     119  // we now have the warps assigned to groups.  now we need to generate the grid data to find the warp assignments
     120  for (int i = 0; i < Nwarpgroup; i++) {
     121
     122    myAssert (warpgroup[i].Nwarps == uniqcount[i], "failure");
     123    ALLOCATE (warpgroup[i].Rmin, double, warpgroup[i].Nwarps);
     124    ALLOCATE (warpgroup[i].Rmax, double, warpgroup[i].Nwarps);
     125    ALLOCATE (warpgroup[i].Dmin, double, warpgroup[i].Nwarps);
     126    ALLOCATE (warpgroup[i].Dmax, double, warpgroup[i].Nwarps);
     127    ALLOCATE (warpgroup[i].onBoundary, int, warpgroup[i].Nwarps);
     128
     129    for (int j = 0; j < warpgroup[i].Nwarps; j++) {
     130
     131      off_t N = warpgroup[i].warps[j];
     132     
     133      int Nx = image[N].NX;
     134      int Ny = image[N].NY;
     135
     136      warpgroup[i].onBoundary[j] = FALSE;
     137
     138      double R, D;
     139      XY_to_RD (&R, &D, 0.0, 0.0, &image[N].coords);
     140      R = ohana_normalize_angle_to_midpoint(R, 180.0);
     141      warpgroup[i].Rmin[j] = R;
     142      warpgroup[i].Rmax[j] = R;
     143      warpgroup[i].Dmin[j] = D;
     144      warpgroup[i].Dmax[j] = D;
     145
     146      // XXX need to worry about 0,360 boundary
     147      XY_to_RD (&R, &D, Nx, 0.0, &image[N].coords);
     148      R = ohana_normalize_angle_to_midpoint(R, 180.0);
     149      warpgroup[i].Rmin[j] = MIN (warpgroup[i].Rmin[j], R);
     150      warpgroup[i].Rmax[j] = MAX (warpgroup[i].Rmax[j], R);
     151      warpgroup[i].Dmin[j] = MIN (warpgroup[i].Dmin[j], D);
     152      warpgroup[i].Dmax[j] = MAX (warpgroup[i].Dmax[j], D);
     153
     154      // XXX need to worry about 0,360 boundary
     155      XY_to_RD (&R, &D, 0.0, Ny, &image[N].coords);
     156      R = ohana_normalize_angle_to_midpoint(R, 180.0);
     157      warpgroup[i].Rmin[j] = MIN (warpgroup[i].Rmin[j], R);
     158      warpgroup[i].Rmax[j] = MAX (warpgroup[i].Rmax[j], R);
     159      warpgroup[i].Dmin[j] = MIN (warpgroup[i].Dmin[j], D);
     160      warpgroup[i].Dmax[j] = MAX (warpgroup[i].Dmax[j], D);
     161
     162      // XXX need to worry about 0,360 boundary
     163      XY_to_RD (&R, &D, Nx, Ny, &image[N].coords);
     164      R = ohana_normalize_angle_to_midpoint(R, 180.0);
     165      warpgroup[i].Rmin[j] = MIN (warpgroup[i].Rmin[j], R);
     166      warpgroup[i].Rmax[j] = MAX (warpgroup[i].Rmax[j], R);
     167      warpgroup[i].Dmin[j] = MIN (warpgroup[i].Dmin[j], D);
     168      warpgroup[i].Dmax[j] = MAX (warpgroup[i].Dmax[j], D);
     169
     170      // bump Rmin,Rmax,Dmin,Dmax 10 arcsec worth of padding
     171      double dR = 10.0/3600.0 / cos (RAD_DEG*warpgroup[i].Dmin[j]);
     172      double dD = 10.0/3600.0;
     173
     174      // at north pole, force test of all nearby skycells
     175      if (warpgroup[i].Dmax[j] > 89.8) {
     176        warpgroup[i].Rmin[j] =   0.0;
     177        warpgroup[i].Rmax[j] = 360.0;
     178        warpgroup[i].Dmax[j] =  90.0;
     179        warpgroup[i].Dmin[j] -=  dD;
     180        continue;
     181      }
     182
     183      if (warpgroup[i].Rmax[j] - warpgroup[i].Rmin[j] > 270.0) {
     184        // Rmin and Rmax are in the range 0 - 360.  For images at the 0,360 boundary,
     185        // "Rmax" is the lower edge, and "Rmin" is the upper edge.  we need to flip them
     186        // and then break the 0-360 range:
     187        double tmp = warpgroup[i].Rmin[j];
     188        warpgroup[i].Rmin[j] = warpgroup[i].Rmax[j] - 360.0;
     189        warpgroup[i].Rmax[j] = tmp;
     190        warpgroup[i].onBoundary[j] = TRUE;
     191      }
     192
     193      warpgroup[i].Rmin[j] -=  dR;
     194      warpgroup[i].Rmax[j] +=  dR;
     195      warpgroup[i].Dmin[j] -=  dD;
     196      warpgroup[i].Dmax[j] +=  dD;
     197    }
     198  }
     199
    114200  free (uniqtimes);
    115201  free (uniqcount);
     
    131217
    132218  // can we find an image in this set which matches one of our measures?
     219  double Rave = average->R;
     220  double Dave = average->D;
    133221
    134222  // we now have the warp group, but which is the correct warp?
     
    138226    // average->R,D could pin-point more quickly
    139227
    140     // this is a possible image: check the coordinates:
     228    if (warpgroup[seq].onBoundary[i]) {
     229      int inRange1 = (Rave >= warpgroup[seq].Rmin[i]) && (Rave <= warpgroup[seq].Rmax[i]);
     230      int inRange2 = (Rave >= warpgroup[seq].Rmin[i] + 360.0) && (Rave <= warpgroup[seq].Rmax[i] + 360.0);
     231      if (!inRange1 && !inRange2) continue;
     232    } else {
     233      if (Rave < warpgroup[seq].Rmin[i]) continue;
     234      if (Rave > warpgroup[seq].Rmax[i]) continue;
     235    }
     236    if (Dave < warpgroup[seq].Dmin[i]) continue;
     237    if (Dave > warpgroup[seq].Dmax[i]) continue;
     238
     239    // this is a possible image based on coordinates: does it match a warp?
    141240    int N = warpgroup[seq].warps[i];
    142241
  • trunk/Ohana/src/dvolens/src/myIndex.c

    r38153 r39488  
    4747
    4848  myIndex->Nindex = myIndex->maxID - myIndex->minID + 1;
    49   myIndex->NINDEX = myIndex->Nindex;
    50  
    51   REALLOCATE (myIndex->index, int, myIndex->NINDEX);
     49  if (myIndex->Nindex > myIndex->NINDEX) {
     50    myIndex->NINDEX = myIndex->Nindex;
     51    REALLOCATE (myIndex->index, int, myIndex->NINDEX);
     52  }
    5253
    5354  int i;
  • trunk/Ohana/src/dvolens/src/select_images.c

    r39487 r39488  
    4343  ALLOCATE (image, Image, NIMAGE);
    4444 
     45  // I need to ensure we get the images from any skycells in a warp
     46  double dD = 2.0;
     47  double dR = dD / cos(RAD_DEG*DminSkyRegion);
     48  RminSkyRegion -= dR;
     49  RmaxSkyRegion += dR;
     50  DminSkyRegion -= dD;
     51  DmaxSkyRegion += dD;
     52
    4553  // go through the complete list of images, selecting ones which overlap any region
    4654  for (i = 0; i < Ntimage; i++) {
  • trunk/Ohana/src/dvolens/src/update_objects_catalog.c

    r39487 r39488  
    22# define SCALE 0.001
    33float MagToFlux (float Mag); // in libdvo, but not exposed?
     4
     5# define TIMESTAMP(TIME){                               \
     6  gettimeofday (&stopTimer, (void *) NULL);             \
     7  double dtime = DTIME (stopTimer, startTimer);         \
     8  TIME += dtime;                                        \
     9  gettimeofday (&startTimer, (void *) NULL); }
    410
    511int update_objects_catalog (Catalog *catalog) {
     
    3137  myIndexType *measureIndex = myIndexAlloc();
    3238
     39  int Nfixed = 0;
     40  int Nfailed = 0;
     41
     42  INITTIME;
     43
     44  double time1 = 0.0;
     45  double time2 = 0.0;
     46  double time3 = 0.0;
     47  double time4 = 0.0;
     48
    3349  for (i = 0; i < catalog->Naverage; i++) {
     50   
     51    if (i % 1000 == 0) {
     52      MARKTIME ("done with %d aves: %f sec (%f %f %f %f)\n", (int) i, dtime, time1, time2, time3, time4);
     53      time1 = 0.0;
     54      time2 = 0.0;
     55      time3 = 0.0;
     56      time4 = 0.0;
     57      gettimeofday (&startTimer, NULL);
     58    }
     59
    3460    Average *average = &catalog->average[i];
    3561    if (average->Nlensing == 0) continue;
     
    6288      myIndexUpdateLimits (measureIndex, catalog->measure[Moff + Mj].imageID);
    6389    }
     90
     91    TIMESTAMP (time1);
    6492    myIndexSetRange (measureIndex);
     93    TIMESTAMP (time2);
     94
    6595    for (Mj = 0; Mj < average->Nmeasure; Mj++) {
    6696      // if there are duplicates (multiple measures from the same image),
     
    89119      // the set of warps which match our obstime, then choosing the one from that set
    90120      // which matches one of our warps.
    91       if ((Mj < 0) && REPAIR_LENSING_IDS) {
    92         Mj = RecoverLensingIndex (average, measureIndex, lensing);
    93       }
    94       myAssert (Mj > -1, "missing index");
     121      if (Mj < 0) {
     122        if (REPAIR_LENSING_IDS) {
     123          Mj = RecoverLensingIndex (average, measureIndex, lensing);
     124          if (Mj == -1) {
     125            Nfailed ++;
     126            continue;
     127          }
     128          Nfixed ++;
     129        } else {
     130          Nfailed ++;
     131          continue;
     132        }
     133      }
    95134
    96135      Measure *measure = &catalog->measure[Moff + Mj];
     
    196235    }
    197236   
     237    TIMESTAMP (time3);
     238
    198239    for (j = 0; j < Nsecfilt; j++) {
    199240      if (!lensobj[j].Nmeas) {
     
    273314    }
    274315
     316    TIMESTAMP (time4);
     317
    275318    average->Nlensobj = Nsecfilt;
    276319    average->lensobjOffset = Nlensobj;
     
    290333  myIndexFree (measureIndex);
    291334
     335  fprintf (stderr, "corrected %d lensing IDs, failed on %d lensing IDs\n", Nfixed, Nfailed);
     336
    292337  catalog->Nlensobj = Nlensobj;
    293338  catalog->Nlensobj_disk = 0;
Note: See TracChangeset for help on using the changeset viewer.