IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 16, 2020, 2:04:27 PM (6 years ago)
Author:
tdeboer
Message:

quick undo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/mana/deimos_mkslit.c

    r41340 r41341  
    77  // input parameters:
    88  //   slit profile response : vector of fractional flux vs x-coord
    9   //   trace                 : spline fit of slit central x pos vs y-coord
    10   //   flux                  : vector of input signal vs y-coord
     9  //   trace_ref,trace_blu   : spline fit of slit central x pos vs y-coord
     10  //   flux (optional)       : vector of input signal vs y-coord
     11  //   sky  (optional)       : vector of input signal vs y-coord
     12  //   fluxbins (optional)   : size of output image in y-direction
     13  //   NOTE: one of flux, sky, or fluxbins must be defined
     14
     15  // output : buff (an image with Nx defined by profile and Ny defined
     16  //                by flux, sky, or fluxbins)
    1117
    1218  int N;
    1319
    14   Vector *profile = NULL;
    15   Vector *flux    = NULL;
    16   Vector *sky     = NULL;
    17   Spline *trace   = NULL;
    18   Buffer *buff    = NULL;
     20  Vector *profile   = NULL;
     21  Vector *flux      = NULL;
     22  Vector *sky       = NULL;
     23  Spline *trace_red = NULL;
     24  Spline *trace_blu = NULL;
     25  Buffer *buff      = NULL;
    1926
    2027  // user-specified flux value (otherwise assumed to be 1)
     
    4047  }
    4148
    42   if (argc != 4) {
    43     gprint (GP_ERR, "USAGE: deimos mkslit (profile) (trace) (buffer) [-flux vector] [-fluxbins N] [-sky vector]\n");
     49  // either flux or fluxbins must be specified to define output size
     50  int profilebins = 0;
     51  if ((N = get_argument (argc, argv, "-profilebins"))) {
     52    remove_argument (N, &argc, argv);
     53    profilebins = atoi (argv[N]);
     54    remove_argument (N, &argc, argv);
     55  }
     56
     57  // for a red vs blu spline, we need to specify the split point
     58  // XXX this is REALLY ad-hoc for Deimos.  not sure how to make
     59  // this more generic (need to define the ranges somewhere)
     60  int redlimit = 4096;
     61  if ((N = get_argument (argc, argv, "-redlimit"))) {
     62    remove_argument (N, &argc, argv);
     63    redlimit = atoi (argv[N]);
     64    remove_argument (N, &argc, argv);
     65  }
     66
     67  if (argc != 5) {
     68    gprint (GP_ERR, "USAGE: deimos mkslit (profile) (trace_red) (trace_blu) (buffer) [-flux vector] [-fluxbins N] [-sky vector]\n");
    4469    return FALSE;
    4570  }
     
    5176
    5277  // XXX I probably should rename FindSpline as SelectSpline and give it the same behavior
    53   if ((profile = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    54   if ((trace   = FindSpline (argv[2])) == NULL) return (FALSE);
    55   if ((buff    = SelectBuffer (argv[3], ANYBUFFER, TRUE)) == NULL) return (FALSE);
     78  if ((profile   = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     79  if ((trace_red = FindSpline (argv[2])) == NULL) return (FALSE);
     80  if ((trace_blu = FindSpline (argv[3])) == NULL) return (FALSE);
     81  if ((buff      = SelectBuffer (argv[4], ANYBUFFER, TRUE)) == NULL) return (FALSE);
    5682
    5783  // define the output window
    58   int Nx = 2*profile[0].Nelements + 1;
     84  // if no profile half-width is specified, use supplied profile
     85  int Nx = profilebins ? 2*profilebins + 1 : 2*profile[0].Nelements + 1;
    5986  int Ny = flux ? flux[0].Nelements : fluxbins;
    6087 
     
    73100
    74101    // evaluate the trace spline at this y-coord to find the x-coord offset of the profile center
     102    Spline *trace = (iy < redlimit) ? trace_red : trace_blu;
    75103    float dx = spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy);
    76104   
     
    90118
    91119      // set the sky in the entire window
    92       out[ix + iy*Nx] = sky ? sky->elements.Flt[iy] : 0.0;
     120      out[ix + iy*Nx] = NAN;
    93121
    94122      // equivalent coord in the profile:
     
    98126
    99127      // a default value:
     128      float vsky = sky ? sky->elements.Flt[iy] : 0.0;
    100129      float vout = NAN;
    101130
     
    121150      if (flux) vout *= flux->elements.Flt[iy];
    122151
    123       out[ix + iy*Nx] += vout;
     152      out[ix + iy*Nx] = vsky + vout;
    124153    }
    125154  }
Note: See TracChangeset for help on using the changeset viewer.