IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37699


Ignore:
Timestamp:
Nov 30, 2014, 12:54:00 PM (12 years ago)
Author:
eugene
Message:

add -reset-images option, add MaxOrder argument to -chipmap, pass chipmap and order to region hosts; use imageSeq array to do imageID->image[i]; make sure chipmaps loaded from remote hosts are pushed into I/O table; revert to allowing all remote hosts to update at the same time; updateMeasures by catalog,measure not be image

Location:
branches/eam_branches/ipp-20140904/Ohana/src/relastro
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/include/relastro.h

    r37686 r37699  
    229229
    230230int    RESET;
     231int    RESET_IMAGES;
    231232int    RESET_BAD_IMAGES;
    232233int    NLOOP;
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FitChip.c

    r37688 r37699  
    7575      return FALSE;
    7676    }
    77     if (!CHIPMAP) order_use = MIN(order_use, 3); // can only go up to 3rd order
     77    if (CHIPMAP) {
     78      order_use = MIN(MIN(order_use, CHIPMAP), 6); // can only go up to 6th order map (can be user limited)
     79    } else {
     80      order_use = MIN(order_use, 3); // can only go up to 3rd order for polynomials
     81    }
     82
    7883    if (VERBOSE2) fprintf (stderr, "using %d for %s\n", order_use, image[0].name);
    7984
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImageOps.c

    r37697 r37699  
    125125
    126126  if (imageSeq) {
    127     myAssert (ID >= minImageID, "oops");
    128     myAssert (ID <= maxImageID, "oops");
     127    if (ID < minImageID) return (-1);
     128    if (ID > maxImageID) return (-1);
    129129    off_t N = imageSeq[ID];
    130130    return N;
     
    276276    }
    277277  }
     278
     279  if (!ID) return; // detection not associated with an image
    278280
    279281  idx = getImageByID (ID);
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImagePosIO.c

    r37662 r37699  
    8585  ALLOCATE (image_pos, ImagePos, Nrow);
    8686  for (i = 0; i < Nrow; i++) {
     87    InitCoords(&image_pos[i].coords, NULL);
    8788    image_pos[i].coords.crval1             = crval1    [i];
    8889    image_pos[i].coords.crval2             = crval2    [i];
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c

    r37686 r37699  
    564564    AstromOffsetTableNewMap(table, tmpMap->Nx, tmpMap->Ny, image);  // registers the map with the image
    565565    unlockUpdateChips ();
    566     AstromOffsetMapCopyData (truMap, tmpMap);
     566    AstromOffsetMapCopyData (image->coords.offsetMap, tmpMap);
    567567    return;
    568568  }
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateMeasures.c

    r37697 r37699  
    11# include "relastro.h"
     2void dump_measures (Average *average, Measure *measure); // in ImageOps.c
    23
    3 // this function operates on Measure, not MeasureTiny
     4// this function is called by UpdateObjectOffsets or relastro_images.c for reset
    45int UpdateMeasures (Catalog *catalog, int Ncatalog) {
    56
    6   off_t i, Nimage;
     7  off_t i, j, Nimage;
    78  Image *image;
     9  double DPOS_MAX_ASEC;
    810
    911  int badImage =
     
    1820  image = getimages (&Nimage, NULL);
    1921
     22  // track measurements which are far from their original position (poor at pole)
     23  int NoffRAave = 0;  int NoffRAori = 0;
     24  int NoffDECave = 0; int NoffDECori = 0;
     25
    2026  for (i = 0; i < Ncatalog; i++) {
     27    myAssert (!catalog[i].Nmeasure || catalog[i].measureT, "programming error");
    2128    for (j = 0; j < catalog[i].Nmeasure; j++) {
    2229      MeasureTiny *measureT = &catalog[i].measureT[j];
    23       Measure     *measure  = catalog[i].measure ? &catalog[i].measure[j] : NULL;
     30      Measure     *measureB = catalog[i].measure ? &catalog[i].measure[j] : NULL;
    2431
    2532      off_t im = getImageByID (measureT->imageID);
     33      if (im < 0) continue; // detections without imageIDs are not associated with a known image (eg, refs)
    2634
    27       // check that we have the
     35      // check that we have the right image:
     36      myAssert (measureT->photcode == image[im].photcode, "image photcode mismatch");
     37      myAssert (measureT->t >= image[im].tzero, "image time mismatch (1)");
     38      myAssert (measureT->t <= image[im].tzero + image[im].NX*image[im].trate/5000.0, "image time mismatch (2)");
     39      // I'm allowing the trate*NX to be a factor of 2x too small
    2840
    29     // skip images that have failed solutions (divergent or otherwise)
    30     // XXX apply this or not??
    31     if (FALSE && (image[i].flags & badImage)) continue;
     41      // skip measurements on images that have failed solutions (divergent or otherwise)
     42      // XXX apply this or not??
     43      if (FALSE && (image[im].flags & badImage)) continue;
    3244
     45      Coords *moscoords = image[im].coords.mosaic;
     46      Coords *imcoords = &image[im].coords;
     47
     48      if (moscoords) {
     49        DPOS_MAX_ASEC = 3600.0*DPOS_MAX*hypot(moscoords->cdelt1, moscoords->cdelt2);
     50      } else {
     51        DPOS_MAX_ASEC = 3600.0*DPOS_MAX*hypot(imcoords->cdelt1, imcoords->cdelt2);
     52      }
     53
     54      double X = measureT->Xccd;
     55      double Y = measureT->Yccd;
     56      if (USE_FIXED_PIXCOORDS) {
     57        if (isfinite(measureT->Xfix) && isfinite(measureT->Yfix)) {
     58          float dX = measureT->Xfix - measureT->Xccd;
     59          float dY = measureT->Yfix - measureT->Yccd;
     60          if (hypot(dX,dY) < 2.0) {
     61            X = measureT->Xfix;
     62            Y = measureT->Yfix;
     63          }
     64        }
     65      }
     66
     67      double R, D;
     68      double dR = NAN, dD = NAN;
     69      XY_to_RD (&R, &D, X, Y, imcoords);
     70
     71      int n = measureT[0].averef;
     72      Average *average = &catalog[i].average[n];
     73
     74      // make sure detection is on the same side of the 0,360 boundary as the average
     75      // this will give some funny results withing ~1 arcsec of the pol
     76      if (dR > +180.0*3600.0) {
     77        // average on high end of boundary, move star up
     78        R += 360.0;
     79        dR = 3600.0*(average[0].R - R);
     80      }
     81      if (dR < -180.0*3600.0) {
     82        // average on low end of boundary, move star down
     83        R -= 360.0;
     84        dR = 3600.0*(average[0].R - R);
     85      }
     86
     87      float csdec = cos(average[0].D * RAD_DEG);
     88
     89      // complain if the new location is far from the average location
     90      // NOTE: This should never happen, or our StarMap tests are not working
     91      if (fabs(dR*csdec) > 3.0*ADDSTAR_RADIUS) {
     92        NoffRAave ++;
     93        if (VERBOSE2 && catalog[i].measure) {
     94          fprintf (stderr, "measurement is far from average location (R): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, dR*csdec, dD);
     95          dump_measures (&average[0], catalog[i].measure);
     96        }
     97      }
     98      if (fabs(dD) > 3.0*ADDSTAR_RADIUS) {
     99        NoffDECave ++;
     100        if (VERBOSE2 && catalog[i].measure) {
     101          fprintf (stderr, "measurement is far from average location (D): %f %f (%f %f)\n", average[0].R, average[0].D, dR, dD);
     102          dump_measures (&average[0], catalog[i].measure);
     103        }
     104      }
     105
     106      // complain if the new location is far from the old location
     107      if (fabs(csdec*(measureT[0].R - R)) > DPOS_MAX_ASEC) {
     108        NoffRAori ++;
     109        if (VERBOSE2 && catalog[i].measure) {
     110          fprintf (stderr, "measurement moves far from original location (R): %f %f (%f %f %f %f)\n", average[0].R, average[0].D, measureT[0].R, dR, csdec*(measureT[0].R - R), dD);
     111          dump_measures (&average[0], catalog[i].measure);
     112        }
     113      }
     114      if (fabs(measureT[0].D - D) > DPOS_MAX_ASEC) {
     115        NoffDECori ++;
     116        if (VERBOSE2 && catalog[i].measure) {
     117          fprintf (stderr, "measurement moves far from original location (D): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, measureT[0].D, dD);
     118          dump_measures (&average[0], catalog[i].measure);
     119        }
     120      }
     121      measureT->R = R;
     122      measureT->D = D;
     123      if (measureB) {
     124        measureB->R = R;
     125        measureB->D = D;
     126      }
     127    }
    33128  }
     129  // printNcatTotal ();
    34130
    35   // printNcatTotal ();
     131  int Noff = NoffRAave + NoffDECave + NoffRAori + NoffDECori;
     132  if (VERBOSE && (Noff > 0)) fprintf (stderr, "Noff ave RA %d, Noff ave DEC %d, Noff ori RA %d, Noff ori DEC %d\n", NoffRAave, NoffDECave, NoffRAori, NoffDECori);
    36133
    37134  return (TRUE);
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateObjectOffsets.c

    r37695 r37699  
    8080
    8181int UpdateObjectOffsets_parallel_group (HostTableGroup *group, SkyList *sky);
     82int UpdateObjectOffsets_parallel_table (HostTable *table, SkyList *sky);
    8283
    8384// CATDIR is supplied globally
     
    9495  }   
    9596
     97 
     98  UpdateObjectOffsets_parallel_table (table, sky);
     99
     100# if (0)
    96101  int Ngroups;
    97102  HostTableGroup *groups = HostTableGroups (table, &Ngroups);
     
    103108    UpdateObjectOffsets_parallel_group (&groups[i], sky);
    104109  }
     110# endif
    105111
    106112  return TRUE;
     
    224230  return TRUE;
    225231}     
     232
     233// CATDIR is supplied globally
     234# define DEBUG 1
     235int UpdateObjectOffsets_parallel_table (HostTable *table, SkyList *sky) {
     236
     237  // launch the relastro_client jobs to the parallel hosts
     238
     239  int i, j;
     240  for (i = 0; i < table->Nhosts; i++) {
     241
     242    if (sky->Nregions < table->Nhosts) {
     243      // do any of the regions want this host?
     244      int wantThisHost = FALSE;
     245      for (j = 0; j < sky->Nregions; j++) {
     246        if (HostTableTestHost (sky->regions[j], table->hosts[i].hostID)) {
     247          wantThisHost = TRUE;
     248          break;
     249        }
     250      }
     251      if (!wantThisHost) {
     252        // fprintf (stderr, "skip host %s\n", table->hosts[i].hostname);
     253        continue;
     254      }
     255    }
     256
     257    // ensure that the paths are absolute path names
     258    char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH);
     259    free (table->hosts[i].pathname);
     260    table->hosts[i].pathname = tmppath;
     261
     262    // options / arguments that can affect relastro_client -load:
     263    // VERBOSE, VERBOSE2
     264    // RESET (-reset)
     265    // TimeSelect -time
     266    // (note that psfQF is applied rigidly at 0.85, as is the galaxy test)
     267    // ImagSelect, ImagMin, ImagMax
     268    // MaxDensityUse, MaxDensityValue
     269
     270    char command[1024];
     271    snprintf (command, 1024, "relastro_client -update-offsets -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -minerror %f",
     272              table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, MIN_ERROR);
     273
     274    if (FIT_MODE == FIT_PM_ONLY)         strextend (command, "-pm");
     275    if (FIT_MODE == FIT_PAR_ONLY)        strextend (command, "-par");
     276    if (FIT_MODE == FIT_PM_AND_PAR)      strextend (command, "-pmpar");
     277
     278    if (VERBOSE)       strextend (command, "-v");
     279    if (VERBOSE2)      strextend (command, "-vv");
     280    if (RESET)         strextend (command, "-reset");
     281    if (UPDATE)        strextend (command, "-update");
     282
     283    if (RESET_BAD_IMAGES) strextend (command, "-reset-bad-images");
     284
     285    if (ImagSelect)    strextend (command, "-instmag %f %f", ImagMin, ImagMax);
     286    if (MaxDensityUse) strextend (command, "-max-density %f", MaxDensityValue);
     287   
     288    if (USE_BASIC_CHECK) strextend (command, "-basic-image-search");
     289    if (FlagOutlier)     strextend (command, "-clip %d", CLIP_THRESH);
     290    if (ExcludeBogus)    strextend (command, "-exclude-bogus %f", ExcludeBogusRadius);
     291   
     292    if (USE_FIXED_PIXCOORDS) strextend (command, "-D USE_FIXED_PIXCOORDS 1");
     293
     294    if (PHOTCODE_KEEP_LIST) strextend (command, "+photcode %s", PHOTCODE_KEEP_LIST);
     295    if (PHOTCODE_SKIP_LIST) strextend (command, "-photcode %s", PHOTCODE_SKIP_LIST);
     296    if (PhotFlagSelect)     strextend (command, "+photflags");
     297    if (PhotFlagBad)        strextend (command, "+photflagbad %d", PhotFlagBad);
     298    if (PhotFlagPoor)       strextend (command, "+photflagpoor %d", PhotFlagPoor);
     299    // XXX note that the above pass in the flag as decimal -- also note that args.c cannot handle 0xHEX values
     300
     301    if (DCR_BLUE_COLOR_POS && DCR_BLUE_COLOR_NEG) {
     302      strextend (command, "-dcr-blue-color %s %s", DCR_BLUE_COLOR_POS, DCR_BLUE_COLOR_NEG);
     303    }
     304    if (DCR_RED_COLOR_POS && DCR_RED_COLOR_NEG) {
     305      strextend (command, "-dcr-red-color %s %s", DCR_RED_COLOR_POS, DCR_RED_COLOR_NEG);
     306    }
     307
     308    if (MinBadQF > 0.0)        strextend (command, "-min-bad-psfqf %f", MinBadQF);
     309    if (MaxMeanOffset != 10.0) strextend (command, "-max-mean-offset  %f", MaxMeanOffset);
     310
     311    if (TimeSelect) {
     312      char *tstart = ohana_sec_to_date (TSTART);
     313      char *tstop  = ohana_sec_to_date (TSTOP);
     314      strextend (command, "-time %s %s", tstart, tstop);
     315      free (tstart);
     316      free (tstop);
     317    }
     318    fprintf (stderr, "command: %s\n", command);
     319
     320    if (PARALLEL_MANUAL) continue;
     321
     322    if (PARALLEL_SERIAL) {
     323      int status = system (command);
     324      if (status) {
     325        fprintf (stderr, "ERROR running relastro_client\n");
     326        exit (2);
     327      }
     328    } else {
     329      // launch the job on the remote machine (no handshake)
     330      int errorInfo = 0;
     331      int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);
     332      if (!pid) {
     333        if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);
     334        exit (1);
     335      }
     336      table->hosts[i].pid = pid; // save for future reference
     337    }
     338  }
     339
     340  if (PARALLEL_MANUAL) {
     341    fprintf (stderr, "run the relastro_client commands above.  when these are done, hit return\n");
     342    getchar();
     343  }
     344  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
     345    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
     346  }
     347
     348  return TRUE;
     349}     
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/args.c

    r37446 r37699  
    372372  }
    373373
    374   CHIPMAP = FALSE;
     374  CHIPMAP = 0;
    375375  if ((N = get_argument (argc, argv, "-chipmap"))) {
    376376    remove_argument (N, &argc, argv);
    377     CHIPMAP = TRUE;
     377    CHIPMAP = atoi(argv[N]);
     378    remove_argument (N, &argc, argv);
     379
    378380  }
    379381
     
    405407    RESET = TRUE;
    406408  }
    407 
    408409  RESET_BAD_IMAGES = FALSE;
    409410  if ((N = get_argument (argc, argv, "-reset-bad-images"))) {
    410411    remove_argument (N, &argc, argv);
    411412    RESET_BAD_IMAGES = TRUE;
     413  }
     414  RESET_IMAGES = FALSE;
     415  if ((N = get_argument (argc, argv, "-reset-images"))) {
     416    remove_argument (N, &argc, argv);
     417    RESET_IMAGES = TRUE;
    412418  }
    413419
     
    874880  fprintf (stderr, "  -high-speed (code[,code,code]) (code[,code,code]) (radius) (output catdir)\n");
    875881  fprintf (stderr, "  -hpm (radius) (output catdir)\n");
     882  fprintf (stderr, "  -chipmap (MaxOrder)\n");
    876883  fprintf (stderr, "  -merge-source (objID) (catID) into (objID) (catID)\n\n");
    877884
     
    886893  fprintf (stderr, "  -statmode (mode)\n");
    887894  fprintf (stderr, "  -reset\n");
     895  fprintf (stderr, "  -reset-images\n");
    888896  fprintf (stderr, "  -nloop (N) : number of image-fit iterations\n");
    889897  fprintf (stderr, "  -update : apply new fit to database\n");
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/launch_region_hosts.c

    r37665 r37699  
    128128    if (PhotFlagPoor)       strextend (command, "+photflagpoor %d", PhotFlagPoor);
    129129
     130    if (CHIPMAP)            strextend (command, "-chipmap %d", CHIPMAP);
     131    if (RESET_IMAGES)       strextend (command, "-reset-images");
     132
    130133    if (MinBadQF > 0.0)        strextend (command, "-min-bad-psfqf %f", MinBadQF);
    131134    if (MaxMeanOffset != 10.0) strextend (command, "-max-mean-offset  %f", MaxMeanOffset);
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_images.c

    r37684 r37699  
    7070
    7171    case TARGET_CHIPS:
     72      if (RESET_IMAGES) UpdateMeasures (catalog, Ncatalog);
    7273      for (i = 0; i < NLOOP; i++) {
    7374        UpdateObjects (catalog, Ncatalog, (i > 0)); // calculate <R>,<D>; if (i > 0), apply Galaxy Motion Model (if desired)
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_images.c

    r37694 r37699  
    103103    case TARGET_CHIPS:
    104104      for (i = 0; i < NLOOP; i++) {
     105        if (RESET_IMAGES) UpdateMeasures (catalog, Ncatalog);
    105106        UpdateObjects (catalog, Ncatalog, (i > 0));
    106107        if ((i > 1) || !USE_GALAXY_MODEL) {
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_regions.c

    r37665 r37699  
    6363
    6464  if (PARALLEL) {
    65     // save the updated image parameters
     65    // save the updated image parameters.  if we are NOT PARALLEL, we have to wait
     66    // until after UpdateObjectOffsets, or the image parameters are swapped and/or freed
     67    save_astrom_table ();
    6668    dvo_image_save (&db, VERBOSE);
    6769    dvo_image_unlock (&db);
     
    7375  if (!PARALLEL) {
    7476    // save the changes to the image parameters
     77    save_astrom_table ();
    7578    dvo_image_save (&db, VERBOSE);
    7679    dvo_image_unlock (&db);
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_images_pos.c

    r37665 r37699  
    8484      continue;
    8585    }
     86    Coords *moscoords = images[seq].coords.mosaic;
    8687    images[seq].coords     = image_pos[i].coords    ;
     88    images[seq].coords.mosaic = moscoords;
     89
    8790    images[seq].dXpixSys   = image_pos[i].dXpixSys  ;
    8891    images[seq].dYpixSys   = image_pos[i].dYpixSys  ;
     
    108111      if (seq < 0) continue;
    109112
    110       images[seq].coords.offsetMap = table->map[j];
    111       // is this sufficient?
     113      AstromOffsetMap *oldMap = images[seq].coords.offsetMap;
     114      AstromOffsetMap *newMap = table->map[j];
     115
     116      if (oldMap) {
     117        AstromOffsetMapSetOrder (oldMap, newMap->Nx, newMap->Ny, &images[seq]);
     118        AstromOffsetMapCopyData (oldMap, newMap);
     119      } else {
     120        lockUpdateChips ();
     121        AstromOffsetTable *FullTable = get_astrom_table ();
     122        AstromOffsetTableNewMap(FullTable, newMap->Nx, newMap->Ny, &images[seq]);  // registers the map with the image
     123        unlockUpdateChips ();
     124        AstromOffsetMapCopyData (images[seq].coords.offsetMap, newMap); // oldMap is now not valid
     125      }
    112126    }
     127    AstromOffsetTableFree(table);
    113128  }
    114129
Note: See TracChangeset for help on using the changeset viewer.