IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39641 for trunk


Ignore:
Timestamp:
Jul 29, 2016, 8:07:10 AM (10 years ago)
Author:
eugene
Message:

add 2 test image options; add manual uniquer for easy restart; set to use IRLS for image and object averages

Location:
trunk/Ohana/src/relphot
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/include/relphot.h

    r39636 r39641  
    276276int    PARALLEL_MANUAL;
    277277int    PARALLEL_SERIAL;
     278char  *MANUAL_UNIQUER;
    278279
    279280int    PARALLEL_REGIONS_MANUAL;
     
    286287int    MOSAIC_ZEROPT;
    287288
    288 int    TEST_IMAGE;
     289int    TEST_IMAGE1;
     290int    TEST_IMAGE2;
    289291
    290292int    NLOOP;
     
    309311int    FREEZE_IMAGES;
    310312int    FREEZE_MOSAICS;
     313int    CALIBRATE_STACKS_AND_WARPS;
    311314int    USE_GRID;
    312315int    KEEP_UBERCAL;
  • trunk/Ohana/src/relphot/src/ImageOps.c

    r39632 r39641  
    11# include "relphot.h"
     2# define BASIC_STATS 0
     3
    24void plot_setMcal (double *list, int Npts, StatType *stats, float clouds);
    35
     
    614616
    615617  off_t i, j, m, c, n, N, Nmax;
    616   int mark, bad, Nfew, Nbad, Nmos, Nrel, Ngrid, Nsys, Nbright;
     618  int mark, bad, Nfew, Nbad, Nmos, Nrel, Ngrid, Nsys;
    617619  float Msys, Mrel, Mmos, Mgrid, Mflat;
    618   double *list, *dlist, *Mlist, *dMlist;
     620  // double *list, *dlist, *Mlist, *dMlist;
    619621
    620622  StatType stats;
     
    637639    Nmax = MAX (Nmax, N_onImage[i]);
    638640  }
    639   ALLOCATE (list, double, Nmax);
    640   ALLOCATE (dlist, double, Nmax);
    641   ALLOCATE (Mlist, double, Nmax);
    642   ALLOCATE (dMlist, double, Nmax);
     641  StatDataSet *refStars = StatDataSetAlloc (1, Nmax);
     642  StatDataSet *brightStars = StatDataSetAlloc (1, Nmax);
    643643
    644644  Nfew = Nbad = Nmos = Ngrid = Nrel = Nsys = 0;
     
    647647  for (i = 0; i < Nimage; i++) {
    648648   
     649    if (image[i].imageID == TEST_IMAGE1) {
     650      fprintf (stderr, "test image 1\n");
     651    }
     652    if (image[i].imageID == TEST_IMAGE2) {
     653      fprintf (stderr, "test image 1\n");
     654    }
     655
    649656    /* on PoorImages run, skip good images */
    650657    if (PoorImages) {
     
    664671
    665672    int minUbercalDist = 1000;
    666 
    667     // number of stars to measure the bright-end scatter
    668     Nbright = 0;
    669 
    670     N = 0;
     673   
     674    off_t Nref = 0;  // total number of reference stars on the image
     675    int Nbright = 0; // number of stars to measure the bright-end scatter
     676
    671677    for (j = 0; j < N_onImage[i]; j++) {
    672678     
     
    716722
    717723    skip:
    718       list[N] = Msys - Mrel - Mmos - Mgrid + Mflat;
    719       dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR);
    720       if (fabs(list[N]) > 0.03) {
     724      refStars->flxlist[Nref] = Msys - Mrel - Mmos - Mgrid + Mflat;
     725      refStars->errlist[Nref] = MAX (catalog[c].measureT[m].dM, MIN_ERROR);
     726      refStars->wgtlist[Nref] = 1;
     727      refStars->msklist[Nref] = 0;
     728      if (fabs(refStars->flxlist[Nref]) > 0.03) {
    721729        // fprintf (stderr, "deviant\n");
    722730      }
    723731
    724       if (image[i].imageID == TEST_IMAGE) {
    725         fprintf (stderr, "%1d, %3d : %3d, %3d : %10.6f %10.6f : %6.3f  %6.3f  %6.3f  %6.3f  %6.3f : %6.3f\n", (int) i, (int) j, (int) c, (int) m, catalog[c].averageT[n].R, catalog[c].averageT[n].D, Msys, Mrel, Mmos, Mgrid, Mflat, list[N]);
     732      if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) {
     733        fprintf (stderr, "%1d, %3d : %3d, %3d : %10.6f %10.6f : %6.3f  %6.3f  %6.3f  %6.3f  %6.3f : %6.3f\n", (int) i, (int) j, (int) c, (int) m, catalog[c].averageT[n].R, catalog[c].averageT[n].D, Msys, Mrel, Mmos, Mgrid, Mflat, refStars->flxlist[Nref]);
    726734      }
    727735
    728736      if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) {
    729         Mlist[Nbright] = list[N];
    730         dMlist[Nbright] = dlist[N];
     737        brightStars->flxlist[Nbright] = refStars->flxlist[Nref];
     738        brightStars->errlist[Nbright] = refStars->errlist[Nref];
     739        brightStars->wgtlist[Nbright] = 1;
     740        brightStars->msklist[Nbright] = 0;
    731741        Nbright ++;
    732742      }
    733       N++;
     743      Nref++;
    734744    }
    735745    /* N_onImage[i] is all measurements, N is good measurements */
     
    740750    mark = FALSE;
    741751    if (!PoorImages) {
    742       mark = (N < IMAGE_TOOFEW) || (N < IMAGE_GOOD_FRACTION*N_onImage[i]);
     752      mark = (Nref < IMAGE_TOOFEW) || (Nref < IMAGE_GOOD_FRACTION*N_onImage[i]);
    743753      if (mark) {
    744754        image[i].flags |= ID_IMAGE_PHOTOM_FEW;
     
    750760
    751761    // no additional weight modification (we treat all stars on an image equally -- note an image is either ubercal-tied or not)
    752     liststats (list, dlist, NULL, N, &stats);
    753     image[i].Mcal  = stats.mean;
    754     image[i].dMcal = stats.error;
    755     image[i].nFitPhotom = N;
    756     image[i].Xm    = 100.0*log10(stats.chisq);
     762# if (BASIC_STATS)
     763    liststats (refStars->flxlist, refStars->errlist, NULL, Nref, &stats);
     764# else
     765    liststats_irls (refStars, Nref, &stats);
     766# endif
     767    image[i].Mcal       = stats.mean;
     768    image[i].dMcal      = stats.error;
     769    image[i].nFitPhotom = Nref;
     770    image[i].Xm         = 100.0*log10(stats.chisq);
    757771    Ncalibrated ++;
    758772
    759     if (image[i].imageID == TEST_IMAGE) {
     773    if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) {
     774      for (j = 0; j < Nref; j++) {
     775        fprintf (stderr, "%1d, %8d : %6.3f  %6.3f  %6.3f  %d\n", (int) i, (int) image[i].imageID, refStars->flxlist[j], refStars->errlist[j], refStars->wgtlist[j], refStars->msklist[j]);
     776      }
     777    }
     778
     779    if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) {
    760780      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal);
    761781    }
     
    767787    if (PLOTSTUFF) {
    768788      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal);
    769       plot_setMcal (list, N, &stats, CLOUD_TOLERANCE);
     789      plot_setMcal (refStars->flxlist, N, &stats, CLOUD_TOLERANCE);
    770790    }
    771791
    772792    // bright end scatter
    773     liststats (Mlist, dMlist, NULL, Nbright, &stats);
     793    liststats (brightStars->flxlist, brightStars->errlist, NULL, Nbright, &stats);
    774794    image[i].dMagSys = stats.sigma;
    775795
     
    782802    image[i].ubercalDist = minUbercalDist + 1;
    783803  }
    784   free (list);
    785   free (dlist);
    786   free (Mlist);
    787   free (dMlist);
     804
     805  StatDataSetFree (brightStars, 1);
     806  StatDataSetFree (refStars, 1);
    788807
    789808  fprintf (stderr, "%d images calibrated\n", Ncalibrated);
  • trunk/Ohana/src/relphot/src/args.c

    r39511 r39641  
    128128  }
    129129
     130  // elements needed for parallel regions / parallel images
     131  MANUAL_UNIQUER = NULL;
     132  if ((N = get_argument (argc, argv, "-manual-uniquer"))) {
     133    remove_argument (N, &argc, argv);
     134    MANUAL_UNIQUER = strcreate (argv[N]);
     135    remove_argument (N, &argc, argv);
     136  }
     137
    130138  PLOTSTUFF = FALSE;
    131139  if ((N = get_argument (argc, argv, "-plot"))) {
     
    176184  }
    177185
    178   TEST_IMAGE = -1;
    179   if ((N = get_argument (argc, argv, "-test-image"))) {
    180     remove_argument (N, &argc, argv);
    181     TEST_IMAGE = atoi(argv[N]);
     186  TEST_IMAGE1 = -1;
     187  if ((N = get_argument (argc, argv, "-test-image1"))) {
     188    char *endptr;
     189    remove_argument (N, &argc, argv);
     190    TEST_IMAGE1 = strtol(argv[N], &endptr, 0);
     191    if (*endptr) relphot_usage ();
     192    remove_argument (N, &argc, argv);
     193  }
     194  TEST_IMAGE2 = -1;
     195  if ((N = get_argument (argc, argv, "-test-image2"))) {
     196    char *endptr;
     197    remove_argument (N, &argc, argv);
     198    TEST_IMAGE2 = strtol(argv[N], &endptr, 0);
     199    if (*endptr) relphot_usage ();
    182200    remove_argument (N, &argc, argv);
    183201  }
     
    283301    FREEZE_IMAGES = TRUE;
    284302  }
    285 
    286303  FREEZE_MOSAICS = FALSE;
    287304  if ((N = get_argument (argc, argv, "-mosfreeze"))) {
    288305    remove_argument (N, &argc, argv);
    289306    FREEZE_MOSAICS = TRUE;
     307  }
     308  CALIBRATE_STACKS_AND_WARPS = FALSE;
     309  if ((N = get_argument (argc, argv, "-only-stacks-and-warps"))) {
     310    remove_argument (N, &argc, argv);
     311    CALIBRATE_STACKS_AND_WARPS = TRUE;
    290312  }
    291313
     
    620642  }
    621643
    622   TEST_IMAGE = -1;
     644  TEST_IMAGE1 = -1;
     645  TEST_IMAGE2 = -1;
    623646
    624647  RESET = FALSE;
  • trunk/Ohana/src/relphot/src/bcatalog.c

    r39478 r39641  
    106106
    107107      // skip garbage measurements
    108       if (catalog[0].measure[offset].psfQF < 0.85) { Npsfqf ++; continue; }
     108      if (isnan(catalog[0].measure[offset].psfQF)     || (catalog[0].measure[offset].psfQF < 0.85))     { Npsfqf ++; continue; }
     109      if (isnan(catalog[0].measure[offset].psfQFperf) || (catalog[0].measure[offset].psfQFperf < 0.85)) { Npsfqf ++; continue; }
    109110      if (isnan(catalog[0].measure[offset].M)) { Nnan ++; continue; }
    110111
  • trunk/Ohana/src/relphot/src/liststats.c

    r39636 r39641  
    210210 
    211211  // XXX add to dataset elements?
    212   ALLOCATE_PTR (wt, double, Npoints);
     212  ALLOCATE_PTR (wtvals, double, Npoints);
     213  ALLOCATE_PTR (wtlist, double, Npoints);
    213214
    214215  int converged = FALSE;
     
    217218    for (int i = 0; i < Npoints; i++) {
    218219      // we are only including the formal error, not the weight in the definition of wt[]
    219       wt[i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]);
     220      wtvals[i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]);
    220221    }
    221222   
    222223    double oldValue = value;
    223     if (!fit_least_squares (&value, dataset->flxlist, dataset->errlist, dataset->wgtlist, wt, Npoints)) {
     224    if (!fit_least_squares (&value, dataset->flxlist, dataset->errlist, dataset->wgtlist, wtvals, Npoints)) {
    224225      value = oldValue;
    225226      break;
     
    235236     
    236237  // calculate the weight thresholds to mask the bad points:
    237   double Sum_W = 0.0;
     238  // double Sum_W = 0.0;
    238239  for (int i = 0; i < Npoints; i++) {
    239     wt[i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]);
    240     Sum_W += wt[i];
    241   }
    242   double WtThreshold = WEIGHT_THRESHOLD * Sum_W / (1.0 * Npoints);
     240    wtvals[i] = weight_cauchy ((dataset->flxlist[i] - value) / dataset->errlist[i]);
     241    wtlist[i] = wtvals[i];
     242    // Sum_W += wtvals[i];
     243  }
     244  dsort (wtlist, Npoints);
     245  int midpt = 0.5 * Npoints;
     246  double WtMedian = (Npoints % 2) ? wtlist[midpt] : 0.5*(wtlist[midpt] + wtlist[midpt-1]);
     247  // double WtThreshold = WEIGHT_THRESHOLD * Sum_W / (1.0 * Npoints);
     248  double WtThreshold = WEIGHT_THRESHOLD * WtMedian;
    243249
    244250  // generate the unmasked subset
     
    255261  double dSig = 0.0;
    256262  for (int i = 0; i < Npoints; i++) {
    257     if ((wt[i] < WtThreshold) || !isfinite(dataset->flxlist[i])) {
     263    if ((wtvals[i] < WtThreshold) || !isfinite(dataset->flxlist[i])) {
    258264      dataset->msklist[i] = TRUE; // mark the masked points
    259265      continue;
     
    313319  free (dykeep);
    314320  free (wtkeep);
    315   free (wt);
     321  free (wtvals);
     322  free (wtlist);
    316323
    317324  return TRUE;
  • trunk/Ohana/src/relphot/src/load_catalogs.c

    r39478 r39641  
    115115  int TIME = time(NULL);
    116116  int PID = getpid();
    117   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     117
     118  if (PARALLEL_MANUAL && MANUAL_UNIQUER) {
     119    snprintf (uniquer, 12, "%11s", MANUAL_UNIQUER);
     120  } else {
     121    snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     122  }
    118123
    119124  int Nsecfilt  = GetPhotcodeNsecfilt ();               // set the desired number in case we need to create the catalog
  • trunk/Ohana/src/relphot/src/relphot_images.c

    r39481 r39641  
    5353  FlatCorrectionTable *flatcorr = NULL;
    5454
    55   if (NLOOP > 0) {
     55  if (CALIBRATE_STACKS_AND_WARPS || (NLOOP > 0)) {
    5656    /* load catalog data from region files (hostID is 0 since we are not a client */
    5757    catalog = load_catalogs (skylist, &Ncatalog, 0, NULL, NULL);
     
    154154
    155155    /* set Mcal & Mmos for bad images */
    156     setMcal  (catalog, TRUE, flatcorr);
    157     setMmos  (catalog, TRUE, flatcorr);
     156    int onlyPoorImages = !CALIBRATE_STACKS_AND_WARPS;
     157    setMcal  (catalog, onlyPoorImages, flatcorr);
     158    setMmos  (catalog, onlyPoorImages, flatcorr);
    158159    MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
    159160
     
    248249     context, this function writes the image parameters as a subset table for the remote
    249250     clients */
    250   reload_catalogs (skylist, flatcorr, 0, NULL);
    251   MARKTIME("-- updated all catalogs: %f sec\n", dtime);
     251  if (!CALIBRATE_STACKS_AND_WARPS) {
     252    reload_catalogs (skylist, flatcorr, 0, NULL);
     253    MARKTIME("-- updated all catalogs: %f sec\n", dtime);
     254  }
    252255
    253256  if (UPDATE_CATFORMAT) {
     
    255258    db.format = dvo_catalog_catformat (UPDATE_CATFORMAT);
    256259  }
    257   if (NLOOP > 0) {
     260  if (CALIBRATE_STACKS_AND_WARPS || (NLOOP > 0)) {
    258261    // do not save changes if we did not make changes.
    259262    dvo_image_update (&db, VERBOSE);
Note: See TracChangeset for help on using the changeset viewer.