;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 readf, lun, temp nlines = 0.d firstdigit = bytarr(5, 32, 32) secdigit = firstdigit for i = 0, 4 do begin ; read off the empty space temp = 'string' readf, lun, temp ; print, temp ; Now read in each line: for j = 0, 31 do begin temp = 'string' readf, lun, temp ; Just to make life easier, add a space at the end of the string temp = temp+' ' ; Translate to bytes tempbyte = byte(temp) ; Get the date: ; print, temp space = where(tempbyte eq 32, nspace) tempdate = string(tempbyte[0:min(space)]) entry = 0 for n =1, nspace - 1 do begin ; Skip double spaces if space[n] - space[n-1] eq 1 then continue ; Okay, so this is a little tricky. These are 16-bit words ; stored as two integer/characters ;The base 64 numbers use ascii characters to represent digit values ;0-63. The ascii characters for 0-9 ($30-$39) represent the digit values ;0-9. The ascii characters A-v ($41 through $76) represent the ;digit values 10 through 63. first = tempbyte[space[n-1]+1] second = tempbyte[space[n-1]+2] ; 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 ; Do the mapping firstdigit[i, entry, j] = first secdigit[i, entry, j] = second entry++ endfor endfor endfor close,lun free_lun, lun dc_offset = firstdigit*64l + 1l*secdigit ;save, dc_offset, file = 'offset_data.sav' end