1 / 7

IDL Tutorials Day 4 Henry (Trae) Winter winter@physics.montana solar.physics.montana/winter/idl_tutorial/2003/index.html

IDL Tutorials Day 4 Henry (Trae) Winter winter@physics.montana.edu http://solar.physics.montana.edu/winter/idl_tutorial/2003/index.html. Today’s Topics. Writing and reading to a text file Using the FORMAT keyword. Opening a Textfile.

pepper
Download Presentation

IDL Tutorials Day 4 Henry (Trae) Winter winter@physics.montana solar.physics.montana/winter/idl_tutorial/2003/index.html

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 Tutorials Day 4 Henry (Trae) Winter winter@physics.montana.edu http://solar.physics.montana.edu/winter/idl_tutorial/2003/index.html

  2. Today’s Topics • Writing and reading to a text file • Using the FORMAT keyword

  3. Opening a Textfile • First you have to open a file. This is done with some variation of the open command. • openr ;Opens a file to read. • openw ;Opens a file to write. • openu ;Opens a file for updates. Syntax: >openw,lun,”filename.ext”, /OPTIONAL_KEYWORDS lun: A number or a variable containing a number for the “logical unit number”. Just a way for IDL to manage files • Important keywords • /APPEND ;Starts writing at the end of an existing file instead of overwriting the file. • /GET_LUN ;IDL assigns a number for the variable lun

  4. Writing to a Textfile • Once the file is open you can write to it just like writing to the screen, except you use the printf procedure Syntax: >printf, lun, “Stuff to be printed” ,”More stuff”, FORMAT=“(2A12)” • Once your finished with the file you need to close it >close, lun ;Closes the file associated with lun >close, /ALL ;Closes all open files

  5. Using the FORMAT Keyword • The FORMAT keyword allows you to format the data output Syntax: >…, FORMAT=‘(5A6)’ Formats the next 5 strings with six characters each >…, FORMAT=‘(3F7.3)’ Formats the next 3 numbers. 7 total digits (including a minus sign if needed, and decimal) and 3 digits past the decimal point. >…, FORMAT=‘(3D7.3)’ Does the same as above except with double precision >…, FORMAT=‘(2A6, 1D7.2, A5)’ The expressions in the print statement will be formatted: First two are strings, 6 characters each. Next expression is a double with 7 total characters and 2 past the decimal. The last is a string with 5 characters

  6. Reading a Textfile • Open a file using the openr procedure • Ascii files can be read with a wide array of procedures and functions. • Most common is readf >readf,lun,var1,var2, FORMAT=‘(some format)’ • Once your finished with the file you need to close it, again.

  7. Homework Assignment • Download extract_text to your directory • Rename it something uniq • Put a header template on it and fill it out • Make documentation notes about what each line does.

More Related