IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7400


Ignore:
Timestamp:
Jun 7, 2006, 8:29:14 AM (20 years ago)
Author:
eugene
Message:

updated fitcolors to include plots, better clipping

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/fitcolors.c

    r7080 r7400  
    1717  char *RegionName, *RegionList;
    1818  char *cmd, *outcmd, *camera;
     19  char name[64], filename[64], plotname[64], label[64];
    1920  double *M1, *M2;
    20   float *out;
     21  float *out, *colorFit, *deltaFit, color, dColor, C0, C1;
    2122  float minDelta, maxDelta, minColor, maxColor;
     23  int fd, Npx, Npy, NPX, NPY, Nplot, PLOT;
     24  Graphdata graphdata;
     25  KapaSection section;
    2226
    2327  Catalog *catalog;
     
    3236  codelist = NULL;
    3337  xvec = yvec = NULL;
     38  colorFit = NULL;
     39  deltaFit = NULL;
    3440
    3541  oldsignal = signal (SIGINT, handle_interrupt);
     
    6470  }
    6571
     72  PLOT = FALSE;
     73  if ((N = get_argument (argc, argv, "-plot"))) {
     74    remove_argument (N, &argc, argv);
     75    strcpy (plotname, argv[N]);
     76    remove_argument (N, &argc, argv);
     77    NPX = atof(argv[N]);
     78    remove_argument (N, &argc, argv);
     79    NPY = atof(argv[N]);
     80    remove_argument (N, &argc, argv);
     81    PLOT = TRUE;
     82  }
     83
    6684  /* interpret command-line options */
    6785  if (argc != 4) goto usage;
     86
     87  if (PLOT) {
     88    if (!GetGraph (&graphdata, &fd, NULL)) return (FALSE);
     89    Nplot = 0;
     90    Npx = Npy = 0;
     91    graphdata.xmin = minColor;
     92    graphdata.xmax = maxColor;
     93    graphdata.ymin = minDelta;
     94    graphdata.ymax = maxDelta;
     95    graphdata.style = 2;
     96    graphdata.ptype = 2;
     97    KapaClear (fd, TRUE);
     98    KapaSetFont (fd, "helvetica", 14);
     99
     100    ALLOCATE (colorFit, float, 11);
     101    ALLOCATE (deltaFit, float, 11);
     102    dColor = (maxColor - minColor) / 10.0;
     103    for (i = 0; i < 11; i++) {
     104      colorFit[i] = minColor + i*dColor;
     105    }
     106  }
    68107
    69108  /* determine relevant photcodes, colors */
     
    154193  if ((yvec = SelectVector ("tmp_y", ANYVECTOR, TRUE)) == NULL) goto escape;
    155194
     195  // set up basic windows
     196  if (PLOT) {
     197    Nplot = 0;
     198    Npx = Npy = 0;
     199    NPX = NPY = 6;
     200    KapaInitGraph (&graphdata);
     201    graphdata.xmin = minColor;
     202    graphdata.xmax = maxColor;
     203    graphdata.ymin = minDelta;
     204    graphdata.ymax = maxDelta;
     205    graphdata.style = 2;
     206    graphdata.ptype = 2;
     207  }
     208
    156209  /*** generate the color-color vectors for the pairs ***/
    157210  // XXXX this function also needs to check for interrupts
     
    218271      if (outcmd != NULL) free (outcmd);
    219272     
     273      C0 = get_double_variable ("C0");
     274      C1 = get_double_variable ("C1");
     275     
    220276      /* do something useful with the results (stored in Cn, C0, C1, etc) */
    221277      fprintf (GetOutfile(), "%s - %s : ", code[0][0].name, code[1][0].name);
    222278      fprintf (GetOutfile(), "%7.4f %7.4f   %7.4f   ",
    223                get_double_variable ("C0"), get_double_variable ("C1"), get_double_variable ("dC"));
     279               C0, C1, get_double_variable ("dC"));
    224280      fprintf (GetOutfile(), "%5s of %5d\n", get_variable ("Cnv"), Npts);
    225       out[NP1 + NP2*NP] = get_double_variable ("C1");
     281      out[NP1 + NP2*NP] = C1;
     282
     283      // make an illustrating plot of each chip vs each other chip
     284      // each page should have, say, a 6x6 grid of plots. each one should show a single chip pair
     285      // as the page fills up, it gets written and a new one created. 
     286      if (PLOT) {
     287        sprintf (name, "s%02d.%02d", Npx, Npy);
     288        section.name = strcreate (name);
     289        if (Npx || Npy) {
     290          section.dx = 0.9 / NPX;
     291          section.dy = 0.9 / NPY;
     292          section.x = 0.1 + Npx * section.dx;
     293          section.y = 0.1 + Npy * section.dy;
     294          strcpy (graphdata.labels, "0000");
     295        }
     296        if (Npx == 0) {
     297          section.dx = 0.9 / NPX + 0.1;
     298          section.dy = 0.9 / NPY;
     299          section.x = 0.0;
     300          section.y = 0.1 + Npy * section.dy;
     301          strcpy (graphdata.labels, "0100");
     302        }
     303        if (Npy == 0) {
     304          section.dx = 0.9 / NPX;
     305          section.dy = 0.9 / NPY + 0.1;
     306          section.x = 0.1 + Npx * section.dx;
     307          section.y = 0.0;
     308          strcpy (graphdata.labels, "1000");
     309        }
     310        if (!Npx && !Npy) {
     311          section.dx = 0.9 / NPX + 0.1;
     312          section.dy = 0.9 / NPY + 0.1;
     313          section.x = 0.0;
     314          section.y = 0.0;
     315          strcpy (graphdata.labels, "1100");
     316        }
     317        KapaSetSection (fd, &section);
     318        KapaSetLimits (fd, &graphdata);
     319        KapaBox (fd, &graphdata);
     320        KapaPrepPlot (fd, Npts, &graphdata);
     321        KapaPlotVector (fd, Npts, xvec[0].elements);
     322        KapaPlotVector (fd, Npts, yvec[0].elements);
     323
     324        for (i = 0; i < 11; i++) {
     325          deltaFit[i] = C0 + C1*colorFit[i];
     326        }
     327        graphdata.style = 0;
     328        graphdata.color = KapaColorByName ("red");
     329        KapaPrepPlot (fd, 11, &graphdata);
     330        KapaPlotVector (fd, 11, colorFit);
     331        KapaPlotVector (fd, 11, deltaFit);
     332
     333        KapaSetFont (fd, "helvetica", 8);
     334        sprintf (label, "%s", code[0][0].name);
     335        KapaSendTextline (fd, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0);
     336        sprintf (label, "%s", code[1][0].name);
     337        KapaSendTextline (fd, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0);
     338        KapaSetFont (fd, "helvetica", 14);
     339
     340        graphdata.style = 2;
     341        graphdata.color = KapaColorByName ("black");
     342
     343        free (section.name);
     344
     345        Npx++;
     346        if (Npx == NPX) {
     347          Npx = 0;
     348          Npy ++;
     349          if (Npy == NPY) {
     350            Npy = 0;
     351            sprintf (filename, "%s.%02d.png", plotname, Nplot);
     352            KapaPNG (fd, filename);
     353            KapaClear (fd, TRUE);
     354            Nplot++;
     355          }
     356        }
     357      }
    226358    }
    227359  }
    228   SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     360  if (skylist != NULL) free_catalog (catalog, skylist[0].Nregions);
     361  if (skylist != NULL) SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    229362  if (RegionName != NULL) free (RegionName);
    230363  if (RegionList != NULL) free (RegionList);
     364  if (codelist != NULL) free (codelist);
     365  if (colorFit != NULL) free (colorFit);
     366  if (deltaFit != NULL) free (deltaFit);
    231367  signal (SIGINT, oldsignal);
    232368  return (TRUE);
     
    250386  if (RegionList != NULL) free (RegionList);
    251387  if (codelist != NULL) free (codelist);
     388  if (colorFit != NULL) free (colorFit);
     389  if (deltaFit != NULL) free (deltaFit);
    252390  DeleteVector (xvec);
    253391  DeleteVector (yvec);
Note: See TracChangeset for help on using the changeset viewer.