IDL Data Input Output NCKU Phys ChengLing Kuo

  • Slides: 26
Download presentation
IDL - Data Input & Output NCKU Phys. Cheng-Ling Kuo Johnny@phys. ncku. edu. tw

IDL - Data Input & Output NCKU Phys. Cheng-Ling Kuo Johnny@phys. ncku. edu. tw

Data IO Data Stream n n Input: keyboard, input device Output: terminal, printer File

Data IO Data Stream n n Input: keyboard, input device Output: terminal, printer File – data is read from file and write to a file n Types: data, image, and any type of signals

IDL - File types ASCII Files Binary Files Image Files WAV Audio Files

IDL - File types ASCII Files Binary Files Image Files WAV Audio Files

ASCII & Binary ASCII n n Slower Portable Need more memory size Edited directly

ASCII & Binary ASCII n n Slower Portable Need more memory size Edited directly Binary n n Efficient Not portable Compact Not directly human readable

The two level of IDL’s IO High-Level n n Easy using and time efficient

The two level of IDL’s IO High-Level n n Easy using and time efficient Inflexible Low-Level n n Difficult and time-consuming Flexible

High-Level IDL’s IO Function list n File: w read_ascii(ascii_template) w read_binary(binary_template) n Image w

High-Level IDL’s IO Function list n File: w read_ascii(ascii_template) w read_binary(binary_template) n Image w read_bmp, read_jpeg, read_tiff n Sound w read_wave

Low-level IDL’s IO LUN(logic unit number) n File support limit 2. 3 GB w

Low-level IDL’s IO LUN(logic unit number) n File support limit 2. 3 GB w Adress up to 2^31 -1 bytes (32 -bit program) n n Range – 2 to 128 0, -1, -2 are stdin, stdout, stderr 1 -99: user specified 100 -128: managed by GET_LUN and FREE_LUN

Low-level IDL’s IO Formated / Unformatted n Formated w readf(read), printf(write) n Unformatted w

Low-level IDL’s IO Formated / Unformatted n Formated w readf(read), printf(write) n Unformatted w readu, writeu

Low-level IDL’s IO Manipulate files n n n openr, openw, openu Get detail information:

Low-level IDL’s IO Manipulate files n n n 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 Open files:

Low-level IDL’s IO Format n Fortran style w A(Character), D(double), F(float), I(integer), O(octal), Z(Hexadecimal)

Low-level IDL’s IO Format n Fortran style w A(Character), D(double), F(float), I(integer), O(octal), Z(Hexadecimal) w print, !PI, format='("I guess pi value is ", 1 X, F 24. 12)' n C style w %C(Character), D(double), F(float), I(integer), O(octal), Z(Hexadecimal) w print, !PI, format='(%"I guess pi value is %12. 4 f")'

Low-level IDL’s IO Formatted IO Name Years Salary ------------Johnny 2002 2000. 5 Ted 2003

Low-level IDL’s IO Formatted IO Name Years Salary ------------Johnny 2002 2000. 5 Ted 2003 1000. 5 Ken 2001 1500. 5 Command IDL>openr, 1, "D: doc教育訓練及展示IDLioformat. txt“ IDL>head=‘’ IDL>name=‘’ & yy=0 L & ss=0. 0 IDL>readf, 1, format="(A 30)", head IDL>readf, 1, format="(A 10, 1 X, I 4, 4 X, F 10. 5)", name, yy, ss IDL>Close, 1

Low-level IDL’s IO Unformatted IO n n Not portable because various machines have different

Low-level IDL’s IO Unformatted IO n n Not portable because various machines have different the representation of binary data XDR(portable) w Add extra bookkeeping information to stored in the file

Image Input&Output IDL’s Image Representation n n Pixel: byte(0 -255) Color System w RGB(Red,

Image Input&Output IDL’s Image Representation n n Pixel: byte(0 -255) Color System w RGB(Red, Green, Blue) w HLS(Hue, Lightness, and Saturation) w HSV(Hue, Saturation, and Value)

Device means graphics environment Supported Devices CGM Computer Graphics Metafile HP Hewlett-Packard Graphics Language

Device means graphics environment Supported Devices CGM Computer Graphics Metafile HP Hewlett-Packard Graphics Language (HP-GL) LJ Digital Equipment LJ 250 (VMS Only) MAC Macintosh display METAFILE Windows Metafile Format (WMF) NULL No graphics output PCL Hewlett-Packard Printer Control Language (PCL) PRINTER System printer PS Post. Script REGIS Regis graphics protocol (DEC systems only) TEK Tektronix compatible terminal WIN Microsoft Windows X X Window System Z Z-buffer pseudo device

Device select the graphic device n n Set_plot, “win” To check the system variable,

Device select the graphic device n n Set_plot, “win” To check the system variable, !d. name

Device Most keywords to the DEVICE procedure are sticky ? that is, once you

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.

Device(win) It can do? n n n VISUAL_DEPTH – color system Font Graphic function

Device(win) It can do? n n n VISUAL_DEPTH – color system Font Graphic function

Device(win) Which’s your system’s graphics environment n n n 24 bits 16 bits 8

Device(win) Which’s your system’s graphics environment n n n 24 bits 16 bits 8 bits Get your system’s visual depth IDL>device, get_visual_depth=depth IDL>print, depth

The color system True. Color (16 -, 24 -, or 32 -bit)-Default IDL>device, decomposed=1

The color system True. Color (16 -, 24 -, or 32 -bit)-Default IDL>device, decomposed=1 n Image IDL>READ_jpeg, 'C: Documents and SettingsjohnnyMy DocumentsMy PicturesSample. jpg', img) IDL>TV, img, true=1 n color indices to be interpreted as 3, 8 -bit color indices, ‘(bbggrr)’xl IDL>PLOT, [0, 1], col=‘ff 0000’xl Color. Table(8 bit) IDL>device, decomposed=0 (the least-significant 8 bits of the color index value to be interpreted as a Pseudo. Color index)

Color table Set palette n loadct, xloadct Show palette n xpalette Get color values

Color table Set palette n loadct, xloadct Show palette n xpalette Get color values of palette n tvlct, r, g, b, /get

Image Input Functions list: n read_bmp, read_jpeg, read_gif, read_tiff Example n True color IDL>READ_JPEG,

Image Input Functions list: n read_bmp, read_jpeg, read_gif, read_tiff Example n True color IDL>READ_JPEG, 'E: RSIIDL 54examplesdatarose. jpg', img 24 n Color table IDL>img 8 = READ_TIFF('E: RSIIDL 54examplesdataexamples. tif', r, g, b) IDL>img 8 = READ_PNG("E: RSIIDL 54examplesdataavhrr. png", r, g, b) IDL>img 8 = READ_BMP("c: winntGreenstone. bmp", r, g, b)

Image display True color IDL>Device, decomped=1 IDL>Tv, img 24, true=1 Color table IDL>Device, decomped=0

Image display True color IDL>Device, decomped=1 IDL>Tv, img 24, true=1 Color table IDL>Device, decomped=0 IDL>tvlct, r, g, b IDL>Tv, img 8

Read screen True color IDL>Img 24=tvrd(true=1) Color table IDL>tvlct, r, g, b, /get IDL>img

Read screen True color IDL>Img 24=tvrd(true=1) Color table IDL>tvlct, r, g, b, /get IDL>img 8=tvrd()

Image Output Functions list: n write_bmp, write_jpeg, write_gif, write_tiff Example n True color IDL>WRITE_TIFF,

Image Output Functions list: n write_bmp, write_jpeg, write_gif, write_tiff Example n 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", img 24, /rgb n Color table IDL>WRITE_TIFF, ‘test. tif', TVRD(), red=r, green=g, blue=b IDL>WRITE_BMP, "test. bmp", img 8, r, g, IDL>WRITE_PNG, "test. png", img 8, r, g, b

Postscript Device Set device = ps IDL> SET_PLOT, “ps” Setup device parameters IDL> DEVICE,

Postscript Device Set device = ps IDL> SET_PLOT, “ps” Setup device parameters IDL> DEVICE, file=“test. ps”, /color, /landscape Plot IDL>TVLCT, [0, 255, 0, 0], [0, 0, 255, 0], [0, 0, 0, 255] IDL> PLOT, [0, 1], color=1 Close device IDL> DEVICE, /close

Printer Device Set device = printer IDL> set_plot, “printer” Setup printer IDL>p= DIALOG_PRINTERSETUP() IDL>j=DIALOG_PRINTJOB()

Printer Device Set device = printer IDL> set_plot, “printer” Setup printer IDL>p= DIALOG_PRINTERSETUP() IDL>j=DIALOG_PRINTJOB() Plot IDL>TVLCT, [0, 255, 0, 0], [0, 0, 255, 0], [0, 0, 0, 255] IDL> PLOT, [0, 1], color=1 Close device IDL> device, /CLOSE_DOCUMENT