Markwardt IDL Page

What's New

   Curve Fitting
   Fitting Tutorial
   Save Files
   Full Listing


Markwardt IDL Pages
Entire Web

Craig's techie blog.

Home Page of Craig Markwardt


IDL Input / Output

FLORMAT - Format a string with named format variables

The function FLORMAT is used to easily insert a set of named parameters into a string using simple format codes. The key point is that format strings use named parameters instead of the position in the string.

FLORMAT makes it easy to make maintainable and understandable format codes. FLORMAT is a convenience routine, which will be most suitable for formatting tabular output, but can be used for any complicated string formatting job where the positional parameters of STRING() become hard to manage. Users of Python will recognize FLORMAT as implementing "string interpolation."

The user passes a format string similar to the IDL printf-style format string (i.e. using modified "%" notation), and a set of named fields either by passing a structure, keywords, or both. The output strings are composed by inserting the named fields into the format string with any requested formatting.

The function FLORMAT is equivalent to the STRING(...,FORMAT=fmt) method of formatting a string, where the format string is allowed to have the name of the variable.

For example consider formatting a time with hours, minutes and seconds into a string as HH:MM:SS. One could use FLORMAT() like this,

   result = flormat('%(hour)02d:%(min)02d:%(sec)02d', $
                    hour=hour, min=min, sec=sec)

The variables HOUR, MIN and SEC are allowed to be scalars or vectors. The key point here is that the format string contains the named keyword variables (or structure entries). Unlike STRING(), the actual variables can be passed in any order, since the format string itself describes in what order the values will be assembled. This is similar to string interpolation in Python.

The same variable can appear multiple times in the format string, but the user only need to specify that variable once. For example,

   result = flormat('<A="%(href)s">Download %(href)s</A>', $

Note that HREF appears twice in the format string.
Apr 18 201313 kb  

PRINTLOG - Captures a transcript of console output

PRINTLOG captures and archives a copy of any output sent to the console. PRINTLOG is used exactly like PRINT and sends its output to the screen as expected. However, it additionally saves a verbatim copy of the output. This can be especially useful if an independent session log is needed (like JOURNAL), or if a strict transaction history is required. In order to use this procedure, you must change your code to use PRINTLOG instead of PRINT, and maintain a string variable which holds the log.

Nov 23 20036 kb  

TRANSREAD - Read ASCII tables quickly and with ease

TRANSREAD parses an ASCII table into IDL variables, one variable for each column in the table. The tabular data is not limited to numerical values, and can be processed with an IDL FORMAT expression.

TRANSREAD behaves similarly to READF/READS in that it transfers ASCII input data into IDL variables. The difference is that TRANSREAD reads more than one row in one pass, and returns data by column. In a sense, it forms the transpose of the typical output from READF or READS (which returns data by row), hence the name TRANSREAD.

Feature highlights include:

  • FORMAT expression is optionally accepted.
  • Comment lines can optionally be recognized and ignored.
  • Standalone operation. No other IDL procedures are needed.
  • Input is either a file unit or a string array.
  • Start and Stop "Cue" Phrases can be used to begin and end the parsing operation.
  • Extensive documentation is included in the header of TRANSREAD.PRO itself.
Dec 21 201118 kb  

PATHUTILS - Form relative and normalized file path names

The routines RELPATH and NORMPATH are used to construct relative and normalized file system path names. RELPATH constructs a relative path between two files or directories. For example, the relative path from /path/to/directory/one to /path/to/file/two is ../../file/two.

NORMPATH normalizes a path so that the shortest possible path is returned, and relative path components are removed if possible. For example, the path /path/to/directory/one/../file/two can be normalized to /path/to/file/two. If an absolute path is not possible, then the shortest relative path is returned.

Both routines should be system independent, but have been tested on Unix.

Mar 29 20083 kb  
Mar 29 20085 kb  

FXGPKG - Read and seek on pipes like normal files (Unix)

This is an embryonic library of routines which will read, write, and seek on arbitrary Unix streams such as pipes and URLs. The most important thing is the seek capability, which allows you to address any point in the stream with random access rather than sequential access.

At present, only Unix pipes are accessible. Eventually it is desired to be able to read from generic URLs and shared memory using third party such as CURL. The current implementation is to store the contents of the Unix pipe in a temporary cache file. Unfortunately, the input/output is limited to unformatted binary content.

All of the routines are required, and you may wish to download the entire archive in one file as either a gzip'ed tar file or zip file.

The routines are internally documented, but you should probably start with FXGOPEN.PRO.

May 24 201214 kb fxgpkg.tar.gzTar Archive  
May 24 201226 kb fxgpkg.zipZip Archive  
May 05 200911 kb  
Sep 06 20072 kb  
Sep 06 20073 kb  
Sep 06 20073 kb  
Sep 06 20072 kb  
Sep 06 20072 kb  
May 24 20123 kb  
May 24 20126 kb  
Sep 06 20074 kb  
May 05 20091 kb  
May 24 20121 kb  
May 24 20127 kb  
Mar 25 20012 kb  
Mar 25 20011 kb  

Copyright © 1997-2010 Craig B. Markwardt
Last Modified on 2013-08-14 10:55:25 by Craig Markwardt