IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20873


Ignore:
Timestamp:
Dec 2, 2008, 6:24:28 PM (17 years ago)
Author:
eugene
Message:

fixes for interger-type vectors; finish imextract upgrade

Location:
branches/eam_branch_20081124/Ohana/src/opihi
Files:
2 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.astro/cgrid.c

    r20860 r20873  
    9595 
    9696  /* prepare vectors to hold data */
     97  N = 0;
    9798  NELEMENTS = 200;
    98   ALLOCATE (Xvec.elements.Flt, opihi_flt, NELEMENTS);
    99   ALLOCATE (Yvec.elements.Flt, opihi_flt, NELEMENTS);
    100   N = 0;
     99  SetVector (&Xvec, OPIHI_FLT, NELEMENTS);
     100  SetVector (&Yvec, OPIHI_FLT, NELEMENTS);
    101101 
    102102  /***  do consecutive RA lines, first increasing **/
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.astro/cplot.c

    r20860 r20873  
    3131  }
    3232
    33   ResetVector (&Xvec, OPIHI_FLT, xvec[0].Nelements);
    34   ResetVector (&Yvec, OPIHI_FLT, xvec[0].Nelements);
     33  SetVector (&Xvec, OPIHI_FLT, xvec[0].Nelements);
     34  SetVector (&Yvec, OPIHI_FLT, xvec[0].Nelements);
    3535 
    3636  r = xvec[0].elements.Flt;
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.astro/czplot.c

    r20860 r20873  
    3838    return (FALSE);
    3939  }
    40   ResetVector (&Xvec, OPIHI_FLT, xvec[0].Nelements);
    41   ResetVector (&Yvec, OPIHI_FLT, xvec[0].Nelements);
    42   ResetVector (&Zvec, OPIHI_FLT, xvec[0].Nelements);
     40  SetVector (&Xvec, OPIHI_FLT, xvec[0].Nelements);
     41  SetVector (&Yvec, OPIHI_FLT, xvec[0].Nelements);
     42  SetVector (&Zvec, OPIHI_FLT, xvec[0].Nelements);
    4343 
    4444  r   = xvec[0].elements.Flt;
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.basic/test/sprintf.sh

    r10311 r20873  
    3535 $PASS = 1
    3636
    37  if ($endmem - $startmem > 10)
     37 if (($endmem - $startmem)/10000 > 1.0)
    3838   $PASS = 0
    3939   echo "growth: {$endmem-$startmem}"
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/grid.c

    r20860 r20873  
    2323
    2424  N = 0;
    25   ResetVector (&Xvec, OPIHI_FLT, 200);
    26   ResetVector (&Yvec, OPIHI_FLT, 200);
     25  SetVector (&Xvec, OPIHI_FLT, 200);
     26  SetVector (&Yvec, OPIHI_FLT, 200);
    2727
    2828  major = minor = 1;
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/test/applyfit2d.sh

    r16056 r20873  
    3232
    3333# Memory test
     34# NOTE: requires test1 to be run first
    3435macro memtest1
    3536
     
    4849 $PASS = 1
    4950
    50  if ($endmem - $startmem > 10)
     51 if (($endmem - $startmem)/1000 > 1.0)
    5152   $PASS = 0
    5253   echo "growth: {$endmem-$startmem}"
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/test/vgauss.sh

    r10069 r20873  
    2020
    2121 vgauss -q x y dy yfit
     22 # lim x y; clear; box; plot -x 1 -c black x y; plot -c red x yfit
     23 # cursor
    2224
    2325 if (abs($C0 - 0.0) > 0.01)
     
    5153
    5254 vgauss -q x y dy yfit
     55 # lim x y; clear; box; plot -x 1 -c black x y; plot -c red x yfit
     56 # cursor
    5357
    5458 if (abs($C0 - 0.0) > 0.01)
     
    7175 break -auto off
    7276
     77 $C0o = 0.5
     78 $C1o = 2
     79 $C2o = 900
     80 $C3o = 1
     81
    7382 create x -10 10 0.1
    74  set y = 1000 * exp(-0.5*x^2/3^2)
     83 set y = $C3o + $C2o * exp(-0.5*(x - $C0o)^2/$C1o^2)
    7584
    7685 gaussdev dY y[] 0.0 1.0
     
    7887 set y = y + dy
    7988
    80  $C0 = 0.5
    81  $C1 = 2
    82  $C2 = 900
    83  $C3 = 1
     89 $C0 = $C0o + 2
     90 $C1 = $C1o + 2
     91 $C2 = $C2o + 50
     92 $C3 = $C3o + 10
    8493
    8594 vgauss -q x y dy yfit
     95 # lim x y; clear; box; plot -x 1 -c black x y; plot -c red x yfit
     96 # cursor
    8697
    87  if (abs($C0 - 0.0) > 0.01)
     98 $dS = 3.0 / sqrt(y[])
     99
     100 if (abs($C0 - $C0o) > $dS)
    88101   $PASS = 0
    89102 end
    90  if (abs($C1 - 3.0) > 0.01)
     103 if (abs($C1 - $C1o)/$C1o > $dS)
    91104   $PASS = 0
    92105 end
    93  if (abs($C2 - 1000.0) > 1)
     106 if (abs($C2 - $C2o)/$C2o > $dS)
    94107   $PASS = 0
    95108 end
    96  if (abs($C3 - 0.0) > 0.2)
     109 if (abs($C3 - $C3o) > $dS)
    97110   $PASS = 0
    98111 end
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/test/vmaxwell.sh

    r10069 r20873  
    4040 break -auto off
    4141
     42 $C0o = 250
     43 $C1o = 25
     44 $C2o = 100
     45 $C3o = 1
     46 $C4o = 10
     47
    4248 create x 0 1000 1
    43  set y = 1000 * (x-200)^2 * exp(-0.5*(x-300)^2/30^2)
    44  set dy = (rnd(y) - 0.5)/0.5
     49 set y = $C2o * (x-$C4o)^2 * exp(-0.5*(x-$C0o)^2/$C1o^2) + $C3o
     50 gaussdev dY y[] 0.0 1.0
     51 set dy = dY * sqrt(y)
    4552 set y = y + dy
    4653
    47  lim x y; clear; box; plot -x 1 -c black x y
     54 $C0 = $C0o + 20
     55 $C1 = $C1o + 2
     56 $C2 = $C2o + 100
     57 $C3 = $C3o + 10
     58 $C4 = $C4o + 20
    4859
    49  $C0 = 250
    50  $C1 = 25
    51  $C2 = 900
    52  $C3 = 1
    53  $C4 = 190
     60 vmaxwell -q x y dy yfit
     61 lim x y; clear; box; plot -x 1 -c black x y; plot x yfit -c red
    5462
    55  vmaxwell x y dy yfit
    56  plot x yfit -c red
     63 $dS = 6.0 / sqrt(y[])
    5764
    58  if (abs($C0 - 0.0) > 0.01)
     65 if (abs($C0 - $C0o) > $dS)
    5966   $PASS = 0
    6067 end
    61  if (abs($C1 - 3.0) > 0.01)
     68 if (abs($C1 - $C1o)/$C1o > $dS)
    6269   $PASS = 0
    6370 end
    64  if (abs($C2 - 1000.0) > 0.1)
     71 if (abs($C2 - $C2o)/$C2o > $dS)
    6572   $PASS = 0
    6673 end
    67  if (abs($C3 - 0.0) > 0.1)
     74 if (abs($C3 - $C3o) > $dS)
     75   $PASS = 0
     76 end
     77 if (abs($C4 - $C4o)/$C4o > $dS)
    6878   $PASS = 0
    6979 end
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/vmaxwell.c

    r20857 r20873  
    6565  dchisq = ochisq + 2*Npts;
    6666
    67   for (i = 0; (i < 20) && ((dchisq > 0.1*(Npts - Npar)) || (dchisq <= 0.0)); i++) {
     67  for (i = 0; (i < 30) && ((dchisq > 0.1*(Npts - Npar)) || (dchisq <= 0.0)); i++) {
    6868    chisq = mrqmin (xvec[0].elements.Flt, yvec[0].elements.Flt, dy, Npts, par, Npar, fmaxwellOD, !Quiet);
    6969    dchisq = ochisq - chisq;
     
    9494
    9595/* pars: x_o, -0.5/sigma^2, I, back, ref */
     96// f = C3 + C2*(x - C4)^2 * exp(-0.5*(x - C0)^2 / C1^2)
    9697opihi_flt fmaxwellOD (opihi_flt x, opihi_flt *par, int Npar, opihi_flt *dpar) {
    9798
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/zplot.c

    r20860 r20873  
    3131    return (FALSE);
    3232  }
    33   Zvec.Nelements = zvec[0].Nelements;
    34   ALLOCATE (Zvec.elements.Flt, opihi_flt, Zvec.Nelements);
     33  SetVector (&Zvec, OPIHI_FLT, zvec[0].Nelements);
    3534  out = Zvec.elements.Flt;
    3635 
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/Makefile

    r20862 r20873  
    2929$(SRC)/dvomisc.$(ARCH).o                \
    3030$(SRC)/region_list.$(ARCH).o            \
    31 $(SRC)/dvomisc.$(ARCH).o                \
    3231$(SRC)/dbBooleanCond.$(ARCH).o          \
    3332$(SRC)/dbCheckStack.$(ARCH).o           \
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/avextract.c

    r20862 r20873  
    1111
    1212  Vector **vec;
    13   PhotCode *code;
    1413  dbStack *stack;
    1514  dbField *fields;
     
    2019  /* defaults */
    2120  vec = NULL;
    22   code = NULL;
    2321  stack = NULL;
    2422  fields = NULL;
     
    5149  // parse the fields to be extracted and returned
    5250  fields = dbCmdlineFields (argc, argv, DVO_TABLE_AVERAGE, &last, &Nfields);
    53   if (fields == NULL) return (FALSE);
     51  if (fields == NULL) goto escape;
     52  if (Nfields == 0) {
     53    FreeSkyRegionSelection (selection);
     54    dbFreeFields (fields, Nfields);
     55    dvo_catalog_free (&catalog);
     56    goto help;
     57  }
    5458
    5559  // examine line for 'where' or 'match to'.  'match to' is forbidden
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/dbCheckStack.c

    r20860 r20873  
    8383
    8484      // this must be a field : is it a valid name?
     85      status = FALSE;
    8586      if (table == DVO_TABLE_MEASURE) {
    8687        status = ParseMeasureField (&fields[Nfields], stack[i].name);
     
    8990        status = ParseAverageField (&fields[Nfields], stack[i].name);
    9091      }
     92      if (table == DVO_TABLE_IMAGE) {
     93        status = ParseImageField (&fields[Nfields], stack[i].name);
     94      }
    9195      if (!status) {
    92         gprint (GP_ERR, "unknown database field %s\n", stack[i].name);
    9396        goto failure;
    9497      }
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/dbCmdlineFields.c

    r20860 r20873  
    7777        status = ParseAverageField (&fields[Nfields], field);
    7878      }
     79      if (table == DVO_TABLE_IMAGE) {
     80        status = ParseImageField (&fields[Nfields], field);
     81      }
    7982      if (!status) {
    80         gprint (GP_ERR, "unknown database field %s\n", field);
    8183        free (field);
    8284        dbFreeFields (fields, Nfields);
     
    143145  REALLOCATE (*stack, dbStack, N + 20);
    144146
     147  Rname = Dname = NULL;
     148  if (table == DVO_TABLE_MEASURE) {
     149    Rname = strcreate ("RA:AVE");
     150    Dname = strcreate ("DEC:AVE");
     151  }
    145152  if (table == DVO_TABLE_AVERAGE) {
    146153    Rname = strcreate ("RA");
    147154    Dname = strcreate ("DEC");
    148   } else {
    149     Rname = strcreate ("RA:AVE");
    150     Dname = strcreate ("DEC:AVE");
    151   }
     155  }
     156  if (table == DVO_TABLE_IMAGE) {
     157    Rname = strcreate ("RA");
     158    Dname = strcreate ("DEC");
     159  }
     160  if (Rname == NULL) return (FALSE);
    152161
    153162  // add: ((ra > rmin) && (ra < rmax) && (dec > dmin) && (dec < dmax))
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/dbExtractImages.c

    r20872 r20873  
    154154      break;
    155155    case IMAGE_PHOTCODE:
    156       value.Flt = image[N].photcode;
     156      value.Int = image[N].photcode;
    157157      break;
    158158    case IMAGE_TIME:
     
    167167      break;
    168168    case IMAGE_NSTAR:
    169       value.Flt = image[N].nstar;
     169      value.Int = image[N].nstar;
    170170      break;
    171171    case IMAGE_NCAL:
    172       value.Flt = image[N].Mxxxx;
     172      value.Int = image[N].Mxxxx;
    173173      break;
    174174    case IMAGE_SKY:
     
    176176      break;
    177177    case IMAGE_FLAG:
    178       value.Flt = image[N].code;
     178      value.Int = image[N].code;
    179179      break;
    180180    case IMAGE_NX_PIX:
    181       value.Flt = image[N].NX;
     181      value.Int = image[N].NX;
    182182      break;
    183183    case IMAGE_NY_PIX:
    184       value.Flt = image[N].NY;
     184      value.Int = image[N].NY;
    185185      break;
    186186    case IMAGE_IMAGE_ID:
    187       value.Flt = image[N].imageID;
     187      value.Int = image[N].imageID;
    188188      break;
    189189    case IMAGE_THETA: {
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/dbFields.c

    r20872 r20873  
    197197  // check for code:mode in photcode name
    198198  code = ParsePhotcodeField (fieldName, &mode, MAG_REL);
    199   if (code == NULL) return (FALSE);
     199  if (code == NULL) {
     200    gprint (GP_ERR, "unknown field '%s' for measurement table in DVO database\n", fieldName);
     201    return (FALSE);
     202  }
    200203
    201204  field->ID = MEAS_MAG;
     
    257260  // check for code:mode in photcode name
    258261  code = ParsePhotcodeField (fieldName, &mode, MAG_AVE);
    259   if (code == NULL) return (FALSE);
     262  if (code == NULL) {
     263    gprint (GP_ERR, "unknown field '%s' for average table in DVO database\n", fieldName);
     264    return (FALSE);
     265  }
     266
    260267  if (code[0].type == PHOT_MAG) {
    261268    gprint (GP_ERR, "'mag' is ambiguous for avextract\n");
     
    337344
    338345  // for words that don't parse, try a photcode
    339   gprint (GP_ERR, "unknown image field %s\n", fieldName);
     346  gprint (GP_ERR, "unknown field '%s' for image table in DVO database\n", fieldName);
    340347  return (FALSE);
    341348}
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/dbStackOps.c

    r20860 r20873  
    3434void dbFreeTempEntry (dbStack *stack) {
    3535
    36   if (stack->type & DB_STACK_TEMP) return;
     36  if (!(stack->type & DB_STACK_TEMP)) return;
    3737
    3838  if (stack[0].name != NULL)  free (stack[0].name);
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/images.c

    r20860 r20873  
    113113
    114114  npts = NPTS = 200;
    115   ResetVector (&Xvec, OPIHI_FLT, NPTS);
    116   ResetVector (&Yvec, OPIHI_FLT, NPTS);
     115  SetVector (&Xvec, OPIHI_FLT, NPTS);
     116  SetVector (&Yvec, OPIHI_FLT, NPTS);
    117117
    118118  ALLOCATE (plist, int, NPTS);
     
    276276
    277277  gprint (GP_ERR, "plotting %d images\n", n);
    278   Xvec.Nelements = Xvec.Nelements = N;
     278  Xvec.Nelements = Yvec.Nelements = N;
    279279  if (N > 0) {
    280280    graphmode.style = 2; /* points */
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/imbox.c

    r20860 r20873  
    3636 
    3737  /* project this image to screen display coords */
    38   ResetVector (&Xvec, OPIHI_FLT, 8);
    39   ResetVector (&Yvec, OPIHI_FLT, 8);
     38  SetVector (&Xvec, OPIHI_FLT, 8);
     39  SetVector (&Yvec, OPIHI_FLT, 8);
    4040
    4141  while (gfits_fread_header (f, &header)) {
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/imdense.c

    r20860 r20873  
    3232  N = 0;
    3333  NPTS = 200;
    34   ResetVector (&Xvec, OPIHI_FLT, NPTS);
    35   ResetVector (&Yvec, OPIHI_FLT, NPTS);
     34  SetVector (&Xvec, OPIHI_FLT, NPTS);
     35  SetVector (&Yvec, OPIHI_FLT, NPTS);
    3636
    3737  for (i = 0; i < Nimage; i++) {
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/imextract.c

    r20872 r20873  
    3939  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
    4040    gprint (GP_ERR, "invalid sky region selection\n");
    41     return FALSE;
     41    goto escape;
    4242  }
    4343
     
    4646  // parse the fields to be extracted and returned
    4747  fields = dbCmdlineFields (argc, argv, DVO_TABLE_IMAGE, &last, &Nfields);
    48   if (fields == NULL) return (FALSE);
     48  if (fields == NULL) goto escape;
     49  if (Nfields == 0) {
     50    FreeSkyRegionSelection (selection);
     51    dbFreeFields (fields, Nfields);
     52    goto help;
     53  }
    4954
    5055  // examine line for 'where' or 'match to'.  'match to' is forbidden
     
    158163    gprint (GP_ERR, "  RA : right ascension of field center (J2000)\n");
    159164    gprint (GP_ERR, "  DEC : declination of field center\n");
     165    gprint (GP_ERR, "  Xm : chisq of photometry calibration\n");
     166    gprint (GP_ERR, "  airmass : mean airmass of exposure\n");
     167    gprint (GP_ERR, "  Mcal : photometry calibration (mags)\n");
     168    gprint (GP_ERR, "  dMcal : photometry calibration error (mags)\n");
     169    gprint (GP_ERR, "  photcode : numeric photcode value for image\n");
     170    gprint (GP_ERR, "  time : time of exposure\n");
     171    gprint (GP_ERR, "  FWHM : mean fwhm of exposure\n");
     172    gprint (GP_ERR, "  exptime : exposure duration (seconds)\n");
     173    gprint (GP_ERR, "  nstar : number of stars detected in exposure\n");
     174    gprint (GP_ERR, "  ncal : number of stars used for photometry calibration\n");
     175    gprint (GP_ERR, "  sky : mean background flux\n");
     176    gprint (GP_ERR, "  flag : processing bit flags\n");
     177    gprint (GP_ERR, "  NX : image dimensions\n");
     178    gprint (GP_ERR, "  NY : image dimensions\n");
     179    gprint (GP_ERR, "  theta : position angle of image\n");
     180    gprint (GP_ERR, "  skew : distortion from rectangle\n");
     181    gprint (GP_ERR, "  scale : pixel scale\n");
     182    gprint (GP_ERR, "  dscale : pixel-scale error (or variation?)\n");
     183    gprint (GP_ERR, "  imageID : unique image identifier\n");
     184    gprint (GP_ERR, "  X_LL_CHIP : chip x-pixel coordinate of lower left corner\n");
     185    gprint (GP_ERR, "  X_LR_CHIP : chip x-pixel coordinate of lower right corner\n");
     186    gprint (GP_ERR, "  X_UL_CHIP : chip x-pixel coordinate of upper left corner\n");
     187    gprint (GP_ERR, "  X_UR_CHIP : chip x-pixel coordinate of upper right corner\n");
     188    gprint (GP_ERR, "  Y_LL_CHIP : chip y-pixel coordinate of lower left corner\n");
     189    gprint (GP_ERR, "  Y_LR_CHIP : chip y-pixel coordinate of lower right corner\n");
     190    gprint (GP_ERR, "  Y_UL_CHIP : chip y-pixel coordinate of upper left corner\n");
     191    gprint (GP_ERR, "  Y_UR_CHIP : chip y-pixel coordinate of upper right corner\n");
     192    gprint (GP_ERR, "  X_LL_FP   : focal-plane x-pixel coordinate of lower left corner\n");
     193    gprint (GP_ERR, "  X_LR_FP   : focal-plane x-pixel coordinate of lower right corner\n");
     194    gprint (GP_ERR, "  X_UL_FP   : focal-plane x-pixel coordinate of upper left corner\n");
     195    gprint (GP_ERR, "  X_UR_FP   : focal-plane x-pixel coordinate of upper right corner\n");
     196    gprint (GP_ERR, "  Y_LL_FP   : focal-plane y-pixel coordinate of lower left corner\n");
     197    gprint (GP_ERR, "  Y_LR_FP   : focal-plane y-pixel coordinate of lower right corner\n");
     198    gprint (GP_ERR, "  Y_UL_FP   : focal-plane y-pixel coordinate of upper left corner\n");
     199    gprint (GP_ERR, "  Y_UR_FP   : focal-plane y-pixel coordinate of upper right corner\n");
    160200    return (FALSE);
    161201  }
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/imstats.c

    r20860 r20873  
    3333
    3434  /* assign vector values */
    35   ResetVector (&Xvec, OPIHI_FLT, Nimage);
    36   ResetVector (&Yvec, OPIHI_FLT, Nimage);
     35  SetVector (&Xvec, OPIHI_FLT, Nimage);
     36  SetVector (&Yvec, OPIHI_FLT, Nimage);
    3737
    3838  gprint (GP_LOG, "seq  ra (J2000) dec    time (s)   Nstars\n");
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/lcurve.c

    r20860 r20873  
    104104  N = 0;
    105105  NPTS = 100;
    106   ResetVector (&Xvec, OPIHI_FLT, NPTS);
    107   ResetVector (&Yvec, OPIHI_FLT, NPTS);
     106  SetVector (&Xvec, OPIHI_FLT, NPTS);
     107  SetVector (&Yvec, OPIHI_FLT, NPTS);
    108108  dYvec.elements.Flt = NULL;
    109109  if (ErrorBars) {   
    110     ResetVector (&dYvec, OPIHI_FLT, NPTS);
     110    SetVector (&dYvec, OPIHI_FLT, NPTS);
    111111  }
    112112
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/mextract.c

    r20860 r20873  
    1111  Catalog catalog;
    1212  SkyList *skylist;
    13   PhotCode *code;
    1413  Vector **vec;
    1514  dbField *fields;
     
    1817
    1918  /* defaults */
     19  vec = NULL;
     20  stack = NULL;
     21  fields = NULL;
     22  values = NULL;
    2023  skylist = NULL;
    21   code = NULL;
    22   fields = NULL;
    23   stack = NULL;
     24  selection = NULL;
    2425
    2526  if ((N = get_argument (argc, argv, "-h"))) goto help;
     
    4950  fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields);
    5051  if (fields == NULL) return (FALSE);
     52  if (Nfields == 0) {
     53    FreeSkyRegionSelection (selection);
     54    dbFreeFields (fields, Nfields);
     55    dvo_catalog_free (&catalog);
     56    goto help;
     57  }
    5158
    5259  // examine line for 'where' or 'match to'.  'match to' is forbidden
     
    168175  }
    169176
    170   free (values);
     177  if (vec) free (vec);
     178  if (values) free (values);
    171179  dbFreeFields (fields, Nfields);
    172180  dbFreeStack (stack, Nstack);
     
    178186
    179187escape:
     188  if (vec) free (vec);
    180189  free (values);
    181190  dbFreeFields (fields, Nfields);
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/mmextract.c

    r20857 r20873  
    1313  Catalog catalog;
    1414  SkyList *skylist;
    15   PhotCode *code;
    1615  Vector **vec;
    1716  dbField *fields;
     
    2120
    2221  /* defaults */
    23   skylist = NULL;
    24   code = NULL;
    25   fields = NULL;
     22  vec = NULL;
    2623  stack1 = NULL;
    2724  stack2 = NULL;
     25  fields = NULL;
     26  values = NULL;
     27  skylist = NULL;
     28  selection = NULL;
    2829
    2930  if ((N = get_argument (argc, argv, "-h"))) goto help;
     
    5758  // parse the fields to be extracted and returned : last points to end, or first 'where' or 'matched'
    5859  fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields);
    59   if (fields == NULL) return (FALSE);
     60  if (fields == NULL) goto escape;
     61  if (Nfields == 0) {
     62    FreeSkyRegionSelection (selection);
     63    dbFreeFields (fields, Nfields);
     64    dvo_catalog_free (&catalog);
     65    goto help;
     66  }
    6067
    6168  // examine line for 'where' and 'match to'.  neither is required, but order is fixed
     
    298305
    299306escape:
     307  if (vec) free (vec);
     308  if (values) free (values);
    300309  dbFreeFields (fields, Nfields);
    301310  dbFreeStack (stack1, Nstack1);
     
    310319
    311320 help:
    312   gprint (GP_ERR, "USAGE: mextract field[,field,field...] where (expression)\n");
     321  gprint (GP_ERR, "USAGE: mmextract field[,field,field...] where (expression) match to (expression)\n");
     322  gprint (GP_ERR, "  pairs of fields are returned: the first set are restricted by the 'where' expression, the second by the 'match to' expression\n");
    313323
    314324  if ((argc > N + 1) && !strcasecmp (argv[N+1], "fields")) {
     
    362372    return (FALSE);
    363373  }
    364   gprint (GP_ERR, " mextract --help fields : for a complete listing of allowed fields\n");
     374  gprint (GP_ERR, " mmextract --help fields : for a complete listing of allowed fields\n");
    365375  return (FALSE);
    366376}
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/procks.c

    r20860 r20873  
    9595
    9696  /* data has been loaded, get ready to plot it */
    97   ResetVector (&Xvec, OPIHI_FLT, 3*Nrocks);
    98   ResetVector (&Yvec, OPIHI_FLT, 3*Nrocks);
     97  SetVector (&Xvec, OPIHI_FLT, 3*Nrocks);
     98  SetVector (&Yvec, OPIHI_FLT, 3*Nrocks);
    9999 
    100100  /* project stars to screen display coords */
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/showtile.c

    r20860 r20873  
    2222  N = 0;
    2323  NPTS = 200;
    24   ResetVector (&Xvec, OPIHI_FLT, NPTS);
    25   ResetVector (&Yvec, OPIHI_FLT, NPTS);
     24  SetVector (&Xvec, OPIHI_FLT, NPTS);
     25  SetVector (&Yvec, OPIHI_FLT, NPTS);
    2626
    2727  /* starting position */
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/simage.c

    r20860 r20873  
    9292
    9393  /* set up storage buffers */
    94   ResetVector (&Xvec, OPIHI_FLT, Nstars);
    95   ResetVector (&Yvec, OPIHI_FLT, Nstars);
    96   ResetVector (&Zvec, OPIHI_FLT, Nstars);
     94  SetVector (&Xvec, OPIHI_FLT, Nstars);
     95  SetVector (&Yvec, OPIHI_FLT, Nstars);
     96  SetVector (&Zvec, OPIHI_FLT, Nstars);
    9797  ALLOCATE (buffer, char, (BLOCK*BYTES_STAR));
    9898
  • branches/eam_branch_20081124/Ohana/src/opihi/dvo/skycat.c

    r20860 r20873  
    5555  Npts = 0;
    5656  NPTS = 200;
    57   ResetVector (&Xvec, OPIHI_FLT, NPTS);
    58   ResetVector (&Yvec, OPIHI_FLT, NPTS);
     57  SetVector (&Xvec, OPIHI_FLT, NPTS);
     58  SetVector (&Yvec, OPIHI_FLT, NPTS);
    5959   
    6060  regions = skylist[0].regions;
  • branches/eam_branch_20081124/Ohana/src/opihi/include/dvomath.h

    r20860 r20873  
    88# define NCHARS 256
    99# define opihi_flt double
    10 # define opihi_int unsigned int
     10# define opihi_int int
     11// NOTE: if opihi_int is changed to unsigned, all subtraction and negation operations
     12// need to result in a float value (or 3 - 5 will yield the unexpected value 2^32 - 2)
    1113
    1214# define REQUIRE_VECTOR_FLT(VECT,RVAL) { \
     
    110112int           CopyVector            PROTO((Vector *out, Vector *in));
    111113int           ResetVector           PROTO((Vector *vec, char type, int Nelements));
     114int           SetVector             PROTO((Vector *vec, char type, int Nelements));
    112115int           CastVector            PROTO((Vector *vec, char type));
    113116int           MatchVector           PROTO((Vector *out, Vector *in, char type));
  • branches/eam_branch_20081124/Ohana/src/opihi/include/dvoshell.h

    r20862 r20873  
    309309int          ParseMeasureField      PROTO((dbField *field, char *fieldName));
    310310int          ParseAverageField      PROTO((dbField *field, char *fieldName));
     311int          ParseImageField        PROTO((dbField *field, char *fieldName));
    311312
    312313dbValue      dbExtractAverages      PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));
  • branches/eam_branch_20081124/Ohana/src/opihi/lib.data/graphtools.c

    r20859 r20873  
    3232
    3333  if (yvec != NULL) {
    34     if (xvec->type == OPIHI_FLT) {
     34    if (yvec->type == OPIHI_FLT) {
    3535      maxY = minY = yvec[0].elements.Flt[0];
    3636      for (i = 1; i < yvec[0].Nelements; i++) {
  • branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/VectorOps.c

    r20860 r20873  
    187187}
    188188
     189// SetVector (vecx, OPIHI_FLT, MAX (Npts, 1));
     190int SetVector (Vector *vec, char type, int Nelements) {
     191
     192  vec[0].Nelements = Nelements;
     193  if (type == OPIHI_FLT) {
     194    ALLOCATE (vec[0].elements.Flt, opihi_flt, Nelements);
     195    vec[0].type = OPIHI_FLT;
     196  } else {
     197    ALLOCATE (vec[0].elements.Int, opihi_int, Nelements);
     198    vec[0].type = OPIHI_INT;
     199  }
     200  return TRUE;
     201}
     202
    189203// recast the vector to the specified type
    190204int CastVector (Vector *vec, char type) {
  • branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/stack_math.c

    r20856 r20873  
    819819    }                                           \
    820820    if ((FTYPE == 's') && (V1->type == 's')) {  \
    821       opihi_int M1  = V1[0].FltValue;           \
     821      opihi_int M1  = V1[0].IntValue;           \
    822822      OUT[0].type = 's';                        \
    823823      OUT[0].IntValue = OP;                     \
     
    855855  if (!strcmp (op, "rnd"))    S_FUNC(M1*0.0 + drand48(), 'S');
    856856  if (!strcmp (op, "not"))    S_FUNC(!(M1), 's');
    857   if (!strcmp (op, "--"))     S_FUNC(-(M1), 's');
     857  if (!strcmp (op, "--"))     S_FUNC(-1*M1, 's'); // NOTE: opihi_int is signed,
    858858  if (!strcmp (op, "isinf"))  S_FUNC(!finite(M1), 'S'); // XXX modify in future
    859859  if (!strcmp (op, "isnan"))  S_FUNC(isnan(M1), 'S'); // XXX modify in future   
     
    939939  if (!strcmp (op, "zero"))   V_FUNC(0, 's');
    940940  if (!strcmp (op, "not"))    V_FUNC(!(*M1), 's');
    941   if (!strcmp (op, "--"))     V_FUNC(-(*M1), 's');
     941  if (!strcmp (op, "--"))     V_FUNC(-1*(*M1), 's'); // NOTE: opihi_int is signed
    942942  if (!strcmp (op, "isinf"))  V_FUNC(!finite(*M1), 'S');
    943943  if (!strcmp (op, "isnan"))  V_FUNC(isnan(*M1), 'S');
     
    980980  if (!strcmp (op, "="))     { }
    981981  if (!strcmp (op, "abs"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = fabs(*M1);         }}
    982   if (!strcmp (op, "int"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (float)(int)(*M1); }}
     982  if (!strcmp (op, "int"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(int)(*M1); }}
    983983  if (!strcmp (op, "exp"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = exp(*M1);          }}
    984984  if (!strcmp (op, "ten"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = pow(10.0,*M1);     }}
Note: See TracChangeset for help on using the changeset viewer.