IDL - Data Input & Output
-
Upload
peter-gibson -
Category
Documents
-
view
73 -
download
0
description
Transcript of IDL - Data Input & Output
![Page 2: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/2.jpg)
Data IO
Data Stream Input: keyboard, input device Output: terminal, printer
File – data is read from file and write to a file Types: data, image, and any type of
signals
![Page 3: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/3.jpg)
IDL - File types
ASCII FilesBinary FilesImage FilesWAV Audio Files
![Page 4: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/4.jpg)
ASCII & Binary
ASCII Slower Portable Need more memory size Edited directly
Binary Efficient Not portable Compact Not directly human readable
![Page 5: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/5.jpg)
The two level of IDL’s IO
High-Level Easy using and time efficient Inflexible
Low-Level Difficult and time-consuming Flexible
![Page 6: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/6.jpg)
High-Level IDL’s IO
Function list File:
read_ascii(ascii_template) read_binary(binary_template)
Image read_bmp, read_jpeg, read_tiff
Sound read_wave
![Page 7: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/7.jpg)
Low-level IDL’s IO
LUN(logic unit number) File support limit 2.3 GB
Adress up to 2^31-1 bytes (32-bit program) Range –2 to 128 0, -1, -2 are stdin, stdout, stderr 1-99: user specified 100-128: managed by GET_LUN and FREE
_LUN
![Page 8: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/8.jpg)
Low-level IDL’s IO
Formated / Unformatted Formated
readf(read), printf(write) Unformatted
readu, writeu
![Page 9: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/9.jpg)
Low-level IDL’s IO
Manipulate files Open files: openr, openw, openu Get detail information: fstat Position the file pointer(unit byte): point_lun Check end-of-file: eof Close files: close IDL current open files: help, /files
![Page 10: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/10.jpg)
Low-level IDL’s IO
Format Fortran style
A(Character), D(double), F(float), I(integer), O(octal), Z(Hexadecimal)
print, !PI, format='("I guess pi value is ", 1X, F24.12)'
C style %C(Character), D(double), F(float), I(integer),
O(octal), Z(Hexadecimal) print, !PI, format='(%"I guess pi value is %12.4f")'
![Page 11: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/11.jpg)
Low-level IDL’s IO
Formatted IOName Years Salary-------------------------Johnny 2002 2000.5Ted 2003 1000.5Ken 2001 1500.5
CommandIDL>openr, 1, "D:\doc\ 教育訓練及展示 \IDL\io\format.txt“IDL>head=‘’IDL>name=‘’ & yy=0L & ss=0.0IDL>readf, 1, format="(A30)", headIDL>readf, 1, format="(A10, 1X, I4, 4X, F10.5)", name, yy, ssIDL>Close, 1
![Page 12: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/12.jpg)
Low-level IDL’s IO
Unformatted IO Not portable because various
machines have different the representation of binary data
XDR(portable) Add extra bookkeeping information to
stored in the file
![Page 13: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/13.jpg)
Image Input&Output
IDL’s Image Representation Pixel: byte(0-255) Color System
RGB(Red, Green, Blue) HLS(Hue, Lightness, and Saturation) HSV(Hue, Saturation, and Value)
![Page 14: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/14.jpg)
Device
Device means graphics environmentSupported Devices
CGM Computer Graphics MetafileHP Hewlett-Packard Graphics Language (HP-GL)LJ Digital Equipment LJ250 (VMS Only)MAC Macintosh displayMETAFILE Windows Metafile Format (WMF)NULL No graphics outputPCL Hewlett-Packard Printer Control Language (PCL)PRINTER System printerPS PostScriptREGIS Regis graphics protocol (DEC systems only)TEK Tektronix compatible terminalWIN Microsoft Windows X X Window SystemZ Z-buffer pseudo device
![Page 15: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/15.jpg)
Device
select the graphic device Set_plot, “win” To check the system variable, !
d.name
![Page 16: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/16.jpg)
Device
Most keywords to the DEVICE procedure are sticky ?that is, once you set them, they remain in effect until you explicitly change them again, or end your IDL session.
![Page 17: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/17.jpg)
Device(win)
It can do? VISUAL_DEPTH – color system Font Graphic function
![Page 18: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/18.jpg)
Device(win)
Which’s your system’s graphics environment 24bits 16bits 8bits
Get your system’s visual depthIDL>device, get_visual_depth=depthIDL>print, depth
![Page 19: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/19.jpg)
The color system
TrueColor (16-, 24-, or 32-bit)-DefaultIDL>device, decomposed=1 Image
IDL>READ_jpeg,'C:\Documents and Settings\johnny\My Documents\My Pictures\Sample.jpg', img)IDL>TV, img, true=1
color indices to be interpreted as 3, 8-bit color indices, ‘(bbggrr)’xlIDL>PLOT, [0,1], col=‘ff0000’xl
ColorTable(8bit)IDL>device, decomposed=0
(the least-significant 8 bits of the color index value to be interpreted as a PseudoColor index)
![Page 20: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/20.jpg)
Color table
Set palette loadct, xloadct
Show palette xpalette
Get color values of palette tvlct, r, g, b, /get
![Page 21: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/21.jpg)
Image Input
Functions list: read_bmp, read_jpeg, read_gif, read_tiff
Example True colorIDL>READ_JPEG, 'E:\RSI\IDL54\examples\data\rose.jpg', img24 Color tableIDL>img8 = READ_TIFF('E:\RSI\IDL54\examples\data\examples.tif', r, g, b)IDL>img8 = READ_PNG("E:\RSI\IDL54\examples\data\avhrr.png", r, g, b)IDL>img8 = READ_BMP("c:\winnt\Greenstone.bmp", r,g,b)
![Page 22: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/22.jpg)
Image display
True colorIDL>Device, decomped=1IDL>Tv, img24, true=1
Color tableIDL>Device, decomped=0IDL>tvlct, r, g, bIDL>Tv, img8
![Page 23: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/23.jpg)
Read screen
True colorIDL>Img24=tvrd(true=1)
Color tableIDL>tvlct, r, g, b, /getIDL>img8=tvrd()
![Page 24: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/24.jpg)
Image Output
Functions list: write_bmp, write_jpeg, write_gif, write_tiff
Example True color
IDL>WRITE_TIFF, ‘test.tif', TVRD(true=1)IDL>WRITE_JPEG, ‘test.jpg', TVRD(true=1), true=1
IDL>WRITE_BMP, "test.bmp",img24, /rgb Color table
IDL>WRITE_TIFF, ‘test.tif', TVRD(), red=r, green=g, blue=b IDL>WRITE_BMP, "test.bmp",img8, r, g,
IDL>WRITE_PNG, "test.png",img8, r, g, b
![Page 25: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/25.jpg)
Postscript Device
Set device = psIDL> SET_PLOT, “ps”
Setup device parametersIDL> DEVICE, file=“test.ps”, /color, /landscape
PlotIDL>TVLCT, [0,255,0,0], [0,0,255,0], [0,0,0,255]IDL> PLOT, [0,1], color=1
Close deviceIDL> DEVICE, /close
![Page 26: IDL - Data Input & Output](https://reader036.fdocuments.net/reader036/viewer/2022062300/56812ba4550346895d8fd62f/html5/thumbnails/26.jpg)
Printer Device
Set device = printerIDL> set_plot, “printer”
Setup printerIDL>p= DIALOG_PRINTERSETUP()IDL>j=DIALOG_PRINTJOB()
PlotIDL>TVLCT, [0,255,0,0], [0,0,255,0], [0,0,0,255]IDL> PLOT, [0,1], color=1
Close deviceIDL> device, /CLOSE_DOCUMENT