Changeset 41341 for trunk/Ohana/src/opihi/mana/deimos_mkslit.c
- Timestamp:
- Apr 16, 2020, 2:04:27 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/mana/deimos_mkslit.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/mana/deimos_mkslit.c
r41340 r41341 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 // 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"); 44 69 return FALSE; 45 70 } … … 51 76 52 77 // 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); 56 82 57 83 // 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; 59 86 int Ny = flux ? flux[0].Nelements : fluxbins; 60 87 … … 73 100 74 101 // 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; 75 103 float dx = spline_apply_dbl (trace->xk, trace->yk, trace->y2, trace->Nknots, iy); 76 104 … … 90 118 91 119 // 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; 93 121 94 122 // equivalent coord in the profile: … … 98 126 99 127 // a default value: 128 float vsky = sky ? sky->elements.Flt[iy] : 0.0; 100 129 float vout = NAN; 101 130 … … 121 150 if (flux) vout *= flux->elements.Flt[iy]; 122 151 123 out[ix + iy*Nx] +=vout;152 out[ix + iy*Nx] = vsky + vout; 124 153 } 125 154 }
Note:
See TracChangeset
for help on using the changeset viewer.
