Changeset 40755
- Timestamp:
- May 27, 2019, 8:42:23 AM (7 years ago)
- Location:
- branches/eam_branches/ohana.20190329/src/opihi
- Files:
-
- 5 edited
-
cmd.data/medimage_commands.c (modified) (5 diffs)
-
include/data.h (modified) (1 diff)
-
lib.data/MedImageOps.c (modified) (2 diffs)
-
mana/deimos_fitprofile.c (modified) (2 diffs)
-
mana/deimos_mkslit.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20190329/src/opihi/cmd.data/medimage_commands.c
r40662 r40755 22 22 int N; 23 23 Buffer *image; 24 Buffer * sig= NULL;25 26 if ((N = get_argument (argc, argv, "- sigma"))) {27 remove_argument (N, &argc, argv); 28 if (( sig= SelectBuffer (argv[N], OLDBUFFER, TRUE)) == NULL) return (FALSE);24 Buffer *var = NULL; 25 26 if ((N = get_argument (argc, argv, "-variance"))) { 27 remove_argument (N, &argc, argv); 28 if ((var = SelectBuffer (argv[N], OLDBUFFER, TRUE)) == NULL) return (FALSE); 29 29 remove_argument (N, &argc, argv); 30 30 } 31 31 32 32 if (argc != 3) { 33 gprint (GP_ERR, "USAGE: medimage add (name) (image) [- sigma sigma]\n");33 gprint (GP_ERR, "USAGE: medimage add (name) (image) [-variance variance]\n"); 34 34 gprint (GP_ERR, " add the given image to the set of images to be medianed\n"); 35 35 gprint (GP_ERR, " optionally supply variance image (for weighted calculations)\n"); … … 39 39 if ((image = SelectBuffer (argv[2], OLDBUFFER, TRUE)) == NULL) return (FALSE); 40 40 41 if ( sig) {42 if (( sig->matrix.Naxis[0] != image->matrix.Naxis[0]) ||43 ( sig->matrix.Naxis[1] != image->matrix.Naxis[1])) {44 gprint (GP_ERR, " sigmabuffer does not match image buffer dimensions\n");41 if (var) { 42 if ((var->matrix.Naxis[0] != image->matrix.Naxis[0]) || 43 (var->matrix.Naxis[1] != image->matrix.Naxis[1])) { 44 gprint (GP_ERR, "variance buffer does not match image buffer dimensions\n"); 45 45 return FALSE; 46 46 } … … 68 68 // new image should match existing medimage dimensions 69 69 70 // AddMedImage (median, image, sig);70 // AddMedImage (median, image, var); 71 71 int Ninput = median->Ninput; 72 72 median->Ninput ++; 73 73 REALLOCATE (median->flx, float *, median->Ninput); 74 REALLOCATE (median-> sig, float *, median->Ninput);74 REALLOCATE (median->var, float *, median->Ninput); 75 75 76 76 ALLOCATE (median->flx[Ninput], float, median->Nx*median->Ny); 77 77 memcpy (median->flx[Ninput], image->matrix.buffer, sizeof(float)*median->Nx*median->Ny); 78 78 79 median-> sig[Ninput] = NULL;80 if ( sig) {81 ALLOCATE (median-> sig[Ninput], float, median->Nx*median->Ny);82 memcpy (median-> sig[Ninput], sig->matrix.buffer, sizeof(float)*median->Nx*median->Ny);79 median->var[Ninput] = NULL; 80 if (var) { 81 ALLOCATE (median->var[Ninput], float, median->Nx*median->Ny); 82 memcpy (median->var[Ninput], var->matrix.buffer, sizeof(float)*median->Nx*median->Ny); 83 83 } 84 84 … … 105 105 if (mode != CALC_MEDIAN) { gprint (GP_ERR, "supply only one of -mean, -irls, -wtmean\n"); return FALSE; } 106 106 mode = CALC_WTMEAN; 107 remove_argument (N, &argc, argv); 108 } 109 110 Buffer *variance = NULL; 111 if ((N = get_argument (argc, argv, "-variance"))) { 112 remove_argument (N, &argc, argv); 113 if ((variance = SelectBuffer (argv[N], ANYBUFFER, TRUE)) == NULL) return (FALSE); 107 114 remove_argument (N, &argc, argv); 108 115 } … … 145 152 val[N] = v; 146 153 wgt[N] = 1.0; 147 if (median-> sig[n]) {148 float s = median-> sig[n][Npix];154 if (median->var[n]) { 155 float s = median->var[n][Npix]; 149 156 if (!isfinite(s)) continue; 150 157 if (fabs(s) < 2*FLT_MIN) s = 2*FLT_MIN; 151 wgt[N] = 1.0 / SQ(s);158 wgt[N] = 1.0 / s; 152 159 } 153 160 N++; -
branches/eam_branches/ohana.20190329/src/opihi/include/data.h
r40662 r40755 49 49 int Ny; 50 50 float **flx; 51 float ** sig;51 float **var; 52 52 } MedImageType; 53 53 -
branches/eam_branches/ohana.20190329/src/opihi/lib.data/MedImageOps.c
r40662 r40755 33 33 for (i = 0; i < medimage[0].Ninput; i++) { 34 34 free (medimage[0].flx[i]); 35 FREE (medimage[0]. sig[i]);35 FREE (medimage[0].var[i]); 36 36 } 37 37 free (medimage[0].flx); 38 free (medimage[0]. sig);38 free (medimage[0].var); 39 39 free (medimage); 40 40 } … … 78 78 medimage->Ny = Ny; 79 79 ALLOCATE (medimage->flx, float *, 1); 80 ALLOCATE (medimage-> sig, float *, 1);80 ALLOCATE (medimage->var, float *, 1); 81 81 82 82 medimages[N] = medimage; -
branches/eam_branches/ohana.20190329/src/opihi/mana/deimos_fitprofile.c
r40754 r40755 78 78 79 79 float Sky_V = 0.0, BckL_V = 0.0, BckR_V = 0.0; 80 int Sky_N = 0, BckL_N = 0, BckR_N =0;80 float Sky_N = 0.0, BckL_N = 0.0, BckR_N = 0.0; 81 81 for (int i = 0; i < xprofile->Nelements; i++) { 82 if (!isfinite(wprofile->elements.Flt[i])) continue; 83 if (!isfinite(fprofile->elements.Flt[i])) continue; 84 float wt = 1 / SQ(wprofile->elements.Flt[i]); 82 85 if (xprofile->elements.Flt[i] < Xs) { 83 BckL_V += fprofile->elements.Flt[i] ;84 BckL_N + +;86 BckL_V += fprofile->elements.Flt[i]*wt; 87 BckL_N += wt; 85 88 continue; 86 89 } 87 90 if (xprofile->elements.Flt[i] > Xe) { 88 BckR_V += fprofile->elements.Flt[i] ;89 BckR_N + +;91 BckR_V += fprofile->elements.Flt[i]*wt; 92 BckR_N += wt; 90 93 continue; 91 94 } 92 Sky_V += fprofile->elements.Flt[i] ;93 Sky_N + +;95 Sky_V += fprofile->elements.Flt[i]*wt; 96 Sky_N += wt; 94 97 } 95 98 float Sky = Sky_V / Sky_N; … … 211 214 int Npts = 0; 212 215 for (int i = 0; i < NptsAll; i++) { 216 if (!isfinite(wprofile[i])) continue; 217 if (!isfinite(fprofile[i])) continue; 213 218 int keep = (mode == MODE_UPPER) ^ (xprofile[i] < limit); 214 219 if (keep) { -
branches/eam_branches/ohana.20190329/src/opihi/mana/deimos_mkslit.c
r40659 r40755 7 7 // input parameters: 8 8 // 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) 11 17 12 18 int N; 13 19 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; 19 26 20 27 // user-specified flux value (otherwise assumed to be 1) … … 40 47 } 41 48 42 if (argc != 4) { 43 gprint (GP_ERR, "USAGE: deimos mkslit (profile) (trace) (buffer) [-flux vector] [-fluxbins N] [-sky vector]\n"); 49 // for a red vs blu spline, we need to specify the split point 50 // XXX this is REALLY ad-hoc for Deimos. not sure how to make 51 // this more generic (need to define the ranges somewhere) 52 int redlimit = 4096; 53 if ((N = get_argument (argc, argv, "-redlimit"))) { 54 remove_argument (N, &argc, argv); 55 redlimit = atoi (argv[N]); 56 remove_argument (N, &argc, argv); 57 } 58 59 if (argc != 5) { 60 gprint (GP_ERR, "USAGE: deimos mkslit (profile) (trace_red) (trace_blu) (buffer) [-flux vector] [-fluxbins N] [-sky vector]\n"); 44 61 return FALSE; 45 62 } … … 51 68 52 69 // 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); 70 if ((profile = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 71 if ((trace_red = FindSpline (argv[2])) == NULL) return (FALSE); 72 if ((trace_blu = FindSpline (argv[3])) == NULL) return (FALSE); 73 if ((buff = SelectBuffer (argv[4], ANYBUFFER, TRUE)) == NULL) return (FALSE); 56 74 57 75 // define the output window … … 73 91 74 92 // evaluate the trace spline at this y-coord to find the x-coord offset of the profile center 93 Spline *trace = (iy < redlimit) ? trace_red : trace_blu; 75 94 float dx = spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy); 76 95
Note:
See TracChangeset
for help on using the changeset viewer.
