IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40661


Ignore:
Timestamp:
Mar 29, 2019, 6:29:50 PM (7 years ago)
Author:
eugene
Message:

working on deimos

Location:
branches/eam_branches/ohana.20190329/src/opihi
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20190329/src/opihi/cmd.data/medimage_commands.c

    r40654 r40661  
    1717  Buffer *image;
    1818
    19   if (argc != 3) {
    20     gprint (GP_ERR, "USAGE: medimage add (name) (image)\n");
     19  Buffer *var = NULL;
     20  if ((N = get_argument (argc, argv, "-var"))) {
     21    remove_argument (N, &argc, argv);
     22    if ((var = SelectBuffer (argv[N], OLDBUFFER, TRUE)) == NULL) return (FALSE);
     23    remove_argument (N, &argc, argv);
     24  }
     25
     26  if (argc != 3) {
     27    gprint (GP_ERR, "USAGE: medimage add (name) (image) [-var var]\n");
    2128    gprint (GP_ERR, "       add the given image to the set of images to be medianed\n");
     29    gprint (GP_ERR, "       optionally supply variance image (for weighted calculations)\n");
    2230    return FALSE;
    2331  }
    2432
    2533  if ((image = SelectBuffer (argv[2], OLDBUFFER, TRUE)) == NULL) return (FALSE);
     34
     35XXX: match dimensions wit var image
    2636
    2737  MedImageType *median = FindMedImage (argv[1]);
     
    4858  int Ninput = median->Ninput;
    4959  median->Ninput ++;
    50   REALLOCATE (median->buffers, float *, median->Ninput);
    51 
    52   ALLOCATE (median->buffers[Ninput], float, median->Nx*median->Ny);
    53   memcpy (median->buffers[Ninput], image->matrix.buffer, sizeof(float)*median->Nx*median->Ny);
     60  REALLOCATE (median->sig, float *, median->Ninput);
     61  REALLOCATE (median->var, float *, median->Ninput);
     62
     63  ALLOCATE (median->sig[Ninput], float, median->Nx*median->Ny);
     64  memcpy (median->sig[Ninput], image->matrix.buffer, sizeof(float)*median->Nx*median->Ny);
     65
     66  median->var[Ninput] = NULL;
     67  if (var) {
     68    ALLOCATE (median->var[Ninput], float, median->Nx*median->Ny);
     69    memcpy (median->var[Ninput], var->matrix.buffer, sizeof(float)*median->Nx*median->Ny);
     70  }
    5471
    5572  return TRUE;
     
    100117      int Npix = ix + Nx*iy;
    101118      for (n = 0; n < Ninput; n++) {
    102         float v = median->buffers[n][Npix];
     119        float v = median->sig[n][Npix];
    103120        if (!isfinite(v)) continue;
    104121        value[N] = v;
     
    106123      }
    107124      if (N == 0) continue;
     125
     126    XXXX: add in calc options:
     127      weighted mean
     128      irls
    108129
    109130      if (CALC_MEAN) {
  • branches/eam_branches/ohana.20190329/src/opihi/include/data.h

    r40642 r40661  
    4848  int Nx;
    4949  int Ny;
    50   float **buffers;
     50  float **sig;
     51  float **var;
    5152} MedImageType;
    5253
  • branches/eam_branches/ohana.20190329/src/opihi/lib.data/MedImageOps.c

    r36679 r40661  
    3232  free (medimage[0].name);
    3333  for (i = 0; i < medimage[0].Ninput; i++) {
    34     free (medimage[0].buffers[i]);
     34    free (medimage[0].sig[i]);
    3535  }
    36   free (medimage[0].buffers);
     36  free (medimage[0].sig);
    3737  free (medimage);
    3838}
     
    7575  medimage->Nx = Nx;
    7676  medimage->Ny = Ny;
    77   ALLOCATE (medimage->buffers, float *, 1);
     77  ALLOCATE (medimage->sig, float *, 1);
    7878
    7979  medimages[N] = medimage;
  • branches/eam_branches/ohana.20190329/src/opihi/lib.data/starfuncs.c

    r40398 r40661  
    7575  FWHMx = 2.355*sqrt (fabs(x2 / I - x*x));
    7676  FWHMy = 2.355*sqrt (fabs(y2 / I - y*y));
     77
     78  fprintf (stderr, "Mxx, Myy: %f, %f\n", x2/I - x*x, y2/I - y*y);
    7779  Sxy   = xy / I - x*y;
    7880  mag = -2.5*log10(I);
  • branches/eam_branches/ohana.20190329/src/opihi/mana/deimos_mkobj.c

    r40659 r40661  
    66
    77  // input parameters:
    8   // * trace       : spline fit of slit central x pos vs y-coord
     8  // * slit_trace  : spline fit of slit central x pos vs y-coord
     9  // * psf_trace   : spline fit of psf central x pos vs y-coord
    910  // * profile     : slit window profile (vector)
    1011  // * object      : vector of object flux vs y-coord
     
    1819
    1920  // if any of these are not defined, they will have assumed identity values
    20   Spline *trace   = NULL;
    21   Vector *profile = NULL;
    22   Vector *object  = NULL;
    23   Vector *sky     = NULL;
    24   Vector *backgnd = NULL;
    25 
    26   Vector *psf     = NULL;
    27   Vector *lsf     = NULL;
     21  Spline *slit_trace = NULL;
     22  Spline *psf_trace  = NULL;
     23  Vector *profile    = NULL;
     24  Vector *object     = NULL;
     25  Vector *sky        = NULL;
     26  Vector *backgnd    = NULL;
     27                     
     28  Vector *psf        = NULL;
     29  Vector *lsf        = NULL;
    2830  // add tilt later
    2931
    30   Buffer *output  = NULL;
     32  Buffer *output     = NULL;
    3133
    3234  float stilt = 0.0; // angle of the slit
    3335
    34   if ((N = get_argument (argc, argv, "-trace"))) {
    35     remove_argument (N, &argc, argv);
    36     if ((trace = FindSpline (argv[N])) == NULL) return (FALSE);
     36  if ((N = get_argument (argc, argv, "-slit-trace"))) {
     37    remove_argument (N, &argc, argv);
     38    if ((slit_trace = FindSpline (argv[N])) == NULL) return (FALSE);
     39    remove_argument (N, &argc, argv);
     40  }
     41  if ((N = get_argument (argc, argv, "-psf-trace"))) {
     42    remove_argument (N, &argc, argv);
     43    if ((psf_trace = FindSpline (argv[N])) == NULL) return (FALSE);
    3744    remove_argument (N, &argc, argv);
    3845  }
     
    8289
    8390  if (argc != 3) {
    84     gprint (GP_ERR, "USAGE: deimos mkobj (buffer) (Ncross) [-Nwave N] [-object vector] [-sky vector] [-backgnd vector] [-trace spline] [-profile vector]\n");
     91    gprint (GP_ERR, "USAGE: deimos mkobj (buffer) (Ncross) [-Nwave N] [-object vector] [-sky vector] [-backgnd vector] [-slit-trace spline] [-psf-trace spline] [-profile vector]\n");
     92    gprint (GP_ERR, "  psf-trace : cross-dispersion shift *relative* to the slit trace\n");
     93    gprint (GP_ERR, "  sky       : sky is relative to background outside slit\n");
    8594    return FALSE;
    8695  }
     
    123132  // if we are appying a trace offset spline, we need to generate an output window which
    124133  // is Nx + the full swing of the trace, then window back down
    125   if (trace) {
     134  if (slit_trace) {
    126135    float dXmin = +1000;
    127136    float dXmax = -1000;
    128137    for (int iy = 0; iy < Ny; iy++) {
    129138      // evaluate the trace spline at this y-coord to find the x-coord offset of the profile center
    130       float dx = spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy);
     139      float dx = spline_apply_dbl (slit_trace->xk, slit_trace->yk, slit_trace->y2, slit_trace->Nknots, iy);
    131140      dXmin = MIN (dx, dXmin);
    132141      dXmax = MAX (dx, dXmax);
     
    180189    int Npof = floor(Nx/2);
    181190    if (psf) Npof -= Npsf;
     191
     192    if (psf_trace) {
     193      float dx = -spline_apply_dbl (psf_trace->xk, psf_trace->yk, psf_trace->y2, psf_trace->Nknots, iy);
     194      Npof += dx;
     195    }
    182196
    183197    // flux = obj * PSF + sky
     
    329343
    330344  // shift pixels in x based on the trace
    331   if (trace) {
     345  if (slit_trace) {
    332346    ALLOCATE_PTR (outTraceBuffer, char, NxBase*Ny*sizeof(float));
    333347    float *outTrace = (float *) outTraceBuffer;
     
    337351
    338352      // evaluate the trace spline at this y-coord to find the x-coord offset of the profile center
    339       float dx = -spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy);
     353      float dx = -spline_apply_dbl (slit_trace->xk, slit_trace->yk, slit_trace->y2, slit_trace->Nknots, iy);
    340354     
    341355      // extract the integer pixel offset and the fractional offset
Note: See TracChangeset for help on using the changeset viewer.