I think the easiest way to achieve your goals is to use the OPENR, READU, and FREE_LUN routine. The READU routine will data read binary files into IDL variables. For example give READU a float variable, it will assign the next four bytes of data in the open binary file to that variable. To skip bytes of data in the file you don't care about, you can create byte array where the number elements corresponds to the number bytes you want to skip. You can then use READU to assign the skipped data to this array. Below is an example program called "pro skip_example". In this example program, a binary file is written with three arrays (byte, float, double). 10 unnecessary bytes are written between these arrays using the variable "junk". The file is then read using the READU command. The unnecessary bytes are skipped using the variable "new_junk".
pro skip_example
junk = bytarr(10)
x = bindgen(10)
y = findgen(10)
z = dindgen(10)
openw, lun, 'testdata.dat', /get_lun
writeu, lun, x, junk
writeu, lun, y, junk
writeu, lun, z, junk
free_lun, lun
openr, lun, 'testdata.dat', /get_lun
newx = bytarr(10)
newy = fltarr(10)
newz = dblarr(10)
new_junk=bytarr(10)
readu, lun, newx, new_junk
readu, lun, newy, new_junk
readu, lun, newz, new_junk
print, newx, newy, newz
free_lun, lun
end
You may also want to try using the BINARY_TEMPLATE routine with READ_ASCII and the TEMPLATE keyword. BINARY_TEMPLATE displays a GUI which allows you to specify the format of your data.
|