;pro parse_offset;, filename ;path = '/Users/bwgref/nustar/asic_screening/' ;filename = 'LOG10-15-09' ;filename = path+filename ; This reads in the 5 'images' of the ASIC, corresponding ; to the Vin = 0V, Vin = 2V, Pre-Amp, leakge, and DC offset. ; See fit_offset.pro for how to analyze this data and generate ; a FITS image that has all of the frames. ; Open file for reading openr, lun, filename, /get_lun temp = 'string' ; trim the header firstdigit = bytarr(5, 32, 32) secdigit = firstdigit pixeldc = fltarr(5, 32, 32) found = 0 while (~found) do begin temp = 'string' readf, lun, temp ; Search for PIXELDC. good = stregex(temp, 'PIXELDC') ; print, temp ; print, good if good eq -1 then continue found = 1 ; Reset temp as a single string: temp = 'string' ; Read off the blank line before the data: readf, lun, temp ; Now get the first data line readf, lun, temp temp = strsplit(temp, /extract) endwhile ; Since you already have temp loaded, just start the for loop here: for n = 0, 4 do begin for y = 0, 31 do begin for x = 0, 31 do begin ; The shift is because there's ; a date string at the beginning of ; every line first = (byte(temp[x+1]))[0] second = (byte(temp[x+1]))[1] ; If the character is a character, shift it to be contiguous ; with the decimal numbers if first ge 65 then first = first - 65 + 58 if second ge 65 then second = second - 65 + 58 ; Now change everything to be referenced to the ASCII code for '0' first -= 48 second -= 48 ; Translate back to decimal values pixeldc[n, x, y] = first*64.0 + 1.0*second endfor ; Get the next string. temp = 'string' readf, lun, temp temp = strsplit(temp, /extract) endfor ; Read off the empty space between the images temp = 'string' readf, lun, temp temp = strsplit(temp, /extract) endfor close,lun free_lun, lun ;save, dc_offset, file = 'offset_data.sav' end