IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 10, 2013, 2:55:11 PM (13 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20130904

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana

  • trunk/Ohana/src/opihi

  • trunk/Ohana/src/opihi/cmd.data

  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r34753 r36375  
    2323// vector types
    2424enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR};
     25static int FITS_TRANSPOSE;
    2526
    2627int read_vectors (int argc, char **argv) {
     
    3435
    3536  char *buffer = NULL;
     37
     38  FITS_TRANSPOSE = FALSE;
     39  if ((Narg = get_argument (argc, argv, "-transpose"))) {
     40    remove_argument (Narg, &argc, argv);
     41    FITS_TRANSPOSE = TRUE;
     42  }
    3643
    3744  /* auto-sense table type */
     
    410417    }
    411418       
    412     // define the multifield vector names
    413     ALLOCATE (vec, Vector *, Nval);
    414     for (j = 0; j < Nval; j++) {
    415       if (Nval == 1)
    416         sprintf (name, "%s", argv[i]);
    417       else
    418         sprintf (name, "%s:%d", argv[i], j);
    419       if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
    420       ResetVector (vec[j], vecType, Ny);
    421     }
    422 
    423     if (!strcmp (type, "char")) {
    424       char *Ptr = data;
     419    if (!FITS_TRANSPOSE) {
     420      // define the multifield vector names (Nval vectors x Ny elements)
     421      ALLOCATE (vec, Vector *, Nval);
     422      for (j = 0; j < Nval; j++) {
     423        if (Nval == 1)
     424          sprintf (name, "%s", argv[i]);
     425        else
     426          sprintf (name, "%s:%d", argv[i], j);
     427        if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
     428        ResetVector (vec[j], vecType, Ny);
     429      }
     430
     431      if (!strcmp (type, "char")) {
     432        char *Ptr = data;
     433        for (j = 0; j < Ny; j++) {
     434          for (k = 0; k < Nval; k++, Ptr++) {
     435            vec[k][0].elements.Int[j] = *Ptr;
     436          }
     437        }
     438      }
     439      if (!strcmp (type, "short")) {
     440        short *Ptr = data;
     441        for (j = 0; j < Ny; j++) {
     442          for (k = 0; k < Nval; k++, Ptr++) {
     443            vec[k][0].elements.Int[j] = *Ptr;
     444          }
     445        }
     446      }
     447      if (!strcmp (type, "int")) {
     448        int *Ptr = data;
     449        for (j = 0; j < Ny; j++) {
     450          for (k = 0; k < Nval; k++, Ptr++) {
     451            vec[k][0].elements.Int[j] = *Ptr;
     452          }
     453        }
     454      }
     455      if (!strcmp (type, "int64_t")) {
     456        int64_t *Ptr = data;
     457        for (j = 0; j < Ny; j++) {
     458          for (k = 0; k < Nval; k++, Ptr++) {
     459            vec[k][0].elements.Int[j] = *Ptr;
     460          }
     461        }
     462      }
     463      if (!strcmp (type, "float")) {
     464        float *Ptr = data;
     465        for (j = 0; j < Ny; j++) {
     466          for (k = 0; k < Nval; k++, Ptr++) {
     467            vec[k][0].elements.Flt[j] = *Ptr;
     468          }
     469        }
     470      }
     471      if (!strcmp (type, "double")) {
     472        double *Ptr = data;
     473        for (j = 0; j < Ny; j++) {
     474          for (k = 0; k < Nval; k++, Ptr++) {
     475            vec[k][0].elements.Flt[j] = *Ptr;
     476          }
     477        }
     478      }
     479    } else {
     480      // define the multifield vector names (Ny vectors x Nval elements)
     481      ALLOCATE (vec, Vector *, Ny);
    425482      for (j = 0; j < Ny; j++) {
    426         for (k = 0; k < Nval; k++, Ptr++) {
    427           vec[k][0].elements.Int[j] = *Ptr;
    428         }
    429       }
    430     }
    431     if (!strcmp (type, "short")) {
    432       short *Ptr = data;
    433       for (j = 0; j < Ny; j++) {
    434         for (k = 0; k < Nval; k++, Ptr++) {
    435           vec[k][0].elements.Int[j] = *Ptr;
    436         }
    437       }
    438     }
    439     if (!strcmp (type, "int")) {
    440       int *Ptr = data;
    441       for (j = 0; j < Ny; j++) {
    442         for (k = 0; k < Nval; k++, Ptr++) {
    443           vec[k][0].elements.Int[j] = *Ptr;
    444         }
    445       }
    446     }
    447     if (!strcmp (type, "int64_t")) {
    448       int64_t *Ptr = data;
    449       for (j = 0; j < Ny; j++) {
    450         for (k = 0; k < Nval; k++, Ptr++) {
    451           vec[k][0].elements.Int[j] = *Ptr;
    452         }
    453       }
    454     }
    455     if (!strcmp (type, "float")) {
    456       float *Ptr = data;
    457       for (j = 0; j < Ny; j++) {
    458         for (k = 0; k < Nval; k++, Ptr++) {
    459           vec[k][0].elements.Flt[j] = *Ptr;
    460         }
    461       }
    462     }
    463     if (!strcmp (type, "double")) {
    464       double *Ptr = data;
    465       for (j = 0; j < Ny; j++) {
    466         for (k = 0; k < Nval; k++, Ptr++) {
    467           vec[k][0].elements.Flt[j] = *Ptr;
     483        if (Ny == 1)
     484          sprintf (name, "%s", argv[i]);
     485        else
     486          sprintf (name, "%s:%d", argv[i], j);
     487        if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name");
     488        ResetVector (vec[j], vecType, Nval);
     489      }
     490
     491      if (!strcmp (type, "char")) {
     492        char *Ptr = data;
     493        for (j = 0; j < Ny; j++) {
     494          for (k = 0; k < Nval; k++, Ptr++) {
     495            vec[j][0].elements.Int[k] = *Ptr;
     496          }
     497        }
     498      }
     499      if (!strcmp (type, "short")) {
     500        short *Ptr = data;
     501        for (j = 0; j < Ny; j++) {
     502          for (k = 0; k < Nval; k++, Ptr++) {
     503            vec[j][0].elements.Int[k] = *Ptr;
     504          }
     505        }
     506      }
     507      if (!strcmp (type, "int")) {
     508        int *Ptr = data;
     509        for (j = 0; j < Ny; j++) {
     510          for (k = 0; k < Nval; k++, Ptr++) {
     511            vec[j][0].elements.Int[k] = *Ptr;
     512          }
     513        }
     514      }
     515      if (!strcmp (type, "int64_t")) {
     516        int64_t *Ptr = data;
     517        for (j = 0; j < Ny; j++) {
     518          for (k = 0; k < Nval; k++, Ptr++) {
     519            vec[j][0].elements.Int[k] = *Ptr;
     520          }
     521        }
     522      }
     523      if (!strcmp (type, "float")) {
     524        float *Ptr = data;
     525        for (j = 0; j < Ny; j++) {
     526          for (k = 0; k < Nval; k++, Ptr++) {
     527            vec[j][0].elements.Flt[k] = *Ptr;
     528          }
     529        }
     530      }
     531      if (!strcmp (type, "double")) {
     532        double *Ptr = data;
     533        for (j = 0; j < Ny; j++) {
     534          for (k = 0; k < Nval; k++, Ptr++) {
     535            vec[j][0].elements.Flt[k] = *Ptr;
     536          }
    468537        }
    469538      }
Note: See TracChangeset for help on using the changeset viewer.