IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36489


Ignore:
Timestamp:
Feb 6, 2014, 12:43:34 PM (12 years ago)
Author:
eugene
Message:

fix cast in vgauss; add cast function; add psf smoothing options to densify and cdensify; add floor, ceil, rint functions to opihi math; add cdensify function; add fitpm function

Location:
trunk/Ohana/src/opihi
Files:
17 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi

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

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

    r36084 r36489  
    2828$(SRC)/cval.$(ARCH).o              \
    2929$(SRC)/czplot.$(ARCH).o    \
     30$(SRC)/cdensify.$(ARCH).o          \
    3031$(SRC)/drizzle.$(ARCH).o           \
    3132$(SRC)/flux.$(ARCH).o              \
    3233$(SRC)/fitplx.$(ARCH).o    \
     34$(SRC)/fitpm.$(ARCH).o     \
    3335$(SRC)/fixwrap.$(ARCH).o           \
    3436$(SRC)/fixcols.$(ARCH).o           \
  • trunk/Ohana/src/opihi/cmd.astro/fitplx.c

    r36375 r36489  
    112112  coords.pc1_2  = coords.pc2_1 = 0.0;
    113113  coords.Npolyterms = 1;
    114   strcpy (coords.ctype, "RA---SIN");
     114  strcpy (coords.ctype, "DEC--SIN");
    115115
    116116  double *X, *Y, *t, *pX, *pY, *dX, *dY;
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r36084 r36489  
    1313int czplot                  PROTO((int, char **));
    1414int czcplot                 PROTO((int, char **));
     15int cdensify                PROTO((int, char **));
    1516int drizzle                 PROTO((int, char **));
    1617int flux                    PROTO((int, char **));
    1718int fitplx                  PROTO((int, char **));
     19int fitpm                   PROTO((int, char **));
    1820int fixwrap                 PROTO((int, char **));
    1921int fiximage                PROTO((int, char **));
     
    7375  {1, "czplot",      czplot,       "plot scaled vectors in sky coordinates"},
    7476  {1, "czcplot",     czcplot,      "plot color-scaled vectors in sky coordinates"},
     77  {1, "cdensify",    cdensify,      "vectors to density history on projection"},
    7578  {1, "drizzle",     drizzle,      "transform image to image"},
    7679  {1, "flux",        flux,         "flux in a convex contour"},
    7780  {1, "fitplx",      fitplx,       "fit proper motion and parallax"},
     81  {1, "fitpm",       fitpm,        "fit proper motion only"},
    7882  {1, "fixwrap",     fixwrap,      "fix megacam over-wrapped pixels"},
    7983  {1, "fiximage",    fiximage,     "fix pixels in an image by interpolation"},
  • trunk/Ohana/src/opihi/cmd.astro/region.c

    r31160 r36489  
    8080  if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE);
    8181  Radius = atof (argv[3]);
    82   strcpy (graphmode.coords.ctype, "RA---TAN");
     82  strcpy (graphmode.coords.ctype, "DEC--TAN");
    8383  if (argc == 5) {
    8484    if (!strcasecmp (argv[4], "TAN"))
    85       strcpy (graphmode.coords.ctype, "RA---TAN");
     85      strcpy (graphmode.coords.ctype, "DEC--TAN");
    8686    if (!strcasecmp (argv[4], "SIN"))
    87       strcpy (graphmode.coords.ctype, "RA---SIN");
     87      strcpy (graphmode.coords.ctype, "DEC--SIN");
    8888    if (!strcasecmp (argv[4], "ARC"))
    89       strcpy (graphmode.coords.ctype, "RA---ARC");
     89      strcpy (graphmode.coords.ctype, "DEC--ARC");
    9090    if (!strcasecmp (argv[4], "STG"))
    91       strcpy (graphmode.coords.ctype, "RA---STG");
     91      strcpy (graphmode.coords.ctype, "DEC--STG");
    9292    if (!strcasecmp (argv[4], "ZEA"))
    93       strcpy (graphmode.coords.ctype, "RA---ZEA");
     93      strcpy (graphmode.coords.ctype, "DEC--ZEA");
    9494    if (!strcasecmp (argv[4], "AIT"))
    95       strcpy (graphmode.coords.ctype, "RA---AIT");
     95      strcpy (graphmode.coords.ctype, "DEC--AIT");
    9696    if (!strcasecmp (argv[4], "GLS"))
    97       strcpy (graphmode.coords.ctype, "RA---GLS");
     97      strcpy (graphmode.coords.ctype, "DEC--GLS");
    9898    if (!strcasecmp (argv[4], "PAR"))
    99       strcpy (graphmode.coords.ctype, "RA---PAR");
     99      strcpy (graphmode.coords.ctype, "DEC--PAR");
    100100  }
    101101
  • trunk/Ohana/src/opihi/cmd.data

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

    r36375 r36489  
    2525$(SRC)/book.$(ARCH).o           \
    2626$(SRC)/book_commands.$(ARCH).o  \
     27$(SRC)/cast.$(ARCH).o           \
    2728$(SRC)/center.$(ARCH).o \
    2829$(SRC)/clear.$(ARCH).o          \
  • trunk/Ohana/src/opihi/cmd.data/densify.c

    r34088 r36489  
    22
    33# define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
     4enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS};
    45
    56int densify (int argc, char **argv) {
    67
    7   int i, Nx, Ny, Xb, Yb, N, Xpix, Ypix, good, UseGraph;
     8  int i, Nx, Ny, Xb, Yb, ix, iy, N, Xpix, Ypix, good, UseGraph;
    89  double Xmin, Xmax, dX, Ymin, Ymax, dY;
    910  float *val;
     
    2425  }
    2526
     27  float scale = 0.0;
     28  if ((N = get_argument (argc, argv, "-scale"))) {
     29    remove_argument (N, &argc, argv);
     30    scale = atof(argv[N]);
     31    remove_argument (N, &argc, argv);
     32  }
     33
     34  int PSFTYPE = IS_DOT;
     35  if ((N = get_argument (argc, argv, "-psf"))) {
     36    remove_argument (N, &argc, argv);
     37    if (!strcasecmp(argv[N], "dot"))    PSFTYPE = IS_DOT;
     38    if (!strcasecmp(argv[N], "square")) PSFTYPE = IS_SQUARE;
     39    if (!strcasecmp(argv[N], "circle")) PSFTYPE = IS_CIRCLE;
     40    if (!strcasecmp(argv[N], "gauss"))  PSFTYPE = IS_GAUSS;
     41    remove_argument (N, &argc, argv);
     42  }
     43
    2644  good = UseGraph ? (argc == 4) : (argc == 10);
    2745  if (!good) {
    2846    gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n");
    2947    gprint (GP_ERR, "   OR: densify buffer x y -graph\n");
     48    gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n");
    3049    return (FALSE);
    3150  }
     
    6988  CHECKVAL(dY);
    7089
     90  float scaleX = (scale > 0.0) ? scale / dX : 3.0;
     91  float scaleY = (scale > 0.0) ? scale / dY : 3.0;
     92
    7193  Nx = (Xmax - Xmin) / dX + 1;
    7294  Ny = (Ymax - Ymin) / dY + 1;
     
    7698  CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);
    7799  strcpy (bf[0].file, "(empty)");
     100 
     101  float scale2 = (scaleX + 1.0) * (scaleY + 1.0);
     102  float fSquare = 1.0 / scale2;
     103  float fCircle = 1.0 / (3.141592 * scale2);
     104  float fSigma  = 0.5 / scale2;
     105  float fGauss  = 1.0 / (2.0 * 3.141592 * scale2);
    78106
    79107  x = vx[0].elements.Flt;
     
    83111    Xb = (*x - Xmin) / dX;
    84112    Yb = (*y - Ymin) / dY;
    85     if (Xb >= Nx) continue;
    86     if (Yb >= Ny) continue;
    87     if (Xb < 0) continue;
    88     if (Yb < 0) continue;
    89     val[Xb + Yb*Nx] ++;
     113    switch (PSFTYPE) {
     114      case IS_DOT:
     115        if (Xb >= Nx) continue;
     116        if (Yb >= Ny) continue;
     117        if (Xb < 0) continue;
     118        if (Yb < 0) continue;
     119        val[Xb + Yb*Nx] ++;
     120        break;
     121      case IS_SQUARE:
     122        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     123          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     124            if (ix >= Nx) continue;
     125            if (iy >= Ny) continue;
     126            if (ix < 0) continue;
     127            if (iy < 0) continue;
     128            val[ix + iy*Nx] += fSquare;
     129          }
     130        }
     131        break;
     132      case IS_CIRCLE:
     133        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     134          float dX = ix - Xb;
     135          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     136            float dY = iy - Yb;
     137            float r2 = dX*dX + dY*dY;
     138            if (r2 > 9) continue;
     139            if (ix >= Nx) continue;
     140            if (iy >= Ny) continue;
     141            if (ix < 0) continue;
     142            if (iy < 0) continue;
     143            val[ix + iy*Nx] += fCircle;
     144          }
     145        }
     146        break;
     147      case IS_GAUSS:
     148        for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) {
     149          float dX = ix - Xb;
     150          for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) {
     151            float dY = iy - Yb;
     152            float r2 = dX*dX + dY*dY;
     153            if (ix >= Nx) continue;
     154            if (iy >= Ny) continue;
     155            if (ix < 0) continue;
     156            if (iy < 0) continue;
     157            val[ix + iy*Nx] += fGauss*exp(-fSigma*r2);
     158          }
     159        }
     160        break;
     161    }
    90162  }
    91163  return (TRUE);
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r36375 r36489  
    1010int center           PROTO((int, char **));
    1111int parity           PROTO((int, char **));
     12int cast             PROTO((int, char **));
    1213int circstats        PROTO((int, char **));
    1314int clear            PROTO((int, char **));
     
    164165  {1, "buffers",      list_buffers,     "list the currently allocated buffers (images)"},
    165166  {1, "center",       center,           "center image on coords"},
     167  {1, "cast",         cast,             "cast input vector to specified type"},
    166168  {1, "circstats",    circstats,        "circular statistics"},
    167169  {1, "clear",        clear,            "erase plot"},
  • trunk/Ohana/src/opihi/cmd.data/vgauss.c

    r35109 r36489  
    4848  if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    4949
     50  CastVector (xvec, OPIHI_FLT);
     51  CastVector (yvec, OPIHI_FLT);
     52
    5053  int Nsvec = strlen(argv[3]);
    5154
     
    6972  }
    7073
    71   CastVector (xvec, OPIHI_FLT);
    72   CastVector (yvec, OPIHI_FLT);
    7374  CastVector (svec, OPIHI_FLT);
    7475  // XXX Cast is failing.
  • trunk/Ohana/src/opihi/dvo/find_matches.c

    r29759 r36489  
    5050  tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
    5151  tcoords.Npolyterms = 1;
    52   strcpy (tcoords.ctype, "RA---ARC");
     52  strcpy (tcoords.ctype, "DEC--ARC");
    5353
    5454  // this region includes a boundary layer of size RADIUS
  • trunk/Ohana/src/opihi/dvo/gimages.c

    r34844 r36489  
    136136      local.pc2_1 = local.pc1_2 = 0.0;
    137137      local.Npolyterms = 1;
    138       strcpy (local.ctype, "RA---TAN");
     138      strcpy (local.ctype, "DEC--TAN");
    139139
    140140      if (typehash == DistortImage) {
  • trunk/Ohana/src/opihi/dvo/showtile.c

    r34584 r36489  
    3434  coords.pc1_2  = coords.pc2_1  = 0.0;
    3535  coords.Npolyterms = 0;
    36   strcpy (coords.ctype, "RA---TAN");
     36  strcpy (coords.ctype, "DEC--TAN");
    3737 
    3838  /* fill in top-left region */
  • trunk/Ohana/src/opihi/dvo/simage.c

    r34584 r36489  
    4343  /* get astrometry information */
    4444  strcpy (coords.ctype, "NONE");
    45   gfits_scan (&header, "CTYPE1",   "%s",  1, coords.ctype);
    46   if (strcmp (coords.ctype, "RA---PLY")) {
     45  gfits_scan (&header, "CTYPE2",   "%s",  1, coords.ctype);
     46  if (strcmp (coords.ctype, "DEC--PLY")) {
    4747    gprint (GP_ERR, "ERROR: wrong astrometric info in header\n");
    4848    return (FALSE);
  • trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c

    r36375 r36489  
    3030    if (!strcmp (argv[i], "abs"))    { type = ST_UNARY; goto gotit; }
    3131    if (!strcmp (argv[i], "int"))    { type = ST_UNARY; goto gotit; }
     32    if (!strcmp (argv[i], "floor"))  { type = ST_UNARY; goto gotit; }
     33    if (!strcmp (argv[i], "round"))  { type = ST_UNARY; goto gotit; }
     34    if (!strcmp (argv[i], "ceil"))   { type = ST_UNARY; goto gotit; }
     35    if (!strcmp (argv[i], "rint"))   { type = ST_UNARY; goto gotit; }
    3236    if (!strcmp (argv[i], "exp"))    { type = ST_UNARY; goto gotit; }
    3337    if (!strcmp (argv[i], "ten"))    { type = ST_UNARY; goto gotit; }
  • trunk/Ohana/src/opihi/lib.shell/stack_math.c

    r36375 r36489  
    11231123  if (!strcmp (op, "abs"))    S_FUNC(fabs(M1), ST_SCALAR_INT);
    11241124  if (!strcmp (op, "int"))    S_FUNC((long long)(M1), ST_SCALAR_INT);
     1125  if (!strcmp (op, "floor"))  S_FUNC(floor (M1), ST_SCALAR_FLT);
     1126  if (!strcmp (op, "ceil"))   S_FUNC(ceil (M1), ST_SCALAR_FLT);
     1127  if (!strcmp (op, "rint"))   S_FUNC(nearbyint (M1), ST_SCALAR_FLT);
    11251128  if (!strcmp (op, "exp"))    S_FUNC(exp (M1), ST_SCALAR_FLT);
    11261129  if (!strcmp (op, "ten"))    S_FUNC(pow (10.0,M1), ST_SCALAR_FLT);
     
    12021205  if (!strcmp (op, "abs"))    V_FUNC(fabs(*M1), ST_SCALAR_INT);
    12031206  if (!strcmp (op, "int"))    V_FUNC((long long)(*M1), ST_SCALAR_INT);
     1207  if (!strcmp (op, "floor"))  V_FUNC(floor (*M1), ST_SCALAR_FLT);
     1208  if (!strcmp (op, "ceil"))   V_FUNC(ceil (*M1), ST_SCALAR_FLT);
     1209  if (!strcmp (op, "rint"))   V_FUNC(nearbyint (*M1), ST_SCALAR_FLT);
    12041210  if (!strcmp (op, "exp"))    V_FUNC(exp(*M1), ST_SCALAR_FLT);
    12051211  if (!strcmp (op, "ten"))    V_FUNC(pow(10.0,*M1), ST_SCALAR_FLT);
     
    12731279  if (!strcmp (op, "abs"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = fabs(*M1);         }}
    12741280  if (!strcmp (op, "int"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }}
     1281
     1282  if (!strcmp (op, "floor")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = floor (*M1); }}
     1283  if (!strcmp (op, "ceil"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = ceil (*M1); }}
     1284  if (!strcmp (op, "rint"))  { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = nearbyint (*M1); }}
     1285
    12751286  if (!strcmp (op, "exp"))   { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = exp(*M1);          }}
    12761287  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.