Changeset 40661
- Timestamp:
- Mar 29, 2019, 6:29:50 PM (7 years ago)
- Location:
- branches/eam_branches/ohana.20190329/src/opihi
- Files:
-
- 5 edited
-
cmd.data/medimage_commands.c (modified) (4 diffs)
-
include/data.h (modified) (1 diff)
-
lib.data/MedImageOps.c (modified) (2 diffs)
-
lib.data/starfuncs.c (modified) (1 diff)
-
mana/deimos_mkobj.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20190329/src/opihi/cmd.data/medimage_commands.c
r40654 r40661 17 17 Buffer *image; 18 18 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"); 21 28 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"); 22 30 return FALSE; 23 31 } 24 32 25 33 if ((image = SelectBuffer (argv[2], OLDBUFFER, TRUE)) == NULL) return (FALSE); 34 35 XXX: match dimensions wit var image 26 36 27 37 MedImageType *median = FindMedImage (argv[1]); … … 48 58 int Ninput = median->Ninput; 49 59 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 } 54 71 55 72 return TRUE; … … 100 117 int Npix = ix + Nx*iy; 101 118 for (n = 0; n < Ninput; n++) { 102 float v = median-> buffers[n][Npix];119 float v = median->sig[n][Npix]; 103 120 if (!isfinite(v)) continue; 104 121 value[N] = v; … … 106 123 } 107 124 if (N == 0) continue; 125 126 XXXX: add in calc options: 127 weighted mean 128 irls 108 129 109 130 if (CALC_MEAN) { -
branches/eam_branches/ohana.20190329/src/opihi/include/data.h
r40642 r40661 48 48 int Nx; 49 49 int Ny; 50 float **buffers; 50 float **sig; 51 float **var; 51 52 } MedImageType; 52 53 -
branches/eam_branches/ohana.20190329/src/opihi/lib.data/MedImageOps.c
r36679 r40661 32 32 free (medimage[0].name); 33 33 for (i = 0; i < medimage[0].Ninput; i++) { 34 free (medimage[0]. buffers[i]);34 free (medimage[0].sig[i]); 35 35 } 36 free (medimage[0]. buffers);36 free (medimage[0].sig); 37 37 free (medimage); 38 38 } … … 75 75 medimage->Nx = Nx; 76 76 medimage->Ny = Ny; 77 ALLOCATE (medimage-> buffers, float *, 1);77 ALLOCATE (medimage->sig, float *, 1); 78 78 79 79 medimages[N] = medimage; -
branches/eam_branches/ohana.20190329/src/opihi/lib.data/starfuncs.c
r40398 r40661 75 75 FWHMx = 2.355*sqrt (fabs(x2 / I - x*x)); 76 76 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); 77 79 Sxy = xy / I - x*y; 78 80 mag = -2.5*log10(I); -
branches/eam_branches/ohana.20190329/src/opihi/mana/deimos_mkobj.c
r40659 r40661 6 6 7 7 // 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 9 10 // * profile : slit window profile (vector) 10 11 // * object : vector of object flux vs y-coord … … 18 19 19 20 // 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; 28 30 // add tilt later 29 31 30 Buffer *output = NULL;32 Buffer *output = NULL; 31 33 32 34 float stilt = 0.0; // angle of the slit 33 35 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); 37 44 remove_argument (N, &argc, argv); 38 45 } … … 82 89 83 90 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"); 85 94 return FALSE; 86 95 } … … 123 132 // if we are appying a trace offset spline, we need to generate an output window which 124 133 // is Nx + the full swing of the trace, then window back down 125 if ( trace) {134 if (slit_trace) { 126 135 float dXmin = +1000; 127 136 float dXmax = -1000; 128 137 for (int iy = 0; iy < Ny; iy++) { 129 138 // 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); 131 140 dXmin = MIN (dx, dXmin); 132 141 dXmax = MAX (dx, dXmax); … … 180 189 int Npof = floor(Nx/2); 181 190 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 } 182 196 183 197 // flux = obj * PSF + sky … … 329 343 330 344 // shift pixels in x based on the trace 331 if ( trace) {345 if (slit_trace) { 332 346 ALLOCATE_PTR (outTraceBuffer, char, NxBase*Ny*sizeof(float)); 333 347 float *outTrace = (float *) outTraceBuffer; … … 337 351 338 352 // 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); 340 354 341 355 // extract the integer pixel offset and the fractional offset
Note:
See TracChangeset
for help on using the changeset viewer.
