function perf_vwbin, list_file, rawimg, qstop=qstop ; if (data_type(list_file) eq 7) then cl = rfits(list_file) $ else cl = list_file ; l = n_elements(cl) j = 0L p = 0 out = lonarr(30000) ;max size? nal = cl(2) print,nal table_start = 0 ;'7000'XL xvec_offset = (long(cl(16) and 'ffff'x) + $ (long(cl(17) and 'ffff'x) * '10000'x)) - table_start nx = cl(18) yvec_offset = (long(cl(19) and 'ffff'x) + $ (long(cl(20) and 'ffff'x) * '10000'x)) - table_start ny = cl(21) xvec = long(cl(xvec_offset:xvec_offset+nx-1)) yvec = long(cl(yvec_offset:yvec_offset+ny-1)) wt_table = lonarr(nx, ny) for ix = 0, nx-1 do begin wt_table (0, ix) = ishft ((xvec(ix) * yvec), -15) endfor ;print,wt_table shift_count = cl(25) and '7fff'x ; AND out the ms bit (Shift Flag) nerr = 0 for i=0,nal-1 do begin nextal = (i)*10+22 ix = (long(cl(nextal)) and 'ffff'x) + (long(cl(nextal+1) and 'ffff'x) * '10000'x) ixr = ix - table_start nent = cl(nextal + 2) ixre = ixr + nent*2 - 1 print, nextal,ix,ixr,table_start,nent,ixre,nerr,format='(i6,5z10, " nerr=", i6)' for j = ixr,ixre,2 do begin add = long(cl(j) and 'ffff'x) + (long(cl(j+1) and 'ffff'x) * '10000'x) if (add eq 0) then begin print, j, cl(j), cl(j+1) ;stop endif r = add / 1024 c = add mod 1024 if (r ge 1024) then begin nerr = 999 return, -1 end wtd_area = (rawimg(c:c+nx-1, r:r+ny-1) * wt_table(0:nx-1,0:ny-1)) rsample = 0D for ir = 0, ny-1 do for ic = 0, nx-1 do rsample = rsample + wtd_area(ic,ir) ;;;;sample = long(rsample / 2.^24) ;;;;sample = long(rsample / 2D^(15 + 16-shift_count+1)) ;15 for wt_table and then shift count sample = floor(rsample / 2D^(15 + 16-shift_count+1)) ;15 for wt_table and then shift count out(p) = sample ;why the +1 ??? p = p + 1 end if (keyword_set(qstop)) then stop end return, out(0:p-1) end