GeographicInfo $SMEI/ucsd/sat/idl/util/geographicinfo.pro
[Previous] [Next]
 NAME:
	GeographicInfo
 PURPOSE:
	Return geographic longitude of specified location
 CATEGORY:
	Trivial
 CALLING SEQUENCE:
	PRO GeographicInfo, UT, previous=previous, next=next, degrees=degrees,	$
	    nagoya	= nagoya    , $
	    cambridge	= cambridge , $
	    mexart	= mexart    , $
	    ooty	= ooty	    , $
	    tmo 	= tmo	    , $
	    location	= location  , $

	    geolng	= geolng    , $
	    geolat	= geolat    , $

	    UTnoon	= UTnoon    , $
	    RAnoon	= RAnoon    , $
	    RAlocal	= RAlocal
 INPUTS:
	UT		array; type: time structure
			    UT times
	/nagoya 	if set, return location of Nagoya (Japan)
	/cambridge	if set, return location of Cambridge (UK)
	/ooty		if set, return location of Ooty (India)
	/tmo		if set, return location of Table Mntn Obs (US)
	location	geographic longitude of requested location
			(in radian, or if /degrees is set, in degrees)
 OPTIONAL INPUT PARAMETERS:
	/degrees	if set, all input and output angles are in degrees
			(default: radians)
	/previous	check for previous noon
	/next		check for next noon
			if neither /previous or /next is set then the nearest
			noon is checked
 OPTIONAL OUTPUT PARAMETERS:
	geolng		scalar; type: float
			    geographic longitude
	geolat		scalar; type: float
			    geographic latitude
	UTnoon		array; type: time structure
			    UT for nearest/previous/next time when Sun crossed local meridian
			    (i.e. local noon)
	RAnoon		array; type; float
			    right ascension of local meridian at times UTnoon
	RAlocal 	array; type; float
			    right ascension of local meridian at times UT
 INCLUDE:
	@compile_opt.pro		; On error, return to caller
 CALLS: ***
	AngleRange, BadValue, InitVar, IsTime, IsType, SubArray, SyncArgs, TimeGST, TimeGet
	TimeOp, TimeSet, TimeUnit, ToRadians, big_eph, jpl_body
 CALLED BY:
	PlotEarthSkymap, PlotPolarSkymap, stardistance, vu_localskymap
	vu_nagoyasourcemap
 PROCEDURE:
	Geographic coordinates are hardwired
 MODIFICATION HISTORY:
	SEP-1999, Paul Hick (UCSD/CASS)
	FEB-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added tmo and geolat keywords


get_page $SMEI/ucsd/sat/idl/util/get_page.pro
[Previous] [Next]
 NAME:
	get_page
 PURPOSE:
	Complete output procedure set up with set_page.
	Submit PostScript or HP file to print queue
 CATEGORY:
	Plotting
 CALLING SEQUENCE:
	get_page [,File, /color]	    Close device & print & delete
	get_page [,File, /killfile]	    Close device & delete
	get_page [,File, /keepfile ,/color] Close device & keep
	get_page [,File, /keepfile, /printfile ,/color]
					    Close device & print & keep
 OPTIONAL INPUTS:
	File		scalar; type: string; default: !ThePlotFile
			    file name to be used for plot filefile name. In general the common block
			    default should be use. Primarily useful for /gif and /bmp ouput.
	/keepfile
	keepfile=KeepFile
			scalar; type: string or byte
			(HP only) the plot file will be saved
			If KeepFile is a valid file name it is used for the saved plot file.
			(this option is only set up for the HP printer on CASS01 and depends
			on the LIBPRN command procedure).
	/printfile	(HP and PS)
			if set the plot file is submitted for printing
			This is the default for HP and PS
	/killfile	(HP, PS and EPS)
			closes the plot device, and deletes the plot file
	/freezedev	by default the plot device is set back to !TheTerminal.
			If /freezedev is set the device will remain at the setting found when
			get_page was called (usually the printer device !ThePrinter)
	/color		plot in color (only for PS files)

	/gif
	/png
	/jpg
	/bmp		can be used in combination with the File argument to save the
			content of the current window into a GIF or BMP file.
			If File has the extension .gif or .bmp then the keyword does not need
			to be specified.
	/silent 	suppresses a bunch of informational messages
 INCLUDE:
	@compile_opt.pro		; On error return to caller
 CALLS: ***
	FILEPATH, GetFileSpec, InitVar, IsDisplay, IsPrinter, IsType, LOADCT, Reset_Colors
	SetFileSpec, SuperArray, WRITE_BMP, WRITE_GIF, do_file, hide_env, put_logo, twin
 CALLED BY:
	even_light_corrections, even_light_photometry, even_light_registration
	qBar_Print, qLine_Print, qSave2File_Save, qset_page, show_wso, smei_frm_summary
	smei_hdr_plot, smei_sky, vu_get_page, vu_image
 SEE ALSO:
	set_page
 PROCEDURE:
	set_page and get_page are supposed to be used together: set_page starts the
	output procedure, get_page completes it. get_page uses the file name save in
	common block 'devices' to determine what kind of output to produce (EPS, GIF, BMP,
	HP, PS, etc.).

	For the PRINTER device no plot file is created but instead output is send directly
	to the printer. Hence none of the keywords are useful. get_page will always close
	the PRINTER device (effectively forcing the printer to start printing).

	For EPS a file name is selected using 'set_page'. The file name is saved in common
	block 'devices'. Here the EPS file is just closed.

	For GIF and BMP a tvrd() is executed, and the return value is written into a file
	with the name in !ThePlotFile. Alternatively the File argument is used to specify a
	file name. If the name does not have extension .gif or .bmp then the keyword /gif
	or /bmp must be set explicitly.
 MODIFICATION HISTORY:
	Based on PSPLOT, written DMZ (ARC, Aug'90)
	July 1991, Paul Hick (ARC)
	1992, Paul Hick (UCSD/CASS); added option for plotting to HP printer
	2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added logo keyword


GetColors $SMEI/ucsd/sat/idl/toolbox/graphics/getcolors.pro
[Previous] [Next]
 NAME:
	GetColors
 PURPOSE:
	Convert array of function values to equivalent color indexes.
	Optionally plot a legend.
 CALLING SEQUENCE:
	FUNCTION GetColors, Value, BreakVal, BreakName, BreakPos,   $
	    open	= open	    , $
	    legend	= legend    , $
	    rimlegend	= rimlegend , $
	    format	= format    , $
	    ctable	= ctable    , $
	    cpart	= cpart     , $
	    usedcolors	= usedcolors, $
	    badforeground=badforeground, $
	    badbackground=badbackground, $
	    charsize	= charsize  , $
	    flip	= flip	    , $
	    noedge	= noedge    , $
	    ncolors	= ncolors   , $
	    strictlabels= strictlabels, $
	    steplabels	= steplabels, $
	    _extra	= _extra
 INPUTS:
	Value		    array; type: any
				function values
	BreakVal	    array[n]; type: any
				function values between adjacent colors

	Only used if /legend is set:

	BreakName	    array[m]; type: any
				labels along legend; usually a subset
				of BreakVal. See PROCEDURE.
	BreakPos	    array[m];
				position for BreakName labels along legend
 CALLED BY:
	PlotEarthSkymap, PlotPlanarCut, PlotPolarSkymap, PlotSolarDisk, PlotSynopticMap
	nagoya_glevel, vu_synopticmap
				See PROCEDURE:
 OPTIONAL INPUT PARAMETERS:
	/legend 	    if set, a legend is plotted at the left
				edge of the screen
	steplabels=steplabels
			    scalar; type: integer; default: 1+ncolors/8
				SEE PROCEDURE
	rimlegend=rimlegend scalar; type: any; default: 0
				sets the thickness of the bounding box around the legend

	/strictlabels
	format=format	    scalar; type: string
				format used to label the legend (only used if
				BreakVal is a float array)
	ctable=ctable	    scalar; type: integer
				used to load a color table with LOADCT
				(only if !d.n_colors=16)
	cpart=cpart	    array[2]; type: float
				fractions of one; limits the range of color indices
				used to cpart*(!d.n_colors-1)
	/noedge 	    avoids using color indices 0 and !d.n_colors-1
				this overrides the cpart setting.
				(these sometimes are set to black and white and don't
				fit in with the rest of the color table).

	_extra=_extra
	/badforeground	    if set then bad values (detected with the
				finite function) are set to the foreground
				color (!p.color)
	/badbackground	    if set then bad values are set to the foreground
				color (!p.background)
	/flip		    uses color table in reverse order, i.e. with increasing
				fnc value corresponding to decreasing color index
 OUTPUTS:
	Result		    array; type: byte
				array with color indices (same dimensions as Value)
 INCLUDE:
	@compile_opt.pro			; On error, return to caller
 CALLS: ***
	InitVar, IsType, LOADCT, REVERSE, UNIQ, anicenum, gridgen
 SIDE EFFECTS:
	The BreakVal array is sorted
 RESTRICTIONS:
	#break values = n_elements(BreakVal) must be less than
	#colors = !d.n_colors
 PROCEDURE:
	The BreakVal array with N = n_elements(BreakVal) elements
	divides the data range into N+1 interval (the 1st interval
	covers data values below BreakVal[0], the last interval
	covers data value above BreakVal[N-1]. A data value is
	matched to a color index depending on the interval it
	belongs to.

	The # colors needed is 1+N (N=n_elements(BreakVal).
	The 1+N color indices are calculated as
	    Col = round( (!d.n_colors-1.)/nBreak*indgen(nCols) )
	i.e. as nearly evenly spaced over the full range 0,!d.n_colors-1
	[Col[0]=0, Col[nBreak]=!d.n_colors-1]

	The legend is a vertical color bar (color 0 to nBreak
	from bottom to top) at the left side of the screen.
	The BreakVal values are plotted at the borders between
	adjacent colors. A maximum of 8 evenly spaced numbers
	is plotted.

	By default the labeling of the legend is determined
	internally from the BreakVal array. This works well if
	the BreakVal array contains a largen number of values
	(usually !d.n_colors).
	For short arrays of BreakVal the labelling is better
	controlled using a couple of arguments

	BreakName explicitly specifies how the legend needs to
	be labelled. Usually these are numbers. The numbers then
	also define the position of the label. If BreakName
	contains custom labels (e.g. string labels (instead of
	numbers), then the position of the label can be
	specified as BreakPos.

	If /strictlabels is set then BreakName = BreakPos = BreakVal
	is assumed, and labels are plotted every
	'steplabels' value of BreakVal
	If BreakName is set then /strictlabels is ignored;
	This is how GetColors worked originally;
	the drawback is that the values plotted along
	the legend are usually not nicely rounded values.
 MODIFICATION HISTORY:
	SEP-1992, Paul Hick (UCSD/CASS)
	APR-1993, Paul Hick (UCSD/CASS)
	    removed restrictions to !d.n_colors=8 and 16
	AUG-1999, Paul Hick (UCSD/CASS)
	    added a check for bad values using the 'finite' function. Corresponding
	    entries in the Color output array are now set to -1 (these will be ignored
	    by ColorSkybox).
	SEP-1999, Paul Hick (UCSD/CASS)
	    added badforeground and badbackground options
	    added /open keyword
	SEP-2003, Paul Hick (UCSD/CASS)
	    added cpart keyword
	OCT-2003, Paul Hick (UCSD/CASS)
	    added /flip and /noedge
	MAY-2006, Paul Hick (UCSD/CASS)
	    Added /rimlegend
	JUN-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added /strictlabel, BreakPos. Added code to improve
	    labeling of legend.


GetFileSpec $SMEI/ucsd/gen/idl/toolbox/files/getfilespec.pro
[Previous] [Next]
 NAME:
	GetFileSpec
 PURPOSE:
	Retrieve file name information from the common block
	set by SetFileSpec.
 CATEGORY:
	I/O, string manipulation
 CALLING SEQUENCE:
	FUNCTION GetFileSpec, setfile, $
	    from	= From	, $
	    upto	= Upto	, $
	    part	= Part	, $
	    strict	= strict, $
	    asfilename	= AsFileName
 INPUTS:
	setfile
	    array; type: string
		array of file names is fed into SetFileSpec before anything
		else is done. If not specified then the information set up by
		a previous call to SetFileSpec is used.
	From, UpTo, Part
	    scalar; type: string
		Any of the following six strings can be used:
		'NODE','DEVICE','DIRECTORY','NAME','TYPE','VERSION'
		(a prefix 'FILE' is permitted, as in 'FILENAME')
		The input is case-insensitive
		Only a unique starting substrings has to be specified
		If From is not specified, From='NODE' is assumed
		If UpTo is not specified, From='VERSION' is assumed
 OPTIONAL INPUT PARAMETERS:
	/AsFileName if UpTo = 'Directory' and AsFileName is set than the
		directory names are returned as file names, i.e.
		in vms a *.DIR name is returned; in Win32 and Unix
		the trailing (back)slash is removed. MacOS is not
		implemented.
 OUTPUTS:
	Result	string array
		The array structure is determined by the input to the
		SetFileSpec call that set up the internal data.
		Includes all FileParts in between and including the
		From and UpTo strings
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, SetFileSpec, SyncDims, os_separator, strposn
 CALLED BY:
	FindAllFiles, FindAllSubDirs, bin_read, bin_write, do_file, findfile_fix
	forecast_ftp, get_page, gunzip_file, gzip_file, img_read, lstree, makemovie, mk_flick
	mpc_body, nso_fe_read, physics_constant, qImage, qImage_Pick, qImage_cw_Property
	qImage_cw_Save, qImage_cw_SmeiMask, qRemoteView_Pick, qSave2File
	qSave2File_Pick, qSave2File_Save, qView, qView_FileFilter, qView_PickFiles
	qView_Save2File, qView_Shortname, qView_TMO_tracksky, qset_page_pick
	qsmei_sky_pick, qvu_pick, set_page, sgp_body, skyd_cat, skyd_equ, smei_base_testcase
	smei_buf, smei_buf_getframe, smei_buf_splitfile, smei_filename, smei_findcrazy
	smei_frm_cp, smei_frm_cvhdr, smei_frm_read, smei_frm_smoothdark, smei_frm_update
	smei_frm_write, smei_getfile, smei_hdr_make, smei_orb_fractions, smei_property
	smei_shutterwrong, smei_sky_cleanedge_map, smei_star_remove, smei_star_split
	smei_star_writepnt, smei_zld_remove, timeposn, unhide_env, usno_body, vu_check
	vu_earthskymap, vu_extract, vu_get_page, vu_getdata, vu_header, vu_image, vu_movie
	vu_quick_movie, vu_remoteview, vu_vox_sequence, vu_vox_write, vu_write, who_am_i
	wso_read, wso_write, www_help_crosslinks, www_help_files, www_help_get_header
	www_help_get_info, xhcs
 EXAMPLE:
	SetFileSpec, 'ud1:[test]file.txt'	Establishes internal data
	print, GetFileSpec()			Prints: ud1:[test]file.txt
	print, GetFileSpec(upto='dir')		Prints: ud1:[test]
	print, GetFileSpec(from='name') 	Prints: file.txt
	print, GetFileSpect(from='dev',upto='dev') Prints: ud1:
 INCLUDE:
	@filespec_common.pro	; Common block with arrays File and Parts
 SIDE EFFECTS:
 >	Input is converted to uppercase
 RESTRICTIONS:
 >	Internal data must have been set up by SetFileSpec
 PROCEDURE:
	Extracts data from common block set by SetFileSpec
 MODIFICATION HISTORY:
	DEC-1997, Paul Hick
	JAN-2001, Paul Hick (UCSD/CASS)
	    Added part keyword
	OCT-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added setfile keyword


getnagoyasources $SMEI/ucsd/sat/idl/toolbox/ips/getnagoyasources.pro
[Previous] [Next]
 NAME:
	getnagoyasources
 PURPOSE:
	Extract Nagoya IPS observations from yearly data files
 CATEGORY:
	I/O
 CALLING SEQUENCE:
	FUNCTION getnagoyasources, trange, $
	    subdir  = subdir	, $
	    degrees = degrees	, $
	    silent  = silent	, $
	    point_sources=point_sources
 INPUTS:
	trange		scalar or array[2]; type: time structure
			    time range (begin and end time)
			    a scalar is interpreted as [trange, trange+1 day]
			    (i.e. a one day time range starting at trange
 OPTIONAL INPUT PARAMETERS:
	subdir=subdir	scalar; type: string; default='daily'
			    subdirectory in $dat/nagoya where to look for data files
	/degrees	if set pp will be in degrees (default: radians)
 OUTPUTS:
	Result		scalar; type: long;
			    # ips sources in time range
 OPTIONAL OUTPUT PARAMETERS:
	point_sources=point_sources
		array[n]; type: structure
		    structure with IPS sources inside time range
	    point_sources.name = string with source name
	    point_sources.pp   = 2-element array with RA and decl of source
	    point_sources.tt   = time structure with time of observation
	    point_sources.vv   = IPS velocity
	    point_sources.gg   = IPS g-level
	    point_sources.xy   = used by PlotEarthSkymap to set pixel locations of sources
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, CheckDir, CvPrecess, FILEPATH, InitVar, IsType, TimeFixYear, TimeGet, TimeOp
	TimeSet, TimeUnit, ToDegrees, destroyvar, txt_read, vu_point_source
 CALLED BY:
	qnagoya_pointsources, vu_localskymap, vu_nagoyasourcemap
 PROCEDURE:
 >	All relevant yearly IPS data files are read to find observations inside
	specified time range. These files are stored in $NAGOYA/'subdir'
	where subdir is supplied as keyword.
 >	Files containing a list of IPS sources with celestial coordinates
	(presumably in B1950) are stored in directory $NAGOYA/sources
	A slightly different list is used each year. Currently this list
	contains the source name, B1950 right ascension and declination,
	and an expected source intensity.
 >	RA and dec for the sources are precessed to the current epoch.
 MODIFICATION HISTORY:
	SEP-1999, Paul Hick (UCSD/CASS)
	JUL-2000, Paul Hick (UCSD/CASS)
	    record length for nagoya.* files changed from 66 to 76 to
	    account for extra column with scintillation index data.
	MAY-2003, Paul Hick (UCSD/CASS)
	    Added precession of source coordinates from B1950 to current epoch.
	DEC-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added check for IPS sources in yearly data files which are not
	    specified in the STELab IPS source list (and for which therefore
	    no sky locations are available).


getootyasources $SMEI/ucsd/sat/idl/toolbox/ips/getootysources.pro
[Previous] [Next]
 NAME:
	getootyasources
 PURPOSE:
	Extract Ooty IPS observations from yearly data files
 CATEGORY:
	I/O
 CALLING SEQUENCE:
	FUNCTION getootysources, trange, $
	    subdir  = subdir	, $
	    degrees = degrees	, $
	    silent  = silent	, $
	    point_sources = point_sources
 INPUTS:
	trange		scalar or array[2]; type: time structure
			    time range (begin and end time)
			    a scalar is interpreted as [trange, trange+1 day]
			    (i.e. a one day time range starting at trange
 OPTIONAL INPUT PARAMETERS:
	subdir=subdir	scalar; type: string; default='daily'
			    subdirectory in $DAT/ooty where to look for data files
	/degrees	if set pp will be in degrees (default: radians)
 OUTPUTS:
	Result		scalar; type: long;
			    # ips sources in time range
 OPTIONAL OUTPUT PARAMETERS:
	point_sources=point_sources
		array[n]; type: structure
		    structure with IPS sources inside time range
	    point_sources.name = string with source name
	    point_sources.pp   = 2-element array with RA and decl of source
	    point_sources.tt   = time structure with time of observation
	    point_sources.vv   = IPS velocity
	    point_sources.gg   = IPS g-level
	    point_sources.xy   = used by PlotEarthSkymap to set pixel locations of sources
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleUnits, BadValue, CheckDir, CvPrecess, FILEPATH, GETOOTYSOURCES, InitVar, IsType
	TimeFixYear, TimeGet, TimeOp, TimeSet, TimeUnit, ToDegrees, destroyvar, flt_string
	txt_read, vu_point_source
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Derived from getnagoyasources


getsmeiasources $SMEI/ucsd/sat/idl/toolbox/ips/getsmeisources.pro
[Previous] [Next]
 NAME:
	getsmeiasources
 PURPOSE:
	Extract SMEI lines of sight from orbital data files
 CATEGORY:
	I/O
 CALLING SEQUENCE:
	FUNCTION getsmeisources, trange, $
	    subdir  = subdir	, $
	    degrees = degrees	, $
	    silent  = silent	, $
	    point_sources = point_sources
 INPUTS:
	trange		scalar or array[2]; type: time structure
			    time range (begin and end time)
			    a scalar is interpreted as [trange, trange+1 day]
			    (i.e. a one day time range starting at trange
 OPTIONAL INPUT PARAMETERS:
	subdir=subdir	scalar; type: string; default='daily'
			    subdirectory in $DAT/smei where to look for data files
	/degrees	if set pp will be in degrees (default: radians)
 OUTPUTS:
	Result		scalar; type: long;
			    # ips sources in time range
 OPTIONAL OUTPUT PARAMETERS:
	point_sources=point_sources
		array[n]; type: structure
		    structure with lines of sight inside time range
		    (see vu_point_source)
	    point_sources.name = string with source name
	    point_sources.pp   = 2-element array with RA and decl of source
	    point_sources.tt   = time structure with time of observation
	    point_sources.vv   = IPS velocity
	    point_sources.gg   = IPS g-level
	    point_sources
	    point_sources.xy   = used by PlotEarthSkymap to set pixel locations of sources
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, CheckDir, CvPrecess, FILEPATH, GETSMEISOURCES, InitVar, IsType, TimeGet
	TimeOp, TimeSet, TimeUnit, ToDegrees, destroyvar, flt_read, smei_orbit_get
	vu_point_source
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Derived from getnagoyasources


GetStarShape $SMEI/pro/tool/getstarshape.pro
[Previous] [Next]
 NAME:
	GetStarShape
 PURPOSE:
	Get a set of shapes in the form of a 2D rectangular template to be used
	to detect stars in an image
 CATEGORY:
 CALLING SEQUENCE:
 INPUTS:
	Frame	    2D array, any type
			Image containing stars
	Star	    scale, type integer
			Location of suspected star in Frame (usually a local
			maximum in Frame)
 OPTIONAL INPUT PARAMETERS:
	/nocentroid if set then no attempt is made to find the centroid of the
		    suspected star (the centroid is supposed to be at the location
		    of the maximum at position Star).
	file=File   character, default: starshape.txt in directory $SMEI/sys
			Name of file containing the basic star template
 OUTPUTS:
	Box	    2D array, type float, same size as the star template used to
			fit the star the suspected star (pixel Star in Frame) is
			in the center of Box.
			Box contains the square from Frame around suspected star.
			Values !VALUES.F_NAN near the edges of Box indicate pixels
			outside the range of the Frame array.
	Mask	    1D array, type long integer
			mask of pixels covering the area in the basic star mask
			defined as 'inside the star', i.e. the part of the 2D
			template actually used to match the peak in Frame to a star.
	BoxBase     scalar, type float
	BoxDev	    scalar, type float
			measure for the fluctuations of the values in the 'outside
			star' pixels in box (~standard deviation)
	BoxMed	    scalar, type float
			median of the 'outside star' pixels in Box

 OPTIONAL OUTPUT PARAMETERS:
 CALLS: ***
	ArrayLocation, FILEPATH, MEAN, STDDEV, SuperArray, VALUESNAN, flt_read
 CALLED BY:
	FitStar
 COMMON BLOCKS:
	common SaveStarShape, Shape, X, Y, InStar
 PROCEDURE:
 >	The basic template, a 2D array of numbers is stored in an ascii file and
	read by flt_read. The template is separated in an 'inside star' and
	'outside star' area. The 'outside' area is used to define a base level,
	which is subtracted from the 'inside' area. The remaining difference is
	the basic template used for fitting.
 > If the /nocentroid keyword is not set, then a set of templates is calculated
	corresponding to set of slightly different centroids for the suspected star.
 MODIFICATION HISTORY:
	OCT-1998, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


grd_read $SMEI/ucsd/gen/idl/util/grd_read.pro
[Previous] [Next]
 NAME:
	grd_read
 PURPOSE:
	Very provisional reader for .grd files
 CATEGORY:
	gen/idl/util
 CALLING SEQUENCE:
	FUNCTION grd_read, InFile, data , $
	    dimension	= dimension	, $
	    norow	= norow 	, $
	    errormessage= errormessage	, $
	    silent	= silent
 INPUTS:
	file	    scalar; type: string
			fully-qualified file name
 OPTIONAL INPUT PARAMETERS:
	/dimension  is set then only the array dimension from the header
			is returned
 OUTPUTS:
	result	    scalar; type: integer
			always 1
	data		array[n,m]; type: float
			data array
		    array[2]: type: integer
			(only if /dimension is set)
			Size of array (i.e. values of n and m)
 OPTIONAL OUTPUT PARAMETERS:
	error_message=error_message
		    scalar; type: string
			always null-string
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, destroyvar, do_file, flt_string, gunzip_file, hide_env
 CALLED BY:
	img_read, makemovie, smei_mkglare, smei_mksidereal, smei_mkstdstar
 SEE ALSO:
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2003, Paul Hick (UCSD/CASS)
	SEP-2003, Paul Hick (UCSD/CASS)
	    Added /dimension keyword
	SEP-2003, Paul Hick (UCSD/CASS)
	    Added /norow keyword
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added code to handle binary grd files in addition
	    to ascii.


gridfill $SMEI/ucsd/sat/idl/toolbox/math/gridfill.pro
[Previous] [Next]
 NAME:
	gridfill
 PURPOSE:
	Removes empty bins. An empty bin is given the average over all
	neighbours with valid function values.
 CATEGORY:
	Plotting: contours
 CALLING SEQUENCE:
	Z = gridfill(Z,nfile=nFill,weightfnc=WeightFnc,status=S)
 INPUTS:
	Z   2D array; any type
	    If of type float, then invalid grid values are marked by !values.f_nan
 OPTIONAL INPUTS:
	nfill=nFill scalar; type integer; default: 0
		<= 0: fill all empty bins with extrapolated values
		>  0: fill empty bins with more than nFill neighbours
	weightfnc=WeightFnc
		scalar; type string; default: not present
		name of function to calculate weights (see PROCEDURE)
 OUTPUTS:
	Z   2D array; type float
		same as input array with invalid grid values replaced by averages
		(if nfill>0 not all invalid values may have been filled in)
 OPTIONAL OUTPUTS:
	status=S
	    2D array; type byte
		array identifying the extrapolated values:
		    = 1  contents of bin is same as valid input value
		    = 2  contents of bin is extrapolated value
		    nFill>0 only:
		    = 0  empty bin with less than nFill neighbours
			  Z[.,.] = !values.f_nan (same as input).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, InitVar
 CALLED BY:
	InterpolateHeliosphere, PlotSynopticMap, wso_read, wso_write
 PROCEDURE:
 >	If nFill <= 0 then:
	Step 1: for each empty bin, count the number of non-empty neighbours
	Step 2: find the subset of empty bins with the maximum number of
	    non-empty neighbours
	Step 3: for the subset of step 2, calculate the average over the non-
	    empty neighbours and assign this average to the empty bin
	Step 4: Go to step 1
	Repeat until there are no empty bins left.

 >	nFill > 0:
	Step 1: for each empty bin, count the number of non-empty neighbours
	Step 2: find the subset of empty bins with nFill or more non-empty
	    neighbours
	Step 3: for the subset of step 2, calculate the average over the non-
	    empty neighbours and assign this average to the empty bin
	Step 4: Return.

 >	By default neigbouring function values are averaged with weight=1.
	If WeightFnc is specified, it is used to calculate the weights instead.
	The function has the form
	    function WeightFnc(I,J,inX,jnY,Z[inX,jnY])
	I,J are the indices of the bad pixel; inX,jnY are arrays with the
	    indices of good neighbour pixels, and Z[inX,jnY] are the
	    function values in the good neighbours.
 MODIFICATION HISTORY:
	1990, Paul Hick (UCSD)
	24-MAR-1999, Paul Hick (UCSD), converted from Fortran


gridgen $SMEI/ucsd/gen/idl/toolbox/gridgen.pro
[Previous] [Next]
 NAME:
	gridgen
 PURPOSE:
	Generate array of x,y,z coordinates for a multi-dim area
 CALLING SEQUENCE:
	FUNCTION gridgen, nn,	$
	    origin  = origin	, $
	    edge    = edge	, $
	    open    = open	, $
	    one     = one	, $
	    range   = range	, $
	    multid  = multid	, $
	    double  = double
 INPUTS:
	n	    array[ndim]; type: integer
		    (ndim = 1,2,3)
		    dimensions of area in x, x-y, or x-y-z directions
 OPTIONAL INPUT PARAMETERS:
	/one	    if set, scales output array to range [0,1] in all dimensions
	one=one     array[ndim]; type: integer with value 0 or 1
		    set scaling for each of the dimension in 'n' separately

	/open	    if set, then the pixel centers for the 'pixel edges' [0,n]
		    is returned
	open=open   array[ndim]; type: integer with value 0 or 1
		    set 'open' status for each of the dimensions separately
		    This is the same as gridgen1d(n, origin=-0.5)
		    The origin=0.5 is added to the origin specified in keyword
		    origin.

	/edge	    if set, then coordinates for the 'pixel edges' of pixels
		    [0,..n-1] is returned
	edge=edge   array[ndim]; type: integer with value 0 or 1
		    set 'edge' status for each of the dimensions separately
		    This is the same as gridgen(n+1, origin=0.5)
		    The origin=0.5 is added to the origin specified in keyword
		    origin.

		    Example: gridgen(5, /edge) = [-0.5,0.5,1.5,2.5,3.5, 4.5]
	origin=origin
		    array[ndim]; type: float
		    defines the origin in units of output grid
		    (i.e. usually in array indices; but if /one or range are
		    used then it is in units of the data range)

	range=range scalar, array[ndim] or array[2,ndim]
		    if scalar then the output array is scaled to the range
			[0,range] in every dimension
		    if array[ndim] then the output array is scaled to the ranges
			[0,range[i]], i=0,ndim-1, in each dimension
		    if array[2,ndim] then the output array is scaled to the ranges
			[range[0,i],range[1,i]], i=0,ndim-1 in each dimension

	/multid     (only in ndim > 1) reforms output array to [ndim,n] array.
		    The default is a two-dim array of size
			[ndim,n[0]*n[1]*..*n[ndim-1]]
 OUTPUTS:
	Result	    array[ndim,n[0],n[1],..,n[ndim-1]]; type: long integer or float
			coordinates across the area
			a float array is returned if keywords /one or /range
			are used.
 CALLS: ***
	InitVar, IsType, gridgen1d
 INCLUDE:
	@compile_opt.pro	    ; On error, return to caller
 CALLED BY:
	EarthSky3DLoc, EarthTransit3DLoc, GetColors, PlotEarthSkymap, PlotPlanarCut
	PlotPolarSkymap, PlotSolarDisk, PlotSynopticMap, RemoteView
	RemoteView_CMEDensity, RemoteView_CubeFrame, RemoteView_CurrentSheet
	RemoteView_FOV_xyz, RemoteView_VertexSphere, RemoteView_rgbo, TMO_skymotion
	TMO_tracksky, ThomsonLOSStep, TimeXAxis, big_orbit, cvsmei, even_light
	even_light_figures, even_light_pedestal, even_light_platescale, jpl_test
	plot3darc, qGlitch_Run, qImage_cw_BoxCosine, qImage_cw_SmeiMask
	qImage_cw_ZEllipse, qView_PlotSeries, qvu_draw, show_wso, smei_ccd2sky, smei_sky
	smei_sky_cleanedge_fov, smei_sky_read, smei_star_box, smei_star_standard
	smei_zld_model, smei_zld_remove, sphere_great_arc, sphere_smooth, stardistance
	vu_extract, vu_get, vu_insitu, vu_insitucurve, vu_planarcut, vu_solardisk
	vu_synopticmap, vu_timeseries, vu_type_skymap, vu_vox_drawelatitude
	vu_vox_drawelongitude, vu_vox_drawhlatitude, vu_vox_drawhlongitude
	vu_vox_draworbit, vu_vox_drawsphere, vu_vox_write, wedge_content, wso_read
 RESTRICTIONS:
	Currently onle 1, 2 and 3-dim cases are implemented
 PROCEDURE:
 >	The origin is subtracted after applying the scaling implied by
	keywords /one and range=range
 >	Combination of 'replicate' function and matrix multiplication #
 MODIFICATION HISTORY:
	OCT-2000, Paul Hick (UCSD/CASS)
	    Result of merging indgen1d, indgen2d, and indgen3d
	JAN-2002, Paul Hick (UCSD/CASS)
	    Change all replicate(1.0,n) statements to replicate(1L,n) in the
	    last case block.
	    Using 1.0 will always return a float array even when an integer
	    return would be acceptable.
	NOV-2005, Paul Hick (UCSD/CASS)
	    Added 4D version
	SEP-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Substantial rewrite: generalized to work for any number
	    of dimensions (memory permitting)


gridgen1d $SMEI/ucsd/gen/idl/toolbox/gridgen1d.pro
[Previous] [Next]
 NAME:
	gridgen1d
 PURPOSE:
	(For internal use by gridgen only)
 CALLING SEQUENCE:
	FUNCTION gridgen1d, nn, $
	    origin  = origin, $
	    edge    = edge  , $
	    open    = open  , $
	    one     = one   , $
	    range   = range , $
	    double  = double
 INPUTS:
	nn	scalar; type: integer
		    number of elements in grid
 OPTIONAL INPUTS:
	origin=origin
		scalar; type: any numerical type
		the origin is shifted AFTER
		applying keywords one or range.
	/open
	/edge	return edges of bins
		the output
	/one	same as range=[0,1]
	range=range
		array[2]; type: any numerical type
		scale array to this range
		If range is of type integer then the grid
		also will be type integer unless integer
		truncation occurs.
	/double if set return double precision grid
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType
 CALLED BY:
	gridgen
 EXAMPLE:
	gridgen(5)		= [0,1,2,3,4]
	gridgen(5,/open)	= [0.5,1.5,2.5,3.5,4.5]
	gridgen(5,/open,/edge)	= [0,1,2,3,4,5]
	gridgen(5,/one) 	= [0.0,0.25,0.5,0.75,1.0]
	gridgen(5,/one,orig=0.5)= [-0.5,-0.25,0.0,0.25,0.5]
 PROCEDURE
	Sets up 1-dim grid. BE CAREFUL MIXING KEYWORDS.
 MODIFICATION HISTORY:
	OCT-2000, Paul Hick (UCSD/CASS)
	SEP-2006, Paul Hick (UCSD/CASS)
	    If range is specified as integer then the return
	    array is returned as integer array also, after
	    checking that integer truncation has not occurred.
	    Keyword origin is now applied after processing
	    keywords one and range (if present).
	JUN-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added code to handle n=1 without error messages


GroupPixels $SMEI/ucsd/sat/idl/toolbox/grouppixels.pro
[Previous] [Next]
 NAME:
	GroupPixels
 PURPOSE:
	Divide a group of pixels in separate groups based on nearness of the pixels in a group
 CATEGORY:
	Tools
 CALLING SEQUENCE:
	Loc = GroupPixels(Locations, Positions, range=range, ngroup=nGroup, pgroup=pGroup, lgroup=lGroup)
 INPUTS:
	Locations	1D array, type integer
			    array of linear indices of pixel locations
	Positions	3D array, type: float
			    x,y,z positions of pixels in 'Locations' array
			    (keywords sizeframe or dimension provide alternative
			    ways to specify x,y,z positions)
 OPTIONAL INPUT ARRAY:
	sizeframe=sizeframe size vector of image cube
	dimension=dimension dimensions of image cube
			    if either of these is specified, then 'Positions' is ignored
			    Instead the dimensions of the image cube are used to
			    to get x,y,z pixel coordinates from 'Locations' using
			    ArrayLocation.
 OPTIONAL INPUT PARAMETERS:
	range=Range	scalar, or vector with as many elements as Frame has dimensions
			    default: Range = 1
			    defines the distance in each dimension of Frame defining
			    how close the members of a group are.
	/ellipsoid	if set, Range is used to define an ellipsoidal region
			if not set, Range defines a square region.
 OUTPUTS:
	Loc		1D array, type integer
			    same as input array Locations but with elements reordered
			if Frame is supplied as an array (i.e. if /sizeframe is not set),
			then groups will be ordered with the values of the highest
			pixel in each group in decreasing order
 OPTIONAL OUTPUT PARAMETERS:
	ngroup=nGroup	scalar, type long integer
			    number of groups of pixels in Loc
	pgroup=pGroup	1D array[nGroup], type long integer
			    indicates the position in Loc where each group begins
	lgroup=lGroup	1D array[nGroup], type long integer
			    indicates number of pixels in each group
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, InitVar, IsType
 CALLED BY:
	Find2DGlitch
 PROCEDURE:
	This procedure was written to group pixels in a 3D image cube, but I think it works
	with cubes of any number of dimensions.
 MODIFICATION HISTORY:
	NOV-1998, Paul Hick (UCSD/CASS)
	FEB-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added possibility to specify x,y,z coordinates for pixels explicitly
	    (in addition to specification of size vector of image cube only)


GuessRecs $SMEI/ucsd/gen/idl/util/guessrecs.pro
[Previous] [Next]
 NAME:
	GuessRecs
 PURPOSE:
	Guess number of records and record length for binary file
 CATEGORY:
	Tricks
 CALLING SEQUENCE:
	FUNCTION GuessRecs, iu, approx_recl, range, recl=recl
 INPUTS:
	iu	    scalar; type: integer
			logical unit number of open file
	approx_recl scalar; type: integer
			approximate record length in bytes
 OPTIONAL INPUT PARAMETERS:
	range	    scalar: type: integer: default: 1
			range of recordlength tested is approx_recl +/- range
 OUTPUTS:
	Results     scalar; type: integer
			guess at # records (-1 if not succesful)
 OPTIONAL OUTPUT PARAMETERS:
	recl = recl scalar: type: integer
			guess at record length in bytes (= file size/# records)
			(-1 if not succesful)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar
 CALLED BY:
	txt_read
 PROCEDURE:
	The approximate record length specified as input does not include record
	terminators (such as CR or CR+LF combinations).
	If the approximate record length specified is L and the range is R then
	for all values i=[L-R,L+R] the procedures checks whether i+1 or i+2 are factors
	of the file size. The largest i that satisfies this criterion is used to set
	the number of records in the file. The record length returned is the ratio of
	file size and number of records (i.e. it includes the record terminators).
 MODIFICATION HISTORY:
	MAR-2000, Paul Hick (UCSD/CASS)
	SEP-2003, Paul Hick (UCSD/CASS)
	    Fixed order in which record lengths are tested.
	    approx_recl is tested first.
	    Then record lenghts increasingly different from approx_recl:
	    approx_recl-1, approx_recl+1, approx_recl-2, approx_recl+2, etc.
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    For an empty file now nrec=recl=0 is returned,
	    instead of nrec=recl=-1.


gunzip_file $SMEI/ucsd/gen/idl/util/gunzip_file.pro
[Previous] [Next]
 NAME:
	gunzip_file
 PURPOSE:
	Unzip .gz. file
 CATEGORY:
	gen/idl/util
 CALLING SEQUENCE:
	FUNCTION gunzip_file, zipfile, rawfile, check=check, isgz=isgz, ramdisk=ramdisk
 INPUTS:
	zipfile scalar; type: string
			file to be unzipped
 OPTIONAL INPUT PARAMETERS:
	/check	    if set then check whether the file exists
	/ramdisk    by default the unzipped file is written to $TUB
		    if /ramdisk is set the environment variable $ramdisk
		    is tried first.
 OUTPUTS:
	status	    0: unzip not successfull
		    1: file succesfully unzipped into file 'rawfile'
	rawfile     scalar; type: string
			name of unzipped file (if status=1) or the blank
			string (if status=0)
 OPTIONAL OUTPUTS:
	isgz=isgz   1 if input file was .gz file; 0 if not.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, GetFileSpec, InitVar, SetFileSpec
 CALLED BY:
	bin_read, flt_read, grd_read, img_read, smei_fts_read, smei_star_readpnt, txt_read
	vox_read
 PROCEDURE:
	If the input file 'zipfile' does not exist or is not a .gz file then
	status = 0 is returned.

	The unzipped output file has the same name as the input file with
	the prefix _tmp_ added and the .gz stripped.
	By default the file is written to $TUB. If /ramdisk is set then
	$ramdisk is used (if the env var exists). Usually $ramdisk will point
	to a ramdisk. Note that the user should set up the ramdisk and make
	sure it is big enough to hold the unzipped file.
 MODIFICATION HISTORY:
	APR-2003, Paul Hick (UCSD/CASS)
	JUL-2004, Paul Hick (UCSD/CASS)
	    Added /ramdisk keyword.
	DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Change name of temp file from _tmp_* to _tmp##_*, where ## is
	    a number less than 10. The number is the lowest number that
	    make a file name for a non-existent files. This was added to
	    avoid conflicts with other program trying the same file
	    (the conflicting program might delete the temp file before it
	    is read).


gzip_file $SMEI/ucsd/gen/idl/util/gzip_file.pro
[Previous] [Next]
 NAME:
	gzip_file
 PURPOSE:
	Unzip .gz. file
 CATEGORY:
	gen/idl/util
 CALLING SEQUENCE:
	status = gzip_file( file, zipfile)
 INPUTS:
	file	scalar; type: string
			file to be unzipped
 OPTIONAL INPUT PARAMETERS:
	/check	    if set then check whether the file exists
	/nozip	    skip the actual zipping; only return the name
		    of the zipped file if it had been zipped
	/force	    force gzip if file already exists
 OUTPUTS:
	status	    0: zip not successfull
		    1: file succesfully zipped into file 'zipfile'
	zipfile     scalar; type: string
			name of zipped file (if status=1) or the blank
			string (if status=0)
 OPTIONAL OUTPUTS:
	isgz=isgz   1 if input file was .gz file; 0 if not.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, GetFileSpec, InitVar
 CALLED BY:
	smei_mksidereal, smei_mkstdstar, smei_star_remove, smei_zld_remove, vu_write, xhcs
 PROCEDURE:
	If the input file 'zipfile' does not exist or is not a .gz file then
	status = 0 is returned.
 MODIFICATION HISTORY:
	OCT-2003, Paul Hick (UCSD/CASS)
	NOV-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added /nozip keyword