IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 11, 2015, 2:14:39 PM (12 years ago)
Author:
eugene
Message:

merge changes from eam branch ipp-20140904

Location:
trunk/Ohana
Files:
60 edited
12 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/opihi/cmd.astro/Makefile

    r36489 r37807  
    7171$(SRC)/star.$(ARCH).o              \
    7272$(SRC)/transform.$(ARCH).o         \
     73$(SRC)/vshimage.$(ARCH).o         \
     74$(SRC)/shimage.$(ARCH).o         \
    7375$(SRC)/imsub.$(ARCH).o             \
    7476$(SRC)/imfit.$(ARCH).o             \
  • trunk/Ohana/src/opihi/cmd.astro/cdensify.c

    r36489 r37807  
    9797  // generate the PSF in a local tangent plane
    9898  Coords coords;
    99   coords.crpix1 = coords.crpix2 = 0.0;
    100   coords.crval1 = coords.crval2 = 0.0;
    101   coords.cdelt1 = coords.cdelt2 = 1.0;
    102   coords.pc1_1  = coords.pc2_2  = 1.0;
    103   coords.pc1_2  = coords.pc2_1  = 0.0;
    104   coords.Npolyterms = 0;
    105   strcpy (coords.ctype, "DEC--TAN");
     99  InitCoords (&coords, "DEC--TAN");
    106100
    107101  r = vr[0].elements.Flt;
  • trunk/Ohana/src/opihi/cmd.astro/coords.c

    r33662 r37807  
    7171    if ((mosbuffer = SelectBuffer (MOSAIC, OLDBUFFER, TRUE)) == NULL) goto escape;
    7272    GetCoords (&moscoords, &mosbuffer[0].header);
    73     RegisterMosaic (&moscoords);
     73    coords.mosaic = &moscoords;
    7474  }
    7575 
  • trunk/Ohana/src/opihi/cmd.astro/csystem.c

    r34342 r37807  
    1313  if (argc != 5) goto syntax;
    1414
    15   switch (argv[1][0]) {
    16     case 'C': input = COORD_CELESTIAL; break;
    17     case 'G': input = COORD_GALACTIC; break;
    18     case 'E': input = COORD_ECLIPTIC; break;
    19     default: goto syntax;
     15  if (!strcmp(argv[1], "G2004")) {
     16    input = COORD_GALACTIC_REID_2004;
     17  } else {
     18    switch (argv[1][0]) {
     19      case 'C': input = COORD_CELESTIAL; break;
     20      case 'G': input = COORD_GALACTIC; break;
     21      case 'E': input = COORD_ECLIPTIC; break;
     22      default: goto syntax;
     23    }
    2024  }
    2125
    22   switch (argv[2][0]) {
    23     case 'C': output = COORD_CELESTIAL; break;
    24     case 'G': output = COORD_GALACTIC; break;
    25     case 'E': output = COORD_ECLIPTIC; break;
    26     default: goto syntax;
     26  if (!strcmp(argv[2], "G2004")) {
     27    output = COORD_GALACTIC_REID_2004;
     28  } else {
     29    switch (argv[2][0]) {
     30      case 'C': output = COORD_CELESTIAL; break;
     31      case 'G': output = COORD_GALACTIC; break;
     32      case 'E': output = COORD_ECLIPTIC; break;
     33      default: goto syntax;
     34    }
    2735  }
    2836
  • trunk/Ohana/src/opihi/cmd.astro/fitplx.c

    r36489 r37807  
    104104  /* project coordinates to a plane centered on the object with units of arcsec */
    105105  Coords coords;
     106  InitCoords (&coords, "DEC--SIN");
    106107  coords.crval1 = Rmean;
    107108  coords.crval2 = Dmean;
    108   coords.crpix1 = 0;
    109   coords.crpix2 = 0;
    110109  coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0;
    111   coords.pc1_1  = coords.pc2_2 = 1.0;
    112   coords.pc1_2  = coords.pc2_1 = 0.0;
    113   coords.Npolyterms = 1;
    114   strcpy (coords.ctype, "DEC--SIN");
    115110
    116111  double *X, *Y, *t, *pX, *pY, *dX, *dY;
  • trunk/Ohana/src/opihi/cmd.astro/fitpm.c

    r36489 r37807  
    100100  /* project coordinates to a plane centered on the object with units of arcsec */
    101101  Coords coords;
     102  InitCoords (&coords, "DEC--SIN");
    102103  coords.crval1 = Rmean;
    103104  coords.crval2 = Dmean;
    104   coords.crpix1 = 0;
    105   coords.crpix2 = 0;
    106105  coords.cdelt1 = coords.cdelt2 = 1.0 / 3600.0;
    107   coords.pc1_1  = coords.pc2_2 = 1.0;
    108   coords.pc1_2  = coords.pc2_1 = 0.0;
    109   coords.Npolyterms = 1;
    110   strcpy (coords.ctype, "DEC--SIN");
    111106
    112107  double *X, *Y, *t, *dX, *dY;
  • trunk/Ohana/src/opihi/cmd.astro/gauss.c

    r36679 r37807  
    3030  if (!GetImageData (&data, &kapa, name)) return (FALSE);
    3131  FREE (name);
     32
     33  int channel = 0;
     34  if ((N = get_argument (argc, argv, "-ch"))) {
     35    channel = GetKapaChannelFromString (argv[N]);
     36    if (!channel) return FALSE;
     37    KiiSetChannel (kapa, channel - 1);
     38  }
    3239
    3340  Nborder = 3;
  • trunk/Ohana/src/opihi/cmd.astro/getcoords.c

    r34345 r37807  
    5454  if (!strcmp(&coords.ctype[4], "-WRP")) {
    5555    if (MOSAIC == NULL) {
    56       gprint (GP_ERR, "must supply mosaic for WRP coords\n");
     56      gprint (GP_ERR, "must supply mosaic for WRP coords with -mosaic [buffer]\n");
    5757      return (FALSE);
    5858    }
     
    6565    }
    6666    GetCoords (&moscoords, &mosbuffer[0].header);
    67     RegisterMosaic (&moscoords);
     67    coords.mosaic = &moscoords;
    6868  }
    6969 
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r36489 r37807  
    6161int times                   PROTO((int, char **));
    6262int transform               PROTO((int, char **));
     63int vshimage                PROTO((int, char **));
     64int shimage                 PROTO((int, char **));
    6365
    6466static Command cmds[] = { 
     
    121123  {1, "star",        star,         "star stats at rough coords"},
    122124  {1, "transform",   transform,    "geometric transformation of image"},
     125  {1, "vshimage",    vshimage,     "generate images for vector spherical harmonic terms"},
     126  {1, "shimage",     shimage,      "generate images for spherical harmonic terms"},
    123127};
    124128
  • trunk/Ohana/src/opihi/cmd.astro/objload.c

    r34088 r37807  
    1919  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    2020  FREE (name);
     21
     22  int channel = 0;
     23  if ((N = get_argument (argc, argv, "-ch"))) {
     24    channel = GetKapaChannelFromString (argv[N]);
     25    if (!channel) return FALSE;
     26    KiiSetChannel (kapa, channel - 1);
     27  }
    2128
    2229  Objtype = 0;
  • trunk/Ohana/src/opihi/cmd.astro/region.c

    r36489 r37807  
    1717  if (!GetGraph (&graphmode, &kapa, name)) return (FALSE);
    1818  FREE (name);
     19
     20  int channel = 0;
     21  if ((N = get_argument (argc, argv, "-ch"))) {
     22    channel = GetKapaChannelFromString (argv[N]);
     23    if (!channel) return FALSE;
     24    KiiSetChannel (kapa, channel - 1);
     25  }
    1926
    2027  NoClear = FALSE;
     
    8087  if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE);
    8188  Radius = atof (argv[3]);
    82   strcpy (graphmode.coords.ctype, "DEC--TAN");
     89  InitCoords (&graphmode.coords, "DEC--TAN");
     90
    8391  if (argc == 5) {
    8492    if (!strcasecmp (argv[4], "TAN"))
     
    99107      strcpy (graphmode.coords.ctype, "DEC--PAR");
    100108  }
     109 
     110  graphmode.coords.crval1 = Ra;
     111  graphmode.coords.crval2 = Dec;
    101112
    102  
     113  graphmode.coords.pc1_1 = (graphmode.flipeast) ? -1 : 1;
     114  graphmode.coords.pc2_2 = (graphmode.flipnorth) ? -1 : 1;
     115
    103116  /* ask kapa for coordinate limits, to get the right aspect ratio */
    104117  KapaGetLimits (kapa, &dx, &dy);
     
    132145  set_int_variable ("NORTH_UP", !graphmode.flipnorth);
    133146
    134   graphmode.coords.pc1_1 = (graphmode.flipeast) ? -1 : 1;
    135   graphmode.coords.pc2_2 = (graphmode.flipnorth) ? -1 : 1;
    136 
    137   graphmode.coords.pc1_2 = graphmode.coords.pc2_1 = 0.0;
    138   graphmode.coords.crval1 = Ra;
    139   graphmode.coords.crval2 = Dec;
    140   graphmode.coords.crpix1 = 0.0;
    141   graphmode.coords.crpix2 = 0.0;
    142   graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0;
    143 
    144147  if (!NoClear) KapaClearSections (kapa);
    145148  KapaSetLimits (kapa, &graphmode);
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r37049 r37807  
    3939$(SRC)/densify.$(ARCH).o        \
    4040$(SRC)/device.$(ARCH).o \
     41$(SRC)/dft2d.$(ARCH).o  \
    4142$(SRC)/dimendown.$(ARCH).o      \
    4243$(SRC)/dimenup.$(ARCH).o        \
     
    160161$(SRC)/vstats.$(ARCH).o            \
    161162$(SRC)/xsection.$(ARCH).o          \
     163$(SRC)/vsh.$(ARCH).o       \
     164$(SRC)/vshfit.$(ARCH).o    \
     165$(SRC)/shterms.$(ARCH).o           \
     166$(SRC)/shfit.$(ARCH).o     \
     167$(SRC)/shdot.$(ARCH).o     \
     168$(SRC)/shapply.$(ARCH).o           \
    162169$(SRC)/wd.$(ARCH).o                \
    163170$(SRC)/write_vectors.$(ARCH).o     \
  • trunk/Ohana/src/opihi/cmd.data/center.c

    r29540 r37807  
    1616  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1717  FREE (name);
     18
     19  int channel = 0;
     20  if ((N = get_argument (argc, argv, "-ch"))) {
     21    channel = GetKapaChannelFromString (argv[N]);
     22    if (!channel) return FALSE;
     23    KiiSetChannel (kapa, channel - 1);
     24  }
    1825
    1926  // XXX need an option to center the image based on the current plot limits
  • trunk/Ohana/src/opihi/cmd.data/dimenup.c

    r20936 r37807  
    2323    return (FALSE);
    2424  }
    25 
    26   gfits_free_matrix (&buf[0].matrix);
    27   gfits_free_header (&buf[0].header);
    28   CreateBuffer (buf, Nx, Ny, -32, 0.0, 1.0);
     25  ResetBuffer (buf, Nx, Ny, -32, 0.0, 1.0);
    2926
    3027  out = (float *) buf[0].matrix.buffer;
  • trunk/Ohana/src/opihi/cmd.data/erase.c

    r13479 r37807  
    1515  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1616  FREE (name);
     17
     18  int channel = 0;
     19  if ((N = get_argument (argc, argv, "-ch"))) {
     20    channel = GetKapaChannelFromString (argv[N]);
     21    if (!channel) return FALSE;
     22    KiiSetChannel (kapa, channel - 1);
     23  }
    1724
    1825  if (argc < 2) {
  • trunk/Ohana/src/opihi/cmd.data/fit2d.c

    r31160 r37807  
    138138    y = yvec[0].elements.Flt;
    139139    z = zvec[0].elements.Flt;
     140    if (Weight) dz = dzvec[0].elements.Flt;
     141
    140142    for (i = 0; i < xvec[0].Nelements; i++, x++, y++, z++) {
    141143      if (mask[i]) continue;
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r37049 r37807  
    11# include "data.h"
     2// XXX adding a comment
    23
    34int accum            PROTO((int, char **));
     
    3132int densify          PROTO((int, char **));
    3233int device           PROTO((int, char **));
     34int dft2d            PROTO((int, char **));
    3335int dimendown        PROTO((int, char **));
    3436int dimenup          PROTO((int, char **));
     
    147149int vpop             PROTO((int, char **));
    148150int vsmooth          PROTO((int, char **));
     151int vsh              PROTO((int, char **));
     152int vshfit           PROTO((int, char **));
     153int shterms          PROTO((int, char **));
     154int shfit            PROTO((int, char **));
     155int shdot            PROTO((int, char **));
     156int shapply          PROTO((int, char **));
    149157int wd               PROTO((int, char **));
    150158int write_vectors    PROTO((int, char **));
     
    189197  {1, "densify",      densify,          "create an image histogram from a set of vectors"},
    190198  {1, "device",       device,           "set / get current graphics device"},
     199  {1, "dft2d",        dft2d,            "2D discrete fourier transform"},
    191200  {1, "dimendown",    dimendown,        "convert image to vector"},
    192201  {1, "dimenup",      dimenup,          "convert vector to image"},
     
    314323  {1, "vstats",       vstats,           "statistics on a vector"},
    315324  {1, "vzload",       vzload,           "load vectors as overlay on image display (scaled points)"},
     325  {1, "vsh",          vsh,              "Vector Spherical Harmonics"},
     326  {1, "vshfit",       vshfit,           "Vector Spherical Harmonics fits"},
     327  {1, "shterms",      shterms,          "Spherical Harmonics terms"},
     328  {1, "shfit",        shfit,            "Spherical Harmonics fits"},
     329  {1, "shdot",        shdot,            "Spherical Harmonics dot product"},
     330  {1, "shapply",      shapply,          "Spherical Harmonics fit application"},
    316331  {1, "wd",           wd,               "write an image to a file"},
    317332  {1, "write",        write_vectors,    "write vectors to datafile"},
  • trunk/Ohana/src/opihi/cmd.data/load.c

    r34088 r37807  
    2323  if (!GetImageData (&data, &kapa, name)) return (FALSE);
    2424  FREE (name);
     25
     26  int channel = 0;
     27  if ((N = get_argument (argc, argv, "-ch"))) {
     28    channel = GetKapaChannelFromString (argv[N]);
     29    if (!channel) return FALSE;
     30    KiiSetChannel (kapa, channel - 1);
     31  }
    2532
    2633  ISCEL = FALSE;
  • trunk/Ohana/src/opihi/cmd.data/point.c

    r15620 r37807  
    2121  if (!GetImageData (&data, &kapa, name)) return (FALSE);
    2222  FREE (name);
     23
     24  int channel = 0;
     25  if ((N = get_argument (argc, argv, "-ch"))) {
     26    channel = GetKapaChannelFromString (argv[N]);
     27    if (!channel) return FALSE;
     28    KiiSetChannel (kapa, channel - 1);
     29  }
    2330
    2431  celestial = FALSE;
  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r37049 r37807  
    55
    66void read_vectors_cleanup ();
     7int read_table_sizes (Header *header);
    78
    89int datafile (int argc, char **argv) {
     
    331332
    332333  off_t Nbytes;
    333   int i, j, N, Nextend, Ny, Binary, vecType, padIfShort;
    334   char type[16], ID[80], *CCDKeyword;
     334  int i, j, N, Ny, Binary, vecType;
     335  char type[16], ID[80];
    335336  FTable table;
    336337  Header header;
    337338  Vector **vec;
    338   int FITS_TRANSPOSE;
    339339
    340340  table.buffer = NULL;
    341341  header.buffer = NULL;
    342342
    343   FITS_TRANSPOSE = FALSE;
     343  int FITS_TRANSPOSE = FALSE;
    344344  if ((N = get_argument (argc, argv, "-transpose"))) {
    345345    remove_argument (N, &argc, argv);
     
    347347  }
    348348
    349   CCDKeyword = NULL;
     349  char *CCDKeyword = NULL;
    350350  if ((N = get_argument (argc, argv, "-keyword"))) {
    351351    remove_argument (N, &argc, argv);
     
    354354  }
    355355
    356   padIfShort = FALSE;
     356  int padIfShort = FALSE;
    357357  if ((N = get_argument (argc, argv, "-pad-if-short"))) {
    358358    remove_argument (N, &argc, argv);
     
    360360  }
    361361
    362   Nextend = -1;
     362  int getSizes = FALSE;
     363  if ((N = get_argument (argc, argv, "-sizes"))) {
     364    remove_argument (N, &argc, argv);
     365    getSizes = TRUE;
     366  }
     367
     368  int Nextend = -1;
    363369  if ((N = get_argument (argc, argv, "-extnum"))) {
    364370    remove_argument (N, &argc, argv);
    365371    Nextend = atoi (extname);
     372  }
     373
     374  int start = 0;
     375  int Nrows = -1; // -1 : read entire table
     376  if ((N = get_argument (argc, argv, "-range"))) {
     377    remove_argument (N, &argc, argv);
     378    start = atoi (argv[N]);
     379    remove_argument (N, &argc, argv);
     380    Nrows = atoi (argv[N]);
     381    remove_argument (N, &argc, argv);
     382  }
     383
     384  // if CharAsVectors, char fields will be saved as vectors NAME:0 -- NAME:n for n characters
     385  // else char fields will be saved as $NAME:0 - $NAME:m for m rows
     386  // if (Ny > 10000), force CharAsVectors
     387  int CharAsVectors = FALSE;
     388  if ((N = get_argument (argc, argv, "-char-vectors"))) {
     389    remove_argument (N, &argc, argv);
     390    CharAsVectors = TRUE;
    366391  }
    367392
     
    397422    }
    398423    if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend);
    399     if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend);
    400 
     424
     425    if (getSizes) {
     426      read_table_sizes (&header);
     427      if (CCDKeyword != NULL) free (CCDKeyword);
     428      gfits_free_header (&header);
     429      return TRUE;
     430    }
     431
     432    if (Nrows == -1) {
     433      Nrows = header.Naxis[1] - start;
     434    }
     435    if (start < 0) ESCAPE ("invalid range: start < 0\n");
     436    if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);
     437    if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");
     438    if (start + Nrows > header.Naxis[1]) ESCAPE ("invalid range: start + Nrows > Ny (%d)\n", header.Naxis[1]);
     439
     440    // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100
     441    // Ny = 100, start = 10, Nrows = 90
     442
     443    if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);
    401444  } else {
    402445    if (CCDKeyword == NULL) {
     
    428471        continue;
    429472      }
    430       if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n");
     473
     474      if (Nrows == -1) {
     475        Nrows = header.Naxis[1] - start;
     476      }
     477      if (start < 0) ESCAPE ("invalid range: start < 0\n");
     478      if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);
     479      if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");
     480      if (start + Nrows > header.Naxis[1]) ESCAPE ("invalid range: start + Nrows > Ny (%d)\n", header.Naxis[1]);
     481
     482      if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);
     483
     484      // if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension\n");
     485
    431486      break;
    432487    }
     
    465520    if (!FITS_TRANSPOSE) {
    466521      // read string column into a list rather than a vector
    467       if (!strcmp (type, "char")) {
     522      if (!strcmp (type, "char") && !CharAsVectors && (Ny < 3000)) {
    468523        char *fieldName = argv[i];
    469524        char *Ptr = data;
     
    537592  if (vec) free (vec);
    538593}
     594
     595// read -fits foo -sizes -- Nx, Ny, Nfields -> $table:Nx, $table:Ny, $table:$Nfields
     596// read -fits foo -fields
     597
     598int read_table_sizes (Header *header) {
     599 
     600  int Nfields;
     601
     602  gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
     603
     604  set_int_variable ("table:Nx", header->Naxis[0]);
     605  set_int_variable ("table:Nx", header->Naxis[0]);
     606  set_int_variable ("table:Nfields", Nfields);
     607
     608  return TRUE;
     609}
     610
  • trunk/Ohana/src/opihi/cmd.data/relocate.c

    r27435 r37807  
    1717  FREE (name);
    1818
     19  int channel = 0;
     20  if ((N = get_argument (argc, argv, "-ch"))) {
     21    channel = GetKapaChannelFromString (argv[N]);
     22    if (!channel) return FALSE;
     23    KiiSetChannel (kapa, channel - 1);
     24  }
     25
    1926  if (argc != 3) {
    2027    gprint (GP_ERR, "USAGE: relocate x y [-n]\n");
  • trunk/Ohana/src/opihi/cmd.data/resize.c

    r29938 r37807  
    1717  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1818  FREE (name);
     19
     20  int channel = 0;
     21  if ((N = get_argument (argc, argv, "-ch"))) {
     22    channel = GetKapaChannelFromString (argv[N]);
     23    if (!channel) return FALSE;
     24    KiiSetChannel (kapa, channel - 1);
     25  }
    1926
    2027  if ((N = get_argument (argc, argv, "-by-image"))) {
  • trunk/Ohana/src/opihi/cmd.data/save.c

    r13479 r37807  
    1616  FREE (name);
    1717
     18  int channel = 0;
     19  if ((N = get_argument (argc, argv, "-ch"))) {
     20    channel = GetKapaChannelFromString (argv[N]);
     21    if (!channel) return FALSE;
     22    KiiSetChannel (kapa, channel - 1);
     23  }
     24
    1825  celestial = FALSE;
    1926  if ((N = get_argument (argc, argv, "-c"))) {
  • trunk/Ohana/src/opihi/cmd.data/tv.c

    r35757 r37807  
    1818  if (!GetImage (&data, &kapa, name)) return (FALSE);
    1919  FREE (name);
     20
     21  int channel = 0;
     22  if ((N = get_argument (argc, argv, "-ch"))) {
     23    remove_argument (N, &argc, argv);
     24    channel = GetKapaChannelFromString (argv[N]);
     25    remove_argument (N, &argc, argv);
     26    if (!channel) return FALSE;
     27    KiiSetChannel (kapa, channel - 1);
     28  }
    2029
    2130  /* shell exits on pipe close, FIX */
  • trunk/Ohana/src/opihi/cmd.data/tvchannel.c

    r16038 r37807  
    2222  }
    2323
    24   Nchannel = atoi (argv[1]);
     24  Nchannel = GetKapaChannelFromString (argv[1]);
     25  if (!Nchannel) return FALSE;
     26
     27  KiiSetChannel (kapa, Nchannel - 1);
     28  return (TRUE);
     29}
     30
     31int GetKapaChannelFromString (char *string) {
     32
     33  int Nchannel = atoi (string);
    2534  if (Nchannel == 0) {
    2635    // try the string values R/Red, G/Green, B/Blue
    27     if (!strcasecmp (argv[1], "R") || !strcasecmp (argv[1], "RED")) {
     36    if (!strcasecmp (string, "R") || !strcasecmp (string, "RED")) {
    2837      Nchannel = 1;
    2938    }
    30     if (!strcasecmp (argv[1], "G") || !strcasecmp (argv[1], "GREEN")) {
     39    if (!strcasecmp (string, "G") || !strcasecmp (string, "GREEN")) {
    3140      Nchannel = 2;
    3241    }
    33     if (!strcasecmp (argv[1], "B") || !strcasecmp (argv[1], "BLUE")) {
     42    if (!strcasecmp (string, "B") || !strcasecmp (string, "BLUE")) {
    3443      Nchannel = 3;
    3544    }
    3645  }
    37   if ((Nchannel < 1) || (Nchannel > 3)) {
    38     gprint (GP_ERR, "invalid channel : use 1 - 3 or (R)ed, (G)reen, (B)lue\n");
    39     return (FALSE);
     46  if ((Nchannel < 1) || (Nchannel > 10)) {
     47    gprint (GP_ERR, "invalid channel : use 1 - 10 or (R)ed, (G)reen, (B)lue\n");
     48    gprint (GP_ERR, "   (R)ed, (G)reen, (B)lue == (1,2,3)\n");
     49    return (0);
    4050  }
    41    
    42   KiiSetChannel (kapa, Nchannel - 1);
    43   return (TRUE);
     51  return Nchannel;
    4452}
  • trunk/Ohana/src/opihi/cmd.data/tvcontour.c

    r13479 r37807  
    7171  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    7272  FREE (name);
     73
     74  int channel = 0;
     75  if ((N = get_argument (argc, argv, "-ch"))) {
     76    channel = GetKapaChannelFromString (argv[N]);
     77    if (!channel) return FALSE;
     78    KiiSetChannel (kapa, channel - 1);
     79  }
    7380
    7481  if ((argc != 4) && (argc != 5)) {
  • trunk/Ohana/src/opihi/cmd.data/tvgrid.c

    r13479 r37807  
    2424  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    2525  FREE (name);
     26
     27  int channel = 0;
     28  if ((N = get_argument (argc, argv, "-ch"))) {
     29    channel = GetKapaChannelFromString (argv[N]);
     30    if (!channel) return FALSE;
     31    KiiSetChannel (kapa, channel - 1);
     32  }
    2633
    2734  if (argc != 3) {
  • trunk/Ohana/src/opihi/cmd.data/vload.c

    r20936 r37807  
    1818  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1919  FREE (name);
     20
     21  int channel = 0;
     22  if ((N = get_argument (argc, argv, "-ch"))) {
     23    channel = GetKapaChannelFromString (argv[N]);
     24    if (!channel) return FALSE;
     25    KiiSetChannel (kapa, channel - 1);
     26  }
    2027
    2128  type = KII_OVERLAY_BOX;
  • trunk/Ohana/src/opihi/cmd.data/vzload.c

    r20936 r37807  
    1818  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    1919  FREE (name);
     20
     21  int channel = 0;
     22  if ((N = get_argument (argc, argv, "-ch"))) {
     23    channel = GetKapaChannelFromString (argv[N]);
     24    if (!channel) return FALSE;
     25    KiiSetChannel (kapa, channel - 1);
     26  }
    2027
    2128  MAX_OUTPUT_SIZE = 10.0;
  • trunk/Ohana/src/opihi/dvo/Makefile

    r37049 r37807  
    4646$(SRC)/badimages.$(ARCH).o              \
    4747$(SRC)/catdir.$(ARCH).o                 \
     48$(SRC)/catname.$(ARCH).o                \
    4849$(SRC)/cmatch.$(ARCH).o         \
    4950$(SRC)/cmpload.$(ARCH).o                \
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r37049 r37807  
    55  off_t i, j, n, m;
    66  int N, Npts, NPTS, last, next, state, Nfields, Nreturn, Ncstack, Nstack;
    7   int Nsecfilt, VERBOSE, needMeasures;
     7  int Nsecfilt, VERBOSE;
    88  char **cstack, name[1024];
    99  void *Signal;
     
    137137  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    138138  if (PARALLEL && !HOST_ID) {
    139       int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
     139    int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
    140140
    141141    dbFreeFields (fields, Nfields);
     
    163163  }
    164164
    165   // check the requested fields : are all average/secfilt entries, or do we need measures?
    166   needMeasures = FALSE;
    167   for (i = 0; !needMeasures && (i < Nfields); i++) {
    168     if (fields[i].photcode == NULL) continue; // non-measure fields do not have a photcode
    169     if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE;
    170     if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE;
    171   }
     165  // check the requested fields
     166  int needMeasure = dbFieldNeedMeasure (fields, Nfields);
     167  int needLensobj = dbFieldNeedLensobj (fields, Nfields);
     168  int needStarpar = dbFieldNeedStarpar (fields, Nfields, TRUE);
    172169
    173170  // grab data from all selected sky regions
     
    189186    catalog.filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i];
    190187    catalog.catflags = LOAD_AVES | LOAD_SECF;
    191     catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS;
     188    catalog.catflags |= needMeasure ? LOAD_MEAS : SKIP_MEAS;
     189    catalog.catflags |= needLensobj ? LOAD_LENSOBJ : SKIP_LENSOBJ;
     190    catalog.catflags |= needStarpar ? LOAD_STARPAR : SKIP_STARPAR;
    192191    catalog.Nsecfilt = 0;
    193192
     
    205204      // XXX for measure values, this could be optimized for one loop over measures...
    206205
    207       m = catalog.average[j].measureOffset;
    208 
    209206      dbExtractAveragesInitAve ();  // reset counters for saved fields (costs very little)
    210207
     208      Average *average = &catalog.average[j];
     209
     210      m = average->measureOffset;
     211      Measure *measure = needMeasure ? &catalog.measure[m] : NULL;
     212
     213      m = average->lensobjOffset;
     214      Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL;
     215
     216      m = average->starparOffset;
     217      StarPar *starpar = needStarpar ? &catalog.starpar[m] : NULL;
     218
     219      m = j*Nsecfilt;
     220      SecFilt *secfilt = &catalog.secfilt[m];
     221
    211222      for (n = 0; n < Nfields; n++) {
    212         values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
     223        values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, &fields[n]);
    213224      }
    214225
  • trunk/Ohana/src/opihi/dvo/avmatch.c

    r37049 r37807  
    149149  }
    150150
    151   // check the requested fields : are all average/secfilt entries, or do we need measures?
    152   int needMeasures = FALSE;
    153   for (i = 0; !needMeasures && (i < Nfields); i++) {
    154     if (fields[i].photcode == NULL) continue; // assert this?
    155     if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE;
    156     if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE;
    157   }
     151  // check the requested fields
     152  int needMeasure = dbFieldNeedMeasure (fields, Nfields);
     153  int needLensobj = dbFieldNeedLensobj (fields, Nfields);
     154  int needStarpar = dbFieldNeedStarpar (fields, Nfields, TRUE);
    158155
    159156  /* create output storage vectors */
     
    194191    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
    195192    catalog.catflags = LOAD_AVES | LOAD_SECF;
    196     catalog.catflags |= needMeasures ? LOAD_MEAS : SKIP_MEAS;
     193    catalog.catflags |= needMeasure ? LOAD_MEAS    : SKIP_MEAS;
     194    catalog.catflags |= needLensobj ? LOAD_LENSOBJ : SKIP_LENSOBJ;
     195    catalog.catflags |= needStarpar ? LOAD_STARPAR : SKIP_STARPAR;
    197196    catalog.Nsecfilt = 0;
    198197
     
    219218      if (Ncat == -2) continue; // no matches to this point
    220219
    221       m = catalog.average[Ncat].measureOffset;
     220      m = Ncat;
     221      Average *average = &catalog.average[m];
     222
     223      m = average->measureOffset;
     224      Measure *measure = needMeasure ? &catalog.measure[m] : NULL;
     225
     226      m = average->lensobjOffset;
     227      Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL;
     228
     229      m = average->starparOffset;
     230      StarPar *starpar = needStarpar ? &catalog.starpar[m] : NULL;
     231
     232      m = Ncat*Nsecfilt;
     233      SecFilt *secfilt = &catalog.secfilt[m];
    222234
    223235      // reset counters for saved fields, extract fields
    224236      dbExtractAveragesInitAve ();
    225237      for (n = 0; n < Nfields; n++) {
    226         values[n] = dbExtractAverages (&catalog.average[Ncat], &catalog.secfilt[Ncat*Nsecfilt], &catalog.measure[m], &fields[n]);
     238        values[n] = dbExtractAverages (average, secfilt, measure, lensobj, starpar, &fields[n]);
    227239      }
    228240
  • trunk/Ohana/src/opihi/dvo/cmpload.c

    r34088 r37807  
    2424  if (!GetImage (NULL, &kapa, name)) return (FALSE);
    2525  FREE (name);
     26
     27  int channel = 0;
     28  if ((N = get_argument (argc, argv, "-ch"))) {
     29    channel = GetKapaChannelFromString (argv[N]);
     30    if (!channel) return FALSE;
     31    KiiSetChannel (kapa, channel - 1);
     32  }
    2633
    2734  Objtype = 0;
  • trunk/Ohana/src/opihi/dvo/dvo_host_utils.c

    r35416 r37807  
    137137
    138138  // determine the sky region
     139  // XXX EAM 20141230 : this needs to respect the -region selection
    139140  double Rmin, Rmax, Dmin, Dmax;
    140141  get_skyregion (&Rmin, &Rmax, &Dmin, &Dmax);
  • trunk/Ohana/src/opihi/dvo/find_matches.c

    r36489 r37807  
    3838   * far from the projection pole. We use the center of the region (catalog) for crval1,2.
    3939   */
     40  InitCoords (&tcoords, "DEC--ARC");
    4041  tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax);
    4142  if (region[0].Dmax < 90) {
     
    4445    tcoords.crval2 = 90.0;
    4546  }
    46   tcoords.crpix1 = 0;
    47   tcoords.crpix2 = 0;
    4847  tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
    49   tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
    50   tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
    51   tcoords.Npolyterms = 1;
    52   strcpy (tcoords.ctype, "DEC--ARC");
    5348
    5449  // this region includes a boundary layer of size RADIUS
  • trunk/Ohana/src/opihi/dvo/gimages.c

    r36489 r37807  
    8585  if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE);
    8686  image_subset (image, Nimage, &subset, &Nsubset, selection, tzero, trange, TimeSelect);
    87   BuildChipMatch (image, Nimage);
     87  // BuildChipMatch (image, Nimage);
    8888
    8989  int DistortImage = wordhash ("-DIS");
     
    102102      }
    103103    }     
    104     if (!FindMosaicForImage (image, Nimage, i)) continue;
    105104
    106105    typehash = wordhash (&image[i].coords.ctype[4]);
     
    129128      if (fabs(Ro - Ra) > 120.0) continue;
    130129
     130      InitCoords (&local, "DEC--TAN");
    131131      local.crval1 = Ro;
    132132      local.crval2 = Do;
    133       local.crpix1 = local.crpix2 = 0.0;
    134133      local.cdelt1 = local.cdelt2 = 1.0/3600.0;
    135       local.pc1_1 = local.pc2_2 = 1.0;
    136       local.pc2_1 = local.pc1_2 = 0.0;
    137       local.Npolyterms = 1;
    138       strcpy (local.ctype, "DEC--TAN");
    139134
    140135      if (typehash == DistortImage) {
  • trunk/Ohana/src/opihi/dvo/images.c

    r34584 r37807  
    131131  /* it is not an error for the database not to have any images */
    132132  if ((image = LoadImagesDVO (&Nimage)) == NULL) return (TRUE);
    133   BuildChipMatch (image, Nimage);
     133  // BuildChipMatch (image, Nimage);
    134134
    135135  if (SOLO_MOSAIC && photcode) {
     
    152152  SetVector (&Yvec, OPIHI_FLT, NPTS);
    153153
     154  Image *mosaic = NULL;
     155
    154156  ALLOCATE (plist, int, NPTS);
    155157  n = N = 0;
     
    157159    if (ByName && strncmp (image[i].name, name, strlen(name))) continue;
    158160    if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue;
    159     if (!(Nmosaic = FindMosaicForImage (image, Nimage, i))) continue;
    160     Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
     161
     162    mosaic = image[i].parent;
     163    Nmosaic = (SOLO_MOSAIC && mosaic) ? mosaic - image : -1;
     164
    161165    if (photcode) {
    162166      if ( photcodeEquiv && (photcode[0].code != GetPhotcodeEquivCodebyCode(image[i].photcode))) continue;
     
    170174    typehash = wordhash (&image[i].coords.ctype[4]);
    171175
    172     if (photcode && SOLO_MOSAIC) {
     176    if (photcode && SOLO_MOSAIC && (Nmosaic >= 0)) {
    173177      // mosaic (DIS) images are not currently given a photcode : plot these via the WRP entries
    174178      /* DIS images represent a field, not a chip */
    175179      if (typehash != ChipImage) continue;
    176180      if (foundMosaic[Nmosaic]) continue;
    177       x[0] = -0.5*image[Nmosaic].NX; y[0] = -0.5*image[Nmosaic].NY;
    178       x[1] = +0.5*image[Nmosaic].NX; y[1] = -0.5*image[Nmosaic].NY;
    179       x[2] = +0.5*image[Nmosaic].NX; y[2] = +0.5*image[Nmosaic].NY;
    180       x[3] = -0.5*image[Nmosaic].NX; y[3] = +0.5*image[Nmosaic].NY;
     181      x[0] = -0.5*mosaic->NX; y[0] = -0.5*mosaic->NY;
     182      x[1] = +0.5*mosaic->NX; y[1] = -0.5*mosaic->NY;
     183      x[2] = +0.5*mosaic->NX; y[2] = +0.5*mosaic->NY;
     184      x[3] = -0.5*mosaic->NX; y[3] = +0.5*mosaic->NY;
    181185      for (j = 0; j < Npts; j++) {
    182         status = XY_to_RD (&r[j], &d[j], x[j], y[j], &image[Nmosaic].coords);
     186        status = XY_to_RD (&r[j], &d[j], x[j], y[j], &mosaic->coords);
    183187        if (!status) break;
    184188        r[j] = ohana_normalize_angle (r[j]);
     
    198202
    199203    /* DIS images represent a field, not a chip */
    200     if ((typehash == DistortImage) && !WITH_MOSAIC) continue;
    201     if ((typehash != DistortImage) &&  SOLO_MOSAIC) continue;
     204    if ((typehash == DistortImage) && !WITH_MOSAIC) continue; // do not plot the mosaic images
     205    if ((typehash != DistortImage) &&  SOLO_MOSAIC) continue; // plot only the mosaic images
     206
    202207    if (typehash == DistortImage) {
    203208      x[0] = -0.5*image[i].NX; y[0] = -0.5*image[i].NY;
  • trunk/Ohana/src/opihi/dvo/imbox.c

    r34584 r37807  
    4343  SetVector (&Yvec, OPIHI_FLT, NPTS);
    4444
     45  mosaic.ctype[0] = 0; 
     46
    4547  while (gfits_fread_header (f, &header)) {
    4648    if (!GetCoords (&coords, &header)) goto skip;
    4749    if (!SOLO_PHU && !strcmp (&coords.ctype[4], "-DIS")) {
    4850      mosaic = coords;
    49       RegisterMosaic (&mosaic);
    5051      goto skip;
     52    }
     53    if (!strcmp (&coords.ctype[4], "-WRP")) {
     54      if (!mosaic.ctype[0]) {
     55        fprintf (stderr, "PHU mosaic not found\n");
     56        return FALSE;
     57      }
     58      coords.mosaic = &mosaic;
    5159    }
    5260
  • trunk/Ohana/src/opihi/dvo/imdata.c

    r37049 r37807  
    8787  if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE);
    8888  image_subset (image, Nimage, &subset, &Nsubset, selection, tzero, trange, TimeSelect);
    89   BuildChipMatch (image, Nimage);
     89  // BuildChipMatch (image, Nimage);
    9090  GetTimeFormat (&TimeReference, &TimeFormat);
    9191
     
    103103    I = subset[i];
    104104
    105     if (!FindMosaicForImage (image, Nimage, I)) continue;
    106105    skyset = SkyListByImage (sky, -1, &image[I]);
    107106
  • trunk/Ohana/src/opihi/dvo/imdense.c

    r34584 r37807  
    2222
    2323  if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE);
    24   BuildChipMatch (image, Nimage);
     24  // BuildChipMatch (image, Nimage);
    2525
    2626  Rmin = graphmode.coords.crval1 - 182.0;
     
    4242    /* project this image to screen display coords */
    4343    status = FALSE;
    44     if (!FindMosaicForImage (image, Nimage, i)) continue;
    4544    XY_to_RD (&r, &d, x, y, &image[i].coords);
    4645    r = ohana_normalize_angle (r);
  • trunk/Ohana/src/opihi/dvo/imextract.c

    r37049 r37807  
    9090
    9191  if ((image = LoadImagesDVO (&Nimage)) == NULL) goto escape;
    92   BuildChipMatch (image, Nimage);
     92  // BuildChipMatch (image, Nimage);
    9393  dbExtractImagesInit ();
    9494
  • trunk/Ohana/src/opihi/dvo/imlist.c

    r34088 r37807  
    3838  }
    3939
    40   // int RegionSelect = FALSE;
    41   // if ((N = get_argument (argc, argv, "-region"))) {
    42   //   remove_argument (N, &argc, argv);
    43   //   RegionSelect = TRUE;
    44   // }
    45 
    4640  PhotcodeValue = NULL;
    4741  PhotcodeSelect = FALSE;
     
    7670  }
    7771
     72  int MAX_LIST = -1;
     73  if ((N = get_argument (argc, argv, "-max-list"))) {
     74    remove_argument (N, &argc, argv);
     75    MAX_LIST = atoi (argv[N]);
     76    remove_argument (N, &argc, argv);
     77  }
     78
    7879  if (argc != 1) {
    79     gprint (GP_ERR, "USAGE: image [-time start range] [-region] [-name string]\n");
     80    gprint (GP_ERR, "USAGE: image [-time start range] [-region] [-name string] [-photcode code] [-Nphotcode N] [-max-list N]\n");
    8081    return (FALSE);
    8182  }
     
    8384  if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE);
    8485  image_subset (image, Nimage, &subset, &Nsubset, selection, tzero, trange, TimeSelect);
    85   BuildChipMatch (image, Nimage);
     86  MAX_LIST = MAX_LIST < 0 ? Nsubset : MIN(MAX_LIST, Nsubset);
    8687
    8788  GetTimeFormat (&TimeReference, &TimeFormat);
    8889
    89   for (j = 0; j < Nsubset; j++) {
     90  for (j = 0; j < MAX_LIST; j++) {
    9091    i = subset[j];
    9192    if (NameSelect && (strstr (image[i].name, name) == (char *) NULL)) continue;
     
    9798      }
    9899    }
    99     if (!FindMosaicForImage (image, Nimage, i)) continue;
    100100    t = TimeValue (image[i].tzero, TimeReference, TimeFormat);
    101101    if (!strcmp(&image[i].coords.ctype[4], "-DIS")) {
  • trunk/Ohana/src/opihi/dvo/imstats.c

    r34584 r37807  
    3131
    3232  if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE);
    33   BuildChipMatch (image, Nimage);
     33  // BuildChipMatch (image, Nimage);
    3434
    3535  /* assign vector values */
     
    4444    else
    4545      Yvec.elements.Flt[i] = image[i].dMcal;
    46     if (!FindMosaicForImage (image, Nimage, i)) continue;
    4746    XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
    4847    gprint (GP_ERR, "%d %8.4f %8.4f %10d %6d  %5.3f %6.3f %6.3f\n",
  • trunk/Ohana/src/opihi/dvo/init.c

    r37049 r37807  
    77int calmextract     PROTO((int, char **));
    88int catlog          PROTO((int, char **));
     9int catname         PROTO((int, char **));
    910int catdir_define   PROTO((int, char **));
    1011int ccd             PROTO((int, char **));
     
    6869//  {1, "calextract",  calextract,   "extract photometry calibration"},
    6970//  {1, "calmextract", calmextract,  "extract photometry calibration"},
     71  {1, "catname",     catname,      "list catalog files by name"},
    7072  {1, "catdir",      catdir_define,"re-define CATDIR"},
    7173//  {1, "ccd",         ccd,          "plot color-color diagram"},
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r35416 r37807  
    211211  }
    212212
     213  // int needLensing = dbFieldNeedLensing (fields, Nfields);
     214  int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE);
     215
    213216  // grab data from all selected sky regions
    214217  Signal = signal (SIGINT, handle_interrupt);
     
    227230    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
    228231    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     232    // catalog.catflags |= needLensing ? LOAD_LENSING : SKIP_LENSING;
     233    catalog.catflags |= needStarpar ? LOAD_STARPAR : SKIP_STARPAR;
    229234    catalog.Nsecfilt = Nsecfilt;
    230235
     
    259264        // extract the relevant values for this measurement
    260265        dbExtractMeasuresInitMeas (); // reset counters for saved fields  (costs very little
     266
     267        Average *average = &catalog.average[j];
     268
     269        int Nstarpar = average->starparOffset;
     270        StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL;
     271
     272        // int Nlensing = average->lensobjOffset;
     273        // Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL;
     274
     275        int Nsec = j*Nsecfilt;
     276        SecFilt *secfilt = &catalog.secfilt[Nsec];
     277
    261278        for (n = 0; n < Nfields; n++) {
    262           values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
     279          values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], NULL, starpar, &fields[n]);
    263280        }
    264281        // fprintf (stderr, "object: ave: %f, cat: %f, averef %d\n", fields[n].name, values[2], values[3], catalog.measure[m].averef);
  • trunk/Ohana/src/opihi/dvo/mmatch.c

    r35416 r37807  
    233233  ALLOCATE (index, off_t, Nelem);
    234234
     235  // int needLensing = dbFieldNeedLensing (fields, Nfields);
     236  int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE);
     237
    235238  // grab data from all selected sky regions
    236239  Signal = signal (SIGINT, handle_interrupt);
     
    246249    catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
    247250    catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS;
     251    catalog.catflags |= needStarpar ? LOAD_STARPAR : SKIP_STARPAR;
    248252    catalog.Nsecfilt = Nsecfilt;
    249253
     
    282286        // extract the relevant values for this measurement
    283287        dbExtractMeasuresInitMeas (); // reset counters for saved fields  (costs very little
     288
     289        Average *average = &catalog.average[Ncat];
     290
     291        int Nstarpar = average->starparOffset;
     292        StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL;
     293
     294        // int Nlensing = average->lensobjOffset;
     295        // Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL;
     296
     297        int Nsec = Ncat*Nsecfilt;
     298        SecFilt *secfilt = &catalog.secfilt[Nsec];
     299
    284300        for (n = 0; n < Nfields; n++) {
    285           values[n] = dbExtractMeasures (&catalog.average[Ncat], &catalog.secfilt[Ncat*Nsecfilt], &catalog.measure[m], &fields[n]);
     301          values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], NULL, starpar, &fields[n]);
    286302        }
    287303
  • trunk/Ohana/src/opihi/dvo/mmextract.c

    r35263 r37807  
    174174  }
    175175
     176  // int needLensing = dbFieldNeedLensing (fields, Nfields);
     177  int needStarpar = dbFieldNeedStarpar (fields, Nfields, FALSE);
     178
    176179  // grab data from all selected sky regions
    177180  Signal = signal (SIGINT, handle_interrupt);
     
    213216        // extract the relevant values for this measurement
    214217        dbExtractMeasuresInitMeas (); // reset counters for saved fields
     218
     219        Average *average = &catalog.average[j];
     220
     221        int Nstarpar = average->starparOffset;
     222        StarPar *starpar = needStarpar ? &catalog.starpar[Nstarpar] : NULL;
     223
     224        // int Nlensing = average->lensobjOffset;
     225        // Lensobj *lensobj = needLensobj ? &catalog.lensobj[m] : NULL;
     226
     227        int Nsec = j*Nsecfilt;
     228        SecFilt *secfilt = &catalog.secfilt[Nsec];
     229
    215230        for (n = 0; n < Nfields; n++) {
    216231          // values needs to be a pointer to a type with FLT and INT (with a union, we would save a bit of memory...)
    217           values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
     232          values[n] = dbExtractMeasures (average, secfilt, &catalog.measure[m], NULL, starpar, &fields[n]);
    218233        }
    219234        // fprintf (stderr, "object: ave: %f, cat: %f, averef %d\n", fields[n].name, values[2], values[3], catalog.measure[m].averef);
  • trunk/Ohana/src/opihi/dvo/objectcoverage.c

    r34088 r37807  
    147147  strcpy (buf[0].file, "(empty)");
    148148
     149  InitCoords (&coords, projection);
    149150  coords.crval1 = RaCenter;
    150151  coords.crval2 = DecCenter;
    151152  coords.crpix1 = 0.5*Nx;
    152153  coords.crpix2 = 0.5*Ny;
    153   strcpy (coords.ctype, projection);
    154   coords.pc1_1 = -1.0;
     154  coords.pc1_1 = -1.0; // sky parity
    155155  coords.pc2_2 = +1.0;
    156   coords.pc1_2 =  0.0;
    157   coords.pc2_1 =  0.0;
    158156  coords.cdelt1 = coords.cdelt2 = pixscale;
    159   coords.Npolyterms = 0;
    160157
    161158  PutCoords (&coords, &buf[0].header);
     
    166163    for (xs = 0; xs < Nx; xs++) {
    167164      status = XY_to_RD (&r, &d, (double)(xs), (double)(ys), &coords);
    168       status &= (r >= 0);
    169       status &= (r <= 360);
     165      r = ohana_normalize_angle (r);
    170166      if (status) {
    171167        V[ys*Nx + xs] = ShowDensity ?  0 : 2;
  • trunk/Ohana/src/opihi/dvo/showtile.c

    r36489 r37807  
    2828
    2929  /* reference for coords is this image */
    30   coords.crpix1 = coords.crpix2 = 0.0;
    31   coords.crval1 = coords.crval2 = 0.0;
    32   coords.cdelt1 = coords.cdelt2 = 1.0;
    33   coords.pc1_1  = coords.pc2_2  = 1.0;
    34   coords.pc1_2  = coords.pc2_1  = 0.0;
    35   coords.Npolyterms = 0;
    36   strcpy (coords.ctype, "DEC--TAN");
     30  InitCoords (&coords, "DEC--TAN");
    3731 
    3832  /* fill in top-left region */
  • trunk/Ohana/src/opihi/dvo/simage.c

    r36489 r37807  
    4242  }
    4343  /* get astrometry information */
    44   strcpy (coords.ctype, "NONE");
    45   gfits_scan (&header, "CTYPE2",   "%s",  1, coords.ctype);
    46   if (strcmp (coords.ctype, "DEC--PLY")) {
    47     gprint (GP_ERR, "ERROR: wrong astrometric info in header\n");
     44  if (!GetCoords (&coords, &header)) {
     45    gprint (GP_ERR, "ERROR: can't get coord info from header\n");
    4846    return (FALSE);
    4947  }
    50   gfits_scan (&header, "CDELT1",   "%f", 1, &coords.cdelt1);
    51   gfits_scan (&header, "CDELT2",   "%f", 1, &coords.cdelt2);
    52   gfits_scan (&header, "CRVAL1",   "%lf", 1, &coords.crval1);
    53   gfits_scan (&header, "CRVAL2",   "%lf", 1, &coords.crval2); 
    54   gfits_scan (&header, "CRPIX1",   "%f", 1, &coords.crpix1);
    55   gfits_scan (&header, "CRPIX2",   "%f", 1, &coords.crpix2);
    56   gfits_scan (&header, "PC001001", "%f", 1, &coords.pc1_1);
    57   gfits_scan (&header, "PC001002", "%f", 1, &coords.pc1_2);
    58   gfits_scan (&header, "PC002001", "%f", 1, &coords.pc2_1);
    59   gfits_scan (&header, "PC002002", "%f", 1, &coords.pc2_2);
    60   /* RA Terms */
    61   gfits_scan (&header, "PCA1X2Y0", "%f", 1, &coords.polyterms[0][0]);
    62   gfits_scan (&header, "PCA1X1Y1", "%f", 1, &coords.polyterms[1][0]);
    63   gfits_scan (&header, "PCA1X0Y2", "%f", 1, &coords.polyterms[2][0]);
    64   gfits_scan (&header, "PCA1X3Y0", "%f", 1, &coords.polyterms[3][0]);
    65   gfits_scan (&header, "PCA1X2Y1", "%f", 1, &coords.polyterms[4][0]);
    66   gfits_scan (&header, "PCA1X1Y2", "%f", 1, &coords.polyterms[5][0]);
    67   gfits_scan (&header, "PCA1X0Y3", "%f", 1, &coords.polyterms[6][0]);
    68   /* Dec Terms */                           
    69   gfits_scan (&header, "PCA2X2Y0", "%f", 1, &coords.polyterms[0][1]);
    70   gfits_scan (&header, "PCA2X1Y1", "%f", 1, &coords.polyterms[1][1]);
    71   gfits_scan (&header, "PCA2X0Y2", "%f", 1, &coords.polyterms[2][1]);
    72   gfits_scan (&header, "PCA2X3Y0", "%f", 1, &coords.polyterms[3][1]);
    73   gfits_scan (&header, "PCA2X2Y1", "%f", 1, &coords.polyterms[4][1]);
    74   gfits_scan (&header, "PCA2X1Y2", "%f", 1, &coords.polyterms[5][1]);
    75   gfits_scan (&header, "PCA2X0Y3", "%f", 1, &coords.polyterms[6][1]);
    76   coords.Npolyterms = 2; /* how many do we use? */
    7748
    7849  /* find number of stars */
  • trunk/Ohana/src/opihi/dvo/skycoverage.c

    r33963 r37807  
    204204  strcpy (buf[0].file, "(empty)");
    205205
     206  InitCoords (&coords, projection);
    206207  coords.crval1 = RaCenter;
    207208  coords.crval2 = DecCenter;
    208209  coords.crpix1 = 0.5*Nx;
    209210  coords.crpix2 = 0.5*Ny;
    210   strcpy (coords.ctype, projection);
    211   coords.pc1_1 = -1.0;
     211  coords.pc1_1 = -1.0; // sky parity
    212212  coords.pc2_2 = +1.0;
    213   coords.pc1_2 =  0.0;
    214   coords.pc2_1 =  0.0;
    215213  coords.cdelt1 = coords.cdelt2 = pixscale;
    216   coords.Npolyterms = 0;
    217214
    218215  PutCoords (&coords, &buf[0].header);
     
    222219      return (FALSE);
    223220  }
    224   BuildChipMatch (image, Nimage);
     221  // BuildChipMatch (image, Nimage);
    225222
    226223  V = (float *)buf[0].matrix.buffer;
     
    230227    for (xs = 0; xs < Nx; xs++) {
    231228      status = XY_to_RD (&r, &d, (double)(xs), (double)(ys), &coords);
    232       status &= (r >= 0);
    233       status &= (r <= 360);
     229      r = ohana_normalize_angle (r);
     230
    234231      // are we in a part of the projection covering the sky or not?
    235232      if (status) {
     
    284281      }
    285282    }
    286 
    287     if (!FindMosaicForImage (image, Nimage, i)) continue;
    288283
    289284    typehash = wordhash (&image[i].coords.ctype[4]);
  • trunk/Ohana/src/opihi/dvo/subpix.c

    r37049 r37807  
    115115  /* load all images, extract those touching Ra, Dec */
    116116  if ((image = LoadImagesDVO (&Nimage)) == NULL) return (FALSE);
    117   BuildChipMatch (image, Nimage);
     117  // BuildChipMatch (image, Nimage);
    118118
    119119  for (i = 0; i < Nimage; i++) {
    120     if (!FindMosaicForImage (image, Nimage, i)) continue;
    121120    status = RD_to_XY (&X, &Y, Ra, Dec, &image[i].coords);
    122121    if (!status || (X < 0) || (X > image[i].NX) || (Y < 0) || (Y > image[i].NY)) continue;
     
    134133  for (i = 0; i < Nsub; i++) {
    135134    I = index[i];
    136     if (!FindMosaicForImage (image, Nimage, I)) continue;
    137135    Timage = image[I].tzero;
    138136    for (j = 0; j < Nmeasure; j++) {
  • trunk/Ohana/src/opihi/include/astro.h

    r31635 r37807  
    1212void FreeAstro (void);
    1313
    14 typedef struct {
    15   int    isIdentity;          // identity transformation
    16   double phi;                 // saved in radians
    17   double Xo;                  // saved in radians
    18   double xo;                  // saved in degrees
    19   double sin_phi_cos_Xo;      // pre-computed values
    20   double sin_phi_sin_Xo;      // pre-computed values
    21   double cos_phi_cos_Xo;      // pre-computed values
    22   double cos_phi_sin_Xo;      // pre-computed values
    23   double cos_phi;             // pre-computed values
    24   double sin_phi;             // pre-computed values
    25   double cos_Xo;              // pre-computed values
    26   double sin_Xo;              // pre-computed values
    27 } CoordTransform;
    28 
    29 #ifndef MOVED_TO_LIBDVO
    30 typedef enum {COORD_NONE, COORD_CELESTIAL, COORD_GALACTIC, COORD_ECLIPTIC} CoordTransformSystem;
    31 #endif
    32 
    33 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output);
    34 int ApplyTransform (double *x, double *y, double X, double Y, CoordTransform *transform);
    35 
    3614# endif
  • trunk/Ohana/src/opihi/include/data.h

    r36679 r37807  
    224224void ListMedImages ();
    225225
     226// in tvchannel.c
     227int GetKapaChannelFromString (char *string);
     228
    226229# endif
  • trunk/Ohana/src/opihi/include/dvomath.h

    r37049 r37807  
    187187int           ListBuffersToList     PROTO((char *name));
    188188int           CreateBuffer          PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale));
     189int           ResetBuffer           PROTO((Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale));
    189190Buffer       *SelectBuffer          PROTO((char *name, int mode, int verbose));
    190191void          dump_buffers          PROTO((int n));  /* deprecated? */
  • trunk/Ohana/src/opihi/lib.shell/BufferOps.c

    r33662 r37807  
    8888}
    8989
     90int ResetBuffer (Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale) {
     91
     92  gfits_free_matrix (&buf[0].matrix);
     93  gfits_free_header (&buf[0].header);
     94  CreateBuffer (buf, Nx, Ny, bitpix, bzero, bscale);
     95  return TRUE;
     96}
     97
    9098int CreateBuffer (Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale) {
    9199
  • trunk/Ohana/src/opihi/pantasks/controller_status.c

    r23530 r37807  
    33int controller_status (int argc, char **argv) {
    44
    5   int status;
    6   char command[1024];
     5  int i, status;
     6  char command[1024], tmpline[1024];
    77  IOBuffer buffer;
    88
    9   if (argc != 1) {
    10     gprint (GP_ERR, "USAGE: controller status\n");
     9  if ((argc > 1) && (!strcasecmp(argv[1], "help")))  {
     10    gprint (GP_ERR, "USAGE: controller status [options]\n");
     11    gprint (GP_ERR, "  OPTIONS:\n");
     12    gprint (GP_ERR, "  -cmd command\n");
     13    gprint (GP_ERR, "  -host hostname\n");
     14    gprint (GP_ERR, "  -state state\n");
     15    gprint (GP_ERR, "  -age seconds\n");
     16    gprint (GP_ERR, "  +jobs [-nohost]\n");
     17    gprint (GP_ERR, "  +host [-nojobs]\n");
    1118    return (FALSE);
    1219  }
     
    1926  }
    2027
     28  snprintf (command, 1024, "status");
     29  for (i = 1; i < argc; i++) {
     30    snprintf (tmpline, 1024, "%s %s", command, argv[i]);
     31    strcpy (command, tmpline);
     32  }
    2133
    22   sprintf (command, "status");
    2334  InitIOBuffer (&buffer, 0x100);
    2435
  • trunk/Ohana/src/opihi/pcontrol/Makefile

    r34088 r37807  
    1111
    1212# programs may add their own internal requirements here
    13 LIBS1         = -lkapa -lFITS -lohana
     13LIBS1         = -ldvo -lkapa -lFITS -lohana
    1414LIBS2         = -lbasiccmd -lshell -ldata
    1515FULL_CFLAGS   = $(BASE_CFLAGS)
  • trunk/Ohana/src/opihi/pcontrol/status.c

    r36623 r37807  
    8585
    8686usage:
    87   gprint (GP_ERR, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n");
     87  gprint (GP_LOG, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n");
    8888  return FALSE;
    8989}
Note: See TracChangeset for help on using the changeset viewer.