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:
	result = scalarproduct(r1, r2 [, /cylin, /sphere, /rect, /degrees, /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, 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    , $
	    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, SetFileSpec, destroyvar, do_file
	flip_colors, twin
 CALLED BY:
	IDL_postop_linux, IDL_postop_vms, IDL_postop_win, even_light_corrections
	even_light_photometry, even_light_registration, qset_page_submit, show_wso
	smei_frm_summary, smei_hdr_plot, smei_sky, smei_star_show, smei_zldsky
	vu_earthskymap, vu_elotime, vu_insitu, vu_planarcut, vu_solardisk, vu_synopticmap
 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, PutFileSpec, bin_read, bin_write, do_file
	findfile_fix, forecast_ftp, get_page, gunzip_file, makemovie, 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, set_page, smei_buf, smei_frm_update, smei_www_skymaps, usno_body
	vu_check, vu_earthskymap, vu_extract, vu_get_page, vu_getdata, vu_header, vu_image
	vu_insitu, 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, even_light_figures
	qvu_draw
 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
	(at current epoch; see Procedure).
 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
			    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, 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
 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:
	/degrees    if set, angles are in degrees (default: radians)
 OUTPUTS:
	rr	array[2,*]; type: double
		    J200 RA and dec of orbital axis
 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:
	smei_sgp4_orbits, smei_zld_weekly
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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_tlm
 CALLED BY:
	smei_sgp4_orbits
 PROCEDURE:
 MODIFICATION HISTORY:
	JUNE-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


sgp4_tlm $SMEI/ucsd/gen/idl/ephem/sgp4_tlm.pro
[Previous] [Next]
 NAME:
	sgp4_tlm
 PURPOSE:
	Extract orbital elements covering bracketing tt_obs from
	tlm data base file
 CATEGORY:
	gen/idl/ephem
 CALLING SEQUENCE:
	status = sgp4_tlm(tt_obs,body_,source=source,tlm=tlm,tt_tlm=tt_tlm)
 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 tlm and tt_tlm
				won't exist
			    1: tlms found
	tlm=tlm 	array[2,ntlm]; type: string
			    tlm (each tlm consists of two records)
			    the tlms will bracket the input time period tt_obs
	tt_tlm		array[ntlm]; type: time structure
			    times extracted from tlm 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_tlm
 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/phick/pro/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:


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_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)


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, 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, _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
	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,  $
	    _extra=_extra, nowrite=nowrite, gzip=gzip, silent=silent
 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 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

	/overwrite	    if set existing frames are overwritten
			    (passed to smei_buf_prep)
 OPTIONAL OUTPUT PARAMETERS:
 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		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	array[1]; type: time structure
			    time of most recent frame processed
 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.


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
 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.
 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:
	TMO_tracksky, cvsmei, qGlitch_Run, qImage_cw_SMEI, smei_cam_quaternion
	smei_ccd2sky, smei_sky2cam, smei_sky2ccd, stardistance
 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
 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:
	TimeGet, TimeSet, 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_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)
	mode=mode	array[n]; type: string or integer; default: 0
			    file mode, e.g. 'frm', 'cal','sky','equ',
			    'l1a'.
			    If ccd=1 then mode is return as integers
			    If ccd=0 then the mode for CCD frames
			    is returned as 'm0','m1','m2'.
	ccd=ccd 	set to 1 if all entries are CCD frames
	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, qImage_cw_Property, qsmei_sky_pick, skyd_cat, smei_buf_prep
	smei_buf_read, smei_filepath, smei_findpnt, smei_frm_cvhdr, smei_getfile
	smei_hdr_get, smei_hdr_plot, smei_mkbase, smei_mkcal_auto, smei_mkorb_auto
	smei_mksky, smei_property, smei_sky_field, smei_sky_getmask, smei_sky_read
	smei_sky_track, smei_star_remove, smei_zld_remove
 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; pphick@ucsd.edu)
	    Substantial rewrite of deconstruction section.
	    Added pos_tt and ccd keywords.


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_sky_getmask, smei_sky_read, smei_star_remove, smei_zld_remove
	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_findpnt $SMEI/user/phick/pro/smei_findpnt.pro
[Previous] [Next]
 NAME:
	smei_findpnt
 PURPOSE:
 CATEGORY:
	user/phick/idl
 CALLING SEQUENCE:
	PRO smei_findpnt, wanted_map	, $
	    silent	= silent	, $
	    from_mode	= from_mode	, $
	    to_mode	= to_mode	, $
	    npeak	= npeak 	, $
	    destination = destination	, $
	    _extra	= _extra
 INPUTS:
	wanted_map	array[n]; type: string, time structure or integer
			    passed to smei_getfile
			    Selects skymap files to be processed
	destination	scalar; type: string; default: $TUB
			    destination directory of output file
 OPTIONAL INPUT PARAMETERS:
	source=source	scalar; type: string
			    passed to smei_getfile
			    source directory for sky maps

	/silent 	if set, suppresses 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, boost, cvsmei, destroyvar, hide_env
	smei_filename, smei_filepath, smei_getfile, smei_sky, smei_star_fit
	smei_star_info, smei_star_writepnt, smei_zld_model, sphere_distance
 PROCEDURE:
 MODIFICATION HISTORY:
	FEB-2008, Paul Hick (UCSD/CASS)


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
 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_filename, 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; pphick@ucsd.edu)
	    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.
	    is returned


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, $
	    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

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

 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; pphick@ucsd.edu)


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
 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:
	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
 OPTIONAL INPUT PARAMETERS:
	dbsource = dbsource
	/test	    if set, the SMEI frames are not update
		(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; pphick@ucsd.edu)
	    Added call to smei_hdr_update to ensure that the
	    header files are up-to-date before calculating
	    smoothed dark currents


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
 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:
	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, 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
 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_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
 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
			if /write or /owerwrite SET:
			    number of headers written into Fits binary table (all cameras
			    combined, if more than one camera was processed).
			if /write and /overwrite NOT set:
			    number of headers extracted from Fits binary tables
	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, IsType, TimeGet
	TimeLimits, TimeOp, TimeSet, TimeUnit, boost, destroyvar, hide_env, smei_filename
	smei_filepath
 CALLED BY:
	qsmei_hdr, smei_findcrazy, smei_frm_smoothdark, smei_frm_where, smei_hdr_plot
	smei_mkcal, smei_orbit_stats, smei_shutterwrong
 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; pphick@ucsd.edu)
	    Added check for presence of requested "get" keyword.
	    If not present, then an array of NaNs is returned.


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
	do_file, 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; pphick@ucsd.edu)


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, SFLOAT, STDDEV, TimeGet, TimeLimits, TimeOp, TimeScale, TimeSet, TimeSystem
	TimeUnit, TimeXAxis, UNIQ, boost, destroyvar, do_file, get_page, hide_env, jpl_body
	jpl_phase, set_page, smei_filename, smei_filepath, smei_frm_where, 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; pphick@ucsd.edu)
	    Added PlotCurve calls to shade periods with
	    bad quaternions.


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: SMEIDC?
				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; 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; 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		    if set the time series plots base on the Fits binary tables
				are updated
	/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
 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.


smei_last_tlm $SMEI/ucsd/camera/idl/toolbox/smei_last_tlm.pro
[Previous] [Next]
 NAME:
	smei_last_tlm
 PURPOSE:
	Retrieves time of most recent Coriolis tlm
 CALLING SEQUENCE:
	FUNCTION smei_last_tlm
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	FILEPATH, SFLOAT, TimeFixYear, TimeSet, hide_env, txt_read
 CALLED BY:
	smei_mkbase, smei_mkcal_auto
 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
 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_tlm, 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)


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


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	, $
	    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
	/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.
 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, destroyvar, hide_env, smei_filepath, smei_hdr_get
	smei_hdr_update
 CALLED BY:
	smei_mkcal_auto
 RESTRICTIONS:
	Can only be run on smei.ucsd.edu
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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
 INCLUDE:
	@compile_opt.pro
 CALLS: ***
	CheckDir, FindAllFiles, InitVar, TimeGet, TimeUnit, hide_env, smei_blocked
	smei_filename, smei_filepath, smei_last_tlm, smei_mkcal, txt_read
 RESTRICTIONS:
	Can only be run on smei.ucsd.edu
 PROCEDURE:
 MODIFICATION HISTORY:
	MAR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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_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
 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
		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
	    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: ***
	FILEPATH, FindAllFiles, GetFileSpec, InitVar, IsTime, IsType, REVERSE, TimeGet
	TimeLInterpol, TimeOp, TimeSet, TimeUnit, do_file, flt_read, hide_env, smei_filepath
	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; pphick@ucsd.edu)


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_mkorb
	smei_orbit_get, txt_read
 RESTRICTIONS:
	Can only be run on the SMEI server (smei.ucsd.edu)
 PROCEDURE:
 MODIFICATION HISTORY:
	DEC-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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; jclover@ucsd.edu)
	    Added new maps, all sky median for v4 background


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: sun.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_mkmask, smei_orbit_get, smei_www_skymaps, txt_read
 RESTRICTIONS:
	-Can only be run on sun.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
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FXADDPAR, 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; pphick@ucsd.edu)


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_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:
	getsmeiasources, 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	    , $
	    destination     = destination   , $
	    to_smeidb	    = to_smeidb     , $
	    update	    = update	    , $
	    state_changes   = state_changes , $
	    camera	    = camera	    , $
	    mode	    = mode	    , $
	    ndoy_lag	    = ndoy_lag	    , $
	    silent	    = silent	    , $
	    source	    = source	    , $
	    usedb	    = usedb	    , $
	    instant_write   = instant_write , $
	    force	    = force	    , $
	    remote	    = remote
 INPUTS:
	trange		array[2]; type: time structure
			time range to be processed
 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

	/update 	/update is ignored if trange is set.
			if set then the existing ASCII files are updated

	source=source	scalar; type: string; default: SMEIDB?
			specifies the location of the SMEI data base
			(passed to smei_getfile).
	destination=destination
			scalar; type: string
			destination directory for the ASCII data base
			files.
			/update NOT: default: $TUB
			/update 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
 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_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, file, new=new, remote=remote
 INCLUDE:
	@compile_opt.pro    ; On error, return to caller
 INPUTS:
	file	    existing file with start times
		    (by default the file in the SMEI tree is used)
 OPTIONAL INPUTS:
	/new	    creates a new file from scratch
		    (by default the existing file in the SMEI tree
		    is updated)
	/remote     copies the modified file with start times
		    to the SMEI master tree
 CALLS: ***
	CV_COORD, FILEPATH, INTERPOL, InitVar, TimeGet, TimeOp, TimeSet, TimeUnit, big_eph
	destroyvar, hide_env, 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.
 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.


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/phick/pro/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  , $

	    time	= time	    , $
	    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    , $
	    get_camera_map = get_camera_map, $
	    min_map	= min_map
 INPUTS:
	wanted_map	    scalar; type: integer
 OPTIONAL INPUT PARAMETERS:
	time=time	    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':

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

	/allraw 	    if set, plot brightness maps (1st 3 Fits extensions)
	/allcnt 	    if set, plot frame counts (2nd 3 Fits extensions in 'sky' maps)
	/allflat	    if set, plot star-subtracted "flat" brightness maps
			    (2nd 3 Fits extension in "equ" maps)
	/allstars	    if set, plot subtracted stars (3rd 3 Fits extensions in "equ" maps)

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

	/equatraw
	/equatcnt
	/equatflat
	/equatstars

	Hires polar maps are always in polar projection.

	/northraw
	/northcnt
	/northflat
	/northstars
	/southraw
	/southcnt
	/southflat
	/southstars

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

	/dirtysky
	/orbtime
	/orbsecs
	/psfn
	/psfe
	/badsky
	/badhtm
	/fovx
	/thetax
	/thetay

	If none of these keywords are specified either than the equatorial
	and two polar maps are assembled into a single map covering the full
	latitude range [-90,+90].

	/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: ***
	BadValue, CvPrecess, CvSky, InitVar, IsType, LOADCT, PlotEarthSkymap, PlotPolarSkymap
	REVERSE, SuperArray, TimeLimits, TimeSet, ToDegrees, ToRadians, UNIQ, WhatIs, big_eph
	destroyvar, get_page, gridgen, jpl_body, set_page, smei_getfile, smei_sky_field
	smei_sky_hdr2range, smei_sky_read
 CALLED BY:
	qsmei_sky_pick, smei_findpnt, smei_mkmask, smei_sky_cleanedge_map
	smei_sky_track, smei_star_fit, smei_star_remove, smei_zld_remove
 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; pphick@ucsd.edu)
	    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.


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_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_earthskymap
 PROCEDURE:
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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; pphick@ucsd.edu)


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; pphick@ucsd.edu)
	    Extracted from smei_sky_read


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  , $

	    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 star 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
 PROCEDURE:
	If this structure is modified then the format statements in
	smei_star_formatpnt need to be updated accordingly.
 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; pphick@ucsd.edu)
	    Added "remove" entry.


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:
 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
	maptype 	    scalar; type: integer
	std_ndim	    array[2]; type: integer
	ndim		    array[2]; type: integer
	xystar		    array[2]; type: double
 OUTPUTS:
	result		    array[m]; type: integer
	ibeg		    scalar; type: integer
	iend		    scalar; type: integer
	jbeg		    scalar; type: integer
	jend		    scalar; type: integer
	rr		    array[2,n]; type: double
 OPTIONAL OUTPUT PARAMETERS:
	ibeg0=ibeg0	    scalar; type: integer
	jbeg0=jbeg0	    scalar; type: integer
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	gridgen
 CALLED BY:
	smei_star_corepsf, smei_star_fit
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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
	camera	    scalar; type: integer
	maptype     scalar; type: integer
	origin	    array[2]
	scale	    scalar
	sky_ndim    array[2]
	std_ndim    array[2]
	ndim	    array[2]
	nvalid	    scalar; type: integer
	valid	    array[nvalid]; type: integer
		    (if nvalid=0 then valid=-1)
	stars_list
	stars_fit
	xystar
	rastar
 OPTIONAL INPUT PARAMETERS:
	/degrees
	/use_filled_psf
	wing_radius=wing_radius
	magnify=magnify
 OUTPUTS:
	results     array[sky_ndim[0],sky_ndim[1]]; type: float
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 EXTERNAL:
 CALLS: ***
	InitVar, ToRadians, smei_star_box, smei_star_info, smei_star_stdmaps
 CALLED BY:
	smei_star_fit
 PROCEDURE:
 MODIFICATION HISTORY:
	JUL-2007, 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 to 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_split
 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	, $
	    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_radius= bkgnd_radius	, $
	    bkgnd_origin= bkgnd_origin	, $
	    bkgnd_count = bkgnd_count	, $

	    wing_radius = wing_radius	, $
	    wing_origin = wing_origin	, $
	    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		, $

	    original_show=original_show , $
	    final_show	= final_show	, $
	    inpsf_show	= inpsf_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
	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_radius=bkgnd_radius
				scalar or array[2]; type: float
				    eventually processed by smei_star_standard.
	bkgnd_origin=bkgnd_origin
				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_radius=wing_radius array[2]; type: float
				    eventually processed by smei_star_standard.
	wing_origin=wing_origin array[2]; type: float

				    eventually processed by smei_star_standard.
	/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).
	/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

	/kill_one
	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
 OUTPUTS:
 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.

	original_show=original_show
	final_show= final_show
	inpsf_show= inpsf_show
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	AngleRange, AngleUnits, BadValue, CORRELATE, FXPAR, HEADFITS, InitVar, IsTime, IsType
	MEAN, MagnifyArray, SMEI_I2M, 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_sky, smei_star_box, smei_star_corepsf
	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; pphick@ucsd.edu)
	    Added keyword /fix_pattern to allow adjusting of centroids
	    of individual stars when multiple stars are fitted
	    simulataneously.


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   , $
	    _extra	    = _extra
 INPUTS:
	tt	array[2]; type: time structure
		    time range
	name	scalar, array[n]; type: string; default: Sirius
		    name(s) of star
 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
	_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, InitVar, IsType, TimeSet, 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
 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_star_fit, smei_star_readpnt, smei_star_split, 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:
	big_eph, qEphem_State, smei_findpnt, smei_frm_where, smei_sky_track
	smei_star_corepsf, smei_star_fit, smei_star_fitone, smei_star_list
	smei_star_show, 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
 OPTIONAL INPUT PARAMETERS:
	root=root	scalar; type: string
			    directory where star catalogue files are located.
			    By default, this is a subdirectory 'list' in 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.
	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); if the name is present
			    in one of the catalogues the information is returned; if
			    the name is not present and empty SMEI_STAR_LIST
			    structure is returned
 OPTIONAL OUTPUT PARAMETERS:
	count=count	scalar; type: integer
			if 'name' NOT specified:
			    # stars in return array 'star'
			if 'name' specified:
			    # stars in 'name' present in catalogues (for which
			    information is returned).
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, IsType, UNIQ, smei_star_alias, smei_star_info, txt_read
	where_common, who_am_i
 EXTERNAL:
	smei_star_list__define
 CALLED BY:
	qEphem_State, smei_star_fit, smei_star_fitone, smei_star_info, 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; pphick@ucsd.edu)
	    Added 'nova_list' catalogue.
	    Edited 'big_variables' catalogue to make format the same as
	    all other catalogues


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:
 OPTIONAL OUTPUT PARAMETERS:
 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 than 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 defineds the full area of the
				PSF to be used to define the star model
	in_fitpsf	    array; type: long
				list of array indices into rr, standard_stars and
				original_star that should be included in the fit
				for the star PSF.
				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 'ifit' array
				Only the subset of bins in 'only' are used in the fit
	/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)
	/use_weights	    if set, the fit is done using the inverse of the skymap
				brightness as weight
	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.
 OUTPUTS:
	Result		    array[nx,ny]; type: float
				the resulting lsq fit to the PSFs of all stars fitted
				simultaneously.
				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
	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:
	skyd_version, smei_star_show, smei_star_split
 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	, $
	    removezld	= removezld	, $

	    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.
	_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:
	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, ZLDVERSION 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; pphick@ucsd.edu)
	    Added keyword use_bkgnd_version to be able to change the
	    selected sidereal background map.
	SEP-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    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.


smei_star_show $SMEI/ucsd/camera/idl/star/smei_star_show.pro
[Previous] [Next]
 NAME:
	smei_star_show
 PURPOSE:
	Plot star time series
 CATEGORY:
 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	, $
	    dtsmooth= dtsmooth	, $
	    tsmooth = tsmooth	, $
	    xysize  = xysize	, $
	    zbuffer = zbuffer	, $
	    imgfile = imgfile	, $
	    logo    = logo	, $
	    silent  = silent	, $
	    _extra  = _extra
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, InitVar, IsType, PlotCurve, SMEI_I2M, TimeGet, TimeUnit, destroyvar, get_page
	set_page, 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; 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:
	Split pnt files into separate files for each star
 CATEGORY:
	camera/idl/star
 CALLING SEQUENCE:
	PRO smei_star_split
 INPUTS:
	(none)
 OUTPUTS:
	(none)
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	FILEPATH, FindAllFiles, GetFileSpec, do_file, hide_env, smei_star_filename
	smei_star_formatpnt, smei_star_readpnt, smei_star_writepnt, txt_read
 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; pphick@ucsd.edu)


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_radius	= bkgnd_radius	    , $
	    bkgnd_origin	= bkgnd_origin	    , $
	    wing_radius 	= wing_radius	    , $
	    wing_origin 	= wing_origin	    , $
	    wing_delta		= wing_delta	    , $
	    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
 INPUTS:
	camera		scalar; type: integer; default: 2
			    camera number (1,2,3)
 OPTIONAL INPUT PARAMETERS:
	/degrees	all angles are in degrees (default is radians)
			This includes bkgnd_radius, wing_radius, psfstretch
			bkgnd_origin and wing_origin
	bkgnd_radius=bkgnd_radius
			scalar or array[2]; type: float; default: none
			    Radius of circle 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 is used to define the background area
	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).
	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 PSF symmetry axis.
	wing_delta=wing_delta
			scalar or array[2]; type: float; default: none
			    correction to wing_radius
	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).
	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 area into an ellipse with a semi-major
			    axis of bkgnd_radius/psfstretch
			    (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
 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)
			    map = -2 inside outer radius, but outside PSF and outside
				    inner radius (if specified)
			    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
			    !!! 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.
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLED BY:
	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 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 zero everywhere else.

	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_radius = bkgnd_radius , $
	    bkgnd_origin = bkgnd_origin , $
	    wing_radius  = wing_radius	, $
	    wing_origin  = wing_origin	, $
	    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
			    column and row indices into original skymap
			    for all bins in box around star
	origin		array[2]; type: float
			    array indices of RA=0, dec=0 (equatorial map)
			    or position of pole (polar maps)
	scale		scalar; type: float
			    map resolution (radians/degrees per bin)
	radec		array[2,m]; type: float
			    RA and dec of m star centroids
	psfangle	array[m]; type: float
			    orientations of PSF relative to equatorial north
			    for m stars
	psfstretch	array[2,m]; type: float
			    direction cosine angle along long and narrow
			    dimension of field of view for m stars
 OPTIONAL INPUTS:
	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 is used to exclude skybins that
			    are part of an already-subtracted star from
			    becoming part of the background bins returned
			    in "in_bkgnd"
	corepsf_mask=corepsf_mask
			array[n]; type: byte
			    0 where bins are inside the core PSF of bright
			    stars

	/degrees	all angles in degrees (default: radians)

	Passed to smei_star_standard:

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

	/use_filled_psf if set, use the alternative PSF map
 OUTPUTS:
	Result		array[n,m]; type: float
			    brightness in standard star map at
			    the equivalent location of rr in the standard star
			    for m stars.
	in_fullpsf=in_fullpsf
			array[n]; type: byte
			    1B identifies locations inside combined PSF of
			    m stars (i.e. the union of non-zero parts)
	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
	std_rr=std_rr	array[2,n,m]; type: float
			    equivalent RA,dec in standard star
			    with abs(RA) < 180 degrees
 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; pphick@ucsd.edu)
	    Added keyword in_corepsf


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
 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, hide_env
	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_wcs $SMEI/user/phick/pro/smei_wcs.pro
[Previous] [Next]
 NAME:
	smei_wcs
 PURPOSE:
	Handles coordinate conversions for SMEI skymaps
 CATEGORY:
 CALLING SEQUENCE:
	FUNCTION smei_wcs, hdr, rr, degrees=degrees
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 CALLS: ***
	IsType
 PROCEDURE:
 MODIFICATION HISTORY:
	FEB-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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
 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; pphick@ucsd.edu)


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, $
	    elongation	    = elongation    , $
	    degrees	    = degrees	    , $
	    add_residue     = add_residue   , $
	    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:
	elongation=elongation
		    scalar or array[n]; type: double; default: none
			solar elongation angles. If not specified the
			elongations are calculated from input argument 'r'
			(this keyword is primarily useful when the elongation
			is calculate by the caller to avoid the overhead
			of calculating these angles twice.)
	/degrees    if set, all angles are in degrees (default: radians)
	/add_residue
		    if set, then add a residual map to the analytic
		    solution.
 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
 CALLS: ***
	EulerRotate, FILEPATH, InitVar, IsType, READFITS, SyncDims, ToDegrees, ToRadians, cvsmei
 CALLED BY:
	smei_zld_model
 PROCEDURE:
	There is a discontinuity of < 0.6 ADUs on the ecliptic.

	The residual map used if /add_residue is set is stored in
	$SMEIDB/c3zldresidue.fts.gz
 MODIFICATION HISTORY:
	APR-2009, Paul Hick (UCSD/CASS)
	APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Added /add_residue to add interpolated value from residue
	    zld map to analytic zld correction.


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, $
	    noslab	= noslab    , $
	    version	= version   , $
	    get_version = get_version,$
	    silent	= silent    , $
	    camera	= camera    , $
	    keep_gegenschein = keep_gegenschein,$
	    dumbbell	= dumbbell  , $
	    weekly	= weekly    , $
	    add_dumbbell_residue = add_dumbbell_residue, $
	    add_weekly_residue	 = add_weekly_residue, $
	    zld_component   = zld_component
 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)

	/dumbbell   adds in an analytic dumpbbel shaped distribution near the Sun
	/add_dumbbell_residue
		if set in addition to /dumbbel then an additional residue is
		    added based on a helioecliptic residue mape
	/weekly     adds in an analytic time-dependent distribution near the Sun
	/add_weekly_residue
		if set in addition to /weekly then an additional residue is
		    added based on a set of weekly helioecliptic residue
		    maps.
	zld_component	(only for the default model 4)
		if set, an array of integers indicating which components of
		the zld model need to be added in:
		0   main model
		1   Gegenschein
		2   analytic dumbbell-shape component
		3   static residue map
		4   analytic time-dependent component
		5   weekly residue map
 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
 CALLS: ***
	AngleRange, AngleUnits, CvSky, InitVar, IsType, big_eph, gridgen, jpl_body
	smei_zld_dumbbell, smei_zld_weekly
 CALLED BY:
	smei_findpnt, smei_sky_read, smei_star_remove, smei_zld_remove, 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)


smei_zld_remove $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	, $
	    fix_bkgnd	= fix_bkgnd	, $
	    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, 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:
 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	    , $
	    add_residue     = add_residue   , $
	    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)
	/add_residu if set then a residue map is added to the analytic
		    time-dependent correction.
 OUTPUTS:
	R	array; type: double
		    zodiacal brightness at locations r
 INCLUDE:
	@compile_opt.pro	; On error, return to caller
 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 (if /add_residue is SET)
	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-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)


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, TimeSystem, ToDegrees, ToRadians, 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


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)


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:
	PlotEarthSkymap, PlotEloTimeMap, RemoteView_FOV_Cube, RemoteView_Init_FOV
	ThomsonLOSRomb, ThomsonLOSStep, big_elongation, eclipsed_area, maygeometry
	qnagoya_plot, smei_findpnt, smei_frm_summary, smei_hdr_plot, smei_sgp4_orbits
	smei_star_fit, 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 smooth_sphere, 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
	/degrees	if set, all angles are in degrees; default: radians

	min_weight	threshold for the weights. All contributing skybins
			with weight less then min_weight will be ignored.
 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, InitVar, 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 Gaussina 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 'wdith' to this function.
 MODIFICATION HISTORY:
	JAN-2008, Paul Hick (UCSD/CASS)
	APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
	    Bugfix. Weighting was done wrong.


stardistance $SMEI/user/phick/pro/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'


STEPPER_S1 $SMEI/idl_override/stepper_s1.pro
[Previou