IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 19, 2015, 11:27:34 AM (12 years ago)
Author:
eugene
Message:

various updates to handle 3D cubes better

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150112/Ohana/src/opihi/cmd.data/tv.c

    r37807 r37869  
    2828  }
    2929
     30  int plane = 0;
     31  if ((N = get_argument (argc, argv, "-plane"))) {
     32    remove_argument (N, &argc, argv);
     33    plane = atoi (argv[N]);
     34    remove_argument (N, &argc, argv);
     35  }
     36  if (plane < 0) {
     37    gprint (GP_ERR, " ERROR: -plane (plane) : cannot be negative\n");
     38    return (FALSE);
     39  }
     40
    3041  /* shell exits on pipe close, FIX */
    3142  if ((N = get_argument (argc, argv, "-kill"))) {
     
    5566  GetCoords (&coords, &buf[0].header);
    5667 
    57   image.data1d = (float *) buf[0].matrix.buffer;
    5868  image.Nx = buf[0].matrix.Naxis[0];
    5969  image.Ny = buf[0].matrix.Naxis[1];
     70
     71  int tooBig = buf[0].matrix.Naxis[2] ? (plane >= buf[0].matrix.Naxis[2]) : plane > 0;
     72  if (tooBig) {
     73    gprint (GP_ERR, " ERROR: -plane (plane) : out of bounds (%d vs %d)\n", plane, buf[0].matrix.Naxis[2]);
     74    return (FALSE);
     75  }
     76  int Npix2D = image.Nx * image.Ny;
     77
     78  float *imdata = (float *) buf[0].matrix.buffer;
     79  image.data1d = &imdata[plane*Npix2D];
    6080
    6181  // send only the root of the file, not the full path
Note: See TracChangeset for help on using the changeset viewer.