IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 16, 2020, 1:54:47 PM (6 years ago)
Author:
tdeboer
Message:

revert to working Ohana build

File:
1 edited

Legend:

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

    r41159 r41340  
    66
    77  // input parameters:
    8   // * slit_trace_red : spline fit of slit central x pos vs y-coord for red chip
    9   // * slit_trace_blu : spline fit of slit central x pos vs y-coord for blu chip
    10   // * psf_trace      : spline fit of psf central x pos vs y-coord
    11   // * profile        : slit window profile (vector)
    12   // * object         : vector of object flux vs y-coord
    13   // * sky            : vector of local sky signal vs y-coord
    14   // * backgnd        : vector of extra-slit background flux vs y-coord
    15   // * PSF            : point-spread function vector (flux normalized, x-dir)
    16   // * LSF            : sline-spread function vector (flux normalized, y-dir)
    17   // * stilt          : slit tilt response : 2D kernel?
    18 
    19   // * redlimit       : pixel break between red and blu chips
    20   // * Nwave          : number of wavelength pixels in output image
     8  // * trace       : spline fit of slit central x pos vs y-coord
     9  // * profile     : slit window profile (vector)
     10  // * object      : vector of object flux vs y-coord
     11  // * sky         : vector of local sky signal vs y-coord
     12  // * background  : vector of extra-slit background flux vs y-coord
     13  // * PSF         : point-spread function vector (flux normalized, x-dir)
     14  // * LSF         : sline-spread function vector (flux normalized, y-dir)
     15  // * stilt       : slit tilt response : 2D kernel?
    2116
    2217  int N;
    2318
    2419  // if any of these are not defined, they will have assumed identity values
    25   Spline *slit_trace_red = NULL;
    26   Spline *slit_trace_blu = NULL;
    27   Spline *psf_trace  = NULL;
    28   Vector *profile    = NULL;
    29   Vector *object     = NULL;
    30   Vector *sky        = NULL;
    31   Vector *backgnd    = NULL;
    32                      
    33   Vector *psf        = NULL;
    34   Vector *lsf        = NULL;
     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;
    3528  // add tilt later
    3629
    37   Buffer *output     = NULL;
     30  Buffer *output  = NULL;
    3831
    3932  float stilt = 0.0; // angle of the slit
    4033
    41   // for a red vs blu spline, we need to specify the split point
    42   // XXX this is REALLY ad-hoc for Deimos.  not sure how to make
    43   // this more generic (need to define the ranges somewhere)
    44   int redlimit = 4096;
    45   if ((N = get_argument (argc, argv, "-redlimit"))) {
    46     remove_argument (N, &argc, argv);
    47     redlimit = atoi (argv[N]);
    48     remove_argument (N, &argc, argv);
    49   }
    50 
    51   if ((N = get_argument (argc, argv, "-slit-trace-red"))) {
    52     remove_argument (N, &argc, argv);
    53     if ((slit_trace_red = FindSpline (argv[N])) == NULL) return (FALSE);
    54     remove_argument (N, &argc, argv);
    55   }
    56   if ((N = get_argument (argc, argv, "-slit-trace-blu"))) {
    57     remove_argument (N, &argc, argv);
    58     if ((slit_trace_blu = FindSpline (argv[N])) == NULL) return (FALSE);
    59     remove_argument (N, &argc, argv);
    60   }
    61   if ((N = get_argument (argc, argv, "-psf-trace"))) {
    62     remove_argument (N, &argc, argv);
    63     if ((psf_trace = FindSpline (argv[N])) == NULL) return (FALSE);
     34  if ((N = get_argument (argc, argv, "-trace"))) {
     35    remove_argument (N, &argc, argv);
     36    if ((trace = FindSpline (argv[N])) == NULL) return (FALSE);
    6437    remove_argument (N, &argc, argv);
    6538  }
     
    10881  }
    10982
    110   int VERBOSE = FALSE;
    111   if ((N = get_argument (argc, argv, "-v"))) {
    112     remove_argument (N, &argc, argv);
    113     VERBOSE = TRUE;
    114   }
    115 
    11683  if (argc != 3) {
    117     gprint (GP_ERR, "USAGE: deimos mkobj (buffer) (Ncross) [-object vector] [-sky vector] [-backgnd vector] [-slit-trace-red spline] [-slit-trace-blu spline] [-psf-trace spline] [-profile vector] [-psf vector] [-lsf vector] [-stilt angle] [-Nwave Npixel] [-redlimit pixel]\n");
    118     gprint (GP_ERR, "  slit_trace_red : spline fit of slit central x pos vs y-coord for red chip\n");
    119     gprint (GP_ERR, "  slit_trace_blu : spline fit of slit central x pos vs y-coord for blu chip\n");
    120     gprint (GP_ERR, "  psf_trace      : spline fit of psf central x pos vs y-coord\n");
    121     gprint (GP_ERR, "  profile        : slit window profile (vector)\n");
    122     gprint (GP_ERR, "  object         : vector of object flux vs y-coord \n");
    123     gprint (GP_ERR, "  sky            : vector of local sky signal vs y-coord\n");
    124     gprint (GP_ERR, "  backgnd        : vector of extra-slit background flux vs y-coord\n");
    125     gprint (GP_ERR, "  PSF            : point-spread function vector (flux normalized, x-dir)\n");
    126     gprint (GP_ERR, "  LSF            : sline-spread function vector (flux normalized, y-dir)\n");
    127     gprint (GP_ERR, "  stilt          : slit tilt response : 2D kernel? \n");
    128     gprint (GP_ERR, "  redlimit       : pixel break between red and blu chips\n");
    129     gprint (GP_ERR, "  Nwave          : number of wavelength pixels in output image\n");
     84    gprint (GP_ERR, "USAGE: deimos mkobj (buffer) (Ncross) [-Nwave N] [-object vector] [-sky vector] [-backgnd vector] [-trace spline] [-profile vector]\n");
    13085    return FALSE;
    13186  }
     
    168123  // if we are appying a trace offset spline, we need to generate an output window which
    169124  // is Nx + the full swing of the trace, then window back down
    170   if (slit_trace_red && slit_trace_blu) {
     125  if (trace) {
    171126    float dXmin = +1000;
    172127    float dXmax = -1000;
    173128    for (int iy = 0; iy < Ny; iy++) {
    174129      // evaluate the trace spline at this y-coord to find the x-coord offset of the profile center
    175       Spline *slit_trace = (iy < redlimit) ? slit_trace_red : slit_trace_blu;
    176       float dx = spline_apply_dbl (slit_trace->xk, slit_trace->yk, slit_trace->y2, slit_trace->Nknots, iy);
     130      float dx = spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy);
    177131      dXmin = MIN (dx, dXmin);
    178132      dXmax = MAX (dx, dXmax);
     
    227181    if (psf) Npof -= Npsf;
    228182
    229     // integral and fractional pixel offsets of PSF (none, by default)
    230     int dxi = 0;
    231     float dxf = 0.0, dxr = 1.0;
    232    
    233     if (psf_trace) {
    234       float dx = spline_apply_dbl (psf_trace->xk, psf_trace->yk, psf_trace->y2, psf_trace->Nknots, iy);
    235       dxi = floor(dx);
    236       dxf = dx - dxi;  // -1.7 -> +0.3, -0.5 -> +0.5, +0.5 ->+0.5, +1.7 -> +0.7
    237       dxr = 1 - dxf;
    238       Npof += dxi;
    239       // fprintf (stderr, "%d: %f : %d\n", iy, dx, Npof);
    240       if (VERBOSE && (iy % 200 == 0)) { gprint (GP_ERR, "%d : %f : %d : %f %f\n", iy, dx, dxi, dxf, dxr); }
    241     }
    242 
    243     // if fractional offset is small, do not interpolate
    244     int doInterp = fabs(dxf) < 1e-5 ? FALSE : TRUE;
    245 
    246183    // flux = obj * PSF + sky
    247184    for (int ix = 0; ix < Nx; ix++) {
     
    254191        // only add in the flux if we are in range of the PSF
    255192        if ((n >= 0) && (n < NpsfFull)) {
    256           if (doInterp) {
    257             if ((n > 0) && (n < NpsfFull)) {
    258               if (isfinite(psfV[n]) && isfinite(psfV[n-1])) {
    259                 value += objVy*psfV[n]*dxr + objVy*psfV[n-1]*dxf;
    260               }
    261             }
    262             if (n == 0) {
    263               if (isfinite(psfV[n])) {
    264                 value += objVy*psfV[n]*dxr;
    265               }
    266             }
    267           } else {
    268             if (isfinite(psfV[n])) {
    269               value += objVy*psfV[n];
    270             }
    271           }
     193          value += objVy * psfV[n];
    272194        }
    273195      } else {
     
    407329
    408330  // shift pixels in x based on the trace
    409   if (slit_trace_red && slit_trace_blu) {
     331  if (trace) {
    410332    ALLOCATE_PTR (outTraceBuffer, char, NxBase*Ny*sizeof(float));
    411333    float *outTrace = (float *) outTraceBuffer;
     
    415337
    416338      // evaluate the trace spline at this y-coord to find the x-coord offset of the profile center
    417       Spline *slit_trace = (iy < redlimit) ? slit_trace_red : slit_trace_blu;
    418       float dx = -spline_apply_dbl (slit_trace->xk, slit_trace->yk, slit_trace->y2, slit_trace->Nknots, iy);
     339      float dx = -spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy);
    419340     
    420341      // extract the integer pixel offset and the fractional offset
Note: See TracChangeset for help on using the changeset viewer.