;pro fit_offset ;restore, 'offset_data.sav' ; loads val, which is [frame, col, row] with ; frame = 0-4, row and col are both 0 - 31 ; Stored data are the digitized Vout. ; Convert val to Voltage range = 10.d nsteps = 4095.d res = range / nsteps ;volts = pixeldc * res volts = 3.* (pixeldc / ( 2.0^12.)) ; volts[0, *, *] is Vout with Vin set to 0 V ; volts[1, *, *] is Vout with Vin set to 2 V ; volts[2, *, *] is Preamp Output Volt (should be uniform and ~ 0.1 V) ; volts[3, *, *] is leakage (should be uniform and ~ 1.6 V) ; volts[4, *, *] is DC level at shaper (?) ; First thing is to generate a Vout -> Vin ; map, assuming linearity: ; Vin = m * Vout + offset ; 2 = m[*, *] * (volts[1, *, *] - volts[0, *, *]) ; m[*, *] = 2 / (volts[1, *, *] - volts[0, *, *]) ; offset = - m[*, *] * volts[0, *, *] slope = 2.d / (reform(volts[1, *, *]) - reform(volts[0, *, *])) offset = -slope * reform(volts[0, *, *]) for i = 2, 4 do volts[i, *, *] = volts[i, *, *] * slope + offset zerolevel = reform(volts[0, *, *]) raillevel = reform(volts[1, *, *]) preAmp = reform(volts[2, *, *]) leakage = reform(volts[3, *, *]) dclevel = reform(volts[4, *, *]) end