say $SMEI/ucsd/gen/idl/util/say.pro
[Previous] [Next]
 NAME:
	say
 CALLING SEQUENCE:
	PRO say, str, silent=silent, threshold=threshold
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	InitVar, who_am_i
 CALLED BY:
	InsituTimeSeries, PlotEarthSkymap [1], forecast, forecast_env, forecast_ftp
	getipssources, getnagoyasources, getootyasources, is_running, mk_flick
	vu_correlate, vu_earthskymap, vu_get_page, vu_getdata, vu_gettime, vu_header
	vu_image, vu_insitu_raw, vu_lineofsight, vu_localskymap, vu_mean, vu_movie
	vu_nagoyasourcemap, vu_new_time, vu_planarcut, vu_prefix, vu_quick_movie
	vu_radialcut, vu_read, vu_remoteview, vu_select, vu_solardisk, vu_spherecut
	vu_syncgrid, vu_synopticmap, vu_timeseries, vu_update_hours, vu_update_marker
	vu_vox_sequence, vu_vox_write, vu_write


scalarproduct $SMEI/ucsd/gen/idl/toolbox/math/scalarproduct.pro
[Previous] [Next]
 NAME:
	scalarproduct
 PURPOSE:
	Calculate scalar product for two vectors
 CATEGORY:
	gen/idl/toolbox/math
 CALLING SEQUENCE:
	FUNCTION scalarproduct, r1, r2, $
	    cylin   = cylin	, $
	    sphere  = sphere	, $
	    rect    = rect	, $
	    degrees = degrees	, $
	    angle   = angle
 INPUTS:
	r1	arrays[3,*]; type: int or float
	r1	arrays[3,*]; type: int or float
		    vectors for which the product is to be taken.
		    the first dimension identifies the three coordinates: Cartesian (default),
		    cylindrical or spherical.
 OPTIONAL INPUT PARAMETERS:
	/angle	    if set then information about the angle between the two vectors is returned:
			i.e. cos(angle) = |r1.r2|/|r1||r2|
	/cylin, /sphere, /rect
		    indicates whether input vectors are in cylindrical, spherical or rectangular
			coordinates. If none is set then rectangular is assumed.
	/degrees    if set, and spherical or cylindrical coordinates are used, then the angles
			are assumed to be in degrees (default: radians)
 OUTPUTS:
	result	array[*]    same type as input
		    scalar products or angle information are returned as array[n]
 INCLUDE:
	@compile_opt.pro	    ; On error, return to caller
 CALLS: ***
	CV_COORD, InitVar, SyncArgs, SyncDims
 CALLED BY:
	RotationMeasure, haystack_2006, jpl_phase
 PROCEDURE:
 >	The arrays r1 and r2 do not necessarily have the same dimensions, i.e.
	if r1 is an array[3,n] and r2 is an array[3] then r2 is interpreted as an array[3,n]
	with all n vectors the same (SyncArgs is used to synchronize the array dimensions).
 >	Arrays r1 and r2 can have more than two dimensions, i.e. if r1 and r2 are both
	arrays[3,n,m] then the scalar products will be returned as array[n,m]
 MODIFICATION HISTORY:
	AUG-1999, Paul Hick (UCSD/CASS)
	NOV-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Extracted from vectorproduct procedure.


set_page $SMEI/ucsd/sat/idl/util/set_page.pro
[Previous] [Next]
 NAME:
	set_page
 PURPOSE:
	Setup procedure for controlling output to plot device or graphics file
	The output procedure is completed by a call to get_page
 CALLING SEQUENCE:
	PRO set_page,	$
	    eps 	= eps	    , $
	    gif 	= gif	    , $
	    bmp 	= bmp	    , $
	    png 	= png	    , $
	    xysize	= xysize    , $
	    scale_factor= scale_factor, $
	    aspect	= aspect    , $
	    fullsize	= fullsize  , $
	    winaspect	= winaspect , $
	    landscape	= landscape , $
	    portrait	= portrait  , $
	    silent	= silent    , $
	    setup_only	= setup_only, $
	    file	= file	    , $
	    zbuffer	= zbuffer   , $
	    printer	= printer   , $
	    display	= display   , $
	    ctable	= ctable    , $
	    old_device	= old_device, $
	    new 	= new	    , $
	    bigsize	= bigsize   , $
	    xoff	= xoff	    , $
	    yoff	= yoff	    , $
	    smallsize	= smallsize , $
	    notwin	= notwin    , $
	    font	= font	    , $
	    flip_bw	= flip_bw   , $
	    flip_ct	= flip_ct
 OPTIONAL INPUT PARAMETERS:
	The following keywords control the size and orientation of the output page.
	They only affect EPS, PS, HP or PRINTER devices (as keywords in the 'device'
	call). EPS is selected with the /eps keyword. PS, HP and PRINTER is used
	depending on !ThePrinter (initialized during startup).

	/landscape	plot in landscape mode
	/portrait	plot in portrait mode
			    If neither of these is set then /landscape is used
			    Only used to set up PS, EPS or default PRINTER.
	xysize=xysize	scalar, or array[2]; type: float
			    horizontal and vertical size of page (in cm for printer,
			    in pixel for display and z-buffer). If a scalar is
			    specified it is assumed to be the horizontal size
	/fullsize	overrides 'xysize' keyword. For the printer xysize is set
			    to the full page size, for other devices [!d.x_size,
			    !d.ysize] is used

			If xysize is not specified then default values are selected
			depending on whether /landscape of /portrait is used.
			If specified then aspect (or /winaspect) overrides either
			xsize of ysize to establish the proper aspect.

	aspect=aspect	scalar; type: float
			    aspect ratio (=ratio vertical/horizontal size
	/winaspect	same as: aspect = !d.y_size/!d.x_size
			    i.e. the aspect ratio of the active window is used
	/silent 	suppresses informational messages
	/setup_only	the command 'set_page, /setup, /silent' is used during
			    IDL_startup to set up the default printer. The plot
			    device is NOT changed, and !ThePlotFile is NOT set (i.e.
			    is set to the null string)

	/eps		sets the plot device to PS and opens an EPS file
			    !ThePlotFile is set to IDL.EPS or 'File'
	/gif		sets the plot device to !TheTerminal
			    !ThePlotFile is set to IDL.GIF or 'File'
	/png		sets the plot device to !TheTerminal
			    !ThePlotFile is set to IDL.PNG or 'File'
	/bmp		sets the plot device to !TheTerminal
			    !ThePlotFile is set to IDL.BMP or 'File'
	/zbuffer	NOT WORKING YET
 OUTPUTS:
	xysize=xysize	array[2]; type: integer
			    [!d.x_size, !d.y_size] on return
	old_device=old_device
			scalar; type: string
			    original graphics device (i.e. value of !d.name when
			    this procedure is called)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, GetFileSpec, InitVar, IsType, LOADCT, destroyvar, do_file, flip_colors, twin
 CALLED BY:
	GetColors [2], GetColors [3], IDL_postop_linux, IDL_postop_vms, IDL_postop_win
	PlotEarthSkymap [2], PlotEarthSkymap [3], PlotEarthSkymap [4], allsky [1]
	allsky [2], allsky [3], allsky_f, ark_duty_cycle, coriolis_map, dusan_earth
	even_light_corrections, even_light_photometry, even_light_registration
	fileset_sizes, grdout, ips_exit, ipv6_packets, ipv6_traffic, krill_request_bars
	krill_request_stats, miscfig, packet_size_graphs, packet_size_update
	qset_page_submit, show_wso, smei_frm_summary, smei_hdr_plot, smei_sky
	smei_star_show, smei_zldsky, smeifig, telescope_sizes, thomsonfig, vu_coronagraph
	vu_earthskymap, vu_elotime, vu_insitu, vu_insitu_persist, vu_planarcut
	vu_solardisk, vu_spherecut, vu_synopticmap, vu_thomson_antifish
	vu_thomson_hammer
 SEE ALSO:
	qset_page
 PROCEDURE:
	Pretty darn ugly.
	The plot device is set to !ThePrinter, or PS (if /eps is set) or
	!TheTerminal (if /gif or /bmp are set).
	!ThePlotFile is always set. Unless argument 'File' is used
	the file name will be IDL.EPS, IDL.GIF or IDL.BMP (if /eps, /gif or /bmp are
	set) or IDL.HP, IDL.PS or IDL.PRINTER (depending on the value of
	!ThePrinter). Note that in the last case (IDL.PRINTER) no plot file is used
	since the output goes directly to the printer.
	For HP and PS the graphics output is collected in the output file, which is
	then send to the printer using get_page
 MODIFICATION HISTORY:
	MAR-1995, Paul Hick (UCSD/CASS)
	MAR-1998, Paul Hick (UCSD/CASS); added PRINTER device
	MAR-2000, Paul Hick (UCSD/CASS)
	    added /gif and /bmp keywords, updated documentation
	???-2002, Paul Hick (UCSD/CASS)
	    added /png keyword
	AUG-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    added /color to device call for EPS


SetFileSpec $SMEI/ucsd/gen/idl/toolbox/files/setfilespec.pro
[Previous] [Next]
 NAME:
	SetFileSpec
 PURPOSE:
	Split file names into file components.
	Optionally parse the file names.
 CATEGORY:
	gen/idl/toolbox/files
 CALLING SEQUENCE:
	PRO SetFileSpec, FileSpec, FileParts, $
	    parse   = Parse , $
	    nosave  = NoSave, $
	    strict  = strict, $
	    status  = Status
 INPUTS:
	FileSpec    string array or scalar, containing file names
		(read-only)
 OPTIONAL INPUT PARAMETERS:
	/parse	    if set, the file names are parsed.
		parsing is successful if
		- The directory exists
		- There is write access to the directory
		- The file name is valid (the file may or may not exist)
		  (if no file name is specified this step is skipped)
		If the parsing is succesful, missing file parts will
		be added to the FileParts array; if not all parts are
		set to the null string.
	/nosave     by default, the FileParts array returned as ouput
		is saved internally in a common block (which can
		be accessed with GetFileSpec and PutFileSpec).
		if nosave is set, the internal data are not overwritten.
	/strict     by default the file type is the part of the
		filename trailing the last dot, i.e. if the file name
		is file.txt.gz, the file type is .gz.
		If /strict is set the type becomes the part following
		the first dot, i.e. the type is .txt.gz.
 OUTPUTS:
	FileParts   string array with one dimension more than
		FileSpec; the extra first dimension has 6 elements,
		containing node, device, directory, name, type, version
		!!! the FileParts argument is sometimes useful in
		combination with the /nosave keyword. Preferably this
		argument should not be used; instead use GetFileSpec
		and PutFileSpec to manipulate the same information.
 OPTIONAL OUTPUT PARAMETERS:
	status=Status	long integer array with same dimensions as FileSpec.
		If keyword Parse set:
		  0 : indicates that parsing failed
		  1 : indicates that parsing was succesfull
		If keyword Parse not set, all values are set to 1
 CALLS: ***
	CheckDir, FILEPATH, FindAllFiles, InitVar, IsType, SyncDims, os_separator, strposn
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@filespec_common.pro	; Common block with arrays File and Parts
 CALLED BY:
	FindAllFiles, FindAllSubDirs, GetFileSpec, PlotEarthSkymap [2], PutFileSpec
	allsky [1], allsky [2], allsky [3], allsky_f, aurora, badpix, bin_read, bin_write, clean
	cvgrd, cvgrd_skymap, do_file, findfile_fix, forecast_ftp, get_page, gunzip_file
	makediff, makemovie [1], makemovie [2], mk_flick, nso_fe_read, qImage, qImage_Pick
	qImage_cw_SmeiMask, qRemoteView_Pick, qSave2File_Save, qView, qView_FileFilter
	qView_PickFiles, qView_Save2File, qView_TMO_tracksky, qset_page_pick, smei_buf
	smei_frm_update, smei_www_skymaps, test_td, tolowcase, usno_body, vu_check
	vu_coronagraph, vu_earthskymap, vu_extract, vu_get_page, vu_getdata, vu_header
	vu_image, vu_insitu, vu_lineofsight, vu_movie, vu_quick_movie, vu_remoteview
	vu_vox_write, www_help_crosslinks, www_help_files, www_help_get_header
	www_help_get_info
 SIDE EFFECTS:
	Internal data are maintained internally (a copy of FileParts)
 RESTRICTIONS:
	FileSpec containing relative directory specifications
	(e.g. [], [-] on VMS, or . and .. on Win32 and Unix), cause
	problems for GetFileSpec. If these are present, then /parse
	should be used to remove them.
 PROCEDURE:
 >	Parsing: the existence check for the directory is done using CheckDir.
	The fully-parsed directory returned by CheckDir is used, so the parse
	keyword can be used to expand environment variables, e.g.
	    SetFileSpec, '$dat/tmo/*.nic', /parse
	    print, GetFileSpec()
	would print (provided the directory exists):
	    /big/oftp/dat/tmo/*.nic
 > If a wildcard is specified in the file name then only the directory
	is parsed.
 >  For an existing file the full file name is obtained using FindAllFiles.
   If the file does not exist, an attempt is made to open
	the file with OPENW to establish that the syntax is valid;
	FindAllFiles is used to obtain the full file name before closing and
	deleting the file again.
 >	The filenames are split up into parts by a series of strposn calls
 >	FileSpec='' (null string) is interpreted as the current working directory,
	and will always return status=1.
 MODIFICATION HISTORY:
	DEC-1997, Paul Hick (UCSD/CASS)
	FEB-2002, Paul Hick (UCSD/CASS)
	    Remove bug which caused problems when multidimensional arrays
	    of filenames were processed.
	JAN-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    If a wildcard (*) is specified in the filename part then only the
	    directory is checked when the /parse keyword is set.


SetRange $SMEI/ucsd/gen/idl/toolbox/setrange.pro
[Previous] [Next]
 NAME:
	SetRange
 PURPOSE:
	Set range of values, checking against a default range
 CATEGORY:
	Tricks
 CALLING SEQUENCE:
	new = SetRange(default, range [, /lower_limit])
 INPUTS:
	default 	array[2]; type: any
			    upper and lower limits on allowed values
 OPTIONAL INPUT PARAMETERS:
	range		scalar or array[2]
			    range to be checked against 'default'
	/lower_limit	if set then a scalar 'range' is interpreted as
			a lower limit (default is upper limit)
 OUTPUTS:
	new		array[2]
			    updated range of values
			    if 'range' undefined then 'new' is set to 'default'
			    if 'range' is scalar then new = [range,default[1]] is
			    returned (/lower_limit is set), or new = [default[0],range[1]]
			    is returned (/lower_limit not set
			    Always 'range' is constrained to stay inside the limits set by 'default'
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar
 CALLED BY:
	RemoteView_rgbo
 PROCEDURE:
	Trivial
 MODIFICATION HISTORY:
	JUN-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


setup3d $SMEI/ucsd/sat/idl/toolbox/tricks/setup3d.pro
[Previous] [Next]
 NAME:
	setup3d
 PURPOSE:
	Sets up scaling (!x.s, !y.s, !z.s) and transformation matrix (!p.t)
 CATEGORY:
 CALLING SEQUENCE:
	setup3d, d0, d1, n0, n1 [, /rotate, /oblique]
	setup3d, d0, d1, n0, n1 [, rotate=[[a,b,c],[d,e,f]], oblique=[p,q] ]
 INPUTS:
	d0	scalar or array[3]; default: -1.5*[1,1,1]
	d1	scalar or array[3]; default:  1.5*[1,1,1]
		    begin and end of data coordinate range
		    scalars are interpreted as scalar*[1,1,1]
	n0	scalar or array[3]; default:  0.0*[1,1,1]
	n1	scalar or array[3]; default:  1.0*[1,1,1]
		    begin and end of normal coordinate range
		    scalars are interpreted as scalar*[1,1,1]

		!x.s, !y.s and !z.s are set up to map data ranges [d0,d1] to normal ranges [n0,n1]
 OPTIONAL INPUT PARAMETERS:
	rotate=rotate
		array[3,n] or array[3*n]; type: float
		    The special form /rotate is identical to rotate=[ [ 0.,-20.,0.], [20., 0. ,0.] ]
		    Set of rotations to be set up in !p.t matrix
		    rotations are processed left to right; rotate[0,*], rotate[1,*] and rotate[2,*]
		    are rotations around x,y and z-axis respectively
	oblique=oblique
		array[2]; type: float
		    The special form /oblique is identical to oblique=[.4,-125]
		    Parameters for an oblique projection
	/xyplane    Puts x-y plane in plane of screen
	/yzplane    Pust y-z plane in plane of screen
	/xzplane    Puts x-z plane in plane of screen
 OUTPUTS:
	Sets !x.s, !y.s, !z.s and !p.t
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	T3D, t3d_oblique
 CALLED BY:
	PlotPlanarCut, PlotSolarDisk, RemoteView_PlotVertices, brachistochrone
	cvplot_figures, even_light_figures, losgeometry, miscfig, projfig, qimage_fig
	qvu_draw, smeifig, ss_map, thomsonfig, tomography_sp
 RESTRICTIONS:
 PROCEDURE:
	!p.t is first reset. Then clockwise rotations around y and z-axis over 90 degrees are
	executed to point the x-axis perpendicular to the screen, the y-axis pointing right and the
	z-axis pointing up in the plane of the screen.
	After that the rotations supplied as keywords are applied, followed by the oblique projection.
 MODIFICATION HISTORY:
	AUG-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


sgp4_eph $SMEI/ucsd/gen/idl/ephem/sgp4_eph.pro
[Previous] [Next]
 NAME:
	sgp4_eph
 PURPOSE:
	Get location of Coriolis spacecraft in ECI coordinates
 CATEGORY:
	gen/idl/ephem
 CALLING SEQUENCE:
	FUNCTION sgp4_eph, tt_obs, body_, $
	    km	    = km	, $
	    location= location	, $
	    source  = source	, $
	    precess = precess
 INPUTS:
	tt_obs		array[n]; type: time structure
			    UT time
 OPTIONAL INPUTS:
	body_		scalar; type: string; default: 'sat27640'
			    spacecraft designation
			    The default sat27640 is Coriolis.
	km=km		if set, return distance in km instead of AU
	source=source	scalar; type: string; default: who_am_i(/dir)/sgp
			    directory where TLE file is located (by default the
			    subdir sgp of the dir where this file is located.
	/precess	precess position and velocity vector to J2000 coordinates
			    (used by big_eph)
 OUTPUTS:
	rr[6,n] 	location and velocity
			    Coordinates are valid for the current epoch and equinox,
			    unless /precess is set (see PROCEDURE).
			    If /location is set only r[0:2,n] is returned.
			    If the required file with TLEs is not found
			    then the output vector contains NaNs.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, BadValue, CvPrecess, FILEPATH, InitVar, SuperArray, TimeFixYear
	TimeLimits, TimeOp, TimeSet, TimeUnit, hide_env, sgp_alias, txt_read, who_am_i
 CALLED BY:
	big_eph, coriolis_map, sgp4_orbit_axis, smei_frm_cvhdr, smei_frm_where
	smei_sgp4_orbits, smei_sgp4_quat
 PROCEDURE:
	The file with orbital elements is 'body.txt' i.e. sat27640.txt for
	Coriolis. The file is looked for in the subdirectory sgp of the
	directory where this source code is located. Used keyword 'source'
	to point to another subdirectory.
	Orbital elements can be retrieved from www.space-track.org

	Excerpt from http://celestrak.com/columns/v02n01/:

	"As it turns out, the NORAD SGP4 orbital model takes the standard
	two-line orbital element set and the time and produces an ECI
	position and velocity for the satellite. In particular, it puts it
	in an ECI frame relative to the "true equator and mean equinox of
	the epoch" of the element set. This specific distinction is
	necessary because the direction of the Earth's true rotation axis
	(the North Pole) wanders slowly over time, as does the true direction
	of the vernal equinox. Since observations of satellites are made
	by stations fixed to the Earth's surface, the elements generated
	will be referenced relative to the true equator. However, since the
	direction of vernal equinox is not tied to the Earth's surface, but
	rather to the Earth's orientation in space, an approximation must
	be made of its true direction. The approximation made in this case is
	to account for the precession of the vernal equinox but to ignore the
	nutation (nodding) of the Earth's obliquity (the angle between the
	equatorial plane and the ecliptic)."
 MODIFICATION HISTORY:
	MAR-2005, Paul Hick (UCSD/CASS)
	SEP-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Reduced memory requirements by extracting TLE bracketing the
	    input time range tt_obs


sgp4_orbit_axis $SMEI/ucsd/gen/idl/ephem/sgp4_orbit_axis.pro
[Previous] [Next]
 NAME:
	sgp4_orbit_axis
 PURPOSE:
	Gets ECI coordinates for Coriolis orbital axis (i.e. the normal
	to the orbital plane, close to the sunward direction).
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION sgp4_orbit_axis, tt, $
	    degrees	= degrees   , $
	    to_sphere	= to_sphere , $
	    precess	= precess
 INPUTS:
	tt	array; type: time structure
 OPTIONAL INPUT PARAMETERS:
	/to_sphere  if set return spherical (RA,dec) coordinates
	/degrees    if set, angles are in degrees (default: radians)
	/precess    (passed to sgp4_eph)
		    precess to J2000 coordinates
 OUTPUTS:
	rr	array[3,*]; type: double
		    coordinates of a unit vector along the normal
		    to the SMEI orbital plane in rectangular (/to_sphere
		    NOT set) or spherical (RA,dec) coordinates
		    (/to_sphere) SET.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, CV_COORD, InitVar, IsTime, TimeOp, TimeSet, TimeSystem, TimeUnit, gridgen
	sgp4_eph, vectorproduct
 CALLED BY:
	cv, smei_normal, smei_sgp4_orbits, smei_zld_weekly
 PROCEDURE:
	Viewed from the Sun SMEI circles the Earth close to the terminator
	in anti-clockwise direction (going north towards the east (dusk
	terminator) and south in the west (dawn terminator).
	The normal, defined as the cross produce of position and velocity
	vector points towards the Sun.
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS)
	MAR-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added more documentation.


sgp4_orbit_period $SMEI/ucsd/gen/idl/ephem/sgp4_orbit_period.pro
[Previous] [Next]
 NAME:
	sgp4_orbit_period
 PURPOSE:
 CATEGORY:
 CALLING SEQUENCE:
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS: ***
	BadValue, SyncArgs, sgp4_tle
 CALLED BY:
	smei_sgp4_orbits
 PROCEDURE:
 MODIFICATION HISTORY:
	JUNE-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


sgp4_tle $SMEI/ucsd/gen/idl/ephem/sgp4_tle.pro
[Previous] [Next]
 NAME:
	sgp4_tle
 PURPOSE:
	Extract orbital elements covering bracketing tt_obs from
	tle data base file
 CATEGORY:
	gen/idl/ephem
 CALLING SEQUENCE:
	status = sgp4_tle(tt_obs,body_,source=source,tle=tle,tt_tle=tt_tle)
 INPUTS:
	tt_obs		array[n]; type: time structure
			    UT time
 OPTIONAL INPUTS:
	body_		scalar; type: string; default: 'sat27640'
			    spacecraft designation
			    The default sat27640 is Coriolis.
	source=source	scalar; type: string; default: who_am_i(/dir)/sgp
			    directory where TLE file is located (by default the
			    subdir sgp of the dir where this file is located.
 OUTPUTS:
	status		scalar; type: integer
			    0: the ephemeris find is not found or there
				is a read error. In this case tle and tt_tle
				won't exist
			    1: tles found
	tle=tle 	array[2,ntle]; type: string
			    tle (each tle consists of two records)
			    the tles will bracket the input time period tt_obs
	tt_tle		array[ntle]; type: time structure
			    times extracted from tle records
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, FILEPATH, InitVar, SuperArray, TimeFixYear, TimeLimits, TimeOp, TimeSet
	TimeUnit, hide_env, sgp_alias, txt_read, who_am_i
 CALLED BY:
	sgp4_orbit_period
 PROCEDURE:
	The file with orbital elements is 'body.txt' i.e. sat27640.txt for
	Coriolis. The file is looked for in the subdirectory sgp of the
	directory where this source code is located. Used keyword 'source'
	to point to another subdirectory.
	Orbital elements can be retrieved from www.space-track.org
 MODIFICATION HISTORY:
	DEC-2005, Paul Hick (UCSD/CASS)
	    Extracted from sgp4_eph


sgp_alias $SMEI/ucsd/gen/idl/ephem/sgp_alias.pro
[Previous] [Next]
 NAME:
	sgp_alias
 PURPOSE:
	Translates aliases for satellite names to their sgp names
 CATEGORY:
	gen/idl/ephem
 CALLING SEQUENCE:
	name = alias_sgp(body)
 INPUTS:
	body	    array: type: string
			alias for satellite name
 OUTPUTS:
	name	    array: type: string
			sgp name for satellite
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	big_body, big_eph, sgp4_eph, sgp4_tle
 PROCEDURE:
	Currently only aliases 'coriolis','windsat' and 'smei' are
	converted to sgp name 'sat2740'
 MODIFICATION HISTORY:
	JUN-2006, Paul Hick (UCSD/CASS)
	SEP-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Bugfix? Unidentified bodies would be returned in lowercase.
	    Now they remain untouched.


sgp_body $SMEI/ucsd/gen/idl/ephem/sgp_body.pro
[Previous] [Next]
 NAME:
	sgp_body
 PURPOSE:
	Get list of bodies for which SGP ephemerides are available
 CATEGORY:
	smei/gen/idl/ephem
 CALLING SEQUENCE:
	sgp_nams = sgp_body([body, files=files, numbers=numbers, count=count])
 OPTIONAL INPUT PARAMETERS:
	body	    scalar or array; type: integer or string
			    integer: list of body numbers
			    string : list of body names
				only valid entries on this list are processed
				If not specified then all bodies are processed
 OUTPUTS:
	names		array[count]; type: string
			    list of body names for which ephemeris files
			    are available; if none exist (count=0) then names=''
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			    # requested bodies for which ephemeris files are present
			    i.e. # elements in input 'body' with invalid entries removed
	file=file	array[count]; type: string
			    file names of the ephemeris files; null-string if count=0
	number=number	array[count]; type: integer
			    body numbers; -1 if count=0
	index=index	array[count]; type: integer
			    index numbers between 0, and total_count-1; -1 if count=0
	total_count=total_count
			scalar; type: integer
			    total # bodies for which ephemeris files are present
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, GetFileSpec, IsType, hide_env, where_common, who_am_i
 CALLED BY:
	RemoteView_BodyLoc, big_body, big_eph
 PROCEDURE:
 >	Currently only 9P/Tempel (comet Tempel 1 around 'deep impact' time) is available
 >	The SGP files are searched for in the subdirectory 'sgp' of the directory
	where this procedure is located.
 MODIFICATION HISTORY:
	JUL-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Based on usno_body()


show_wso $SMEI/user/pphick/idl/show_wso.pro
[Previous] [Next]
 NAME:
	show_wso
 PURPOSE:
 CALLS: ***
	FILEPATH, InitVar, PlotSynopticMap, SuperArray, WhatIs, get_page, gridgen, set_page
	view, wso_read
 MODIFICATION HISTORY:


Sky_ColorView [1] $SMEI/user/jclover/from_ztemp/Vu_F3DF6.pro
[Previous] [Next]
 NAME:
   Sky_ColorView
 PURPOSE:
   Calculates image of sky from 3D density matrix for a given viewer location
   and viewing direction.
 CATEGORY:
   Image construction
 CALLING SEQUENCE:
   Sky_ColorView, F3D, R3D,   $
     rotation = Rotation,     $
     states	= States,	$
     dostates = DoStates,     $
     /heliographic,	     $
     /degrees,		    $
     /cartesian,	    $
     eqdistance   = EqDistance, $
     eqangle   = EqAngle,   $
     eqarea	= EqArea
 INPUTS:
     F3D	    array[N,L,M]; type: float
		    3D data array
		    Cartesian: N=L=M; cube of data with Sun in the center
		    Spherical: N=# longitudes covering 360 deg
			    L=# latitudes  covering -90,90 deg
			    M=# heliocentric distances covering [R3D[0],R3D[1]]
     R3D	    scalar, array[2]; type: float; default: [0,1.5]
		    A scalar is interpreted as [0,R3D]
		    Determines size of volume covered by F3D (in AU)
		    Cartesian: R3D[1] is half the size of the cube covered by F3D
			  (R3D[0] is not used)
		    Spherical: heliocentric distance range covered by F3D

     rotation=Rotation	  scalar; type: float

      The density matrix is assumed to reflect the heliospheric density
      for a whole Carrington rotation (360 degree in heliographic longitude)
      starting at the value 'rotation'.
      The value of Rotation is used in three ways:
      1. the fractional part is used to set the starting heliographic longitude,
	  e.g. 1884.0 starts at 0 degrees; 1884.25 at 270 degrees.
      2. if the image time in the States array is set to !values.f_nan, it is
	  assumed to be the time at which the longitude corresponding to 'Rotation'
	  crossed the central meridian (i.e. it is set to CarringtonT(Rotation))
      3. Rotation is passed to ReadSynopticMap to read in a map to be wrapped around
	  the surface of the Sun

     states = States   float array[8,*]

      Each state is processed separately, and results in an image
      All angles are in radians unless /degrees is set.

      State[0]	     time of image in days since 2000 Jan 1.5 (mjd2).
		if equal to !values.f_nan it is set to the start of the
		rotation specified in the rotation keyword
      State[1:3]   position of viewer (longitude, latitude, heliocentric distance)
		By default, ecliptic coordinates are assumed.
		Set /heliographic keyword to input heliographic coordinates.
		The heliocentric distance is in AU.
      State[4:5]   viewing direction corresponding to center of image
		(longitude, latitude) in the same coordinate system as used for
		the viewer location, but with the viewer in the origin.
      State[6]	     Angular width of rectangular field of view
      State[7]	     ??? Tilt angle of field of view. Zero tilt means that the horizontal
		direction in the image is parallel to the ecliptic or solar
		equator (depending on the setting of keyword /heliographic)
		Tilt angle increases counterclockwise.
 OPTIONAL INPUT PARAMETERS:
   dostates = DoStates
	       scalar, or array[2]; type: integer; default: all states
	       defines subset of States array to be processed in terms of
	       index to States array (0,..,n_elements(States)-1)
	       if scalar: process states from DoStates to n_elements(States)-1
	       if array : process states from DoStates[0] to DoStates[1]
   /heliographic     if set, angles specified in the state array are assumed to
	       in heliographic coordinates (default: ecliptic coordinates)
   /degrees	  if set, angles used in viewer location and viewing direction
	       are assumed to be in degrees (default: radians)
   /cartesian	      if set, the array F3D is assumed to refer to
	       a Cartesian coordinate system with linear dimensions [N,L,M].
	       x-coord = n, n=0,N-1
	       y-coord = l, l=0,L-1
	       z-coord = m, m=0,M-1
   /stereo
   stereo=[Angle,Distance]
      /stereo	  if set, stereo pairs are produced using default
	       settings for stereo angle (6 degrees) and
	       distance (Sun-viewer distance)
      stereo=[Angle, Distance]
	       if specified as a two-element array, the first
	       element is used as stereo angle, the second as
	       stereo distance. If the distance is set to zero
	       then the viewer-origin distance Loc[2,*] is used.
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
   states = States
      array[8,*]; type: float or double
	  times set to 'bad value' !values.f_nan will be filled in using
	  the start time of 'rotation'
 CALLS:
	CMEDensity, CarringtonT, CubeFrame, CvSky, EarthOrbit, FILEPATH, GlobePosition
	GlobeSize, ReadSynopticMap, SkyDisplay, SkyFOVTilt, SkyGrid, SkyStereoStates
	Sky_BodyColors, TimeBuild, TimeGet, TimeSet, TimeString, UTSystem, VertexMap
	VertexSphere, ZEclipticPlane, skycolors
 CALLED BY:
	SkyForecast, test_td
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
   ???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
   NOV-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
     Added nGrid keyword to allow specification of viewing space dimensions
     for each of the three dimensions separately.
     Added rInner keyword to allow specification of inner boundary for a
     density matrix specified in spherical coordinates (was always set to zero before).


Sky_ColorView [2] $SMEI/user/jclover/from_ztemp/Vu_thomson_remote.pro
[Previous] [Next]
 NAME:
   Sky_ColorView
 PURPOSE:
   Calculates image of sky from 3D density matrix for a given viewer location
   and viewing direction.
 CATEGORY:
   Image construction
 CALLING SEQUENCE:
   Sky_ColorView, F3D, R3D,   $
     rotation = Rotation,     $
     states	= States,	$
     dostates = DoStates,     $
     /heliographic,	     $
     /degrees,		    $
     /cartesian,	    $
     eqdistance   = EqDistance, $
     eqangle   = EqAngle,   $
     eqarea	= EqArea
 INPUTS:
     F3D	    array[N,L,M]; type: float
		    3D data array
		    Cartesian: N=L=M; cube of data with Sun in the center
		    Spherical: N=# longitudes covering 360 deg
			    L=# latitudes  covering -90,90 deg
			    M=# heliocentric distances covering [R3D[0],R3D[1]]
     R3D	    scalar, array[2]; type: float; default: [0,1.5]
		    A scalar is interpreted as [0,R3D]
		    Determines size of volume covered by F3D (in AU)
		    Cartesian: R3D[1] is half the size of the cube covered by F3D
			  (R3D[0] is not used)
		    Spherical: heliocentric distance range covered by F3D

     rotation=Rotation	  scalar; type: float

      The density matrix is assumed to reflect the heliospheric density
      for a whole Carrington rotation (360 degree in heliographic longitude)
      starting at the value 'rotation'.
      The value of Rotation is used in three ways:
      1. the fractional part is used to set the starting heliographic longitude,
	  e.g. 1884.0 starts at 0 degrees; 1884.25 at 270 degrees.
      2. if the image time in the States array is set to !values.f_nan, it is
	  assumed to be the time at which the longitude corresponding to 'Rotation'
	  crossed the central meridian (i.e. it is set to CarringtonT(Rotation))
      3. Rotation is passed to ReadSynopticMap to read in a map to be wrapped around
	  the surface of the Sun

     states = States   float array[8,*]

      Each state is processed separately, and results in an image
      All angles are in radians unless /degrees is set.

      State[0]	     time of image in days since 2000 Jan 1.5 (mjd2).
		if equal to !values.f_nan it is set to the start of the
		rotation specified in the rotation keyword
      State[1:3]   position of viewer (longitude, latitude, heliocentric distance)
		By default, ecliptic coordinates are assumed.
		Set /heliographic keyword to input heliographic coordinates.
		The heliocentric distance is in AU.
      State[4:5]   viewing direction corresponding to center of image
		(longitude, latitude) in the same coordinate system as used for
		the viewer location, but with the viewer in the origin.
      State[6]	     Angular width of rectangular field of view
      State[7]	     ??? Tilt angle of field of view. Zero tilt means that the horizontal
		direction in the image is parallel to the ecliptic or solar
		equator (depending on the setting of keyword /heliographic)
		Tilt angle increases counterclockwise.
 OPTIONAL INPUT PARAMETERS:
   dostates = DoStates
	       scalar, or array[2]; type: integer; default: all states
	       defines subset of States array to be processed in terms of
	       index to States array (0,..,n_elements(States)-1)
	       if scalar: process states from DoStates to n_elements(States)-1
	       if array : process states from DoStates[0] to DoStates[1]
   /heliographic     if set, angles specified in the state array are assumed to
	       in heliographic coordinates (default: ecliptic coordinates)
   /degrees	  if set, angles used in viewer location and viewing direction
	       are assumed to be in degrees (default: radians)
   /cartesian	      if set, the array F3D is assumed to refer to
	       a Cartesian coordinate system with linear dimensions [N,L,M].
	       x-coord = n, n=0,N-1
	       y-coord = l, l=0,L-1
	       z-coord = m, m=0,M-1
   /stereo
   stereo=[Angle,Distance]
      /stereo	  if set, stereo pairs are produced using default
	       settings for stereo angle (6 degrees) and
	       distance (Sun-viewer distance)
      stereo=[Angle, Distance]
	       if specified as a two-element array, the first
	       element is used as stereo angle, the second as
	       stereo distance. If the distance is set to zero
	       then the viewer-origin distance Loc[2,*] is used.
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
   states = States
      array[8,*]; type: float or double
	  times set to 'bad value' !values.f_nan will be filled in using
	  the start time of 'rotation'
 CALLS:
	CMEDensity, CarringtonT, CubeFrame, CvSky, EarthOrbit, FILEPATH, GlobePosition
	GlobeSize, ReadSynopticMap, SkyDisplay, SkyFOVTilt, SkyGrid, SkyStereoStates
	Sky_BodyColors, TimeBuild, TimeGet, TimeSet, TimeString, UTSystem, VertexMap
	VertexSphere, ZEclipticPlane, skycolors
 CALLED BY:
	SkyForecast, test_td
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
   ???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
   NOV-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
     Added nGrid keyword to allow specification of viewing space dimensions
     for each of the three dimensions separately.
     Added rInner keyword to allow specification of inner boundary for a
     density matrix specified in spherical coordinates (was always set to zero before).


skycolors $SMEI/ucsd/sat/idl/shared/skycolors.pro
[Previous] [Next]
 NAME:
	skycolors
 CALLED BY:
	Sky_ColorView [1], Sky_ColorView [2]


skyd_cat $SMEI/ucsd/camera/idl/toolbox/skyd_cat.pro
[Previous] [Next]
 NAME:
	skyd_cat
 PURPOSE:
	Creates the initial orbit catalogues needed by the
	SMEI skyd daemon.
 CALLING SEQUENCE:
	PRO skyd_cat, range, $
	    camera	= camera    , $
	    mode	= mode	    , $
	    source	= source    , $
	    dig 	= dig	    , $
	    destination = destination,$
	    to_smeidb	= to_smeidb , $
	    full_count	= full_count, $
	    keepskip	= keepskip  , $
	    smoothdark	= smoothdark, $
	    reverse_order= reverse_order
 INPUTS:
	range		array[2]; type: time structure
			    time range for which to produce a catalogue.
			    If omitted the entire mission time is used.
 OPTIONAL INPUTS:
	camera=camera	    array or scalar; type: integer; default: [1,2,3]
				SMEI cameras to be processed
	mode=mode	    array or scaler; type: integer; default: [0,1,2]
				modes to be processed
	source=source	    scalar or array; type: string; default: SMEISKY?
				list of directories with skymaps.
				The default SMEISKY? is translated to all
				directories assigned to env vars $SMEISKYn
	/dig		    If /dig is set then the skymaps should be located
				in subdirectories c1,c2,c3.
				IF source=SMEISKY? then always /dig is assumed
	destination=destination
			    scalar; type: string; default: $TUB
				destination directory for the skyd catalogues
	/to_smeidb	    forces destination=$SSWDB_SMEI/cat/list
				(see PROCEDURE)
	/full_count	    by default the sky catalogues are based on the frame
			    counts for frames satisfying the default conditions
			    used by smeidb_sky for frame selection (not a "just-bad"
			    frame, good quaternion, shutter open and base OK;
			    this is the second set of 4 columns in
			    the smei_frm_orb_m<mode>.txt files).
			    If full_count is set then the unrestricted counts for
			    all frames per orbit (the first set of 4 columns in the
			    smei_frm_orb_m<mode>.txt files) is used.
	/keepskip	    by default, orbits marked 'skip' are not written
			    into the catalogue files. Set /keepskip to override.
	/smoothdark	    create catalogues for the skymaps based on smoothed
			    dark currents (cam 3 only).
			    (By default, skyd_cat looks in the c1,c2,c3 directories
			    of $SMEISKY0/sky. Setting this keyword forces it to
			    look in the c3s directory).
	/reverse_order	    by default, catalogues are written in reverse
			    chronological order (i.e. the most recent data get
			    processed first). To reverse this, and process data
			    chronologically set this keyword.
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	CheckDir, FILEPATH, FXPAR, FindAllFiles, HEADFITS, InitVar, IsTime, IsType, TimeGet
	TimeOp, TimeSet, TimeUnit, boost, destroyvar, flt_string, hide_env, smei_filename
	smei_filepath, timeposn, txt_read
 CALLED BY:
	smei_mksky
 PROCEDURE:
	The skyd catalogues are derived from the files
	smei_frm_orb_m0.txt, smei_frm_orb_m1.txt and smei_frm_orb_m2.txt
	in directory $SSWDB_SMEI/cat/list. These files list the numbers
	of frames for each camera in each of three modes. They are
	created and maintained by the IDL procedure
	smei_orbit_stats (through a daily cronjob).

	The skyd_catalogues will have names skyd_c<cam>m<mode>.txt
	where <cam> is the camera id (1,2,3) and <mode> the mode id
	<0,1,2>. The files are written to directory 'destination'.
	If /to_smeidb is set the destination directory is the same
	as for the smei_frm_orb_m*.txt files ($SSWDB_SMEI/cat/list).
	These catalogues are accessed by the Python script
	skyd_orbit (which in turn is used by the SMEI
	skyd daemon skyd_wait).
 MODIFICATION HISTORY:
	DEC-2005, Paul Hick (UCSD/CASS)
	MAR-2007, Paul Hick (UCSD/CASS)
	    Added keyword /full_count
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword /reverse_order


skyd_pass2make $SMEI/sys/skyd/skyd_pass2make.pro
[Previous] [Next]
 NAME:
	skyd_pass2make
 PURPOSE:
	Runs through SKYD orbit catalogues to replace
	orbits marked "pass" back to "make"
 CATEGORY:
	skyd
 CALLING SEQUENCE:
	PRO skyd_pass2make
 INPUTS:
 OUTPUTS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	destroyvar, txt_read
 PROCEDURE:
 MODIFICATION HISTORY:
	DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


skyd_reverse $SMEI/sys/skyd/list/skyd_reverse.pro
[Previous] [Next]
 NAME:
	skyd_reverse
 CALLING SEQUENCE:
	PRO skyd_reverse, f
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	InitVar, txt_read


skyd_version $SMEI/ucsd/camera/idl/toolbox/skyd_version.pro
[Previous] [Next]
 NAME:
	skyd_version
 PURPOSE:
	Creates catalogue with software version numbers used
	to create skymap database
 CALLING SEQUENCE:
	PRO skyd_version, $
	    camera	= camera    , $
	    destination = destination,$
	    to_smeidb	= to_smeidb
 OPTIONAL INPUTS:
	camera=camera	    array or scalar; type: integer; default: [1,2,3]
				SMEI cameras to be processed
	destination=destination
			    scalar; type: string; default: $TUB
				destination directory for the skyd_equ catalogues
	/to_smeidb	    forces destination=$SSWDB_SMEI/cat/list
				(see PROCEDURE)
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	CheckDir, FILEPATH, FXPAR, HEADFITS, InitVar, SFLOAT, TimeGet, TimeSet, TimeUnit, hide_env
	smei_filepath, smei_getfile, smei_star_readpnt
 PROCEDURE:
 MODIFICATION HISTORY:
	JUN-2008, Paul Hick (UCSD/CASS)


SkyDriveIn $SMEI/user/pphick/idl/drivers/skydrivein.pro
[Previous] [Next]
 NAME:
	SkyDriveIn
 CALLING SEQUENCE:
	pro SkyDriveIn, distance,	$
	    rotation	= Rotation,	$	; Defines 3D data set
	    resolution	= Resolution,	$
	    cube	= Cube, 	$
	    drawecliptic= DrawEcliptic, $
	    meshecliptic= MeshEcliptic, $
	    tiff8	= Tiff8,	$
	    tiff24	= Tiff24,	$
	    bmp8	= Bmp8, 	$
	    bmp24	= Bmp24,	$
	    interleave	= Interleave,	$
	    fov 	= fov,		$
	    firststate	= FirstState,	$

	    fire	= Fire, 	$
	    helios	= Helios,	$
	    smex	= Smex, 	$	; Single s/c east of Earth
	    twinsc	= Twinsc,	$	; Two s/c on either side of Earth

	    cartesian	= Cartesian,	$
	    eqdistance	= eqdistance,	$
	    eqangle	= eqangle,	$
	    eqarea	= eqarea,	$
	    cme 	= cme,		$
	    noplot	= noplot,	$
	    stereo	= stereo,	$
	    xsize	= xsize,	$
	    ysize	= ysize
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, NewcombSun, SKYIMAGE, TimeGet, TimeSet, flt_read


SkyForecast $SMEI/user/pphick/idl/drivers/skyforecast.pro
[Previous] [Next]
 NAME:
	SkyForecast
 CALLING SEQUENCE:
	pro SkyForecast, file,		$
	    rotation	= Rotation,	$	; Defines 3D data set
	    ngrid	= ngrid,	$
	    cube	= Cube, 	$
	    drawecliptic= DrawEcliptic, $
	    meshecliptic= MeshEcliptic, $
	    tiff8	= Tiff8,	$
	    tiff24	= Tiff24,	$
	    bmp8	= Bmp8, 	$
	    bmp24	= Bmp24,	$
	    interleave	= Interleave,	$
	    fov 	= fov,		$
	    firststate	= FirstState,	$

	    fire	= Fire, 	$
	    helios	= Helios,	$
	    smex	= Smex, 	$	; Single s/c east of Earth
	    twinsc	= Twinsc,	$	; Two s/c on either side of Earth

	    eqdistance	= eqdistance,	$
	    eqangle	= eqangle,	$
	    eqarea	= eqarea,	$
	    cme 	= cme,		$
	    noplot	= noplot,	$
	    stereo	= stereo,	$
	    xysize	= xysize
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CARRINGTONT, FILEPATH, MEAN, Sky_ColorView [1], Sky_ColorView [2], TimeGet, TimeOp
	TimeSet, vu_read


smei_base_testcase $SMEI/ucsd/camera/idl/toolbox/smei_base_testcase.pro
[Previous] [Next]
 NAME:
	smei_base_testcase
 PURPOSE:
	Runs test case for smei_base program and validates results
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_base_testcase, make=make, db=db, keep=keep,	$
	    source=source, digsource=digsource
 OPTIONAL INPUT PARAMETERS:
	/make	    if set, the testcase results are regenerated
	source=source	passed to smei_base
	/digsource  passed to smei_base
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, FindAllFiles, GetFileSpec, InitVar, IsType, TimeGet, TimeOp, TimeSet
	TimeUnit, flt_string, smei_getfile, smei_property, txt_read, who_am_i
 PROCEDURE:
	The testcase results are stored in an ASCII file in the
	same directory as this procedure (smei_base_testcase.txt).
	The file contains frame names and values for pedestal and
	dark current.

	The executable smei_base is run for all frames in the testcase.
	Resulting Fits frames are written to $TUB/smei_base_testcase.
	These files are cleaned up afterward.

	Differences between pedestal and dark current should be at
	the single precision level.
 MODIFICATION HISTORY:
	DEC-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_blocked $SMEI/ucsd/camera/idl/toolbox/smei_blocked.pro
[Previous] [Next]
 NAME:
	smei_blocked
 PURPOSE:
	Used to temporary block the real-time SMEI pipeline
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION smei_blocked, ignore_block=ignore_block
 OPTIONAL INPUT PARAMETERS:
	/ignore_block	    return values always 0
		    (pipeline NOT blocked)
 OUTPUTS:
	Result		0: pipeline not blocked
		    1: pipeline blocked
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, hide_env, smei_filepath, txt_read
 CALLED BY:
	smei_mkbase, smei_mkcal_auto, smei_mkorb_auto, smei_mksky
 PROCEDURE:
	File $SMEIDB/cat/sts/block/block_file.txt should contain 0 or 1
	(the file needs to be edited manually).
	1 means that the pipeline is blocked.
	The caller presumably will abort (unless /ignore_block is set)
 MODIFICATION HISTORY:
	DEC-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_buf $SMEI/ucsd/camera/idl/buf/smei_buf.pro
[Previous] [Next]
 NAME:
	smei_buf
 PURPOSE:
	Main procedure for processing l1a files
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	PRO smei_buf, tmp_list
 INPUTS:
	tmp_list	scalar; type: string; default: $TUB/l1a_list.txt
			    name of ascii file created by Python script l1a.py
			    (the file will be deleted after it has been read)
 OUTPUTS:
	.nic files to $dat/smei/nic
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, GetFileSpec, InitVar, SetFileSpec, TimeGet, TimeOp, TimeSystem
	TimeUnit, destroyvar, do_file, hide_env, smei_buf_get, smei_buf_getframe
	smei_buf_mget, txt_read
 PROCEDURE:
 >	This procedure is accessed primarily through the Python script
	l1a.py, which creates the main IDL main program and the input
	file 'tmp_list'.
 >	All frames are extracted from the specified list of *.buf files
	and written to disk as *.nic files.
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS)
	FEB-2004, Paul Hick (UCSD/CASS)
	    Added option for 'noclones' check.
	    Added option to move processed L1A files to other directory
	MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added option to allow writing of Fits files and Nic files.


smei_buf_get $SMEI/ucsd/camera/idl/buf/smei_buf_get.pro
[Previous] [Next]
 NAME:
	smei_buf_get
 PURPOSE:
	Extracts data area for specified frames
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	PRO smei_buf_get, frame_headers, $
	    source	= source	, $
	    destination = destination	, $
	    nic 	= nic		, $
	    fits	= fits		, $
	    ptr_data	= ptr_data	, $
	    gzip	= gzip		, $
	    trange	= trange	, $
	    count	= count 	, $
	    silent	= silent	, $
	    email	= email 	, $
	    _extra	= _extra
 INPUTS:
	frame_headers	array; type: smei_frm_hdr structure
			    frame header array (as returned by smei_buf_getframe)
 OPTIONAL INPUT PARAMETERS:
	trange=trange	array[n]; type: time structure
			    time info for tracking down SMEI frames.
			    See smei_buf_getframe for more information.
	source=source	scalar; type: string; default: /media/cdrecorder
			    directory where the L1A files are located.
			    If trange is used this is passed to smei_buf_getframe.
			    If frame_headers is specified than this is added to
			    frame_headers.l1a_file (which does not include a
			    directory).
	destination=destination
			scalar; type: string
			    directory into which to write the individual frame files
			    Output files have form c#frm_YYYY_DDD_HHMMSS (for padded
			    frames) or c#roi_YYYY_DDD_HHMMSS (for unpadded ROI
			    frames). # is the camera number (1,2 or 3).
	/nic		if set (and a valid destination is specified) then frame are
			    written in NIC file format (i.e. the data are stored in
			    the same way as for the TMO data, but the trailer has
			    a totally different structure)
	/fits		if set (and a valid destination is specified) then a fits
			    file is written
			    (at this point the frame headers are not written into
			    the fits file.
	/split_dir	if writing out lots and lots of frames it is probably better
			    to distribute the frames over multiple directories.
			    If /split_dir is set then each day of data is split in
			    4-hour intervals over 6 directories with names
			    destination/YYYY_DDD/HH with HH=00,04,08,12,16,20

	email=email	list of email addresses to be notified of errors
			    (used in smei_buf_read and smei_frm_cvhdr).

	If the output keyword ptr_data is set, and /nic, /fits are not set
	then the frame data ar returned as a heap variable.

	/overwrite	    will unconditionally overwrite existing files when
			    writing individual frames to disk
	/gzip		    gzip directories
 OPTIONAL OUTPUT PARAMETERS:
	count=count	    # frames found

	ptr_data=ptr_data
			array; type: pointer
			    the frame data corresponding to 'hdr'
			    i.e. *ptr_data[i] is the 2D frame data array.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, InitVar, IsTime, IsType, TimeGet, TimeSet, TimeUnit, hide_env
	smei_buf_getframe, smei_buf_gzip, smei_buf_prep, smei_buf_read, smei_frm_write
	smei_property, smei_setup_roi, txt_read
 CALLED BY:
	smei_buf
 EXAMPLE:
	The most efficient way to replace a damaged frame in the SMEI database from a DVD
	is the following command:
	    smei_buf_get, timeset('2005_006_160819'), cam=2, /fits, dest=getenv('TUB'), /usedb
	This requires that the proper DVD is mounted on /media/cdrecorder (specify
	source=<source> to override the default) and that the SMEI database is accessible.
	Note: dest='SMEIDB?' will NOT work.
 PROCEDURE:
	If either /fits or /nic is set then data are saved to binary files in
	the destination directory (no pointer data will be returned).

	File names will have the form c#frm_YYYY_DDD_HHMMSS.ext:
	#   = camera id (1,2 or 3)
	ext = 'fts' or 'nic'

	If neither /nic nor /fits is specified then data can be extracted in
	ptr_data.

	/fits SET:

	Writes bare fits file (no extra frame header info is put in the file yet,
	just the data are stored).

	/nic SET (obsolete; we don't use .nic files anymore):

	A 512 byte trailer is added after the data array.
	The first 3 bytes are the characters 'buf' (to distinguish these
	files from e.g. the TMO data files). The next 256 is the unmodified
	header from the original frame (except for byte swapping to put the
	data in native machine format.

 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS)
	MAY-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Changed default source from /media/cdrecorder to /media/CDROM


smei_buf_getframe $SMEI/ucsd/camera/idl/buf/smei_buf_getframe.pro
[Previous] [Next]
 NAME:
	smei_buf_getframe
 PURPOSE:
	Extracts individual frames from all *.buf files in the specified
	source directory.
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	FUNCTION smei_buf_getframe, trange, $
	    source  = source	, $
	    camera  = camera	, $
	    count   = count	, $
	    dups_too= dups_too	, $
	    usedb   = usedb	, $
	    silent  = silent
 INPUTS:
	trange		array[n]; type: time structure
			    n=0: if not specified than all frames in all L1A files in
				    'source' are extracted.
			    n=1: extract frame for specified time
			    n=2: extract all frames between trange[0] and trange[1]
			    n>2: extract frames for specified times
 OPTIONAL INPUT PARAMETERS:
	source=source	scalar, array; type: string
			    scalar: source directory containing L1A *.buf files
			    array : list of fully-qualified names of L1A files
	camera=camera	scalar, array[2], array[3]
			    numbers 1, 2, or 3, identifying the cameras to be extracted
			    if 'camera' not set then all cameras are extracted.
	/usedb		if set then an attempt is made to find a file pointer in the
			    first L1A file to be accessed close to trange[0] (by
			    looking for nearby frames in the SMEI data base).
			    (this is primarily used to replace corrupted frames in the
			    SMEI data base).
 OUTPUTS:
	hdr	    array; type: smei_frm_hdr structure
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			    # frames returned in 'hdr'
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FindAllFiles, GetFileSpec, InitVar, IsTime, IsType, TimeGet, TimeLimits
	TimeOp, TimeSet, TimeUnit, UNIQ, boost, destroyvar, hide_env, smei_buf_read
	smei_getfile, smei_property, where_common
 EXTERNAL:
	smei_buf_hdr__define, smei_frm_hdr__define
 CALLED BY:
	smei_buf, smei_buf_get
 PROCEDURE:
	Frame headers are stored in the same order as they are read from the
	L1A files, i.e. there will be contiguous groups of frames from each
	L1A files. Each L1A file appears to be chronological, but subsequent
	files overlap (because of the double dump?). As a result the frame
	header array as a whole (from more than one L1A file) is probably not
	chronological.
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_buf_gzip $SMEI/ucsd/camera/idl/buf/smei_buf_gzip.pro
[Previous] [Next]
 NAME:
	smei_buf_gzip
 PURPOSE:
	Controls gzipping of new frames in SMEI data base.
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	PRO smei_buf_gzip, last_dir, need_gzip
 INPUTS:
	need_gzip	scalar; type: integer
			    # frames to be gzipped
	last_dir	scalar; type: string
			    name of directory to be gzipped
 OUTPUTS:
	need_gzip	scalar; type: integer
			    reset to zero
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType, hide_env
 CALLED BY:
	smei_buf_get, smei_buf_mget, smei_buf_prep
 PROCEDURE:
 MODIFICATION HISTORY:
	OCT-2004, Paul Hick (UCSD/CASS)


smei_buf_hdr__define $SMEI/ucsd/camera/idl/buf/smei_buf_hdr__define.pro
[Previous] [Next]
 NAME:
	smei_buf_hdr__define
 PURPOSE:
	Structure definition for file header of SMEI .buf files
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	hdr = {smei_buf_hdr}
 INPUTS:
	(none)
 OUTPUTS:
	(none)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL BY:
	smei_buf_getframe, smei_buf_splitfile
 PROCEDURE:
	See Don Mizuno's, SMEI_CONVERT memo
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_buf_mget $SMEI/ucsd/camera/idl/buf/smei_buf_mget.pro
[Previous] [Next]
 NAME:
	smei_buf_mget
 PURPOSE:
	Extracts all frames from specified l1a_files
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	PRO smei_buf_mget, l1a_files, $
	    destination = destination	, $
	    nic 	= nic		, $
	    fits	= fits		, $
	    nowrite	= nowrite	, $
	    gzip	= gzip		, $
	    silent	= silent	, $
	    email	= email 	, $
	    _extra	= _extra
 INPUTS:
	l1a_files	array; type: string
			    fully-qualified names of l1a_files
 OPTIONAL INPUT PARAMETERS:
	destination=destination
			scalar; type: string
			    directory into which to write the individual frame files
			    Output files have form c#frm_YYYY_DDD_HHMMSS (for padded
			    frames) or c#roi_YYYY_DDD_HHMMSS (for unpadded ROI
			    frames). # is the camera number (1,2 or 3).
	/nic		if set (and a valid destination is specified) then frames are
			    written in NIC file format (i.e. the data are stored in
			    the same way as for the TMO data, but the trailer has
			    a totally different structure)
	/fits		if set (and a valid destination is specified) then a fits
			    file is written
			    (at this point the frame headers are not written into
			    the fits file).
	/split_dir	if writing out lots and lots of frames it is probably better
			    to distribute the frames over multiple directories.
			    If /split_dir is set then each day of data is split in
			    4-hour intervals over 6 directories with names
			    destination/YYYY_DDD/HH with HH=00,04,08,12,16,20
	/nowrite	if set then no frames are written (all frames are listed as 'rejected')
			    This allows for testing of reading L1A files.

	/overwrite	if set existing frames are overwritten
			    (passed to smei_buf_prep)

	email=email	list of email addresses to be notified of errors
			    (used in smei_buf_read and smei_frm_cvhdr).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	smei_buf
 SEE ALSO:
	smei_buf_get, smei_buf_getframe
 CALLS: ***
	CheckDir, InitVar, IsType, hide_env, smei_buf_gzip, smei_buf_prep, smei_buf_read
	smei_frm_write, smei_property, smei_setup_roi
 PROCEDURE:
	This is a faster alternative to smei_buf_get. It processes all
	l1a_files in sequence and extracts/writes to disk all frame data.

	If either /nic of /fits is set then data are saved to binary files in
	the destination directory (no pointer data will be returned).

	File names will have the form c#frm_YYYY_DDD_HHMMSS.ext:
	#   = camera id (1,2 or 3)
	ext = 'nic' or 'fts'

	/nic SET:

	A 512 byte trailer is added after the data array.
	The first 3 bytes are the characters 'buf' (to distinguish these
	files from e.g. the TMO data files). The next 256 is the unmodified
	header from the original frame (except for byte swapping to put the
	data in native machine format.

	/fits SET:

	STILL NEEDS WORK
	Writes bare fits file (no extra frame header info is put in the file yet,
	just the data are stored).
 MODIFICATION HISTORY:
	APR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_buf_prep $SMEI/ucsd/camera/idl/buf/smei_buf_prep.pro
[Previous] [Next]
 NAME:
	smei_buf_prep
 PURPOSE:
	Decide whether a frame extracted from an L1A file needs to be
	written to disk.
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	FUNCTION smei_buf_prep, hdri, destination, $
	    nic 	= nic	    , $
	    fits	= fits	    , $
	    last_dir	= last_dir  , $
	    filelist	= filelist  , $
	    split_dir	= split_dir , $
	    overwrite	= overwrite , $
	    count	= count     , $
	    last_time	= last_time , $
	    noclones	= noclones  , $
	    comment	= comment   , $
	    gzip	= gzip	    , $
	    need_gzip	= need_gzip , $
	    status	= status
 INPUTS:
	hdri		array[1]; type: frame header structure
			    frame header
	destination	scalar; type: string
			    name of existing directory where to write the file

			    If split_dir is NOT set then frames will be written
			    directly to 'destination'
			    If split_dir is SET then files are written into subdirectories
			    destination/year_doy/c1, destination/year_doy/c2 or
			    destination/year_doy/c3
	count		array[4]; type: integer
			    Counters to be updated.
 OPTIONAL INPUT PARAMETERS:
	/nic		write nic file
	/fits		write fits file

	/split_dir	if writing out lots and lots of frames it is probably better
			    to distribute the frames over multiple directories.
			    If /split_dir is set then each day of data is split in
			    4-hour intervals over 6 directories with names
			    destination/YYYY_DDD/HH with HH=00,04,08,12,16,20
	/overwrite	by default frames are not written to drive if a file for
			    the frame already exists, UNLESS the new frame was from
			    the 1st telemetry dump. Set this keyword to
			    unconditionally overwrite existing files.
			    (setting -overwrite speeds up processing by a factor 2).

	count=count	array[4]; type: integer
			    The count array MUST EXIST on input for updates to
			    occur. One or more of the counters are incremented by 1.
			    count[0]: # frames written to disk as .nic or .fts
				file (updated in smei_frm_write)
			    count[1]: # frames skipped because file already exists
				(updated here)
			    count[2]: # frames with times earlier than the most
				recent frame (updated here) that are written to
				disk (these should be frames from the second dump;
				if the second dump contains the same frames as the
				first the number of these frames should be small)
			    count[3]: # clone frames (updated here)
	last_time=last_time
			array[1]; type: time structure
			    time of most recent frame processed
	status=status	if set, then status files for each day are created in
			    $SSWDB_SMEI/cat/sts. This keyword is used only
			    in the SMEI pipeline.
 OUTPUTS:
	filename	scalar; type: string
			    fully-qualified file name to be used for output file.
			    If /overwrite is NOT set and the file exists already
			    then the null-string is returned.
	count		array[3]; type: integer
			    updated file counters
	last_time	array[1]; type: time structure
			    updated frame time
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	smei_buf_get, smei_buf_mget
 COMMON BLOCKS:
	common save_three_clones, last_hdrs, last
	common save_double_dump , overlap_on, overlap_l1a, first_dump
 CALLS: ***
	CheckDir, FILEPATH, GetFileSpec, InitVar, IsType, TimeGet, TimeLimits, TimeOp, TimeSet
	TimeUnit, UNIQ, boost, destroyvar, hide_env, smei_buf_gzip, smei_filename
	smei_filepath, smei_frm_read, smei_property, txt_read
 RESTRICTIONS:
	If /split_dir is set then a 'mkdir --parents' is spawned to to create
	subdirectories, and gzip is spawned to compress files. This works in
	Linux, but not in Windows without some modifications.
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS)
	MAY-2003, Paul Hick (UCSD/CASS)
	    If /overwrite is NOT and a frame exists already the telemetry times are
	    compared. If the new frame is earlier than the one already on disk,
	    then it is still overwritten.
	    This determination is made from the name of the original telemetry file
	    which is stored in the frame header.
	JUL-2003, Paul Hick (UCSD/CASS)
	    Force overwrite if there is read error on an existing .nic file.
	FEB-2004, Paul Hick (UCSD/CASS)
	    Added /noclones keyword
	    Added new code to deal with double dump frames. Should reduce disk I/O
	    considerably.
	AUG-2004, Paul Hick (UCSD/CASS)
	    Introduced error handler bracketing calls to smei_property(hdr,/tlm_time).
	    Occasionally the tlm_file name is screwy enough to crash
	    smei_property. If this happens continue assuming that the new frame
	    is from a second dump.
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword "status". This triggers writing of "status" files
	    to $SSWDB_SMEI/cat/sts each time the last frame for a given
	    day has been written. Used in pipeline.


smei_buf_read $SMEI/ucsd/camera/idl/buf/smei_buf_read.pro
[Previous] [Next]
 NAME:
	smei_buf_read
 PURPOSE:
	Read Level 1A file in 'buf' format
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	FUNCTION smei_buf_read, l1a_file, pointer,  $
	    get_file_header = get_file_header,	$
	    file_header     = file_header    ,	$
	    frame_headers   = frame_headers  ,	$
	    frame_nr	    = frame_nr	     ,	$
	    frame_data	    = frame_data     ,	$
	    get_next_frame  = get_next_frame ,	$
	    silent	    = silent	     ,	$
	    force_close     = force_close    ,	$
	    trunc_time	    = trunc_time     ,	$
	    start_pointer   = start_pointer  ,	$
	    email	    = email
 INPUTS:
	l1a_file	    scalar; type: string
				fully-qualified file name of SMEI l1a*.buf file.
				To close an open file, set l1a_file = ''
	pointer 	    scalar; type: integer
				file pointer in l1a_file where the requested frame starts.
				This argument is optional, but if known, speeds up
				the process of finding a frame in the L1A file.
 OPTIONAL INPUT PARAMETERS:
	/get_file_header    only fill file_header structure
	/get_next_frame     get next frame from file
			    If this keyword is set then the data file is kept open
			    with the file pointer after the current frame.
	frame_nr=frame_nr
			    get frame with number 'frame_nr'
			    The frame number specified here should be taken
			    from the header array returned in a previous call
			    (this is a 1-based frame number).
	trunc_time	    array[1]; type: time structure
			    used only when collecting all frame headers (i.e.
			    keywords frame_nr_defined and get_next_frame NOT set,
			    and argument have_pointer NOT set). The collection of
			    frames stops at the indicated time instead of
			    continuing until the end-of-file is reached.
	start_pointer	    scalar; type: integer
				when new l1a_file is opened move to file pointer
				to start_pointer and start processing from there
				instead of from the beginning of the file.
				'start_pointer' is destroyed to avoid using
				in another l1a_file.

	email=email	    list of email addresses to be notified of errors
			    (used in smei_buf_read and smei_frm_cvhdr).
 OUTPUTS:
	status		    scalar; type: integer
				0: failure; 1: success
 OPTIONAL OUTPUT PARAMETERS:
	file_header=file_header
			    array[1]; type: file header structure
	frame_headers=frame_headers
			    array[n]; type: frame header structure array
				an array with with headers for all frames is returned
			    array[1]; type: frame header structure
				if 'frame_nr' is specified than the
				header for the matching frame is returned
	frame_data=frame_data
			    array[n], array[n,m]; type: unsigned int, long or float
				if 'frame_nr' is set then the matching frame
				data are returned here.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro	; ROI mask common block
 CALLED BY:
	smei_buf_get, smei_buf_getframe, smei_buf_mget
 COMMON BLOCKS:
	common smei_read_buf_file, iu, open_file, open_hdr, pntr, last_frm, frm_count
 CALLS: ***
	InitVar, IsTime, IsType, TimeGet, TimeLimits, TimeOp, TimeUnit, boost, destroyvar
	hide_env, smei_buf_splitfile, smei_filename, smei_frm_cvhdr, smei_property
	smei_setup_roi, who_am_i
 PROCEDURE:
	The content of SMEI .buf files is described in Don Mizuno's memo:

	The data area is padded to a 2D frame using the mask stored in
	the ASCII file smei_buf_roi.txt. This file contains a 318 x 64 array with values 0,1,2 and 3.
	0: pixels outside the region of interest
	1: pixels in the smei fov
	2: pixels in the covered columns left and right
	3; pixels in the square open areas outside the smei fov
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS)
	APR-2003, Paul Hick (UCSD/CASS)
	    Fixed bug in frame header structure. The naxes values in the raw
	    header were not updated when the ROI was applied (so the nic files
	    prior to today (Apr 20) have naxes=[0,0] in the trailer).
	MAR-2003, Paul Hick (UCSD/CASS)
	    Entry frame_header.n_satured is filled here using the
	    data extracted from the L1A file.
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added checks for corrupted frames (as identified by
	    smei_frm_cvhdr).


smei_buf_splitfile $SMEI/ucsd/camera/idl/buf/smei_buf_splitfile.pro
[Previous] [Next]
 NAME:
	smei_buf_splitfile
 PURPOSE:
	Analyze content of 256-ascii file header in SMEI L1A *.buf file
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	FUNCTION smei_buf_splitfile, byte_hdr
 INPUTS:
	ascii_hdr	array[256]; type: byte
			    256-byte header
 OUTPUTS:
	Result		array[1]; type: smei_buf_hdr structure
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_buf_hdr__define
 CALLS: ***
	GetFileSpec, TimeOp, TimeSet, timeposn
 CALLED BY:
	smei_buf_read
 PROCEDURE:
	The file header is actually stored in ascii form, so the input byte
	array is converted to string before processing
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Based on SMEI Convert 1.0


smei_cam2angle $SMEI/ucsd/camera/idl/toolbox/smei_cam2angle.pro
[Previous] [Next]
 NAME:
	smei_cam2angle
 PURPOSE:
	Get angles from unit vector in SMEI camera frame
 CATEGORY:
	camera/idl
 CALLING SEQUENCE:
	angle = smei_cam2angle(runit [,stheta=stheta, rtheta=rtheta])
 INPUTS:
	runit	    array[3,n]; type: float or double
			x,y,z components of unit vector in UCSD camera frame
 OPTIONAL INPUT PARAMETERS:
	/stheta     if set, then the direction cosine angles are returned
			this is the default if no keywords are specified.
	/rtheta     if set, then the rotation angles from
			Buffington et al., SPIE 4853, 490, 2002.
		    are returned
 OUTPUTS:
	angle	    array[2,n]; type: double
			requested theta-x and theta-y angles
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, ToRadians
 CALLED BY:
	smei_findcrazy, smei_frm_hbar, smei_frm_where
 SEE ALSO:
 PROCEDURE:
	/stheta set
	    locations in the sky as direction cosine angles theta-x and
	    These are the direction cosine angles required by Andy's formulae for
	    mapping sky locations to CCD positions ('Defining the field of
	    view for the SMEI cameras', A. Buffington, 11 July 2001.)
	    !!! These are not the same as the theta-x, theta-y angles
	    in Buffington et al., SPIE 4853, 490, 2002.
	/rtheta
	    !!! These are the theta-x, theta-y angles
	    in Buffington et al., SPIE 4853, 490, 2002.
	    i.e. angles used in determining the performance of the baffle,
	    incl. the glare.
 MODIFICATION HISTORY:
	MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_cam_quaternion $SMEI/ucsd/camera/idl/toolbox/smei_cam_quaternion.pro
[Previous] [Next]
 NAME:
	smei_cam_quaternion
 PURPOSE:
	Get quaternion that rotates from ECI (=J2000) frame to UCSD
	camera frame for given Coriolis s/c quaternion and camera.
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	qcam = smei_cam_quaternion(hdr)
	qcam = smei_cam_quaternion(quaternion, camera)
	qcam = smei_cam_quaternion(uttime, camera)
 INPUTS:
	hdr	array[n]; type: SMEI_FRM_HDR structure
		    hdr.quaternion and hdr.camera are used
		    to calculate the camera quaternion.
		array[n]; type: time structure
		    UT time is used to get the quaternion
		    assuming the Coriolis is in its
		    nominal attitude.
		array[4] or array[4,n]; type: double
		    Coriolis quaternion (as extracted from
		    frame header). If 'hdr' is a quaternion
		    then 'camera' needs to specified too.
 OPTIONAL INPUTS:
	camera	    scalar or array[n]; type: integer
		    camera number (as extracted from frame header)
 OUTPUTS:
	qcam	    array[4] or array[4,n]; type: double
		    camera quaternion (relative to same coord
		    system as Coriolis quaternion)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CombineRotations, IsTime, IsType, smei_camera, smei_property, smei_sgp4_quat
 CALLED BY:
	cvsmei, smei_ccd2sky, smei_frm_where, smei_sky2cam
 SEE ALSO:
	smei_orient_test
 PROCEDURE:
	Camera quaternion rotates from J2000 equatorial coordinates to
	UCSD camera coordinates.
 MODIFICATION HISTORY:
	JUN-2003, Paul Hick (UCSD/CASS
	FEB-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added option to input time and retrieve the
	    the nominal quaternion.


smei_camera $SMEI/ucsd/camera/idl/toolbox/smei_camera.pro
[Previous] [Next]
 NAME:
	smei_camera
 PURPOSE:
	Defines parameters for the SMEI fov
 CATEGORY:
	SMEI
 CALLING SEQUENCE:
	R = smei_camera(/get_center)
 INPUTS:
	nsize = nsize	    array[2]; type: long integer; default:[1280,360]
				CCD frame size (pixels)
	center= center	    array[2]; type: float; default: [631.65, 1233.03]
				x- and y-coordinate of center of field of view arc
	optical_axis	    array[2]; type: float; default: [-89.5 (deg), 1179.50 (pix)]
				azimuth and radius of optical axis
				identifies the location of the optical axis relative
				to the fov center in terms of polar coordinates. By
				default. The optical axis is near azimuth 270
				(vertically below the center) at ~ 1200 pixels
				distance.
	fov_size	    array[2,2]; type: float: default:[30 (deg), 42.5 (pix)]#[-1,1]
				the size of the SMEI fov in polar coordinates
				The fov is ~ 60 degrees in azimuth by 85 pixels
				in the radial direction, and is centered on the
				optical axis.
	quaternion	    array[4]; type: double: default
				quaternion describing orientation of cameras
				relative to the spacecraft structure.
	fov_tosky	    array[2,2] type: float
				scaling from CCD coordinates to sky coordinates
	fov_toccd

 OPTIONAL INPUT PARAMETERS:
	/get_nsize	    retrieve frame size
	/get_center	    retrieve center of field of view arc
	/get_optical_axis   retrieve optical axis coordinates
	/get_fov_size	    retrieve field of view size
	/get_fov_limits     retrieve limits of field of view
	/get_quaternion     retrieve camera quaternions
	/get_fov_tosky	    retrieve CCD-to-sky transformation constants
	/get_fov_toccd

	/get_structure	    retrieve structure containing all field of view information

	/degrees	    if set then all angles (input and output) is in degrees
			     (default: radians)
 OUTPUTS:
	Output depends on the keyword selection.
	If /get_fov_limits is set the limits of the field of view are returned:

	R	array[2,2]; type: float
		limiting values in azimuth and radius of the fov
		in the form [[angle1,radius1],[angle2,radius2]].
		Angle1 and angle2 are in radians between [-!pi,+!pi].
		The fov runs counterclockwise from 'angle1' to 'angle2'.

	If /get_structure is set then a structure is returned containing all
	field of view information:

	R	array[1]; type: structure
		{SMEI_fov,  $
		    camera  : camera,
		    nsize	: nsize,
		    center	: center,
		    axis	: optical_axis,
		    size	: fov_size,
		    limits	: fov_limits,
		    quaternion	: quaternion,
		    tosky	: fov_tosky,
		    radial_profile: ptr to radial_profile}
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CombineRotations, InitVar, IsType, ToDegrees, ToRadians
 CALLED BY:
	SMEI_cr_removal, TMO_tracksky, cvsmei, qGlitch_Run, qImage_cw_SMEI
	smei_cam_quaternion, smei_ccd2sky, smei_sky2cam, smei_sky2ccd, stardistance
	test_tmo
 SEE ALSO:
	smei_orient_test
 PROCEDURE:
	Default values are used unless other values are specified as input arguments
	The fov limits are calculated from the location of the optical axis and
	the size of the field of view.
 MODIFICATION HISTORY:
	FEB-2000, Paul Hick (UCSD/CASS)
	MAR-2003, Paul Hick (UCSD/CASS)
	    Added numbers for flight cameras.
	JAN-2004, Paul Hick (UCSD/CASS)
	    Added camera values from Aarons indexing program. These used the center
	    values from Andys memo, and camera quaternions obtained by trial-and-error.
	    These numbers are now the default.
	FEB-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Update camera quaternions with values used by the Fortran
	    SMEI programs. Presumably these are the best we have.


smei_camera_gain $SMEI/ucsd/camera/idl/star/smei_camera_gain.pro
[Previous] [Next]
 NAME:
	smei_camera_gain
 PURPOSE:
	Returns the camera gain at specified time
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	FUNCTION smei_camera_gain, tt, $
	    camera	= camera    , $
	    zero_time	= zero_time , $
	    zero_gain	= zero_gain , $
	    delta_gain	= delta_gain
 INPUTS:
	tt		array[n]; type: time structure
			    UT time
 OPTIONAL INPUTS:
	camera=camera	scalar or array[n]; type: integer; default: 2
			    camera number, 0,1,2,3
			    camera=0 will always return gain=1.00
	zero_time=zero_time
			array[1]; type: time structure;
			    default: TimeSet(yr=2003,doy=0)
			    Time origin for gain correction
	zero_gain=zero_gain
			array[4]; type: float; default: 1.0/[0.00,0.97,1.00,0.92]
			    gains for "camera 0" and three cameras at time zero_time
	delta_gain=delta_gain
			array[4]; type: float; default: [0.00,-0.005,-0.01,-0.01]
			    gain change per year for "camera 0" and three cameras
 OUTPUTS:
	gain		array[n]; type: float
			    gain correction at specified times
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, TimeOp, TimeSet, TimeUnit
 CALLED BY:
	smei_sky_read, smei_star_fit, smei_star_remove, smei_zld_remove [1]
	smei_zld_remove [2]
 PROCEDURE:
	The sensitivity of the cameras appears to be decreasing at a
	rate of about 1% per year. (But see next paragraph)

	JUL-2008:
	From looking at a timeseries of a patch of 31x31 skybins centered on the
	galactic center for the period 2003-2008 we found that the gain for
	camera 1 is decreasing by about 0.5%/year. For camera 2 the original
	number of 1%/year is still acceptable, but may actually be closer to
	1.1%/year. For camera 3 the current 1%/year may be a bit large, but
	it is not clear by how much.

	NOV-2008:
	It was decided to set the gain decrease for camera 1 back to 0.1%/year.

	Andy set the time origin for the gain to 2003, doy 0 (NOT doy 1).
	So the time origin is at 2002 Dec 31, 0 UT.
 MODIFICATION HISTORY:
	JUL-2006, Jordan Vaughan, Paul Hick (UCSD/CASS)
	NOV-2007, Paul Hick (UCSD/CASS)
	    zero_gain was defined wrong. The gain for camera 1 at zero_time
	    is 1.0/0.97 (NOT 0.97); for camera 3 it is 1.0/0.92 (NOT 0.92).
	    I.e., cameras 1 and 3 are MORE sensitive than camera 2;
	    NOT less sensitive as originally coded.
	DEC-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Gain for camera 1 was set to 0.5% per year for a while.
	    On Dec 1 the gain was set back to old value of 1% per year.
	    Default tt is now the time origin zero_time (used to crash
	    with undefined tt).


smei_ccd2sky $SMEI/ucsd/camera/idl/obsolete/smei_ccd2sky.pro
[Previous] [Next]
 NAME:
	smei_ccd2sky
 PURPOSE:
	Convert from CCD coordinates to positions in the sky
 CATEGORY:
	SMEI
 CALLING SEQUENCE:
	R = smei_ccd2sky( rvec, [ camera=camera, quaternion=quaternion, /degrees])
 INPUTS:
	rvec		array[2,*]; type: float
			    x- and y- coordinates of locations on the CCD
			    These are converted to sky coordinates if inside the
			    field of view. If no points lie inside the field of
			    view then the scalar BadValue(rvec) is returned.
			    If rvec is not specified then all pixels in a
			    frame are processed.
 OPTIONAL INPUT PARAMETERS:
	/rectangular	if set then the return value is in rectangular coordinates
			(with 1st dimension of 3).

	camera=camera	This keyword can be any one of the following three.
			array[1]; type: smei_buf_frm structure
			    this determines the camera and the quaternion.
			    The keywords 'quaternion' and 'qcamera' are ignored.
			array[1]; type: smei_camera_fov structure
			    structure containing information about SMEI field of
			    view; usually the return value of smei_camera
			    with the /get_structure keyword set.
			scalar; type: integer
			    camera number (1,2 or 3).
			If not specified then camera=1 is assumed.

			The camera number is used as argument to smei_camera to
			obtain the fov structure.

	quaternion=quaternion
			array[4]; type: float
			    Coriolis quaternion, or (if /qcamera is set) the
			    camera quaternion (i.e. the quaternion
			    constructed by smei_cam_quaternion).
	/qcamera	indicates that 'quaternion' already is the camera
			quaternion for the camera specified in 'camera'.
	/degrees	if set, all in- and output angles are in degrees
			    (default: radians). Note that the 'fov' structure
			    must be consistent with the setting of /degrees.
	/boolean	if set then the output array 'inside' is returned as an
			2D array of indices. (set this keyword only if rvec
			is NOT specified, i.e. when processing a whole frame.
	distort=distort
			NOT IMPLEMENTED YET
 OUTPUTS:
	R	    array[2,n]; type: float
			spherical coordinates (longitude, latitude)
			for all pixels inside the SMEI fov
 OPTIONAL OUTPUT PARAMETERS:
	inside=inside
		    array[  n]; type: long integer (if /twod NOT set)
		    array[2,n]; type: long integer (if /twod set0
			one- or two-D CCD pixel indices for all the pixels
			listed in R
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, BadValue, CV_COORD, CvRotation, InitVar, Inside_Wedge, IsType, SubArray
	SyncDims, ToDegrees, ToRadians, boost, gridgen, smei_cam_quaternion, smei_camera
	smei_radial2theta
 PROCEDURE:
 MODIFICATION HISTORY:
	OCT-1998, Paul Hick (UCSD/CASS)
	FEB-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu); added quaternion keyword


smei_coriolis $SMEI/ucsd/gen/idl/ephem/smei_coriolis.pro
[Previous] [Next]
 NAME:
	smei_coriolis
 PURPOSE:
	Returns time at which Coriolis was in specified orbit
 CALLING SEQUENCE:
	FUNCTION smei_coriolis, tt_or_orbit , $
	    orbital_period  = orbital_period, $
	    number	    = number	    , $
	    fraction	    = fraction	    , $
	    doublex	    = doublex
 INPUTS:
	tt_or_orbit	    array; type: time structure or any numerical type
				if input are times then output is the
				orbit number; if input is numerical then
				output is the orbit time.
 OPTIONAL INPUTS:
	/orbital_period     return orbital period
				if set then the orbital period at the specified
				time or orbit number is returned
				(if tt_or_orbit is not specified then
				tt_or_orbit=0 is assumed)
	/number 	    these three keywords are used only if a time
	/fraction	    structure is specified as input (the keywords
	/doublex	    are passed to smei_orbit_get.
 OUTPUTS:
	smei_coriolis	    array; type: numerical or time structure
				orbit number or orbit time (depending on input
				tt_or_orbit
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, IsTime, IsType, TimeGet, TimeLInterpol, TimeOp, TimeSet
	smei_orbit_get, smei_orbit_set, timeposn, txt_read, who_am_i
 CALLED BY:
	FUNCTION smeilatest lastorbit, PlotEarthSkymap [2], TimeGet, TimeSet, allsky [1]
	allsky [2], allsky [3], allsky_f, orb_comp, smei_frm_findpoint, smei_getfile
	smei_orbit_stats, smei_shutterwrong, smei_star_fit, smei_www_skymaps
 PROCEDURE:
	Orbit n0(=0) starts at t0 = 2002/12/31 23:56:41.900.
	The orbital period at this time was p0=0.0705612268519d0 days (6096.490 s),
	and has been decreasing since with dp=0.084 msec per orbit.
	(0.42s reduction in SMEI period per 365 days).

	The effective orbital period for orbit n is p0-(n-n0)*dp.
	The start times for each orbit becomes:

	t(n0+0) = t0
	t(n0+1) = t(n0+0)+p0-1*dp
	t(n0+2) = t(n0+1)+p0-2*dp
	...
	t(n0+n) = t(n0+n-1)+p0-n*dp = t0+n*p0-0.5*n*(n+1)*dp
 MODIFICATION HISTORY:
	JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


SMEI_cr_removal $SMEI/user/pphick/idl/smei_cr_removal.pro
[Previous] [Next]
 NAME:
	SMEI_cr_removal
 CALLING SEQUENCE:
	pro SMEI_cr_removal, files, $
	    nbuffer	    = nbuffer	    , $
	    sigmathreshold  = SigmaThreshold, $
	    minthreshold    = MinThreshold  , $
	    remove	    = Remove	    , $
	    silent	    = silent
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, BadValue, CV_COORD, Find2DGlitch, GroupPixels, Inside_Wedge
	SuperArray, TMO_skymotion, bin_read, destroyvar, gridgen, smei_camera


smei_cv_catalogue $SMEI/ucsd/camera/idl/star/smei_cv_catalogue.pro
[Previous] [Next]
 NAME:
	smei_cv_catalogue
 PURPOSE:
	Modifies formatting in bright star catalogue
 CATEGORY:
	camera/idl
 CALLING SEQUENCE:
	PRO smei_cv_catalogue
 INPUTS:
	Text file brightstars.txt in same directory as this routine.
 OUTPUTS:
	updata catalogue (overwrites old one)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, txt_read, who_am_i
 PROCEDURE:
	Fixes format problem with small negative latitudes. The minus sign
	in front of zero degrees is moved to the minute (or even the seconds
	field) e.g. entry -0 20 20 is changed to 0 -20 20
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_filename $SMEI/ucsd/camera/idl/toolbox/smei_filename.pro
[Previous] [Next]
 NAME:
	smei_filename
 PURPOSE:
	Construct or deconstructs file name for SMEI data files from/into its
	components (time,camera,file extension, and map mode)
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	FUNCTION smei_filename, tt, $
	    camera  = camera, $
	    mode    = mode  , $
	    postfix = postfix,$
	    upto    = upto  , $
	    pos_tt  = pos_tt, $
	    type    = type  , $
	    dir     = dir   , $
	    ccd     = ccd
 INPUTS:
	tt		array[n]; type; time structure or string
			    time or file name

			If tt is a file name, two conditions must
			be met for a successfull deconstruction:
			- it must contain a valid time string
			    (see timeposn).
			- the time must be preceeded by an
			    underscore
			If these are not met then the 'camera'
			'mode' and 'postfix' fields are not set
			(i.e. camera=-1, mode=postfix='')
 OPTIONAL INPUT PARAMETERS:
	If input 'tt' is a time structure, the file name is
	constructed using the following additional input:

	camera=camera	scalar or array[n]; type: integer; default: 1
			    camera number (1,2, or 3)
	type=type	scalar or array[n]; type: string; default: '.fts.gz'
			    file type
	mode=mode	scalar or array[n]; type: string or integer; default: 0
			    file mode, e.g. 'frm', 'cal','sky','equ'
			    If an integer is specified it is assumed to be the
			    frame binning mode 0 (1x1), 1 (2x2) or 2 (4x4),
			    in which case the mode will be 'm'+mode
	upto=upto	scalar; type: integer; default: TimeUnit(/sec)
			    sets time unit where file name is truncated
			    (only used if input 'tt' is time structure)
 OUTPUTS:
	If input 'tt' is time structure:

	result		array[n]; type: string
			    name of SMEI file

	If input 'tt' is a file name

	result		array[n]; type: time structure
			    time coded into SMEI file (e.g. time of
			    frame or start time of orbit)
 OPTIONAL OUTPUT PARAMETERS:
	If input 'tt' is a filename several parameters coded into
	the file are extracted:

	camera=camera	array[n]; type: integer
			    camera number (1,2, or 3)
	ccd=ccd 	set to 1 if all entries are CCD frames
			    (i.e. 'm0','m1','m2' and 'cal' files
	mode=mode	array[n]; type: string or integer; default: 0
			    file mode, e.g. 'frm', 'cal','sky','equ',
			    'l1a', 'm0', 'm1', 'm2'.
			    If ccd=1, and all files are 'm0','m1' or
			    'm2' (i.e. no 'cal' files), then mode is
			    returned as integers (0,1 or 2).
			    Otherwise the mode is returned as a string,
			    i.e. for CCD frames it will be 'm0','m1','m2'.
	pos_tt=pos_tt	array[n]; type: integer
			    position where time string starts in file name
			    (-1 if no time string is found)
			    pos_tt applies to the file name only (i.e.
			    after the directory spec has been removed).
	type=type	array[n]; type: string
			    file type (may be a double type
			    e.g. .fts.gz)
	directory=directory
			array[n]; type: string
			    directory (null-string if not present)
	postfix=postifx array[n]; type: string
			    null-string, 'm0' or 's'
			    Set to 'm0' (if the directory name
			    ends in 'c#m0') or 's' (if the directory name
			    ends in 'c#s' (where # is the camera
			    number).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	GetFileSpec, InitVar, IsTime, IsType, SyncArgs, TimeGet, TimeSet, TimeUnit, UNIQ
	strreverse, timeposn
 CALLED BY:
	img_read, orb_comp, psfn, qImage_cw_Property, qsmei_sky_pick, skyd_cat
	smei_buf_prep, smei_buf_read, smei_filepath, smei_findpnt, smei_getfile
	smei_hdr_get, smei_hdr_plot, smei_mkbase, smei_mkcal, smei_mkcal_auto
	smei_mkorb_auto, smei_mksky, smei_property, smei_rewind, smei_sky_field
	smei_sky_getmask, smei_sky_read, smei_sky_track, smei_star_remove
	smei_zld_remove [1], smei_zld_remove [2]
 PROCEDURE:
	Uses the standard SMEI template for file names:
	    c1m0_2003_123_123456.fts.gz
 MODIFICATION HISTORY:
	MAY-2004, Paul Hick (UCSD/CASS)
	JUL-2004, Paul Hick (UCSD/CASS)
	    Modified to deal with new frame name syntax with mode coded
	    into the file name
	JUL-2004, Paul Hick (UCSD/CASS)
	    Updated documentation
	MAR-2008, Paul Hick (UCSD/CASS)
	    Substantial rewrite of deconstruction section.
	    Added pos_tt and ccd keywords.
	JUN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    The filename of a calibration patter (mode='cal') is now
	    recognized as a CCD frame.


smei_filepath $SMEI/ucsd/camera/idl/toolbox/smei_filepath.pro
[Previous] [Next]
 NAME:
	smei_filepath
 PURPOSE:
	Construct path to SMEI file (frame or skymap)
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	FUNCTION smei_filepath, tf, $
	    base    = base  , $
	    source  = source, $
	    camera  = camera, $
	    mode    = mode  , $
	    postfix = postfix,$
	    type    = type  , $
	    upto    = upto  , $
	    full    = full
 INPUTS:
	tf		undefined; scalar, or array[1]
			    if defined then either a time (in the form of a standard
			    time structure), or the name of a SMEI frame or skymap
			    (e.g. 'c2m0_2003_123_456789')
			    NOTE: if tf is NOT defined than keyword source MUST be
			    set to an existing directory.
 OPTIONAL INPUT PARAMETERS:
	source=source	scalar; type: string; default: SMEIDB?
			    directory where to look for SMEI frames.
			    If the directory does not exist then the current SMEI
			    drive is used. The default value SMEIDB? will result
			    in an automatic determination of a source directory
			    using the information in file smei_drives.txt.

	The SMEI frames are stored in directories of the form
	$SMEIDB#/yyyy_doy/hh. By default the name of the full directory
	where the frames for time 'tf' are located is returned.

	/base		if set only the part $SMEIDB# is returned
	/day		if set only the part $SMEIDB#/yyyy_doy is returned

	mode		scalar; or array[2]
			    mode[0] is used in construction of directory
			    (e.g. $SMEIDB/orb for orbital patterns (mode='orb')
			    mode[1] is used in construction of filename (/full set)
			    (e.g. mode=['orb_003','orb'] results in
			    $SMEIDB/orb_003/c3orb_2000_001_000000.fts.gz)
 OUTPUTS:
	ff		scalar; type: string
			    directory where frame(s) for specified time are located
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	skyd_cat, skyd_version, smei_blocked, smei_buf_prep, smei_findpnt, smei_frm_mask
	smei_frm_read, smei_getfile, smei_hdr_get, smei_hdr_plot, smei_hdr_update
	smei_mkbase, smei_mkc3mask, smei_mkcal, smei_mkcal_auto, smei_mkmask, smei_mkorb
	smei_mkorb_auto, smei_mksidereal, smei_mksky, smei_orbit_stats, smei_property
	smei_rewind, smei_sky_getmask, smei_sky_read, smei_star_remove
	smei_zld_remove [1], smeidb_mounted
 COMMON BLOCKS:
	common smei_filepath_save, checkdrives, sdat
 CALLS: ***
	CheckDir, FILEPATH, InitVar, IsTime, IsType, TimeGet, TimeOp, TimeSet, TimeUnit
	destroyvar, flt_read, smei_filename, who_am_i
 PROCEDURE:
	The SMEI data are distributed across several hard drives.
	Env variables SMEIDB1, SMEIDB2, etc. exist pointing to the mount
	points of each drive. Each drive contains data for the time range
	specified in the file 'smei_drives.txt'.

	SMEI data are organized in separate folders for each day. E.g. the
	folder $SMEIDB1/2003_100/c2 contains all SMEI frames
	day of year 100 (in year 2003) for camera 2.

	If tf is NOT defined then the YYYY_DOY part in the returned path
	will be missing. This is useful to locate skymaps (which usually are
	split up by camera only, not by time).
 MODIFICATION HISTORY:
	JUN-2003, Paul Hick (UCSD/CASS)
	    Introduced to deal with multiple hard drives containing
	    SMEI data frames.
	MAY-2004, Paul Hick (UCSD/CASS)
	    Modified to reflect new directory structure of SMEI data base
	    (frames are now organized in a separate directory for each
	    doy of year, with subdirectories for each of the cameras)
	AUG-2006, Paul Hick (UCSD/CASS)
	    Modified to do something useful when tf is not defined.
	FEB-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Generalized to work with data other than CCD frames
	    (skymaps, hdr and png files)
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added 'cal', 'orb', 'orb_003', 'sts' to mode options.
'	    'mode' can now be a 2-element array with mode[0] used
	    in the directory name and mode[1] in the filename
	    (if /full is set)


smei_findcrazy $SMEI/ucsd/camera/idl/toolbox/smei_findcrazy.pro
[Previous] [Next]
 NAME:
	smei_findcrazy
 PURPOSE:
	Look for 'crazy frames'
 CATEGORY:
 CALLING SEQUENCE:
	PRO smei_findcrazy, trange, source=source, camera=camera, mode=mode, copy=copy
 INPUTS:
	trange		passed to smei_hdr_get
 OPTIONAL INPUT PARAMETERS:
	camera
	mode
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS: ***
	GetFileSpec, InitVar, boost, destroyvar, do_file, smei_cam2angle, smei_frm_hbar
	smei_hdr_get
 SEE ALSO:
 PROCEDURE:
 MODIFICATION HISTORY:
	JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_findobj $SMEI/user/pphick/idl/smei_findobj.pro
[Previous] [Next]
 NAME:
	smei_findobj
 PURPOSE:
	WORK IN PROGRESS
	Analyzes output from smei_findpnt
 CATEGORY:
	smei/ucsd/camera/idl/star
 CALLING SEQUENCE:
	PRO smei_findobj		, $
	    eq_objects	= eq_objects	, $
	    np_objects	= np_objects	, $
	    sp_objects	= sp_objects	, $
	    camera	= camera	, $
	    source	= source	, $
	    from_mode	= from_mode	, $
	    binfactor	= binfactor
 OPTIONAL INPUT PARAMETERS:
	eq_objects=eq_objects		array; type: structure
	np_objects=np_objects		array; type: structure
	sp_objects=sp_objects		array; type: structure
	source=source			scalar; type: string; default: $TUB
	fromn_mode=from_mode		scalar; type: string; default: 'bol'
	camera=camera			scalar; type: integer; default
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS: ***
	AngleRange, AngleUnits, ArrayLocation, FILEPATH, HIST_2D, InitVar, IsType, MEAN, REVERSE
	STDDEV, WhatIs, boost, cvsmei, cvsmei_init, destroyvar, smei_i2m, smei_star_list
	smei_star_readpnt, view
 SEE ALSO:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 EXAMPLE:
 STATE INFO USED:
 STATE INFO MODIFIED:
 PROCEDURE:
 MODIFICATION HISTORY:
	NOV-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_findpnt $SMEI/ucsd/camera/idl/star/smei_findpnt.pro
[Previous] [Next]
 NAME:
	smei_findpnt
 PURPOSE:
	Originally created to look for point sources in the star-subtracted
	equ files to find unknown objects (i.e. objects not included in the
	SMEI star catalogues).

	To run this program access is needed to the 'equ' files, If keyword
	/use_catalogue is set then also access to the 'sky' files is required.
 CATEGORY:
	smei/ucsd/camera/idl/star
 CALLING SEQUENCE:
	PRO smei_findpnt, wanted_map	, $
	    camera	= camera	, $
	    from_mode	= from_mode	, $
	    to_mode	= to_mode	, $
	    destination = destination	, $
	    fix_centroid= fix_centroid	, $
	    cvmin	= cvmin 	, $
	    use_catalogue= use_catalogue, $
	    npeak	= npeak 	, $
	    silent	= silent	, $
	    _extra	= _extra
 INPUTS:
	wanted_map	array[n]; type: string, time structure or integer
			    passed to smei_getfile.
			    Selects skymap files to be processed.
			    Usually this is a pair of times (start time and
			    stop time) to process all maps inside a period
			    of time.
 OPTIONAL INPUT PARAMETERS:
	camera=camera	scalar; type: integer; default: 2
			    camera id (1,2,3). The default camera 2 has the most
			    sky real estate.
	from_mode=from_mode
			scalar; type: string; default: 'equ'
			    selects the type of skymap to be used.
			    Can also be used for 'sky' to work from the
			    unsubtracted maps, but that doesn't make much sense
			    since these maps still contain all the catalogue stars.
	to_mode=to_mode
			scalar; type: string; default: 'bol'
			    This is only used in the naming convention for the
			    output 'pnt' files: the names will look like:
			    c2bol_YYYY_DOY_hhmmss.pnt
			    where YYYY_DOY_hhmmss is the start time of a SMEI
			    orbit, taken from the associated 'equ' file
	destination=destination
			scalar; type: string; default: $TUB
			    destination directory of output file(s)
	fix_centroid=fix_centroid
			if set, this turns on the 'fix_centroid' option in the
			smei_star_fit, i.e. the centroid position of the new
			object is iteratively improved. This gives better results
			at the expense of a substantial increase in processing time.

	cvmin=cvmin	scalar; type: float; default: 0.7
			    Only new objects with a PSF correlation coefficient
			    greater than cvmin will be written to the output files

	/use_catalogue	if set, an attempt is made to match unknown objects against
			objects in the SMEI catalogue. This will pick up 'unknown'
			objects at the location of a SMEI catalogue object, usually
			indicating that the catalogue star was imperfectly subtracted.
			This keyword can increase processing time significantly
			especially if combined with a low cvmin value.

	npeak=npeak	scalar; type: integer; default: none, i.e. no limit
			passed to FindPeaks.
			Can be used to limit the number of objects on the initial
			list of local maxima in the skymap, that are further
			investagated by smei_star_fit.
			Probably best avoided (see PROCEDURE)

	silent=silent	scalar; type: integer; default: 0
			    higher values suppress more informational messages
 OUTPUTS:
	Files in destination directory
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, AngleUnits, ArrayLocation, BadValue, FILEPATH, FXPAR, FindPeaks, HEADFITS
	InitVar, REVERSE, SuperArray, TimeSet, TimeSystem, boost, cvsmei, destroyvar, hide_env
	smei_filename, smei_filepath, smei_getfile, smei_sky, smei_star_fit
	smei_star_info, smei_star_writepnt, sphere_distance
 PROCEDURE:
	The equ files have all SMEI catalogue stars (presumably all stars
	brighter than 6th magnitude), the sidereal background and the
	zodiacal dust cloud subtracted.

	The search procedure consists of the following steps:

	1. Smoothing of skymaps.

	First the map is smoothed by subtracting a running mean for an 8 degree wide box.
	This takes out variations over spatial scales much larger than the PSF. This step
	mainly serves to create local maxima that are more easily sorted, i.e. it makes
	it easier to process maxima starting with the highest and working down from there.

	The second step is to apply a smoothing using a running mean of 1 degree, the full
	width of the SMEI PSF. This reduces the noise in the maps, and avoids picking
	up every noise spike as a separate local maxima.

	2. Prepare a list of candidate objects.

	In this step the procedure FindPeaks is used to make a list of all the local
	maxima in the skymap, listing the highest ones first.
	The number of local maxima can be controlled with a number of keywords
	(see FindPeaks for details). This should not really be necessary:
	step 1 has proven to be the simplest way to control the output from
	FindPeaks.

	3. Fit all the candidate maxima to the PSF using smei_star_fit.

	This step uses the default star fitting procedure for SMEI to identify
	those objects on the candidate list that look like point sources (i.e.
	look like the SMEI PSF).

	The main keyword to control this step is /fix_centroid.
	The default mode is NOT to use this keyword. In that case the PSF is fit
	once at the location of each candidate maximum. If /fix_centroid is ON,
	then an iterative procedure is used to find the location in the skymap
	near the candidate maximum that provides the best fit (the highest
	correlation between the object in the skymap and the standard SMEI PSF).

	The advantage of NOT setting /fix_centroid is a significant reduction
	in processing time (close to a factor of 10). The disadvantage is that
	the quality of the PSF fitting is worse, which might lead to good objects
	going unnoticed because the correlation is much worse.

	The result of step 3 is that all the candidate objects from step 2
	can be classified by sorting on the correlation coefficient of
	of the PSF fit. The difference between using (or not using) /fix_centroid
	is that the candidates will be sorted differently.

	4. Retain the best fitting objects only

	At this stage the keyword cvmin is used to only retain objects that
	resulted in a correlation coefficient higher than cvmin (0.7 by default).
	The total list of candidates for one skymap can easily be on the order
	of 1000 or so. A significant fraction of the correlation coefficient
	(often 70-80%) of the candidates will be quite low, so it makes sense
	to reduce the search space by focusing on the higher correlations.

	Note that at this stage the effect of using (or not using) fix_centroid
	in step 3 becomes evident: since the correlation coefficients are different
	(lower when fix_centroid is not used), a different set of candidate objects
	is retained. Note that if cvmin=-1 is used, all objects are retained.
	This results in significantly larger output files though.

	[Rebekah, could you summarize your tests with /fix_centroid and cvmin here.
	This is what I remember]

	For cvmin=0.7 a testrun indicates that approximately the same amount of
	objects remain for runs with /fix_centroid ON and OFF, with about 2/3 of
	the objects the same in both lists.

	4. Match against catalogue stars

	This step is optional. By default it is not done, but it can be switched
	on with keyword /use_catalogue.

	The locations of the candidate maxima from step 4 (after trimming the list
	using cvmin), is compared against the locations in the SMEI star
	catalogues. If a catalogue star is found whitin 0.5 degrees of a
	candidate object, most likely the object found is the results of
	a badly-subtracted catalogue star. In this case the candidate
	object will be listed in the output file under the name of the candidate
	object. Note that this is not a positive indentification; it just indicates
	the proximity of a catalogue star.

	Using a low value of cvmin in combination with /use_catalogue keyword is
	not advisable: checking a long list of candidate objects against the SMEI
	star catalogue will drastically increase processing time.

	5. Write output file

	The output files contains the results of the fits for all candidate
	objects, sorted by correlation (the best one first).

	Note that for objects located in the overlapping area between the polar
	maps and the equatorial map (approximately between 50 and 60 degrees
	declination north and south there will be two records in the output file:
	one for the object seen in the equatorial map, the other in one of the
	polar maps. This needs to be taken into account when analyzing the
	content of the input file (e.g. when counting the number of hits for
	a given object in a sequences of skymaps).

	The names of the objects indicated in which map the object was detected,
	EQ (for the equatorial map), NP and SP for north and south polar map,
	respectively; followed by an integer that counts the number of objects.
	Note that the same object will have a different name in output files
	for different skymaps. Entries will need to be matched by RA and dec.

 MODIFICATION HISTORY:
	FEB-2008, Paul Hick (UCSD/CASS)
	NOV-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Thorough review of code; added documentation.
	    Most significant change to the code was the removal of the zodiacal
	    dust cloud subtraction. The equ file now contain maps with the zld
	    already subtracted, so this is not needed anymore.
       Reduced dependence on 'sky' files. These are needed now only if
       keyword /use_catalogue is used.


smei_fixpnt $SMEI/user/pphick/idl/smei_fixpnt.pro
[Previous] [Next]
 NAME:
	smei_fixpnt
 CALLING SEQUENCE:
	PRO smei_fixpnt, file, version=version
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, FindAllFiles, InitVar, hide_env, smei_star_formatpnt, smei_star_info
	txt_read


smei_frm_base $SMEI/ucsd/camera/idl/frm/smei_frm_base.pro
[Previous] [Next]
 NAME:
	smei_frm_base
 PURPOSE:
	Calculate pedestal and dark current for frame
 CATEGORY:
	smei/camera/idl/misc
 CALLING SEQUENCE:
	PRO smei_frm_base, hdr, img, silent=silent,			$
	    cam_full=cam_full, cam_ok=cam_ok, init=init, reset=reset,	$
	    clear=clear, frm=frm, step=step, status=status,		$
	    nfill_control=nfill_control, nbad_control=nbad_control
 INPUTS:
	hdr	    array[1]; type: structure
			frame header
	img	    array; type: integer
			frame data
 OPTIONAL INPUT PARAMETERS:
	nfill_control=nfill_control
		    scalar; type: integer; default: 10
	/init	    initialize all camera/mode combinations
	/reset	    re-initialize the current camera/mode combination only
	/clear	    clear all variables stored internally in common block
	silent	    =0: display all messages
		    =1: suppress non-essential messages
		    =2: suppress all messages
 OUTPUTS:
	hdr	    array[1]; type: structure
			frame header with a number of values filled, in particular
			hdr.pedestal, hdr.dark current, hdr.squares, hdr.centerpix
	img	    array; type: float
			image with pedestal and dark current subtracted
			Any negative elements after subtraction are set to zero
			(these will mostly be pixels in the semi-covered columns
			(5 and 315 for mode 2 data)
 OPTIONAL OUTPUT PARAMETERS:
	cam_ok=cam_ok
		    scalar; type: byte
		    0: failed to determine pedestal and/or dark current
		    1: pedestal and dark current determined successfully
	nfill_control=nfill_control
		    scalar; type: integer
			# good frames used to build reference base values
	cam_full=cam_full
		    0: still busy accumulating reference base data (based on
			nfill_control preceeding good frames) for current
			camera/mode combination
		    1: reference data for preceeding nfill_control good frames
			available
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro	; SMEI masks
 CALLED BY:
	smei_frm_track
 COMMON BLOCKS:
	common smei_frm_base_save, ped_threshold, drk_threshold,	    $
	    ped_mean_init, drk_mean_init, ped_sigma_init, drk_sigma_init,   $
	    nfull, nbads, ifull, bfull, nbad, badv, $
	    peds_mean, peds_sigma, drks_mean, drks_sigma,$
	    ped_mean , ped_sigma , drk_mean , drk_sigma , $
	    drk_nout_init, drk_dout_init, drks_nout, drk_nout, drk_dout,    $
	    drk_lr_ratio
 CALLS: ***
	ArrayLocation, BadValue, InitVar, IsType, MEAN, STDDEV, TimeGet, TimeUnit, destroyvar
	smei_property, smei_setup_roi, where_common, who_am_i
 PROCEDURE:

 MODIFICATION HISTORY:
	MAY-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_comments $SMEI/ucsd/camera/idl/frm/smei_frm_comments.pro
[Previous] [Next]
 NAME:
	smei_frm_comments
 PURPOSE:
	Returns comments for Fits header in SMEI frame
 CATEGORY:
 CALLING SEQUENCE:
	FUNCTION smei_frm_comments, hdr
 INPUTS:
	hdr array[1]; type: SMEI__FRM_HDR structure
		SMEI frame header
 OUTPUTS:
	str array[n]; type: string
		list of comments (one for each tag name
		in the SMEI__FRM_HDR structure
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	smei_frm_cvhdr
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_cp $SMEI/ucsd/camera/idl/frm/smei_frm_cp.pro
[Previous] [Next]
 NAME:
	smei_frm_cp
 PURPOSE:
	Copy SMEI frames from SMEI data base
 CATEGORY:
	ucsd/camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_frm_cp, trange, destination=destination, unzip=unzip, camera=camera, mkdir=mkdir, _extra=_extra
 INPUTS:
	trange		    array[2]; type: time structure
			    time range to be copied (see TimeSet)
 OPTIONAL INPUT PARAMETERS:
	camera=camera	scalar, or array[n] (n=1,2,3); default: [1,2,3]
			    cameras to be copied
	/unzip		if set files are unzipped
	/mkdir		if set then the destination directory specified using
			    the'destination' keyword is created if it doesn't exist already

	Passed to smei_getfile:

	silent=silent	controls informational messages
	mode=mode	scalar, or array[n] (n=0,1,2); default: none
			if set only the specified modes are selected
 OUTPUTS:
	(none)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, GetFileSpec, InitVar, IsTime, TimeGet, TimeOp, TimeSet, TimeUnit
	do_file, hide_env, smei_getfile
 RESTRICTIONS:
	Files are copied in groups of typically about 4000 frames at a time.
	See do_file for more details. The limitation arises from a restriction
	on the length of a shell command (usually 128 kB).
 PROCEDURE:
 >	Files for camera 1 are copied into subdirectory c1 of destination
	directory (the subdirectory is created if it does not exist yet).
	Same for cameras 2 and 3.
 > Specifying the mode keyword requires that file headers need to be read
	to determine the mode (the camera number is coded into the file name).
	This slows down the copy operation considerably.
 EXAMPLES:
	Copy files for cameras 1 and 2 from between 0 UT on doy 110 to 0 UT on doy 115
	for 4x4 binning (mode 2) to the $TUB directory: Unzip files after copy
	is complete.

	tt = TimeSet(yr=2004,doy=[110,115])
	smei_frm_cp, tt,destination=getenv('TUB'), /unzip, camera=[1,2], mode=2


	Copy all frames for the specified time period for all cameras to
	'/zulu/zone/2003_110_115', creating the subdirectory 2003_110_115 if it
	doesn't exist already; suppress informational messages:

	tt = TimeSet(yr=2004,doy=[110,115])
	smei_frm_cp, tt,destination=getenv('TUB'), /unzip, silent=1

	See TimeSet for other ways to specify begin and end time.
 MODIFICATION HISTORY:
	JUL-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_cvhdr $SMEI/ucsd/camera/idl/frm/smei_frm_cvhdr.pro
[Previous] [Next]
 NAME:
	smei_frm_cvhdr
 PURPOSE:
	Convert frame headers between various formats
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	FUNCTION smei_frm_cvhdr,	$
	    from_hdr	= from_hdr  ,	$
	    from_byte	= from_byte ,	$
	    from_fits	= from_fits ,	$

	    to_ascii	= to_ascii  ,	$
	    to_fits	= to_fits   ,	$
	    to_byte	= to_byte   ,	$
	    to_hdr	= to_hdr    ,	$

	    swap_bytes	= swap_bytes,	$

	    tlm_file	= tlm_file  ,	$
	    l1a_file	= l1a_file  ,	$
	    l1a_pntr	= l1a_pntr  ,	$

	    length	= length    ,	$
	    allow_bad	= allow_bad ,	$
	    corrupt_frame = corrupt_frame   , $
	    error_message = error_message
 OPTIONAL INPUT PARAMETERS:
	from_hdr=from_hdr	array[1]; type: smei_frm_hdr structure
				    frame header

	from_byte=from_byte	array[256] or array[512]; type: byte
				    binary header from L1A file (256 bytes) or
				    trailer from .nic file (512 bytes).
				    A trailer from .nic file should have the
				    starting byte('buf') removed already.

	from_fits=from_fits	array[n]; type: string
				    fits header extracted from SMEI frame fits file

	/to_hdr 		return header as a smei_frm_hdr structure
	/to_byte		return header as a 256 or 512 byte array
	/to_fits		return header as a fits header string array
				    if the fits header is not from a SMEI camera frame
				    then the integer -1 is returned.
	/to_ascii		return a single string with an ascii representation
				of selected information from the header (used primarily
				for display in widgets).

	/swap_bytes		if set, then bytes are swapped in the byte header
				(used if from_byte=from_byte or /to_byte is used.
 OUTPUTS:
	rtn_hdr 		header in format selected with /to_* keywords
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, CV_COORD, FXADDPAR, FXPAR, GetFileSpec, InitVar, IsType, MKHDR, TimeGet
	TimeOp, TimeSet, TimeUnit, cvsmei, eclipsed_area, jpl_body, jpl_eph, sgp4_eph
	smei_frm_comments, smei_frm_flag, smei_property
 CALLED BY:
	img_read, smei_buf_read, smei_frm_read, smei_frm_write
 PROCEDURE:
	Only a selection of the data in the header are put in the string,
	separated by the newline character (10B).

	The binary frame header in the Hanscom L1A*.buf files binary header
	has 256 bytes. These are in Unix format (big-endian), i.e. byte swapping
	is necessary on i386 machines (which are little-endian).

	The .nic files contain a 512 byte trailer.
	The first 3 bytes in the .nic files are used to store the ASCII string 'buf'
	(to distinguish them from other .nic files, e.g. the TMO data).
	The next 256 bytes in the .nic trailer (bytes 3-258) are a copy
	of the frame header found in the Hanscom L1A*.buf files, except for byte
	swapping when necessary (i.e. they are little-endian).
	The remaining 253 bytes are partially filled with UCSD extensions:

	    259 +
	    byte   0- 59 (60)	name of original telemetry file
	    byte  60-119 (60)	name of original L1A file
	    byte 120-123 ( 4)	file pointer into L1A file

	    byte 184-187 ( 4)	# pixels contributing to pedestal
	    byte 188-191 ( 4)	# pixels contributing to dark current
	    byte 192-196 ( 4)	# pixels in negative measles
	    byte 196-199 ( 4)	# pixels in positive measles
	    byte 200-203 ( 4)	# pixels in big measles
	    byte 204-207 ( 4)	# pixels in cosmic rays
	    byte 208-211 ( 4)	# pixels in big cosmic rays
	    byte 212-215 ( 4)	residual intensity in squares
	    byte 216-219 ( 4)	residual intensity in center group
	    byte 220-223 ( 4)	standard deviation of pedestal
	    byte 224-227 ( 4)	standard deviation of dark current
	    byte 228-231 ( 4)	flags

 MODIFICATION HISTORY:
	OCT-2003, Paul Hick (UCSD/CASS)
	    Extracted from smei_buf_splitframe
	JUN-2004, Paul Hick (UCSD/CASS)
	    Added room for name of another pattern file name.
	    Rearranged to put everything at proper boundaries.
	MAR-2005, Paul Hick (UCSD/CASS)
	    Added code to fill hdr.sun,hdr.moon,hdr.venus,hdr.ra,hdr.dec
	    and hdr.angle, hdr.eclipse and hdr.shadow using JPL ephemeris
	    and Coriolis orbital elements run through sgd4.
	    Note that for the first real-time downloads of the
	    SMEI data the orbital elements will probably be out of date, so
	    especially hdr.moon and hdr.eclipse should be treated with suspicion
	    until this has been rerun with valid orbital elements.
	MAR-2009, Paul Hick (UCSD/CASS)
	    Added checks for valid camera and mode values, and a check on
	    valid time when converting from binary header to a hdr structure.
	    When an invalid value is found, the integer -1 is returned
	    instead of a structure.
	MAR-2011, Paul Hick (UCSD/CASS)
	    Bug fix. The julian_date entry in a binary header from an L1A file
	    was tested for equality against the time specified in the year,doy,
	    hour,min,sec fields. This led to the occasional rejection of
	    a header (testing real numbers for equalitiy is a bad idea after all).
	    The test now is that julian date needs to within 10 msec.
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added corrupt_frame keyword to be able to suppress printing of
	    of error_messages while recovery from corrupt frame is in progress
	    (this would potentially generate truckloads of messages.
	    Added error_message keyword.


smei_frm_darkfit $SMEI/user/pphick/idl/glare/smei_frm_darkfit.pro
[Previous] [Next]
 NAME:
	smei_frm_darkfit
 CALLING SEQUENCE:
	PRO smei_frm_darkfit, tt, plotx=plotx
 INCLUDE:
	@compile_opt.pro    ; On error, return to caller
 CALLS: ***
	CURVEFIT, FILEPATH, FindAllFiles, GetFileSpec, InitVar, IsTime, PlotCurve, TimeOp
	TimeSet, TimeUnit, boost, flt_read, smei_frm_darkfnc, who_am_i


smei_frm_darkfnc $SMEI/user/pphick/idl/glare/smei_frm_darkfnc.pro
[Previous] [Next]
 NAME:
	smei_frm_darkfnc
 CALLING SEQUENCE:
	PRO smei_frm_darkfnc, x, a, f, p
 INCLUDE:
	@compile_opt.pro
 CALLED BY:
	smei_frm_darkfit


smei_frm_drive $SMEI/ucsd/camera/idl/toolbox/smei_frm_drive.pro
[Previous] [Next]
 NAME:
	smei_frm_drive
 PURPOSE:
	Return time range for content of SMEI data base
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	FUNCTION smei_frm_drive, drive
 INPUTS:
	drive	    scalar or array[n]; type: integer or string
			identified SMEI drive as integer n
			or as string of type 'SMEIDBn'
			If omitted all drives are used
 OUTPUTS:
	t	    array[2,n]; type: time structure
			begin and end time of data on each drive
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, IsType, TimeSet, destroyvar, flt_read, flt_string, who_am_i
 CALLED BY:
	smei_hdr_update
 COMMON BLOCKS:
	common smei_filepath_save, checkdrives, sdat
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_eclipse $SMEI/ucsd/camera/idl/frm/smei_frm_eclipse.pro
[Previous] [Next]
 NAME:
	smei_frm_eclipse
 PURPOSE:
	Eclipse calculations
 CATEGORY:
	smei_frm_eclipse, hdr, /may2003
 CALLING SEQUENCE:
	PRO smei_frm_eclipse, hdr,  $
	    may2003 = may2003	, $
	    nov2003 = nov2003	, $
	    jun2003 = jun2003	, $
	    apr2004 = apr2004	, $
	    oct2004 = oct2004	, $
	    apr2005 = apr2005	, $
	    mar2006 = mar2006	, $
	    sep2007 = sep2007	, $
	    aug2008 = aug2008	, $
	    jan2009 = jan2009	, $
	    jan2010 = jan2010	, $
	    earth   = earth	, $
	    orbit   = orbit	, $
	    loc     = loc	, $
	    runit   = runit	, $
	    area    = area	, $
	    camera  = camera	, $
	    _extra  = _extra
 INPUTS:
	hdr			array; type: structure
				    headers of SMEI frames returned from a
				    previous call. If hdr exists than the
				    optional input parameters are ignored.
 OPTIONAL INPUT PARAMETERS:
	/may2003, orbit=0	for eclipse on 31 May 2003 04:13
	/may2003, orbit=-1	for eclipse on 31 May 2003 02:42
	/nov2003		for eclipse on 23 Nov 2003 22:53
	/apr2004		for eclipse on 19 Apr 2004 15:24

	/apr2005		for eclipse on 08 Apr 2005 20:35
	/mar2006		for eclipse on 29 Mar 2006 10:10
	/sep2007
	/aug2008		includes full eclipse
	/jan2009
	/jan2010

	/jun2003		Coriolis in Earth shadow from 13:58:19 until 14:14:51

	orbit=0 		plots several orbits around time of maximum eclipse
	orbit=-1		plots the earlier of the two eclipses usually seen by SMEI
	orbit=1 		plots the later of the two eclipses
 OUTPUTS:
	(Plot to screen)

	hdr			array; type: structure
				    headers of all SMEI frames processed
				    This can be used as input for subsequent
				    call to to bypass rereading of the frames.
 OPTIONAL OUTPUT PARAMETERS:
	loc=loc 		output from smei_frm_where
	runit=runit		output from smei_frm_where
	area=area		output from eclipsed_area
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, TimeGet, TimeLimits, TimeSet, TimeUnit, eclipsed_area, jpl_body
	smei_frm_where, smei_property
 PROCEDURE:
 MODIFICATION HISTORY:
	OCT-2004, Paul Hick (UCSD/CASS)
	FEB-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added eclipses in sep 2007 and later.


smei_frm_findpoint $SMEI/ucsd/camera/idl/frm/smei_frm_findpoint.pro
[Previous] [Next]
 NAME:
	smei_frm_findpoint
 PURPOSE:
	Return frames with specified locations in the fov
 CATEGORY:
	ucsd/camera/idl
 CALLING SEQUENCE:
	PRO smei_frm_findpoint, trange, $
	    _extra  = _extra	, $
	    hdr     = hdr	, $
	    theta   = theta	, $
	    ccd     = ccd	, $
	    list    = list	, $
	    camera  = camera
 INPUTS:
	trange		array[2]; type: time structure
			    time range of target frames
 OPTIONAL INPUT PARAMETERS:
	/degrees	if set all angles are in degrees (default: radians)

	The sky locations can be specified using any one of the methods
	used in smei_frm_where. The simplest is:

	points_radec	array[2]; type: float
			    J2000 RA and dec of locations in the sky.
			    The units are degrees or radians depending on the
			    setting of keyword /degrees.

	list=list	scalar; type: string; default: none
			    name of an output file where to write the fully-qualified
			    file names of all SMEI frames containing the sky location.
 OUTPUTS:
	hdr=hdr 	array; type: structure
			    headers for all identified SMEI frames
	theta=theta	see smei_frm_where
	ccd=ccd 	see smei_frm_where
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, InitVar, IsType, MEAN, TimeGet, TimeLimits, TimeOp, TimeSet, TimeUnit, boost
	destroyvar, do_file, smei_coriolis, smei_frm_where, smei_property
 CALLED BY:
	grayburst
 PROCEDURE:
 >	Check whole orbit starting at trange[0] for frames with the sky location
	in it. If no frames are found, try the next orbit.
 >	If a transit of the sky location is found then determine the start
	and duration of the transit. Use this to estimate when the transit
	in the next orbit is.
 MODIFICATION HISTORY:
	NOV-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_flag $SMEI/ucsd/camera/idl/frm/smei_frm_flag.pro
[Previous] [Next]
 NAME:
	smei_frm_flag
 PURPOSE:
	Manipulates hdr.flags entry in SMEI frm header
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	result = smei_frm_flag(flag [,flag=flag, names=names])
 INPUTS:
	hdr		array; SMEI__FRM_HDR structure
 OPTIONAL INPUTS
	flag=flag	array; type: SMEI_FRM_HDR structure or integer
 OPTIONAL INPUT PARAMETERS:
	The following flags are processed:

	base_done
	base_ok
	eclipse
	shadow
	bad_quat
	just_bad
	anneal

	tagmode
	full_frame
	shutter
	dark_offset
	flatfield
	cosmic_rays
	calibration
	flat_enabled
	led_enabled
	bos_alert
 OUTPUTS:
	results     array: type: SMEI_FRM_HDR structure or integer
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType, ibsetf, ibtestf
 CALLED BY:
	smei_frm_cvhdr, smei_frm_update
 PROCEDURE:
	Each keyword corresponds to a bit in the hdr.flags entry.
	The values used here should be consistent with the value
	in the Fortran include value smei_frm_hdr.h
 MODIFICATION HISTORY:
	MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_flatfield $SMEI/ucsd/camera/idl/frm/smei_frm_flatfield.pro
[Previous] [Next]
 NAME:
	smei_frm_flatfield
 PURPOSE:
	Get small or large-scale flatfield for the SMEI cameras.
 CATEGORY:
	camera/idl/field
 CALLING SEQUENCE:
	ff = smei_frm_flatfield(camera=camera [, /lsff)
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
	camera=camera	    scalar; type: integer; default: 1
				camera number (1,2, or 3)
	/lsff		    get large scale flatfield instead of
			    small scale flatfield.
 OUTPUTS:
	ff		    array[1272,256]; type: double
				flatfield value; the flatfield is applied
				by multiplying the uncorrected value by ff.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro	; ROI definition
 CALLS: ***
	FILEPATH, InitVar, IsType, MagnifyArray, READFITS, SuperArray, smei_setup_roi
	who_am_i
 PROCEDURE:
	SMALL SCALE (ON BOARD) FLAT FIELDS:

	c1_ssff.fts.gz, c2_ssff.fts.gz, c3_ssff.fts.gz

	For the small-scale flatfields, if the uncorrected CCD-readout is N ADUs,
	then the flat field corrected read-out M follows by adding one to the
	flatfield values and multiplying, i.e. with ff the array read from the
	FTS file:

	M = (1+ff)*N

	The addition of 1 is already done in the output array
	(i.e. 1+ff is returned).


	LARGE SCALE FLAT FIELDS:

	c1_lsff.fts.gz, c2_lsff.fts.gz, c3_lsff.fts.gz

	For the large-scale flatfields, if the uncorrected readout is N ADUs, then
	the flat field corrected readout M follows by dividing by the flat field
	value, i.e. with ff the array from the FTS file:

	M = N/ff

	The inversion is already done in the output array (i.e. 1/ff is returned).


	RAL TO SMEI MAPPING (applies to ssff and lsff files, NOT the lsffc files):

	All FTS files contain float arrays of size 1280x600 ('RAL frame'). The SMEI
	engineering mode (mode 0) frames have dimensions 1272x256. The pixels in a
	SMEI frame are a subset of the pixels in a RAL frame. The RAL frame is
	mapped to the SMEI frame by dropping the first 5 columns, then extracting
	the next 1272 columns; and dropping the first 65, 59 and 61 rows for
	cameras 1, 2 and 3, resp., then extracting the next 256.

	Let:
	    n = 5, m = 65   for camera 1
	    n = 5, m = 59   for camera 2
	    n = 5, m = 61   for camera 3

	Then in IDL (with 0-based array indices):

	    SMEI = RAL[n:n+1271,m:m+255]

	or pixel-by-pixel:

	    SMEI[i,j] = RAL[n+i,m+j]

	In Fortran (1-based array indices):

	    for j=1,256
		for i=1,1272
		    SMEI[i,j] = RAL[n+i,m+j]
		end for
	    end for

	NORMALIZED FLAT FIELD CORRECTION (clsff):

	c1_clsff.fts.gz, c2_clsff.fts.gz, c3_clsff.fts.gz

	Contain arrays of size 1280x301 with numbers of order 1. As far as I can
	tell these are based on the large-scale flat field files with a couple of
	modifications:
	- geometrical effects are taken out (cosine effect along long dimension due
	  to changing effective aperture size, and radial effect along the narrow
	  dimension
	- a couple of 'bad pixels' are stamped out

	Even though the arrays suggest they are in engineering mode they are
	effectively in mode 2 (4x4 binning): numbers are identical in groups of 4x4.
	To use them with the SMEI an offset needs to be taken into account different
	from the large-scale flatfield discussed above: the first two columns need
	to be dropped, and the first 16, 10 and 12 rows for cameras 1,2 and 3,
	respectively.
	So let:
	    n = 2, m = 16   for camera 1
	    n = 2, m = 10   for camera 2
	    n = 2, m = 12   for camera 3
	Then use the same code as above for the large-scale flatfields.
 MODIFICATION HISTORY:
	JAN-2004, Paul Hick (UCSD/CASS)
	NOV-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added the normalized flatfield corrections.


smei_frm_hbar $SMEI/ucsd/camera/idl/frm/smei_frm_hbar.pro
[Previous] [Next]
 NAME:
	smei_frm_hbar
 PURPOSE:
	Detects horizontal features in SMEI frames with readout
	lower than neigbouring rows (i.e. 'crazy frames')
 CATEGORY:
	ucsd/camera/idl/frm
 CALLING SEQUENCE:
	FUNCTION smei_frm_hbar, trange, $
	    length	= length    , $
	    _extra	= _extra    , $
	    roi_map	= roi_map   , $
	    moon	= moon	    , $
	    sun 	= sun	    , $
	    venus	= venus     , $
	    bpos	= bpos	    , $
	    bmap	= bmap	    , $
	    hdr 	= hdr	    , $
	    bdepth	= bdepth    , $
	    blength	= blength   , $
	    dlength	= dlength   , $
	    pcount	= pcount    , $
	    excl_moon	= excl_moon , $
	    excl_sun	= excl_sun  , $
	    excl_venus	= excl_venus, $
	    degrees	= degrees
 INPUTS:
	trange		array[2]; type: time structure
			array; type: string
			    if time structure of array this is passed to
			    smei_getfile to get a list of frame file names.
			array[*,*,n]; type: numerical
			    image cube of n SMEI frames
 OPTIONAL INPUT PARAMETERS:
	length		scalar; type: integer; default: 100
			    maximum length of horizontal feature searched for

	blength 	scalar; type: integer; default: length
			    the return arrays bmap, bpos
			    provide information about horizontal features
			    of length 'blength' pixels and longer.
			    (if the maximum length horizontal feature is less
			    than 'blength' than the maximum length is used
			    for 'blength').
	dlength 	scalar; type: integer: default: length

	excl_moon	array[4]; type: float or double
	excl_sun	array[4]; type: float or double
	excl_venus	array[4]; type: float or double
			    if the respective body is inside this exclusion zone
			    the tx-ty (direction cosine) plane then no check is
			    performed (and result -1 is returned)
			    Default units are radians (unless /degrees is set)
	/degrees	sets units of exclusion zones to degrees

	If a 2D array is input as trange then additional header information
	can be provided with the following keywords:
	(these are ignored if trange is a time structure or string:
	the information is extracted from the frame headers):

	roi_map 	identifier for region of interest map used (usually 4)
	moon		location Moon
	sun		location Sun
	venus		location Venus
 OUTPUTS:
	result		array[n]; type: long
			    length of longest horizontal feature in frame
 OPTIONAL OUTPUT PARAMETERS:
	pcount		array[*,n]; type: long
			    number of pixels in horizontal bars at each stage
			    of the detection process
			    pcount[0,n]: # pixels with length 1 and longer
			    pcount[1,n]: # pixels with length 2 and longer
			    etc.

	These output arguments refer to the last frame processes, so they are
	useful only when processing a single frame:

	bmap=bmap	array[*,*]; type: bytarr
			    map of horizontal features with length 'blength' or
			    longer marked by one; zero everywhere else.
	bpos=bpos	array[*,*,n]; type: long
			    starting pixels of hor features with length 'blength'
			    or longer
			    If a bar is n > blength then n+1-blength
			    consecutive pixels will be marked in bmap.
	bdepth=bdepth	scalar; type: float
	blength=blength scalar; type: integer
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro
 CALLS: ***
	ArrayLocation, InitVar, IsTime, IsType, LocalExtrema, MEAN, STDDEV, TimeUnit, destroyvar
	smei_cam2angle, smei_frm_hbar_inside, smei_frm_read, smei_getfile, smei_property
	smei_setup_roi, who_am_i
 CALLED BY:
	smei_findcrazy
 PROCEDURE:
 MODIFICATION HISTORY:
	JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_hbar_inside $SMEI/ucsd/camera/idl/frm/smei_frm_hbar_inside.pro
[Previous] [Next]
 NAME:
	smei_frm_hbar_inside
 PURPOSE:
	(internal use by smei_frm_hbar only)
 CALLING SEQUENCE:
	FUNCTION smei_frm_hbar_inside, txy, tbox, body
 INCLUDE:
	@compile_opt.pro
 CALLED BY:
	smei_frm_hbar
 MODIFICATION HISTORY:
	JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_hdr__define $SMEI/ucsd/camera/idl/frm/smei_frm_hdr__define.pro
[Previous] [Next]
 NAME:
	smei_frm_hdr__define
 PURPOSE:
	Structure definition for frame header of SMEI .buf files
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	hdr = {smei_frm_hdr}
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL BY:
	smei_buf_getframe, smei_frm_summary, smei_frm_track, smei_getfile, smei_hdr_plot
 PROCEDURE:
	See Don Mizuno's, SMEI_CONVERT memo
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS)
	    Based on SMEI Convert 1.0 and 1.1
	FEB-2005, Paul Hick (UCSD/CASS)
	    Rearranged order. Merged all times in single structure
	    elements. Added entry for exposure time. Added location
	    of venus. Removed all blank_double, blank_float,
	    blank_long and blank_short.
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added dark_average


smei_frm_info $SMEI/ucsd/camera/idl/frm/smei_frm_info.pro
[Previous] [Next]
 NAME:
	smei_frm_info
 PURPOSE:
	Compiles statistics for list of frames
 CATEGORY:
	camera/idl/misc
 CALLING SEQUENCE:
	PRO smei_frm_info, hdrs, day_by_day=day_by_day
 INPUTS:
	hdrs	array; type: smei_frm_hdr structure
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
	(to screen)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, TimeGet, TimeOp, TimeUnit, smei_property
 PROCEDURE:
	Counts frames for each camera and mode.
	Also distinguished between padded 'full-frame' data
	and unpadded 'ROI' data.
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_mask $SMEI/ucsd/camera/idl/frm/smei_frm_mask.pro
[Previous] [Next]
 NAME:
	smei_frm_mask
 PURPOSE:
	Check whether camera 3 mask is active at specified time
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	FUNCTION smei_frm_mask, tframe, mask=mask
 INPUTS:
	tframe	    character*(*)   SMEI frame time in format YYYY_DOY_hhmmss
 OUTPUTS:
	smei_frm_mask_active
		    logical	    .TRUE. : bad pixel mask in use for specified time
				    .FALSE.: no bad pixel mask in use for specified time
	cmask	    character*(*)   mask time in format YYYY_DOY
				    This is used in the construction of the file
				    name for the mask.
 CALLS: ***
	FILEPATH, IsTime, SyncArgs, TimeSet, smei_filepath, txt_read
 PROCEDURE:
	A bad pixel mask is in effect during time periods hardcoded in this routine.
	If the specified frame time tframe is inside one of these time periods then
	the appropriate mask is returned. If not inside any one of the time periods
	then a mask containing only the value 1 is returned.
 MODIFICATION HISTORY:
	MAR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_ped $SMEI/ucsd/camera/idl/frm/smei_frm_ped.pro
[Previous] [Next]
 NAME:
	smei_frm_ped
 PURPOSE:
	Calculate electronic pedestal offset for SMEI frames
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	R = smei_frm_ped,
 INPUTS:
	hdr
	ff
 OPTIONAL INPUT PARAMETERS:
	pattern=pattern
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType, smei_property
 SEE ALSO:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 EXAMPLE:
 PROCEDURE:
 MODIFICATION HISTORY:
	OCT-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_read $SMEI/ucsd/camera/idl/frm/smei_frm_read.pro
[Previous] [Next]
 NAME:
	smei_frm_read
 PURPOSE:
	Read SMEI frame
 CATEGORY:
	camera/idl/misc
 CALLING SEQUENCE:
	FUNCTION smei_frm_read, ff  , $
	    source	= source    , $
	    head_room	= head_room , $
	    hdr 	= hdr	    , $
	    silent	= silent    , $
	    error	= error     , $
	    nodata	= nodata    , $
	    ramdisk	= ramdisk   , $
	    raw 	= raw	    , $
	    allow_bad	= allow_bad , $
	    ls_corrupt	= ls_corrupt, $
	    rm_corrupt	= rm_corrupt
 INPUTS:
	ff		scalar; type: string
			    file name of SMEI frame
			    If no file type is specified then .fts.gz is assumed
			    If no directory is specified then the main
			    SMEI data base on smeidb is used.
 OPTIONAL INPUT PARAMETERS:
	source=source	scalar; type: string
			    source directory of SMEI frames
	/nodata 	if set, only read the frame header
			(return value of img will be -1).
 OUTPUTS:
	img		array[n,m]; type: integer
			    SMEI frame data
 OPTIONAL OUTPUT PARAMETERS:
	hdr=hdr 	array[1]; type: structure
			    frame header
	error=error	scalar; type: string
			    error string. Will be the null string if
			    file was read successfully.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro	; ROI mask common block
 CALLS: ***
	FILEPATH, GetFileSpec, HEADFITS, InitVar, IsType, READFITS, TimeGet, TimeOp, TimeUnit
	bin_read, do_file, hide_env, smei_filepath, smei_frm_cvhdr, smei_property
	smei_setup_roi, timeposn, who_am_i
 CALLED BY:
	aurora, img_read, smei_buf_prep, smei_frm_hbar, smei_frm_track, smei_getfile
	stardistance
 SEE ALSO:
 SIDE EFFECTS:
 RESTRICTIONS:
	Andy renames .nic files to .raw to look at them in Adobe Photoshop.
	For now we assume that all .raw files are indeed .nic files in disguise.
 PROCEDURE:
 MODIFICATION HISTORY:
	MAY-2003, Paul Hick (UCSD/CASS)
	JUN-2003, Paul Hick (UCSD/CASS)
	    Added check for missing file extension.
	JUL-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added /ramdisk keyword


smei_frm_rebin $SMEI/ucsd/camera/idl/frm/smei_frm_rebin.pro
[Previous] [Next]
 NAME:
	smei_frm_rebin
 PURPOSE:

 CATEGORY:
 CALLING SEQUENCE:
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro	; ROI mask common block
 EXTERNAL:
 CALLS: ***
	InitVar, MagnifyArray, smei_setup_roi, who_am_i
 SEE ALSO:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 EXAMPLE:
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_smoothdark $SMEI/ucsd/camera/idl/frm/smei_frm_smoothdark.pro
[Previous] [Next]
 NAME:
	smei_frm_smoothdark
 PURPOSE:
	Add extra Fits keyword to frame header containing
	smoothed dark current (boxcar average in the time domain)
 CATEGORY:
	ucsd/camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_frm_smoothdark, trange, $
	    dbsource	= dbsource  , $
	    test	= test	    , $
	    silent	= silent
 INPUTS:
	trange	    array[2]; type: string or time structure
		    time range to be smoothed
		    (internally the range is extended to include
		    enough frames to get the averages near the
		    beginning and end of the time range)
 OPTIONAL INPUT PARAMETERS:
	dbsource = dbsource
		    scalar; type: string; default; SMEIDB?
		    indicates location of frames (either SMEIDB? or SMEIDB?)
		    passed to smei_hdr_update and smei_hdr_get
	/test	    if set, the SMEI frames are not updated
		    (i.e. nothing is modified, just output is written
		    to screen)
 OUTPUTS:
	(Keyword SDARK0 added to Fits header)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FXHMODIFY, GetFileSpec, InitVar, IsType, MEAN, POLY_FIT, TimeGet, TimeLimits, TimeOp
	TimeSet, TimeUnit, hide_env, smei_hdr_get, smei_hdr_update
 CALLED BY:
	smei_mkbase
 PROCEDURE:
	TimeSet(['2006_004','2007_003']
	Note that the frame names and dark currents are pulled out
	of the header database. This means that, after a period
	has been "based" using smei_base, the corresponding
	header files need to be updated first with
	smei_hdr_update before this procedure is run to
	calculate the smoothed dark currents (which are than
	inserted into the frames).
 MODIFICATION HISTORY:
	AUG-2008, Paul Hick (UCSD/CASS)
	OCT-2008, Paul Hick (UCSD/CASS)
	    Added call to smei_hdr_update to ensure that the
	    header files are up-to-date before calculating
	    smoothed dark currents
	JAN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added silent=silent to smei_hdr_update call


smei_frm_summary $SMEI/ucsd/camera/idl/obsolete/smei_frm_summary.pro
[Previous] [Next]
 NAME:
	smei_frm_summary
 PURPOSE:
	Plots time series for various basic parameters in SMEI data frames
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_frm_summary, frame, printer=printer, zbuffer=zbuffer,	$
	    destination=destination, _extra=_extra,			$
	    nfill_control=nfill_control, nbad_control=nbad_control,	$
	    hdr=hdr, silent=silent
 INPUTS:
	frame		array[1], or array[2]; type: time structure
			    begin and end time for time range to be plotted.
			    If only a start time is given then the end time is taken
			    to be the start time, plus one day.
 OPTIONAL INPUT PARAMETERS:
	source=source
	destination=destination
	camera=camera
 OUTPUTS:
	(to png file)
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_frm_hdr__define
 CALLS: ***
	AngleRange, BadValue, CheckDir, FILEPATH, InitVar, IsTime, IsType, MEAN, PlotCurve, STDDEV
	TimeGet, TimeLimits, TimeOp, TimeScale, TimeSet, TimeSystem, TimeUnit, TimeXAxis, WhatIs
	destroyvar, get_page, jpl_body, jpl_phase, set_page, smei_frm_track, smei_frm_where
	smei_getfile, smei_property, sphere_distance
 COMMON BLOCKS:
 PROCEDURE:
 TO DO:
	- Dark current subtraction does not take slope from row to row into account
	  (especially important for camera three)
	- Definition of SAA needs improvement
 MODIFICATION HISTORY:
	APR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_track $SMEI/ucsd/camera/idl/obsolete/smei_frm_track.pro
[Previous] [Next]
 NAME:
	smei_frm_track
 PURPOSE:
	Calculates frame baseline (pedestal, dark current,
	average intensity in squares and center group) using
	information from previously processed frames.
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	FUNCTION smei_frm_track, frm, count , $
	    nfill_control   = nfill_control , $
	    nbad_control    = nbad_control  , $
	    ff	    = ff    , $
	    hdr     = hdr   , $
	    img     = img   , $
	    reset   = reset , $
	    status  = status, $
	    silent  = silent
 INPUTS:
	frm	    scalar; type: integer
			frame number to be processed
	count	    scalar; type: integer
			total # frames to be processed
			(used to dimension a several arrays maintained internally
			in common block, and used to clear the common block whe
			frm becomes equal to count (i.e. when all frames have been
			processed).
 OPTIONAL INPUT PARAMETERS:
	/silent     suppress run-time information
			(passed to smei_frm_base)
	/reset	    re-initialize the current camera/mode combination
	nfill_control=nfill_control
		    scalar; type: integer; default: (set in smei_frm_base)
			# good frames used to build reference base values
			(passed to smei_frm_base)
	ff=ff
	hdr=hdr
	img=img
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
	hdr = hdr
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_frm_hdr__define
 CALLS: ***
	ArrayLocation, InitVar, IsType, TimeGet, TimeUnit, destroyvar, smei_frm_base
	smei_frm_read, smei_property
 CALLED BY:
	smei_frm_summary
 COMMON BLOCKS:
	common smei_frm_track_save, ncount, cam_fulls, cam_start, cam_nail, frm_ok, cameras, modes, step
 PROCEDURE:
 MODIFICATION HISTORY:
	MAY-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_frm_update $SMEI/ucsd/camera/idl/frm/smei_frm_update.pro
[Previous] [Next]
 NAME:
	smei_frm_update
 PURPOSE:
	Update headers of SMEI Fits frames
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_frm_update, cframe,	$
	    shutter_open=shutter_open,	$
	    bad_quat=bad_quat,		$
	    new_quat=new_quat,		$
	    just_bad=just_bad,		$
	    on=on,			$
	    off=off
 INPUTS:
	cframe	    scalar; type: string
		    fully-qualified name of SMEI frame
 OPTIONAL INPUT PARAMETERS:
	/shutter_open	if set the value of the 'shutter-open' flag is changed
	/just_bad	if set the value of the 'just_bad' flag is changed
	/on		by default the flag setting is reversed.
			/on explicitly sets the flag to 'on'
	/off		/off explicitly sets the flag to 'off'
	new_quat=new_quat
			array[4]; type: double
			new quaternion to be put in frame header.
			(if new_quat is set, then the bad_quat flag is
			explicitly set to zero).
 OUTPUTS:
	Changes are written directly into the disk file
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FXHMODIFY, GetFileSpec, InitVar, IsType, SetFileSpec, smei_frm_flag, smei_getfile
 CALLED BY:
	qnew_2007_013
 PROCEDURE:
	Only one header entry can be changed in one frame at a time.
 MODIFICATION HISTORY:
	MAR-2004, Paul Hick (UCSD/CASS)
	JUL-2006, Paul Hick (UCSD/CASS)
	    Added /on and /off keywords
	    Added /bad_quat keyword
	OCT-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added new_quat keyword


smei_frm_where $SMEI/ucsd/camera/idl/frm/smei_frm_where.pro
[Previous] [Next]
 NAME:
	smei_frm_where
 PURPOSE:
	Calculate location of Coriolis and pointing of cameras
	for specified time and spacecraft quaternion.
	Check whether specified location (RA,dec in J2000) is
	inside the field of view.
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	smei_frm_where, hdr
 INPUTS:
	hdr		    can be one of the following
			    array[n]; type: frame header structure
				array of headers for target frames
			    array[2]; type: time structure
				time range (passed to smei_getfile)
			    scalar or array; type: string
				list of file names of target frames. These can
				be fully-qualified. If it only consists of a filename
				(e.g. c2m2_2004_101_121212) then the SMEI data base
				is used.

			    if 'hdr' is not specified then the dialog_pickfile
			    dialogis used to select files. If two files are
			    selected, then the file names are passed to
			    smei_getfile to find all frames in between the
			    implied time range. If only one file or more than two
			    files are selected, then the indicated frames are
			    processed.
 OUTPUT PARAMETERS:
	hdr		    array[n]; type: frame header structure
				array of headers for target frames
				(if the input 'hdr' was a time range or a list of
				fully-qualified filenames)
 OPTIONAL INPUT PARAMETERS:
	/open_shutter	    selects frames with shutter open
	/closed_shutter     selects frames with shutter closed
				(this checks the 'shutter_open' flag in the frame
				header; by default the 'shutter_open' flag is NOT checked)
	mode=mode	    selects data for specified mode (0,1 or 2) only.

	/degrees	    if set all angles are in degrees (default: radians)

	/spacecraft	    if set then sky locations of all bodies in the planetary
			    JPL ephemeris and asteroid USNO ephemeris are calculated
			    from a spacecraft-centric perspective (by default the locations
			    are geocentric). The difference is probably only significant
			    for the Moon (e.g. it matters for eclipse calculations).

			    The location of the spacecraft is approximate only. It assumes
			    that the spacecraft is at geocentric distance of 6367+850 km.
			    The location in geocentric RA and dec is derived from the
			    spacecraft quaternion assuming the spacecraft is in its default
			    attitude with the s/c axis along the nadir-zenith direction (i.e.
			    if breaks down during attitude changes.
	source=source	    scalar; type: string
				passed to smei_getfile
	camera=camera	    scalar; type: integer
				passed to smei_getfile

	show=show	    scalar; type: integer: default: 0
			     1: print info for frames and all bodies for all frames
			     2: print info for frames and all bodies, but only for
				frames that contain one or more bodies.
			     3: print SMEI frame info only for all frames

			    -1:
	outfile=outfile     scalar; type: string
				fully-qualified name of output file
				Captures same output of 'show' to the specified file
				If outfile is specified and 'show' is not set then
				show=1 is assumed.

	points_radec	    array[2,n]; type: float
				J2000 RA and dec of locations in the sky.
				The units are degrees or radians depending on the
				setting of keyword /degrees.
	points_name	    array[n]; type: string
				list of ascii names for all sky locations
				in 'points_radec'. If not specified, then '1','2',
				etc. is used.

	Instead of specifying points_radec sky locations can be identified by
	the following keywords. /jpls depends on the JPL planetary ephemeris.
	/stars depends on the bright star list compiled by Susan Rappoport and
	Andy Buffington, /usnos depends on the USNO ephemeris,and
	/mpcs depends on ephemerides from the Minor Planet Center homepage.

	Locations in the sky are specified as J2000 RA and dec.
	/jpls		    checks for planets, Sun and Moon (using JPL ephemeris)
				Optional if jpl_list is specified.
	/stars		    checks for stars on SMEI star list (currently cut off at
				SMEI magnitude 'm_max' (default: 4.5,
				which leaves about 1000 stars).
				Optional if star_list is specified.
	/usnos		    checks for asteroids on the USNO ephemeris
				Optional if usno_list is specified.
	jpl_list=jpl_list   array; type: integer; default: sun,planets and moon
				list of planets to check.
				Usually set up by a call to jpl_body
	star_list=star_list array; type: structure
				list of stars to check. Usually set up by call to
				smei_star_info(/get_struct)
	usno_list=usno_list array; type: integer or string; default: all asteroids
				list of asteroids to be checked. Usually set up by
				call to usno_body
	mpc_list=mpc_list   array; type: integer or string; default: all MPC bodies
				list of MPC bodies to be checked. Usually set up by
				call to mpc_body

	/all		    by default only information about points strictly inside
				the fov is given (and output in the OPTIONAL OUTPUT
				PARAMETERS). Setting /all will return
				information about all points.

	m_max=m_max	    scalar or array[2]; type: float
				if scalar then only stars from the SMEI catalogue
				brighter then this cut-off SMEI magnitude are used.
 OPTIONAL OUTPUT PARAMETERS:
	sc_loc = sc_loc     array[3,n]; type: double
				best guess at Coriolis location in geographic
				coordinates (derived from quaternion, assuming that
				the spacecraft is in its default attitude with
				z-axis pointing to nadir and x-axis along the
				velocity vector).
				    array[0,*]: geographic longitude
				    array[1,*]: geographic latitude
				    array[2,*]: don't know exactly, but it's
					positive when Coriolis is heading north;
					negative when heading south.
	pointing = pointing array[3,n]; type: double
				camera pointing in equatorial coordinates
				    array[0,*]: right ascension of optical axis
				    array[1,*]: declination of optical
				    array[2,*]: camera tilt relative to equat north

	nobject=nobject     scalar; type: integer
				# sky objects
				if nobject=0 then none of the output arguments
				below will exist.

	name  = name	    array[nobject]; type: string
				names of bodies for which information is given

	inside = inside     array[nobject,n]; type: byte
				0 if inside fov; 1 if outside fov

	loc    = loc	    array[3,nobject,n]; type: float
				    equatorial coordinates of all bodies in 'name'
				    array[0,*,*]: right ascension
				    array[1,*,*]: declination
				    array[2,*,*]: distance (for stars and RA-dec
					pairs this will be 1)
	runit = runit	    array[3,nobject,n]; type: double
				locations in the sky of planets, asteroids or stars,
				as unit vectors in the UCSD camera frame
	ccd = ccd	    array[2,nobject,n]; type: double
				CCD locations of points in the sky. These are the
				values after applying Andys' formulae.
				    array[0,*,*]: x coordinate
				    array[1,*,*]: y coordinate
	mags = mags	    array[nobject,n]; type: float
				    apparent SMEI magnitude. This is only available
				    for the stars in the SMEI star catalogue.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, AngleUnits, CV_COORD, CombineRotations, CvRotation, CvSky, InitVar, IsTime
	IsType, REVERSE, SuperArray, TimeGet, ToDegrees, ToRadians, WhatIs, boost, cvsmei
	destroyvar, jpl_body, jpl_eph, mpc_body, mpc_eph, sgp4_eph, smei_cam2angle
	smei_cam_quaternion, smei_getfile, smei_hdr_get, smei_property, smei_star_info
	usno_body, usno_close, usno_eph
 CALLED BY:
	grayburst, maygeometry, qImage_cw_DrawEphem, qImage_cw_Where, smei_frm_eclipse
	smei_frm_findpoint, smei_frm_summary, smei_hdr_plot, stardistance
 EXAMPLE:

	EXAMPLE 1:

	Check where Mars is inside FOV between 2:00 and 2:30 on 2003 doy 67.
	The frames are read from the default location for the SMEI data.

	hdr = timeset(yr=2003, doy=67, hr=2, min=[0,30])
	smei_frm_where, hdr, show=1, jpl_list=jpl_body(/mars)

	hdr is now filled with the headers for all frames in the specified
	time range. Subsequent calls with this header will bypass reading of frames.

	EXAMPLE 2:

	Given an array with frame names (e.g. read from a file), create a file
	with information about the position of the Sun.
	If 'file' contains records of the form c2m2_2003_101_121212 with frames
	for camera 2 only:

	status = txt_read(file, frames)
	smei_frm_where, frames, jpl_list=jpl_body(/sun), /all, $
	    /longformat, outfile='sun.txt'

	The file sun.txt is created in the working directory.
 PROCEDURE:
	For single frames retrieve the header first with smei_frm_read, and
	use it as input. This circumvents the potentially very slow
	call to smei_getfile.
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS)
	OCT-2004, Paul Hick (UCSD/CASS)
	    Added rtheta keyword.
	OCT-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Replaced approximate calculation of spacecraft location based
	    on quaternion to more accurate location based on orbital elements.
	    Replaced stheta and rtheta by runit keyword. The function
	    smei_cam2angle can be used to convert the unit vectors to angles.


smei_frm_write $SMEI/ucsd/camera/idl/frm/smei_frm_write.pro
[Previous] [Next]
 NAME:
	smei_frm_write
 PURPOSE:
	Write SMEI data into nic file
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	status = smei_frn_write(hdri, data, filename, count=count)
 INPUTS:
	hdri		array[1]; type: frame header structure
			    frame header for frame to be written to file
	data		array[n,m]; type: unsigned integer (??)
			    data to be written
	filename	scalar; type: string
			    fully-qualified name for output file
 OPTIONAL INPUT PARAMETERS:
	count		array[3]; type: integer
			    file counters; one or more of the counters are incremented by one
			    count[0]: # frames written to disk as .nic or .fits file
			    count[1]: # frames skipped because file already exists
			    count[2]: # frames with times earlier than the most recent frame
				that are written to disk (these should be frames from the second dump;
				if the second dump contains the same frames as the first the number
				of these frames should be small)
 OUTPUTS:
	count		array[3]; type: integer
			    updated file counters (only count[0] is updated)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, GetFileSpec, IsType, WRITEFITS, hide_env, smei_frm_cvhdr
 CALLED BY:
	smei_buf_get, smei_buf_mget
 RESTRICTIONS:
	If /split_dir is set then a 'mkdir --parents' is spawned to to create subdirectories,
	and gzip is spawned to compress files. This will probably work under Linux, but not
	in Windows without some modifications.
 PROCEDURE:
	This thing still needs an I/O error handler
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS)
	MAY-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added explicit check for existence of directory
	    and create it if not.


smei_fts_read $SMEI/ucsd/gen/idl/util/smei_fts_read.pro
[Previous] [Next]
 NAME:
	smei_fts_read
 PURPOSE:
	Read Fits file
 CALLING SEQUENCE:
	status = smei_fts_read(File, Array, errormessage=errormessage)
 INPUTS:
	File	    string	file name
 OPTIONAL INPUT PARAMETERS:
	header=header
		    if set then only the Fits header is read and returned
			in 'Hdr'. The data array is set to -1.
 OUTPUTS:
	status	    0: some error occurred (check 'errormessage')
		    1: file properly read
	Array	    array[n,m]
		    2D array of requested type
		    if something goes wrong or /header was set then
		    Array = -1 is returned
	Hdr	    Fits header array
 OPTIONAL OUTPUT PARAMETERS:
	errormessage
		    scalar; type: string
			Contains null string if file was read succesfully
			Contains error message if an error occurred
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	HEADFITS, InitVar, IsType, READFITS, do_file, gunzip_file
 PROCEDURE:
	Wrapper for the readfits.pro procedure in SSW.
	The SSW version decompresses Fits file in place, which won't work
	if the gzipped version is stored on a read-only file system.
	This wrapper unzips the file into a temporary file using
	gunzip_file and takes care of cleaning up the temporary file.
 MODIFICATION HISTORY:
	JUL-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_getfile $SMEI/ucsd/camera/idl/toolbox/smei_getfile.pro
[Previous] [Next]
 NAME:
	smei_getfile
 PURPOSE:
	Get list of file names for all files (CCD frames or skymaps)
	in specified time range
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION smei_getfile, wanted_file, $

	    nodialog= nodialog	, $
	    usetime = usetime	, $
	    exists  = exists	, $
	    exact   = exact	, $

	    camera  = camera	, $
	    mode    = mode	, $
	    count   = count	, $

	    tt	    = tt	, $
	    source  = source	, $
	    nodig   = nodig	, $

	    science_mode     = science_mode	, $
	    engineering_mode = engineering_mode , $
	    smoothdark	     = smoothdark	, $
	    prefer_smoothdark= prefer_smoothdark, $
	    chronological    = chronological	, $

	    get_hdr = get_hdr	, $
	    hdr     = hdr	, $
	    get_map = get_map	, $
	    map     = map	, $

	    silent  = silent	, $

	    ramdisk = ramdisk	, $
	    ls_corrupt=ls_corrupt,$
	    rm_corrupt=rm_corrupt
 INPUTS:
	wanted_file	array[1], or array[2]; type: time structure
			    begin and end time for requested time range
			    If only a start time is given then the end time is
			    taken to be the start time, plus one day.
			    If "wanted_file" is not defined than the IDL pickfile
			    dialog is called
 OPTIONAL INPUT PARAMETERS:
	/exists 	should only be used if "wanted_file" contains names
			    of files known to exist (the procedure skips
			    straight to the read section).
	/usetime	should only be used with "wanted_file" containing
			    sensible SMEI file names. The times, mode and
			    camera fields are extracted, and used as if
			    input through "wanted_file" (time), "camera" and
			    "mode" (override by explicitly setting mode and
			    camera, if necessary)
	/nodialog	for string input of file names (possible a scalar
			    containing a wildcard) the dialog_pickfile is
			    used to select file. If /nodialog is set then
			    file_search is used instead).
	source=source	scalar; type: string; default: SMEIDB?
			    root directory of smei data
	camera=camera	scalar, or array[n]; type: integer
			    camera number (1,2 or 3); if set only filees for the
			    specified camera(s) are extracted.
	mode=mode	scalar, or array[n]; type: integer or string; default: [0,1,2]
			    if set then only retrieve files for specified mode(s).
	/get_hdr	return file headers
	/get_map	return a pointer to the maps (CCD frames or skymaps)

	/science_mode	(for skymaps only)
			    selects science mode orbits only
	/engineering_mode   selects engineering mode orbits only
	/smoothdark	    selects orbits with smoothed dark current
				(only can pick up camera 3 science_mode orbits)
	/prefer_smoothdark  removes orbits with dark current NOT smoothed if
				the matching orbit with dark current smoothed
				is also present
 OUTPUTS:
	Result		array[count]; type: string or smei_frm_hdr structure
			    fully-qualified file names for all files
			    if no files are found (count=0) then ff is the null string

			    if /get_hdr is set then the headers are returned instead.
			    if /get_map is set then the file data are returned instead
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			    # files located
	tt=tt		array[count]; type: time structure
			    file times (i.e. the return value of
			    timeposn(Result,/extract))
	hdr=hdr 	array[count]; smei_frm_hdr structure
			    file headers
	map=map 	array[count]; heap pointer
			    file data
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, FindAllFiles, GetFileSpec, InitVar, IsTime, IsType, TimeGet
	TimeLimits, TimeOp, TimeSet, TimeSystem, TimeUnit, boost, destroyvar, flt_string
	hide_env, os_separator, smei_coriolis, smei_filename, smei_filepath, smei_frm_read
	smei_orbit_get, smei_sky_read, timeposn, unique_only, where_common
 EXTERNAL:
	smei_frm_hdr__define
 CALLED BY:
	maygeometry, psfn, qImage_cw_Property, qsmei_hdr, skyd_version, smei_base_testcase
	smei_buf_getframe, smei_findpnt, smei_frm_cp, smei_frm_hbar, smei_frm_summary
	smei_frm_update, smei_frm_where, smei_hdr_make, smei_orbit_stats
	smei_shutterwrong, smei_sky, smei_sky_atlocation, smei_sky_read, smei_sky_track
	smei_star_fitone, smei_star_remove, smei_zld_remove [1]
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2003, Paul Hick (UCSD/CASS)
	OCT-2003, Paul Hick (UCSD/CASS)
	    Added /get_hdr and hdr=hdr keywords
	FEB-2004, Paul Hick (UCSD/CASS)
	    Added /get_map and map=map keywords
	MAY-2004, Paul Hick (UCSD/CASS)
	    Fairly substantial rewrite of a crappy routine.
	    Modified to reflect new directory structure of SMEI data base
	    (frames are now organized in a separate directory for each
	    doy of year, with subdirectories for each of the cameras)
	JUL-2004, Paul Hick (UCSD/CASS)
	    Added /ramdisk keyword. Bug fix on processing of mode keyword.
	SEP-2004, Paul Hick (UCSD/CASS)
	    Added code to select frames for a specific mode by checking the
	    file name first. If the mode is encoded in the file name this
	    speeds up the selection considerably.
	AUG-2006, Paul Hick (UCSD/CASS)
	    Removed some dead code that dates back to when the mode was not
	    yet encoded in the filename for SMEI CCD frames.
	    Generalized interpretation of mode keyword: if set to a string
	    than skymaps will be processed, instead of SMEI CCD frames.
	OCT-2007, Paul Hick (UCSD/CASS)
	    Changed loop variable from short to long integer.
	FEB-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Fairly substantial revision. The procedure now also locates
	    skymaps, hdr and png files efficiently.


smei_hdr_c3maskupload $SMEI/ucsd/camera/idl/hdr/smei_hdr_c3maskupload.pro
[Previous] [Next]
 NAME:
	smei_hdr_c3maskupload
 PURPOSE:
	Best effort at determining upload times for C3 "bad-pixel" masks
 CATEGORY:
	camera/idl/hdr
 CALLING SEQUENCE:
	FUNCTION smei_hdr_c3maskupload, trange, time=time, name=name, status=status
 INPUTS:
	trange	    array[2]; time structure or valid time string
		start and end time
 OUTPUTS:
	result	    scalar; type: integer
		number of uploads in specified time period
 OPTIONAL OUTPUT PARAMETERS:
	time	    array[result]; type: time structure
		upload times
	name	    array[result]; type: string
		name of "bad-pixel" mask
	status	    array[result]; type: byte
		0: upload failed
		1: upload succesfull
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType, TimeGet, TimeSet, TimeUnit, destroyvar
 CALLED BY:
	smei_hdr_plot
 PROCEDURE:
	Information mostly from SMEI logs, plus some additional
	information scattered around in the code, primarily
	the Fortran routine smei_frm_c3mask_active.f
 MODIFICATION HISTORY:
	JUN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_hdr_get $SMEI/ucsd/camera/idl/hdr/smei_hdr_get.pro
[Previous] [Next]
 NAME:
	smei_hdr_get
 PURPOSE:
	Reads Fits binary tables containing all SMEI frame headers
 CATEGORY:
	ucsd/camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_hdr_get, tt		, $
	    source	= source	, $
	    destination = destination	, $
	    camera	= camera	, $
	    mode	= mode		, $
	    get 	= get		, $
	    time	= time		, $
	    hdr 	= hdr		, $
	    one 	= one		, $
	    two 	= two		, $
	    three	= three 	, $
	    four	= four		, $
	    five	= five		, $
	    six 	= six		, $
	    seven	= seven 	, $
	    dbname	= dbname	, $
	    dbsource	= dbsource	, $
	    count	= count 	, $
	    silent	= silent	, $
	    exact	= exact
	    ;_extra	= _extra
 INPUTS:
	tt		array[2]; standard time structure
			    indicates time range for which SMEI frame are to
			    be processed. Can be a time structure, valid time string,
			    or SMEI orbit numbers.
 OPTIONAL INPUT PARAMETERS:
	source=source	scalar; type: string
			    either a single Fits file containing frame headers in binary
			    table form, or a directory where these files are located.
			    If a directory is specified then the Fits files MUST contain
			    frame headers organized in daily files
	destination=destination
			scalar; type: string
			    only used if /write or /overwrite are set
			    destination directory for Fits binary table file
	camera=camera	scalar; type: integer (1,2,3)
			    camera for which headers are to be extracted
			    If not specified, camera 1 is used.
	mode=mode	scalar; type: integer (0,1,2); default: none
			    only frames for specified mode are extracted
	get=get 	scalar or array; type: string
			    list of tag names of the {smei_frm_hdr} structure
			    to be extracted in the one,..,seven keywords
			    (to get a list of valid entry, type 'smei_hdr_get' at
			    the IDL prompt).
	dbsource=dbsource
			only used if output arg 'dbname' is requested
			passed to smei_filepath
			    scalar; type: string; default: SMEIDB?
			    location of SMEI data frames (usually SMEIDB? or SMEIDC?)
 OUTPUTS:
	time=time	array; type: standard time structure
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			number of frames found
	hdr=hdr 	complete header

	one=one 	Extracted keywords in the order specified in 'get'
	two=two
	three=three
	four=four
	five=five
	six=six
	seven=seven

	dbname		array; type: string
			    list of fully-qualified frame file name in SMEI database
			    specified in 'dbname'.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_frm_hdr
 CALLS: ***
	BadValue, CheckDir, FILEPATH, FXBCLOSE, FXBOPEN, FXBREAD, InitVar, IsTime, IsType, TimeGet
	TimeLimits, TimeOp, TimeSet, TimeUnit, boost, destroyvar, hide_env, smei_filename
	smei_filepath
 CALLED BY:
	qnew_2007_013, qsmei_hdr, smei_findcrazy, smei_frm_smoothdark, smei_frm_where
	smei_hdr_plot, smei_mkcal, smei_mkorb, smei_orbit_stats, smei_shutterwrong, tbad
	tplot
 SEE ALSO:
	smei_hdr_make
 PROCEDURE:
 MODIFICATION HISTORY:
	JUN-2005, Paul Hick (UCSD/CASS)
	FEB-2007, Paul Hick (UCSD/CASS)
	    Bug fix(?). Variable mode was used in two different roles
	    when dbname was set.
	SEP-2008, Paul Hick (UCSD/CASS)
	    Added check for presence of requested "get" keyword.
	    If not present, then an array of NaNs is returned.
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Modified processing of input time range to allow
	    specification of SMEI orbit numbers.


smei_hdr_make $SMEI/ucsd/camera/idl/hdr/smei_hdr_make.pro
[Previous] [Next]
 NAME:
	smei_hdr_make
 PURPOSE:
	Writes Fits binary tables containing all SMEI frame headers
 CATEGORY:
	ucsd/camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_hdr_make, tt,	$
	    overwrite	= overwrite	, $
	    source	= source	, $
	    destination = destination	, $
	    camera	= camera	, $
	    get 	= get		, $
	    count	= count 	, $
	    remote	= remote	, $
	    silent	= silent
	    ;_extra	= _extra
 INPUTS:
	tt		array[2]; standard time structure
			    indicates time range for which SMEI frame are to
			    be processed
 OPTIONAL INPUT PARAMETERS:
	/overwrite	if SET a binary Fits table is overwritten if it exists
			    By default existing files are NOT overwritten.
			    The file name will have the form c#hdr_YYYY_DOY_hhmmss.fts
			    where #=1,2,3 is the camera number.
			    Existing files are overwritten
	source		scalar; type: string
			    source of SMEI frame files (passed to smei_getfile)
			    (usually set to SMEIDB? or SMEIDC?)
	destination	scalar; type: string
			    destination directory for Fits binary table file
	remote=remote	scalar; type: string; default: none
			    if present, is combined with destination to build
			    the destination as <remote>:<destination>
			    (usually "remote" is set to the computer hosting
			    the header database when this routine is executed
			    on another computer)
	camera		scalar; type: integer (1,2,3)
			    only camera one frames are processed. By default all three
			    cameras are processed and headers are written into three
			    separate files, one for each camera.
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			    number of headers written into Fits binary table (all cameras
			    combined, if more than one camera was processed).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_frm_hdr
 CALLS: ***
	CheckDir, FILEPATH, FXADDPAR, FXBADDCOL, FXBCREATE, FXBFINISH, FXBHMAKE, FXBWRITM
	FXHMAKE, FXWRITE, GetFileSpec, InitVar, IsTime, IsType, TimeGet, TimeOp, TimeSet, TimeUnit
	hide_env, smei_getfile, smei_property
 CALLED BY:
	smei_hdr_update
 SEE ALSO:
	smei_hdr_get
 PROCEDURE:
 MODIFICATION HISTORY:
	JUN-2005, Paul Hick (UCSD/CASS))
	JAN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword silent=silent to smei_getfile call


smei_hdr_plot $SMEI/ucsd/camera/idl/hdr/smei_hdr_plot.pro
[Previous] [Next]
 NAME:
	smei_hdr_plot
 PURPOSE:
	Plots time series for various basic parameters in SMEI data frames
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_hdr_plot, tt		, $
	    destination = destination	, $
	    camera	= camera	, $
	    silent	= silent	, $
	    printer	= printer	, $
	    remote	= remote	, $
	    _extra	= _extra
 INPUTS:
	tt		    array[2]; type: time structure
				time range to be updated
 OPTIONAL INPUT PARAMETERS:
	destination=destination
	remote=remote	    scalar; type: string; default: none
				if present, is combined with destination to build
				the destination as <remote>:<destination>
				(usually "remote" is set to the computer hosting
				the header database when this routine is executed
				on another computer)
	camera=camera
 OUTPUTS:
	(to png file)
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_frm_hdr__define
 CALLS: ***
	AngleRange, BadValue, CheckDir, FILEPATH, FXPAR, HEADFITS, InitVar, IsType, MEAN
	PlotCurve, PlotCurves, SFLOAT, STDDEV, TimeGet, TimeLimits, TimeOp, TimeScale, TimeSet
	TimeSystem, TimeUnit, TimeXAxis, UNIQ, boost, destroyvar, do_file, get_page, gridgen
	hide_env, init_contiguous_group, jpl_body, jpl_phase, next_contiguous_group
	set_page, smei_filename, smei_filepath, smei_frm_where, smei_hdr_c3maskupload
	smei_hdr_get, smei_orbit_get, smei_orbit_set, smei_property, sphere_distance
 CALLED BY:
	smei_hdr_update
 PROCEDURE:
	- Definition of SAA needs improvement
 MODIFICATION HISTORY:
	SEP-2005, Paul Hick (UCSD/CASS)
	OCT-2007, Paul Hick (UCSD/CASS)
	    Added PlotCurve calls to shade periods with
	    bad quaternions.
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added markers for mask uploads (cam 3 only) and anneals.


smei_hdr_update $SMEI/ucsd/camera/idl/hdr/smei_hdr_update.pro
[Previous] [Next]
 NAME:
	smei_hdr_update
 PURPOSE:
	Update Fits binary tables containing SMEI frm headers or time series plots based
	on Fits binary tables.
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_hdr_update, tt 	, $
	    source	= source	, $
	    pscmd	= pscmd 	, $
	    destination = destination	, $
	    camera	= camera	, $
	    silent	= silent	, $
	    all 	= all		, $
	    drive	= drive 	, $
	    update	= update	, $
	    plotx	= plotx 	, $
	    force	= force 	, $
	    remote	= remote
 INPUTS:
	tt		    array[2]; type: time structure
				time range to be updated
 OPTIONAL INPUT PARAMETERS:
	all=all 	    if set the whole SMEI data base is updated (overrides 'tt')
	drive=drive	    scalar; type: integer
				if set the corresponding drive is processed (overrides 'tt' and /all)
	source=source	    scalar; type: string; default: SMEIDB?
				directory indicating source of SMEI data frames (parameter is
				passed to smei_filepath)
				(usually SMEIDB? or SMEIDC?)
	destination=destination
			    scalar; type: string; default: $SSWDB_SMEI/cat/hdr
				directory where Fits binary tables are stored
	remote=remote	    scalar; type: string;
				defaults: none if $HOST != smei.ucsd.edu
					  'soft@smei' if $HOST == smei.ucsd.edu
				if present, is combined with destination to build
				the destination as <remote>:<destination>
				(usually "remote" is set to the computer hosting
				the header database when this routine is executed
				on another computer; passed to smei_hdr_make and
				smei_hdr_plot)
	camera=camera	    scalar or array[n]; type: integer; default: [1,2,3]
				cameras to be updated
	plotx=plotx	    0: update hdr data base of Fits binary tables
			    1: update time series plots based on the Fits binary tables
				(the "png" files)
			    2: do both
	/force		    will unconditionally update Fits tables or png files
	silent=silent	    suppresses informational messages if set to > 0
 OUTPUTS:
	Updated Fits binary tables.
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXPAR, FindAllFiles, HEADFITS, InitVar, IsType, TimeGet, TimeLimits, TimeOp
	TimeSet, TimeSystem, TimeUnit, hide_env, is_running, smei_filepath, smei_frm_drive
	smei_hdr_make, smei_hdr_plot, timeposn
 CALLED BY:
	smei_frm_smoothdark, smei_mkbase, smei_mkcal, smei_mkorb_auto, tplot
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2005, Paul Hick (UCSD/CASS)
	OCT-2006, Paul Hick (UCSD/CASS)
	    Added pscmd keyword
	FEB-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Default destinations are now set through calls to
	    smei_filepath instead of hardcoding them here.
	JAN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    For cam 3, added check of timestamp of orb files
	    to decide whether an update is required for a png file.
	    If $HOST != smei.ucsd.edu then keyword remote is now
	    initialized to 'soft@smei', if not specified explicitly.


smei_i2m $SMEI/ucsd/camera/idl/star/smei_i2m.pro
[Previous] [Next]
 NAME:
	smei_i2m
 CALLING SEQUENCE:
	FUNCTION smei_i2m, from_ms=from_ms, from_bb=from_bb
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType
 CALLED BY:
	PRO bold, smei_findobj, smei_star_fit, smei_star_show


smei_last_tle $SMEI/ucsd/camera/idl/toolbox/smei_last_tle.pro
[Previous] [Next]
 NAME:
	smei_last_tle
 PURPOSE:
	Retrieves time of most recent Coriolis tle
 CALLING SEQUENCE:
	FUNCTION smei_last_tle
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, SFLOAT, TimeFixYear, TimeSet, hide_env, txt_read
 CALLED BY:
	smei_mkbase, smei_mkcal_auto, smei_mkorb_auto, smei_mksky
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_mkbase $SMEI/ucsd/camera/idl/toolbox/smei_mkbase.pro
[Previous] [Next]
 NAME:
	smei_mkbase
 PURPOSE:
	Used to run smeidb_base and smei_hdr-update
	for whole days of frames in $SSWDB_SMEI
 CALLING SEQUENCE:
	PRO smei_mkbase, $
	    camera	= camera      , $
	    lastdays	= lastdays    , $
	    days_to_cal = days_to_cal , $
	    ignore_block= ignore_block, $
	    force	= force       , $
	    test	= test
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, FindAllFiles, InitVar, IsType, TimeGet, TimeOp, TimeSet, TimeUnit, boost
	destroyvar, hide_env, smei_blocked, smei_filename, smei_filepath
	smei_frm_smoothdark, smei_hdr_update, smei_last_tle, smei_orbit_stats, txt_read
 RESTRICTIONS:
	Status files are written to $SSWDB_SMEI on the smei server
	over ssh. If this procedure is run as part of a cronjob
	then login without password to the smei server should
	be possible
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	JUN-2010, John Clover (UCSD/CASS)
	    Increasing default threshold for camera 2
	    ped_median_excess from 6 to 8.
       SEP-2010, John Clover (UCSD/CASS)
	       Changed defaults for camera 1 and camera 2
	       ped_median_excess	   8		8
	       dark_cut 		  14	       14
	       dark_max_ratio		1.05	     1.05
	       These likely still need tweaking


smei_mkc3mask $SMEI/ucsd/camera/idl/toolbox/smei_mkc3mask.pro
[Previous] [Next]
 NAME:
	smei_mkc3mask
 PURPOSE:
	Converts J. Tappins mask file into format needed by smei_cal
 CATEGORY:
 CALLING SEQUENCE:
	PRO smei_mkc3mask, last_only=last_only
 OPTIONAL INPUTS:
	/last_only	processes only the most recent mask
		    (useful when adding a mask)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, WhatIs, flt_read, flt_string, smei_filepath
 PROCEDURE:
	The first line in James' files contain the array dimensions
	(1272 by 256). This line should be commented with a semi-colon first.

	The files have rows of 19 numbers (values 0 and 1 only)
	Each row of 1272 mask values is stored in 67 rows with the last
	row missing one number: 66*19+18=1272

	Files are written in format (1272I1)
 MODIFICATION HISTORY:
	FEB-2007, Paul Hick (UCSD/CASS)
	SEP-2007, Paul Hick (UCSD/CASS)
	    Added mask 2007_237.
	MAR-2007, Paul Hick (UCSD/CASS)
	    Added mask 2008_023.
	OCT-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added mask 2008_226. Added /last_only keyword
	OCT-2009, John Clover (UCSD/CASS; jclover@ucsd.edu)
	    Added mask 2009_260
	XXX-2010, John Clover
	    Added mask 2010_098
	OCT-2010, John Clover
	    Added mask 2010_259


smei_mkcal $SMEI/ucsd/camera/idl/toolbox/smei_mkcal.pro
[Previous] [Next]
 NAME:
	smei_mkcal
 PURPOSE:
	Create "closed shutter" calibration pattern
 CALLING SEQUENCE:
	PRO smei_mkcal, tt, $
	    camera  = camera	, $
	    generate= generate	, $
	    name    = name	, $
	    template= template	, $
	    force   = force
 INPUTS:
	tt	    array[1]; time structure; default: TimeSystem()
			day on which to look for mode 0 frames
			(fraction of day is ignored)
 OPTIONAL INPUTS:
	camera=camera
		    scalar or array; type: integer; default: [1,2,3]
			cameras to be processed
	template=template
		    scalar; type: integer
			fully-qualified file name of an existing
			calibration ASCII template. This keywords overrides
			input 'tt' and 'camera'
	/generate   by default only the ASCII file describing the
			pattern (input for smei_cal) is made.
			If /generate is set then the calibration pattern
			itself is made.
	/force	    if set, then existing patterns are overwritten
 OPTIONAL OUTPUTS:
	name=name   scalar or array; type: string
			fully-qualified names of created patterns
			(null-string if no pattern is created)
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, FXPAR, GetFileSpec, InitVar, IsTime, IsType, READFITS, TimeGet, TimeLimits
	TimeSet, TimeSystem, TimeUnit, boost, destroyvar, hide_env, smei_filename
	smei_filepath, smei_hdr_get, smei_hdr_update, txt_read
 CALLED BY:
	smei_mkcal_auto
 RESTRICTIONS:
	Should only be run on smei.ucsd.edu or smeidb.smei.ucsd.edu
 PROCEDURE:
	Creates the ASCII calibration template (unless this is specified
	as input). This is stored in $SMEIDB/cal/txt.
	In addition to the pattern itself, a sequence of png files is generated
	for the pattern itself and the individual frames on which the
	pattern is based. These are stored in subdirectories of $SMEIDB/cal.
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS)
	DEC-2009, Paul Hick (UCSD/CASS)
	    Allow execution on smeidb. When running on smeidb
	    all output files are created locally, and then are scp'd
	    to $SMEIDB on smei, to avoid problems in case
	    smei exports $SMEIDB in read-only mode.
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword 'template' to allow  input of an existing
	    ASCII calibration templates. This allows (re-)creation
	    of cal pattern file and associated images.


smei_mkcal_auto $SMEI/ucsd/camera/idl/toolbox/smei_mkcal_auto.pro
[Previous] [Next]
 NAME:
	smei_mkcal_auto
 PURPOSE:
 CALLING SEQUENCE:
	PRO smei_mkcal_auto, $
	    camera  = camera	, $
	    lastpat = lastpat	, $
	    ignore_block=ignore_block, $
	    force   = force
 OPTIONAL INPUTS:
	camera = camera     scalar or array; type: integer; default [1,2,3]
			camera number(s): 1, 2 and/or 3
	lastpat = lastpat   scalar; type: integer; default: 0
			indicates the number of status files to be
			checked starting from the most recent one.
			Special values:
			lastpat = -1: check all status files
			lastpat =  0: check all status files, starting
			    with the status file matching the doy
			    for the most recent cal pattern available
			    (used in SMEI data pipeline)
	/ignore_block	    passed to smei_blocked
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	CheckDir, FindAllFiles, InitVar, TimeGet, TimeUnit, hide_env, smei_blocked
	smei_filename, smei_filepath, smei_last_tle, smei_mkcal, txt_read
 RESTRICTIONS:
	Can only be run on smei.ucsd.edu and smeidb.smei.ucsd.edu
 PROCEDURE:
	Sets "cal = 1" field in status file if cal pattern is successfully generated.
	The "cal" field is always zero if the "mode 0" frame count is zero.

	If the "mode 0" count is non-zero then "cal=0" means that the calibration
	pattern for the set of mode 0 frames on this doy has not been created
	yet. "cal=1" means that the cal patterns already exists.

	This routine is usually run as a cronjob with keyword
	lastpat=0. This looks for the most recent status file with
	"cal=1" (pointing to the most recent existing cal pattern). It then
	processes status files from that doy onward looking for status files
	with a non-zero "mode 0" frame count and "cal=0". It the creates the
	calibration pattern, and updates the status file by setting "cal=1".
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS)
	DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Also allow execution from smeidb.
	    Added documentation.


smei_mkdrives $SMEI/ucsd/camera/idl/toolbox/smei_mkdrives.pro
[Previous] [Next]
 NAME:
	smei_mkdrives
 PURPOSE:
	Rewrites the file smei_drives.txt
 CATEGORY:
	camera/idl/frm
 CALLING SEQUENCE:
	PRO smei_mkdrives
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS: ***
	FILEPATH, FindAllSubDirs, TimeGet, TimeOp, TimeSet, TimeUnit, hide_env, who_am_i
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2007, G. Megally, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_mkglare $SMEI/ucsd/camera/idl/toolbox/smei_mkglare.pro
[Previous] [Next]
 NAME:
	smei_mkglare
 PURPOSE:
	Converts glare related grd files to Fits files
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_mkglare
 INPUTS:
	From $SSWDB_SMEI/glare
 OUTPUTS:
	To $SSWDB_SMEI
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXADDPAR, IsType, MKHDR, WRITEFITS, do_file, grd_read
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_mki2m $SMEI/user/pphick/idl/smei_mki2m.pro
[Previous] [Next]
 NAME:
	smei_mki2m
 CALLING SEQUENCE:
	PRO smei_mki2m, f
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	LINFIT, gridgen, smei_star_list, smei_star_readpnt


smei_mklsff $SMEI/user/pphick/idl/smei_mklsff.pro
[Previous] [Next]
 NAME:
	smei_mklsff
 CALLING SEQUENCE:
	pro smei_mklsff
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, WRITEFITS, grd_read


smei_mkmask $SMEI/ucsd/camera/idl/toolbox/smei_mkmask.pro
[Previous] [Next]
 NAME:
	smei_mkmask
 PURPOSE:
	Produces a daily "sky mask" indicating which parts of the sky were seen
	by SMEI on a given day (1=always seen; 0=never seen; between 0 and 1:
	seen in some but not all skymaps).
 CALLING SEQUENCE:
	PRO smei_mkmask, range, $
	    nbin	= nbin	    , $
	    to_smeidb	= to_smeidb , $
	    norbit	= norbit    , $
	    remote	= remote    , $
	    silent	= silent
 INPUTS:
	range		array[2]; type: time structure or valid time strings
			    default: ['2006_033','2008_318']
			    time range (start and end day)
 OPTIONAL INPUTS:
	/to_smeidb	if set then write Fits file to standard
			    directory $SMEIDB/msk
	norbit=norbit	scalar; type: integer; default: 15
			    number of consecutive orbits to be used for
			    the creation of a mask (the default 15 covers
			    about one day).
	nbin=nbin	scalar; type: integer; default: 5
			    Sets the resolution of the mask
			    Must be a factor of 1800.
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	CheckDir, FILEPATH, FXADDPAR, InitVar, IsType, MKHDR, TimeGet, TimeSet, TimeUnit
	WRITEFITS, gridgen, hide_env, smei_filepath, smei_orbit_get, smei_sky
 CALLED BY:
	smei_mksky
 PROCEDURE:
	The size of the mask array is [3600,1800]/nbin. For nbin=5 (default)
	this gives a 720x360 mask with a resolution of 0.5 degrees,
	covering [0,360] in RA and [-90,+90] in declination.

	The mask value for each skybin is a value between 0 and 1.
	1 means that the skybin has a value in each of the morbit orbits
	tested (where morbit <= norbit, is the number of skymaps found);
	0 means that the skybin did not contain anything in all skymaps.
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_mkorb $SMEI/ucsd/camera/idl/toolbox/smei_mkorb.pro
[Previous] [Next]
 NAME:
	smei_mkorb
 PURPOSE:
	Calculates approximations for parameters needed to
	create orbital "on-the-fly" patterns
 CATEGORY:
	ucsd/camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_mkorb, ut_frac , $
	    lastpat = lastpat	, $
	    firstorb= firstorb	, $
	    lastorb = lastorb	, $
	    generate= generate	, $
	    truncpat= truncpat	, $
	    filecmd = filecmd	, $
	    threshold=threshold , $
	    force   = force	, $
	    silent  = silent
 OPTIONAL INPUTS:
	lastpat=lastpat
	    scalar; type: integer; default: nr cal patterns, minus one.
		defines the pair of "closed-shutter" calibration patterns
		where to start calculating, i.e. the last "lastpat" pairs
		of calibration patterns are processed.

	    lastpat=0: look at orbits more recent than last cal pattern
		this is used in the real-time data pipeline
	    lastpat=1: look at orbits between last pair of cal patterns
	    lastpat>1: look further back for last 'lastpat' pairs of cal patterns

	firstorb=firstorb
	    scalar; type: integer
		overrides the internally determined start orbit
	lastorb=lastorb
	    scalar; type: integer
		overrides the internally determined stop orbit
	/generate   (only used if lastpat=1, and if run on
		SMEI server smei.ucsd.edu)
		if set then generate the "on-the-fly" orbital
		patterns.
	/filecmd    (only used if lastpat=1, and if run on
		SMEI server smei.ucsd.edu)
		append result to file $SMEIDB/cat/list/c3orb
	threshold=threshold
		scalar; type: integer; default: 800
		minimum on nr of frames required for "on-the-fly" pattern
		(if there are less frames no pattern is created)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, FindAllFiles, GetFileSpec, InitVar, IsTime, IsType, REVERSE, TimeGet
	TimeLInterpol, TimeLimits, TimeOp, TimeSet, TimeUnit, do_file, flt_read, hide_env
	smei_filepath, smei_hdr_get, smei_orbit_get, timeposn, txt_read
 CALLED BY:
	smei_mkorb_auto
 RESTRICTIONS:
	Needs access to
	$SMEIDB/cat/list/c3orb
	    file with previously used smeidb_orb calls
	    (the first 3-years of calls are used to get values for
	    min and max orbital fractions)
	$SMEIDB/cat/list/smei_frm_orb_m1.txt
	    contains frame counts per orbit
	and directory $SMEIDB/cal
	    contains the "closed-shutter" calibration patterns.
 PROCEDURE:
	For camera 3 a sequence of "on-the-fly" patterns needs to be defined
	between each pair of successive "closed-shutter" calibration patterns.
	Each sequence is created by a call to the Fortran program
	smei_orb. The main parameters needed for this program are
	minimum orbit, start orbit, stop orbit, minimum orbital fraction, and
	maximum orbital fraction.

	minimum orbit: usually the first full science mode orbit following
	    a "closed-shutter" calibration pattern.
	    NOTE that this probably will be wrong near anneals, when the
	    proper minimum patterns may be the one close to the trailing
	    calibration pattern.
	start orbit: first orbit for which an "on-the-fly" patterns is needed
	    Usually the same as the minimum orbit)
	stop orbit: last orbit for which an "on-the-fly" pattern is needed.
	    Usually the last science mode orbit preceding the next-following
	    calibration pattern.
	minimum orbital fraction (between 0 and 1)
	maximum orbital fraction (between 0 and 1)
	    restricts the range of CCD frames to be used in the construction
	    of "on-the-fly" patterns.

	For the first three years of SMEI these parameters were determined
	"by hand". This information is stored in the bash script $SMEIDB/cat/list/c3orb
	in the form of calls to smei_orb. More recent data in this script are based
	on the output of this program.

	Minimum, start and stop orbit are set using the frame counts stored
	in $SMEIDB/cat/list/smei_frm_orb_m1.txt. The main constraint is that the
	number of valid frames needs to be above a specified threshold.

	The minimum and maximum fraction are calculated by mapping back to
	the first three assuming that the fractions have a periodicity of 1 year.

 MODIFICATION HISTORY:
	APR-2007, Paul Hick (UCSD/CASS)
	JAN-2010, Paul Hick (UCSD/CASS)
	    Prevent last_orbit return value to be larger than
	    orbit number of following cal
	    Bugfix. Do not use redirection over ssh to send modified
	    c3orb script back to soft@smei.
	    Changed definition for min_orbit. It now is one orbit later
	    than first_orbit to avoid using a partial orbit as min_orbit.
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added check for multiple cal patterns in the same orbit.
	    Script will abort when this happens.
	    Bugfix: the c3orb script was not updated correctly.
	    Updates are now done to file $SMEIDB/cat/list/c3orb_pipeline
	    Improved algorithm to calculate start, stop and minimum orbit.
	    The old algorithm put the start and minimum orbit very often
	    one orbit too high.


smei_mkorb_auto $SMEI/ucsd/camera/idl/toolbox/smei_mkorb_auto.pro
[Previous] [Next]
 NAME:
	smei_mkorb_auto
 PURPOSE:
	Wrapper for smei_mkorb for creating "on-the-fly" orbital
	patterns. Used in real-time data pipeline only.
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_mkorb_auto, $
	    threshold	= threshold	, $
	    ignore_block= ignore_block	, $
	    force	= force
 OPTIONAL INPUT PARAMETERS:
	threshold   passed to smei_mkorb
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FindAllFiles, IsType, TimeGet, TimeOp, TimeSet, TimeUnit, boost, hide_env
	smei_blocked, smei_filename, smei_filepath, smei_hdr_update, smei_last_tle
	smei_mkorb, smei_orbit_get, txt_read
 RESTRICTIONS:
	Can only be run on the SMEI servers (smei.ucsd.edu or smeidb.smei.ucsd.edu)
 PROCEDURE:
 MODIFICATION HISTORY:
	DEC-2008, Paul Hick (UCSD/CASS)
	DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Allow for execution on smeidb


smei_mksidereal $SMEI/ucsd/camera/idl/toolbox/smei_mksidereal.pro
[Previous] [Next]
 NAME:
	smei_mksidereal
 PURPOSE:
	Combine three grid files
	    eq_allskymeed.grd.gz
	    np_allskymeed.grd.gz, and
	    sp_allskymeed.grd.gz
	into one compressed Fits file
	    $SSWDB_SMEI/sid/c0sid_2002_365_000000.fts.gz.
	The resulting FITS file represents sidereal background information
	useful for star removal algorithms.
 CALLING SEQUENCE:
	PRO smei_mksidereal, version
 INPUTS:
	None
 OPTIONAL INPUT PARAMETERS:
	None
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	CheckDir, FILEPATH, FXADDPAR, InitVar, IsType, MKHDR, TimeGet, TimeSet, TimeUnit
	WRITEFITS, grd_read, gzip_file, hide_env, smei_filepath
 RESTRICTIONS:
	The input grid file paths and output FITS file path are hardcoded
	into the program.
 PROCEDURE:
	The three grid files mentioned above are assumed to be valid grid
	files. Additional FITS header information is added to each map as
	they are written to the output FITS file.
	A special version number header keyword, BKGNDVER, is added to the
	main FITS header.
 MODIFICATION HISTORY:
	JUL-2006, Jordan Vaughan (UCSD)
	DEC-2007, Paul Hick (UCSD/CASS)
	    Introduced WCS-compliant keywords to describe coordinate system.
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added new skymap version (2.0; not quite final yet).
	OCT-2009, John Clover (UCSD/CASS)
	    Added new maps, all sky median for v4 background
	JUL-2010, John Clover (UCSD/CASS; jclover@ucsd.edu)
	    Added newer maps, fixes error caused by star removal
	    that manifested in the over all background maps


smei_mksky $SMEI/ucsd/camera/idl/toolbox/smei_mksky.pro
[Previous] [Next]
 NAME:
	smei_mksky
 PURPOSE:
	Create skymaps from most recent SMEI data
 CATEGORY:
	ucsd/camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_mksky, $
	    camera	= camera	, $
	    ignore_block= ignore_block	, $
	    force	= force 	, $
	    make_mask	= make_mask	, $
	    make_www	= make_www	, $
	    remote	= remote	, $
	    boss	= boss
 OPTIONAL INPUTS:
	camera	    scalar or array; type: integer; default: [1,2,3]
		camera numbers
	/ignore_block	if the SMEI pipeline is blocked (by putting a 1 in
		file $SSWDB_SMEI/cat/sts/block/block_pipeline.txt)
		this procedure will abort by default.
		Setting this keyword will ignore this block.
	/force	    if set then the "overwrite" flag is set for the "skyd"
		daemon (resulting in overwriting existing skymaps)
	/make_mask  if set then the "msk" daily skymasks are calculated
		and written to $SSWDB_SMEI/msk
	/make_www   creates html tables for available SMEI skymaps
		(see smei_www_skymaps)
	remote=remote	scalar; type: string: default: soft@smei
		if /make_mask is SET, and this procedure has no write
		access to $SSWDB_SMEI, then remote should be set to a
		username/host on a machine that does have write
		access. The "msk" files are copied using scp.
	boss	    scalar; type: string: default: smeidb.smei.ucsd.edu
		set hostname of 'boss'. previously only ran on sun
		this should let it run on any machine, use with
		caution
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, FindAllFiles, InitVar, IsType, STRSPLIT, TimeGet, TimeOp, TimeSet, TimeSystem
	TimeUnit, UNIQ, boost, hide_env, skyd_cat, smei_blocked, smei_filename, smei_filepath
	smei_last_tle, smei_mkmask, smei_orbit_get, smei_www_skymaps, txt_read
 RESTRICTIONS:
	-Can only be run on smei.smei.ucsd.edu on the "skyd" account.
	 unless boss is specified
	 Depends on the collection of "status" files in $SSWDB_SMEI/cat/sts.
	- Will not run if a skyd daemon is already running.
	- To update the sts files on the smei server over ssh login using
	  public/private key pair needs to be set up.
 PROCEDURE:
	Processes days for which the sts files has flag "summary" ON
	(i.e. pedestal/dark current have been calcalate and the header
	files have been updated); and (camera 3 only) the flag "orb" is
	ON (i.e. "on-the-fly" orbital patterns are available; the flag
	"sky" of OFF (i.e. no skymaps have been made yet.

	- skyd_cat is called to create the catalogues in $SKYD/list.
	- the cf file $SKYD/cf/skyd_sun.cf is modified
	- launches the skyd daemon
	- sets the flag "sky" in the appropriate sts files.
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_mkstarmask $SMEI/ucsd/camera/idl/star/smei_mkstarmask.pro
[Previous] [Next]
 NAME:
	smei_mkstarmask
 PURPOSE:
	Creates the star mask file used in the creation of
	skymaps by smei_skyd
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_mkstarmask, notest=notest
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXADDPAR, InitVar, MKHDR, WRITEFITS, grd_read
 PROCEDURE:
	Uses grd files in $SSWDB_SMEI as input, and creates
	starmask.fts.gz in the same directory.
	starmask.fts needs to be moved to $SMEIDB
	where the Fortran routine smei_get_starmask looks for it.
 MODIFICATION HISTORY:
	DEC-2008, Paul Hick (UCSD/CASS)
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Bugfix: maps were stored in wrong coordinate system. The new
	    version converst from Andy's convention used in the grd file
	    to the SMEI skymap convention (the same is done for the
	    sidereal background maps in smei_mksidereal.pro)
	    Bugfix: resolution (bins/degrees) was specified wrong in Fits header.
	    Made Fits header WCS compliant.
	    Added Fits header keyword for star mask version number (now 2.0)


smei_mkstdstar $SMEI/ucsd/camera/idl/star/smei_mkstdstar.pro
[Previous] [Next]
 NAME:
	smei_mkstdstar
 PURPOSE:
	Convert grd files for standard stars to Fits files
	used by smei_skyd
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_mkstdstar
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXADDPAR, IsType, MKHDR, WRITEFITS, grd_read, gzip_file, who_am_i
 MODIFICATION HISTORY:
	JUN-2006, Paul Hick (UCSD/CASS)
	SEP-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    In addition to old PSF there now is an alternative PSF
	    (presumably with the background removed more accurately)
	    The old standard_star.fts is now standard_star_fixd.fts;
	    the new PSF is in standard_star_fill.fts.


smei_mkzldresidue $SMEI/ucsd/camera/idl/zld/smei_mkzldresidue.pro
[Previous] [Next]
 NAME:
	smei_mkzldresidue
 PURPOSE:
	Stores Andy's zld correction map (1 static and 52 weekly
	corrections) in a single Fits file
 CATEGORY:
	camera/idl/zld
 CALLING SEQUENCE:
	PRO smei_mkzldresidue
 INPUTS:
	(none)
 OUTPUTS:
	c3zldresidue.fts.gz
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXADDPAR, GetFileSpec, IsType, MKHDR, REVERSE, WRITEFITS, grd_read, hide_env
 PROCEDURE:
	The Fits headers should be WCS-compliant.
	The coordinate system used is helioecliptic J2000.
	Each of Andys maps is 360 x 360 with 0.5 degree resolution.
	covering [-90,+90] in helioecliptic longitude. This is expanded
	with zeroes to [-180,+180] making a standard helioecliptic
	low-res map.
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_normal $SMEI/user/pphick/idl/smei_normal.pro
[Previous] [Next]
 NAME:
	smei_normal
 CALLING SEQUENCE:
	PRO smei_normal, _extra=_extra
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	AngleRange, AngleUnits, PlotCurve, TimeGet, TimeOp, TimeSet, TimeUnit, WhatIs, gridgen
	ra_fictitious_sun, sgp4_orbit_axis


smei_orbit_get $SMEI/ucsd/camera/idl/toolbox/smei_orbit_get.pro
[Previous] [Next]
 NAME:
	smei_orbit_get
 PURPOSE:
	Extracts fields from orbit structure
 CATEGORY:
	camera/gen/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION smei_orbit_get, orb, $
	    number	= number    , $
	    fraction	= fraction  , $
	    doublex	= doublex   , $
	    roundx	= roundx    , $
	    ceilx	= ceilx     , $
	    floorx	= floorx
 INPUTS:
	orb	    array; type: orbit structure
			orbit structure as created by smei_orbit_set
 OPTIONAL INPUTS:
	/number     extract integer orbit number
	/fraction   extract double precison fraction
	/doublex    extract orbit as double precision number, i.e. the
		    sum of number and fraction part. Note that this number
		    looses precision pretty quick for high orbit numbers.
	/roundx     extract orbit rounded to nearest integer orbit number
 OUTPUTS:
	rtn	    scalar or array
			integer orbit number of double precision
			fraction depending on setting of /number
			or /fraction
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar
 CALLED BY:
	getsmeisources, smei_coriolis, smei_getfile, smei_hdr_plot, smei_mkmask
	smei_mkorb, smei_mkorb_auto, smei_mksky, smei_orbit_stats, smei_sky_track
	smei_star_show
 PROCEDURE:
 MODIFICATION HISTORY:
	JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_orbit_set $SMEI/ucsd/camera/idl/toolbox/smei_orbit_set.pro
[Previous] [Next]
 NAME:
	smei_orbit_set
 PURPOSE:
	Creates structure for manipulating SMEI orbit numbers
 CATEGORY:
	camera/gen/idl/toolbox
 CALLING SEQUENCE:
	rtn = smei_orbit_set(number, [fraction])
 INPUTS:
	number		scalar or array; any numerical type
	fraction	scalar or array; any numerical type
			    number and fraction are added together
			    and put in the structure
 OUTPUTS:
	rtn		array; type: orbit structure
			    rtn.number is integer orbit number
			    rtn.fraction is double precision orbital fraction
				with 0 <= fraction < 1
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType
 CALLED BY:
	smei_coriolis, smei_hdr_plot, smei_sky_track
 PROCEDURE:
 MODIFICATION HISTORY:
	JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_orbit_stats $SMEI/ucsd/camera/idl/toolbox/smei_orbit_stats.pro
[Previous] [Next]
 NAME:
	smei_orbit_stats
 PURPOSE:
	Extracts information about frame counts and state changes from
	the SMEI data base. The information is stored in ASCII files.
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_orbit_stats, trange	    , $
	    source	    = source	    , $
	    destination     = destination   , $
	    to_smeidb	    = to_smeidb     , $
	    update	    = update	    , $
	    state_changes   = state_changes , $
	    camera	    = camera	    , $
	    mode	    = mode	    , $
	    ndoy_lag	    = ndoy_lag	    , $
	    silent	    = silent	    , $
	    usedb	    = usedb	    , $
	    instant_write   = instant_write , $
	    remote	    = remote
 INPUTS:
	trange		array[2]; type: time structure; default: ['2003_001',Current time]
			time range to be processed
			If /update is set, then trange should NOT be specified

 OPTIONAL INPUT PARAMETERS:
	/state_changes	if NOT set then frame counts are made only.
			if SET then a log of state changes over time is made

	source=source	scalar; type: string; default: SMEIDB?
			specifies the location of the SMEI data base
			(passed to smei_getfile).

	/update 	/update is ignored if trange is set.
			If set then also /to_smeidb is assumed.

			If set then the existing ASCII files in $SSWDB_SMEI/cat/list
			are updated (i.e. /to_smeidb is assumed).
			If NOT set then new ASCII files covering time range trange
			are created in the specified destination; if no trange is
			specified then the whole SMEI mission is covered.

	/to_smeidb	sets the destination to $SSWDB_SMEI/cat/list

	destination=destination
			scalar; type: string
			destination directory for the ASCII data base files.
			/to_smeidb NOT set: default: $TUB
			/to_smeidb SET	  : default: $SSWDB_SMEI/cat/list

	camera=camera	scalar or array[2]; type: integer; default: [1,3]
			ignored if /state_changes is NOT set
			create/update state changes for specified cameras only

	mode=mode	scalar; type: integer
			ignored if /state_changes is SET
			if set the frame counts are for the specified mode
			only (by default all three modes are combined)

	tnow=tnow	array[1]; type: time structure; default: TimeSystem()
			ignored when /state_changes is set
			sets the end time when /update is set

	ndoy_lag	scalar; type: integer; default: -3
			sets overlap with existing ASCII files when /update
			is set (i.e. the last ndoy_lag days in the ASCII
			files is redone).

	/usedb		by default the header data base is used.
			If /usedb is set the frame data base is used
			(this takes a lot longer)
	silent=silent	scalar; type: integer; default: 0
			controls level of informational messages

	/instant_write	only used is /state_changes is set
			forces write of results as they are accumulated, instead
			of storing into potentially gigantic arrays that are
			written at the end.
 OUTPUTS:
	(to ASCII files; see PROCEDURE)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CheckDir, FILEPATH, GetFileSpec, InitVar, IsType, REVERSE, SMEI_ORBIT_BAD, TimeGet
	TimeOp, TimeSet, TimeSystem, TimeUnit, boost, destroyvar, do_file, flt_string
	smei_coriolis, smei_filepath, smei_getfile, smei_hdr_get, smei_orbit_get
	smei_property, smeidb_mounted, txt_read
 CALLED BY:
	smei_mkbase
 PROCEDURE:
	/state_changes NOT set (i.e. frame counts only)
	    if no mode is specified then create/update files
		destination/smei_frm_day.txt and destination/smei_frm_orb.txt
	    if mode is specified then create/update files
		destination/smei_frm_day_m#.txt and destination/smei_frm_orb_m#.txt
		(where # is 0,1,2)

	/state_changes SET (i.e. state changes only)
	    create/update files destination/smei_state_cam#.txt'
	    where # is 1,2,3
 MODIFICATION HISTORY:
	SEP-2005, Paul Hick (UCSD/CASS)
	MAR-2007, Paul Hick (UCSD/CASS)
	    Added counters for frames that satisfy the default test
	    criteria used by smeidb_sky to select frames for skymap
	    construction.
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added timestamp to header


smei_orient_test $SMEI/ucsd/camera/idl/toolbox/smei_orient_test.pro
[Previous] [Next]
 NAME:
	smei_orient_test
 PURPOSE:
	Check orientation of cameras
 CATEGORY:
	camera/idl/tricks
 CALLING SEQUENCE:
	smei_orient_test
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, CombineRotations, CvRotation, HAFB_GET_CAMERA_DATA, WhatIs
 RESTRICTIONS:
	Probably need to compile smeipoint.pro explicitly to get access to
	Don's get_camera_data
 SEE ALSO:
	smei_camera
 PROCEDURE:
	The UCSD s/c coordinate system:
	    X-axis along velocity vector
	    Y-axis along rotation axis spacecraft
	    Z-axis to zenith
	The HAFB s/c coordinate system (as in Don's smeipoint.pro routine):
	    X-axis along velocity vector
	    Y-axis opposite to rotation axis spacecraft
	    Z-axis pointing to nadir (i.e. down to Earth)

	To go from UCSD to HAFB s/c coordinate system, rotate around
	x-axis by 180 degrees:
	    R[sc UCSD -> s/c HAFB]: Euler angles: [0,!pi,!pi]; quaternion: [1,0,0,0].

	The UCSD camera coordinate system:
	    X-axis along long dimension (on CCD positive X goes to larger pixel indices)
	    Y-axis along narrow dimension (on CCD positive Y goes to smaller radius)
	    Z-axis along optical axis
	The HAFB camera coordinate system (as in Don's smeipoint.pro routine):
	    X-axis is UCSD Z-axis (along optical axis)
	    Z-axis is UCSD Y-axis
	    Y-axis is UCSD X-axis

	To go from HAFB to UCSD camera coordinate system, apply
	Euler angles:
	    R[camera HAFB -> camera UCSD]:   [0,!pi/2,!pi/2]; quaternion: [1,1,1,1]/2.
	(this is a rotation of 120 degrees around a unit vector with equal components
	along positive x,y and z axes).

	The Euler angles provided to Spectrum Astro rotate from the UCSD
	s/c coordinate system to the UCSD camera coordinate system.
	    R[sc UCSD -> camera UCSD]
	The Euler angles provided to Spectrum Astro apply rotations to Z,X and
	Z axes. We want Euler angles applied to Z,Y,Z axes. To go from Z,Y,Z angles
	to Z,X,Z angles add 90 deg to the first and subtract 90 deg from the
	last Euler angle.

	The HAFB camera quaternions rotate from the HAFB camera coordinate
	system to the HAFB s/c coordinate system.

	    R[camera HAFB -> sc HAFB]

	To retrieve the equivalent Spectrum Astro angles from the HAFB quaternions
	apply the following rotations in sequence:

	    R[sc UCSD -> s/c HAFB]			quaternion [1,0,0,0]
	    Inverse of R[camera HAFB -> sc HAFB]	(inverse of smeipoint quaternion)
	    R[camera HAFB -> camera UCSD]		quaternion: [1,1,1,1]/2.
	    Convert the resulting quaternion to Z,Y,Z angles, i.e.
		add 90 to first and -90 to third to get Z,X,Z angles:

	The Euler angles given to Spectrum Astro are:

	camera 1:  -28.207646	    69.541377	   -21.4776600
	camera 2:  -86.023031	    58.285313	    -6.5798011
	camera 3: -143.782150	    62.553932	     0.3674422

	We frequently need to convert from equatorial coordinates to UCSD
	camera coordinates. The quaternions provided to us in the SMEI data
	rotate from the ECI (J2000 equatorial) to the HAFB s/c frame.
	So to go from UCSD camera frame to the ECI frame apply the following
	rotations

	    R[camera UCSD -> camera HAFB]	    quaternion [-1,-1,-1,1/2
	    R[camera HAFB -> s/c HAFB]		    (from smeipoint)
	    Inverse of R[sc HAFB -> ECI]	    (inverse of quaternion from SMEI data)

	The first two of these (rotating from UCSD camera to HAFB s/c frame)
	is returned by smei_camera. The inverse of all three combined
	rotations is returned by smei_cam_quaternion.
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_pick_stars $SMEI/ucsd/camera/idl/tmo/smei_pick_stars.pro
[Previous] [Next]
 NAME:
	smei_pick_stars
 PURPOSE:
	Select stars to be used for frame registration
 CATEGORY:
	camera/idl
 CALLING SEQUENCE:
	FUNCTION smei_pick_stars, pp, mag, dmin=dmin, magmax=magmax, count=count
 INPUTS:
	pp		array[2,*]; type: float
			    x,y pixel coordinates
 OPTIONAL INPUT PARAMETERS:
	dmin=dmin	only entries at least dmin pixels
			removed from the nearest neighbour are put in 'list'
	magmax=magmax	only entries with magnitudes less then magmax
			are put in 'list'
 OUTPUTS:
	pp		array[2,*]; type: float
			    subset of input for stars fitting criterion
			    pp will not exist on return if no stars fit.
	list		array; type: integer
			    list of stars fitting the criterion
			    If no stars fit then list = -1 is returned
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			# stars in 'list'
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType
 CALLED BY:
	stardistance
 PROCEDURE:
 MODIFICATION HISTORY:
	FEB-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_plot_timeseries $SMEI/ucsd/camera/idl/toolbox/smei_plot_timeseries.pro
[Previous] [Next]
 NAME:
	smei_plot_timeseries
 PURPOSE:
	Plots SMEI timeseries from one of the points files generated
	by the SMEI tomography program.
 CATEGORY:
 CALLING SEQUENCE:
	PRO smei_plot_timeseries, file, nr=nr, $
	    nvalid_los	= nvalid_los	, $
	    xrange	= xrange	, $
	    refresh	= refresh	, $
	    path	= path		, $
	    _extra	= _extra
 INPUTS:
	file	    scalar; type: string
		    fully-qualified file name.
		    If not specified the IDL dialog_pickfile is used.
 OPTIONAL INPUT PARAMETERS:
	nr=nr	    array; type: integer; default: 0
		    list of timeseries to be plotted
	nvalid_los=nvalid_los
		scalar; type: integer; default: 1
		threshold for plotting timeseries: only timeseries with
		more than "nvalid_los" points are displayed.
	/refresh    if set, forces reading of new file, instead of using
		data still in memory
	path=path   scalar; type: string
		    directory name passed to dialog_pickfile
		    Only used if 'file' is not defined
	xrange=xrange	array[2]; type: time structure
		    range of time axis (passed to PlotCurver)
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 COMMON BLOCKS:
	common smei_plot_timeseries_common, old_file, d
 CALLS: ***
	BadValue, InitVar, IsType, PlotCurve, TimeGet, TimeSet, TimeUnit, destroyvar, flt_read
	hide_env
 PROCEDURE:
	Once read, information from the last read file is kept in memory
	for replotting, except when /refresh is set (which forces reading
	of a new file.
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_property $SMEI/ucsd/camera/idl/toolbox/smei_property.pro
[Previous] [Next]
 NAME:
	smei_property
 PURPOSE:
	Get some property of a SMEI frame
 CATEGORY:
	camera/idl/misc
 CALLING SEQUENCE:
	FUNCTION smei_property, frame	,   $
	    uncovered	= uncovered	    ,	$
	    inroi	= inroi 	    ,	$
	    pedestal	= pedestal	    ,	$
	    dark_current= dark_current	    ,	$
	    dark_median = dark_median	    ,	$
	    dark_average= dark_average	    ,	$
	    squares	= squares	    ,	$
	    centerpix	= centerpix	    ,	$
	    left	= left		    ,	$
	    right	= right 	    ,	$
	    high	= high		    ,	$
	    low 	= low		    ,	$
	    sandwich	= sandwich	    ,	$
	    average	= average	    ,	$
	    threshold	= threshold	    ,	$
	    exclude_value=exclude_value     ,	$
	    ceiling_value=ceiling_value     ,	$
	    floor_value = floor_value	    ,	$

	    rejected	= rejected	    ,	$
	    silent	= silent	    ,	$
	    sigma	= sigma 	    ,	$
	    stdev	= stdev 	    ,	$

	    time	= time		    ,	$
	    exposure	= exposure	    ,	$
	    name	= name		    ,	$
	    path	= path		    ,	$
	    camera	= camera	    ,	$
	    mode	= mode		    ,	$
	    frame_nr	= frame_nr	    ,	$
	    onboard_ff_enabled=onboard_ff_enabled,  $
	    shutter_open= shutter_open	    ,	$
	    led_enabled = led_enabled	    ,	$
	    roi_map	= roi_map	    ,	$
	    bos_alert	= bos_alert	    ,	$
	    bos_change	= bos_change	    ,	$
	    sun 	= sun		    ,	$
	    moon	= moon		    ,	$
	    venus	= venus 	    ,	$
	    ccd_temp	= ccd_temp	    ,	$
	    tlm_time	= tlm_time	    ,	$
	    l1a_time	= l1a_time	    ,	$
	    tlm_file	= tlm_file	    ,	$
	    l1a_file	= l1a_file	    ,	$
	    l1a_pntr	= l1a_pntr	    ,	$
	    quaternion	= quaternion	    ,	$

	    n_pedestal	= n_pedestal	    ,	$
	    n_dark_current = n_dark_current ,	$

	    base_done	= base_done	    ,	$
	    base_ok	= base_ok	    ,	$
	    in_eclipse	= in_eclipse	    ,	$
	    in_earth_shadow = in_earth_shadow,	$
	    bad_quaternion  = bad_quaternion,	$
	    just_bad	= just_bad	    ,	$
	    anneal	= anneal	    ,	$
	    bad_data	= bad_data	    ,	$
	    version	= version	    ,	$
	    cal_pattern     = cal_pattern	    ,	$
	    orb_pattern = orb_pattern	    ,	$

	    orbit	= orbit 	    ,	$
	    naxes	= naxes 	    ,	$
	    crpix	= crpix 	    ,	$
	    cdelt	= cdelt 	    ,	$
	    crval	= crval 	    ,	$
	    lonpole	= lonpole	    ,	$

	    count	= count
 INPUTS:
	frame	    array[n,m,k]; type: short integer ??
			sequence of k SMEI frames of dimension n x m
		    array[n]; type: structure
			header structure of SMEI frame(s)
 OPTIONAL INPUT PARAMETERS:
	If input 'frame' are 2D-arrays with SMEI frame data:

	/uncovered	Get uncovered arrea of CCD (between dark columns)
	/inroi		Only get pixels inside ROI
	/pedestal	Get pedestal value
			(based on a subset of the pixels in the pedestal columns)
	/dark_current
	/dark_median
	/dark_average
	/dark_columns	Get dark columns
	/ccd_squares	Get CCD squares
	/sngle_pix	Get single pixel in center of fov

	If input 'frame' is a header structure:

	/time			returns time of array as time structure
	/name			returns file name of frame (name+extension)
	/path			returns fully-qualified path
	/onboard_ff_enabled	returns 1 if ff was enabled
	/tlm_time		returns name of original telemetry file

 OUTPUTS:
	If input 'frame' are 2D-arrays with SMEI frame data:

	out	    /pedestal set:
			array[k]; type: double
			    Currently the pedestal is the average over the top
			    half of dark columns (pixels 32 and up) away from the
			    field of view

		    /dark_columns set:
			array[nn,m,k]; type: same as input 'frame'
			dark columns (nn=2,4, or 8 depending on binning)

		    /ccd_squares set:
			array[2*nn,nn,k]; type: same as input 'frame'
			squares on either side of fov (nn=10,20,40 depending on binning)

		    /single_pix set
			array[nn,nn,k]; type: same as input 'frame'
			single pixel in center above field of view
			(nn=1,2,4 depending on binning)
	dark_column=dark_columns
			    array[2,64] (mode 2); type: unsigned int, long or float
				(multiply array dims by 2^(2-mode) for mode 0,1)
				pixels in covered columns on eithe side of the frame
				(with a width of 'a' pixels)
	ccd_squares=ccd_squares
			    array[10,10]; type: unsigned int, long or float
				(multiply array dims by 2^(2-mode) for mode 0,1)
				pixels in open areas outside of the smei fov
				(two squares of 10 x 10 telemetry pixels)
	single_pix=single_pix
			    array[1,1]
				(multiply array dims by 2^(2-mode) for mode 0,1)
				pixels horizontally centered in frame above fov
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro	; ROI mask common block
 CALLS: ***
	ArrayLocation, BadValue, FILEPATH, GetFileSpec, InitVar, IsType, STDDEV, TimeSet, UNIQ
	boost, smei_filename, smei_filepath, smei_setup_roi, timeposn, where_common
	who_am_i
 CALLED BY:
	img_read, maygeometry, qImage_cw_Property, qImage_cw_Where, qsmei_hdr
	smei_base_testcase, smei_buf_get, smei_buf_getframe, smei_buf_mget
	smei_buf_prep, smei_buf_read, smei_cam_quaternion, smei_frm_base, smei_frm_cvhdr
	smei_frm_eclipse, smei_frm_findpoint, smei_frm_hbar, smei_frm_info, smei_frm_ped
	smei_frm_read, smei_frm_summary, smei_frm_track, smei_frm_where, smei_hdr_make
	smei_hdr_plot, smei_orbit_stats, smei_shutterwrong, smei_sky2cam, stardistance
 SEE ALSO:
 RESTRICTIONS:
	The file smei_buf_roi.txt must exist in the same directory as this source
	code file.
 PROCEDURE:
	The dark_columns, ccd_squares and single pix are identified by checking for values
	2,3 and 4, respectively in the mask read from smei_buf_roi.txt.
 MODIFICATION HISTORY:
	MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_radial2theta $SMEI/ucsd/camera/idl/toolbox/smei_radial2theta.pro
[Previous] [Next]
 NAME:
	smei_radial2theta
 PURPOSE:
	Converts a radial offset Rccd-R0 to an angle thetay
 CATEGORY:
	camera
 CALLING SEQUENCE:
	thetay = smei_radial2theta(delta_r[, thetax, tol=tol])
 INPUTS:
	delta_r     array; type: float
			radial offsets in left-hand side of Eq. 3
			in pixels
 OPTIONAL INPUT PARAMETERS:
	thetax	    scalar or array with structure type as 'delta_r';
		    type: same as 'delta_r'; default: 0.0
			thetax value in right-hand side of Eq. 3
			in degrees
 OUTPUTS:
	thetay	    array with same structure as 'delta_r'; type: same as 'delta_r'
			thetay value that satisfies Eq. 3 for specified
			radial offset and thetax in degrees.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_theta2radial
 CALLS: ***
	InitVar, SubArray, SuperArray, nrZBrent, nrZbrac
 CALLED BY:
	cvsmei, smei_ccd2sky
 PROCEDURE:
	See Andy's memo "Defining the field of view for the SMEI cameras" (11-July-2001)
	This function inverts Equation 3.
 MODIFICATION HISTORY:
	FEB-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_rewind $SMEI/ucsd/camera/idl/toolbox/smei_rewind.pro
[Previous] [Next]
 NAME:
	smei_rewind
 PURPOSE:
	Rewinds SMEI pipeline by clearing entries in status files
	in $SSWDB_SMEI/cat/sts
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_rewind, tt , $
	    cal     = cal	, $
	    base    = base	, $
	    orb     = orb	, $
	    sky     = sky	, $
	    camera  = camera	, $
	    notest  = notest
 INPUTS:
	tt	    scalar or array[1]; time in the form of a
		    string or standard time structure. The input time is
		    truncated to the beginning of the day (0 UT).
		    Usually specified in the form YYYY_DOY. This rewinds
		    the pipeline back to (and including) the indicating
		    day.
 OPTIONAL INPUT PARAMETERS:
	Four keywords are available to indicate which part of the
	pipeline processing is to redone.
	One and only one of the following four keyword must be set:
	/cal	    Redo everything starting with the calibration patterns
	/base	    Rebase all frames, redo "on-the-fly" patterns and skymaps
	/orb	    Redo the orbital "on-the-fly" pattern, and the skymaps
	/sky	    Redo only the skymaps

	camera=camera	scalar, or array; type: integer; default: [1,2,3]
			list of cameras for which status are updated
	/notest 	no actual updates of the status files are made
			UNLESS this keyword is set. If /notest is NOT set
			then the content of the updated status files is
			written to screen only.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FindAllFiles, InitVar, IsTime, IsType, TimeGet, TimeOp, TimeSet, TimeUnit, hide_env
	smei_filename, smei_filepath, txt_read
 SIDE EFFECTS:
	Updates status files
 PROCEDURE:
	The status files are used in the script smei_pipeline.sh, and
	the IDL programs it calls to decide which steps to executed.
	Rewinding the pipeline with this procedure only will clear
	(set to zero) the appropriate flags in the status file, forcing
	the indicated steps to be redone.

	Note that this will only work if smei_pipeline.sh is set up
	in such a way that existing files are overwritten. In particular,
	this means that the /force keyword must be used on all IDL
	procedures executed.
 MODIFICATION HISTORY:
	MAR-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added documentation


smei_rmdups $SMEI/user/pphick/idl/smei_rmdups.pro
[Previous] [Next]
 NAME:
	smei_rmdups
 CALLING SEQUENCE:
	PRO smei_rmdups
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, FindAllFiles, GetFileSpec, WhatIs, where_common


smei_roi_mask $SMEI/ucsd/camera/idl/buf/smei_roi_mask.pro
[Previous] [Next]
 NAME:
	smei_roi_mask
 PURPOSE:
	Common block definition with ROI information
 CATEGORY:
	camera/idl/buf
 CALLING SEQUENCE:
	@smei_roi_mask.pro
 INPUTS:
	From text file smei_buf_roi.txt
 OUTPUTS:
	Stored in common block
 COMMON BLOCKS:
	common smei_roi_mask, roi_siz, roi_frm, roi_drk, roi_sqr, roi_pix, roi_ped, roi_col, roi_fov, roi_bad
 CALLS:
	smei_setup_roi, who_am_i
 MODIFICATION HISTORY:
	APR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_setup_roi $SMEI/ucsd/camera/idl/buf/smei_setup_roi.pro
[Previous] [Next]
 NAME:
	smei_setup_roi
 PURPOSE:
	Fill common block with ROI information
 CATEGORY:
	camera/idl
 CALLING SEQUENCE:
	smei_setup_roi
 INPUTS:
	(from text file smei_roi.txt)
 OPTIONAL INPUTS:
	/destroy    destroys ROI heap variables
 OUTPUTS:
 CALLS: ***
	ArrayLocation, FILEPATH, InitVar, IsType, MagnifyArray, destroyvar, txt_read, who_am_i
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_roi_mask.pro
 CALLED BY:
	qImage_cw_Where, qView_Destroy, smei_buf_get, smei_buf_mget, smei_buf_read
	smei_frm_base, smei_frm_flatfield, smei_frm_hbar, smei_frm_read, smei_frm_rebin
	smei_property, smei_roi_mask
 PROCEDURE:
	Sets up pointers to list of array indices into SMEI frames for each of the modes
	For i=0,1,2 (three different modes):
	*roi_siz[i]	2-element array with image dimension
	*roi_frm[i]	list of pixels included in the SMEI roi
	*roi_fov[i]	list of pixels inside the field of view (incl. *roi_bad[i])
	*roi_drk[i]	list of pixels in dark current columns
	*roi_sqr[i]	list of pixels in two squares outside fov arc
	*roi_pix[i]	list of pixels in center square inside fov arc
	*roi_ped[i]	list of pixels in pedestal columns
	*roi_col[i]	list of pixels in pedestal and dark current columns
	*roi_bad[i]	list of pixels with partially covered pixels
			(i.e. the column to the right of the dark columns on the left, and
			the column to the left of the dark columns on the right of the frame)
 MODIFICATION HISTORY:
	APR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_sgp4_orbits $SMEI/ucsd/gen/idl/ephem/smei_sgp4_orbits.pro
[Previous] [Next]
 NAME:
	smei_sgp4_orbits
 PURPOSE:
	Build list of start times for all orbits using TLE data base.
 CALLING SEQUENCE:
	PRO smei_sgp4_orbits, input_sgp4_file, new=new, smeitree=smeitree, silent=silent
 INCLUDE:
	@compile_opt.pro    ; On error, return to caller
 INPUTS:
	input_sgp4_file
		    existing file with start times.
		    By default the file in the SMEI tree is used
		    (if /new is NOT set)
 OPTIONAL INPUTS:
	/new	    creates a new file from scratch. In this case
		    input_sgp4_file is ignored
	/smeitree   The output file is created as $TUB/smei_sgp4_orbits.tmp
		    If /smeitree is set then the file in $TUB is copied to
		    the SMEI master tree and to the SMEI tree on smei.ucsd.edu
		    (requires that env $SMEIMASTER is defined)
 CALLS: ***
	AngleRange, CV_COORD, FILEPATH, INTERPOL, InitVar, TimeGet, TimeOp, TimeSet, TimeUnit
	big_eph, destroyvar, hide_env, ra_fictitious_sun, sgp4_eph, sgp4_orbit_axis
	sgp4_orbit_period, sphere_distance, txt_read, who_am_i
 PROCEDURE:
	sgp4_eph returns rectangular ECI coordinates relative to the
	current equinox. Essentially this means equatorial coordinates
	relative to the current equinox. So the declination is
	effectively the geographic latitude.

	Currently (March 2011) this procedure is called as part of
	smei_pipeline.sh (executed hourly as cronjob on smeidb).

	The file is used in IDL only by the procedure smei_coriolis.pro.
	In Fortran the only function calling it is smei_orbit_info2.f.

	Content of file:

	1. SMEI orbit number
	2. Orbit start time in format YYYY_DOY_hhmmssmss
	   The orbital start time in format hh:mm:ss.mss
	   Defined as the time Coriolis crosses a fixed geographic
	   latitude (~ -31.1 degrees; close to the latitude of the
	   SAA) going north.
	3. Orbital period, defined as time difference between two
	   successive orbital start times
	4. Orbital period used in sgp4 software
	   I think this is some sort of Keplerian orbital period;
	   not particulary useful.
	5. Precision of geographic latitude calculation

	The remaining columns are related to the normal of the SMEI orbital
	plane (pointing towards the Sun).

	6. Solar elongation (in degrees) of the normal
	7. RA (in degrees) of the fictitious Sun
	   This progresses stricly linear with UT going through
	   360 degrees in 365.25 days (one Julian year).
	   This is approximate, but good enough for government work)
	8. RA difference (J2000, in degrees) of the normal with the
	   RA of the fictitious Sun.
	9. Declination of the normal (J2000, in degrees)
 MODIFICATION HISTORY:
	JAN-2006, Paul Hick (UCSD/CASS)
	OCT-2006, Paul Hick (UCSD/CASS)
	    Replaced NewcombSun by big_eph calls
	MAR-2007, Paul Hick (UCSD/CASS)
	    Eliminated big_eph. Now only sgp4_eph is used.
	APR-2007, Paul Hick (UCSD/CASS)
	    Added check to avoid calculating start times past
	    the time of the last TLE available to sgp4_eph.
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added column for elongation of normal to Coriolis
	    of orbital plane.
	MAR-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added columns for RA,dec of orbit normal


smei_sgp4_quat $SMEI/ucsd/gen/idl/ephem/smei_sgp4_quat.pro
[Previous] [Next]
 NAME:
	smei_sgp4_quat
 PURPOSE:
	Calculates quaternion for nominal SMEI attitude at indicated times.
 CATEGORY:
 CALLING SEQUENCE:
	FUNCTION smei_sgp4_quat,  tt
 INPUTS:
	tt	array; type: time structure
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
	qq	array[4,*]; type: double
		    spacecraft quaternion
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CV_COORD, CvRotation, sgp4_eph
 CALLED BY:
	qImage_cw_Where, smei_cam_quaternion
 PROCEDURE:
	Should match the quaternion specified in the SMEI frame header.
 MODIFICATION HISTORY:
	JUL-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_shutterwrong $SMEI/user/pphick/idl/smei_shutterwrong.pro
[Previous] [Next]
 NAME:
	smei_shutterwrong
 PURPOSE:
	Detect frames that may have the shutter flag set wrong
 CALLING SEQUENCE:
	PRO smei_shutterwrong, trange, camera=camera, mode=mode, dbsource=dbsource
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, GetFileSpec, InitVar, IsType, MEAN, STDDEV, TimeGet, TimeUnit, smei_coriolis
	smei_getfile, smei_hdr_get, smei_property
 MODIFICATION HISTORY:
	JAN-2006, Paul Hick (UCSD/CASS)


smei_sky $SMEI/ucsd/camera/idl/sky/smei_sky.pro
[Previous] [Next]
 NAME:
	smei_sky
 PURPOSE:
	View orbital sky maps
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	PRO smei_sky, wanted_map, _extra=_extra,    $
	    source	= source    , $
	    allraw	= allraw    , $
	    allcnt	= allcnt    , $
	    allflat	= allflat   , $
	    allstars	= allstars  , $

	    two_eyes	= two_eyes  , $

	    timesun	= timesun   , $
	    degrees	= degrees   , $
	    maxelo	= maxelo    , $
	    ndim	= ndim	    , $
	    equator	= equator   , $
	    range	= range     , $
	    ctable	= ctable    , $
	    breakval	= breakval  , $
	    antisolar	= antisolar , $
	    silent	= silent    , $
	    zero_point	= zero_point, $
	    difference	= difference, $
	    xysize	= xysize    , $

	    rawmap	= rawmap    , $
	    sidereal	= sidereal  , $

	    noplot	= noplot    , $

	    skymap	= skymap    , $
	    hdrs	= hdrs	    , $
	    count	= count     , $
	    imgfile	= imgfile   , $

	    logo	= logo	    , $
	    charsize	= charsize  , $
	    exten_no	= exten_no  , $
	    compose	= compose   , $
	    naked	= naked     , $
	    legend	= legend    , $
	    logscale	= logscale  , $
	    get_camera_map = get_camera_map, $
	    min_map	= min_map   , $

	    flip_ct	= flip_ct   , $
	    flip_bw	= flip_bw   , $
	    timeavgcam	= timeavgcam

 INPUTS:
	wanted_map	    scalar; type: integer
 OPTIONAL INPUT PARAMETERS:
	timesun=timesun     array[1]; type: time structure
			    overrides the time extracted from the
			    file header as the time determining the position
			    of the Sun in the sun-centered maps.
	/degrees	    if set, all angles are in degrees
				default: radians

	mode = 'sky','equ':

	The all* keywords force display of all three 'raw' (hires) skymaps in one
	image. (i.e. the equatorial and the two polar maps):

	/allraw 	    ('sky' and 'equ')
			    if set, plot brightness maps (1st 3 Fits extensions)
			    in three separate panels: north pole, equatorial
			    region and south pole.
	/allcnt 	    ('sky' only)
			    if set, plot frame counts (2nd 3 Fits extensions in 'sky' maps)
			    in three separate panels: north pole, equatorial
			    region and south pole.
	/allflat	    ('equ' only)
			    if set, plot star-subtracted "flat" brightness maps
			    (2nd 3 Fits extension in "equ" maps)
			    in three separate panels: north pole, equatorial
			    region and south pole.
	/allstars	    ('equ' only)
			    if set, plot subtracted stars (3rd 3 Fits extensions in "equ" maps)
			    in three separate panels: north pole, equatorial
			    region and south pole.

	A number of keywords force display of a single Fits extension.
	Hires equatorial maps are always in equi-rectangular projection:

	/equatraw	    ('sky' and 'equ')
	/equatcnt	    ('sky')
	/equatflat	    ('equ')
	/equatstars	    ('equ')

	Hires polar maps are always in polar projection.

	/northraw	    ('sky' and 'equ')
	/northcnt	    ('sky')
	/northflat	    ('equ')
	/northstars	    ('equ')
	/southraw	    ('sky' and 'equ')
	/southcnt	    ('sky')
	/southflat	    ('equ')
	/southstars	    ('equ')

	Remaining keywords refer to lores maps. The lores maps are always full-sky.

	/dirtysky	    ('sky')
	/orbtime	    ('sky', 'equ')
	/orbsecs	    ('sky', 'equ')
	/psfn		    ('sky', 'equ')
	/psfe		    ('sky')
	/badsky 	    ('sky')
	/badhtm 	    ('sky')
	/fovx		    ('sky', 'equ')
	/thetax 	    ('sky')
	/thetay 	    ('sky')

	If none of these keywords are specified than the equatorial
	and two polar maps are assembled into a single map covering the full
	sky.

	/difference	??
	/compose    ??

	Full-sky maps (i.e. the lores maps and composite hires maps) are by
	default plotted in a sun-centered (or centered anti-solar if /antisolar
	is set). The map projection is controlled by the maxelo keyword.

	/equator	passed to PlotEarthSkymap. Puts the equatorial plane on the
			horizontal instead of the ecliptic.
			Used only for sun-centered (composite) maps.
	/rawmap 	This displays the sun-centered map without interpolation
			to obtain the map values. In this case the keyword
			/equator is set in PlotEarthSkymap.
			Used only for sun-centered (composite) maps.
	/sidereal	forces display in a sidereal (equatorial)
			coordinate system.
	maxelo=maxelo	    passed to PlotEarthSkymap. Determines the map projection
			(Hammer-Aitoff, equi-rectangular or fish-eye)
	/antisolar	shifts from sun-centered map to map centered on
			anti-solar direction.


	Other keywords passed to smei_sky_read

	camera=camera	    scalar, or array[n]; type:integer; default: 2
				camera numbers
	nbin=nbin

	/noplot 	    suppresses plotting
			    mostly used to pull out the skymap array
			    ignored if keyword allraw is set
 OUTPUTS:
	skymap=skymap	    skymap array as returned by smei_sky_read
	hdrs=hdrs	    scalar or array; type: string
				list of fully-qualified filenames read
				by smei_sky_read
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, BadValue, CvPrecess, CvSky, InitVar, IsType, LOADCT, PlotEarthSkymap [1]
	PlotEarthSkymap [2], PlotEarthSkymap [3], PlotEarthSkymap [4], PlotPolarSkymap
	REVERSE, SuperArray, TimeLimits, TimeSet, ToDegrees, ToRadians, UNIQ, WhatIs, big_eph
	destroyvar, get_page, gridgen, jpl_body, set_page, smei_getfile, smei_sky_cleantime
	smei_sky_field, smei_sky_hdr2range, smei_sky_hdr_check, smei_sky_read
 CALLED BY:
	FUNCTION smeilatest lastorbit, qsmei_sky_pick, smei_findpnt, smei_mkmask
	smei_sky_cleanedge_map, smei_sky_track, smei_star_fit, smei_star_remove
	smei_zld_remove [1], smei_zld_remove [2]
 PROCEDURE:
 MODIFICATION HISTORY:
	DEC-2004, Paul Hick (UCSD/CASS)
	JUL-2006, Paul Hick (UCSD/CASS)
	    Added time keyword
	APR-2008, Paul Hick (UCSD/CASS)
	    Added code to handle input of 2-element 'source'.
	    Fixed bug in making of difference maps for raw maps
	MAY-2008, Paul Hick (UCSD/CASS)
	    All full-sky maps are now by default sun-centered.
	    Added /sidereal keyword to force display in sidereal
	    equatorial in equi-rectangular projection.
	JUL-2008, Paul Hick (UCSD/CASS)
	    Improved interpolation procedure on equatorial map
	    for points close to edge of map. Primarily needed
	    to overcome limitation in IDL interpolate procedure
	    for point just outside the array limits.
	FEB-2010, Paul Hick (UCDS/CASS)
	    Removed ambiguity between keywords 'time' and 'timeavgmap'
	    (made keyword time inaccessible) by renaming 'time' to
	    'timesun'
	JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Bugfixes: added safeguards against completely empty skymaps
	    to avoid crash because of invalid array index -1.


smei_sky2cam $SMEI/ucsd/camera/idl/obsolete/smei_sky2cam.pro
[Previous] [Next]
 NAME:
	smei_sky2cam
 PURPOSE:
	Convert from equatorial coordinates to coordinates in the UCSD
	SMEI camera frame.
 CATEGORY:
	camera/idl
 CALLING SEQUENCE:
	R = smei_sky2cam( rvec, [ camera=camera, quaternion=quaternion, /degrees] )
 INPUTS:
	rvec	    array[2,n] or array[3,n]; type: float
			positions in the sky as spherical or rectangular
			equatorial coordinates.

			/rect NOT SET: spherical coordinates
			    rvec[0,*] is RA;
			    rvec[1,*] is declination
			    rvec[3,*] (usually the distance)

			/rect SET: rectangular coordinates
			    rvec[0,*] is x-coordinate (toward vernal equinox
			    rvec[1,*] is y-coordinate
			    rvec[3,*] is z-coordinate (toward equatorial north)

			The units of the angles are determined by the setting of /degrees.
 OPTIONAL INPUT PARAMETERS:
	/degrees	if set, all in- and output angles are in degrees
			(default: radians). Note that the input 'camera' structure,
			if specified, must be consistent with the setting of /degrees.

	/rectangular	if set then rvec is in rectangular Cartesian coordinates.
			The 1st dimension in rvec MUST be 3; if it is not then
			this keyword is ignored.

	camera=camera	Identifies the SMEI camera

			Can be any one of the following three.

			array[1]; type: SMEI_FRM_HDR structure
			    this determines the camera and the quaternion.
			    The keyword 'quaternion', if present,
			    will be ignored.

			array[1]; type: SMEI_CAMERA_FOV structure
			    structure containing information about SMEI field of
			    view; usually the return value of smei_camera
			    with the /get_structure keyword set.
			    This determines the fixed S/C-to-camera quaternion. The
			    Coriolis quaternion must be specified using the
			    'quaternion' keyword.

			scalar; type: integer
			    camera number (1,2 or 3).
			    This determines the fixed S/C-to-camera quaternion. The
			    Coriolis quaternion must be specified using the
			    'quaternion' keyword.

			If not specified then camera=1 is assumed.

			The camera number is used as argument to smei_camera to
			obtain the fov structure.
	quaternion=quaternion
		    array[4]; type: float
			Coriolis S/C quaternion
 OUTPUTS:
	R	    array[3,n]; type: float
			x,y,z coordinates of unit vector in the UCSD camera
			frame
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CV_COORD, CvRotation, InitVar, IsType, SyncDims, ToRadians, boost, smei_cam_quaternion
	smei_camera, smei_property
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Extracted from smei_sky2ccd.


smei_sky2ccd $SMEI/ucsd/camera/idl/obsolete/smei_cam2ccd.pro
[Previous] [Next]
 NAME:
	smei_sky2ccd
 PURPOSE:
	Convert from positions in the sky to CCD coordinates
 CATEGORY:
	camera/idl
 CALLING SEQUENCE:
	R = smei_sky2ccd( runit, [ camera=camera, /degrees] )
 INPUTS:
	runit		array[3,n]; type: float
			    positions in the sky as unit vectors in the UCSD camera
			    frames (as output by smei_frm_sky2ccd)
			    These are converted to CCD coordinates if inside the FOV
			    If no points lie inside the
			    field of view then the scalar BadValue(rvec) is returned.
 OPTIONAL INPUT PARAMETERS:
	camera=camera	scalar; type: integer
			    camera number (1,2 or 3).
			If not specified then camera=1 is assumed.
			The camera number is used as argument to smei_camera to
			obtain the fov structure.

	/degrees    if set, all in- and output angles are in degrees
			(default: radians). Note that the 'camera' structure
			must be consistent with the setting of /degrees.
	/boolean    if set then the output array 'inside' is a byte array of zeros
			and ones indicating whether the corresponding vectory is
			outside/inside the field of view (instead of a list of
			indices from the IDL 'where' function identifying vectors
			inside the field of view).
	scalefov=scalefov
		    scalar; type: float; default=3.0 (covers essentially the whole
			hemisphere centered on the camera optical axis).
			Only locations closer then fov.size[0]/2 (= 30 degrees) to the
			pole potentially lie inside the fov. The multiplier scalefov
			extends the search to at most 89.5 degrees (essentially the
			whole hemisphere centered on the pole. See PROCEDURE.
	distort=distort
		    NOT IMPLEMENTED YET
 OUTPUTS:
	R	    array[2,n]; type: float
			x and y pixel coordinates inside the SMEI fov
 OPTIONAL OUTPUT PARAMETERS:
	inside=inside	array; type: long int (/boolean NOT set) or byte (/boolean set).
			    if /boolean is not set then 'inside' is a list of indices of
			    vectors inside field of view
			    if /boolean is set then 'inside' is a byte array with 0 for
			    vectors inside or 1  for vectors inside the field of view.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, CV_COORD, InitVar, Inside_Wedge, IsType, SyncDims, ToDegrees, ToRadians
	smei_cam2ccd, smei_camera, smei_theta2radial
 PROCEDURE:
	The determination of sky locations inside the field of view is done in
	two cuts. The first cut retains only points within scalefov*30 deg from
	the optical axis. The default scalefov=3.0 so all points within 90 deg
	are retained (actually 89.5 degrees).

	The second cut retains only points strictly inside the field of view as
	defined in the 'camera' structure. Only CCD coordinates for these points are
	returned and are marked in the 'inside' array.
 MODIFICATION HISTORY:
	FEB-2003, Paul Hick (UCSD/CASS)
	FEB-2005, Paul Hick (UCSD/CASS)
	    Added keyword runit
	MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Split smei_sky2ccd into two parts: smei_sky2cam and smei_cam2ccd.


smei_sky_atlocation $SMEI/ucsd/camera/idl/toolbox/smei_sky_atlocation.pro
[Previous] [Next]
 NAME:
	smei_sky_atlocation
 PURPOSE:
	Good question
 CATEGORY:
	Extract function values at specified sky locations from a SMEI
	skymaps. Put together in kinda adhoc fashion. So sorry.
 CALLING SEQUENCE:
	FUNCTION smei_sky_atlocation, wanted_map, $
	    show	= show	    , $
	    time	= time	    , $
	    _extra	= _extra
 INPUTS:
	wanted_map	passed to smei_getfile
 OPTIONAL INPUT PARAMETERS:
	/show		prints the locations and function values extracted
			from the skymap on the screen for all extensions
			in the selected skymap.
	_extra=_extra	/show SET:
			One of the from_* keywords to cvsmei is used here to
			specify one or more skymap locations
			(just a single location should be specified, I think, otherwise
			the screen will be flooded with too much output).
			/show NOT set:
			keywords are passed to smei_sky_field to determine
			whether a skymap is requested, and what extension to read,
			if it is a skymap.
			Also, one of the from_* keywords to cvsmei is used
			to specify the sky locations
 OUTPUTS:
	R		function value
 OPTIONAL OUTPUT PARAMETERS:
	time=time	array[1]; type: time structure
			if /show is set, then the time at which SMEI observed the
			sky location is returne here.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, FXPAR, InitVar, READFITS, TimeGet, TimeOp, TimeSet, TimeUnit, cvsmei
	smei_getfile, smei_sky_field, smei_sky_hdr2mode
 CALLED BY:
	qImage_cw_Where
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_sky_cleanedge_fix $SMEI/ucsd/camera/idl/toolbox/smei_sky_cleanedge_fix.pro
[Previous] [Next]
 NAME:
	smei_sky_cleanedge_fix
 PURPOSE:
	Applies a correction to a hires skymap (equatorial
	north pole or south pole) for straylight contribution
	from sky just outside the fov.
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_sky_cleanedge_fix	, $
	    lo_fovx	, lo_time	, $	; Lores direction cosine angle and time maps
	    hi_sky	,		  $	; Hires sky map
	    lo_edge	, hi_edge	, $	; Inner and outer edge of band in need of fixing
	    fraction	, time_sample	, $	; Max fraction of sample time series subtracted
	    left_sample , right_sample	, $
	    mode    = mode
 INPUTS:
	lo_fovx 	    array[720,360]; type: float
	lo_time 	    array[720,360]; type: float
				2D lores skymaps: time and fovx angle
	hi_sky		    array[3600,1200,n] or array[800,800]
				2D hires skymap to be corrected
				If n=1 the 3rd dimension may be absent

	lo_edge 	    scalar; inner edge of fov area that needs
				to be corrected (lo_edge=20 degrees)
	hi_edge 	    scalar: outer edge of fov area that needs
				to be corrected (hi_edge=30 degrees)
	time_sample	    array[n]; type: float
				times (as seconds since start of orbit)
				covering the entire orbit
	left_sample	    array[n]; type: float
				sky brightness at "left edge" of fov
				(negative direction cosine angles)
				set by smei_sky_cleanedge_median)
	right_sample	    array[n]; type: float
				sky brightness at "right edge" of fov
				(positive direction cosine angles)
				set by smei_sky_cleanedge_median)
 OUTPUTS:
	hi_sky		    array[3600,1200] or array[800,800]
				corrected 2D hires skymap
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	INTERPOL, IsType, cvsmei
 CALLED BY:
	smei_sky_cleanedge_fov
 RESTRICTIONS:
	The units of the angles (degrees or radians) must be the
	same for lo_fovx, lo_edge and hi_edge
 PROCEDURE:
	All bins in the hires sky map with direction cosine angle
	greater than lo_edge in absolute value are corrected by
	subtracted a fraction of the left_sample or right_sample
	array.

	The correction is largest at the edge of the fov
	and drops of linearly with direction cosine angle to zero
	at direction cosine angle lo_edge.

	At direction cosine angle hi_edge the correction is
	'fraction' times left_sample or right_sample.

	For each skybin the time is used to determine the
	appropriate left_sample or right_sample value by
	linear interpolation on the two sample time series.
 MODIFICATION HISTORY:
	APR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_sky_cleanedge_fov $SMEI/ucsd/camera/idl/toolbox/smei_sky_cleanedge_fov.pro
[Previous] [Next]
 NAME:
	smei_sky_cleanedge_fov
 PURPOSE:
	Remove straylight from sky just outside edge
	of camera field of view
 CATEGORY:
	ucsd/camera/idl/stars
 CALLING SEQUENCE:
	PRO smei_sky_cleanedge_fov, $
	    eq_sky	= eq_sky    , $
	    np_sky	= np_sky    , $
	    sp_sky	= sp_sky    , $

	    time_map	= time_map  , $
	    fovx_map	= fovx_map  , $

	    degrees	= degrees   , $
	    silent	= silent
 OPTIONAL INPUT PARAMETERS:
	/degrees		if set then the angles in fovx_map are in
				degrees (default: radians)
	/silent 		controls informational messages

	eq_sky=eq_sky		array[3600,1200]; type: float
	np_sky=np_sky		array[ 800, 800]; type: float
	sp_sky=sp_sky		array[ 800, 800]; type: float
				    2D hires sky maps: equatorial, north pole and
				    south pole
	time_map=time_map	array[720,360]; type: float
	fovx_map=fovx_map	array[720,360]; type: float
				    2D lores skymaps: time and fovx angle
 OUTPUTS:
	eq_sky=eq_sky		array[3600,1200]; type: float
	np_sky=np_sky		array[ 800, 800]; type: float
	sp_sky=sp_sky		array[ 800, 800]; type: float
				    2D hires sky maps: equatorial, north pole and
				    south pole
				    with the straylight contribution from sky
				    just outside the fov removed
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, ToDegrees, ToRadians, destroyvar, gridgen, smei_sky_cleanedge_fix
	smei_sky_cleanedge_median, smei_sky_cleanedge_sample
 CALLED BY:
	smei_sky_cleanedge_map, smei_star_remove
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2007, Paul Hick (UCSD/CASS)
	MAY-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added check for number of valid lores element in time map.
	    There should be at least two valid elements in time_sample


smei_sky_cleanedge_map $SMEI/ucsd/camera/idl/toolbox/smei_sky_cleanedge_map.pro
[Previous] [Next]
 NAME:
	smei_sky_cleanedge_map
 PURPOSE:
	Wrapper for smei_sky_cleanedge_fov for processing
	a single Fits skymap.
 CATEGORY:
	ucsd/camera/idl/stars
 CALLING SEQUENCE:
	PRO smei_sky_cleanedge_map, file, $
	    overwrite	= overwrite	, $
	    degrees	= degrees	, $
	    silent	= silent
 INPUTS:
	file			scalar; type; string
				    fully-qualified file name of sky map
 OPTIONAL INPUTS:
	/degrees
	/silent
	/overwrite
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXADDPAR, FXPAR, GetFileSpec, HEADFITS, InitVar, READFITS, WRITEFITS, do_file
	hide_env, smei_sky, smei_sky_cleanedge_fov
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2007, Paul Hick (UCSD/CASS)


smei_sky_cleanedge_median $SMEI/ucsd/camera/idl/toolbox/smei_sky_cleanedge_median.pro
[Previous] [Next]
 NAME:
	smei_sky_cleanedge_median
 PURPOSE:
	Converts the data for sky bins in a one-degree strip
	of sky along the left or right edge of the fov
	(collected by smei_sky_cleanedge_sample) into
	a time series at times time_sample
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION smei_sky_cleanedge_median, time, sky, time_sample, time_hbox
 INPUTS:
	time		array[n]; type: float
			    times (as seconds since start of orbit)
			    for sky bins along left edge of fov.
	sky		array[n]; type: float
			    sky brightness for sky bins along left
			    edge of fov.
			These arrays are output from smei_sky_cleanedge_sample
	time_sample	array[m]; type: float
			    equal-step array of times covering
			    entire orbit.
 OUTPUTS:
	sky_sample	array[m]; type: float
			    sky brightness at times time_sample
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue
 CALLED BY:
	smei_sky_cleanedge_fov
 PROCEDURE:
	The sky_sample values are the median of all skybins
	within time_hbox seconds of time_sample.
	If no sky bins are present then sky_sample is set to
	BadValue(0.0).
 MODIFICATION HISTORY:
	APR-2007, Paul Hick (UCSD/CASS)
	OCT-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Changed loop variable from short to long integer


smei_sky_cleanedge_sample $SMEI/ucsd/camera/idl/toolbox/smei_sky_cleanedge_sample.pro
[Previous] [Next]
 NAME:
	smei_sky_cleanedge_sample
 PURPOSE:
	(for internal use by smei_sky_cleanedge_fov)
	Accumulates bins from hires skymaps along strip of
	sky close to edge of fov.
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
	PRO smei_sky_cleanedge_sample	, $
	    lo_fovx	, lo_time	, $ ; Lores direction cosine angle and time maps
	    hi_sky	,		  $ ; Hires sky map
	    lo_edge	, hi_edge	, $ ; Inner and outer edge of strip used to make sample brightness
	    left_time	, left_sky	, $
	    right_time	, right_sky	, $
	    mode    = mode
 INPUTS:
	lo_fovx 	    array[720,360]; type: float
	lo_time 	    array[720,360]; type: float
				2D lores skymaps: time and fovx angle
	hi_sky		    array[3600,1200] or array[800,800]
				2D hires skymap to be corrected

	lo_edge 	    scalar; inner edge of strip along edge fov
				(lo_edge=29 degrees)
	hi_edge 	    scalar: outer edge of strip along edge fov
				(hi_edge=30 degrees)
 OUTPUTS:
	left_time	    array[n]; type: float
				times (as seconds since start of orbit)
				for sky bins along left edge of fov.
	left_sky	    array[n]; type: float
				sky brightness for sky bins along left
				edge of fov.
	right_time	    array[n]; type: float
				sky brightness for sky bins along right
				edge of fov.
	right_sky	    array[n]; type: float
				sky brightness for sky bins along right
				edge of fov
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	boost, cvsmei
 CALLED BY:
	smei_sky_cleanedge_fov
 RESTRICTIONS:
	The units of the angles (degrees are radians) must be the
	same for lo_fovx, lo_edge and hi_edge
 PROCEDURE:
	Collects sky bins inside 1-degree strip along "left edge"
	(negative direction cosine angles) and "right edge" (positive
	direction cosine angles) of fov, and stores times in
	left_time and right_sky, and sky brightnesses in
	right_time and right_sky.

	Bin times and brightnesses are tagged to the end of the
	*_time and *_sky arrays, i.e. these arrays need to be
	destroyed by the calling procedure prior to accumulating
	sky bins for the three hires maps (equatorial, north pole
	and south pole).
 MODIFICATION HISTORY:
	APR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_sky_cleantime $SMEI/ucsd/camera/idl/toolbox/smei_sky_cleantime.pro
[Previous] [Next]
 NAME:
	smei_sky_cleantime
 PURPOSE:
	Removes averages from slices of a skymap that are between
	two orbital time intervals, determined by the number of
	slices. (default 360 slices)
 CATEGORY:
	camera/idl/toolbox
 CALLING SEQUENCE:
FUNCTION smei_sky_cleantime , $
	skymap		, $ ; equatorial map
	timemap 	, $ ; low-res orbtime map
	cammap=cammap	    , $ ; low-res camera coverage map
	camavg=camavg	    , $ ; camera or cameras to average
	slices=slices		; number of time slices
 INPUTS:
	skymap		array[720,360]; type: float
			    low res equatorial skymap
	timemap 	array[720,360]; type: float
			    orbtime map
 OPTIONAL INPUTS:
	slices=slices	    scalar; type: float
			    number of slices to cut map
			    into for averaging times
	camavg=camavg	    scalar or array; type: integer
			    camera or cameras to remove
			    average values from (default: 3)
			    must only contain integer values
			    1 2 or 3, or an array of those
			    eg. [1,2,3]
	cammap=cammap	    array[720,360]; type: integer
			    map of camera coverage
			    (if either camavg or cammap are
			    not provided, then the entire
			    skymap will have the average
			    removed in slices
 OUTPUT:
	skymap		array[720,360]; type: float
			    same as input map but with
			    time-slice averages removed
			    in specified camera only
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	CONGRID, InitVar, MEAN
 CALLED BY:
	smei_sky
 MODIFICATION HISTORY:
	JAN-2010, John Clover (UCSD/CASS; jclover@ucsd.edu)
	OCT-2010, John Clover
	    Added more flexibility, if nbin is changed in smei_sky, this should
	    catch it and adjust appropriately.


smei_sky_field $SMEI/ucsd/camera/idl/sky/smei_sky_field.pro
[Previous] [Next]
 NAME:
	smei_sky_field
 PURPOSE:
	Maps keywords to Fits extension numbers in the
	various types of SMEI skymaps
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	FUNCTION smei_sky_field, files, $

	    exten_no	= exten_no  , $

	    equatraw	= equatraw  , $ ; sky, equ
	    northraw	= northraw  , $ ; sky, equ
	    southraw	= southraw  , $ ; sky, equ

	    equatcnt	= equatcnt  , $ ; sky
	    northcnt	= northcnt  , $ ; sky
	    southcnt	= southcnt  , $ ; sky

	    equatflat	= equatflat , $ ;      equ
	    northflat	= northflat , $ ;      equ
	    southflat	= southflat , $ ;      equ

	    equatstars	= equatstars, $ ;      equ
	    northstars	= northstars, $ ;      equ
	    southstars	= southstars, $ ;      equ

	    dirtysky	= dirtysky  , $ ; sky		: SKYD__LO_SKY	= 1
	    orbtime	= orbtime   , $ ; sky, equ, ecl : SKYD__LO_TIME = 2
	    orbsecs	= orbsecs   , $ ; sky, equ, ecl : SKYD__LO_SECS = 9
	    psfn	= psfn	    , $ ; sky		: SKYD__LO_PSFN = 3
	    psfe	= psfe	    , $ ; sky		: SKYD__LO_PSFE = 4
	    badsky	= badsky    , $ ; sky		: SKYD__LO_CUT	= 5
	    badhtm	= badhtm    , $ ; sky		: SKYD__LO_FRAC = 6
	    fovx	= fovx	    , $ ; sky, equ	: SKYD__LO_FOVX = 10 Added in version 5.1
	    thetax	= thetax    , $ ; sky		: SKYD__LO_ROTX = 7
	    thetay	= thetay    , $ ; sky		: SKYD__LO_ROTY = 8
	    hits	= hits	    , $ ; sky, equ, ecl : SKYD__LO_HIT	= 11 Added in version 6.0
	    badpixels	= badpixels , $ ; sky

	    sunsky	= sunsky    , $ ;	    ecl: helioecliptic sky map
	    sunflat	= sunflat   , $ ;	    ecl: helioecliptic sky map (flat)
	    suntime	= suntime   , $ ;	    ecl: helioecliptic orbit fraction
	    sunsecs	= sunsecs   , $ ;	    ecl: helioecliptic orbit time
	    sunhits	= sunhits   , $ ;	    ecl: helioecliptic contr pix count

	    fullsky	= fullsky   , $ ;	    ecl: equatorial lores skymap
	    fullflat	= fullflat  , $ ;	    ecl: equatorial lores skymap (flat)

	    hires_map	= hires_map , $
	    lores_map	= lores_map , $
	    eclsun_map	= eclsun_map, $
	    frame_map	= frame_map , $
	    adus_map	= adus_map  , $
	    angle_map	= angle_map , $
	    cvsmei_mode = cvsmei_mode,$

	    droplist	= droplist  , $
	    count	= count     , $
	    map_types	= map_types

 INPUTS:
	files	    array[n]; type: string
			file names
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
	result	    array[n]; type: integer
			extension number (-1 if keyword does
			not match an extension number)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, SyncArgs, SyncDims, smei_filename
 CALLED BY:
	qImage_cw_Property, qImage_cw_Where, qsmei_sky, qsmei_sky_pick, smei_sky
	smei_sky_atlocation, smei_sky_read, smei_sky_track
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2008, Paul Hick (UCSD/CASS)
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keywords /sun*


smei_sky_getmask $SMEI/ucsd/camera/idl/sky/smei_sky_getmask.pro
[Previous] [Next]
 NAME:
	smei_sky_getmask
 PURPOSE:
	Get SMEI mask at specified time and sky location(s)
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	FUNCTION smei_sky_getmask, ut, ra, dec, $
	    equator = equator	, $
	    degrees = degrees	, $
	    scalar  = scalar	, $
	    silent  = silent
 INPUTS:
	ut	array[1]; type: time structure or valid time string
	ra	array[n]; type: float
		    right ascensions or ecliptic longitudes
	dec	array[m]; type: float
		    equatorial declinations or ecliptic latitudes
 OPTIONAL INPUT PARAMETERS:
	/equator    if set, ra,dec are intepreted as equatorial coordinates
		    (default: ecliptic coordinates)
	/degrees    if set, all angles are in degrees (default: radians)
	/scalar     if set, a single position is returned as a scalar
		    instead of a 1-element array
	silent=silent	scalar; type: integer
		    larger numbers suppress more messages.
 OUTPUTS:
	R	array[n.m]; type: float
		    mask values
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, CvSky, FILEPATH, InitVar, IsType, READFITS, TimeGet, TimeUnit, cvsmei, gridgen
	hide_env, smei_filename, smei_filepath
 CALLED BY:
	vu_coronagraph, vu_earthskymap
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_sky_grd2fts $SMEI/user/pphick/idl/smei_sky_grd2fts.pro
[Previous] [Next]
 NAME:
	smei_sky_grd2fts
 CALLING SEQUENCE:
	PRO smei_sky_grd2fts, f
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FXADDPAR, InitVar, IsType, MKHDR, REVERSE, WRITEFITS, grd_read


smei_sky_hdr2mode $SMEI/ucsd/camera/idl/sky/smei_sky_hdr2mode.pro
[Previous] [Next]
 NAME:
	smei_sky_hdr2mode
 PURPOSE:
	Determines value of skymap 'mode' from Fits header
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	FUNCTION smei_sky_hdr2mode, hdr
 INPUTS:
	hdr	array[1]; type structure
 OUTPUTS:
	R	scalar; type: string
		    one of ['npmap','spmap','eqmap','lores']
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FXPAR, IsType
 CALLED BY:
	smei_sky_atlocation, smei_sky_read
 PROCEDURE:
	Usually used to determine the value for the 'mode'
	keyword for cvsmei.
 MODIFICATION HISTORY:
	MAR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_sky_hdr2range $SMEI/ucsd/camera/idl/sky/smei_sky_hdr2range.pro
[Previous] [Next]
 NAME:
	smei_sky_hdr2range
 PURPOSE:
	Determines break values for display of skymaps from Fits header
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	FUNCTION smei_sky_hdr2range, hdr, difference=difference, degrees=degrees
 INPUTS:
	hdr	array[1]; type structure
 OUTPUTS:
	R	array; type: float
		    array[3]
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, FXPAR, InitVar, IsType, ToDegrees
 CALLED BY:
	smei_sky
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2008, Paul Hick (UCSD/CASS)
	DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added ranges for star-subtracted maps in equ files, and
	    helioecliptic maps in ecl files.


smei_sky_hdr__define $SMEI/ucsd/camera/idl/sky/smei_sky_hdr__define.pro
[Previous] [Next]
 NAME:
	smei_sky_hdr__define
 PURPOSE:
	Defines hdr structure or skymaps
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	PRO smei_sky_hdr__define
 INPUTS:
	(none)
 OUTPUTS:
	(none)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL BY:
	smei_sky_read
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS)
	    Extracted from smei_sky_read
	JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added ccd_mode (is filled only when reading
	    a hires equatorial map.


smei_sky_hdr_check $SMEI/ucsd/camera/idl/sky/smei_sky_hdr_check.pro
[Previous] [Next]
 NAME:
       smei_sky_hdr_check
 PURPOSE:
       Align sky map headers for various routines
 CATEGORY:
       camera/idl/sky
 CALLING SEQUENCE:
PRO smei_sky_hdr_check, hdrs, hdr
 INPUTS:
       hdrs	structure; type: smei_sky_hdr
	hdr	structure; type: smei_sky_hdr

 OUTPUTS:
       hdrs=hdrs       structure or array; type: smei_sky_hdr

 INCLUDE:
	@compile_opt.pro		; On error, return to caller
 CALLS: ***
	boost
 CALLED BY:
	smei_sky
 PROCEDURE:
	smei_sky_hdr_check, hdrs, hdr
	       two headers to be compared
 MODIFICATION HISTORY:
       FEB-2010, John Clover (UCSD/CASS)
	    Compares two hdr structures for matching cameras and
	    returns them with the same dimensions
	    Still ignorant of modes, and prefers c3 to c3s unless
	    /prefer_smoothdark was used in caller (smei_sky)


smei_sky_read $SMEI/ucsd/camera/idl/sky/smei_sky_read.pro
[Previous] [Next]
 NAME:
	smei_sky_read
 PURPOSE:
	Reads orbital skymaps
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	FUNCTION smei_sky_read, wanted_map, $
	    source	= source    , $
	    nbin	= nbin	    , $
	    silent	= silent    , $

	    xgrid	= xgrid     , $
	    ygrid	= ygrid     , $
	    xedge	= xedge     , $
	    yedge	= yedge     , $

	    degrees	= degrees   , $

	    hdrs	= hdrs	    , $
	    fixgain	= fixgain   , $
	    rmbkgnd	= rmbkgnd   , $
	    rmzld	= rmzld     , $
	    exten_no	= exten_no  , $

	    use_flat	= use_flat  , $
	    use_stars	= use_stars , $

	    num 	= num	    , $
	    _extra	= _extra
 INPUTS:
	wanted_map	scalar, array[1]; type: numerical, time structure, or string
			    indicates the orbit(s) to be processed
			    (passed to smei_getfile together with _extra).
 OPTIONAL INPUT PARAMETERS:
	source=source	scalar; type: string
			    source directory for skymaps
	(the following keywords are processed by smei_sky_field)

	/equatraw
	/northraw
	/southraw
	/equatflat
	/northflat
	/southflat
	/equatcnt
	/northcnt
	/southcnt
	/equatstars
	/northstars
	/southstars
	/dirtysky
	/orbtime
	/orbsecs
	/psfn
	/psfe
	/badsky
	/badhtm
	/fovx
	/thetax
	/thetay
	/hit
	/badpixels
			if none of these map types is selected then the hires maps
			(equatorial,south and north pole) are put together into a
			single equatorial map covering [-90,+90] degrees declination.
			Note that this option also handles skymaps that contains
			a single equatorial map covering the full latitude range.

	nbin		scalar; type: integer; default: 5
			    rebinning factor applied to high-resolution maps.
			    A rebinning with factor 5 results in maps
			    with 5 deg bins in RA and Dec.

	/fixgain	if set then sky brightnesses are corrected for changing
			camera gain (see smei_camera_gain)

	/use_flat	if set for 'equ' and 'ecl' files then the
			maps with subtracted stars replaced by a flat background
			are used
 OUTPUTS:
	Result		array; type: float
			    skymap (-1 if no skymap was read)
 OPTIONAL OUTPUT PARAMETERS:
	orbit		scalar; type: integer
			    actual orbit number used
	xgrid		horizontal grid (bin centers)
	ygrid		vertical grid (bin centers)
	xedge		horizontal grid (bin edges)
	yedge		vertical grid (bin edges)

	num=num 	array; type: integer
			    array of same size as returned skymap
			    Contains 1,2 or 3 identifying camera
			    that observed correspondig skybin
			    (contains 0 where skymap is empty).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, BadValue, FILEPATH, FXPAR, HEADFITS, InitVar, IsType, MEAN, READFITS
	TimeOp, TimeSet, ToDegrees, ToRadians, boost, cvsmei, destroyvar, gridgen, hide_env
	smei_camera_gain, smei_filename, smei_filepath, smei_getfile, smei_sky_field
	smei_sky_hdr2mode, smei_zld_model
 EXTERNAL:
	smei_sky_hdr__define
 CALLED BY:
	smei_getfile, smei_sky
 PROCEDURE:
	Way too complicated.
 MODIFICATION HISTORY:
	DEC-2004, Paul Hick (UCSD/CASS)
	JUL-2006, Paul Hick (UCSD/CASS)
	    Added /fovx to extract Fits extension containing direction cosine
	    angle in long dimension. If the extension is not present then an
	    array with value of 15 degree everywhere is returned.
	DEC-2007, Paul Hick (UCSD/CASS)
	    Added keyword /fixgain
	APR-2008, Paul Hick (UCSD/CASS)
	    Added keyword /rmbkgnd and /rmzld to be able to remove
	    sidereal background and zodiacal light distribution.
	MAY-2008, Paul Hick (UCSD/CASS)
	    Bugfixes in ZLD removal (missing degrees=degrees).
	JUN-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added "num" keyword


smei_sky_testcase $SMEI/ucsd/camera/idl/toolbox/smei_sky_testcase.pro
[Previous] [Next]
 NAME:
	smei_sky_testcase
 PURPOSE:
 CATEGORY:
 CALLING SEQUENCE:
	PRO smei_sky_testcase
 INPUTS:
 OUTPUTS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXPAR, InitVar, READFITS, WhatIs, hide_env, who_am_i
 PROCEDURE:
 MODIFICATION HISTORY:
	DEC-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_sky_track $SMEI/ucsd/camera/idl/sky/smei_sky_track.pro
[Previous] [Next]
 NAME:
	smei_sky_track
 PURPOSE:
	Track location on sky
 CATEGORY:
	camera/idl/sky
 CALLING SEQUENCE:
	PRO smei_sky_track, wanted_map	, $
	    body	= body		, $
	    degrees	= degrees	, $
	    rmbkgnd	= rmbkgnd	, $
	    rmzld	= rmzld 	, $
	    range	= range 	, $
	    destination = destination	, $
	    equator	= equator	, $
	    fix_sun	= fix_sun	, $
	    step	= step		, $
	    rm_min_count= rm_min_count	, $
	    _extra	= _extra
 INPUTS:
	wanted_map	scalar, array[1]; type: numerical, time structure,
			    or string
			    indicates the orbit(s) to be processed
			    (passed to smei_getfile together with _extra).
 OPTIONAL INPUT PARAMETERS:
	body=body	array[2], type: float
			    ecliptic or equatorial coordinates
			    of fixed point on sky
			scalar; type: string
			    name of one of the bodies for which
			    an ephemeris is available from big_eph
	/degrees	if set, all angles are in degrees
			    (default: radians)
	/rmbkgnd	if set, subtract sidereal background
			    (for 'sky' maps this is SET by default;
			    for 'equ' map this is NOT set by default)
	/rmzld		if set, subtract zodiacal light distribution
			    by default this is SET for both 'sky'
			    and 'equ' maps
	range=range	array[2]; type: float;
			    default: [-30,390] for 'sky' maps;
				     [-10, 10] for 'equ' maps
			    brightness range in ADUS
	destination=destination
			name of existing directory. If set this is
			    where gif images will be written
	/equator	keep horizontal parallel to equatorial plane
			    (default: parallel to ecliptic plane)
	/fix_sun	if set the direction to the Sun is kept on
			    the x-axis (left in a fish-eye plot)
	step=step	scalar; type: integer; default: 1
			    step size for processing the selected
			    map: only one of every 'step' maps is processed
	rm_min_count=rm_min_count
			scalar; type: integer: default: 0
			the first 'rm_min_count' maps are used to create
			a 'minimum skymap'. The minimum map is then
			subtracted from the displayed map for all subsequent
			skymaps.
	_extra=_extra
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleUnits, BadValue, CheckDir, FILEPATH, FXPAR, InitVar, IsType, READFITS, SuperArray
	TimeGet, TimeOp, TimeSet, TimeUnit, ToDegrees, ToRadians, UNIQ, big_eph, cvsmei, jpl_body
	smei_filename, smei_getfile, smei_orbit_get, smei_orbit_set, smei_sky
	smei_sky_field, smei_star_info
 CALLED BY:
	smei_star_show
 PROCEDURE:
	mei_sky_track,dest=getenv('PWD'),mode='equ',maxelo=10,/deg, $
	    chars=1.2,range=[-8,29.9],xysize=[400,400],nbin=1, /use_flat
 MODIFICATION HISTORY:
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star__define $SMEI/ucsd/camera/idl/star/smei_star__define.pro
[Previous] [Next]
 NAME:
	smei_star__define
 PURPOSE:
	Defines structure to store fit parameters for stars
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star__define
 INPUTS:
	(none)
 OUTPUTS:
	(none)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL BY:
	smei_star_fit
 RESTRICTIONS:
	If this structure is modified then the format statements in
	smei_star_formatpnt need to be updated accordingly.
 PROCEDURE:
	The standard star is defined as a 200 x 200 array with bins
	of 0.025 x 0.025 degrees (5 x 5 degree total).
	The skymaps have bins of 0.1 x 0.1 degrees.

	When a star is fitted to the 'standard star' locations in
	a box of 50 x 50 bins (5 x 5 degrees) around the star are mapped into the
	'standard star' map where 'standard brightnesses' are determined
	by linear interpolation on the 'standard star' array. Fitting
	the star involves matching observed 50 x 50 observed skymap brightnesses
	against the 50 x 50 'standard brightnesses'.

	The fit is done using skybins inside an area defined by the core PSF, and
	(if wing_radius is used, instead of bkgnd_radius) additional bins
	extending out to the selected wing_radius).

	Let there be 'n' 0.1 x 0.1 bins in the skymap inside the (extended) PSF,
	and let the skymap brightness in these bins be
	(1)	v(i)			i=1,n
	These values can be symbolically represented as:
	(2)	v(i) = a(i) + I(i)	i=1,n
	where a(i) is the background component, and I(i) the brightness
	attributed to the star.

	The locations in the skymap are mapped into the 'standard star' reference
	frame. By linear interpolation the 'standard brightnesses' are:
	(3)	I_std(i)	i=1,n

	The fitting procedure generates an lsq 'model' for the star from
	'standard star' values:
	(4)	v_model(i) = A(i) + B * I_std(i)

	Here A(i) represents a planar fit to  the background, and B is the
	star brightness normalized to the 'standard star' brightness.
	These fit quantities are stored in structure tags:
		back_const
		back_slope
		bright

	Let the extended PSF, mapped to the 'standard star' reference frame,
	cover a total of 'N' 0.025 x 0.025 bins and let the 'standard
	brightness' in these bins be
	(5)	J_std(N)	i=i,N

	The total number of ADUs in this area then is
	(6)	T(std) = Sum(i=1,N) {J_std(i)}

	A similar sum can be defined from (3), based on 0.1 x 0.1 deg bins:
	(7)	U(std) = Sum(i=1,n) {I_std(i)}

	Since
	(8)	N = (0.1/0.025)^2 x n = 16 x n
	it follows
	(9)	U(std) = T(std)/16
	or
		U(std) x 0.1^2 = T(std) x 0.025^2

	The quantity T(std) x 0.025^2 is stored in the structure tag 'total_adus'.
	It is calculated in smei_star_stdmaps in the 'standard star'
	reference frame (the right side of Eq. (9)).

	There are two indirect ways to calculate the quantity 'B' in (4).
	The first one is fairly trivial. v_model in Eq (4) is calcaluted as a
	50 x 50 array, matching the box in the skymap. Looking at Eqs. (4)
	and (9):
	(10)	B1 = Sum(i=1,n) {v_model(i)-A(i)) / U(std)

	The second is an estimate based on the actual data 'v(i)' in Eq. (1),
	and assuming that the fit worked:

	(11)	Sum(i=1,n) {v(i)} = Sum(i=1,n) {v_model(i)}

	From (10) and (11) it follows:

	(12)	B2 = Sum(i=1,n) {v(i)-A(i)} / U(std)

	B1 is stored in tag 'bright_mdl'; B1 is stored in tag 'bright_raw'.

	If the bins used in the lsq fit would be the same set of bins used
	to calculate the sum in Eq. (10), then B1 would be identical to
	B in Eq. (4). For a number of reasons only a subset of the bins in
	Eq (1) are actually used in the lsq fit. So B1 and B will not be
	identical.

	B2 in some sense is an indicator of the quality of the lsq fit. For
	a perfect fit, B2 would be the same as B (Eq. 4). In reality, there
	are systematic differences between B2 and B that are not understood.
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS)
	    Extracted from smei_star_fit
	NOV-2006, Jordan Vaughan (UCSD; jtvaugha@ucsd.edu)
	    Added gain field to stars_fit
	MAY-2007, Paul Hick (UCSD/CASS)
	    Changed scalar fovxangle to 2-element array fovangle
	    Added 2-element array dfovangle
	JUL-2007, Paul Hick (UCSD/CASS)
	    Added psfstretch, renamed dfovangle to dpsfstretch
	FEB-2008, Paul Hick (UCSD/CASS)
	    Added "remove" entry.
	NOV-2011, Paul Hick (UCSD/CASS)
	    Expanded information in header considerably.
	JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added structure key 'total_area'


smei_star_alias $SMEI/ucsd/camera/idl/star/smei_star_alias.pro
[Previous] [Next]
 NAME:
	smei_star_alias
 PURPOSE:
	Translates aliases for star names to catalogue names
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_alias, alias
 INPUTS:
	alias		    scalar or array; type: string
				star alias
 OUTPUTS:
	smei_star_alias     same dimensions as 'alias'; type: string
				name from SMEI catalogue
				if the alias is not known the input
				value is left unchanged.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	where_common
 CALLED BY:
	big_eph, smei_star_fitone, smei_star_list, smei_star_show
 EXAMPLE:
	    name = smei_star_alias('Sirius')
	returns
	    name = 'HD 48915'
 PROCEDURE:
	List of aliases and real names are hardcoded
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_box $SMEI/ucsd/camera/idl/star/smei_star_box.pro
[Previous] [Next]
 NAME:
	smei_star_box
 PURPOSE:
	Set up box around star centroid of about the same
	size as the standard star map.
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_box, $
	    fullmap , $
	    maptype , $
	    std_ndim, $
	    ndim    , $
	    xystar  , $
	    ibeg    , $
	    iend    , $
	    jbeg    , $
	    jend    , $
	    rr	    , $
	    ibeg0=ibeg0, $
	    jbeg0=jbeg0
 INPUTS:
	fullmap 	    scalar; type: integer
				1 if array size 'ndim' is for a full skymap
				0 if not.
				Matters only for equatorial maps (maptype=0). For
				full maps, if the box around the stars partly falls
				outside the map (RA < 0 or RA > 360) then the box
				can be filled using the opposite side of the map.
	maptype 	    scalar; type: integer
				-1: south-polar map
				 0: equatorial map
				 1: north-polar map
				Only used to test for equatorial map (for full maps,
				see description of 'fullmap' argument.
	std_ndim	    array[2]; type: integer
				size of the standard star map (50x50)
	ndim		    array[2]; type: integer
				size of the skymap
	xystar		    array[2]; type: double
				array indices into the skymap (of size 'ndim')
				of the star centroid
 OUTPUTS:
	result		    array[m], m <= std_ndim[0]; type: integer
				see PROCEDURE
	ibeg		    scalar; type: integer
	jbeg		    scalar; type: integer
				horizontal and vertical index values in the
				returned 'rr' array for the lower-left corner
	iend		    scalar; type: integer
	jend		    scalar; type: integer
				same for the upper-right corner
	rr		    array[2,n], n <= std_ndim[0]*std_ndim[1]; type: double
				see PROCEDURE
 OPTIONAL OUTPUT PARAMETERS:
	ibeg0=ibeg0	    scalar; type: integer
	jbeg0=jbeg0	    scalar; type: integer
				horizontal and vertical index values in 'rr' for
				the lower-left corner before rows/columns
				outside the map were truncated.
				ibeg0=ibeg and jbeg0=jbeg if the lower-left corner
				of the 'std_ndim' sized box lies inside the map;
				if not then at least one of ibeg0 or jbeg0 will
				be an invalid negative index into the skymap.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	gridgen
 CALLED BY:
	smei_star_corepsf, smei_star_fit
 PROCEDURE:
	rr[2,n] provides horizontal (xx[0,*]) and vertical (xx[1,*]) indices into
	a skymap of dimensions 'ndim' for a square box of skylocations centered on
	the star centroid 'xystar'. The size of the box is usually 'std_ndim', but is
	smaller if part of the box falls outside the skymap.

	result[n] is an array of horizontal indices into the skymap across the box.

	If the whole box of size 'std_ndim' lies inside the skymap then
	rr[2,n] gives locations for a box of size `std_ndim`; result[n] is of size
	std_ndim[0]: result = reform(rr[0,std_ndim[0]) (i.e. a monotonic increasing
	sequence for the horizontal locations of the bottom row of the box).

	If part the box of size 'std_ndim' sticks out 'above' or 'below' of the map,
	then the rows outside the map are removed and only coordinates of rows
	inside the map are returned in rr[2,n]; n=nx x ny with ny < std_ndim[1].

	If part of the box of size 'std_ndim' sticks out 'left' or 'right' of the map
	then, for polar maps (maptype=+/-1) and for incomplete (fullmap=0) equatorial
	(maptype=0) maps, the columns outside the map are remove, and only coordinates
	for columns inside the map are returned in rr[2,n]; n = nx x ny with nx < std_ndim[0].
	In this case it is still true result[nx] = rr[0:nx-1] (i.e. still a monotonic
	increasing sequence of horizontal locations of the bottom row of the box.

	For a complete (fullmap=1) equatorial (maptype=0) map, instead of truncating
	columns from the box of size 'std_ndim' that extend below RA=0 or above RA=360,
	the columns 'outside' the map are filled in by picking up colmns from the
	opposite side of the map. In this case rr[2,n]; n=nx x ny with nx=std_ndim[0], and
	result[nx] with nx=std_ndim[0]. rr[2,n] will contain invalid horizontal
	indices for the columns outside the map. However, the locations in result[nx]
	have been adjusted to reflect the 'wrap'-operation, and will contain valid
	horizontal indices only. This 'result' array should be used by caller to index
	the skymaps.
 MODIFICATION HISTORY:
	JUL-2007, Paul Hick (UCSD/CASS)
	FEB-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added documentation


smei_star_cleanlist $SMEI/ucsd/camera/idl/star/smei_star_cleanlist.pro
[Previous] [Next]
 NAME:
	smei_star_cleanlist
 CALLING SEQUENCE:
	PRO smei_star_cleanlist
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	txt_read


smei_star_cleanup $SMEI/ucsd/camera/idl/star/smei_star_cleanup.pro
[Previous] [Next]
 NAME:
	smei_star_cleanup
 PURPOSE:
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_cleanup, file, silent=silent
 INPUTS:
 OPTIONAL INPUTS:
 OUTPUTS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	GetFileSpec, SFLOAT, boost, flt_format, hide_env, smei_star_formatpnt
	smei_star_info, smei_star_list, smei_star_standard, txt_read
 PROCEDURE:
 MODIFICATION HISTORY:


smei_star_corepsf $SMEI/ucsd/camera/idl/star/smei_star_corepsf.pro
[Previous] [Next]
 NAME:
	smei_star_corepsf
 PURPOSE:
	Create a skymap identifying the bins lying
	inside the "core" PSF for the specified stars
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_corepsf, $
	    fullmap   , $
	    camera    , $
	    maptype   , $
	    origin    , $
	    scale     , $
	    sky_ndim  , $
	    std_ndim  , $
	    ndim      , $
	    nvalid    , $
	    valid     , $
	    stars_list, $
	    stars_fit , $
	    xystar    , $
	    rastar    , $
	    degrees	    = degrees	    , $
	    use_filled_psf  = use_filled_psf, $
	    wing_radius     = wing_radius   , $
	    magnify	    = magnify
 INPUTS:
	fullmap     scalar; type: integer
			1 if array size 'ndim' is for a full skymap
			0 if not
			passed to smei_star_box
	camera	    scalar; type: integer
			camera number (1,2,3)
	maptype     scalar; type: integer
			-1: south-polar map
			 0: equatorial map
			 1: north-polar map
			passed to smei_star_box and smei_star_stdmaps
	origin	    array[2]
			passed to smei_star_stdmaps
	scale	    scalar
			passed to smei_star_stdmaps
	sky_ndim    array[2]; type: integer
			size of output array 'result'
			(usually the same as 'ndim' ????)
	std_ndim    array[2]; type: integer
			size of standard star map (50x50)
			passed to smei_star_box
	ndim	    array[2]; type: integer
			size of full skymap (see also 'fullmap')
	nvalid	    scalar; type: integer
			number of stars in 'valid' (i.e. n_elements(nvalid))
	valid	    array[nvalid]; type: integer
			(if nvalid=0 then valid=-1)
			indices into the star arrays (stars_list, stars_fit, xystar
			and rastar). Only stars in these arrays with indices
			valid[i], i=nvalid-1,0,-1 are processed
	stars_list  array[n]; type: structure
			contains general star info; only SMEI magnitude is used)
	stars_fit   array[n]; type: structure
			contains skymap dependent star info; only psfangle and
			fovangle are used.
	xystar	    array[2,n]
			star centroids as indices into skymap of size 'ndim'
	rastar	    array[2,n]
			star centroids in RA and dec
 OPTIONAL INPUT PARAMETERS:
	/degrees
	/use_filled_psf
		    passed to smei_star_stdmaps
	wing_radius = wing_radius
		    passed to smei_star_stdmaps
	magnify     = magnify
		    scalar; type: float; default: 0.0
			    some sort of offset applied to cos(fovangle)
 OUTPUTS:
	results     array[sky_ndim[0],sky_ndim[1]]; type: float
			    skymap where the location of bright stars are marked
			    with there SMEI magnitude (see PROCEDURE).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, ToRadians, smei_star_box, smei_star_info, smei_star_stdmaps
 CALLED BY:
	smei_star_fit
 PROCEDURE:
	The returned skymap is initialized to SMEI magnitude 100.
	Then all stars in the 'valid' list are processed from faintest
	to brightest star (as indicated by the SMEI magnitude in the
	'star_list' structure. For each star all skybins in the 'core' PSF
	(as determined by smei_star_stdmaps) are set to the SMEI magnitude.
	Note that in overlapping PSF cores, the brightest magnitude will win.
 MODIFICATION HISTORY:
	JUL-2007, Paul Hick (UCSD/CASS)
	FEB-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added documentation. Changed top_mags from 10 to 100.
	    The earlier value caused problem when fitting faint stars
	    that were given the wrong SMEI magnitude in the star catalogues.


smei_star_enough_bins $SMEI/ucsd/camera/idl/star/smei_star_enough_bins.pro
[Previous] [Next]
 NAME:
	smei_star_enough_bins
 PURPOSE:
	Used in smei_star_fit.pro to test whether the lsq fit
	for a star needs to be executed or not.
 CATEGORY:
	ucsd/camera/idl/stars
 CALLING SEQUENCE:
	FUNCTION smei_star_enough_bins,       $
	    fit_bkgnd			    , $
	    n_fitpsf			    , $
	    n_bkgnd			    , $
	    min_psf_bins    = min_psf_bins  , $
	    min_bkgnd_bins  = min_bkgnd_bins
 INPUTS:
	fit_bkgnd   scalar; type: integer
			0: background and PSF fitted simultaneously
			1: background fitted simultaneously from PSF
	n_fitpsf    scalar; type: integer
			number of sky bins in PSF
	n_bkgnd     scalar; type:integer
			number of sky bins in background area
			(only relevant if fit_bkgnd=1)
 OPTIONAL INPUT PARAMETERS:
	min_psf_bins   = min_psf_bins
		    scalar; type: integer; default: 25
			lower limit on number of sky bins in PSF needed
			for lsq fit to proceed
	min_bkgnd_bins = min_bkgnd_bins
		    scalar; type: integer; default: 5
			lower limit on number of background bin needed
			for lsq fit to proceed
 OUTPUTS:
	result	    scalar; type: integer
			0: do not do lsq fit
			1: proceed with lsq fit
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar
 CALLED BY:
	smei_star_fit
 MODIFICATION HISTORY:
	APR-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_filename $SMEI/ucsd/camera/idl/star/smei_star_filename.pro
[Previous] [Next]
 NAME:
	smei_star_filename
 PURPOSE:
	Construct file name from star name, and v.v.
 CATEGORY:
	ucsd/camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_filename, star, reverse=reverse
 INPUTS:
	star	    array; type: string
		    star name, or file name (if /reverse SET)
 OPTIONAL INPUT PARAMETERS:
	/reverse    if set, reverse translation
		(from file name back to star name)
 OUTPUTS:
	result	    array; type: string
		    file name, or star name (if /reverse SET)
		    File names are 12 chars long
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar
 CALLED BY:
	smei_star_fitone, smei_star_show, smei_star_writepnt
 PROCEDURE:
 MODIFICATION HISTORY:
	DEC-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_fit $SMEI/ucsd/camera/idl/star/smei_star_fit.pro
[Previous] [Next]
 NAME:
	smei_star_fit
 PURPOSE:
	Fit bright stars in sky map
 CATEGORY:
	ucsd/camera/idl/stars
 CALLING SEQUENCE:
	PRO smei_star_fit, file 	, $

	    hdr 	= hdr		, $
	    sky 	= sky		, $

	    camera	= camera	, $
	    ccd_mode	= ccd_mode	, $
	    origin	= origin	, $
	    scale	= scale 	, $
	    southpole	= southpole	, $
	    northpole	= northpole	, $

	    torigin	= torigin	, $
	    time_map	= time_map	, $
	    psf_map	= psf_map	, $
	    fovx_map	= fovx_map	, $
	    nofovx	= nofovx	, $

	    stime	= stime 	, $
	    etime	= etime 	, $

	    final_sky	= final_sky	, $
	    flat_sky	= flat_sky	, $

	    star_sky	= star_sky	, $
	    star_fit	= star_fit	, $
	    star_info	= star_info	, $

	    count	= count 	, $

	    upto_mags	= upto_mags	, $

	    bkgnd_origin= bkgnd_origin	, $
	    bkgnd_radius= bkgnd_radius	, $
	    bkgnd_count = bkgnd_count	, $

	    wing_origin = wing_origin	, $
	    wing_radius = wing_radius	, $
	    auto_wing	= auto_wing	, $

	    star_list	= star_list	, $
	    star_remove = star_remove	, $
	    star_index	= star_index	, $

	    catalogues	= catalogues	, $
	    degrees	= degrees	, $

	    kill_one	= kill_one	, $
	    fix_centroid= fix_centroid	, $
	    fix_fovangle= fix_fovangle	, $
	    fix_psfangle= fix_psfangle	, $
	    fix_pattern = fix_pattern	, $

	    noplane	= noplane	, $
	    noyzero	= noyzero	, $
	    use_filled_psf=use_filled_psf,$
	    use_weights = use_weights	, $
	    weights	= weights	, $

	    skip_dist	= skip_dist	, $
	    incl_dist	= incl_dist	, $
	    max_stars	= max_stars	, $

	    badfit	= badfit	, $
	    show	= show		, $

	    area_show	= area_show	, $
	    max_show	= max_show	, $
	    min_show	= min_show	, $

	    silent	= silent	, $

	    sigma	= sigma 	, $

	    magnify	= magnify	, $
	    ;no_stars_mask  = no_stars_mask  , $
	    no_corepsf_mask = no_corepsf_mask, $

	    rmbkgnd	= rmbkgnd	, $
	    rmzld	= rmzld 	, $

	    known_stars = known_stars	, $
	    known_names = known_names	, $
	    known_mags	= known_mags

 INPUTS:
	file			scalar; type; string
				    fully-qualified file name of sky map
 OPTIONAL INPUT PARAMETERS:
	/degrees		if set then all angles are in degrees (default: radians)

	hdr=hdr 		array[1]; type: structure
				    sky map header
	sky=sky 		array[n,m]; type: float
				    2D sky map

	camera=camera
	ccd_mode=ccd_mode
	origin=origin
	scale=scale

	/southpole		if set, then fit stars in north polar map
	/northpole		if set, then fit stars in south polar map
				    By default stars are fit in the equatorial map

	star_list=star_list	array; type: SMEI_STAR_LIST structure
				    list of stars to be fitted
				    These can be extracted from the SMEI
				    star catalogues with smei_star_list.
				array: type: string
				    alternatively a list of star names are specified
				    A call to smei_star_list is made to convert
				    the list to a SMEI_STAR_LIST structure
	catalogues=catalogues	scalar or array; type: string;
				    list of star catalogues to be used
				    Passed to  smei_star_list.
				    NOT used if keyword star_list is set.
	upto_mags=upto_mags	scalar; type: float; default: 6.0
				    maximum SMEI magnitude; only stars
				    brighter than this are removed.
				    All other objects are fitted, but NOT removed
				    from the skymaps
	bkgnd_origin=bkgnd_origin
				array[2]; type: float
				    eventually processed by smei_star_standard.
	bkgnd_radius=bkgnd_radius
				scalar or array[2]; type: float
				    eventually processed by smei_star_standard.
	bkgnd_count=bkgnd_count
				scalar; type: float (<= 1.0) or integer (> 1)
				    passed to smei_star_lsqbins.

	wing_origin=wing_origin array[2]; type: float
				    eventually processed by smei_star_standard.
	wing_radius=wing_radius array[2]; type: float
				    eventually processed by smei_star_standard.
	/auto_wing		if set, then wing_radius varies with the SMEI magnitude as
				    wing_radius+0.1*(3-m_SMEI) degrees
				i.e. the wing radius is smaller for fainter stars by
				one high-res skybin (0.1 degrees) per magnitude.
				wing_radius is set to 1.4 degrees if it is not defined.
				(note that smei_star_standard will prevent the
				wing_radius to drop below a minimum value though).
				This keyword was added for use in the SMEI pipeline only,
				to define a larger wing radius for very bright stars.
	/fix_centroid		if set, then the star centroid is included in the fit.
				    If multiple stars are fitted simultaneously then this will
				    adjust the centroid of the group of stars while keeping the
				    relative locations of the stars fixed (as implied by the
				    catalogue positions).
				    This keyword is primarily useful for correcting for pointing
				    errors, which affect all stars in a group in the same way.
	/fix_pattern		/fix_pattern implies /fix_centroid.
				    /fix_pattern has no effect for stars fitted individually.
				    if set, then for stars fitted simultaneously the centroids
				    of all stars in the group are adjusting individually
				    (changing the relative locations of the stars) to improve the fit.
	/fix_psfangle		if set, then the PSF angle is included in the fit
	/fix_fovangle		if set, then the direction cosine angles are included
				    in the fit.
				    (this slows down the star fitting considerably).

	/noplane		if set, suppress fit of planar background, and fit a
				   constant background instead (default: fit
				   planar background).
	/noyzero		passed to smei_star_lsqfit
	/use_filled_psf 	passed to smei_star_standard
	/use_weights		passed to smei_star_lsqfit

	weights=weights 	array[n,m]; type: float
				    Only used if /use_weights SET.
				    Weights to be used for skybins

	/no_corepsf_mask	by default, when a star is fitted, all skybins in the core PSF
				    of stars brighter then m_smei+2 are excluded from being
				    using in the fitting procedure.
				    Set this keyword to bypass this (bad idea!)

	/kill_one		by default, when multiple (nearby) stars are fitted simultaneously
				    all stars in the group are subtracted. If /kill_one is set the
				    group is fitted as a whole, but only the brightest star is subtracted
				    and the other stars will be fitted separately later.

	skip_dist=skip_dist	scalar; type: float; default: 0.25 degrees
				    nearby fainter stars at angular distances less
				    then 'skip_dist' away are not fit
	incl_dist=incl_dist	scalar; type: float; default: 0.75 degrees
				    nearby fainter stars at angular distances
				    less than 0.75 degrees (and more than /skip_dist)
				    are included when fitting a star.
	max_stars=max_stars	scalar; type: integer; default: 4
				    maximum number of stars fitted simultaneously.
				    If more than 'max_stars' stars pass the
				    'incl_dist' criterion, than only the
				    brightest 'max_stars-1' are included in the fit
				    (for a fit of max_stars stars).
	sigma=sigma		scalar; type: float
				    ?
	show=show		scalar; type: star
				    name of star for which results are displayed
				    This should be one of the names from the
				    SMEI star catalogue.
				    Set show='*' to display results for all stars
				    Five views of the star are displayed:
				    - the area around the star in the original skymap
				    - the same area after the fit is subtracted
				    - the same area with the PSF replaced by the fitted background
				    - the same area showing the bins used in the fit
				    - a scatter plot of model vs. data

	min_show		scalar or array[2]; type: numeric; default: none
	max_show		scalar or array[2]; type: numeric; default: none
				    when keyword 'show' is set the display is auto-scaled
				    by default. These two keywords can be used to
				    set the dynamic range. If a scalar is set then the
				    value is used for all three diplays of the area around the
				    star. If a 2-element array is specified then the
				    1st value is used for the first display (the original
				    skymap), and the 2nd is used for the two subtracted
				    displays.

	Sometimes it is convenient to be able to specify characteristics of certain 'known' stars,
	rather than fitting them. There are two mechanisms in place to do this.

	known_stars = known_stars
				array[3,*]; type: float
				    specifies RA, dec and SMEI magnitude of a list of 'known' stars.
				    These stars are removed from the map prior to fitting other
				    stars by subtracting the standard star multiplied by the SMEI
				    brightness (as determined by smei_i2m from the SMEI magnitude)
				    at the specified location in the skymap.
				    Note that it is the responsibility of the user to find the
				    correct location and SMEI magnitude of the star. Note also
				    that these star do not need to be in one of the SMEI
				    star catalogues.

	known_names		array; type: string
	known_mags		array, same size as 'known_names'; type: numeric
				    list of stars (catalogue names and SMEI magnitudes)
				    of stars for which the brightness is considered
				    known. The brightness for these stars is not fitted.
				    Typically used when a non-variable star (with known
				    brightness), intrudes on the location of a variable
				    star of interest. Both stars can be fit simultaneously,
				    while keeping the brightness of the non-variable star
				    fixed, i.e. only the background and brightness of the
				    variable star is fit.
 OPTIONAL OUTPUT PARAMETERS:
	count=count		scalar; type: integer
				    number of stars fitted (but not necessarily
				    subtracted)
				    count=0 if the skymap was not found or if
				    no stars with valid intensity or psf angle
				    were found.
				    If count=0 then star_fit will not exist.
	star_fit=star_fit	array[count]; SMEI_STAR_FIT structure
				    contains the fit results for all stars
	star_index=star_index	array[count]; integer
				    position of fitted star in original
				    star_list (useful only if star_list is
				    is one of the input arguments)
				    If count=0 then star_index = -1
	final_sky=final_sky	array[3600,1200] or array[800,800]
				    skymap with stars subtracted
	flat_sky=flat_sky	array[3600,1200] or array[800,800]
				    skymap with stars subtracted, but also with
				    the core PSF for each fitted star explicitly
				    replaced by the background model
	star_sky=star_sky	array[3600,1200] or array[800,800]
				    skymap containing the subtracted stars

				If there is a problem reading the skymap Fits files
				these variables will contain a scalar -1
				If count=0 then final_sky and sky will contain the
				unmodified input skymap, and star_sky will contain
				zeroes.

	area_show=area_show	array[50,50,4]; type: float
				    If keyword 'show' is used, this returns the content
				    of the the four displays showing the area around
				    the star (after applying the min_show and max_show
				    keywords). Note that only the last display is saved,
				    so this keyword only makes sense if a single star
				    is specified in the 'show' keyword.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, AngleUnits, BadValue, CORRELATE, FXPAR, HEADFITS, InitVar, IsTime, IsType
	MEAN, MagnifyArray, STDDEV, TimeGet, TimeLimits, TimeOp, TimeSet, TimeUnit, ToDegrees
	ToRadians, boost, cvsmei, destroyvar, hide_env, jpl_body, jpl_eph, jpl_mag
	smei_camera_gain, smei_coriolis, smei_i2m, smei_sky, smei_star_box
	smei_star_corepsf, smei_star_enough_bins, smei_star_formatpnt, smei_star_info
	smei_star_list, smei_star_lsqbins, smei_star_lsqfit, smei_star_standard
	smei_star_stdmaps, sphere_distance, twin, usno_body, usno_eph, view, where_common
 EXTERNAL:
	smei_star__define
 CALLED BY:
	smei_findpnt, smei_star_fitone, smei_star_remove
 PROCEDURE:
	The information needed for the star removal is:

	sky		2D-sky map
	map type	type of sky map (south pole, north pole, equatorial map)
	origin		array indices for RA=dec=0 (eq map) or indices of pole (polar map)
	resolution	number of degrees/radians per bin
	camera		SMEI camera (each camera has its own standard star map)

	psf_map 	equatorial 2D-sky map with rotation angles for the stars

	time_map	equatorial 2D-sky map with times (secs since start of orbit)

	This information can be supplied in a number of different ways:

	1. Set 'file' to the fully-qualified file name of a sky map
	    All information is extracted from the file by smei_sky.
	    Information in other keywords is ignored.
	    Note that by default the equatorial map is processed, unless
	    /southpole or /northpole is set.

	2. Set keyword 'hdr' to the header of a sky map previously read by
	    smei_sky. 'hdr' provides all the information needed,
	    include the map type (equatorial, south- or northpole).
	    The skymap itself can be supplied in keyword 'sky' (it probably
	    is available from the same smei_sky call that set 'hdr'. If absent
	    then the original skymap is read (the file name is in 'hdr').
	    All other keywords are ignored. The psf and time maps are always
	    read from file by smei_sky.

	3. Explicitly provide all information in the appropriate keywords.
	    Defaults are set to the values currently used for the sky maps
	    produced by smei_skyd.


	Stars are fitted and subtracted starting with the brightest stars
	and working down to the fainter stars down to the cutoff magnitude
	'upto_mags'.

	Groups of upto 'max_stars' stars are fitted simultaneously. This group
	is selected as follows:
	- the first star in the group is the brightest star in the sky
	  that has not been fit yet.
	- all stars within 'incl_dist' are added to the group
	- the same is done iteratively for stars added to the group in this
	  way: for each a neighbourhood of 'incl_dist' is searched, and if
	  stars are found these are added to the group
	- stop if no more stars are found within 'incl_dist' of any star
	  in the group, or if the group size exceeds 'max_crowd' members
	- pass through all group members in order of decreasing brightness
	  and remove fainter stars that lie within 'skip_dist'. These
	  stars are marked as "done" immediately.
	- only keep at most 'max_star' of the remaining stars are not
	  fitted on the assumption that its psf is indistinguishable from
	  the psf of the brighter star.

	The results of the fit are by default subtracted for all the stars
	in the group simultaneously. If /kill_single is set then only the
	fit for the bright star is subtracted. The fainter stars will be
	fitted again separately (after the bright star has been removed).

	By default a planar (sloped) background is fitted. If keyword
	/noplane is set then a constant background is fitted.

	By default the star locations in the SMEI star catalogue are used
	as fixed centroids. If keyword /fix_centroid is set then a brute
	force iteration scheme is used to improve the fit by fitting the
	centroid location also. This is mainly useful for detecting 'bad
	quaternion' episodes in the SMEI data. Setting /fix_centroids
	slows the program down considerably.

	Fitting of the plane background and the star brightnesses is done
	using linear least squares fits. lsqLinearFit implements fits
	upto four dimension as analytic expressions, allowing for fitting
	of two stars with a planar background of three stars with a constant
	background. For fits in more dimension a matrix inversion is used.

	The planets Mercury,Venus,Mars,Jupiter,Saturn and Uranus are
	subtracted using their apparent visual magnitudes to control
	the order of subtraction.

 MODIFICATION HISTORY:
	NOV-2005, Paul Hick (UCSD/CASS)
	FEB-2006, Paul Hick (UCSD/CASS)
	    Replaced keyword /plane by keyword /noplane. By default
	    a sloped background is fitted unless suppressed by /noplane.
	AUG-2006, Paul Hick (UCSD/CASS)
	    Keyword star_list can now also be a list of star names from
	    the SMEI catalogues.
	    If no stars are left to be fitted the procedure will now always
	    return with count=0 and final_sky and star_sky existing.
	    (it used to abort in some situations).
	SEP-2006, Paul Hick (UCSD/CASS)
	    Added /use_filled_psf keyword
	    Added star_info keyword
	NOV-2006, Jordan Vaughan (UCSD; jtvaugha@ucsd.edu)
	    Added gain field to star_fit
	    Set star_fit.close to '-' by default
	FEB-2007, Jordan Vaughan, Paul Hick (UCSD/CASS)
	    Added stars_mask array, passed to smei_star_stdmaps
	    to exclude skybins from previously-subtracted star
	    from the background skybins.
	APR-2007, Paul Hick (UCSD/CASS)
	    The lowres time map is now used as is (i.e. we do not
	    take the absolute value anymore).
	MAY-2007, Paul Hick (UCSD/CASS)
	    Added keyword fix_psfangle fix_fovangle
	    In the iterative fitting a point far away from the
	    current best fit is now used in an attempt to speed up
	    the iteration when the starting point is far away from
	    the correct solution (seems to be most useful if
	    keyword /fix_fovangle is set).
	JUN-2007, Paul Hick (UCSD/CASS)
	    Bug fix. psfwidth calculation for case with only one
	    skybin insided psf would crash.
	JUL-2007, Paul Hick (UCSD/CASS)
	    Substantial rewrite of section that selects the
	    group of stars to be fitted simultaneously.
	JAN-2008, Paul Hick (UCSD/CASS)
	    Modified storage of planet names in star_list
	    structure (left-adjusted, instead of right-adjusted)
	FEB-2008, Paul Hick (UCSD/CASS)
	    Added star_fit.remove entry.
	    Added USNO asteroids and the 'stars_not_subtracted'
	    catalogue to list of point sources. These are fitted but
	    not subtracted from the sky map.
	    Bug fix in calculation of psfwidth (sometimes gave NaN).
	MAR-2008, Paul Hick (UCSD/CASS)
	    Bugfix. The return arrays final_sky, flat_sky and
	    star_sky would not exist if count=0 (no stars subtracted).
	    Now final_sky and flat_sky contain the input map,
	    and star_sky contains zeroes.
	APR-2008, Paul Hick (UCSD/CASS)
	    Made sure that dradec is really zero when no centroid
	    fitting is done (used to be a really small number
	    sometimes instead of identical to zero).
	    Added keyword weights. Added keyword original_weights
	    to all smei_star_lsqfit calls.
	JUL-2008, Paul Hick (UCSD/CASS)
	    Added keyword /fix_pattern to allow adjusting of centroids
	    of individual stars when multiple stars are fitted
	    simulataneously.
	FEB-2010, Paul Hick (UCSD/CASS)
	    Added keyword area_show. Added documentation.
	    Fixed bug in processing of keyword star_list (would crash
	    if none of the stars on the list would be in one of
	    the selected SMEI star catalogues).
	JUN-2010, Paul Hick (UCSD/CASS)
	    Fixed bug in the construction of flat_sky array (pieces
	    of final_sky were erroneously copied into flat_sky)
	JUN-2010, John Clover (UCSD/CASS)
	    Bumped incl_dist to 1.0 degrees
	APR-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added more checks in the iteration procedures to pick up
	    cases where there are not enough bins left for an lsq fit
	    (also prevents crashes due to an 'array index out of
	    range' error on an empty index array when no bins are
	    left at all)


smei_star_fitone $SMEI/ucsd/camera/idl/star/smei_star_fitone.pro
[Previous] [Next]
 NAME:
	smei_star_fitone
 PURPOSE:
	Fit specified star(s) for all skymaps in specified
	time range, and write results to file
 CATEGORY:
	sat/idl/star
 CALLING SEQUENCE:
	PRO smei_star_fitone, name, tt	    , $
	    camera	    = camera	    , $
	    mode	    = mode	    , $
	    rmbkgnd	    = rmbkgnd	    , $
	    destination     = destination   , $
	    show_	    = show_	    , $
	    movie	    = movie	    , $
	    _extra	    = _extra
 INPUTS:
	name	scalar, array[n]; type: string; default: Sirius
		    name(s) of star
	tt	array[2]; type: time structure
		    time range
 OPTIONAL INPUT PARAMETERS:
	camera=camera
		scalar; type: integer
		    camera number (1,2,3)
	mode=mode
		scalar; type: string; default: 'sky'
		    skymap type: 'sky' or 'equ'
	/rmbkgnd
	destination=destination
		scalar; type: string; default: none
		    name of existing directory where output
		    file is written
	/movie	    if set, create an animated gif
		    (requires that 'destination' is set)
	_extra=_extra
		additional keywords for smei_star_fit
 OUTPUTS:
	(to file)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
	smei_star_fit__define
 CALLS: ***
	CheckDir, FILEPATH, GetFileSpec, InitVar, IsType, MagnifyArray, WhatIs, boost, mk_flick
	smei_getfile, smei_star_alias, smei_star_filename, smei_star_fit, smei_star_info
	smei_star_list, smei_star_writepnt
 EXAMPLE:
	smei_star_fitone,['V598 Puppis','HD 54153'],cat='*',skip_dist=0.1, /degrees,/fix_centroid,rmbkgnd = 0, $
	    known_stars=[106.51,-38.40,5.68]
 PROCEDURE:
 MODIFICATION HISTORY:
	SEP-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_formatpnt $SMEI/ucsd/camera/idl/star/smei_star_formatpnt.pro
[Previous] [Next]
 NAME:
	smei_star_formatpnt
 PURPOSE:
	Controls formatting of time series files
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_formatpnt	, $
	    get_titles	= get_titles	, $
	    get_format	= get_format	, $
	    get_timefmt = get_timefmt	, $
	    old_format	= old_format
 OUTPUTS:
	/get_titles	    if set then return string of column titles that preceeds the numbers
				in the time series files
	/get_format	    if set then return the format string used to write the smei_star_fit
				structures produced by smei_star_fit
	/get_timefmt	    if set then return the format used to write the time of observation
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar
 CALLED BY:
	smei_fixpnt, smei_star_cleanup, smei_star_fit, smei_star_readpnt
	smei_star_writepnt
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS)
       NOV-2006, Jordan Vaughan (UCSD; jtvaugha@ucsd.edu)
	    Added gain column to PNT titles, formatc, and format
	MAY-2007, Paul Hick (UCSD/CASS)
	    Modified to take changes in smei_star__define into
	    account (changed scalar fovxangle to 2-element
	    array fovangle; added dfovangle)
	JUL-2007, Paul Hick (UCSD/CASS)
	    Modified to take changes in smei_star__define into
	    account
	JAN-2008, Paul Hick (UCSD/CASS)
	    Fixed bug in format (star name has 12 chars, not 11)
	FEB-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added X column (point source removed from skymap)


smei_star_info $SMEI/ucsd/camera/idl/star/smei_star_info.pro
[Previous] [Next]
 NAME:
	smei_star_info
 PURPOSE:
	Retrieves info about stars from the SMEI star catalogue
 CATEGORY:
 CALLING SEQUENCE:
	FUNCTION smei_star_info, star, $
	    degrees	= degrees   , $
	    count	= count     , $
	    get_ra_dec	= get_ra_dec, $
	    rectangular = rectangular,$
	    get_struct	= get_struct, $
	    get_number	= get_number, $
	    get_name	= get_name  , $
	    get_obafg	= get_obafg , $
	    get_magv	= get_magv  , $
	    get_magb	= get_magb  , $
	    get_mags	= get_mags  , $
	    _extra	= _extra
 INPUTS:
	star		    array; type: structure
				smei_star_list structure returned by smei_star_list.
 OPTIONAL INPUT PARAMETERS:
	/get_number	    get number from smei catalogue
	/get_ra_dec	    get RA and declination (this is also the default)
	/get_name	    get ascii name for star
	/get_obafg	    get spectral class
	/get_magv	    get visual magnitude
	/get_magb	    get blue magnitude
	/get_mags	    get SMEI magnitude

	If 'star' does not exist on input, or is not specified then smei_star_list
	is called to read the star catalogues. All keywords to smei_star_list can be
	used to control which star catalogues are read.
 OUTPUTS:
	result		    array[2,*] or array[*]; type: depends on keywords
				if none of the /get* keywords is set then the
				equatorial location of the stars are returned in
				radians or degrees
				(depending on setting of /degrees keyword).
				array[0,*] is the right ascension
				array[1,*] is the declination

				Otherwise the quantity indicated by the get* keyword
				is returned.
 OPTIONAL OUTPUT PARAMETERS:
	star		    if 'star' does not exist on input then the result from a
			    call to smei_star_list is returned
	count=count	    # stars in 'star' structure
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleUnits, CV_COORD, InitVar, IsType, smei_star_list
 CALLED BY:
	PRO bolstrip, big_eph, qEphem_State, smei_findpnt, smei_fixpnt, smei_frm_where
	smei_sky_track, smei_star_cleanup, smei_star_corepsf, smei_star_fit
	smei_star_fitone, smei_star_list, smei_star_show, smei_star_test, stardistance
 PROCEDURE:
	Returns fields from the 'star' structure
 MODIFICATION HISTORY:
	FEB-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_list $SMEI/ucsd/camera/idl/star/smei_star_list.pro
[Previous] [Next]
 NAME:
	smei_star_list
 PURPOSE:
	Reads content of star catalogues used for star subtraction in SMEI frames
 CATEGORY:
	camera
 CALLING SEQUENCE:
	FUNCTION smei_star_list     , $
	    root	= root	    , $
	    silent	= silent    , $
	    count	= count     , $
	    name	= name	    , $
	    catalogues	= catalogues, $
	    get_format	= get_format, $
	    rmstar	= rmstar
 OPTIONAL INPUT PARAMETERS:
	root=root	scalar; type: string
			    directory where star catalogue files are located.
			    By default, this is the directory where this
			    file is located.
	name=name	array; type: string
			    list of star names; only the data for the
			    specified stars are returned. These MUST be names
			    present in the SMEI star catalogues.
	catalogues	scalar or array; type: string;
			    default: ['brightstars','variables_4th','big_variables','duhstars']
			    list of catalogues to be used. Must be one or more of
			    the entries on the defaults list (lowercase! and NO typos!).
	/silent 	suppresses informational messages

	/get_format	if set, return the format used for the bright star catalogue
 OUTPUTS:
	star		array; type: SMEI_STAR_LIST structure
			if 'name' NOT specified:
			    all stars in the selected catalogues
			if 'name' specified:
			    array of length n_elements(name)
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			# stars in return array 'star'
	rmstar=rmstar	array; type: byte
			0: star should be fitted but not subtracted from skymap
			1: star should be fitted and subtracted from skymap
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, GetFileSpec, InitVar, IsType, UNIQ, destroyvar, smei_star_alias
	smei_star_info, txt_read, where_common, who_am_i
 EXTERNAL:
	smei_star_list__define
 CALLED BY:
	PRO bold, qEphem_State, smei_findobj, smei_mki2m, smei_star_cleanup, smei_star_fit
	smei_star_fitone, smei_star_info, smei_star_test, stardistance
 RESTRICTIONS:
	Small declinations (-1<lat<0) need special attention: the minus sign
	needs to be put in front of the first non-zero component (i.e. minutes
	or arcseconds)
 PROCEDURE:
 MODIFICATION HISTORY:
	JAN-2003, Paul Hick (UCSD/CASS)
	MAR-2003, Paul Hick (UCSD/CASS)
	    Rewrite to deal with single bright star catalogue
	JAN-2004, Paul Hick (UCSD/CASS)
	    Added big_variables.txt and variables_4th.txt
	NOV-2005, Paul Hick (UCSD/CASS)
	    Removed duplicate entries from list of stars (this should take
	    care of the overlap between 'brightstars' and 'big_variables'
	    catalogues.
	MAR-2008, Paul Hick (UCSD/CASS)
	    Removed keyword 'pos'. Added 'duhstars' catalogue.
	DEC-2008, Paul Hick (UCSD/CASS)
	    Added 'nova_list' catalogue.
	    Edited 'big_variables' catalogue to make format the same as
	    all other catalogues
	MAY-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added some code to report detection of duplicate names in the
	    star catalogues. These are removed (but this was done quietly
	    before).
	    Also merged big_variables.txt and variables_4th.txt with the
	    main brightstars.txt catalogue. Almost all of the variables
	    already were present in brightstars already. The original
	    brightstars.txt file is saved as brightstars_original.txt.
	JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Bugfix. The default value for keyword 'catalogues' after
	    merging of three catalogues is the first two (instead of
	    four) catalogues hardcoded.


smei_star_list__define $SMEI/ucsd/camera/idl/star/smei_star_list__define.pro
[Previous] [Next]
 NAME:
	smei_star_list__define
 PURPOSE:
	Defines structure for star in SMEI star catalogues
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_list__define
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL BY:
	smei_star_list
 PROCEDURE:
 MODIFICATION HISTORY:
	FEB-2008, Paul (UCSD/CASS; pphick@ucsd.edu)


smei_star_lsqbins $SMEI/ucsd/camera/idl/star/smei_star_lsqbins.pro
[Previous] [Next]
 NAME:
	smei_star_lsqbins
 PURPOSE:
	Refine PSF and background area definition based on
	properties of the original star.
 CATEGORY:
 CALLING SEQUENCE:
	PRO smei_star_lsqbins, original_star, rr, rr0, in_psf, in_bkgnd, bkgnd_count=bkgnd_count
 INPUTS:
	original_star	array[nx,ny]; type: float
			    area from original skymap around the star to be subtracted
			    (current a 50x50 box i.e 5x5 degrees)
	rr		array[2,nx*ny]; type: integer??
			    column and row indices into original skymap for all bins
			    in original_star
	rr0		array[2,nx*ny]; type: float
			    x,y locations relative to the centroid of the star
			    (in the same units as rr, i.e. bin spacings)
	in_psf		array[nx,ny]; type: byte
			    1: bin is inside the PSF
			    0: bin is outside the PSF
	in_bkgnd	array[nx,ny]; type: byte
			    1: bin is included in background area
			    0: bin is not included in background area
 OPTIONAL INPUT PARAMETERS:
	bkgnd_count=bkgnd_count
			scalar; type: float (<=1.0) or integer (n > 1)
			    sets the maximum number of pixels to be retained for
			    the background area (in the in_bkgnd array).
			    bkgnd_count >  1  : maximum number of bins to be retained
			    bkgnd_count <= 1.0: maximum fraction of current number of
						background bins to be retained
 OUTPUTS:
	in_psf		updated, bins where original_star is NaN are set to zero
	in_bkgnd	updated, bins where original_star is NaN are set to zero, and
			the number of bins in in_bkgnd is reduced to match the input
			given in bkgn_count
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType
 CALLED BY:
	smei_star_fit
 PROCEDURE:
	The first filter on in_psf and in_bkgnd is that only bins with finite
	values in original star are left non-zero.

	If bkgnd_count is defined then the background array in_bkgnd is modified
	so that at most bkgnd_count bins are left non-zero. These will be the bins
	in the background with the lowest value in original_star.
	Note that in_bkgnd is NOT modified if there are already less than
	bkgnd_count bins in it.
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_lsqfit $SMEI/ucsd/camera/idl/star/smei_star_lsqfit.pro
[Previous] [Next]
 NAME:
	smei_star_lsqfit
 PURPOSE:
	Performs multi-dimensional least-squares fit between
	observed star and standard star
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_lsqfit, $
	    rr		    , $
	    standard_stars  , $
	    original_star   , $
	    in_fullpsf	    , $
	    in_fitpsf	    , $
	    in_bckgnd	    , $
	    back	    , $
	    bright	    , $
	    sigma	    = sigma	    , $
	    only	    = only	    , $
	    noplane	    = noplane	    , $
	    noyzero	    = noyzero	    , $
	    bkgnd_model     = bkgnd_model   , $
	    one_star_model  = one_star_model, $
	    use_weights     = use_weights   , $
	    original_weights= original_weights,$
	    fixed_bright    = fixed_bright
 INPUTS:
	rr		    array[2,n]; type: float
				position vectors for all bins in the box around
				the star, relative to the star centroid
				(in units of the bin size of the skymap from
				which the star was extracted).
	standard_stars	    array[n,m]; type: float
				intensities in equivalent locations in standard
				star for all bins around star
				The 2nd dimension indicates the m stars fitted
				simultaneously (absent if m=1)
	original_star	    array[nx,ny] (with nx*ny=n); type: float
				intensities in box around star as extracted
				from the original skymap.
	in_fullpsf	    array; type: long
				list of array indices into rr, standard_stars and
				original_star that defines the full area of the
				PSF used to define the star model.
				in_fullpsf is almost, but not quite,
				    in_fullpsf = total(standard_stars GT 0.0,2) GT 0
	in_fitpsf	    array; type: long
				list of array indices into rr, standard_stars and
				original_star that should be used to fit the star.
				in_fitpsf is a subset of in_fullpsf
				(see smei_star_stdmaps).
	in_bckgnd	    array; type: long
				list of array indices to be used to fit the background.
				If this is a valid list of indices (i.e. if
				in_bckgnd[0] NE -1 then these pixels are used to fit
				a background separately from the fit to the PSF.
				The fit is to a plane or, if /noplane, is SET the
				mean of the background pixels is used.
 OPTIONAL INPUTS:
	sigma=sigma	    scalar; type: float
				if set then a second fit is made after discarding
				bins that are more than 'sigma' standard deviations
				in the residual after the first fit.
	only=only	    array; type: integer
				set of indices into the 'in_fitpsf' array
				Only the subset of bins in 'only' are used in the fit
				(this is only used in this procedure for a recursive
				call when keyword sigma is used).
	/noplane	    if set, then fit constant background (i.e. do
			    not fit a sloped background
	/noyzero	    passed to lsqLinearFit for fitting of PSF only if
			    background and PSF are fitted separately (i.e. if
			    in_bckgnd contains a valid list of background bins)
	original_weights=original_weights
			    array[nx,ny] (with nx*ny=n); type: float;
				default: 1.0/(50.0+original_star) (See PROCEDURE)
				Only used if /use_weights SET.
				Weights to be used for each skybin in the lsq fit.
	/use_weights	    if set, the fit is done using weights specified in
			    keyword original_weights.
	fixed_bright=fixed_bright
			    array[m]; type: float
				can be used to fix the brightness for one or more of the
				m stars. Should be set to the brightness of the star(s)
				that need to be 'frozen'. All other values should be set
				to NaN (i.e. BadValue(0.0))
				Usually output values from the keyword 'bright' of this
				procedure obtained from previous fit are used. This can
				be used for instance to separate a variable star (say a nova)
				from a non-variable close neighbour. The close neighbour
				can be fit from pre-nova data, and the result can then be
				used to freeze the brightness during the nova outburst.
 OUTPUTS:
	Result		    array[nx,ny]; type: float
				the resulting lsq fit to the PSFs of all stars fitted
				simultaneously. This is the 'best fit' model for the
				m stars combined:
				star_model[nx,ny] = (Sum(m))bright[m]*standard_stars[n,m]
	back		    array[3]; type: float
				constants for fit of background
				back[0] intensity at the centroid of the star
				    (i.e. at the origin of the rr position vectors)
				back[1:2] horizontal and vertical slope of the background
	bright		    array[m]; type: float
				brightness fit for all stars
 OPTIONAL OUTPUTS:
	bkgnd_model=bkgnd_model
			    array[nx,ny]; type: float
				the resulting lsq fit for the planar background
	one_star_model=one_star_model
			    array[nx,ny,n]; type: float
				the resulting lsq fit to the brightest of the stars
				one_star_model[nx,ny,i] = bright[i]*standard_stars[n,i]
				This is equal to the return value if only one star is fitted
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, MEAN, MagnifyArray, STDDEV, destroyvar, lsqLinearFit, view
 CALLED BY:
	smei_star_fit
 PROCEDURE:
	Note if /use_weights is set then the default weight used
	is 1.0/(50.0+original_star).
	The 50.0 is an estimate for the brightness of the darkest sky.
	The reason for using it is to avoid extremely large weights for
	background skybins when original_star already has the sidereal
	background and the zodiacal light removed (resulting in a
	residual background that is essentially zero).
 MODIFICATION HISTORY:
	DEC-2006, Paul Hick (UCSD/CASS)
	AUG-2006, Paul Hick (UCSD/CASS)
	    Added in_bckgnd argument to be able to fit background and
	    star separately
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword original_weights.
	    Changed default weights from 1/original_star
	    to 1/(50+original_star).


smei_star_make $SMEI/ucsd/camera/idl/star/smei_star_make.pro
[Previous] [Next]
 NAME:
	smei_star_make
 PURPOSE:
	Create star structure from RA,Dec
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_make, radec, $
	    name    = name  , $
	    mags    = mags  , $
	    magv    = magv  , $
	    magb    = magb  , $
	    degrees = degrees
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleUnits, IsType
 EXAMPLE:
 PROCEDURE:
 MODIFICATION HISTORY:
	MAY-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_readpnt $SMEI/ucsd/camera/idl/star/smei_star_readpnt.pro
[Previous] [Next]
 NAME:
	smei_star_readpnt
 PURPOSE:
	Reads time series files into smei_star_fit structure
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_readpnt, filename, stars,	$
	    hdr 	    = hdr   , $
	    nohdr	    = nohdr , $
	    error_message   = error_message,	$
	    silent	    = silent
 INPUTS:
	filename	scalar; type: string
			    fully-qualified filename
 OUTPUTS:
	smei_star_readpnt
 OPTIONAL OUTPUT PARAMETERS:
	hdr=hdr 	array; type: string
			    header (lines at beginning of file starting
			    with semi-colon)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, boost, destroyvar, do_file, gunzip_file, hide_env, smei_star_formatpnt
 EXTERNAL:
	smei_star_fit__define
 CALLED BY:
	PRO bold, skyd_version, smei_findobj, smei_mki2m, smei_star_show, smei_star_split
	smei_star_test
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS)
	SEP-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added hdr keyword


smei_star_remove $SMEI/ucsd/camera/idl/star/smei_star_remove.pro
[Previous] [Next]
 NAME:
	smei_star_remove
 PURPOSE:
	Removes bright stars from SMEI orbital sky maps
 CATEGORY:
	ucsd/camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_remove, wanted_map,	      $

	    destination 	= destination	    , $
	    to_smeidb		= to_smeidb	    , $

	    checkversion	= checkversion	    , $
	    overwrite		= overwrite	    , $
	    force		= force 	    , $
	    silent		= silent	    , $

	    keepbkgnd		= keepbkgnd	    , $
	    fit_with_nobkgnd	= fit_with_nobkgnd  , $

	    cleanedge		= cleanedge	    , $

	    version		= version	    , $
	    get_version 	= get_version	    , $
	    reverse_loop	= reverse_loop	    , $

	    use_bkgnd_version	= use_bkgnd_version , $
	    use_zld_version	= use_zld_version   , $

	    _extra		= _extra
 INPUTS:
	wanted_map	array[n]; type: string, time structure or integer
			    passed to smei_getfile
			    Selects skymap files to be processed
 OPTIONAL INPUT PARAMETERS:

	/to_smeidb	if set, write to directory structure as used
			    for SMEI data base (separate subdirs for mode
			    and camera) with 'destination' as the base dir.
	destination	scalar; type: string; default: $TUB
			array[2]; type: string
			    destination directory for skymaps and time series file
			    if /to_smeidb NOT set then maps are written
				directly to 'destination'.
				The default in this case is $TUB
			    if /to_smeidb SET then files are written to
				a directory structure as used for the
				SMEI data base with 'destination' as the
				base directory.
				The default in this case is 'SMEIDB?' (the
				SMEI database).
			    If two directories are specified the first is used
			    for the skymap and the second for the time series
			    If destination includes a "user@host:" identifier then
			    the output is created locally in $TUB
			    and is then transferred to the remote host using scp;
			    the local files are deleted after the transfer;
			    note that this will only work if the remote host has
			    been configured for ssh using private/public keys
			    allowing login without passwords.
	/overwrite	forces overwriting of existing skymaps and timeseries files
			(by default no files are overwritten)
	/checkversion	if present, files will be overwritten only if the current
			star subtraction version number and the current sidereal
			background version is higher then the version in the Fits
			header of the skymap.
			(if /keepbkgnd is set then the background version is not
			checked)

	silent=silent	if set, suppresses informational messages
	upto_mags=upto_mags
			scalar; type: float; default: 6.0
			    maximum SMEI magnitude; only stars brighter than this
			    are removed. (passed to smei_star_fit)
	/keepbkgnd	if set, the sidereal background (Milky Way, faint stars,
			    etc.) is not subtracted from the skymaps after
			    the bright stars are subtracted.

	/cleanedge	if set, a correction is made for straylight from sky
			    just outside the fov into the outer areas (direction
			    cosine angles larger than 20 deg) of the camera fov.
	/fit_with_nobkgnd   if set, stars are fit with the sidereal background removed

	_extra=_extra	The _extra keyword is passed to smei_star_fit,
			    and smei_getfile, so check those for
			    additional input keywords.

	/get_version	retrieve software version number
			    (returned in keyword "version")
	use_bkgnd_version=use_bkgnd_version
			scalar; type: integer 1,2 or 3; default: 3
			    selects the sidereal background map
	use_zld_version=use_zld_version
			scalar; type: integer 1,2,3,4; default: 4
			    selects the zodiacal brightness model
			    (passed to smei_zld_model)
 OUTPUTS:
	Files in destination directory
 OPTIONAL OUTPUTS:
	version=version Only defined if /get_version is set
			array[2]; type: float
			    version[0]: version of bright star subtraction
			    version[1]: version of sidereal background map
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, CheckDir, FILEPATH, FXADDPAR, FXPAR, GetFileSpec, HEADFITS, InitVar
	IsType, MKHDR, READFITS, TimeGet, TimeOp, TimeSystem, TimeUnit, WRITEFITS, boost, cvsmei
	destroyvar, do_file, gzip_file, hide_env, smei_camera_gain, smei_filename
	smei_filepath, smei_getfile, smei_sky, smei_sky_cleanedge_fov, smei_star_fit
	smei_star_writepnt, smei_zld_model
 CALLED BY:
	remove_stars, remove_stars_c3s, remove_stars_m0, smei_star_update
 EXAMPLE:
	smei_star_remove, 1500
	    Subtract stars for orbit 1500 (specified as integer) for camera 1
	smei_star_remove, smei_coriolis([1500,1501]), camera=1
	    Subtract stars for orbits 1500 and 1501 (specified as time
	    structure) for camera 1
	smei_star_remove, '2003/04/16 18:25:57'
	    Subtract stars for orbit 1500 specified as time string
	smei_star_remove, '*.fts.gz'
	    Use dialog_pickfile to select single skymap
	smei_star_remove, 'c1sky_2006_045_021031.fts.gz'
	    Subtract stars for specified map
 PROCEDURE:
	For each skymap a new skymap (Fits file) with the star-subtracted
	maps is created, and an ASCII file with information about the
	fitted stars. Both files are created in the directories
	specified in keyword 'destination'.

	The current star subtraction is build around the following
	set of keywords:

	smei_star_remove, f, /cleanedge, /use_weights, /auto_wing

	This implies a wind_radius value of 1.4 degrees.
	A good way to redo a section of maps in a time range 'trange' in the SMEI
	skymap data base on $SMEISKY0 is the command:

	smei_star_remove, trange,cam=3,/cleanedge,/use_weights,/auto_wing,  $
	    /checkversion,silent=3,/to_smeidb

 MODIFICATION HISTORY:
	NOV-2005, Paul Hick (UCSD/CASS)
	JUN-2006, Paul Hick (UCSD/CASS)
	    Modified to accept arrays as input in wanted_map argument.
	JUN-2006, Paul Hick (UCSD/CASS)
	    Added Fits keyword VERSION to sky map
	    Added NAME, CREATED and VERSION keywords to time series file
	    Added keyword /overwrite
	JUL-2006, Jordan Vaughan, Paul Hick (UCSD/CASS) V2.0
	    Added subtraction of sidereal background map (can be disabled
	    by keyword /keepbkgnd)

	    Added two extensions (copied from original skymap):
	    -extension 6: fraction of orbit (extension 7 from original skymap)
	    -extension 7: time in sec since first frame used
		    (extension 14 from original skymap)

	    Keyword VERSION is now called BSTARVER (to distinguish it from
	    keyword BKGNDVER (the version of the sidereal background map)
	    Keyword MILKYWAY is now called BKGND
	    If the sidereal backgound is subtracted keyword BKGND is set
	    to 1, and two more keywords are added:
	    BKGNDVER is the version of the sidereal background map
	    BKGAIN   is the gain correction (multiplicative factor) applied
	    to the sidereal background map before subtracting it.

	    Fixed problem with header for extension 4 (map of removed stars
	    in equatorial map.
	AUG-2006, Paul Hick (UCSD/CASS) V3.0
	    Modifications related to separate fitting of background and PSF.
	    Added couple of entries to smei_star_fit structure.
	    Time series file is now written by procedure smei_star_writepnt
	AUG-2006, Paul Hick (UCSD/CASS) V3.0
	    Padded records in time series file with 5 spaces to make them
	    exactly the same length as the titles record.
	SEP-2006, Paul Hick (UCSD/CASS) V3.1
	    Added /use_filled_psf keyword
	    Added star_info keyword to smei_star_fit and smei_star_writepnt
	NOV-2006, Paul Hick (UCSD/CASS) V4.0
	    Rearranged layout of time series file
	    Added extension (lowres map copied from original skymap)
	    -extension 8: number of pixels per skybin
		    (extension 16 from original skymap)
	MAR-2007, Paul Hick (UCSD/CASS) V4.1
	    Added extension (lowres map copied from original skymap)
	    -extension 8: direction cosine angle
		    (extension 15 from original skymap)
	    -extension 9: old extension 8 (pixels per skybin)
	APR-2007, Paul Hick (UCSD/CASS) V4.2
	    Added cleanedge keyword to allow removal of straylight
	    from sky just outside the camera fov.
	MAY-2007, Paul Hick (UCSD/CASS) V4.3
	    Modified fovangle field and added dfovangle field
	    to star_fit structure
	MAY-2007, Paul Hick (UCSD/CASS) V4.31
	    If keywords /cleanedge is set and /keepbkgnd NOT set,
	    then the sidereal background is added again AFTER
	    the star subtraction, and PRIOR to the removal of
	    the scattered light along the edge of the FOV. After
	    the scattered light correction the sidereal background
	    is taken out again.
	    Added keyword /to_smeidb to write directly into SMEI data base
	    Added keyword remote to do transfers to remote host
	JUN-2007, Paul Hick (UCSD/CASS)
	    Added keyword /from_smeidb
	JUL-2007, Paul Hick (UCSD/CASS)
	    Bug fix. removebkgnd was written into Fits file as byte
	    instead of short int.
	JUL-2007, Paul Hick (UCSD/CASS), V5.01
	    Added three extensions to output Fits file.
	    These contain 3 skymaps (equatorial,north and south pole)
	    with the stars subtracted and the core PSF replaced by
	    the background model.
	    Modified use of area defined with wing_radius. Bins in this
	    area that are part of the core PSF of a brighter neighbour
	    star (which has been subtracted already) are excluded from
	    being used in the lsq fit. They are still used when the
	    star model is subtracted.
	    Removed keywords wing_radius and use_filled_psf
	    (now passed to smei_star_fit using _extra keyword).
	NOV-2007, Paul Hick (UCSD/CASS), V5.02
	    Fixes bug in calculation of camera gain for cameras 1 and 3
	    smei_camera_gain.
	DEC-2007, Paul Hick (UCSD/CASS), V5.03
	    Added /inside_range keyword to be able to process
	    files in a specified time range (specified as a 2-element
	    time array in 'wanted_map')
	    Changed keyword CREATED in time series file to DATE.
	    Shortened header for equatorial maps in ext 3 and 6
	    (TX1MOON, TX2MOON, TX3MOON removed).
	DEC-2007, Paul Hick (UCSD/CASS), V5.04
	    Added two lines to header for timeseries files
	    (clean edge and remove bkgnd keywords)
	DEC-2007, Paul Hick (UCSD/CASS), V5.05
	    Added some more keyword to timeseries header:
	    BSTAR,BSTARVER,BKGNDVER,BKGAIN,CLNEDGE
	    (these are also present in the Fits file with the
	    star-subtracted skymaps).
	DEC-2007, Paul Hick (UCSD/CASS), V5.06
	    Added keywords ONEORBIT and ORBIT to timeseries header.
	JAN-2008, Paul Hick (UCSD/CASS), V5.07
	    Fixed some format issues in pnt file.
	    Star name was truncated at 11 char, should be 12.
	    Planet names were print right-adjusted, should be
	    left-adjusted
	FEB-2008, Paul Hick (UCSD/CASS)
	    Location of files now done using smei_getfile.
	    Removed keyword remote (functionally is now provided by
	    keyword destination).
	FEB-2008, Paul Hick (UCSD/CASS), V5.10
	    Added star_fit.remove entry.
	    Bug fix in calculation of psfwidth (sometimes gave NaN).
	FEB-2008, Paul Hick (UCSD/CASS), V5.11
	    Added USNO asteroids and 'stars_not_subtracted' catalogue to
	    list of point sources (these are fitted, but not subtracted).
	MAR-2008, Paul Hick (UCSD/CASS), V5.12
	    Added keyword SMEI_SKY, SMEI_CAL and SMEI_ORB to pnt header
	MAR-2008, Paul Hick (UCSD/CASS), V5.13
	    Fixed problem with two DATE keywords in header of output
	    Fits file.
	MAR-2008, Paul Hick (UCSD/CASS), V5.2
	    Bug fix in edge-clean procedure. The bug may have been
	    introduced with V5.01 (JUL-2007) with the inclusion of the
	    'flat' star-subtracted maps.
	APR-2008, Paul Hick (UCSD/CASS), V5.3
	    Both sidereal background and zodiacal dust brightness
	    are now subtracted prior to fitting stars.
	    The weighting in smei_star_lsqfit was changed to
	    from 1/b to 1/(50+b), where b is the residual brightness
	    (after background and zodiac subtraction).
	    Added keyword removezld.
	    Added header keywords ZLD, ZLDVER to output files.
	    Renamed header keyword gain from BKGAIN to SKYGAIN
	APR-2008, Paul Hick (UCSD/CASS), V5.31
	    Replaced sidereal background map with new version.
	JUN-2008, Paul Hick (UCSD/CASS)
	    Added PSF angle to output Fits file.
	JUL-2008, Paul Hick (UCSD/CASS), V5.32
	    Changed gain decrease for camera 1 from 1%/yr to 0.5%/yr
	    (in smei_camera_gain)
	OCT-2008, Paul Hick (UCSD/CASS), V5.33
	    Fixed bug in calculation of observation time (used stime as
	    time origin instead of extracted the origin from the header
	    for the time map (keyword TORIGIN).
	DEC-2008, Paul Hick (UCSD/CASS), V6.00
	    New sidereal background map (version 3)
	    New zodiacal dust cloud model (model 4.01)
	    Gain change for camera 1 set back to -1% per year.
	AUG-2009, Paul Hick (UCSD/CASS)
	    Added keyword use_bkgnd_version to be able to change the
	    selected sidereal background map.
	SEP-2009, Paul Hick (UCSD/CASS)
	    Added keyword use_zld_version to be able to change the
	    selected zld model.
	OCT-2009, John Clover (UCSD/CASS; jclover@ucsd.edu), V6.01
	    Changed the default behavior of star fitting, the sidereal
	    background is no longer removed prior to the star fit
	    if background is removed, it is done so after star fit.
	    Also changed default background to version 4.
	DEC-2009, Paul Hick (UCSD/CASS), V6.02
	    The star_sky array returned from smei_star_fit is now
	    contains "flat" stars, i.e. the fitted stars with the
	    fitted background model subtracted
	MAY-2010, John Clover (UCSD/CASS), V7.01
	    Updated to include ZLD removed FTS headers.
	    1, 2, 3 contain star removed "flat" maps (eq, np, sp)
	    with ZLD removed
	    4, 5, 6 contain star removed "flat" maps (eq, np, sp)
	    with ZLD not removed (unchanged from previous version)
	    Removed keyword removezld (zld now always removed)
	    Added keyword fit_with_nobkgnd (default off)
	JUN-2010, Paul Hick (UCSD/CASS), V7.02
	    After bugfix in construction of flat_sky in smei_star_fit
	JUL-2010, John Clover (UCSD/CASS)
	    Incrimented use_bkgnd_version to 5, new background maps
	    have been from engineering mode maps with the bugfix
	    applied
	AUG-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V7.03
	    Added two columns (for ccd_mode and area of (exteneded)
	    PSF. Changed format of column Istd. Allowed value 2
	    in last column to indicate stars not fitted because there
	    are not enough good bins.


smei_star_show $SMEI/ucsd/camera/idl/star/smei_star_show.pro
[Previous] [Next]
 NAME:
	smei_star_show
 PURPOSE:
	Plot star time series
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_show, star_name, pnt_, $
	    source  = source	, $
	    xname   = xname	, $
	    xtype   = xtype	, $
	    yname   = yname	, $
	    ytype   = ytype	, $
	    ttrange = ttrange	, $
	    cvrange = cvrange	, $
	    fixgain = fixgain	, $
	    magnitude=magnitude , $
	    pnt     = pnt	, $
	    camera  = camera	, $
	    track   = track	, $
	    yaxis   = yaxis	, $
	    newyaxis= newyaxis	, $
	    dtsmooth= dtsmooth	, $
	    tsmooth = tsmooth	, $
	    xysize  = xysize	, $
	    zbuffer = zbuffer	, $
	    imgfile = imgfile	, $
	    logo    = logo	, $
	    silent  = silent	, $
	    _extra  = _extra
 INPUTS:
	star_name	scalar; type: string; default: Polaris
			    name of star
			    used only if 2nd argument (pnt_) is not specified
			    star_name is run through smei_star_alias
			    and smei_star_info to translate the specified
			    name to a star_name on one of the SMEI star catalogues
			    (set keyword cat='*' to scan all available catalogues).
			    If no match is found then 'star_name' is used (after
			    replacing spaces with underscores) to locate a time
			    series file <star_name>.txt or <star_name>.txt.gz.
			    If a match is found than the standard naming convention
			    for naming pnt files is followed to locate a pnt file
			    (see smei_star_filename).
	pnt_		array; type: structure
			    time series info read from pnt file.
			    If this argument is specified (obtained from a previous
			    call to smei_star_show) then 'star_name' is ignored
			    and this argument is used instead of reading the
			    time series from file.
 OPTIONAL INPUT PARAMETERS:
	source=source	scalar; type: string; default: $SMEISKY0/star
			    name of directory where pnt file for 'star_name'
			    timeseries is located

	Any of the quantities in the time series ('pnt') file can be plotted.
	These are selected by specifying field names in the xname and yname
	keywords. Valid entries are:
	    NAME
	    RADEC	2-element vector
	    MAPTYPE
	    CAMERA
	    TIME
	    PSFANGLE
	    FOVANGLE	2-element vector
	    PSFSTRETCH	2-element vector
	    GAIN
	    NAME_CLOSE
	    TOTAL_ADUS
	    BRIGHT_RAW
	    BRIGHT_MDL
	    BRIGHT
	    BACK_CONST
	    BACK_SLOPE	2-element vector
	    N_BKGND
	    N_FITPSF
	    STDEV_BKGND
	    STDEV_PSF
	    CVFIT
	    DRADEC	2-element vector
	    DPSFANGLE
	    DPSFSTRETCH 2-element vector
	    PSFWIDTH	2-element vector
	    REMOVE
	    DONE

	xname=xname	scalar; type: string; default: 'TIME'
			    selects the quantity on the horizontal axis
	yname=yname	scalar or array; type: string; default: 'BRIGHT'
			    selects one or more quantities for the vertical axis
			    Note: if more than one quantity for the y-axis is
			    specified then probably keywords newyaxis and yaxis
			    will be needed to get a decent plot
			    (see PlotCurve).
	xtype=xtype	scaler; type: integer; default: 0
	ytype=ytype	scalar; type: integer; default: replicate(0,n_elements(yname)
			    either 0 or 1; selects the vector component if one of the
			    vector fields is used for xname and/or yname
	Special cases:
	- If one of the vector fields is used for xname, then the second vector
	  component is used for the y-axis, e.g.
	    xname='RADEC' is the same as xname='RADEC, xtype=0, yname='RADEC', ytype=1

	camera=camera	scalar or array; type: integer; default: none
			    list of cameras (value 1,2 or 3). If present, only
			    data points for the indicated cameras are plotted.
	ttrange=ttrange array[2]; type: string or time structure; default: none
			    limits time series to specied time range
			    If only one time is specified than the time series
			    from that time to the end of the time series is plotted.
	cvrange=cvrange scalar or array[2]; type: numeric; default: none
			    only plots data points for which the correlation of the
			    PSF fits was in the specified range.
			    If a scalar is specified then [cvrange,1.0] is assumed,
			    i.e. all points with fits better than the indicated
			    threshold are used.
	/magnitude	converts the brightness to a SMEI magnitude scale
			(Note: this is a very coarse conversion)
	/fixgain	if set, then the gain information in the pnt file is used
			to correct the timeseries for camera gain.

	/track		calls smei_sky_track instead of plotting time series info
			(Does this work? What does it do anyways?)

	_extra=_extra	extra keywords passed to smei_star_info, smei_sky_track,
			    PlotCurve and xyouts
 OUTPUTS:
	pnt_		array; type structure
			    the content read from the pnt file. This can be used
			    in subsequent calls to bypass reading the file
			    again. In this case the 'star_name' argument is ignored.
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, IsTime, IsType, PlotCurve, TimeGet, TimeLimits, TimeSet, TimeUnit
	destroyvar, get_page, set_page, smei_i2m, smei_orbit_get, smei_sky_track
	smei_star_alias, smei_star_filename, smei_star_info, smei_star_readpnt
	smei_star_showsmooth, smei_star_title, where_common
 PROCEDURE:
 MODIFICATION HISTORY:
	JAN-2008, Paul Hick (UCSD/CASS)
	FEB-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_showsmooth $SMEI/ucsd/camera/idl/star/smei_star_showsmooth.pro
[Previous] [Next]
 NAME:
	smei_star_showsmooth
 PURPOSE:
	Internal use only (by smei_star_show)
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_showsmooth, time, fnc, $
	    dtsmooth	= dtsmooth  , $
	    tsmooth	= tsmooth   , $
	    sigma	= sigma
 INPUTS:
	time
	fnc
 OPTIONAL INPUT PARAMETERS:
	dtsmooth=dtsmooth
 OUTPUTS:
	Result
 OPTIONAL OUTPUT PARAMETERS:
	sigma=sigma
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	BadValue, IsTime, IsType, MEAN, STDDEV, TimeGet, TimeOp, TimeSet, TimeUnit
 CALLED BY:
	smei_star_show
 PROCEDURE:
 MODIFICATION HISTORY:
	OCT-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_split $SMEI/ucsd/camera/idl/star/smei_star_split.pro
[Previous] [Next]
 NAME:
	smei_star_split
 PURPOSE:
	Processes all individual star files (as created by Python
	script smei_star_split.py) and sorts their content into
	chronological order.
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_split, wildcard, $
	    source	= source     , $
	    remove	= remove     , $
	    silent	= silent     , $
	    force	= force
 INPUTS:
	wildcard    scalar; type: string; default: '*'
 OPTIONAL INPUTS:
	source	    scalar; type: string; default: '.'
		    source directory of files for individual stars
 OUTPUTS:
	Rewrites all the files for individual stars
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FindAllFiles, GetFileSpec, InitVar, SMEI_STAR_TESTPNT, TimeOp, TimeSet, TimeUnit
	do_file, hide_env, smei_star_readpnt, smei_star_writepnt
 PROCEDURE:
	For each star a separate file is created in $SMEISKY0/star
	containing all the records for that star found in the
	pnt files stored in $SMEISKY0/pnt.
 MODIFICATION HISTORY:
	JAN-2007, Paul Hick (UCSD/CASS)
	JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Removed the part that creates the individual star files.
	    This is now done with Python script smei_star_split.py


smei_star_standard $SMEI/ucsd/camera/idl/star/smei_star_standard.pro
[Previous] [Next]
 NAME:
	smei_star_standard
 PURPOSE:
	Read in the standard star map
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_standard, camera	    , $
	    bkgnd_origin	= bkgnd_origin	    , $
	    bkgnd_radius	= bkgnd_radius	    , $
	    wing_origin 	= wing_origin	    , $
	    wing_radius 	= wing_radius	    , $
	    wing_delta		= wing_delta	    , $
	    min_wing_radius	= min_wing_radius   , $
	    psfstretch		= psfstretch	    , $
	    degrees		= degrees	    , $

	    get_origin		= get_origin	    , $
	    get_ndim		= get_ndim	    , $
	    get_fov		= get_fov	    , $
	    get_scale		= get_scale	    , $

	    get_nomansland_id	= get_nomansland_id , $
	    get_background_id	= get_background_id , $
	    get_wayoutside_id	= get_wayoutside_id , $

	    use_filled_psf	= use_filled_psf    , $
	    in_psf		= in_psf	    , $
	    show		= show		    , $
	    scale		= scale 	    , $
	    origin		= origin	    , $
	    extend_corepsf	= extend_corepsf    , $

	    silent		= silent
 INPUTS:
	camera		scalar; type: integer; default: 2
			    camera number (1,2,3)
 OPTIONAL INPUT PARAMETERS:
	!!! DO NOT MIX the bkgnd_* and wing_* keywords: results will be unpredictable.

	/degrees	all angles are in degrees (default is radians)
			This includes bkgnd_radius, wing_radius, psfstretch
			bkgnd_origin, wing_origin, wing_delta and min_wing_radius
	bkgnd_origin=bkgnd_origin
			array[2]; type: float; default: [0,0]
			    only used if bkgnd_radius is set.
			    Shifts the origin of the ellipsoidal background area
			    The units are the same as bkgnd_radius (i.e. radians or
			    degrees, depending on setting of /degrees).
	bkgnd_radius=bkgnd_radius
			scalar or array[2]; type: float; default: none
			    Radius of circular or ellipsoidal area around centroid
			    of standard star used to define the background area around the PSF
			    If two radii are specified than the ring in between
			    the two circles/ellipses is used to define the background area.
			    (an ellipse results from the use of 'psfstretch' see below.)
	wing_origin=wing_origin
			array[2]; type: float; default: [0,0]
			    only used if wing_radius is set.
			    Shifts the origin of the ellipsoidal wing area
			    The units are the same as wing_radius (i.e. radians or
			    degrees, depending on setting of /degrees).
	wing_radius=wing_radius
			scalar or array[2]; type: float; default: none
			    Axes of ellipse defining a wing area around the PSF
			    If scalar then the ellipse becomes a circle.
			    Inside this area the PSF is extended using an
			    exponential dropoff in directions along and
			    perpendicular to the PSF symmetry axis.
	wing_delta=wing_delta
			scalar or array[2]; type: float; default: none
			    correction to wing_radius
	min_wing_radius=min_wing_radius
			scalar; type: float; default: 0.5 degrees
			    sets a lower value on the effective wing radius
			    (wing_radius+wing_delta) to avoid using too low
			    values (wing_delta is used to scale the effective
			    wing radius with magnitude; this could lead to
			    small, or even negative values for very faint stars).
	psfstretch=psfstretch
			array[2]; type: float: default: [0.0,0.0]
			    Only used if bkgnd_radius or wing_radius is set
			    to non-zero value
			    Setting psfstretch to a value other than one will turn the
			    background (if bkgnd_* keywords are uses) or wing (if wing_*
			    keywords are used) area into an ellipse with a semi-major
			    axis of bkgnd_radius/psfstretch, i.e. larger values of
			    psfstretch shrink the axes.
			    (usually psfstretch=cos(fovangle) where fovangle is the
			    direction cosine angle in the long fov dimension)
	/get_origin	if set return origin (array indices for RA=0, dec=0) of
			    standard star map
	/get_ndim	if set return dimensions of standard star map
	/get_fov	if set return width of standard map in angular units
			    This is the product of the return values for the /get_ndim
			    and /get_scale keywords.
	/get_scale	if set return scale (angular units per bin) of standard
			    star map
	/show		if set display standard star map

	/use_filled_psf if set, use the alternative PSF map
 OUTPUTS:
	See /get_origin, /get_scale, /get_ndim
	for return value if one of these keywords is set. If no keyword is set:

	std_map 	array[n,n]; type: float
			    2D standard star map of 200x200 bins
			    map >  0 inside PSF (brightness of standard star)
			    map = -1 inside inner radius, but outside PSF
				    (not present if bkgnd_radius is a scalar (outer radius only),
				    or if wing_radius is used)
			    map = -2 inside outer radius, but outside PSF and outside
				    inner radius (if specified);
				    or inside wing_radius but outside PSF.
			    map = -3 outside outer radius, and outside PSF
	in_psf		array[n,n]; type: byte
			    1 inside the non-zero area of the PSF; 0 outside
			    This is the effective non-zero area of the PSF, or 'core PSF'
			    !!! If keyword wing_radius is set this EXCLUDES the circular
			    !!! area out to radius 'wing_radius', but only covers the part
			    !!! that is non-zero in the standard_star file.

	origin=origin	array[2]; float
			    array indices for RA=0,dec=0) of the standard star map
	scale=scale	scalar; type: float
			    scale (angular units per bin) of standard star map
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	smei_star_cleanup, smei_star_fit, smei_star_stdmaps, smei_star_writepnt
 COMMON BLOCKS:
	common smei_star_standard_save, $
	    std_psf	    , $
	    std_wing	    , $
	    std_cam	    , $
	    std_origin	    , $
	    std_scale	    , $
	    std_adus	    , $
	    std_map	    , $
	    std_in_psf
 CALLS: ***
	FILEPATH, FXPAR, InitVar, IsType, READFITS, ToDegrees, destroyvar, gridgen, view, who_am_i
 PROCEDURE:
	The standard star is stored in the Fits file standard_star.fts.gz
	in the same directory as this procedure.
	The standard map is a 200x200 array covering a 5x5 deg area
	(0.025 deg/bin). for each camera. It contains positive-definite
	values defining the PSF and is zero everywhere else.

	The center of the map (at array indices [99.5,99.5] is the
	centroid of the PSF. The standard star represents the shape of a star
	with its centroid located at RA=0, dec=0 (i.e. on the equator).

	Either the bkgnd_* or the wing_* are used to fill the return
	array:

	Only outer radius specified in bkgnd_radius:

	The input values bkgnd_radius, bkgnd_origin and psfstretch are
	used to define an ellipsoidal area around the center of the map.
	Bins outside the ellipse are set to -3.
	Bins inside the ellipse (but not in the PSF) are set to -2.
	The output map contains -3, -2, and positive-definite values.

	Both inner and outer radius specified in bkgnd_radius:

	The input values bkgnd_radius, bkgnd_origin and psfstretch are
	used to define an ellipsoidal ring around the center of the map.
	Bins outside the outer ellipse are set to -3.
	Bins inside the ring between inner and outer ellipse
	(but not in the PSF) are set to -2.
	Bins inside the inner ellipse (but not in the PSF) are set to -1
	The output map contains -3, -2, -1, and positive-definite values

	Single radius or semi-major axes specified in wing_radius:

	The input values wing_radius (and wing_delta), wing_origin, and
	psfstretch are used to define an ellipsoidal ring around the
	center of the map.
	Bins outside the ellipse (but not in the PSF) are set to -3.
	The output map contains -3, and positive-definite values

	The bins with value -2 in the output map can be used to define
	a background area around the PSF.
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS)
	AUG-2006, Paul Hick (UCSD/CASS)
	    Added /use_filled_psf keyword to work with alternative PSF map
	MAR-2007, Paul Hick (UCSD/CASS)
	    Change bkgnd_radius and fovxangle from argument to keyword.
	    Added keywords wing_radius and wing_origin
	MAY-2007, Paul Hick (UCSD/CASS)
	    Changed scalar fovxangle keyword to 2-element array psfstretch
	    Changed keyword /get_adus to /get_psfadus.
	    Added keyword /get_psfarea
	JUL-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword in_psf
	    Removed keywords get_psfarea and get_psfadus.


smei_star_stdmaps $SMEI/ucsd/camera/idl/star/smei_star_stdmaps.pro
[Previous] [Next]
 NAME:
	smei_star_stdmaps
 PURPOSE:
	Get brightness in standard star at indicated locations
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_stdmaps, camera, $
	    maptype	    , $
	    rr		    , $
	    origin	    , $
	    scale	    , $
	    radec	    , $
	    psfangle	    , $
	    psfstretch	    , $
	    degrees	 = degrees	, $
	    bkgnd_origin = bkgnd_origin , $
	    bkgnd_radius = bkgnd_radius , $
	    wing_origin  = wing_origin	, $
	    wing_radius  = wing_radius	, $
	    wing_delta	 = wing_delta	, $
	    in_fullpsf	 = in_fullpsf	, $
	    in_fitpsf	 = in_fitpsf	, $
	    in_corepsf	 = in_corepsf	, $
	    in_bkgnd	 = in_bkgnd	, $
	    std_rr	 = std_rr	, $
	    use_filled_psf=use_filled_psf,$
	    stars_mask	 = stars_mask	, $
	    corepsf_mask = corepsf_mask , $
	    stdarea	 = stdarea	, $
	    stdadus	 = stdadus
 INPUTS:
	camera		scalar; type: integer
			    camera id (1,2,3)
	maptype 	scalar; type: integer
			    -1: map of south pole
			     0: equatorial map
			    +1: map of north pole
	rr		array[2,n]; type: integer
			    position vectors for all bins in the box around
			    the star as column and row indices into the original skymap
			    for all bins in box around star
	origin		array[2]; type: float
			    array indices of RA=0, dec=0 (equatorial map),
			    position of north pole, dec=90 (north polar map) or
			    position of south pole, dec=-90 (south polar map)
	scale		scalar; type: float
			    map resolution (radians/degrees per bin)
	radec		array[2,m]; type: float
			    RA and dec of the star centroids for m stars
	psfangle	array[m]; type: float
			    orientations of PSF relative to equatorial north
			    for m stars
	psfstretch	array[2,m]; type: float
			    'stretch' factors along long and narrow dimension of the
			    SMEI field of view for m stars. Larger stretch factors
			    will shrink the PSF size (similar to the geometric effect
			    of the shrinking aperture size when viewed from a direction
			    away from the optical axis (the fov direction cosine angle)).
 OPTIONAL INPUTS:
	/degrees	if set, all angles are in degrees (default: radians)

	stars_mask=stars_mask
			array[n]; type: float
			    box around star with results for previously-
			    subtracted stars.
			    This is a box extracted from the "stars_sky"
			    array in smei_star_fit: it is zero in skybins
			    where nothing has been subtracted yet, and
			    positive-definite when subtraction has taken
			    place (the content is the intensity that was
			    subtracted from the original skymap).
			    If present this affects 'in_fit_psf' and 'in_bkgnd':
			    in_bkgnd: skybins that are part of an already-subtracted
				star are excluded.
			    in_fitpsf: skybins that that are part of an already-subtracted
				star and are in the core PSF of one of the m stars
				are excluded.

	corepsf_mask=corepsf_mask
			array[n]; type: byte
			    0 where bins are inside the core PSF of bright stars.
			    This mask affects 'in_fit_psf':
			    skybins inside the core PSF of bright stars, but outside
			    the core PSF of the m stars are excluded

	Passed to smei_star_standard:

	bkgnd_origin=bkgnd_origin
			array[2]; type: float
	bkgnd_radius=bkgnd_radius
			scalar or array[2]; type: float
	wing_origin=wing_origin
			array[2]; type: float
	wing_radius=wing_radius
			scalar or array[2]; type: float
	wing_delta=wing_delta
			scalar or array[2]; type float

	/use_filled_psf if set, use the alternative PSF map
 OUTPUTS:
	Result		array[n,m]; type: float
			    'standard star' brightnesses at the locations rr for m stars.
			    The 'standard star' gives the brightness of a star located
			    at RA=0, dec=0 with PSF angle of zero.
			    The sky locations rr are transformed to locations in the
			    'standard star' reference frame; 'standard star' brightnesses
			    are obtained by interpolation.
	in_fullpsf=in_fullpsf
			array[n]; type: byte
			    1B identifies locations inside combined PSF of
			    m stars (i.e. the union of the non-zero location
			    for the individual stars).
			    This includes locations inside the "core" PSF, and
			    (if wing_radius is used) additional locations where
			    the core PSF is extended out to the specified
			    wing_radius.
	in_fitpsf=in_fitpsf
			array[n]; type: byte
			    subset of in_fullpsf
			    excludes bins set to 1B in in_fullpsf based
			    on info provided in keyword stars_mask
			    and corepsf_mask
	in_corepsf=in_corepsf[n,m]
			array[n]; type: byte
			    1B identifies locations inside the "core" PSF
			    (stored in the standard star map) for each of the
			    m fitted stars individually.
			    If wing_radius is set this is NOT the same as in_fitpsf
			    (in_corepsf is a subset of in_fitpsf, identifying the
			    PSF before it was extended out to wing_radius)
	in_bkgnd=in_bkgnd
			array[n]; type: byte
			    1B identifies locations in background area
			    Is affected by stars_mask, if specified

	std_rr=std_rr	array[2,n,m]; type: float
			    equivalent RA,dec in the 'standard star' reference frame
			    (centered on RA=0, dec=0) with abs(RA) < 180 degrees
	stdarea=stdarea array[m]; type: float
			    total angular size of the PSF for all m stars.
			    Calculated in the 'standard star' reference frame, and
			    includes all bins with non-zero brightness (i.e. if
			    wing_radius is used this includes the bins outside the
			    core PSF filled with an exponential dropoff out to
			    wing_radius. (!!! Not sure this is the right way to
			    do it: maybe should use core PSF only)
	stdadus=stdadus array[m]; type: float
			    Total adus in the 'standard star' in the same set of
			    bins used to calculate 'stdarea'.
			    The sum is defined as the sum of the ADUs in the
			    standard star skybins, times the binarea (0.025^2 deg).
			    (this makes totaladus independent of bin size, making
			    it easier to compare with the same quantity calculated
			    in the fullsky maps (with 0.1 deg resolution).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, BILINEAR, EulerRotate, IsType, ToDegrees, ToRadians, smei_star_standard
 CALLED BY:
	smei_star_corepsf, smei_star_fit
 PROCEDURE:
	See Section 6 in http://supercat.ucsd.edu/reports/smei.pdf
 MODIFICATION HISTORY:
	JUN-2006, Paul Hick (UCSD/CASS)
	JUL-2006, Jordan Vaughan (jtvaugha@ucsd.edu)
	    Added costhetax argument
	JUL-2006, Paul Hick (UCSD/CASS)
	    Modified the linear interpolation on the standard map.
	    The 'missing data' value now is -1.0 instead of 0.0.
	    The value 0.0 is now used to indicate bins used to sample
	    the background.
	JUL-2006, Paul Hick (UCSD/CASS)
	    Added /use_filled_psf keyword
	FEB-2007, Jordan Vaughan, Paul Hick (UCSD/CASS)
	    Added stars_mask keyword to be able to exclude skybins
	    in already-subtracted stars from the background.
	JUL-2007, Paul Hick (UCSD/CASS)
	    Added keyword in_corepsf
	NOV-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added more documentation.


smei_star_test $SMEI/ucsd/camera/idl/star/smei_star_testpnt.pro
[Previous] [Next]
 NAME:
	smei_star_test
 PURPOSE:
	Test integrity of star time series files
	Works for pnt files, and for files made for
	individual stars (if /nohdr) is set.
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	FUNCTION smei_star_testpnt, files, $
	    nohdr   = nohdr	, $
	    silent  = silent
 INPUTS:
	files	    scalar or array; type: none
 OPTIONAL INPUTS:
	/nohdr
 OUTPUTS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	SMEI_STAR_TESTPNT, TimeOp, TimeSet, TimeUnit, UNIQ, hide_env, jpl_body, smei_star_info
	smei_star_list, smei_star_readpnt, sphere_distance, usno_body, where_common
 PROCEDURE:
	Checks for duplicate times
	Checks for times before start of mission (this catches
	data points without a valid time for which the time
	is set to 2000/01/01
	Checks for timea after end of mission (should never happen)
 MODIFICATION HISTORY:
	JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_title $SMEI/ucsd/camera/idl/star/smei_star_title.pro
[Previous] [Next]
 NAME:
	smei_star_title
 PURPOSE:
 CATEGORY:
 CALLING SEQUENCE:
	FUNCTION smei_star_title, xtag, itag
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS:
 CALLED BY:
	smei_star_show
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_update $SMEI/ucsd/camera/idl/star/smei_star_update.pro
[Previous] [Next]
 NAME:
	smei_star_update
 PURPOSE:
	Update star subtractions in SMEI data base
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_update, camera=camera, mode=mode
 INPUTS:
	(none)
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FindAllFiles, InitVar, IsType, smei_star_remove
 PROCEDURE:
 MODIFICATION HISTORY:
	NOV-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smei_star_writepnt $SMEI/ucsd/camera/idl/star/smei_star_writepnt.pro
[Previous] [Next]
 NAME:
	smei_star_writepnt
 PURPOSE:
	Write fit informations for bright star to file
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_writepnt, filename, star_fit , $
	    dec_cutoff	    = dec_cutoff, $
	    camera	    = camera	, $
	    append	    = append	, $
	    star_info	    = star_info , $
	    degrees	    = degrees	, $
	    single_star     = single_star
 INPUTS:
	filename	    scalar; type: string
			    Fully-qualified filename
	star_fit	    array; type: structure
			    Structure with information from fits of bright star
			    (from output keyword star_fit in smei_star_fit.
			    If star_fit is NOT defined and /append is NOT set then
			    just the header is written.
 OPTIONAL INPUT PARAMETERS:
	append=append	    if set, the append to existing file
			    if NOT set, a new file is created. The file
			    starts with a header.
	camera=camera	    scalar; type: integer; default: none
			    camera ID (1,2 or 3)
			    If present, a line is added to the header with the
			    mean intensity (in adus) in the standard star
	dec_cutoff	    scalar; type: float; default: none
			    If present, stars are written to file only if:
			    abs(dec(star) LE dec_cutoff in equatorial map
			    dec_star GT dec_cutoff in north polar map
			    dec_star LT -dec_cutoff in south polar maps
			    If NOT present, all stars are written to file
			    Note that the units of dec_cutoff (degrees or radians)
			    must be consistent with the units for RA,dec stored
			    in the 'star_fit' structure.
	star_info=star_info array; type: string
			    string array containg fit parameters used by smei_star_fit.
			    This is added to the header (if /append NOT set).
 OUTPUTS:
	(to ASCII file)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	GetFileSpec, InitVar, IsType, TimeGet, TimeSystem, boost, flt_format, hide_env
	smei_star_filename, smei_star_formatpnt, smei_star_standard
 CALLED BY:
	smei_findpnt, smei_star_fitone, smei_star_remove, smei_star_split
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2006, Paul Hick (UCSD/CASS)
	SEP-2006, Paul Hick (UCSD/CASS)
	    Added /use_filled_psf keyword
	JUL-2007, Paul Hick (UCSD/CASS)
	    Removed wing_radius and use_filled_psf keywords
	DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Changed keyword CREATED to DATE (consistent with IDL)
	    Removed version keyword (version is now added to header in smei_star_remove)


smei_theta2radial $SMEI/ucsd/camera/idl/toolbox/smei_theta2radial.pro
[Previous] [Next]
 NAME:
	smei_theta2radial
 PURPOSE:
	Converts from angle thetay in the sky to radial offset
	Rccd-R0 on the CCD
 CATEGORY:
	camera
 CALLING SEQUENCE:
	R = smei_theta2radial(thetay [, thetax])
 INPUTS:
	thetay	    array[*]; type: any
			thetay argument for Eq. 3
 OPTIONAL INPUT PARAMETERS:
	thetax	    array[*] or array[2,*]; type: same as thetay
			if thetax is absent then Equation 2 from the memo is
			used (= Eq. 3 with thetax=0)

			CASE 1: array[*]: if thetax is an array with the same structure
			    as thetay then the radial offset from Eq. 3 is returned
			CASE 2: array[2,*]: this is used by smei_radial2theta to determine the
			    zero for Eq 3 for given thetax and radial offset.
			    thetax[0,*]: stores the thetax values
			    thetax[1,*]: stores the radial offset values
 OUTPUTS:
	R	    array[*]; type: same type as thetax
			CASE 1: radial offset from Eq 3 in pixels
			CASE 2: radial offset from Eq 3, minus radial offset specified in
			    thetax[1,*] (the value of thetay that makes this difference zero is
			    the value that smei_radial2theta is after).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL BY:
	smei_radial2theta
 CALLS: ***
	IsType, SubArray
 CALLED BY:
	cvsmei, smei_sky2ccd
 PROCEDURE:
	See Andy's memo "Defining the field of view for the SMEI cameras" (11-July-2001)
	This function implements Equation 3. All angles are in degrees.
 MODIFICATION HISTORY:
	FEB-2003, Paul Hick (UCSD/CASS)
	JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Modification to intercept large thetay values


smei_www_skymaps $SMEI/ucsd/camera/idl/toolbox/smei_www_skymaps.pro
[Previous] [Next]
 NAME:
	smei_www_skymaps
 PURPOSE:
	Creates the html tables showing available skymaps
	on SMEI website.
 CALLING SEQUENCE:
	PRO smei_www_skymaps, mode, $
	    supercat	= supercat  , $
	    update	= update    , $
	    lastmonths	= lastmonths, $
	    remote	= remote    , $
	    silent	= silent
 OPTIONAL INPUTS:
	mode		    array or scaler; type: integer; default: 'sky'
				modes to be processed
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	CheckDir, FILEPATH, FindAllFiles, GetFileSpec, InitVar, IsType, SetFileSpec, TimeGet
	TimeMonth, TimeSet, TimeSystem, TimeUnit, boost, destroyvar, hide_env, smei_coriolis
	txt_read
 CALLED BY:
	smei_mksky
 PROCEDURE:
 MODIFICATION HISTORY:
	OCT-2006, Paul Hick (UCSD/CASS)
	JAN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Bug fix in construction of index.html with /update set when
	    crossing from one year to the next.


smei_zld_dumbbell $SMEI/ucsd/camera/idl/zld/smei_zld_dumbbell.pro
[Previous] [Next]
 NAME:
	smei_zld_dumbbell
 PURPOSE:
	Calculates analytic dumbbell-shaped correction to the zodiacal light
	distribution seen by SMEI
 CATEGORY:
	ucsd/camera/idl/zld
 CALLING SEQUENCE:
	FUNCTION smei_zld_dumbbell, r, $
	    degrees	    = degrees	    , $
	    silent	    = silent	    , $
	    zld_component   = zld_component
 INPUTS:
	r	    array[2] or array[2,n]; type: double
			Sun-centered ecliptic coordinates (longitude and
			latitude for points where correction is needed).
 OPTIONAL INPUT PARAMETERS:
	/degrees    if set, all angles are in degrees (default: radians)
	zld_component = zld_component
		    array; type: integer; default: none
			By default, both components (analytic and residue
			map) are returned.
			The values ZLD_MDL__FNC_DUMBBELL and ZLD_MDL__RES_DUMBBELL
			can be used in zld_component to extract either one
			of both components. The constants are defined in
			include file smei_zld_parts.pro
 OUTPUTS:
	Result	    scalar or array[n]
			brightness of zodiacal light correction in
			ADUs at nominal gain.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_zld_parts.pro
 CALLS: ***
	AngleRange, EulerRotate, InitVar, IsType, SyncDims, ToDegrees, ToRadians, WhatIs
 CALLED BY:
	smei_zld_model, test_dumbbell
 PROCEDURE:
	There is a discontinuity of < 0.6 ADUs on the ecliptic.

	The residual map is stored in $SMEIDB/c3zldresidue.fts.gz
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS)
	APR-2009, Paul Hick (UCSD/CASS)
	    Added /add_residue to add interpolated value from residue
	    zld map to analytic zld correction.
	DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Couple of bugfixes. Fairly substantial rewrite.
	    Removed /add_residue, and instead added keyword zld_component
	MAR-2010, John Clover (UCSD/CASS; jclover@ucsd.edu)
	    Bugfix with Sun centered ecliptic domain. Coords were 0
	    and positive in array to rightmost column, and 0 to negative
	    to leftmost column, causing some issue, latitudes are
	    shifted to be -180 to 180 degrees.
	    Added exclusion zone for 0-15 degrees elongation
	    from Sun and added dropoff starting at 75 degrees
	    elongation and added exclusion outside of 90 degrees
	    elongation from the Sun


smei_zld_model $SMEI/ucsd/camera/idl/zld/smei_zld_model.pro
[Previous] [Next]
 NAME:
	smei_zld_model
 PURPOSE:
	Implements the current analytic fit to the zodiacal light
	distribution for the SMEI observations
 CATEGORY:
	camera/idl/dust
 CALLING SEQUENCE:
	FUNCTION smei_zld_model, tt, rr, $
	    ndim	= ndim	    , $
	    range	= range_    , $
	    degrees	= degrees   , $
	    ecliptic	= ecliptic  , $
	    equatorial	= equatorial, $
	    model_1	= model_1   , $
	    model_2	= model_2   , $
	    model_3	= model_3   , $
	    model_4	= model_4   , $
	    use_zld_version=use_zld_version, $
	    version	= version   , $
	    get_version = get_version,$
	    silent	= silent    , $
	    camera	= camera    , $
	    zld_component = zld_component,  $
	    minelo	= minelo    , $

	    noslab	= noslab	; Obsolete (not used in model 4)
 INPUTS:
	tt	    array[1]; type: time structure
			UT time at which zodiacal light brightness is required
	rr	    array[2,*]; type: float or double
			angles defining the lines of sight for which brightness is required

			rr[0,*] is ecliptic longitude of los relative to Sun
			rr[1,*] is ecliptic latitude of los
			    (i.e. a helioecliptic coordinate system is assumed)

			if /ecliptic is SET:
			rr[0,*] is ecliptic longitude of los
			rr[1,*] is ecliptic latitude of los

			if /equatorial is SET:
			rr[0,*] is right ascension of los
			rr[1,*] is declination of los

			The units of the angles are set by keyword /degrees
			NOTE: it is allowed to specify rr as an array[3,*] with the
			3rd element in the first dimension the line of sight distance
			(only the angles are used)
 OPTIONAL INPUT PARAMETERS:
	ndim=ndim   array[2]; type: integer; default: none
			if present, a full-sky map is set up in the coordinate system
			implied by setting of /ecliptic and /equatorial
			The lines of sight used are returned in rr
	range=range array[2,2]; type: float; default: none
			range of grid in longitude and latitude.
			Used in conjunction with keyword 'ndim'.
			range[0:1,0]; start and end longitude
			range[0:1,0]; start and end latitude
			These are the outer bin edges, NOT the bin centers.
	/degrees    if SET the angles in argument 'rr' and 'range'
			are in degrees; default is radians
	/equatorial if SET then 'rr' is specified in equatorial coordinates
	/ecliptic   if SET then 'rr' is specified in ecliptic coordinates
			if neither /equatorial nor /ecliptic is set then 'rr' is
			assumed to be in helioecliptic coordinates

	/get_version	makes the zodial light model version number the
			function return value
	Each of the following keywords selects a different zld model. If none is set then
	/model_4 is used (this is the default model; the other ones are pretty much obsolete).
	The providence of the first three models is hazy at best.

	/model_1
	/model_2
	/model_3
	/model_4    this is the official, published model
	use_zld_version=use_zld_version
		    scalar; type: integer (1,2,3,4)
			alternative to setting one of the /model_* keywords
			Overrides /model_* keywords only if one of the valid
			integer values is passed

	The following four keywords are only applied for the default model (model_4)

	zld_component=zld_component
		array; type: integer; default: none

		    For the time being the default for model 4 only includes
		    the first three components.

		    By default, all zld components are included. Individual
		    components can be controlled by adding them to the zld_component,
		    an array of integers (defined in include file smei_zld_parts.pro)
		    indicating which components of the zld model will be included:
		    ZLD_MDL__BACKGROUND main background model
		    ZLD_MDL__GEGENSCHEIN    Gegenschein
		    ZLD_MDL__SLAB	    slab along ecliptic
		    ZLD_MDL__FNC_DUMBBELL   analytic dumbbell-shape component
		    ZLD_MDL__RES_DUMBBELL   static residue map
		    ZLD_MDL__FNC_WEEKLY     analytic time-dependent component
		    ZLD_MDL__RES_WEEKLY     weekly residue map
		The last two are NEVER applied to camera 3.
 OUTPUTS:
	result	    if /get_version NOT set:
		    array[*]; type: double
			the model brightness of the zodiacal dust cloud
		    if /get_version SET:
			version number of the zodiacal light model
	rr	    array[2,n,m]; type: double
			(only if keyword ndim is used)
			The lines of sight used to create a full-sky map
 OPTIONAL OUTPUTS:
	version=version scalar; type: float
		    returns the version number of the zodiacal light model
		    (as specified by the /model_* keywords)

 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_zld_parts.pro
 CALLS: ***
	AngleRange, AngleUnits, BadValue, CvSky, InitVar, IsType, ToRadians, WhatIs, big_eph
	destroyvar, gridgen, jpl_body, smei_zld_dumbbell, smei_zld_weekly
 CALLED BY:
	smei_sky_read, smei_star_remove, smei_zld_remove [1], smei_zld_remove [2]
	smei_zldsky
 EXAMPLE:
	To get the zodiacal dust cloud brightness on an equatorial grid with a resolution
	of one degree at the current time:

	tt = TimeSystem()
	rr = gridgen([360,180],/open,range=[[0,360],[-90,90]],/multid)
	zz = smei_zld_model(tt,rr,/degrees,/equatorial)

	returns an double precision array zz[360,180].
 PROCEDURE:
	Purely empirical fit

	The brightness scale corresponds to camera 2 at nominal gain 1.
	To subtract this model from a skymap the map needs to multiplied by the
	time- and camera-dependent gain factor returned by smei_camera_gain.
 MODIFICATION HISTORY:
	AUG-2006, Jordan Vaughan (jtvaugha@ucsd.edu), Paul Hick (UCSD/CASS)
	    Based on Andys zodiac_model.for, but substantially rewritten.
	DEC-2007, Paul Hick (UCSD/CASS)
	    Added second zodiacal light model (keyword /model_2),
	    based on the model first used for the comet movies.
	    The old model is available with keyword /model_1.
	APR-2008, Paul Hick (UCSD/CASS)
	    Next iteration on zld model added as /model_3.
	    (/model_2 remains the default).
	    Added keyword "version"
	NOV-2008, Paul Hick (UCSD/CASS)
	    Next iteration on zld model added as /model_4.
	DEC-2008, Paul Hick (UCSD/CASS)
	    Model 4 is now the default model (was model 2)
	    Bug fix in new model (V4.01)
	DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V4.02
	    Added static dumbbell and time-dependent (weekly)
	    corrections. Added keyword zld_component to control
	    which components are include in the returned zld model.
	    Increased version number from V4.01 to V4.02 to cover
	    a bugfix in smei_zld_remove (lores skymaps in
	    ext 5 and 6 did not have NaNs replaced by BAD_DATA
	    value in Fits header).
	MAY-2010, John Clover (UCSD/CASS), V4.03
	    Implements the full ZLD model with all functional
	    and residual adjustments.


smei_zld_parts $SMEI/ucsd/camera/idl/zld/smei_zld_parts.pro
[Previous] [Next]
 NAME:
	smei_zld_parts
 PURPOSE:
	Defines IDs for various parts of the zodiacal light model
 CATEGORY:
	camera/idl/zld
 CALLING SEQUENCE:
	@smei_zld_parts.pro
 PROCEDURE:
	Include where needed
 MODIFICATION HISTORY:
	JUN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added documentation


smei_zld_remove [1] $SMEI/ucsd/camera/idl/zld/smei_zld_remove.pro
[Previous] [Next]
 NAME:
	smei_zld_remove
 PURPOSE:
	Removes zodiacal light distribution from SMEI orbital sky maps
 CATEGORY:
	ucsd/camera/idl/zld
 CALLING SEQUENCE:
	PRO smei_zld_remove, wanted_map , $

	    destination = destination	, $
	    to_smeidb	= to_smeidb	, $

	    checkversion= checkversion	, $
	    overwrite	= overwrite	, $
	    force	= force 	, $
	    silent	= silent	, $

	    width	= width 	, $
	    reverse_loop= reverse_loop	, $

	    _extra	= _extra	, $
	    new_style_ecl    = new_style_ecl

 INPUTS:
	wanted_map	array[n]; type: see smei_getfile
			    Selects skymap files to be processed
			    in combination with other keywords passed
			    using _extra.
 OPTIONAL INPUT PARAMETERS:

	/to_smeidb	if set, write to directory structure as used
			    for SMEI data base (separate subdirs for mode
			    and camera) with 'destination' as the base dir.
	destination=destination
			scalar; type: string
			    destination directory for skymaps
			    if /to_smeidb NOT set then maps are written
				directly to 'destination'.
				The default in this case is $TUB
			    if /to_smeidb SET then files are written to
				a directory structure as used for the
				SMEI data base with 'destination' as the
				base directory.
				The default in this case is 'SMEIDB?' (the
				SMEI database).
			    If destination starts with a "user@host:" identifier then
			    the output is first created locally in $TUB
			    and is then transferred to the remote host using scp;
			    the local files will be deleted after the transfer;
			    note that this will only work if the remote host has
			    been configured for ssh using private/public keys
			    allowing login without passwords.
	/silent 	if set, suppresses informational messages

	/checkversion	overwrite existing skymaps only if the version
			number has increased.
	/overwrite	overwrite existing skymaps

	/new_style_ecl	forces creation of new-style ecl files (see PROCEDURE)
			When ready for the change to the new-style maps this
			keyword should be changed to /old_style_ecl to switch
			default operation to the new-style. At some point
			the /old_style_ecl probably should be removed altogether.

	_extra=_extra	keywords passed to smei_getfile
 OUTPUTS:
	Files in destination directory
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	ArrayLocation, BadValue, CheckDir, CvSky, FILEPATH, FXADDPAR, FXPAR, GetFileSpec
	HEADFITS, InitVar, IsType, MKHDR, READFITS, TimeGet, TimeOp, TimeSet, TimeSystem, TimeUnit
	WRITEFITS, big_eph, cvsmei, cvsmei_init, do_file, gridgen, gzip_file, hide_env, jpl_body
	smei_camera_gain, smei_filename, smei_filepath, smei_getfile, smei_sky
	smei_zld_model
 PROCEDURE:
	All maps in the ecl files are low-res maps (720 x 360, i.e. 0.5 degree resolution)
	Extension 0, 1, 5 and 6 are different in old-style and new-style maps

	Old-style ecl file:
	    Extension 0, Helioecliptic map HLNG=[-180,180],HLAT=[-90,+90]
		Helio-ecliptic map based on star-subtracted "bumpy" maps with zld removed
	    Extension 1, Helioecliptic map HLNG=[-180,180],HLAT=[-90,+90] (flat)
		Helio-ecliptic map based on star-subtracted "flat" maps with zld removed
	    Extension 2, Time (fraction of orbit) HLNG=[-180,180],HLAT=[-90,+90]
		Helio-ecliptic map of time in orbit as fraction of orbit
	    Extension 3, Time (sec since TORIGIN) HLNG=[-180,180],HLAT=[-90,+90]
		Helio-ecliptic map of time in orbit as seconds since TORIGIN
	    Extension 4, Contributing pixel count HLNG=[-180,180],HLAT=[-90,+90]
		Helio-ecliptic map of contributing pixel count
	    Extension 5, Equatorial map RA=[0,360],DEC=[-90,+90]
		Equatorial map based on star-subtracted "bumpy" maps with zld removed
	    Extension 6, Equatorial map RA=[0,360],DEC=[-90,+90] (flat)
		Equatorial map based on star-subtracted "flat" maps with zld removed
	    Extension 7, Time (fraction of orbit) RA=[0,360],DEC=[-90,+90]
		Equatorial map of time in orbit as fraction of orbit
	    Extension 8, Time (sec since TORIGIN) RA=[0,360],DEC=[-90,+90]
		Equatorial map of time in orbit as seconds since TORIGIN
	    Extension 9, Contributing pixel count RA=[0,360],DEC=[-90,+90]
		Equatorial map of contributing pixel count

	New-style ecl file:
	    Extension 0, Helioecliptic map HLNG=[-180,180],HLAT=[-90,+90] (no zld)
		Helio-ecliptic map based on star-subtracted "flat" maps with zld removed
		(this is extension 1 from the old-style ecl file)
	    Extension 1, Helioecliptic map HLNG=[-180,180],HLAT=[-90,+90] (with zld)
		Helio-ecliptic map based on star-subtracted "flat" maps with zld NOT removed
	    Extension 2, Time (fraction of orbit) HLNG=[-180,180],HLAT=[-90,+90]
		Helio-ecliptic map of time in orbit as fraction of orbit
	    Extension 3, Time (sec since TORIGIN) HLNG=[-180,180],HLAT=[-90,+90]
		Helio-ecliptic map of time in orbit as seconds since TORIGIN
	    Extension 4, Contributing pixel count HLNG=[-180,180],HLAT=[-90,+90]
		Helio-ecliptic map of contributing pixel count
	    Extension 5, Equatorial map RA=[0,360],DEC=[-90,+90] (no zld)
		Equatorial map based on star-subtracted "flat" maps with zld removed
		(this is extension 6 from the old-style ecl file)
	    Extension 6, Equatorial map RA=[0,360],DEC=[-90,+90] (with zld)
		Equatorial map based on star-subtracted "flat" maps with zld NOT removed
	    Extension 7, Time (fraction of orbit) RA=[0,360],DEC=[-90,+90]
		Equatorial map of time in orbit as fraction of orbit
	    Extension 8, Time (sec since TORIGIN) RA=[0,360],DEC=[-90,+90]
		Equatorial map of time in orbit as seconds since TORIGIN
	    Extension 9, Contributing pixel count RA=[0,360],DEC=[-90,+90]

 MODIFICATION HISTORY:
	SEP-2005, Paul Hick (UCSD/CASS), V1.0
	    Started, but never finished
	DEC-2007, Paul Hick (UCSD/CASS), v2.0
	    First working version. Now uses /model_2 in smei_zld_model
	FEB-2008, Paul Hick (UCSD/CASS)
	    Location of files now done using smei_getfile.
	APR-2008, Paul Hick (UCSD/CASS)
	    Rewrite. Not using smoothsphere to reduce resolution
	    (too slow). Instead the raw maps (equatorial, polar)
	    are now smoothed using the IDL smooth function. Then
	    The sun-centered ecliptic map is obtained using
	    bi-linear interpolation on the smoothed raw maps.
	    Version number will be increased once the next
	    (final?) zld model becomes available.
	SEP-2008, Paul	Hick (UCDS/CASS)
	    Added code to check star subtraction version and
	    sidereal background version when /checkversion is
	    set.
	DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added code to prepare for switch to new-style ecl file (see
	    PROCEDURE). For now the procedure works as before (producing
	    old-style ecl files) if the input equ file was made with
	    star-subtraction version < 7.0, unless the keyword /new_style_ecl
	    is set. For star subtraction version >= 7.0 only new-style
	    ecl files can be made.
	    Bug fix. For the equatorial skymaps (extensions 5 and 6) NaN values
	    were not replaced by the BAD_DATA value in the header.


smei_zld_remove [2] $SMEI/ucsd/camera/idl/zld/smei_zld_remove_old.pro
[Previous] [Next]
 NAME:
	smei_zld_remove
 PURPOSE:
	Removes zodiacal light distribution from SMEI orbital sky maps
 CATEGORY:
	ucsd/camera/idl/zld
 CALLING SEQUENCE:
	PRO smei_zld_remove, wanted_map , $

	    destination = destination	, $
	    to_smeidb	= to_smeidb	, $

	    checkversion= checkversion	, $
	    overwrite	= overwrite	, $
	    force	= force 	, $
	    silent	= silent	, $

	    width	= width 	, $
	    reverse_loop= reverse_loop	, $

	    _extra	= _extra	, $
	    keep_gegenschein = keep_gegenschein

 INPUTS:
	wanted_map	array[n]; type: see smei_getfile
			    Selects skymap files to be processed
			    in combination with other keywords passed
			    using _extra.
 OPTIONAL INPUT PARAMETERS:

	/to_smeidb	if set, write to directory structure as used
			    for SMEI data base (separate subdirs for mode
			    and camera) with 'destination' as the base dir.
	destination=destination
			scalar; type: string
			    destination directory for skymaps
			    if /to_smeidb NOT set then maps are written
				directly to 'destination'.
				The default in this case is $TUB
			    if /to_smeidb SET then files are written to
				a directory structure as used for the
				SMEI data base with 'destination' as the
				base directory.
				The default in this case is 'SMEIDB?' (the
				SMEI database).
			    If destination starts with a "user@host:" identifier then
			    the output is first created locally in $TUB
			    and is then transferred to the remote host using scp;
			    the local files will be deleted after the transfer;
			    note that this will only work if the remote host has
			    been configured for ssh using private/public keys
			    allowing login without passwords.
	/silent 	if set, suppresses informational messages

	/checkversion	overwrite existing skymaps only if the version
			number has increased.
	/overwrite	overwrite existing skymaps

	_extra=_extra	keywords passed to smei_getfile
 OUTPUTS:
	Files in destination directory
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS:
	ArrayLocation, BadValue, CheckDir, CvSky, GetFileSpec, InitVar, IsType, TimeGet, TimeOp
	TimeSet, TimeSystem, TimeUnit, big_eph, gridgen, gzip_file, hide_env, jpl_body
	smei_camera_gain, smei_filename, smei_sky, smei_zld_model
 PROCEDURE:
 MODIFICATION HISTORY:
	SEP-2005, Paul Hick (UCSD/CASS), V1.0
	    Started, but never finished
	DEC-2007, Paul Hick (UCSD/CASS), v2.0
	    First working version. Now uses /model_2 in smei_zld_model
	FEB-2008, Paul Hick (UCSD/CASS)
	    Location of files now done using smei_getfile.
	APR-2008, Paul Hick (UCSD/CASS; ppick@ucsd.edu)
	    Rewrite. Not using smoothsphere to reduce resolution
	    (too slow). Instead the raw maps (equatorial, polar)
	    are now smoothed using the IDL smooth function. Then
	    The sun-centered ecliptic map is obtained using
	    bi-linear interpolation on the smoothed raw maps.
	    Version number will be increased once the next
	    (final?) zld model becomes available.
	SEP-2008, Paul	Hick (UCDS/CASS; pphick@ucsd.edu)
	    Added code to check star subtraction version and
	    sidereal background version when /checkversion is
	    set.


smei_zld_weekly $SMEI/ucsd/camera/idl/zld/smei_zld_weekly.pro
[Previous] [Next]
 NAME:
	smei_zld_weekly
 PURPOSE:
 CATEGORY:
	camera/idl/zld
 CALLING SEQUENCE:
	FUNCTION smei_zld_weekly, t, r	, $
	    elo_angle	    = elo_angle     , $
	    pa_angle	    = pa_angle	    , $
	    degrees	    = degrees	    , $
	    silent	    = silent	    , $
	    zld_component   = zld_component
 INPUTS:
	t	array[1]; type: time structure
	r	array[2,n]; type: float
		    Sun-centered ecliptic longitude and latitude
 OPTIONAL INPUT PARAMETERS:
	elo_angle=elo_angle
		array[n]; type: float
		    solar elongation of locations r
		    (calculated from r if not specified)
	pa_angle=pa_angle
		array[n]; type: float
		    position angle of locations r: angle from
		    ecliptic north measured counter-clockwise
		    (calculated from r if not specified)
	/degrees    if set then angles are in degrees (default: radians)
	zld_component = zld_component
		array; type: integer; default: none
		    By default, both components (analytic and residue
		    map) are returned.
		    The values ZLD_MDL__FNC_WEEKLY and ZLD_MDL__RES_WEEKLY
		    can be used in zld_component to extract either one
		    of both components. The constants are defined in
		    include file smei_zld_parts.pro
 OUTPUTS:
	R	array; type: double
		    zodiacal brightness at locations r
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
	@smei_zld_parts.pro
 CALLS: ***
	AngleRange, FILEPATH, InitVar, IsTime, IsType, READFITS, SyncDims, TimeGet, TimeOp
	TimeSet, TimeUnit, ToDegrees, WhatIs, big_eph, cvsmei, sgp4_orbit_axis
	sphere_distance
 CALLED BY:
	smei_zld_model
 PROCEDURE:
	Correction consists of an analytic part, plus
	a residual map based on a sequence of 52 weekly residues.

	The analytic correction consists of a strictly time-depenent
	part that matches cameras 2 and 3, and corrects for discontinuities
	in camera 3 introduced by different "bad-pixel" masks, and a second
	part that depends on the orientation of the Coriolis orbital plane
	relative to the Sun.

	The residue maps are stored in $SMEIDB/c3zldresidue.fts.gz. The
	residual correction is calculated by lineary interpolation between
	two neigbouring weekly maps.
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS)
	DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Removed /add_residue, and instead added keyword zld_component.


smei_zldsky $SMEI/ucsd/camera/idl/zld/smei_zldsky.pro
[Previous] [Next]
 NAME:
	smei_zldsky
 PURPOSE:
	Quick and dirty way for plotting the zodiacal light models
	in smei_zld_model
 CATEGORY:
	camera/idl/zld
 CALLING SEQUENCE:
	PRO smei_zldsky, tt, $
	    nra 	    = nra	    , $
	    ndec	    = ndec	    , $
	    equatorial	    = equatorial    , $
	    degrees	    = degrees	    , $
	    zero_shift	    = zero_shift    , $
	    _extra	    = _extra
 INPUTS:
	tt	array[1]; type: time structure
 OPTIONAL INPUT PARAMETERS:
	nra=nra     scalar; type: integer
			nr of elements for right ascension
	ndec=ndec   scalar; type: integer
			nr of elemens for declination
	/equatorial
	/degrees
	zero_shift=zero_shift
	_extra=_extra
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, InitVar, PlotEarthSkymap [1], PlotEarthSkymap [2]
	PlotEarthSkymap [3], PlotEarthSkymap [4], TimeSystem, ToDegrees, ToRadians, WhatIs
	get_page, gridgen, set_page, smei_zld_model
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smeidb_mounted $SMEI/ucsd/camera/idl/toolbox/smeidb_mounted.pro
[Previous] [Next]
 NAME:
	smeidb_mounted
 PURPOSE:
	Check whether SMEI data base is accessible
 CATEGORY:
	camera/idl/misc
 CALLING SEQUENCE:
	FUNCTION smeidb_mounted, tf, drive=drive
 INPUTS:
	tf	    scalar, or array[1]
			    either a time (in the form of a standard
			    time structure), or the name of a SMEI frame
			    (e.g. 'c2frm_2003_123_456789')
 OPTIONAL INPUT PARAMETERS:
	The SMEI frames are stored in directories of the form
	$SMEIDB#/yyyy_doy/c#.
 OUTPUTS:
	sts scalar; type: string
		directory where frame(s) for specified time are located
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	smei_orbit_stats
 COMMON BLOCKS:
	common smei_filepath_save, checkdrives, sdat
 CALLS: ***
	CheckDir, FILEPATH, InitVar, IsTime, IsType, TimeGet, TimeSet, destroyvar, flt_read
	flt_string, smei_filepath, timeposn, who_am_i
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2004, Paul Hick (UCSD/CASS)
	MAR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Introduced timeposn call to extract time from frame


smeifig $SMEI/user/pphick/idl/figures/smeifig.pro
[Previous] [Next]
 NAME:
	smeifig
 CALLING SEQUENCE:
	PRO smeifig, figure, xysize=xysize,_extra=_extra
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, LOADCT, arrow3d, get_page, plot3darc, plot3dline, plot3dtext, set_page, setup3d
	twin, vectorproduct


SMEIremoteDisplay__define $SMEI/ucsd/sat/idl/remoteview/smeiremote/smeiremotedisplay__define.pro
[Previous] [Next]
 NAME:
	SMEIremoteDisplay__define
 PURPOSE:
	Defines SMEIremoteDisplay class structure
 CATEGORY:
	SMEIremote
 CALLING SEQUENCE:
	display = obj_new('SMEIremoteDisplay')
 INPUTS:
 INCLUDE:
	@compile_opt.pro	    ; On error, return to caller
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


SMEIremoteFOV__define $SMEI/ucsd/sat/idl/remoteview/smeiremote/smeiremotefov__define.pro
[Previous] [Next]
 NAME:
	SMEIremoteFOV__define
 PURPOSE:
	Defines SMEIremoteFOV class structure
 CATEGORY:
	SMEIremote
 CALLING SEQUENCE:
	fov = obj_new('SMEIremoteFOV')
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS:
 SEE ALSO:
 SIDE EFFECTS:
 RESTRICTIONS:
 EXAMPLE:
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


SMEIremoteMatrix__define $SMEI/ucsd/sat/idl/remoteview/smeiremote/smeiremotematrix__define.pro
[Previous] [Next]
 NAME:
	SMEIremoteMatrix__define
 PURPOSE:
	Defines SMEIremoteMatrix class structure
 CATEGORY:
	SMEIremote
 CALLING SEQUENCE:
	fov = obj_new('SMEIremoteMatrix')
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS:
 SEE ALSO:
 SIDE EFFECTS:
 RESTRICTIONS:
 EXAMPLE:
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


SMEIremoteView__define $SMEI/ucsd/sat/idl/remoteview/smeiremote/smeiremoteview__define.pro
[Previous] [Next]
 NAME:
	SMEIremoteView__define
 PURPOSE:
	Defines SMEIremoteView class structure
 CATEGORY:
	SMEIremote
 CALLING SEQUENCE:
	fov = obj_new('SMEIremoteView')
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS:
 SEE ALSO:
 SIDE EFFECTS:
 RESTRICTIONS:
 EXAMPLE:
 PROCEDURE:
 MODIFICATION HISTORY:
	AUG-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


smooc $SMEI/user/bjackson/c1_differencer/c1_wsmdif.pro
[Previous] [Next]
 NAME:
	smooc
 PURPOSE:
	This function smooths an image file within the boundaries of the
	windowed area so that point glitches, cosmic rays, especially
	are removed from the images.
 CALLING SEQUENCE:
	function smooc,ar,nh,nv,xsize,ysize,minx,maxx,miny,maxy,difmax,i2
 CALLS: ***
	C1_WSMDIF, COSRMV, WRITEFITS


sphere_distance $SMEI/ucsd/sat/idl/toolbox/math/sphere_distance.pro
[Previous] [Next]
 NAME:
	sphere_distance
 PURPOSE:
	Get angle between two vectors
 CATEGORY:
	sat/idl/toolbox/math
 CALLING SEQUENCE:
	FUNCTION sphere_distance, Los1, Los2, Los3, Los4, Los5, Los6, $
	    degrees	= degrees	, $
	    rectangular = rectangular	, $
	    eps 	= eps
 INPUTS:
	Los1, Los2	any arrays with 1st dimension of 2 or 3 elements
			containing vector coordinates in spherical
			(longitude, latitude, distance) or rectangular (x,y,z)
			coordinates.
 OPTIONAL INPUT PARAMETERS:
	/degrees	if set, all angles are in degrees (default: radians)
	/rectangular	if set, Los1 and Los2 are in rectangular (x,y,z) coordinates
 OUTPUTS:
	E		distances in range [0,180] degrees.
			The array size is the same as for the input array with
			the 1st dimension removed.
 OPTIONAL OUTPUT PARAMETERS:
	eps=eps 	position angle of Los2 relative to north at Los2
			(only works if /rectangular is NOT set)
 INCLUDE:
	@compile_opt.pro	    ; On error, return to caller
 CALLS: ***
	InitVar, IsType, SubArray, SuperArray, SyncArgs, SyncDims, ToRadians
 CALLED BY:
	PlotCoronagraph, PlotEarthSkymap [1], PlotEloTimeMap, RemoteView_FOV_Cube
	RemoteView_Init_FOV, ThomsonLOSRomb, ThomsonLOSStep, big_elongation
	coriolis_map, cv, eclipsed_area, maygeometry, qnagoya_plot, smei_findpnt
	smei_frm_summary, smei_hdr_plot, smei_sgp4_orbits, smei_star_fit, smei_star_test
	smei_zld_weekly, sphere_great_arc, sphere_smooth, stardistance, vu_point_source
 EXAMPLE:
	Specify vectors in spherical coordinates (all in the equatorial plane).
	Every vector in los2 is combined with the vector in los1. All angles are in degrees.

	los1 = [0,0,1]
	los2 = [[0,0,1], [45,0,1], [90,0,1], [135,0,1], [180,0,1]]
	e = sphere_distance(los1, los2, /degrees)
	print, e
	    0.000000	  45.0000      90.0000	    135.000	 180.000
	help, los1, los2, e
	    LOS1	    INT       = Array[3]
	    LOS2	    INT       = Array[3, 5]
	    E		    FLOAT     = Array[5]
 PROCEDURE:
	Apply the following to the longitude and latitude angles:
	L = acos( sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lng1-lng2) )
 MODIFICATION HISTORY:
	AUG-2000, Paul Hick (UCSD/CASS)
	DEC-2000, Paul Hick (UCSD/CASS)
	    Modified to accept vector arrays of any number of dimensions
	JUL-2006, Paul Hick (UCSD/CASS)
	    Added option to provide components of vectors seperately
	    (using 4 or 6 arguments).
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword 'eps'. Renamed from 'elongation' to
	    'sphere_distance'


sphere_great_arc $SMEI/ucsd/sat/idl/toolbox/math/sphere_great_arc.pro
[Previous] [Next]
 NAME:
	sphere_great_arc
 PURPOSE:
	Returns array of points along great circle
	connecting two points on sphere
 CATEGORY:
	sat/widget/qimage_cw
 CALLING SEQUENCE:
	FUNCTION sphere_great_arc, los1, los2, $
	    npoints = npoints	, $
	    degrees = degrees
 INPUTS:
	los1
	los2
 OPTIONAL INPUT PARAMETERS:
	npoints = npoints
	/degrees
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, SyncArgs, ToRadians, gridgen, sphere_distance
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


sphere_smooth $SMEI/ucsd/sat/idl/toolbox/math/sphere_smooth.pro
[Previous] [Next]
 NAME:
	sphere_smooth
 PURPOSE:
	Smooths data on a sphere
 CATEGORY:
	sat/idl/toolbox/math
 CALLING SEQUENCE:
	FUNCTION sphere_smooth, FF  , $

	    irange	= irange    , $
	    igrid	= igrid     , $     ; Input grid

	    odim	= odim_     , $     ; Output grid
	    orange	= orange    , $
	    ogrid	= ogrid     , $

	    width	= width     , $
	    gauss	= gauss     , $
	    degrees	= degrees   , $

	    weightfnc	= weightfnc , $

	    fillall	= fillall   , $
	    fillbad	= fillbad   , $
	    fillgood	= fillgood  , $

	    min_weight	= min_weight
 INPUTS:
	FF		array[N,M,L]; type: any numerical type
			    N: longitudinal dimension
			    M: latitudinal dimension
			    L: number of arrays to be smoothed
 OPTIONAL INPUT PARAMETERS:
	irange=irange	array[2,2]; type: float; default: [[0,360],[-90,90]]
			Specifies the range of the input grid on which
			F is defined
			    irange[*,0]: longitude range
			    irange[*,1]: latitude range
			The grid specifies a skymap in
			equirectangular projection
	igrid=igrid	array[2,N,M]; type: float
			Instead of giving irange, the grid can be specified
			explicitly:
			    igrid[0,*,*]: longitudes
			    igrid[1,*,*]; latitudes
			Note that the grid must still be equirectangular

	odim=odim	array[2]; type: integer; default: [N,M]
			    dimensions of smoothed output skymap
			    The dimensions must be smaller then/equal to
			    the input dimensions and must be a factor of
			    the input dimensions.
	orange=orange	array[2,2]; type: float; default: irange
			Specifies the range of the output grid on which
			R is defined.
			    orange[*,0]; longitude range
			    orange[*,1]: latitude range
			Again, this is a equirectangular grid.
	ogrid=ogrid	array[2,n,m]; type: float
			Instead of giving odim and orange, the output
			grid can be specified explicitly:
			    grid[0,*,*]: longitudes
			    grid[1,*,*]; latitudes
	width=width	scalare; type: float; default: 1 degree
			width used to select points near each grid point
			to be used for a weighted mean.
	/gauss		forces use of a Gaussian weighting function
			with width specified in keyword 'width'.
	/degrees	if set, all angles are in degrees; default: radians

	weight_fnc=weight_fnc
			name of user-defined function to be used to calculate
			weight (see PROCEDURE).

	min_weight	threshold for the weights. Smoothed values are ignored
			if the total weight of the contributing input bins
			is less then min_weight

	/fillbad	only fill-in 'bad' values (NaN in input array FF)
			with smoothed values. This is only allowed if the
			input dimension (N,M) are the same as the output
			dimension odim.
	/fillgood	only replace good values with smoothed values
	/fillall	fill all values (both good and bad) by smoothed
			values, i.e., same as setting both /fillbad, /fillgood.
			This is also the default if neither /fillbad nor
			/fillgood is set.
 OUTPUTS:
	R		array[n,m]; type: same as FF
			    smoothed output skymap
 OPTIONAL OUTPUT PARAMETERS:
	igrid=igrid	if not defined on input, they are returned as calculated
	ogrid=ogrid	.. from the *dim and *range keywords.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, ArrayLocation, BadValue, InitVar, IsType, SubArray, SuperArray, ToDegrees
	ToRadians, gridgen, sphere_distance
 PROCEDURE:
 >	If neither /gauss, nor weight_fnc is set than all points within
	'width' (angular separation) of a grid point will be averaged with
	the same weight.
 >	If /gauss is set a Gaussian weight is used in the calculation
	of the average (with weight exp(-(elo/width)^2). Contributing points
	will extend to about 3*width away in angular separation.
 >	A user-defined function weight_fnc can be used to calculate the weight.
	The function should have the form
	    W = weight_fnc(elo, width=width, degrees=degrees)
	with 'elo' (in units indicated by keyword 'degrees') the elongation,
	and 'width' the input argument 'width' to this function.
 MODIFICATION HISTORY:
	JAN-2008, Paul Hick (UCSD/CASS)
	APR-2008, Paul Hick (UCSD/CASS)
	    Bugfix. Weighting was done wrong.
	APR-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Fixed problem with /fillbad keyword. Procedure will now abort
	    if /fillbad is set and (some) of the points from the output grid
	    are not present in the input grid (this is necessary to be able
	    to retain good values from input array in the output array.


spokes $SMEI/user/pphick/idl/spokes.pro
[Previous] [Next]
 NAME:
	spokes
 CALLING SEQUENCE:
	PRO spokes
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	READFITS, WRITEFITS, WhatIs, gridgen


square_on_sky $SMEI/user/pphick/idl/square_on_sky.pro
[Previous] [Next]
 NAME:
	square_on_sky
 CALLING SEQUENCE:
	PRO square_on_sky
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	twin


ss_map $SMEI/user/pphick/idl/ss_map.pro
[Previous] [Next]
 NAME:
	ss_map
 CALLING SEQUENCE:
	pro ss_map, axyz=axyz
 INCLUDE:
	@compile_opt.pro
COMMON:
common defcolor
pforeground
pbackground
common ss_br_map
v_br
p_br
 CALLS: ***
	AngleRange, CARRINGTONT, CV_COORD, CvSky, FLT3DGEN, PLOT3DAXIS, READ_TOMOGRAPHY_B3D
	gridfill, plot3darc, setup3d, twin


stardistance $SMEI/user/pphick/idl/stardistance.pro
[Previous] [Next]
 NAME:
	stardistance
 PURPOSE:
 CALLING SEQUENCE:
	PRO stardistance, arcmax=arcmax, mkelo=mkelo, tmo=tmo
 INCLUDE:
	@compile_opt.pro
 CALLING SEQUENCE:
 CALLS: ***
	AngleUnits, BadValue, CV_COORD, EulerRotate, FILEPATH, FindAllFiles, GeographicInfo
	InitVar, Inside_Wedge, IsType, LINEARLSQFIT, MagnifyArray, REVERSE, SuperArray
	TimeGet, TimeOp, TimeSet, bin_read, cvsmei, destroyvar, flat_centerofmass, gridgen
	jpl_body, jpl_eph, lsqLinearFit, smei_camera, smei_frm_read, smei_frm_where
	smei_pick_stars, smei_property, smei_star_info, smei_star_list, sphere_distance
	view, wedge_bounding_box, wedge_content
 MODIFICATION HISTORY:


statpos $SMEI/ucsd/sat/idl/toolbox/tricks/statpos.pro
[Previous] [Next]
 NAME:
	statpos
 PURPOSE:
	Calculate position of average, median and maximum of array
 CATEGORY:
	Statistics
 CALLING SEQUENCE:
	FUNCTION statpos, Y	, $
	    min     = min	, $
	    max     = max	, $
	    binsize = binsize	, $
	    hist    = hist	, $
	    fraction= fraction
 INPUTS:    (read-only)
	A   array	array for which median value is requested
			    A should already represent a histogram
			    If it isn't use one of the histogram
			    keywords
 OPTIONAL INPUT PARAMETERS:
	min=min
	max=max
	binsize=binsize
			if any one of these keywords is set then
			array Y is fed to the IDL histogram function
			with these keywords.
	fraction=fraction
			scalar; type: float; default: 0.5
			    sets the fraction used for the median
			    calculation, i.e. finds the position
			    where 'fraction' are lower and 1-fraction
			    are higher.
 OUTPUTS:
	STATPOS     3 element float array
	    StatPos[0]	position of average ('center of mass')
	    StatPos[1]	position of median
	    StatPos[2]	position of maximum
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType
 CALLED BY:
	bargraph
 PROCEDURE:
	The values returned by StatPos are based on the array index, i.e.
	0 <= StatPos[i] <= n_elements(A)-1  (i=0,1,2)

	Note that the average calculated here from the histogram depends
	on the bin size. Use the mean function if that's a problem.
 MODIFICATION HISTORY:
	MAY-1993, Paul Hick (UCSD/CASS)
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added keyword 'fraction'


StereoAOrbit $SMEI/ucsd/gen/idl/ephem/stereoaorbit.pro
[Previous] [Next]
 NAME:
	StereoAOrbit
 PURPOSE:
	Calculate position of Stereo A (Ahead)
 CATEGORY:
	smei/gen/idl/ephem
 CALLING SEQUENCE:
	FUNCTION StereoAOrbit, T, degrees=degrees
 INPUTS:
	T	array[n]; type: time structure
		    times at which s/c positions are needed
 OPTIONAL INPUT PARAMETERS:
	/degrees    if set then angles are output in degrees
		(default: radians)
 OUTPUTS:
	Result	array[3,*]; type: float
		    J2000 ecliptic longitude (deg/rad), latitude
		    (deg/rad) and distance (AU).
		    The angular units depend on the setting of /degrees
 INCLUDE:
	@compile_opt.pro    ; On error, return to caller
 CALLS: ***
	BadValue, KeplerOrbit, TimeGet, TimeSet, ToDegrees
 CALLED BY:
	big_eph
 RESTRICTIONS:
	The precision is probably about 0.1 degrees in ecliptic longitude,
	provided orbital elements are added as needed (once or twice year?)
 PROCECURE:
	From http://ssd.jpl.nasa.gov/horizons.cgi
	(J2000.0 Orbital Elements)
	Elements cover four periods between 2007/01/01 and 2007/09/30:

	2007/01/01 -> 2007/01/31

	2454115.500000000 = A.D. 2007-Jan-15 00:00:00.0000 (CT)
	 EC= 9.509555173766652E-03 QR= 9.620747268989945E-01 IN= 1.306235954146905E-01
	 OM= 2.380953113698972E+02 W = 3.355229542907300E+02 Tp=  2454210.608155566733
	 N = 1.029594704279364E+00 MA= 2.620771466946642E+02 TA= 2.609996629128498E+02
	 A = 9.713114668842425E-01 AD= 9.805482068694904E-01 PR= 3.496521480770163E+02

	2007/02/01 -> 2007/02/28

	2454147.500000000 = A.D. 2007-Feb-16 00:00:00.0000 (CT)
	 EC= 6.279052167650651E-03 QR= 9.596197332195503E-01 IN= 1.213139724936570E-01
	 OM= 2.169765459780858E+02 W = 5.374894575771112E+01 Tp=  2454265.510775187053
	 N = 1.038608771871410E+00 MA= 2.374329737152352E+02 TA= 2.368291467561132E+02
	 A = 9.656833090947861E-01 AD= 9.717468849700218E-01 PR= 3.466175231231067E+02

	2007/03/01 -> 2007/03/31

	2454175.500000000 = A.D. 2007-Mar-16 00:00:00.0000 (CT)
	 EC= 6.226246274394636E-03 QR= 9.577018334129234E-01 IN= 1.234975641202794E-01
	 OM= 2.149185709343068E+02 W = 7.828787777683904E+01 Tp=  2454286.911843170412
	 N = 1.041813256894421E+00 MA= 2.439296648101152E+02 TA= 2.432909800026552E+02
	 A = 9.637020798975118E-01 AD= 9.697023263821002E-01 PR= 3.455513717238894E+02

	2007/04/01 -> 2007/10/01

	2454253.500000000 = A.D. 2007-Jun-02 00:00:00.0000 (CT)
	 EC= 5.917966070544746E-03 QR= 9.565996862733112E-01 IN= 1.251469150146348E-01
	 OM= 2.143572837656983E+02 W = 9.239562034525594E+01 Tp=  2454299.754766134545
	 N = 1.044099914070154E+00 MA= 3.117054026536591E+02 TA= 3.111966164343318E+02
	 A = 9.622945125484443E-01 AD= 9.679893388235775E-01 PR= 3.447945882847869E+02

	2007/10/01 -> now

	2454466.500000000 = A.D. 2008-Jan-01 00:00:00.0000 (CT)
	 EC= 5.655394382946006E-03 QR= 9.564978161375505E-01 IN= 1.253836830038676E-01
	 OM= 2.142571411361414E+02 W = 9.225614784090398E+01 Tp=  2454299.536585085094
	 N = 1.044680486714094E+00 MA= 1.744234215566499E+02 TA= 1.744859573944121E+02
	 A = 9.619379546429810E-01 AD= 9.673780931484115E-01 PR= 3.446029715098184E+02

	2011/01/21 -> 2012/01/21

	2455583.500000000 = A.D. 2011-Jan-22 00:00:00.0000 (CT)
	 EC= 5.649610774525156E-03 QR= 9.563712745374616E-01 IN= 1.256261457055498E-01
	 OM= 2.140504362161804E+02 W = 9.348075068567380E+01 Tp=  2455678.680902264081
	 N = 1.044896949233696E+00 MA= 2.605457655988884E+02 TA= 2.599079145507906E+02
	 A = 9.618050989876956E-01 AD= 9.672389234379295E-01 PR= 3.445315830082727E+02

	2012/01/21 -> now

	2455948.500000000 = A.D. 2012-Jan-22 00:00:00.0000 (CT)
	 EC= 5.705938568515530E-03 QR= 9.563266675804051E-01 IN= 1.257640058659871E-01
	 OM= 2.139833070619798E+02 W = 9.406913424182217E+01 Tp=  2456023.716625969391
	 N = 1.044881265762684E+00 MA= 2.814075566505216E+02 TA= 2.807657290779928E+02
	 A = 9.618147233058820E-01 AD= 9.673027790313589E-01 PR= 3.445367543624463E+02


    JDCT     Epoch Julian Date, Coordinate Time
      EC     Eccentricity, e
      QR     Periapsis distance, q (AU)
      IN     Inclination w.r.t xy-plane, i (degrees)
      OM     Longitude of Ascending Node, OMEGA, (degrees)
      W      Argument of Perifocus, w (degrees)
      Tp     Time of periapsis (Julian day number)
      N      Mean motion, n (degrees/day)
      MA     Mean anomaly, M (degrees)
      TA     True anomaly, nu (degrees)
      A      Semi-major axis, a (AU)
      AD     Apoapsis distance (AU)
      PR     Orbital period (day)
 MODIFICATION HISTORY:
	AUG-2007, George Megally (UCSD/CASS; gmegally@ucsd.edu)
	AUG-2007, John Clover (UCSD/CASS; jclover@ucsd.edu)
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Split up into seperate routines for A and B.
	    Updated orbital elements from Horizon (almost, but not quite the
	    same as the original ones).
	JUN-2009, John Clover (UCSD/CASS; jclover@ucsd.edu)
	    Fixed time structure to cover the whole of the end of the day between
	    elements.


StereoBOrbit $SMEI/ucsd/gen/idl/ephem/stereoborbit.pro
[Previous] [Next]
 NAME:
	StereoBOrbit
 PURPOSE:
	Calculate position of Stereo B (Behind)
 CATEGORY:
	smei/gen/idl/ephem
 CALLING SEQUENCE:
	FUNCTION StereoBOrbit, T, degrees=degrees
 INPUTS:
	T	    array[n]; type: time structure
			times at which s/c positions are needed
 OPTIONAL INPUT PARAMETERS:
	/degrees    if set then angles are output in degrees (default: radians)
 OUTPUTS:
	Result	    array[3,*]; type: float
			J2000 ecliptic longitude (deg/rad), latitude
			(deg/rad) and distance (AU).
			The angular units depend on the setting of /degrees
 INCLUDE:
	@compile_opt.pro    ; On error, return to caller
 CALLS: ***
	BadValue, KeplerOrbit, TimeGet, TimeSet, ToDegrees
 CALLED BY:
	big_eph
 RESTRICTIONS:
	The precision is probably about 0.1 degrees in ecliptic longitude,
	provided orbital elements are added as needed (once or twice year?)
 PROCECURE:
	From http://ssd.jpl.nasa.gov/horizons.cgi
	(J2000.0 Orbital Elements)
	Elements cover four periods between 2007/01/01 and 2007/09/30:

	2007/01/01 -> 2007/01/31

	2454115.500000000 = A.D. 2007-Jan-15 00:00:00.0000 (CT)
	 EC= 2.717512429419864E-02 QR= 9.315766343405397E-01 IN= 2.062856692554812E-01
	 OM= 1.265504225590081E+02 W = 2.009817559818071E+02 Tp=  2453977.546381154098
	 N = 1.051787957703235E+00 MA= 1.450979550234674E+02 TA= 1.468311244708070E+02
	 A = 9.575995203295605E-01 AD= 9.836224063185813E-01 PR= 3.422743123871886E+02

	2007/02/01 -> 2007/02/28

	2454147.500000000 = A.D. 2007-Feb-16 00:00:00.0000 (CT)
	 EC= 4.699285093170608E-02 QR= 9.871128055468245E-01 IN= 2.992287472926523E-01
	 OM= 3.392409078493881E+02 W = 1.283202740400959E+02 Tp=  2454109.145052516367
	 N = 9.349709833378660E-01 MA= 3.586076296454760E+01 TA= 3.917087846701419E+01
	 A = 1.035787408847744E+00 AD= 1.084462012148664E+00 PR= 3.850386872058772E+02

	2007/03/01 -> 2007/03/31

	2454175.500000000 = A.D. 2007-Mar-16 00:00:00.0000 (CT)
	 EC= 4.372120282913373E-02 QR= 9.936734937715849E-01 IN= 3.079140638493386E-01
	 OM= 3.385303364716559E+02 W = 1.396338867376834E+02 Tp=  2454119.296489763539
	 N = 9.304977044270033E-01 MA= 5.229723725577440E+01 TA= 5.639454403113316E+01
	 A = 1.039104387456201E+00 AD= 1.084535281140816E+00 PR= 3.868897239479882E+02

	2007/04/01 -> 2007/10/01

	2454253.500000000 = A.D. 2007-Jun-02 00:00:00.0000 (CT)
	 EC= 4.182627806223717E-02 QR= 9.986984397920566E-01 IN= 2.942094890131228E-01
	 OM= 3.365510702179411E+02 W = 1.467482264878249E+02 Tp=  2454124.112501636613
	 N = 9.262301226788787E-01 MA= 1.198425984820785E+02 TA= 1.238910903027097E+02
	 A = 1.042293706168792E+00 AD= 1.085888972545528E+00 PR= 3.886723085174492E+02

	2007/10/01 -> now

	2454466.500000000 = A.D. 2008-Jan-01 00:00:00.0000 (CT)
	 EC= 4.143096626093998E-02 QR= 9.996061655975762E-01 IN= 2.943195765731059E-01
	 OM= 3.364601578200525E+02 W = 1.467863556683245E+02 Tp=  2454512.857852065004
	 N = 9.255412455738544E-01 MA= 3.170938958574695E+02 TA= 3.137364080607738E+02
	 A = 1.042810825735152E+00 AD= 1.086015485872728E+00 PR= 3.889615959543680E+02

    JDCT     Epoch Julian Date, Coordinate Time
      EC     Eccentricity, e
      QR     Periapsis distance, q (AU)
      IN     Inclination w.r.t xy-plane, i (degrees)
      OM     Longitude of Ascending Node, OMEGA, (degrees)
      W      Argument of Perifocus, w (degrees)
      Tp     Time of periapsis (Julian day number)
      N      Mean motion, n (degrees/day)
      MA     Mean anomaly, M (degrees)
      TA     True anomaly, nu (degrees)
      A      Semi-major axis, a (AU)
      AD     Apoapsis distance (AU)
      PR     Orbital period (day)
 MODIFICATION HISTORY:
	AUG-2007, George Megally (UCSD/CASS; gmegally@ucsd.edu)
	AUG-2007, John Clover (UCSD/CASS; jclover@ucsd.edu)
	JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Split up into seperate routines for A and B.
	    Updated orbital elements from Horizon (almost, but not quite the
	    same as the original ones).
       JUN-2009, John Clover (UCSD/CASS; jclover@ucsd.edu)
	       Fixed time structure to cover the whole of the end of the day between
	       elements.


stopwatch $SMEI/ucsd/sat/idl/toolbox/tricks/stopwatch.pro
[Previous] [Next]
 NAME:
	stopwatch
 PURPOSE:
 CATEGORY:
	Totally unnecessary
 CALLING SEQUENCE:
	PRO stopwatch, set=set, start=start, stop=stop
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType, TimeGet, TimeOp, TimeSystem, TimeUnit
 CALLED BY:
	flt_read
 MODIFICATION HISTORY:
	JUL-2003, Paul Hick (UCSD/CASS)


strbreak $SMEI/ucsd/gen/idl/toolbox/strbreak.pro
[Previous] [Next]
 NAME:
	strbreak
 PURPOSE:
	Split string in pieces at white space
 CALLING SEQUENCE:
	FUNCTION strbreak, label, tokens=tokens
 COMMON:
	@compile_opt.pro
 CALLS: ***
	boost, destroyvar
 CALLED BY:
	txt_block_read
 PROCEDURE:
	Substrings enclosed by double quotes are left intact,
	i.e. are treated as a single piece without whitespace.


STRETCH $SMEI/idl_override/stretch.pro
[Previous] [Next]
 NAME:
	STRETCH

 PURPOSE:
	Stretch the image display color tables so the full range
	runs from one color index to another.

 CATEGORY:
	Image processing, point operations.

 CALLING SEQUENCE:
	STRETCH, Low, High [, /CHOP]

 INPUTS:
	Low:	The lowest pixel value to use.	If this parameter is omitted,
	    0 is assumed.  Appropriate values range from 0 to the number
	    of available colors-1.

	High:	The highest pixel value to use.  If this parameter is omitted,
	    the number of colors-1 is assumed.	Appropriate values range
	    from 0 to the number of available colors-1.

 OPTIONAL INPUTS:
	Gamma:	Gamma correction factor.  If this value is omitted, 1.0 is
	    assumed.  Gamma correction works by raising the color indices
	    to the Gamma power, assuming they are scaled into the range
	    0 to 1.

 KEYWORD PARAMETERS:
	CHOP:	If this keyword is set, color values above the upper threshold
	    are set to color index 0.  Normally, values above the upper
	    threshold are set to the maximum color index.

 OUTPUTS:
	No explicit outputs.

 CALLED BY:
	GetColors [2], GetColors [3], PlotEarthSkymap [2], PlotEarthSkymap [3]
	PlotEarthSkymap [4], Stretch_Colors, allsky [1], allsky [2], allsky [3], allsky_f
	flip_colors, ipsv [1], ipsv [2], ipsv [3], nagoya_glevel, vu_get_page
	vu_thomson_antifish, vu_thomson_hammer
 COMMON BLOCKS:
	COLORS: The common block that contains R, G, and B color
	    tables loaded by LOADCT, HSV, HLS and others.

 SIDE EFFECTS:
	Image display color tables are loaded.

 RESTRICTIONS:
	Common block COLORS must be loaded before calling STRETCH.

 PROCEDURE:
	New R, G, and B vectors are created by linearly interpolating
	the vectors in the common block from Low to High.  Vectors in the
	common block are not changed.

	If NO parameters are supplied, the original color tables are
	restored.

 EXAMPLE:
	Load the STD GAMMA-II color table by entering:

	    LOADCT, 5

	Create and display and image by entering:

	    TVSCL, DIST(300)

	Now adjust the color table with STRETCH.  Make the entire color table
	fit in the range 0 to 70 by entering:

	    STRETCH, 0, 70

	Notice that pixel values above 70 are now colored white.  Restore the
	original color table by entering:

	    STRETCH

 MODIFICATION HISTORY:
	DMS, RSI, Dec, 1983.
	DMS, April, 1987.   Changed common.
	DMS, October, 1987. For unix.
	DMS, RSI, Nov., 1990.	Added GAMMA parameter.


Stretch_Colors $SMEI/ucsd/gen/idl/environment/stretch_colors.pro
[Previous] [Next]
 NAME:
	Stretch_Colors
 PURPOSE:
	Reverse color table
 CATEGORY:
	Annoying
 CALLING SEQUENCE:
	PRO Stretch_Colors, reverse=reverse, silent=silent
 INPUTS:
	(none)
 OPTIONAL INPUT PARAMETERS:
	/reverse    if set then reverse the color table
 OUTPUTS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, STRETCH
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


strposn $SMEI/ucsd/gen/idl/toolbox/strposn.pro
[Previous] [Next]
 NAME:
	strposn
 PURPOSE:
	Locates a substring in an array of strings and returns
	string arrays for preceding and trailing parts. By default, the
	substring is removed, but can be retained using keywords
	TrailingFront or LeadingBack
 CATEGORY:
	string manipulation
 CALLING SEQUENCE:
	FUNCTION strposn, Strings, SubStr, Front, Back, $
	    Last	    = Last	    , $
	    frontdefault    = FrontDefault  , $
	    trailingfront   = TrailingFront , $
	    leadingback     = LeadingBack
 INPUTS:
	Strings     string array or scalar  (read-only)
	Substr	    string scalar or array (read-only)
		If not specified the scalar Substr=',' (comma) is used
		Substring(s) to be searched for. If more than one
		substring is specified to position of the string with
		the lowest (highers if /last is set) index is returned.
 OPTIONAL INPUT PARAMETERS:
	/last	    if set, search is for the last occurence of Substr
		(similar to rstrpos; default is to search for the
		first occurence, similar to strpos)
	/frontdefault	if set, strings which do not contain Substr
		are returned in the Front array
		(by default these strings will be returned in Back)
	/trailingfront	if set, and Substr is found it will be attached to
		the end of the Front array (i.e. SubStr is used as a
		terminator).
	/leadingback	if set, and Substr is found it will be attached to the
		front of the Back array (i.e. Substr is used as a prefix)
 OUTPUTS:
	Index	    long integer array of same structure as Strings
		Contains the starting positions of SubStr (set to -1
		for strings not containing SubStr) i.e. same as for
		strpos and rstrpos
	Front	    string variable of same structure as Strings.
		Contains the sections of the strings preceding SubStr
		- includes Substr if Trailingfront is set
		- includes strings not containing SubStr if
		  Frontdefault is set
	Back	    string variable of same structure as Strings.
		Contains the sections of the strings following SubStr
		- includes Substr if Leadingback is set
		- includes strings not containing SubStr unless
		  Frontdefault is set
 OPTIONAL OUTPUT PARAMETERS:
	(None)
 INCLUDE:
	@compile_opt.pro		; On error, return to caller
 CALLS: ***
	InitVar, REVERSE, SyncDims, UNIQ
 CALLED BY:
	GetFileSpec, PutFileSpec, SetFileSpec, timeposn, txt_block_read, vox_update
	www_help_crosslinks, www_help_make, www_help_names, www_help_tree
 SIDE EFFECTS:
	TrailingFront and LeadingBack are mutually exclusive. If both are
	present TrailingFront takes precedence.
 RESTRICTIONS:
	None
 PROCEDURE:
 MODIFICATION HISTORY:
	DEC-1997, Paul Hick (UCSD/CASS)
	MAR-2003, Paul Hick (UCSD/CASS)
	    Improved efficiency. Removed one of the two remaining explicit DO-loops,
	    made the second more compact.
	DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Argument Substr can now be an array (used to be scalar only)


strreverse $SMEI/ucsd/gen/idl/toolbox/strreverse.pro
[Previous] [Next]
 NAME:
	strreverse
 PURPOSE:
	Reverse order of chars in string
 CATEGORY:
	gen/idl/toolbox
 CALLING SEQUENCE:
	FUNCTION strreverse, str
 INPUTS:
	str	scalar or array; type: string
 OUTPUTS:
	result	    same as input with order of chars
		in all strings reversed
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	REVERSE
 CALLED BY:
	TimePosn_test, qsmei_sky_pick, smei_filename
 MODIFICATION HISTORY:
	DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


SubArray $SMEI/ucsd/gen/idl/toolbox/subarray.pro
[Previous] [Next]
 NAME:
	SubArray
 PURPOSE:
	Extract/add/multiply subarrays in a multi-dimensional array
 CATEGORY:
	Array strangling
 CALLING SEQUENCE:
	FUNCTION SubArray, L,	$
	    element	    = Element	    , $
	    dimension	    = Dimension     , $
	    lastelement     = LastElement   , $
	    lastdimension   = LastDimension , $
	    add 	    = add	    , $
	    multiply	    = multiply	    , $
	    divide	    = divide	    , $
	    replace	    = replace	    , $
	    clear	    = clear	    , $
	    type	    = type	    , $
	    value	    = value
	R = SubArray(L) 	Extract subarray with dimension=0, element=0
	R = SubArray(L,add=1)	Add 1 to subarray with dimension=0, element=0
 INPUTS:
	L	    any multi-dimensional array
 OPTIONAL INPUT PARAMETERS:
	dimension=dimension scalar; type: integer
				identifies one of the dimensions, 0,..,(size(L))[0]-1
	/lastdimension	    selects the trailing dimension of L, i.e.
				equivalent to dimension=(size(L))[0]-1
				(/lastdimension takes precedence over the dimension keyword)

	If neither 'dimension' nor 'lastdimension' are used, then dimension=0 is assumed

	element=element     scalar; type: integer
				identifies one of the elements in the selected dimension,
				0,..,(size(L))[Dimension+1]-1
	/lastelement		selects the last element of the selected dimension, i.e.
				equivalent to element=(size(L))[Dimension+1]-1.

	If neither 'element' nor 'lastelement' are used, then element=0 is assumed

	add=add 	    scalar or array with same # elements as the subarray identified
				by (dimension, element). 'Add' will be added to the subarray.
	multiply=multiply   scalar or array with same # elements as the subarray identified
				by (dimension, element). 'multiply' will be multiplied to
				the subarray.'multiply' is executed prior to 'add'
	replace=Replace     replaces elements
				Takes precedence over 'add' and 'multiply'
	/clear		    sets elements to zero (numerical input) or null-string (string input)
				Take precedence over 'multiply'

	type=type	    makes a subarray of the appropriate type (filled with zeroes)

	If neither of 'type','add','multiply','replace' and 'clear'  is used, then
	the selected subarray will be extracted.
 OUTPUTS:
	If 'add' or 'multipy' or 'replace', or 'clear' are used:
	    Input array with the selected subarray modified.
	If 'type is set then a subarray of the selected type is returned
	Otherwise:
	    Array with one dimension less than the input array, corresponding
	    to the selected subarray.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, IsType
 CALLED BY:
	AngleUnits, Carrington, CenterOfMass, CvPointOnLos, CvSky_Equatorial, CvSky_GSE
	CvSky_GSEQ, CvSky_GSM, CvSky_Geographic, CvSky_HEEQ, CvSky_Heliographic, CvSky_IHG
	CvSky_Precess, CvSky_RTN, CvSky_Solar_EloPa, Distance2Line, EulerRotate
	GeographicInfo, IPS_hlevel_w, Inside_Wedge, RotationMeasure, TMO_skymotion
	ThomsonBrightness, TimeArray, TimeGet, cvsmei, haystack_2006, img_read, jpl_parallax
	jpl_phase, jpl_sizeofsun, lospos, lsqCircleFit, lsqQuadraticFit, put_logo
	qImage_cw_BoxCosine, smei_ccd2sky, smei_radial2theta, smei_theta2radial
	sphere_distance, sphere_smooth, thomsonfig, vu_atlocation, vu_cvgrid, vu_fnc
	vu_lineofsight, vu_type_insitu
 PROCEDURE:
	Trivial
 MODIFICATION HISTORY:
	MAR-1998, Paul Hick (UCSD/CASS)
	OCT-2004, Paul Hick (UCSD/CASS)
	    Modifications to allow string input for /clear and /replace
	MAR-200r, Paul Hick (UCSD/CASS, pphick@ucsd.edu)
	    Added type=type keyword.


SuperArray $SMEI/ucsd/gen/idl/toolbox/superarray.pro
[Previous] [Next]
 NAME:
	SuperArray
 PURPOSE:
	Add a dimension to an array
 CATEGORY:
	Array strangling
 CALLING SEQUENCE:
	FUNCTION SuperArray, L, N, lead=Lead, trail=Trail, after=After, before=Before
 INPUTS:
	L	numerical scalar or array
	N	int scalar
		    # elements in the extra dimension
 OPTIONAL INPUT PARAMETERS:
	!!! dimensions are counted 1,..,size(L)

	/lead	new dimension is first dimension
	/trail	new dimension is last dimension
	after=After
		insert new dimension after dimension After
	before=Before
		insert new dimension before dimension Before
 OUTPUTS:
	Array with one dimension of N elements more than input variable
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType
 CALLED BY:
	AngleUnits, ColorEloTimeBox, ColorPolarBox, ColorSkybox, CvSky, CvSky_Equatorial
	CvSky_GSEQ, CvSky_GSM, CvSky_Geographic, CvSky_HEEQ, CvSky_Heliographic, CvSky_IHG
	CvSky_Precess, Distance2Line, Distance2Sun, EarthSky3DLoc, EarthTransit3DLoc
	EulerRotate, FrameMoments, GetStarShape, HOSOrbit, IPS_hlevel_w, MagnifyArray
	PRO bold, PlotCoronagraph, PlotEarthSkymap [1], PlotEarthSkymap [2]
	PlotEloTimeMap, RGBO_DepthCue, RGBO_Project, RemoteView, RemoteView_Display2D
	RemoteView_Display3D, RemoteView_FOV, RemoteView_Init_Matrix
	RemoteView_Init_View, RemoteView_StereoStates, SMEI_cr_removal, SyncArgsSub
	TMO_skymotion, TMO_tracksky, ThomsonLOSDensity, ThomsonLOSStep, TimeArray, TimeGet
	allsky [1], allsky [2], allsky [3], allsky_f, badpix, big_eph, even_light
	even_light_corrections, even_light_info, get_page, gridgen, haystack_2006
	img_read, jpl_mag, jpl_phase, lospos, lsqLinearFit, mpc_eph, mpc_orbit_eph, plot3darc
	plot_ipv6_fraction, plot_traffic, put_logo, qImage_cw_BoxCosine
	qImage_cw_ZEllipse, qView_FileFilter, qView_ModifyData, qView_PickFiles
	qView_PlotSeries, qView_SubtractBase, sgp4_eph, sgp4_tle, show_wso, smei_findpnt
	smei_frm_flatfield, smei_frm_where, smei_radial2theta, smei_sky, smei_sky_track
	sphere_distance, sphere_smooth, stardistance, testsmei, thomsonfig, trypleiades
	unitvectors, vu_atlocation, vu_check, vu_coronagraph, vu_earthskymap, vu_elotime
	vu_extract, vu_lineofsight, vu_mean, vu_radialcut, vu_read, vu_syncgrid
	vu_synopticmap, vu_timeseries, wedge_content
 EXAMPLE:
	    R = SuperArray( indgen(3,4,5), 10, after=2)
	    creates an array R[3,4,10,5)
 PROCEDURE:
	The basic building block is the expression replicate(1,N)#L
	Reform and transpose are used to control the array structure.
 MODIFICATION HISTORY:
	MAR-1998, Paul Hick (UCSD/CASS)
	FEB-2000, Paul Hick (UCSD/CASS)
	    added handling of string arrays.
	JUN-2003, Paul Hick (UCSD/CASS, pphick@ucsd.edu)
	    Fixed bug adding to array with trailing dummy dimension.


surfertable [1] $SMEI/user/bjackson/surfertable.pro
[Previous] [Next]
 NAME:
	surfertable
 CALLING SEQUENCE:
	PRO surfertable
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, MODIFYCT, gridgen, surfertable_update [1], surfertable_update [2]
 CALLED BY:
	surfertable_update [1], surfertable_update [2]


surfertable [2] $SMEI/user/jclover/from_ztemp/surfertable.pro
[Previous] [Next]
 NAME:
	surfertable
 CALLING SEQUENCE:
	PRO surfertable
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, MODIFYCT, gridgen, surfertable_update [1], surfertable_update [2]
 CALLED BY:
	surfertable_update [1], surfertable_update [2]


surfertable [3] $SMEI/user/pphick/idl/surfertable.pro
[Previous] [Next]
 NAME:
	surfertable
 CALLING SEQUENCE:
	PRO surfertable
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, MODIFYCT, gridgen, surfertable_update [1], surfertable_update [2]
 CALLED BY:
	surfertable_update [1], surfertable_update [2]


surfertable_update [1] $SMEI/user/jclover/from_ztemp/surfertable.pro
[Previous] [Next]
 NAME:
	surfertable_update
 CALLING SEQUENCE:
	PRO surfertable_update, itable, name, p,r,g,b, bw=bw
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, MODIFYCT, gridgen, surfertable [1], surfertable [2], surfertable [3]
 CALLED BY:
	surfertable [1], surfertable [2], surfertable [3]


surfertable_update [2] $SMEI/user/pphick/idl/surfertable.pro
[Previous] [Next]
 NAME:
	surfertable_update
 CALLING SEQUENCE:
	PRO surfertable_update, itable, name, p,r,g,b, bw=bw
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	InitVar, MODIFYCT, gridgen, surfertable [1], surfertable [2], surfertable [3]
 CALLED BY:
	surfertable [1], surfertable [2], surfertable [3]


SyncArgs $SMEI/ucsd/gen/idl/toolbox/syncargs.pro
[Previous] [Next]
 NAME:
   SyncArgs
 PURPOSE:
	Change a list of arguments (usually a combination of scalars and
	arrays) to a list of arrays of equal size.
 CALLING SEQUENCE:
	PRO SyncArgs, A0,A1,A2,A3,A4,A5,A6,A7,A8,A9
 INPUTS:
	A0,...,A9   any type of argument
 OUTPUTS:
	A0,...,A9   arguments of same size
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	who_am_i
 CALLED BY:
	CombineRotations, EarthSky3DLoc, GeographicInfo, HOSOrbit, ThomsonLOSFar
	ThomsonLOSRomb, ThomsonMidpointFar, ThomsonPDistance, ThomsonPDistanceFar
	TimeMonth, TimeSet, TimeYDate, eclipsed_area, lsqCircleFit, lsqQuadraticFit
	nrZBrent, nrZbrac, scalarproduct, sgp4_orbit_period, smei_filename, smei_frm_mask
	smei_sky_field, sphere_distance, sphere_great_arc, timeposn, vectorproduct
 RESTRICTIONS:
	A maximum of 10 arguments is permitted
 PROCEDURE:
 >	Arguments that don't exist on input, will be created as type byte
	(unless none of the arguments exist)
 >	If no arrays are present a list of scalars is returned
 >	Arguments are changed to arrays with the same structure as the largest
	array in the list of arguments.
 >	If there is more than one such array, the first one in the list used
	as target. The others are reformed to match the target type
 >	Scalars and arrays with one element will always be changed to match
	the largest array.
 >	Arrays with size smaller than the target array are boosted to match
	the target array only if the dimensions are the same as the leading
	dimensions are the same as for the target array.
 MODIFICATION HISTORY:
	MAR-1995, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


SyncArgsSub $SMEI/ucsd/gen/idl/toolbox/syncargssub.pro
[Previous] [Next]
 NAME:
	SyncArgsSub
 PURPOSE:
	Intenal use by SyncArgs only
 CALLING SEQUENCE:
	PRO SyncArgsSub, A0, N, s
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	SuperArray
 MODIFICATION HISTORY:
	MAR-1995, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


SyncDims $SMEI/ucsd/gen/idl/toolbox/syncdims.pro
[Previous] [Next]
 NAME:
	SyncDims
 PURPOSE:
	Reforms A to have the same size (scalar or array) as specified in Size
 CATEGORY:
	Toolbox
 CALLING SEQUENCE:
	SyncDims, A, sizeinfo = size(SomeVariable)
	SyncDims, A, extendinfo = size(SomeVariable)
	SyncDims, A, replicateinfo = [size(Array1), size(Array2),...]
 INPUTS:
	A	scalar or array of any type
 OPTIONAL INPUTS:
	sizeinfo    'size and type' vector as returned by the IDL
		    'size' function (only the size information is used)
 OUTPUTS:
	sizeinfo:
	    A	    input array with structure modified to match SizeInfo
		    (note: array content is not tampered with)
	extendinfo:
	    A
	replicateinfo:
	    A	    'size and type' vector, obtained by concatenating the
		    information from the input 'size and type' vectors.
 CALLED BY:
	AngleUnits, BZero, CenterOfMass, CvPointOnLos, Distance2Line, EulerRotate, FishEye
	GetFileSpec, HammerAitoff, MercatorProj, NewcombSun, RemoteView_FOV_loc
	SetFileSpec, TMO_skymotion, ThomsonLOSRomb, TimeInterpol, TimeSplit, TimeString
	coord3to2, cvsmei, nrZbrak, qImage_cw_Transform, scalarproduct, smei_ccd2sky
	smei_sky2cam, smei_sky2ccd, smei_sky_field, smei_zld_dumbbell, smei_zld_weekly
	sphere_distance, strposn, vectorproduct, vu_atlocation
 RESTRICTIONS:
	No check is made that Size actually represents a valid size vector.
 PROCEDURE:
	Used usually before exiting a procedure to make sure that
	input and output array have exactly the same structure.
 MODIFICATION HISTORY:
	DEC-1997, Paul Hick (UCSD/CASS; pphick@ucsd.edu)