IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35604


Ignore:
Timestamp:
May 29, 2013, 9:03:05 AM (13 years ago)
Author:
eugene
Message:

fix / cleanup some of the relphot plotting functions (Mmos plots failed in threaded context); force use of INNER_WTMEAN for Mmos

Location:
branches/eam_branches/ipp-20130509/Ohana/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130509/Ohana/src/libkapa/src/IOfuncs.c

    r34582 r35604  
    3030  sscanf (buffer, "%*s %d", &Nbytes);
    3131  ALLOCATE (data, char, Nbytes + 1);
     32  memset (data, 0, Nbytes + 1);
     33
    3234  status = read (device, data, Nbytes);
    3335  if (status != Nbytes) {
     
    7880      // XXX BUT: I need to think a bit more about hand-shaking.
    7981  }
    80   if (DEBUG) fprintf (stderr, "recv buffer: %s\n", buffer);
     82  if (DEBUG) fprintf (stderr, "recv buffer: %s...\n", buffer);
    8183
    8284  /* find the message length, allocate space */
    8385  sscanf (buffer, "%*s %d", &Nbytes);
    8486  ALLOCATE (message, char, Nbytes + 1);
     87  memset (message, 0, Nbytes + 1);
    8588
    8689  /* read Nbytes from the device */
     
    9295  /* make the string easy to parse */
    9396
    94   if (DEBUG) fprintf (stderr, "recv: %s\n", message);
     97  if (DEBUG) fprintf (stderr, "recv: %s...\n", message);
    9598
    9699  /* scan the incoming message */
     
    131134  if (Nwrite != length) return (FALSE);
    132135
    133   if (DEBUG) fprintf (stderr, "send: %s\n", string);
     136  if (DEBUG) fprintf (stderr, "send: %s...\n", string);
    134137
    135138  free (string);
     
    145148
    146149  ALLOCATE (message, char, length + 1);
     150  memset (message, 0, length + 1);
    147151
    148152  /* read Nbytes from the device */
    149153  status = read (device, message, length);
    150   if (DEBUG) fprintf (stderr, "recv message: %s\n", message);
     154  if (DEBUG) fprintf (stderr, "recv message: %s...\n", message);
    151155
    152156  if (status != length) {
     
    173177  Nbytes = strlen (expect);
    174178  ALLOCATE (answer, char, Nbytes + 1);
     179  memset (answer, 0, Nbytes + 1);
    175180
    176181  KiiScanCommand (device, Nbytes, "%s", answer);
  • branches/eam_branches/ipp-20130509/Ohana/src/relphot/include/relphot.h

    r35416 r35604  
    328328void          plot_star_coords    PROTO((Catalog *catalog, int Ncatalog));
    329329void          plot_stars          PROTO((Catalog *catalog, int Ncatalog));
     330
     331void          plot_list_add       PROTO((Graphdata *graphdata, double *xlist, double *ylist, int N));
     332int           get_graph           PROTO((int N));
     333int           open_graph          PROTO((int N));
     334
    330335void          reload_catalogs     PROTO((SkyList *skylist, FlatCorrectionTable *flatcorr, int hostID, char *hostpath));
    331336int           reload_catalogs_parallel PROTO((SkyList *sky));
  • branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/ImageOps.c

    r35600 r35604  
    595595    image[i].Xm    = 100.0*log10(stats.chisq);
    596596
    597     plot_setMcal (list, N, &stats, CLOUD_TOLERANCE);
     597    if (PLOTSTUFF) {
     598      fprintf (stderr, "Mcal for : %s\n", image[i].name);
     599      plot_setMcal (list, N, &stats, CLOUD_TOLERANCE);
     600    }
    598601
    599602    // bright end scatter
     
    683686}
    684687
     688static int setMcal_init_done = FALSE;
    685689void plot_setMcal (double *list, int Npts, StatType *stats, float clouds) {
    686690
     
    692696
    693697  if (Npts == 0) {
    694     fprintf (stderr, "cannot set image Mcal values yet (nan Mave)\n");
     698    // fprintf (stderr, "cannot set image Mcal values yet (nan Mave)\n");
    695699    return;
    696700  }
    697701
     702  plot_defaults (&graphdata);
     703  graphdata.xmin = -0.01;
     704  graphdata.xmax = +1.01;
     705  graphdata.ymin = -0.21;
     706  graphdata.ymax = +0.21;
     707
     708  if (!setMcal_init_done) {
     709    int kapa = get_graph(0);
     710    if (kapa < 1) {
     711      kapa = open_graph(0);
     712      if (!kapa) return;
     713    }
     714
     715    KapaClearSections (kapa);
     716    KapaClearPlots (kapa);
     717    KapaSetLimits (kapa, &graphdata);
     718    KapaSetFont (kapa, "helvetica", 14);
     719    KapaBox (kapa, &graphdata);
     720    setMcal_init_done = TRUE;
     721  }
     722
    698723  ALLOCATE (xlist, double, Npts);
    699 
    700   /**** Mcal vs seq ****/
    701   float minMcal    = +100.0;
    702   float maxMcal    = -100.0;
    703724  for (i = 0; i < Npts; i++) {
    704     xlist[i] = i;
    705     minMcal = MIN (list[i], minMcal);
    706     maxMcal = MAX (list[i], maxMcal);
    707   }
    708 
    709   float McalRange  = MAX(1.2*(maxMcal - minMcal), 0.21);
    710   float McalCenter = 0.5*(maxMcal + minMcal);
    711 
    712   plot_defaults (&graphdata);
    713   graphdata.xmin = -1;
    714   graphdata.xmax = Npts + 1;
    715   graphdata.ymin = McalCenter - 0.5*McalRange;
    716   graphdata.ymax = McalCenter + 0.5*McalRange;
    717   plot_list (&graphdata, xlist, list, Npts, "sequence vs Mcal", "%s.seq.png", OUTROOT);
     725    xlist[i] = i / (float) Npts;
     726  }
     727
     728  plot_list_add (&graphdata, xlist, list, Npts);
    718729
    719730  free (xlist);
  • branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/MosaicOps.c

    r35416 r35604  
    711711  if (FREEZE_MOSAICS) return (FALSE);
    712712
    713   if (NTHREADS) {
     713  // plots cannot be done in a threaded context (the plot commands collide)
     714  // so do not run setMmos in threaded mode if PLOTSTUFF is set
     715  if (NTHREADS && !PLOTSTUFF) {
    714716    int status = setMmos_threaded (catalog, PoorImages, flatcorr);
    715717    return status;
     
    734736  SetMmosInfoInit (&info, Nmax, TRUE, PoorImages);
    735737
     738  // int savePlotDelay = PLOTDELAY;
     739  // if (PLOTSTUFF) PLOTDELAY = 0.0;
     740
    736741  for (i = 0; i < Nmosaic; i++) {
    737742    setMmos_mosaic (&mosaic[i], i, image, catalog, &info, flatcorr);
    738743  }
    739744  SetMmosInfoFree (&info);
     745
     746  if (PLOTSTUFF) {
     747    fprintf (stdout, "press return\n");
     748    if (fscanf (stdin, "%*c") != 1) fprintf (stderr, "\n");
     749  }
    740750
    741751  npass_output ++;
     
    757767
    758768  StatType stats;
    759   liststats_setmode (&stats, STATMODE);
     769  // liststats_setmode (&stats, STATMODE);
     770  liststats_setmode (&stats, "INNER_WTMEAN");
    760771
    761772  double *list   = info->list;
     
    937948  }
    938949
    939   plot_setMcal (list, N, &stats, CLOUD_TOLERANCE);
     950  if (PLOTSTUFF) {
     951    fprintf (stderr, "Mmos: %6.3f %6.3f +/- %6.3f %5d %5d | %s\n", stats.mean, stats.median, stats.sigma, stats.Nmeas, N, image[MosaicToImage[Nmos][0]].name);
     952    plot_setMcal (list, N, &stats, CLOUD_TOLERANCE);
     953  }
    940954
    941955  // bright end scatter
     
    961975    // fprintf (stderr, "%d %d %d\n", (int) i, (int) im, image[im].ubercalDist);
    962976  }
     977 
    963978  return TRUE;
    964979}
  • branches/eam_branches/ipp-20130509/Ohana/src/relphot/src/plotstuff.c

    r35600 r35604  
    1717  fprintf (stderr, "kapa is dead, must restart\n");
    1818  Xgraph[active] = -1;
     19}
     20
     21int get_graph (int N) {
     22  return Xgraph[N];
    1923}
    2024
     
    156160}
    157161
     162// plot the vector pair to a file with name defined by the varargs format
     163void plot_list_add (Graphdata *graphdata, double *xlist, double *ylist, int Npts) {
     164
     165  KapaPrepPlot (Xgraph[0], Npts, graphdata);
     166  PlotVector (Npts, xlist, 0, 0, "x");
     167  PlotVector (Npts, ylist, 1, 0, "y");
     168}
     169
    158170void plot_defaults (Graphdata *graphdata) {
    159171
Note: See TracChangeset for help on using the changeset viewer.