| BMP | GEO TIFF | Interfile |
| JPEG | NRIF | PICT |
| PNG | PPM | SRF |
| TIFF | XWD | X11 Bitmap |
| CDF | HDF |
| HDF-EOS | netCDF |
| ASCII | Binary | DICOM |
| DXF | WAV | XDR |
1. At the IDL Command Line, enter the following:plottemplate=ascii_template()2. Select the file "plot.txt" located in the data directory:/usr/local/rsi/idl_5.4/idl_5.4/examples/data/plot.txt3. The following dialog appears:

4. First we will choose the field type. Since we know our data file is delimited by tabs (or whitespace) select the Delimited button. Also, be sure to specify to begin reading the data at line 3, not line 1 in the Data Starts at Line field. This is because there are two comment lines at the beginning of the file. Click Next.You will see the following displayed in the Output Log:5. Now the following dialog box appears:
6. At this dialog, be sure to select Tab as the delimiter between data elements since we know we have used tabs in the original file. Now move on to the final dialog by clicking Next.
7. Now the following dialog box appears:
8. In this dialog, we will give a name to each data field for IDL to recognize each set. At the top of the box, click on the first row and then name the data set by typing the name Time for the first set in the box. Next, move on to the second row, naming this data set Temp1 for the first set of temperatures in the data set. Finally, name the last data set Temp2. Click Finish.
9. Type the following at the IDL Command Line to read in the file plot.txt using the template weve just created:
plot_ascii=read_ascii(filepath('plot.txt',subdir=['examples', 'data']), template= plottemplate)10. Then enter:print, plot_ascii
IDL> print, plot_ascii
{
11
12
13
14
15
16
17
18
19
2.90000 3.20000
6.00000 8.50000
9.20000 9.80000 12.7000
8.20000 5.80000
1.90000 3.90000
7.10000 7.30000
10.1000 8.90000 13.9000
7.20000 6.90000
}
Reading binary data can be done in much the same way as reading
ASCII data using the BINARY_TEMPLATE function in conjunction with the READ_BINARY
function. However, in order to show you different ways of using IDL,
we will use the READ_BINARY function alone. The binary file that
we will read in the following example contains an image of the Maroon Bells
mountains, a group of mountains located in the Rocky Mountains of Colorado,
stored as a binary integer array. To read in the binary data we use
the following command:
maroon_bells=read_binary('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/surface.dat', $Note: The dollar sign ($) at the end of the first line is the IDL continuation character. It allows you to enter long IDL commands as multiple lines.
data_dims=[350,450],data_type=2,endian='little')
In the READ_ASCII example, we used a macro to describe the filename by the path to the file (filepath('plot.txt',subdir=['examples', 'data'])). This doesn't work well when you start using data in your home directories. So, we just use the absolute filename '/usr/local/rsi/idl_5.4/idl_5.4/examples/data/surface.dat'.
In the READ_ASCII example, we used a template to describe the format of the data (template=plottemplate). Here, we have described the data using keywords (template was one keyword).
|
|
|
| 0 | Undefined |
| 1 | Byte |
| 2 | Integer |
| 3 | Longword Integer |
| 4 | Floating point |
| 5 | Double-precision floating |
| 6 | Complex |
| 7 | String |
| 8 | Structure |
| 9 | Double-precision complex |
| 10 | Pointer |
| 11 | Object reference |
| 12 | Unsigned Integer |
| 13 | Unsigned Longword Integer |
| 14 | 64-Bit Integer |
| 15 | Unsigned 64-Bit Integer |
Therefore, the dimension of the data is 350 by 450 ( data_dims=[350,450]), an integer array (data_type=2), and we selected Little Endian(endian='little'), since we know that this file was created on an Intel processor-based machine.
We now display the image by entering:
tvscl, maroon_bells

You can view an image in IDL with two different routines. The TV procedure writes an array to the display as an image without scaling. The TVSCL procedure displays the image with the color values scaled to use the whole color table.
1. Enter the following at the IDL Command Line:nyny=read_tiff('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/image.tif')2. Now display the image:tv,nyny

3. Now, using IDLs WRITE_TIFF command, rename and write the file:write_tiff,'copynyny.tif',nyny
| This information is available in alternative formats upon request by individuals with disabilities. Please send email to alt-format@msi.umn.edu or call 612-624-0528. | ||||||||||||
|
HOME
| QUESTIONS | FEEDBACK
|
||||||||||||
|
||||||||||||