1 / 26

IDL - Data Input & Output

IDL - Data Input & Output. NCKU Phys. Cheng-Ling Kuo Johnny@phys.ncku.edu.tw. 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. IDL - File types. ASCII Files

Télécharger la présentation

IDL - Data Input & Output

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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

  3. IDL - File types • ASCII Files • Binary Files • Image Files • WAV Audio Files

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

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

  6. 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

  7. 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

  8. Low-level IDL’s IO • Formated / Unformatted • Formated • readf(read), printf(write) • Unformatted • readu, writeu

  9. 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

  10. 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")'

  11. 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\教育訓練及展示\IDL\io\format.txt“ IDL>head=‘’ IDL>name=‘’ & yy=0L & ss=0.0 IDL>readf, 1, format="(A30)", head IDL>readf, 1, format="(A10, 1X, I4, 4X, F10.5)", name, yy, ss IDL>Close, 1

  12. 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

  13. 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)

  14. Device • Device means graphics environment • Supported Devices CGM Computer Graphics Metafile HP Hewlett-Packard Graphics Language (HP-GL) LJ Digital Equipment LJ250 (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 PostScript REGIS Regis graphics protocol (DEC systems only) TEK Tektronix compatible terminal WIN Microsoft Windows X X Window System Z Z-buffer pseudo device

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

  16. 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.

  17. Device(win) • It can do? • VISUAL_DEPTH – color system • Font • Graphic function

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

  19. The color system • TrueColor (16-, 24-, or 32-bit)-Default IDL>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)’xl IDL>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)

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

  21. Image Input • Functions list: • read_bmp, read_jpeg, read_gif, read_tiff • Example • True color IDL>READ_JPEG, 'E:\RSI\IDL54\examples\data\rose.jpg', img24 • Color table IDL>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)

  22. Image display • True color IDL>Device, decomped=1 IDL>Tv, img24, true=1 • Color table IDL>Device, decomped=0 IDL>tvlct, r, g, b IDL>Tv, img8

  23. Read screen • True color IDL>Img24=tvrd(true=1) • Color table IDL>tvlct, r, g, b, /get IDL>img8=tvrd()

  24. 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

  25. 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

  26. 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

More Related