filespec_common $SSW_SMEI_UCSD/gen/idl/toolbox/files/filespec_common.pro
[Previous] [Next]
 NAME:
	filespec_common
 PURPOSE:
	Contains common block used by filespec procedures
 CATEGORY:
	String manipulation
 CALLING SEQUENCE:
	@filespec_common.pro
 INCLUDED BY:
	PutFileSpec, SetFileSpec
 PROCEDURE:
	File is set by SetFileSpec and updated by PutFileSpec
	File is used read-only by GetFileSpec
	Parts is used read-only by PutFileSpec and GetFileSpec
 MODIFICATION HISTORY:
	JUL-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


FindAllFiles $SSW_SMEI_UCSD/gen/idl/toolbox/files/findallfiles.pro
[Previous] [Next]
 NAME:
	FindAllFiles
 PURPOSE:
	Extended version of FindFile for locating file satisfying
	a list of file specs in a list of directories.
	FindAllFiles is intended to be robust; it is slow compared
	to a direct call to findfile.
 CATEGORY:
	Environment
 CALLING SEQUENCE:
	FUNCTION FindAllFiles, FilesIn	    , $
	    paths	    = PathsIn	    , $
	    count	    = count	    , $
	    separator	    = Separator     , $
	    shortnames	    = ShortNames    , $
	    nodirectories   = NoDirectories , $
	    recursive	    = Recursive     , $
	    symlink	    = symlink	    , $
	    excl_files	    = excl_files    , $
	    excl_paths	    = excl_paths    , $
	    excl_recursive  = excl_recursive, $
	    forcecd	    = ForceCD	    , $
	    ls_style	    = ls_style
 INPUTS:
	Files		list of file specifications, specified as
			a comma-separated list, or a string array
			(default: *.*, NOT *)
 OPTIONAL INPUT PARAMETERS:
	paths=Paths	list of directories to be searched, specified
			as a separated list, or a string array
			(if omitted then the current directory is assumed)

	separator=Separator
			separator used between entries in Files and Paths
	/shortname	if set then only file name, type (and version
			on vms) are returned (default: return fully
			qualified names)
	/recursive	search recursively through all subdirectories
	/symlink	(only on Unix/Linux systems when /recursive is set)
			by default, a recursive search does not descent into
			directories that are symbolic links. If /symlink is
			set then it will (see "IsSymLink").
	/nodirectories	discards directories, i.e. only regular files are
			returned.
	/forcecd	THIS HAS ONLY BEEN TESTED ON LINUX.
			by default the IDL findfile function is called with
			argument of type full_dir+file_name_wildcard.
			The array returned by findfile will then also contain
			fully-qualified filenames. In deeply nested directories
			with lots of matching files findfile may return nothing
			at all (probably because some memory buffer overflows).
			Setting /force_cd will first cd into 'full_dir', then
			do a findfile with only file_name_wildcard. Findfile will
			only return file names (without a directory). 'Full_dir'
			is then explicitly prefixed to the output of findfile.
			This may prevent the buffer overflow.
	/ls_style	passed to findfile_fix. If set then the content
			of subdirectories is included.

	Three additional keywords allow files and/or paths to be excluded:

	excl_files=excl_files
			list of file specifications similar to 'Files'
	excl_paths=excl_paths
			list of directories similar to 'Paths'
	/excl_recursive
			triggers a recursive search similar to '/recursive'

	These three keyword are used as input for a recursive call to
	FindAllFiles. The result is subtracted from the files matching
	found using 'Files' and 'Paths'

 OUTPUTS:
	Result		string array with filenames; if no files are found then
			files is set to the null string (files='')
 OPTIONAL OUTPUT PARAMETERS:
	count=count	number of files located
 INCLUDE:
	@compile_opt.pro	; On error return to caller
 CALLS: ***
	FILEPATH, FindAllSubDirs, GetFileSpec, InitVar, IsType, SetFileSpec, os_separator
	unique_only, where_common
 CALLED BY:
	SetFileSpec, qView_FileFilter, qView_PickFiles, skyd_cat, smei_base_testcase
	smei_buf_getframe, smei_getfile, smei_hdr_update, smei_mkbase, smei_mkcal_auto
	smei_mkorb, smei_mkorb_auto, smei_mksky, smei_rewind, smei_star_split
	smei_star_update, smei_www_skymaps, vu_select, www_help_files
 SIDE EFFECTS:
 >	windows: Directories . and .. are omitted
	Trailing delimiter for directories are stripped off
 >	If both Files and Paths are specified as arrays then Separator is
	not used.

	The findfile function on Linux sometimes shows peculiar behavior
	(similar to the Unix ls command). Problems can arise when searching
	a directory with containing only one subdirectory; or when the
	directory contains a symbolic link.
 PROCEDURE:
	Separator is OS dependent: ',' on VMS and Win32, ' ' on all other
	Each entry in the Files list can contain a directory specification;
	in that case the Paths keyword is not used for that entry.
 MODIFICATION HISTORY:
	???-????, Paul Hick (UCSD/CASS)
	AUG-2000, Paul Hick (UCSD/CASS)
	    Added /recursive keyword
	JUN-2001, Paul Hick (UCSD/CASS)
	    Added /symlink
	JAN-2002, Paul Hick (UCSD/CASS)
	    Added exclusion keywords
	SEP-2002, Paul Hick (UCSD/CASS)
	    On Linux output from the IDL findfile function is now filtered
	    through findfile_fix to deal with directories.
	    (this may actually be necessary for all Unix flavors)
	    Added /forcecd and /ls_style keywords. Added check to exclude
	    wildcards in the directory paths.
	MAR-2003, Paul Hick (UCSD/CASS)
	    Improved processing of FileIn=''. This now should handle directories
	    with lots of files better (at least on Linux) by avoiding the used
	    of an explicit wildcard (*.*) in the call to findfile.
	FEB-2004, Paul Hick (UCSD/CASS)
	    Changed check for !version.os to check for !version.os_family.
	    Makes this hopefully it bit more generally useful.
	OCT-2004, Paul Hick (UCSD/CASS)
	    Modified handling of a path specification without a filename.
	    Windows didn't handle the Linux solution correctly.
	OCT-2006, Paul Hick (UCSD/CASS)
	    Added forcecd keyword to FindAllSubDirs call
	JUL-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Replaced findfile by file_search
	    Keyword /forcecd is now ignored.


FindAllSubDirs $SSW_SMEI_UCSD/gen/idl/toolbox/files/findallsubdirs.pro
[Previous] [Next]
 NAME:
	FindAllSubDirs
 PURPOSE:
	Return a list of all subdirectories in a specified directory
 CATEGORY:
	Environment
 CALLING SEQUENCE:
	FUNCTION FindAllSubDirs, Path, $
	    count	= count      , $
	    symlink	= symlink    , $
	    recursive	= recursive  , $
	    forcecd	= ForceCD
 INPUTS:
	Path		scalar; type: string; default: current directory
 OPTIONAL INPUT PARAMETERS:
	/symlink	by default, symbolic links to directories are not returned
			unless /symlink is set (ignored on non-unix systems;
			see IsSymLink.
 OUTPUTS:
	List		array; type: string
			    list of subdirectories
			    fully-qualified directory names are returned.
			    on Linux and Win32 the directories include the trailing (back)slash
			    if no subdirectories are found then List = '' is returned.
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			    number of subdirectories
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, GetFileSpec, InitVar, IsSymLink, SetFileSpec
 CALLED BY:
	FindAllFiles, findfile_fix, mk_flick, smei_mkdrives, www_help_tree
 RESTRICTIONS:
	Currently linux, Win32 and vms are implemented.
 PROCEDURE:
	Findfile is used to get a list of files in the specified directories. Then the
	directories are selected.
 MODIFICATION HISTORY:
	AUG-2000, Paul Hick (UCSD/CASS)
	JUN-2001, Paul Hick (UCSD/CASS)
	    added /symlink keyword
	JAN-2002, Paul Hick (UCSD/CASS)
	    Return arg 'count' didn't exist on return if 'path' didn't exist.
	    Now zero is returned.
	JUL-2002, Paul Hick (UCSD/CASS)
	    Fixed a bug caused by peculiar behaviour of IDL findfile on Linux
	    (and presumably every Unix flavor) when a directory is tested
	    containing only a single subdirectory. This apparently reflects
	    the same peculiar behaviour of the Unix 'ls' command.
	MAR-2003, Paul Hick (UCSD/CASS)
	    Added /recursive keyword
	SEP-2006, Paul Hick (UCSD/CASS)
	    Added some code to deal with spaces in directory names (adding
	    explicit quotes). Moved initvar statement for Path to start of function.
	OCT-2006, Paul Hick (UCSD/CASS)
	    Added forcecd keyword.
	JUL-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Replaced findfile by file_search (for unix only). Lot less complicated.
	    Note that /forcecd is no longer used (and if set, is ignored).


findfile_fix $SSW_SMEI_UCSD/gen/idl/toolbox/files/findfile_fix.pro
[Previous] [Next]
 NAME:
	findfile_fix
 PURPOSE:
	Applies fix to output from IDL findfile procedure.
 CATEGORY:
	gen/toolbox/files
 CALLING SEQUENCE:
	FUNCTION findfile_fix, dir, file, old_files, count=count, ls_style=ls_style
 INPUTS:
	path
	file
	old_files   array; type: string
		    Output from findfile
 OPTIONAL INPUT PARAMETERS:
	count=count scalar; type: integer
		    Output from findfile (# files)
 OUTPUTS:
	result	    array; type: string
		    Corrected 'old_files' array
 OPTIONAL OUTPUT PARAMETERS:
	count=count scalar; type: integer
		    # entries in new_files
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FindAllSubDirs, GetFileSpec, InitVar, SetFileSpec, where_common
 PROCEDURE:
	This is kludging at its best. On Linux (maybe even all Unix
	flavors??) a findfile call with a wildcard (in particular a
	single star) can pick up subdirectories:
	    files = findfile('path/*')
	The result is a string array of the form:
	    full_file_1
	    full_file_2
	    ..
	    full_file_n
	    (blank line)
	    full_subdir_1:	(sub dir name followed by colon)
	    file_1_in_subdir_1	(file name without directory)
	    file_2_in_subdir_1	(file name without directory)
	    ..
	    file_n_in_subdir_1	(file name without directory)
	    (blank Line)
	    full_subdir_2:	(sub dir name followed by colon)
	    etc.

	The list of full_file_n at the beginning may not be present.
	Moreover, if only one subdirectory matches the template then
	full_subdir_1 will be missing too, and only the list
	file_n_in_subdir_1 remains. In this last case it is impossible
	to reconstruct the full file names. An attempt is made to recover
	the name of the subdirectory using FindAllSubdirs. If not
	successful then these entries (the whole list of files) is discarded.

	If it is possible to reconstruct full paths, two approaches
	are possible depending on the setting of /ls_style.
	If /ls_style is NOT set, then all entries inside subdirectories
	are discarded, and only the subdirectory name itself is returned.

	If /ls_style IS set, then the content of subdirectories is also
	returned (converted to full paths by prefixing the names of the
	subdirectory). Blank lines are always removed.
 MODIFICATION HISTORY:
	SEP-2002, Paul Hick (UCSD/CASS)
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added a fix to make sure subdirectories have a trailing slash
	    when output from findfile with only a directory (no filename)
	    as argument is processed.


FindPeaks $SSW_SMEI_UCSD/gen/idl/toolbox/findpeaks.pro
[Previous] [Next]
 NAME:
	FindPeaks
 PURPOSE:
	Find local maxima in 2D array
 CATEGORY:
	smei/gen/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION FindPeaks, Box , $
	    mask    = Mask	, $
	    npeak   = npeak	, $
	    flat    = flat	, $
	    relative= relative	, $
	    map     = Map	, $
	    fraction= fraction	, $
	    untested= untested	, $
	    mindist = mindist	, $
	    count   = count
 INPUTS:
	Box	    2D array, any type
 OPTIONAL INPUT PARAMETERS:
	mask=Mask   1D or 2D array, type integer, default: no mask (includes all elements)
			Elements outside the mask are ignored
			1D array: list of indices defining the area in Box to be searched
			for maxima.
			    !!! A 1-element mask MUST be entered as an array of 1-element.
				A scalar is ignored, so put brackets around the input
				argument if necessary)
			2D array: array of same dimensions as Box with value 1 defining
			    the mask and value 0 outside the mask.
	fraction=fraction
		    scalar; same type as input array; default: 1.0
			fraction between 0 and 1. Only this fraction of the image inside
			the mask is searched for local maxima.
	mindist=mindist
		    scalar; type: any; default: 0
			minimum distance between local maxima. Local maxima closer then
			mindist to a higher local maximum are included with the higher
			maximum.
	npeak=npeak scalar; type: integer
			Maximum number of local maxima to be detected. By default the
			whole array is searched for all maxima. If npeak is set then the
			search is interrupted when npeak local maxima have been found.
			In this case the 'map' array will be partially filled with the
			value returned in 'untested' to indicate that this part of Box
			has not been searched for maxima.
	flat=flat   scalar; same type as input array.
			In determing whether neigbour pixels are above/at/below the
			central pixel of a 3x3 group of pixels, above/at/below are defined
			as follows:
			    below:  Vneighbour < Vcenter-flat
			    at	 :  Vcenter-flat <= Vneigbour <= Vcenter+flat
			    above:  Vneighbour > Vcenter+flat
			In a 'noisy' map setting flat to a positive value, suppresses the
			detection of lots of unwanted local maxima. (Probably the same can be
			accomplished by applying the IDL smooth function to the input
			argument Box before calling this function.)
 OUTPUTS:
	Peaks	    1D array, type integer
			Indices of local maxima inside area defined by mask
 OPTIONAL OUTPUT PARAMETERS:
	map=Map     2D array, type long integer, same dimension as Box
			Provisionally divides Box into areas associated with each
			local maxima. The index from the Peaks array is used
			in Map to indicate the associated maximum
	untested=untested
		    value used to indicate untested areas in Box (see npeak keyword)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, boost, where_common
 CALLED BY:
	smei_findpnt
 PROCEDURE:
	The entire input image is searched for local maxima. This very quickly
	takes and intolarably long time. Usually keywords fraction and/or npeak need
	to be used to get results reasonably quick.
 MODIFICATION HISTORY:
	OCT-1998, Paul Hick (UCSD/CASS)
	JAN-2003, Paul Hick (UCSD/CASS)
	    Fixed problems with local maxima of equal height. Added keywords npeak,
	    untested and flat. Significant speedup by processing groups of up to
	    nine pixels (3x3 group) instead of only single pixels.
	FEB-2008, Paul Hick (UCSD/CASS)
	    Modified to deal with NaN in Box (always excluded from Mask)
	    Bugfix.


flat_centerofmass $SSW_SMEI_UCSD/gen/idl/toolbox/flat_centerofmass.pro
[Previous] [Next]
 NAME:
	flat_centerofmass
 PURPOSE:
	Calculations related to the centroid of a flat density distribution
 CATEGORY:
	gen/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION flat_centerofmass, box, centroid   , $
	    polar	= polar 	, $
	    shift_origin= shift_origin	, $
	    degrees	= degrees

	R = flat_centerofmass(box [, /polar, /degrees])
		Returns centroid of 'box'
	R = flat_centerofmass(box ,/shift_origin [, /polar, /degrees])
		Returns coordinate of 'box' relative to its centroid
	R = flat_centerofmass(box , centroid [, /polar, /degrees])
		Positions box with its centroid matching 'centroid'
 INPUTS:
	If /polar NOT set:
	box	    array[2,2]; type: integer
			defines two corners of box in the form [ [x1,y1], [x2,y2] ]

	If /polar set:
	box	    array[2,2]; type: float
			limiting values in phase angle and radius of the wedge
			in the form [[angle1,radius1],[angle2,radius2]].
			Angle1 and angle2 are in radians between [-!pi,+!pi].
			The wedge runs counterclockwise from 'angle1' to 'angle2'
			over less than 180 degrees: either angle2 > angle1 with
			angle2-angle1 < !pi or angle2 < angle1 with
			angle2+2*!pi-angle1 < !pi. Always radius1 < radius2.
 OPTIONAL INPUT PARAMETERS:
	centroid    array[2]; type: float or integer
			position of centroid in rectangular (if /polar NOT set)
			or polar (if /polar set) coordinates. If this argument is specified
			then box is positioned with its centroid on this point.
	/polar	    if set, box and centroid is specified in polar coordinates
			(default: rectangular coordinates)
	/shift_origin
		    if set, then the centroid of 'box' is calculated. Then the coordinates
			of 'box' relative to this center are returned.
	/degrees    if set, in- and output angles are in degrees (default: radians)
 OUTPUTS:
	R	    array[2]
		    array[2,2]
 INCLUDE:
	@compile_opt.pro	    ; On error, return to caller
 CALLS: ***
	AngleRange, InitVar, IsType, ToRadians
 CALLED BY:
	even_light, qImage_TrackPeak, qView_TrackPeak
 PROCEDURE:
	For a rectangular, constant density distribution the centroid is the
	geometric center of the box (the mean of the x and y coordinates of the corners).

	For a wedge shaped box the phase angle of the centroid is the geometric mean
	of the phase angles of the corners: phi(centroid) = (phi1+phi2)/2.
	For the radius, r(centroid)^2 = (r1^2+r2^)/2.

	If /shift_origin is set then the return values are the coordinates
	of 'box' relative to the centroid (i.e. the centroid coordinates are
	subtracted from the box coordinates

	If argument 'centroid' is specified then the centroid of 'box' is calculated.
	Then the box is positioned on 'centroid' such that the box centroid coincides
	with 'centroid'.
 MODIFICATION HISTORY:
	MAR-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


flip_colors $SSW_SMEI_UCSD/gen/idl/environment/flip_colors.pro
[Previous] [Next]
 NAME:
	flip_colors
 PURPOSE:
	Reverse color table and/or fore- and background colors
 CATEGORY:
	Annoying
 CALLING SEQUENCE:
	PRO flip_colors, $
	    flip_bw	= flip_bw   , $
	    flip_ct	= flip_ct   , $
	    silent	= silent    , $
	    noflip_bw	= noflip_bw , $
	    noflip_ct	= noflip_ct
 INPUTS:
	(none)
 OPTIONAL INPUT PARAMETERS:
	/flip_bw
	/flip_ct
	/silent
 OUTPUTS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, STRETCH, who_am_i
 CALLED BY:
	RemoteView_Display2D, RemoteView_Display3D, get_page, qGlitch_Show, set_page
	vu_get_page, vu_image, vu_insitucurve
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


flt_clean $SSW_SMEI_UCSD/gen/idl/util/flt_clean.pro
[Previous] [Next]
 NAME:
	flt_clean
 PURPOSE:
	Check a specified format against a specified string.
 CALLING SEQUENCE:
	flt_clean, StrIn, FmtIn, StrOut, FmtOut, /nocheck
 INPUTS:
	StrIn	    character string (usually a record read from file)
	FmtIn	    format to be matched against string
 OPTIONAL INPUTS:
	/nocheck    see procedure
 OUTPUTS:
	StrOut	    reduced character string (see procedure)
	FmtOut	    reduced format; = '()' if the input format does not
		match the input string
 OPTIONAL OUTPUTS:
	StrCrumbs   string array containing the discarded portions of the
		input string
	NumCrumbs   # elements in StrCrumbs
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar
 CALLED BY:
	flt_read
 PROCEDURE:
	The input format is searched for the character descriptor 'A'. All 'A'
	occurrences are removed from the format, and the corresponding
	substrings are removed from the input string.
	The reduced output format will contain only numeric format desciptors
	(I,F,D,E).
	If the input string does not adequately match the format,
	string '()' is returned as output format. This occurs if:
 >	If the string is longer or shorter than the length implied by the
	input format, i.e. the lengths must match exactly
 >	(Only if the keyword NoCheck is not set)
	If the substring for an 'A' descriptor contains a numerical digit (0..9)
 MODIFICATION HISTORY:
	MAY-1994, Paul Hick (ARC)
	SEP-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Bug fix. If format would end with a string (e.g. A3) then this would not
	    be cleaned up properly.


flt_format $SSW_SMEI_UCSD/gen/idl/util/flt_format.pro
[Previous] [Next]
 NAME:
	flt_format
 PURPOSE:
	Simplifies a format specication as produced by flt_string
 CATEGORY:
	gen/idl/util
 CALLING SEQUENCE:
	FUNCTION flt_format, InStr
 INPUTS:
	InStr	scalar; type: string
			any comma-separated list of format specifiers
			(the outer enclosing brackets are optional, but
			there should be no internal brackets)
 OUTPUTS:
	Result	scalar; type: string
			more compact list of format specifiers
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	where_common
 CALLED BY:
	flt_string, smei_star_cleanup, smei_star_writepnt
 RESTRICTIONS:
	The algorithm used tries to find recurring groups of format
	elements, but is somewhat heuristic.
 PROCEDURE:
	The format spec set up by flt_string only takes into account
	immediately neighbouring format specifies, i.e. instead
	of I4,I4,I4 the format will say 3I4. This function looks for
	more complicated repetitions in the flt_string format, e.g
	    str = 'I4,I2,F6.2,I2,F6.2,I3,I4,I2,F6.2,I2,F6.2,I3,I6,I1,I1'
	    print, flt_format(str)
	    2(I4,2(I2,F6.2),I3),I6,2I1
 MODIFICATION HISTORY:
	SEP-2004, Paul Hick (UCSD/CASS)
	JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Explicitly remove all whitespace from input string.
	    (input is still not modified)


flt_read $SSW_SMEI_UCSD/gen/idl/util/flt_read.pro
[Previous] [Next]
 NAME:
	flt_read
 PURPOSE:
	Read 2D float array from ASCII file
 CATEGORY:
	I/O
 CALLING SEQUENCE:
	FUNCTION flt_read, InFile, Array	, $
	    nx		    = NX		, $
	    ny		    = NY		, $
	    exponent	    = exponent		, $
	    stopboost	    = stopboost 	, $
	    header	    = header		, $
	    atleast	    = atleast		, $
	    silent	    = silent		, $
	    NoCheck	    = NoCheck		, $
	    timer	    = timer		, $
	    fmts	    = fmts		, $
	    errormessage    = errormessage	, $
	    crumbs	    = Crumbs		, $
	    skipfmt	    = skipfmt		, $
	    comments	    = Comments		, $
	    usefstat	    = UseFSTAT		, $
	    double_precision= double_precision	, $
	    integer	    = integer		, $
	    delay	    = delay		, $
	    padvalue	    = padvalue		, $
	    xfora	    = xfora		, $
	    bad 	    = bad		, $
	    modify_format   = modify_format	, $
	    mask_string     = mask_string	, $
	    comment_char    = comment_char
 INPUTS:
	FILE	    char    name of ASCII file
 OPTIONAL INPUTS:
	nx=NX	    1st dimension of output array Array (if omitted
		    the number of elements in the 1st record is used)
	ny=NY	    2nd dimension of output array Array (if omitted NY is
		    set to the numbers of records in the file)
	atleast=atleast only records with at least 'atleast' numbers in them are
		    accepted
	/exponent   the records read from FILE are checked for exponents
		    (see flt_string procedure)
	/stopboost  only the first NY records are read
	/nocheck    reduces double-checking in flt_clean
	/skipfmt    analyze each record with flt_string, i.e. do NOT try
		    the accumulated formats used to read previous records
	mask_string=mask_string
		    scalar; type: string
			see flt_string.
	/modify_format
		    activates a call to flt_format in all calls to
		    flt_string. This shortens the format specifiers returned
		    in keyword fmts.

		    The reason for introducing this keyword is that there
		    apparently is a limit on the length of format statements.
		    E.g. if a file was written with format
			(I1,4F7.2,I4,183(I8,F7.2))
		    then flt_read without the /modify_format keyword will try
		    to read it with a really long format with 183 pairs of
		    I8,F7.2 in it. The long version of the format causes an
		    error when it is used in a read/write statement.
		    However the short version also has a problem when it is
		    used to read the whole file with a single read statement.

		    While
			readf, iu, format='(F6.1,F10.1,F7.2,F10.1,F7.2)', tmp
		    works correctly, the shorter version
			readf, iu, format='(F6.1,2(F10.1,F7.2))', tmp
		    results in an error (IDL 6.0 and 6.1beta on Linux).
		    This change in format is exactly what /modify_format
		    accomplishes. No error occurs when the latter format is
		    used to read the file record by record.
	silent=silent
		    scalar; type: integer; default: 0
		    controls display of informational messages.
		    Set silent=-1 to generate lots of messages
	/timer	    displays timer information (testing purposes only)
	/double_precision
		    if set then a double precision array is returned
			(default: single precision)
	comment_char=comment_char
		    scalar; type: string; default: ';'
		    lines starting with this character are skipped
 OUTPUTS:
	RtnVal	    0: some error occurred (check 'errormessage')
		    1: file properly read
	Array	    array[n,m]; type: float or double
		    2D array of floating point numbers
		    if something goes wrong Array = -1 is returned
	Crumbs	    string  2D array containing the character substrings
		    not converted into numbers
		    This array will be complete only if /skipfmt is set
		    (processing all records separately). If skipfmt is not
		    set only then usually only the crumbs for the first
		    record is returned.
	errormessage	= '' (null string) if the file is properly read
		    = string describing error is something goes wrong
 OPTIONAL OUTPUT PARAMETERS:
	NX,NY	    dimensions of Array
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, InitVar, IsType, boost, destroyvar, do_file, flt_clean, flt_string
	gunzip_file, hide_env, stopwatch
 CALLED BY:
	InsituTimeSeries [1], InsituTimeSeries [2], ReadSynopticMap
	RemoteView_CMEDensity, RemoteView_Colors, RemoteView_rgbo, even_light_figures
	getsmeisources, img_read, jpl_test, mpc_eph, nso_fe_read, nso_fe_start
	smei_filepath, smei_frm_drive, smei_mkc3mask, smei_mkorb, smei_plot_timeseries
	smeidb_mounted, vu_header, vu_linecut, vu_losmap, vu_planarcut, vu_read, wso_read
 COMMON BLOCKS:
	common flt_read_common, old_time
 RESTRICTIONS:
	For each record in the file all formats are tried that were established
	from preceding records. If the record can be read successfully with
	one of these formats than the result is accepted and flt_string is not called
	to analyze the record. This depends on IDL returning an error when a
	record does not fit the record. However, IDL is too tolerant about matching
	formats to strings resulting in wrong results, e.g.
	    x = fltarr(2)
	    reads, '123,456', format='(I2,1X,I3)', x
	    print, x
		12.0000  0.00000
	I.e. no error is generated !!! For uniformly formatted files this is
	usually not a problem. But for irregularly formatted files this pitfall is
	best avoided by setting the /skipfmt keyword.
 PROCEDURE:
 >	Empty records and records starting with a semi-colon (;) are ignored
 >	The function flt_string is used to convert a record read from FILE as
	a string into a floating point array
 >	Only the first NX numbers of each record are stored in subsequent rows
	of Array. NX is explicitly given as input or, if omitted, is set equal
	to the number of elements in the first record of FILE
 >	If less than NX numbers are found in a record, the corresponding
	row in Array is padded with zeros.
 >	A buffer array of size NX by NY is initialized before reading
	the file, where NY is explicitly input or set to # records in the file.
	If FILE contains more than NY records, records following record NY are
	appended to Array by the 'boost' procedure (this is slow for big arrays)
	unless the keyword /stopboost is set.
 MODIFICATION HISTORY:
	OCT-1992, Paul Hick (UCSD/CASS)
	FEB-1995, Paul Hick (UCSD/CASS)
	    Added the 'crumbs' option
	MAR-2000, Paul Hick (UCSD/CASS)
	    Added /double_precision keyword
	JAN-2002, Paul Hick (UCSD/CASS)
	    Added /status keyword
	NOV-2002, Paul Hick (UCSD/CASS)
	    Added padvalue keyword
	MAY-2003, Paul Hick (UCSD/CASS)
	    More strict interpretation of /skipfmt: if set then every record
	    is processed separately by flt_string. No attempt is made anymore to read
	    read more than one record at a time with a single format.
	JUN-2003, Paul Hick (UCSD/CASS)
	    Added option to process .gz files transparently
	OCT-2003, Paul Hick (UCSD/CASS)
	    Added 'bad' keyword.
	SEP-2004, Paul Hick (UCSD/CASS
	    Added /modify_format keyword.
	FEB-2007, Paul Hick (UCSD/CASS)
	    Minor change in processing of /xfora keyword
	    Added check for presense of Crumbs keyword before trying
	    a direct read (the direct read does not fill the Crumbs
	    array).
	AUG-2008, Paul Hick (UCSD/CASS)
	    Empty files now return an status code of zero, instead of
	    aborting.
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword comment_char


flt_string $SSW_SMEI_UCSD/gen/idl/util/flt_string.pro
[Previous] [Next]
 NAME:
	flt_string
 PURPOSE:
	Extract numbers from string and put them in floating point array
 CATEGORY:
	String processing
 CALLING SEQUENCE:
	FUNCTION flt_string, INPUT		, $
	    exponent	    = exponent		, $
	    xfora	    = xfora		, $
	    double_precision= double_precision	, $
	    integer	    = integer		, $
	    strvec	    = StrVEC		, $
	    fmt 	    = fmt		, $
	    numfmt	    = numfmt		, $
	    lenfmt	    = lenfmt		, $
	    strcrumbs	    = strcrumbs 	, $
	    numcrumbs	    = numcrumbs 	, $
	    lencrumbs	    = lencrumbs 	, $
	    modify_format   = modify_format	, $
	    mask_string     = mask_string	, $
	    test_numonly    = test_numonly	, $
	    positive_only   = positive_only
 INPUTS:
	INPUT		string (e.g. 89/1/12)
 OPTIONAL INPUTS:
	/exponent	if set and nonzero, exponentials of type 'D' and 'E' are
			also interpreted
	/double_precision
			if set then a double precision array is returned
			(default: single precision)
	/xfora
	/modify_format	if set, the format returned in 'fmt' is run
			through the function flt_format to
			shorten the format string.
	mask_string=mask_string
			scalar; type: string
			    string of '0' and '1' with '1' in chars that
			    are explicitly NOT part of a number.
			    (the char will be part of an A or X format in the
			    resulting format specifier returned in 'fmt')
	/test_numonly	test string; returns 1 for strings that do not have
			    any chars that are not part of a number
			    (i.e. for which numcrumbs=0)
	/positive_only	assumes that all numbers are positive
			    (effectively this ignores the minus character
			    "-" as not a valid part of the mantissa;
			    it can still occur in an exponent).
 OUTPUTS:
	RtnVal		floating array (e.g. [89,1,12])
	StrVEC		string array (array FltVEC before conversion to float)
	fmt		format string matching the input string
	numfmt		# valid numbers located in the input string
	lenfmt		# chars taken up by the numfmt numbers in the input string
	strcrumbs	string array with part of input string not translated
			into numbers
	numcrumbs	# elements in strcrumbs
	lencrumbs	# total length of all elements in strcrumbs summed
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, InitVar, boost, destroyvar, flt_format
 CALLED BY:
	AngleUnits, TimeSplit, cvsmei, flt_read, getootyasources, grd_read, nagoya_glevel
	nso_fe_read, physics_constant, qImage_cw_DrawEphem, qImage_cw_smei_frm
	qLine_Curve, qsmei_sky_pick, skyd_cat, smei_base_testcase, smei_frm_drive
	smei_getfile, smei_mkc3mask, smei_orbit_stats, smei_time, smeidb_mounted
	txt_block_read, vox_read, vu_check, vu_header, vu_quick_movie, vu_set_header_entry
	vu_set_time_entry, vu_timeseries, vu_vox_read, wso_write
 PROCEDURE:
	Checks each character against a list of valid characters.
	Processing characters sequentially going from first to last,
	the largest possible substrings representing valid numbers
	are extracted. Only integer exponents are accepted
	(if the keyword /exponent is set).
 MODIFICATION HISTORY:
	Written Jan 1989 by DMZ (ARC)
	Converted to V2 Dec 1990 by DMZ (ARC)
	OCT-1990, Paul Hick (ARC)
	    Expanded to accept exponentials,
	?-1993, Paul Hick (UCSD)
	    Added construction of format specifiers
	FEB-1995, Paul Hick (UCSD/CASS)
	    Added option to pull out the substrings not translated
	    into numbers
	MAR-2000, Paul Hick (UCSD/CASS)
	    Added /double_precision keyword
	JUL-2002, Paul Hick (UCSD/CASS)
	    Fixed problem dealing with formatting of peculiar exponents.
	    E.g. '(1.dat)' would return format '(D2.-4,A3)'.
	    Now it returns '(D3.0,A2)'
	MAY-2004, Paul Hick (UCSD/CASS)
	    Changed strmid(var,2,999) to strmid(var,2)
	    (extracts to end of string 'var')
	SEP-2004, Paul Hick (UCSD/CASS)
	    Added call to flt_format to shorten the format specifier
	    returned in fmt
	DEC-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added /positive_only keyword