IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39591


Ignore:
Timestamp:
May 28, 2016, 5:07:36 PM (10 years ago)
Author:
eugene
Message:

add parallax factor function; add pm transformation

Location:
trunk/Ohana/src/opihi/cmd.astro
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/Makefile

    r39245 r39591  
    6060$(SRC)/objload.$(ARCH).o           \
    6161$(SRC)/outline.$(ARCH).o           \
     62$(SRC)/parallax_factor.$(ARCH).o   \
    6263$(SRC)/polar.$(ARCH).o             \
    6364$(SRC)/precess.$(ARCH).o           \
  • trunk/Ohana/src/opihi/cmd.astro/csystem.c

    r37807 r39591  
    44
    55  /* USAGE: csystem [C/G/E/H] [C/G/E/H] [epoch] */
    6   int i;
    7   double X, Y, x, y;
    8   opihi_flt *xptr, *yptr;
    9   Vector *xvec, *yvec;
     6  int i, N;
     7  double X, Y, x, y, uX, uY, ux, uy;
    108  CoordTransformSystem input, output;
    11   CoordTransform *transform;
     9
     10  Vector *xvec = NULL;
     11  Vector *yvec = NULL;
     12  Vector *uxvec = NULL;
     13  Vector *uyvec = NULL;
     14
     15  // transform proper motions at the same time
     16  char *uXname = NULL;
     17  char *uYname = NULL;
     18  int pmBackwards = FALSE;
     19  if ((N = get_argument (argc, argv, "-pm"))) {
     20    remove_argument (N, &argc, argv);
     21    uXname = strcreate (argv[N]);
     22    remove_argument (N, &argc, argv);
     23    uYname = strcreate (argv[N]);
     24    remove_argument (N, &argc, argv);
     25  }
     26  if ((N = get_argument (argc, argv, "-pmback"))) {
     27    if (uXname) {
     28      gprint (GP_ERR, "cannot mix -pm and -pmback\n");
     29      return FALSE;
     30    }
     31    remove_argument (N, &argc, argv);
     32    uXname = strcreate (argv[N]);
     33    remove_argument (N, &argc, argv);
     34    uYname = strcreate (argv[N]);
     35    remove_argument (N, &argc, argv);
     36    pmBackwards = TRUE;
     37  }
    1238
    1339  if (argc != 5) goto syntax;
     
    3561  }
    3662
    37   transform = InitTransform (input, output);
     63  CoordTransform *transform = InitTransform (input, output);
    3864  if (transform == NULL) {
    3965    gprint (GP_ERR, "transform %c to %c is not yet defined\n", argv[1][0], argv[2][0]);
     
    4268   
    4369  if (SelectScalar (argv[3], &X)) {
    44     if (!SelectScalar (argv[4], &Y)) return (FALSE);
     70    if (!SelectScalar (argv[4], &Y)) goto escape;
    4571     
     72    // apply transform at the current coordinate to transform motions:
     73    if (uXname) {
     74      if (!SelectScalar (uXname, &uX)) goto escape;
     75      if (!SelectScalar (uYname, &uY)) goto escape;
     76
     77      if (pmBackwards) {
     78        TransformProperMotionBackwards (&ux, &uy, uX, uY, X, Y, transform);
     79      } else {
     80        TransformProperMotionForewards (&ux, &uy, uX, uY, X, Y, transform);
     81      }
     82    }
    4683    ApplyTransform (&x, &y, X, Y, transform);
    4784
    48     gprint (GP_LOG, "%10.6f %10.6f\n", x, y);
     85    if (uXname) {
     86      gprint (GP_LOG, "%10.6f %10.6f @ %10.6f %10.6f\n", x, y, ux, uy);
     87    } else {
     88      gprint (GP_LOG, "%10.6f %10.6f\n", x, y);
     89    }
     90    free (transform);
    4991    return (TRUE);
    5092  }
    5193
    5294  /* find vectors */
    53   if ((xvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    54   if ((yvec = SelectVector (argv[4], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     95  if ((xvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) goto escape;
     96  if ((yvec = SelectVector (argv[4], OLDVECTOR, TRUE)) == NULL) goto escape;
    5597
    5698  if (xvec[0].Nelements != yvec[0].Nelements) {
    5799    gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[3], argv[4]);
    58     return (FALSE);
     100    goto escape;
    59101  }
    60102 
     103  // apply transform at the current coordinate to transform motions:
     104  if (uXname) {
     105    if ((uxvec = SelectVector (uXname, OLDVECTOR, TRUE)) == NULL) goto escape;
     106    if ((uyvec = SelectVector (uYname, OLDVECTOR, TRUE)) == NULL) goto escape;
     107   
     108    if (xvec[0].Nelements != uxvec[0].Nelements) {
     109      gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[3], uXname);
     110      goto escape;
     111    }
     112    if (xvec[0].Nelements != uyvec[0].Nelements) {
     113      gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[3], uYname);
     114      goto escape;
     115    }
     116
     117    CastVector (uxvec, OPIHI_FLT);
     118    CastVector (uyvec, OPIHI_FLT);
     119  }
     120
    61121  CastVector (xvec, OPIHI_FLT);
    62122  CastVector (yvec, OPIHI_FLT);
    63123
    64   xptr = xvec[0].elements.Flt;
    65   yptr = yvec[0].elements.Flt;
     124  opihi_flt *xptr = xvec[0].elements.Flt;
     125  opihi_flt *yptr = yvec[0].elements.Flt;
     126
     127  opihi_flt *uxptr = uxvec ? xvec[0].elements.Flt : NULL;
     128  opihi_flt *uyptr = uyvec ? yvec[0].elements.Flt : NULL;
    66129
    67130  for (i = 0; i < xvec[0].Nelements; i++, xptr++, yptr++) {
     131    if (uXname) {
     132      if (pmBackwards) {
     133        TransformProperMotionBackwards (uxptr, uyptr, *uxptr, *uyptr, *xptr, *yptr, transform);
     134      } else {
     135        TransformProperMotionForewards (uxptr, uyptr, *uxptr, *uyptr, *xptr, *yptr, transform);
     136      }
     137      uxptr ++;
     138      uyptr ++;
     139    }
    68140    ApplyTransform (xptr, yptr, *xptr, *yptr, transform);
    69141  }
    70142
     143  FREE (transform);
    71144  return (TRUE);
    72145
     146escape:
     147  FREE (transform);
     148  return FALSE;
     149
    73150syntax:
    74   gprint (GP_ERR, "USAGE: csystems [C/G/E/H] [C/G/E/H] X Y\n");
    75   return (FALSE);
     151  gprint (GP_ERR, "USAGE   : csystems [C/G/E/H] [C/G/E/H] X Y [-pm uX uY] [-pmback ux uy]\n");
     152  gprint (GP_ERR, " -pm    : transform motions in source system to target system\n");
     153  gprint (GP_ERR, " -pmback: transform motions in target system to source system\n");
     154  gprint (GP_ERR, " e.g.   : csystem C G R D -pm uR uD -> R D will contain glon, glat; uR, uD will contain uL, uB\n");
     155  gprint (GP_ERR, " e.g.   : csystem C G R D -pmback uL uB -> R D will contain glon, glat; uL, uB will contain uR, uD\n");
     156  return FALSE;
    76157}
  • trunk/Ohana/src/opihi/cmd.astro/fitplx_irls.c

    r39585 r39591  
    123123  }
    124124  // FitPMandPar_IRLS sets the values of Wx,Wy based on the fit distance
     125
     126  if (VERBOSE && Nresample) {
     127    fprintf (stderr, "-- solution before resample --\n");
     128    fprintf (stderr, "Ro, Do: %f, %f +/- %f, %f (%f, %f)\n", Rmean, Dmean, fit.dRo, fit.dDo, fit.Ro, fit.Do);
     129    fprintf (stderr, "uR, uD: %f, %f; duR, duD: %f, %f\n", fit.uR, fit.uD, fit.duR, fit.duD);
     130    fprintf (stderr, "par: %f +/- %f\n", fit.p, fit.dp);
     131    fprintf (stderr, "chisq: %f Nfit %d\n", fit.chisq, fit.Nfit);
     132  }
    125133
    126134  // update the mask based on the input mask and the outlier limits.
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r39245 r39591  
    4848int objload                 PROTO((int, char **));
    4949int outline                 PROTO((int, char **));
     50int parallax_factor         PROTO((int, char **));
    5051int polar                   PROTO((int, char **));
    5152int precess                 PROTO((int, char **));
     
    117118  {1, "objload",     objload,      "plot obj data on Ximage "},
    118119  {1, "outline",     outline,      "fit outline region"},
     120  {1, "parallax_factor", parallax_factor, "generate parallax_factors"},
    119121  {1, "polar",       polar,        "convert polar image to cartesian"},
    120122  {1, "precess",     precess,      "precess coordinates"},
Note: See TracChangeset for help on using the changeset viewer.