Re: IDL/PV-Wave - Can they strip headers in binary files? [message #1237] |
Fri, 18 June 1993 13:26 |
ft
Messages: 4 Registered: May 1993
|
Junior Member |
|
|
In article <9306171303.AA03092@tigermoth.aero.gla.ac.uk.gla.ac.uk> gnaa38@aero.gla.ac.uk (Paul Porcelli) writes:
> Could someone tell me how IDL or PV-Wave copes with dislaying data from a
> binary file which has a a header of various types (ie int,float,string) and
> which also defines the number of records in the file.
> Would the header have to be stripped first by another program?
> I am specifically interested in how easy it is to read from a file of
> this type and ouput the data in a graphical format(ie plot etc).
> Are any of the two products more suited to this task?
> Any help will be greatly appreciated.
In PV-Wave (and maybe IDL too, I haven't used it) you can use the assoc()
command to associate a binary file with a variable, including parsing of the
binary data into array structures, and skipping of header data. Eg:
avar=assoc(lun,bytarr(512,512),1024B)
Where lun is the unit number of an opened file, the byte array is the
desired parsing format of the data, and 1024B skips 1024 bytes of header in
the file. Then, you can access chunks of the file as:
image1=avar(0) ; first 512x512 byte image
image2=avar(1) ; second...
The data is not read from the file until the associated variable is assigned
to something else (which can be done in a command, like: "tv,avar(0)". As I
understand it, the offset and the array structure can be specified as any
data type (byte, int, long, float, etc), so you can parse the file as you
like.
Then, you can use any of the image commands (tv,tvscl,rot,fft,etc) on the
array structure (if it's an image).
PV-Wave also has precut commands for reading various graphics formats (in
version 4.1 - I understand there will be more of these in 4.2 in a few
months):
dc_read_8_bit(filename) ; read 8 bit raster file
dc_read_24_bit(filename) ; read 24 bit raster file
dc_read_tiff(filename) ; read TIFF format image (no jpg support tho)
> Paul Porcelli
> Technical Programmer
> Dept of Aerospace Engineering
> University of Glasgow
> Tel: 041-339-8855 (x4345)
--
Fred True
AT&T
ft@maxwell.ccs.att.com
ftrue@attmail.com
|
|
|
Re: IDL/PV-Wave - Can they strip headers in binary files? [message #1242 is a reply to message #1237] |
Fri, 18 June 1993 06:18  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
gnaa38@aero.gla.ac.uk (Paul Porcelli) writes:
> Could someone tell me how IDL or PV-Wave copes with dislaying data from a
> binary file which has a a header of various types (ie int,float,string) and
> which also defines the number of records in the file.
> Would the header have to be stripped first by another program?
> I am specifically interested in how easy it is to read from a file of
> this type and ouput the data in a graphical format(ie plot etc).
> Are any of the two products more suited to this task?
> Any help will be greatly appreciated.
> Thanks.
IDL and PV-wave both have the same kind of I/O capabilities as a
third-generation language such as FORTRAN and C. (In fact, FORTRAN-style
FORMAT specifications are supported.) This means that you can write a fairly
simple routine to read in and parse the header and data in your table.
Routines for some standard file formats, such as FITS, have already been
written using standard IDL/PV-wave calls. However, it's a fairly simple matter
to write a reader routine yourself if you know what the format of the file is.
Once you've read the data into arrays, you can then plot it in the normal
matter.
Both IDL and PV-wave are likely to be equally capable in reading files. In
fact, a program written in one will probably work in the other.
Bill Thompson
|
|
|