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_mkmodel.c

    r41159 r41340  
    8686// generate a subimage of the full model for the range row - row + Ny
    8787// obj,sky,bck are subset vectors corresponding to the range row to row+Ny
    88 // the slit_trace_* and psf_trace refer to the full image starting at row
    89 float *deimos_make_model (opihi_flt *obj, opihi_flt *sky, opihi_flt *bck, Vector *psf, Vector *profile, Spline *slit_trace_red, Spline *slit_trace_blu, float redlimit, Spline *psf_trace, int Nx, int Ny, int row) {
    90 
    91   float *raw = deimos_make_straight_image (obj, sky, psf, psf_trace, Nx, Ny, row);
     88float *deimos_make_model (opihi_flt *obj, opihi_flt *sky, opihi_flt *bck, Vector *psf, Vector *profile, Spline *trace, int Nx, int Ny, int row) {
     89
     90  float *raw = deimos_make_straight_image (obj, sky, psf, Nx, Ny, row);
    9291  float *new = deimos_apply_tilt (raw, Nx, Ny);
    9392  deimos_apply_profile (profile, new, Nx, Ny);
    9493  deimos_add_background (bck, new, Nx, Ny, row);
    95   float *out = deimos_apply_trace (slit_trace_red, slit_trace_blu, redlimit, new, Nx, Ny, row);
     94  float *out = deimos_apply_trace (trace, new, Nx, Ny, row);
    9695
    9796  free (raw);
     
    105104// *** generate a raw image with no slit tilt and no trace offsets.  apply the PSF to the
    106105// object flux, add in the sky flux
    107 float *deimos_make_straight_image (opihi_flt *obj, opihi_flt *sky, Vector *psf, Spline *psf_trace, int Nx, int Ny, int row) {
     106float *deimos_make_straight_image (opihi_flt *obj, opihi_flt *sky, Vector *psf, int Nx, int Ny, int row) {
    108107  OHANA_UNUSED_PARAM(row);
    109108 
     
    114113
    115114  // Xref is a global supplied by the user (defaults to Nx/2 if < 0)
    116   int XoffRef = (int)(Xref - Npsf);
     115  int Xoff = (int)(Xref - Npsf);
    117116
    118117  // Nx : width of output window
     
    124123   
    125124    // we are generating the image for just the row range row to row+Ny
    126     // note that obj & sky are subset vectors for just this range of pixels
    127125    opihi_flt objVy = obj[iy]; // if we shift to using the row offset: obj[iy + row]
    128126    opihi_flt skyVy = sky[iy]; // if we shift to using the row offset: sky[iy + row]
    129127     
    130     // integral and fractional pixel offsets of PSF (none, by default)
    131     int dxi = 0;
    132     float dxf = 0.0, dxr = 1.0;
    133     int Xoff = XoffRef;
    134    
    135     if (psf_trace) {
    136       // the psf_trace is referenced against the full image, so we need to add row to iy:
    137       float dx = spline_apply_dbl (psf_trace->xk, psf_trace->yk, psf_trace->y2, psf_trace->Nknots, iy + row);
    138       dxi = floor(dx);
    139       dxf = dx - dxi;  // -1.7 -> +0.3, -0.5 -> +0.5, +0.5 ->+0.5, +1.7 -> +0.7
    140       dxr = 1 - dxf;
    141       Xoff += dxi;
    142       // fprintf (stderr, "%d: %f : %d\n", iy + row, dx, Xoff);
    143     }
    144 
    145     // if fractional offset is small, do not interpolate
    146     int doInterp = fabs(dxf) < 1e-5 ? FALSE : TRUE;
    147 
    148128    // flux = obj * PSF + sky
    149129    for (int ix = 0; ix < Nx; ix++) {
     
    156136      // only add in the flux if we are in range of the PSF
    157137      if ((n >= 0) && (n < NpsfFull)) {
    158         if (doInterp) {
    159           if ((n > 0) && (n < NpsfFull)) {
    160             if (isfinite(psfV[n]) && isfinite(psfV[n-1])) {
    161               value += objVy*psfV[n]*dxr + objVy*psfV[n-1]*dxf;
    162             }
    163           }
    164           if (n == 0) {
    165             if (isfinite(psfV[n])) {
    166               value += objVy*psfV[n]*dxr;
    167             }
    168           }
    169         } else {
    170           if (isfinite(psfV[n])) {
    171             value += objVy * psfV[n];
    172           }
    173         }
     138        value += objVy * psfV[n];
    174139      }
    175140      out[ix + iy*Nx] = value;
     
    254219
    255220// shift pixels in x based on the trace
    256 float *deimos_apply_trace (Spline *slit_trace_red, Spline *slit_trace_blu, float redlimit, float *input, int Nx, int Ny, int row) {
     221float *deimos_apply_trace (Spline *trace, float *input, int Nx, int Ny, int row) {
    257222
    258223  ALLOCATE_PTR (output, float, Nx*Ny);
     
    262227    // evaluate the trace spline at this y-coord to find the x-coord offset of the profile center
    263228    // NOTE: spline is evaluated at full dispersion coordinate
    264     int iy_full = iy + row;
    265     Spline *slit_trace = (iy_full < redlimit) ? slit_trace_red : slit_trace_blu;
    266     float dx = -spline_apply_dbl (slit_trace->xk, slit_trace->yk, slit_trace->y2, slit_trace->Nknots, iy_full);
     229    float dx = -spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy + row);
    267230     
    268231    // extract the integer pixel offset and the fractional offset
Note: See TracChangeset for help on using the changeset viewer.