tace_time2level1 $SSW/trace/idl/util/trace_time2level1.pro
[Previous] [Next]
   Name: tace_time2level1

   Purpose: map from event times to TRACE L1 data; optionally write->file

   Input Parameters:
      tstart, tstop - time range of interest
 
   Output Parameters:
      pindex, pdata - optionally return level1 index,data

   Keyword Parameters:
      testarray - parameter TEST_ARRRAY per 'struct_where.pro'
      _extra    -    keyword inherit keywords -> trace_prep
      soho      - switch - if set, write with synoptic dbase filenames
      synoptic  - switch - synonym for /SOHO
      mcnt (output) - number of TRACE images matching (and written if app.)

   Calls: ***
	BOX_MESSAGE, TRACE_PREP, TRACE_TIME2LEVEL1, data_chk [1], data_chk [2]
	struct_where, trace_cat, trace_cat2data, write_trace
   History:
      27-Feb-2001 - S.L.Freeland 


timeline $SSW/trace/idl/ops/timeline.pro
[Previous] [Next]
COMMENTS:
	Auto codes:
	0: begin & infil = '/tsw/obs_dev/timeline/ops_sim4.tim'		& date = '15-Dec-97' & end
	1: begin & infil = '/tsw/obs_dev/timeline/barker1.tim'		& date = '21-Jun-97' & end
	2: begin & infil = '/tsw/obs_dev/timeline/tv_trans1.tim'	& date = ' 1-Jan-98 13:00' & end
	3: begin & infil = '/tsw/obs_dev/timeline/tv_trans2.tim'	& date = ' 4-Jan-98 13:00' & end
	4: begin & infil = '/tsw/obs_dev/timeline/tv_trans3.tim'	& date = ' 7-Jan-98 13:00' & end
	5: begin & infil = '/tsw/obs_dev/timeline/tv_barker.tim'	& date = '21-Jun-97  1:00' & end
	6: begin & infil = '/tsw/obs_dev/timeline/tv_3days1.tim'	& date = '10-Jan-98 14:00' & end
	7: begin & infil = '/tsw/obs_dev/timeline/tv_3days2.tim'	& date = '11-Jan-98 00:00' & end
	8: begin & infil = '/tsw/obs_dev/timeline/tv_3days3.tim'	& date = '12-Jan-98 00:00' & end
	9: begin & infil = '/tsw/obs_dev/timeline/octsim1.tim'		& date = '16-Dec-97 00:00' & end

 CALLS: ***
	ARR2STR [1], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	BREAK_FILE2, BSORT [1], BSORT [2], BSORT [3], BSORT [4], CONCAT_DIR [1]
	CONCAT_DIR [2], CONCAT_DIR [3], DELVARX [1], DELVARX [2], DELVARX [3], DELVARX [4]
	DO_STRUPCASE, Date2DOY [1], Date2DOY [2], FILE_EXIST [2], FMT_DURATION, FSTRING
	GO_TABLE2CLD, GO_TEST, IDL_SPEED, OPSDB_PRINT, RD_JPEG_TABLE, SOLAR2WEDGE
	STR2ARR [1], STR2ARR [2], TLIN_CONVERT, TLIN_CONV_MNEM, TLIN_FMT_TIME
	TLIN_GET_VER, TLIN_MK_PROC_FIL, TLIN_MK_SC_FIL, TLIN_MK_SRC_FIL, TLIN_PLOT_USAGE
	TLIN_RD_INPUT, TOPSDB_ADD_ENTRY, TOPSDB_BAD_COL_TAB, TOPSDB_BAD_PIX_TAB
	TOPSDB_COMP_LINK, TOPSDB_CONF_CHK, TOPSDB_EXPAND_SEQ, TOPSDB_FDB2SRC
	TOPSDB_FIXUP22, TOPSDB_FULL_FILE, TOPSDB_GEN_IP_CLD, TOPSDB_GET_ADDR
	TOPSDB_GET_ID, TOPSDB_GET_INFO, TOPSDB_GET_STRUCT, TOPSDB_GET_VER
	TOPSDB_ID_ASSIGN, TOPSDB_ID_ASSIGN_S1, TOPSDB_INIT_CLD_FIL
	TOPSDB_INIT_SRC_FIL, TOPSDB_LATEST_VER, TOPSDB_MK_AEC_LD, TOPSDB_MK_FRM_CLD
	TOPSDB_MK_FULL_CLD, TOPSDB_MK_PNT_LD, TOPSDB_MOD_ENTRY, TOPSDB_MOVE_FILE
	TOPSDB_PARSE_SYM, TOPSDB_PATCHUP_INFO, TOPSDB_PRINT, TOPSDB_RD_ID_ASSIGN
	TOPSDB_RD_WRT, TOPSDB_RM_ENTRY, TOPSDB_TABLE2CLD, TOPSDB_UFRM2FRM, UNIQ [1]
	UNIQ [2], UNIQ [3], WEB_SEQ_ALL_USERS, WEB_SEQ_DO1, WEB_SEQ_DO_ARRAY
	WEB_SEQ_DO_FILE, WEB_SEQ_DO_TIMELINES, WEB_SEQ_DO_TIMELINES_S1
	WEB_SEQ_GEN_INDEX, WEB_SEQ_INDEX, WEB_SEQ_MAP_LINKS, WEB_SEQ_S2, WEB_SEQ_SUB
	WEB_SEQ_TARG, WEB_SEQ_TLIN_INDEX, WEB_SEQ_TLIN_LIN, anytim2doy [1]
	anytim2doy [2], anytim2ex [1], anytim2ex [2], anytim2ints [1], anytim2ints [2]
	break_file [4], concat_dir [4], curdir [1], curdir [2], data_type [1]
	data_type [2], dec2sun [1], dec2sun [2], delvarx [5], deriv_arr [1], deriv_arr [2]
	ex2fid [1], ex2fid [2], file_append [1], file_append [2], file_exist [1]
	file_exist [3], file_list [1], file_list [2], fmt_tim [1], fmt_tim [2]
	ftp_copy [1], ftp_copy [2], get_host [1], get_host [2], get_subdirs [1]
	get_subdirs [2], gt_day [1], gt_day [2], gt_time [1], gt_time [2], html_basics
	input [1], input [2], int2secarr [1], int2secarr [2], is_member [1], is_member [2]
	parse_lines [1], parse_lines [2], plots2, polyfill2, prstr [1], prstr [2]
	rd_tfile [1], rd_tfile [2], rd_tr_seq_head, rd_ulin_col, rem_elem [1]
	rem_elem [2], remtab [1], remtab [2], restgen [1], restgen [2], savegen [1]
	savegen [2], str2html [1], str2html [2], str2html [3], str_copy, str_replace [1]
	str_replace [2], strcapitalize [1], strcapitalize [2], strlastchar [1]
	strlastchar [2], strmids [1], strmids [2], tbeep [1], tbeep [2], tbeep [3]
	topsdb [1], topsdb [2], topsdb [3], tr_list_frames, tv2 [1], tv2 [2], uniqo [1]
	uniqo [2], ut_time [1], ut_time [2], wc_where [1], wc_where [2], web_seq
	where_arr [1], where_arr [2], xyouts2 [1], xyouts2 [2], zbuff2file [1]
	zbuff2file [2], zformat [1], zformat [2]
HISTORY:
	Written Mar-97 by M.Morrison
V2.0	30-Apr-97 (MDM) - Added "priority=0" if not defined for start
			- Added global register setting capability
	 1-May-97 (MDM) - Fixed STOP and PNT instructions
	19-May-97 (MDM) - Patched PNT instruction (off by 2 bytes)
	23-Jul-97 (MDM) - Allowed first item to be REL instead of ABS
			- Allowed input starting date/time to have
			  hours and the timeline works relative to that
			  time
	 5-Aug-97 (MDM) - Handle .utim files
	 6-Aug-97 (MDM) - Handle setting of local registers
			- Handle setting of target IDs
	13-Aug-97 (MDM) - Added plotting disk usage capability
	15-Aug-97 (MDM) - Modified to insert UTIM files
			- Added AREL option (relative to last ABS time)
	16-Aug-97 (MDM) - Added some stuff for prompting.  Allow plot disable
	19-Aug-97 (MDM) - Made the routine a procedure
	19-Aug-97 (MDM) - Recognize STOP option
			- Various mods on the plotting display
	27-Aug-97 (MDM) - Generate STOL procs
	28-Aug-97 (MDM) - Fixed downlink interrupting profile of disk
			  usage
	29-Aug-97 (MDM) - Added absolute time (.atim) output
	30-Aug-97 (MDM) - Modified .atim output somewhat
	 4-Sep-97 (MDM) - Corrected bug in xyouts2 for loop (stepsiz=0)
	 4-Sep-97 (MDM) - Put in barker times
			- Handle the day roll-over when commanding by ABS
	 8-Sep-97 (MDM) - Changed start time of 3day contam day #1 to 14:00
			- Changed default priority start from 0 to 1
	 9-Sep-97 (MDM) - Fixed date for contam day #2
	17-Sep-97 (MDM) - Corrected PNT update to use "target_list1.tab"
			  instead of "target_table1.tab"
	 7-Oct-97 (MDM) - Corrected error for when sequence is not in the
			  database
	 7-Oct-97 (MDM) - Corrected sequence start happens during D/L
			  with how disk usage plot works.
V3.0	 7-Oct-97 (MDM) - Removed some print statements
			- Copy the final timeline output to the web page area
			- Added check for time moving backwards in final 
			  timeline output list
			- Changed how "last_one" works in plotting
	13-Oct-97 (MDM) - Corrected "auto=9" to be 16-Dec-97 (not 12-Dec-97)
V3.1	14-Oct-97 (MDM) - Trap on PREV_DONE when not actually started
			- Sped up part of it by finding all UTIM files
			  once
V3.2	30-Oct-97 (MDM) - Added INIT_TIME option (default is to say all between
			  00:00 and 12:00 is for the next day.  This option
			  allows us to say the day starts at INIT_TIME="02:00"
			  and it says the next day entries are from 00:00 to
			  02:00.
V3.21	31-Oct-97 (MDM) - Added SEQ_MEM_DUMP command mnemonic
			- Added /WEB option to TIMELINE call
V3.22	 3-Nov-97 (MDM) - Various fixes
			- Added more info on CASE statement mis-match
V3.30	 3-Nov-97 (MDM) - Changed TLIN_CONVERT to use the DATE passed in
V3.31	 3-Nov-97 (MDM) - More fixes
V4.00	 3-Nov-97 (MDM) - Flag ALL locations where time moves backwards
			- Make major release number (because of 3.30 changes)
V4.01	11-Nov-97 (MDM) - Modified ATIM to maintain the order when same time
V4.02	11-Nov-97 (MDM) - Modified start/stop time on FOT output file
V4.03	26-Nov-97 (MDM) - Modified to allow SAA in the .tim file
			- Append the full .tim file to the FOT file
V4.04	 2-Dec-97 (MDM) - Added /FLIGHT option
V4.05	 2-Dec-97 (MDM) - Added better labeling of the disk usage plots
V4.06	 2-Dec-97 (MDM) - Modified to handle versioned .utim files

WARNING:
	**** It also will not work with all REL time values that span over 24 hours


timeline2html $SSW/trace/idl/ops/timeline2html.pro
[Previous] [Next]

 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], REVERSE, TIME2FILE
	UNIQ [1], UNIQ [2], UNIQ [3], anytim2ints [1], anytim2ints [2], concat_dir [4]
	doy2date [1], doy2date [2], doytim2ints, file_exist [1], file_exist [3]
	file_list [1], file_list [2], gt_day [1], gt_day [2], prstr [1], prstr [2]
	sel_timrange [1], sel_timrange [2], strtab2html, ut_time [1], ut_time [2]
 History: 
      	  29-Apr-98 (JFC) - reversed ff anf file so that it would 
	                    create the list with newest files first

	  30-Apr-98 (JFC) - added IAPs to timeline list
	  13-Jul-98 (MDM) - Added </head> to the header
	  13-Jul-98 (MDM) - Changed to write a file per month and one for
			    +/- 1 week.
	  20-Jul-98 (JFC) - Added monthly plan to timeline html page & links
	  20-Mar-00 (JFC) - Added line to generated HTML file so we know 
	                    it came from here
	                  - De-spaghettify some html formatting
	                  - Stomp a Y2K bug.  The code will die next in 2095.
	  28-Jun-02 (TDT) - Changes to speed it up immensely:  do file search 
			    only for last 70 days and remake web pages only for
			    2 latest months; fix /fotdisk directory
	  27-Jan-05 (DCM) - Took out monthly plan portion as they are not used
  *****  Don't make test timelines more than 1 month in the future, or else this
	  will stop processing the current month  *******************


tjitter $SSW/trace/idl/egse/tjitter.pro
[Previous] [Next]
	See jitter_subs.pro header for history
   CMH 5/12/00  Modified "en_dattim" to be '051231_000000' from '991231_000000'
                It had previously choked on the year turnover from 1999 to 2000


topsdb [1] $SSW/trace/idl/egse/topsdb.pro
[Previous] [Next]
NAME:
	topsdb
PURPOSE:
	TRACE operations software (load maker, ...)
 CALLS: ***
	ARR2STR [1], Arr2Str [2], BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3]
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], DO_STRUPCASE, FILE_EXIST [2]
	FMT_DURATION, GO_TABLE2CLD, OPSDB_PRINT, RD_JPEG_TABLE, SOLAR2WEDGE, STR2ARR [1]
	STR2ARR [2], TOPSDB_ADD_ENTRY, TOPSDB_BAD_COL_TAB, TOPSDB_BAD_PIX_TAB
	TOPSDB_COMP_LINK, TOPSDB_CONF_CHK, TOPSDB_EXPAND_SEQ, TOPSDB_FDB2SRC
	TOPSDB_FIXUP22, TOPSDB_FULL_FILE, TOPSDB_GEN_IP_CLD, TOPSDB_GET_ADDR
	TOPSDB_GET_ID, TOPSDB_GET_INFO, TOPSDB_GET_STRUCT, TOPSDB_GET_VER
	TOPSDB_ID_ASSIGN, TOPSDB_ID_ASSIGN_S1, TOPSDB_INIT_CLD_FIL
	TOPSDB_INIT_SRC_FIL, TOPSDB_LATEST_VER, TOPSDB_MK_AEC_LD, TOPSDB_MK_FRM_CLD
	TOPSDB_MK_FULL_CLD, TOPSDB_MK_PNT_LD, TOPSDB_MOD_ENTRY, TOPSDB_MOVE_FILE
	TOPSDB_PARSE_SYM, TOPSDB_PATCHUP_INFO, TOPSDB_PRINT, TOPSDB_RD_ID_ASSIGN
	TOPSDB_RD_WRT, TOPSDB_RM_ENTRY, TOPSDB_TABLE2CLD, TOPSDB_UFRM2FRM, UNIQ [1]
	UNIQ [2], UNIQ [3], anytim2doy [1], anytim2doy [2], anytim2ex [1], anytim2ex [2]
	anytim2ints [1], anytim2ints [2], break_file [4], concat_dir [4], curdir [1]
	curdir [2], data_type [1], data_type [2], dec2sun [1], dec2sun [2], ex2fid [1]
	ex2fid [2], file_append [1], file_append [2], file_exist [1], file_exist [3]
	file_list [1], file_list [2], fmt_tim [1], fmt_tim [2], ftp_copy [1], ftp_copy [2]
	get_host [1], get_host [2], get_subdirs [1], get_subdirs [2], int2secarr [1]
	int2secarr [2], is_member [1], is_member [2], prstr [1], prstr [2], rd_tfile [1]
	rd_tfile [2], rem_elem [1], rem_elem [2], remtab [1], remtab [2], restgen [1]
	restgen [2], savegen [1], savegen [2], str2html [1], str2html [2], str2html [3]
	str_copy, str_replace [1], str_replace [2], strlastchar [1], strlastchar [2]
	strmids [1], strmids [2], tbeep [1], tbeep [2], tbeep [3], uniqo [1], uniqo [2]
	ut_time [1], ut_time [2], wc_where [1], wc_where [2], where_arr [1], where_arr [2]
	zformat [1], zformat [2]
 CALLED BY:
	timeline, web_seq
HISTORY:
	Created (from MDI opsdb.pro Dec-96
	13-Jan-97 (MDM) - Changed format of the IP table load routines
	12-Feb-97 (MDM) - Corrected 1/2 segment addresses for bad pixel table loads
	10-Mar-97 (MDM) - Added PZT table creation
	11-Mar-97 (MDM) - Added AEC and pointing table creation
	27-Mar-97 (MDM) - Added /FTP option from shawnee
			- Added ID assignment
			- Make a load file for loading the stuff
			- Make the "CLD" file header be different (1 line instead of
			  two and no ";"s.
	 2-Apr-97 (MDM) - Fixed FTP ("lcd")
	16-Apr-97 (MDM) - Mod to only allow ID assigning on shawnee
	16-Apr-97 (MDM) - Used MDI_EXE_DIR for tsqlnk
	17-Apr-97 (MDM) - Fixed seq 'nword' count
	28-Apr-97 (MDM) - Added protection for ID assignment so
			  that labels with "-" or "+" are excluded.
	 1-May-97 (MDM) - Added "descr" option to init_src routine
	16-Jun-97 (MDM) - Fixed bad column loads to start at offset 0 (not 1*N)
	16-Jun-97 (MDM) - Fixed bad column to put in rowlength even if 0 bad pix
	17-Jun-97 (MDM) - Modified to allow tracing down of what sub-sequences
			  and frames are used
			- Added routine TOPSDB_FULL_FILE to speed things up
	19-Jun-97 (MDM) - Generate control file to run test
			- PZT table load
	20-Jun-97 (MDM) - Fixed up control file to run test
	23-Jun-97 (MDM) - Renamed topsdb_proc_lst to topsdb
	24-Jun-97 (MDM) - Trap on ID = -1
			- Adjusted wait on driver src file
			- Added >> option to .slst file
			- Added dhc_flush to driver src file
	 3-Jul-97 (MDM) - Reversed stop seq command (since updated dbase)
			- Do ID assigning very first
			- Expanded max label name from 24 to 30 char
	 8-Jul-97 (MDM) - Modified AEC table PAH to be 1 DN = 1/8th %
			- Changed to have AEC3.TAB be the default
	18-Jul-97 (MDM) - Default huffman table changed to "jpeg_table2"
	29-Jul-97 (MDM) - Changed the driver control file maker
			- Corrected some small bugs (re long file names)
			- Put in check for seq overwriting frame mem
			- Allow ID assign from diapason
	 4-Aug-97 (MDM) - Added "do_strupcase"
	 6-Aug-97 (MDM) - Copy the ID files from shawnee to diapason
			  even if the ID file was not updated (it may have
			  been updated on shawnee earlier)
	15-Aug-97 (MDM) - Changed PZT default table to pzt_offset_std1.tab
	19-Aug-97 (MDM) - Added STOL proc creation 
	13-Oct-97 (MDM) - Changed how target loading is done.  Maintain the
			  order of the "list1.tab" file
	14-Oct-97 (MDM) - Modified topsdb_rd_id_assign to save the read
			  file for TIMELINE to run faster.
	30-Oct-97 (MDM) - Added /NOINIT option (not initialize the database)
			- Added /DELTA option to TOPSDB_PRINT
	 5-Nov-97 (MDM) - Added protection on RESTGEN call (added ".genx")
			- Fixed /NOINIT option capability (it wasn't doing
			  partial loads)
			- Removed BREAK_FILE2, used BREAK_FILE with /LAST_DOT
			- Changed SEQ address database to start at 0x8000 not 0x0
			  Do the subtraction before the call to the linker
			- ^^ re-enables the frame/seq overlap memory conflict
			- Added the conflict memory check
	24-Nov-97 (MDM) - Allowed running from the "flight" /tsw/obs directory
			  by using getenv('TSW_TOPSDB_DIR')
	25-Nov-97 (MDM) - More mods from yesterday (add "-v" calls to compiler/linker)
	 2-Dec-97 (MDM) - Made aec_realistic2.tab the default AEC table
	17-Dec-97 (MDM) - Added TOPSDB_RD_WRT positional output argument
			- Made /NOINIT the default for /flight
			- Modified to assume all /flight are incremental loads
			- Added /FULL_RELOAD option (basically does a remove all)
			- Modified the .lst (expand_seq) code to not reload a file
			  which is already validated as on-board
			- Added "semi_active/semi_removed" concept to handle full
			  reloads for sequences with two versions on board
	19-Feb-98 (FZ)  - Test byte swapping for different platforms
WARNINGS:
	.genx file creation/selection is dangerous - needs to be controlled
	carefully.  an addon memory load HAS to start with the last actual
	load.  Runs by users are creating .genx files which do not match
	the last actual load and the partial load is wrong.

	Partial load takes ALL routines listed in the .lst file (derived
	from .slst file) and reloads them.  This includes the EXECUTE_LIST
	stuff right now (which could be excluded easily).  Identifying 
	which other seq/sub-seq/frames need to be reloaded will have to
	rely on the version number (ie: .useq2, .useq3, ...) not matching
	what is currently on board....


topsdb [2] $SSW/trace/idl/egse/topsdb.pro
[Previous] [Next]
METHOD:
	environment variable OPSDB_TYPE needs to be defined and the
	filename is derived as follows
		MDI_OPSDB_TYPE		Filename
		----------		--------
		DEV			topsdb_dev
		SIM			topsdb_sim (needed?)
		PREP			topsdb_prep
		FLIGHT			topsdb_flt



common topsdb_blk, dir, filnam, info

case getenv('MDI_OPSDB_TYPE') of
    '': begin
	    print, 'MDI_OPSDB_TYPE is not defined.  Stopping.
	    stop
	end
    'DEV': filnam0 = 'topsdb_dev'
    'SIM': filnam0 = 'topsdb_sim'
    'PREP': filnam0 = 'topsdb_prep'
    'FLIGHT': filnam0 = 'topsdb_flight'
    else: begin
	    print, 'MDI_OPSDB_TYPE not recognized.  Stopping...
	    stop
	end
endcase

dir = concat_dir(getenv('TSW_TOPSDB_DIR'), 'topsdb')
filnam = concat_dir( dir, filnam0)
filnam2 = filnam + '.genx'

if (keyword_set(init)) then begin
    info = topsdb_get_struct()
    return
end

if (keyword_set(qwrite)) then begin
    if (data_type(info) ne 8) then begin
	message, 'Write requested with no data defined', /info
	return
    end
    ;
    file_delete, filnam2
    savegen, info, file=filnam
end

if (keyword_set(qbackup)) then begin
    if (data_type(info) ne 8) then begin
	message, 'Write requested with no data defined', /info
	return
    end
    ;
    fid = ex2fid(anytim2ex(!stime))
    filnam2 = concat_dir(dir, filnam0 + fid)
    file_delete, filnam2
    savegen, info, file=filnam2
end

if (n_elements(info) eq 0) then qread = 1
if (keyword_set(qforce_rd)) then qread = 1
if (keyword_set(qread)) then begin
    if (not file_exist(filnam2)) then begin
	message, 'Input file does not exist: ' + filnam, /info
	return
    end
    ;
    print, 'Restoring: ' + filnam2
    restgen, info0, file=filnam2
    n = n_elements(info0)
    info = replicate(topsdb_get_struct(), n)
    info = str_copy(info, info0)
end

if (n_params() eq 1) then out = info
end
 CALLS:
 CALLED BY
	timeline, web_seq


topsdb [3] $SSW/trace/idl/egse/topsdb_old.pro
[Previous] [Next]
NAME:
	topsdb
PURPOSE:
	TRACE operations software (load maker, ...)
 CALLED BY:
	timeline, web_seq
HISTORY:
	Created (from MDI opsdb.pro Dec-96
	13-Jan-97 (MDM) - Changed format of the IP table load routines
	12-Feb-97 (MDM) - Corrected 1/2 segment addresses for bad pixel table loads
	10-Mar-97 (MDM) - Added PZT table creation
	11-Mar-97 (MDM) - Added AEC and pointing table creation
	27-Mar-97 (MDM) - Added /FTP option from shawnee
			- Added ID assignment
			- Make a load file for loading the stuff
			- Make the "CLD" file header be different (1 line instead of
			  two and no ";"s.
	 2-Apr-97 (MDM) - Fixed FTP ("lcd")
	16-Apr-97 (MDM) - Mod to only allow ID assigning on shawnee
	16-Apr-97 (MDM) - Used MDI_EXE_DIR for tsqlnk
	17-Apr-97 (MDM) - Fixed seq 'nword' count
	28-Apr-97 (MDM) - Added protection for ID assignment so
			  that labels with "-" or "+" are excluded.
	 1-May-97 (MDM) - Added "descr" option to init_src routine
	16-Jun-97 (MDM) - Fixed bad column loads to start at offset 0 (not 1*N)
	16-Jun-97 (MDM) - Fixed bad column to put in rowlength even if 0 bad pix
	17-Jun-97 (MDM) - Modified to allow tracing down of what sub-sequences
			  and frames are used
			- Added routine TOPSDB_FULL_FILE to speed things up
	19-Jun-97 (MDM) - Generate control file to run test
			- PZT table load
	20-Jun-97 (MDM) - Fixed up control file to run test
	23-Jun-97 (MDM) - Renamed topsdb_proc_lst to topsdb
	24-Jun-97 (MDM) - Trap on ID = -1
			- Adjusted wait on driver src file
			- Added >> option to .slst file
			- Added dhc_flush to driver src file
	 3-Jul-97 (MDM) - Reversed stop seq command (since updated dbase)
			- Do ID assigning very first
			- Expanded max label name from 24 to 30 char
	 8-Jul-97 (MDM) - Modified AEC table PAH to be 1 DN = 1/8th %
			- Changed to have AEC3.TAB be the default
	18-Jul-97 (MDM) - Default huffman table changed to "jpeg_table2"
	29-Jul-97 (MDM) - Changed the driver control file maker
			- Corrected some small bugs (re long file names)
			- Put in check for seq overwriting frame mem
			- Allow ID assign from diapason
	 4-Aug-97 (MDM) - Added "do_strupcase"
	 6-Aug-97 (MDM) - Copy the ID files from shawnee to diapason
			  even if the ID file was not updated (it may have
			  been updated on shawnee earlier)
	15-Aug-97 (MDM) - Changed PZT default table to pzt_offset_std1.tab
	19-Aug-97 (MDM) - Added STOL proc creation 
	13-Oct-97 (MDM) - Changed how target loading is done.  Maintain the
			  order of the "list1.tab" file
	14-Oct-97 (MDM) - Modified topsdb_rd_id_assign to save the read
			  file for TIMELINE to run faster.
	30-Oct-97 (MDM) - Added /NOINIT option (not initialize the database)
			- Added /DELTA option to TOPSDB_PRINT
	 5-Nov-97 (MDM) - Added protection on RESTGEN call (added ".genx")
			- Fixed /NOINIT option capability (it wasn't doing
			  partial loads)
			- Removed BREAK_FILE2, used BREAK_FILE with /LAST_DOT
			- Changed SEQ address database to start at 0x8000 not 0x0
			  Do the subtraction before the call to the linker
			- ^^ re-enables the frame/seq overlap memory conflict
			- Added the conflict memory check
WARNINGS:
	.genx file creation/selection is dangerous - needs to be controlled
	carefully.  an addon memory load HAS to start with the last actual
	load.  Runs by users are creating .genx files which do not match
	the last actual load and the partial load is wrong.

	Partial load takes ALL routines listed in the .lst file (derived
	from .slst file) and reloads them.  This includes the EXECUTE_LIST
	stuff right now (which could be excluded easily).  Identifying 
	which other seq/sub-seq/frames need to be reloaded will have to
	rely on the version number (ie: .useq2, .useq3, ...) not matching
	what is currently on board....


topsdb_old $SSW/trace/idl/egse/topsdb_old.pro
[Previous] [Next]
METHOD:
	environment variable OPSDB_TYPE needs to be defined and the
	filename is derived as follows
		MDI_OPSDB_TYPE		Filename
		----------		--------
		DEV			topsdb_dev
		SIM			topsdb_sim (needed?)
		PREP			topsdb_prep
		FLIGHT			topsdb_flt



common topsdb_blk, dir, filnam, info

case getenv('MDI_OPSDB_TYPE') of
    '': begin
	    print, 'MDI_OPSDB_TYPE is not defined.  Stopping.
	    stop
	end
    'DEV': filnam0 = 'topsdb_dev'
    'SIM': filnam0 = 'topsdb_sim'
    'PREP': filnam0 = 'topsdb_prep'
    'FLIGHT': filnam0 = 'topsdb_flight'
    else: begin
	    print, 'MDI_OPSDB_TYPE not recognized.  Stopping...
	    stop
	end
endcase

dir = getenv('TSW_TOPSDB_DIR')
dir = '/tsw/obs_dev/topsdb'
filnam = concat_dir( dir, filnam0)
filnam2 = filnam + '.genx'

if (keyword_set(init)) then begin
    info = topsdb_get_struct()
    return
end

if (keyword_set(qwrite)) then begin
    if (data_type(info) ne 8) then begin
	message, 'Write requested with no data defined', /info
	return
    end
    ;
    file_delete, filnam2
    savegen, info, file=filnam
end

if (keyword_set(qbackup)) then begin
    if (data_type(info) ne 8) then begin
	message, 'Write requested with no data defined', /info
	return
    end
    ;
    fid = ex2fid(anytim2ex(!stime))
    filnam2 = concat_dir(dir, filnam0 + fid)
    file_delete, filnam2
    savegen, info, file=filnam2
end

if (n_elements(info) eq 0) then qread = 1
if (keyword_set(qforce_rd)) then qread = 1
if (keyword_set(qread)) then begin
    if (not file_exist(filnam2)) then begin
	message, 'Input file does not exist: ' + filnam, /info
	return
    end
    ;
    print, 'Restoring: ' + filnam2
    restgen, info0, file=filnam2
    n = n_elements(info0)
    info = replicate(topsdb_get_struct(), n)
    info = str_copy(info, info0)
end

end


tr_build_img [1] $SSW/trace/idl/ops/tr_build_img.pro
[Previous] [Next]
NAME:
       tr_build_img
PURPOSE:
       To build a TRACE image from raw telemetry file
INPUT:
	inv_str	- Inventory structure variable telling were to get the data
	sou_files- Raw telemetry source file names
OUTPUT:
	dp_header- Data Product header
	img0	- Decompressed image (if necessary)
	img_comp- The compressed image (if compressed)
	percentd- Percent of data present
	apid	- APID
	pkt_time- Packet time
OPTIONAL KEYWORD OUTPUT:
	index	- DP_HEADER in a structure/index
       qdebug  - Debug flag
 CALLS: ***
	FILE_EXIST [2], MASK, TR_BUILD_IMG_ADD_PKT, TR_BUILD_IMG_CHK_PKT
	TR_BUILD_IMG_RD_PKT, data_type [1], data_type [2], dec2sun [1], dec2sun [2]
	deriv_arr [1], deriv_arr [2], file_exist [1], file_exist [3], mail [1], mail [2]
	tbeep [1], tbeep [2], tbeep [3], trace_jpeg_decomp
 CALLED BY:
	tr_reformat, xdisp_trace2
HISTORY:
V1.0   26-Nov-97 Written by M.Morrison  (guts from MK_TRACE_I0)
V1.1    1-Dec-97 (MDM) - Added hook into JPEG decompression routine
			- Added INDEX output (structure)
V1.2	 4-Dec-97 (MDM) - Made "img_comp" be BYTE type
V1.3	 4-Dec-97 (MDM) - Don't do decompression for times when data is
			  missing. (TEMPORARY FIX)
V2.0	28-Jan-98 (RWN) - Revised with capability to combine partial images 
			  or data products together when they have the same 
			  time and sequence numbers
V2.1	28-Jan-98 (MDM) - Modified to make the non-image data products have
			  the "dp_header" be 7 words
V2.2	 3-Feb-98 (RWN) - Modified TR_BUILD_IMG_ADD_PKT to have the same
			  wrap-around handling as TR_BUILD_IMG_CHK_PKT, plus a
			  printout when there is no data in the latter routine
V2.3	10-Feb-98 (MDM) - Added protection for single packet case
V2.4	17-Feb-98 (MDM) - Removed V1.3 temporary fix
			- Added /qstop
V2.41	18-Feb-98 (MDM) - Changed how tr_build_img_chk_pkt worked when only
			  one packet is sent (don't simply return since the
			  padded pkt buffer is needed to be generated)
V2.5	19-Feb-98 (RWN) - Modified 'nstr' from an input argument to calculation
			  Modified input argument inv_str to inv_str0
V2.6	 3-Mar-98 (MDM) - Changed "trace_decode_idl" to "trace_jpeg_decomp"
V2.7   31-Mar-98 (RWN) - Added /temp switch in call to "trace_jpeg_decomp"
			  to prevent clobbering of stream by the C-decompressor
			  ("progver" variable was still left as 2.6)  (MDM 6-Jul-98)
V2.8	 6-Jul-98 (MDM) - Added protection for when NWORDS does not match NX,NY
V2.9	21-Jul-98 (MDM) - Corrected SAI<0>2 error handling
V2.91  17-Aug-98 (RWN) - Added printout when npkts <= 0 for diagnostic purposes
V2.92	19-Aug-98 (MDM) - Added call to TR_HSM_FIX to make file be staged
V2.93	19-Feb-99 (MDM) - Removed "morrison" from mail list during errors
V2.94   9-Jul-99 (RWN) - Modified 'ffff'x to 'ffff'xL when 'and' to idp_header
			  for nwords due to IDL5.2 change; also made other words ;			  long
V2.95  10-Jul-99 (RWN) - More modifed 'ffff'xL 's
V2.96	 7-Jul-00 (RWN) - Added printout and return in tr_build_img_rd_pkt when ;			  npkt <= 0 
V2.97  14-Aug-00 (RWN) - Add printout and return when npkts = 1 and type = 1


tr_build_img [2] $SSW/trace/ssw_contributed/tr_build_img2.pro
[Previous] [Next]
NAME:
       tr_build_img
PURPOSE:
       To build a TRACE image from raw telemetry file
INPUT:
	inv_str	- Inventory structure variable telling were to get the data
	sou_files- Raw telemetry source file names
OUTPUT:
	dp_header- Data Product header
	img0	- Decompressed image (if necessary)
	img_comp- The compressed image (if compressed)
	percentd- Percent of data present
	apid	- APID
	pkt_time- Packet time
OPTIONAL KEYWORD OUTPUT:
	index	- DP_HEADER in a structure/index
 CALLED BY:
	tr_reformat, xdisp_trace2
HISTORY:
       Written 26-Nov-97 by M.Morrison (guts from MK_TRACE_I0)
        1-Dec-97 (MDM) - Added hook into JPEG decompression routine
			- Added INDEX output (structure)


TR_DARK_SUB $SSW/trace/idl/util/tr_dark_sub.pro
[Previous] [Next]
 NAME:
	TR_DARK_SUB

 PURPOSE:
	Subtract a previously averaged, 1 second exposed dark current image, 
	which includes an ADC offset, from a TRACE image after selecting and 
	reading in the closest dark fits file for the first image.  The ccd 
	summing is matched to the TRACE image and other parameters are 
	compared with some differences displayed.  Binning and sub-image 
	extraction are handled when necessary.

 CATEGORY:
	FITS processing

 SAMPLE CALLING SEQUENCE:
	image_out = tr_dark_sub(index, image, nx=nx, ny=ny,  $
		    dark_raw_image=dark_exp, version=version)

 INPUTS:
	index	   - The index structure for each image, including /image
	image	   - The data array (NX x NY)
	
 OPTIONAL INPUT KEYWORD PARAMETERS: 
	nx	   - The x axis dimension of the image, otherwise derived from
		     TRACE keyword 'naxis1'
	ny	   - The y axis dimension of the image, otherwise derived from
		     TRACE keyword 'naxis2'
	darkdir    - Alternate directory for processed dark current fits images,
		     default = 'concat_dir('$tdb','tdc_darks')' for dark images at LMSAL & GSFC
	user_dark  - If set, read in a user supplied dark current fits image from
		     darkdir as the first image with filename given by 'user_dark'. 
		     This image is assumed to be sized, binned, and pixel aligned 
		     already.
	dc_scalar  - If set, then do not select or read in a dark current file,
		     just use a scalar value for the backround level (for testing)
	dc_only    - If set, the output is the dark current image
	verbose    - Set for a few more messages; overrides /loud
	loud	   - Not set to minimize the messages
	qstop	   - Set to stop in this procedure for debuging purposes

 OUTPUT KEYWORD PARAMETERS: 
	dark_raw_image - The raw dark current image before binning or extraction
	dark_raw_index - The dark current index for the raw dark image
	version        - The current version number of the program
	retrn          - Flag for branching on unusual return

 CALLS: ***
	ADD_TAG [1], ADD_TAG [2], CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3]
	TR_EXT_SUBIMG, concat_dir [4], file_list [1], file_list [2], gt_tagval [1]
	gt_tagval [2], read_trace, sel_filetimes [1], sel_filetimes [2]
 CALLED BY:
	TRACE_PREP
 PROCEDURE:
 
	1. First time thru select and read in the closest dark current fits 
	     file by time from the DARKS calibration database
	2. Select the dark image for the ccd summing used
	3. Extract a sub-image, if needed, taking binning into account
	4. Rebin the dark image, if necessary
	5. Subtract off the dark current image, which includes the ADC offset currents

 MODIFICATION HISTORY:
V1.0	Completed on 15-Apr-98  by  R .W. Nightingale  based on (sxt) dark_sub.pro
V1.1	16-Apr-98 (RWN) - Modified so darkdir can be input from TRACE_PREP	    
			  Updated procedure and keyword descriptions
V1.2   19-Jun-98 (RWN) - Modified to subtract 1s dark image only (as pedestal image)
			  Added retrn and dark_index keywords
			  Adjusted fixed dc_scalar dark_image value
			  Turned on verbose keyword
			  Added capability for user to supply correctly sized dark image
V1.3   23-Jun-98 (RWN) - Added large_diff and removed new_dark = 3
V1.4    6-Jul-98 (RWN) - Modified temperature difference check to 8 degrees
			- Added large_diff to 'first time thru...'
V1.5    4-Aug-98 (RWN) - Added 8x8 ccd_summing for dark_set
V1.6	22-Sep-98 (RWN) - In call to read_trace use /image keyword inplace of
			  /all_tags for shorter index list
V1.7	12-Oct-98 (RWN) - Modify default darkdir to "concat_dir('$tdb','tdc_darks')"
			  to work at most sites
V1.8    9-Sep-99 (RWN) - Add 'dark' keyword for call to TR_EXT_SUBIMG; cleanup code for sht_mdur
			- Add keyword 'loud'
V1.9	 9-Feb-00 (RWN) - Add tsum0 keyword to call of TR_EXT_SUBIMG
			  Add adjustment for summing/binning extract check before call
V2.0	14-Mar-00 (RWN) - Update printout of "Extract subimage..." to "Extract dark subimage..."
V2.1	19-Aug-02 (RWN) - Update to prevent crash on no files found & print warning


tr_decode_head [1] $SSW/trace/dbase/cal/info/tr_decode_head.pro
[Previous] [Next]
NAME:

 CALLS:
 CALLED BY
	emi_summary, focus_trace [1], focus_trace [2], tr_summary_head, xdisp_trace [1]
	xdisp_trace2, xrd_trace


tr_decode_head [2] $SSW/trace/idl/egse/tr_decode_head.pro
[Previous] [Next]
NAME:

 CALLS:
 CALLED BY
	emi_summary, focus_trace [1], focus_trace [2], tr_summary_head, xdisp_trace [1]
	xdisp_trace2, xrd_trace


TR_EXT_SUBIMG $SSW/trace/idl/util/tr_ext_subimg.pro
[Previous] [Next]
 NAME:
	TR_EXT_SUBIMG

 PURPOSE:
	To extract a sub image out of a TRACE image with no change of the 
	image resolution

 SAMPLE CALLING SEQUENCE:
	subimg = tr_ext_subimg(index_in, data_in, index_out, ref_index=index3)
	dark_sub_image = tr_ext_subimg(dark_index, dark_data, dark_sub_index, $
		 dark=dark, nx1=nx1,ny1=ny1, sri_llex0=sri_llex, $
		 sri_lley0=sri_lley, tsum0=sum_ccd, verbose=verbose)
       image3 = tr_ext_subimg(index1, image1, index3, nx1=subimgx, dark=dark, $ 
		 ny1=subimgy, sri_llex0=sllex,sri_lley0=slley, tsum0=tbin_ccd, $
		 verbose=verbose)

 INPUT:
	index_in  - The index for the full image from which the extract will
		    occur
	data_in	  - The data array of the full image from which the extract 
		    will occur

 OUTPUT:
	index_out - The updated index for the extracted output  
	data_out = tr_ext_subimg(...) - The data array extracted from the full image

 CALLS: ***
	BOX_MESSAGE, get_history, gt_tagval [1], gt_tagval [2], update_history
 CALLED BY:
	TRACE_PREP, TR_DARK_SUB, TR_FLAT_SUB
 OPTIONAL KEYWORD INPUT:
	verbose   - Set to have the extraction variables written out
	ref_index - It is possible to either pass an index structure of all 
		    tags and have the corresponding portion extracted -- or
		    to pass the following 5 parameters:
	nx1	  - The number of pixels to extract in x
	ny1	  - The number of pixels to extract in y
	sri_llex0 - The lower-left corner full resolution x position of subimage to
		    be extracted from "data_in" image
	sri_lley0 - The lower-left corner full resolution y position of subimage to
		    be extracted from "data_in" image
	tsum0	  - The ccd sum factor for dark extracts or the total ccd binning/
		    summing factor for other subimage extractions
	dark      - Flag set if called from TR_DARK_SUB.PRO, so do not check history
	nohistory - Flag set if do not want history to be updated

 RESTRICTIONS:
	The routine assumes that the subimage to be extracted is contained 
	in the full input image, and that the size and lower left coordinates
	of the full input image are given in the input index.

 MODIFICATION HISTORY:
V1.0	Completed on 15-Apr-98 by  R. W. Nightingale based on sxt: ext_subimg3.pro
V1.1   10-Jun-98 (RWN) - Implemented keyword verbose
V1.2   26-Sep-98 (RWN) - Updated the size and lower left corner keywords
			  in the output index
V1.3	13-Sep-99 (RWN) - Updated pixel location of subimage lower left corner on
			  "data_in" image, index_out.sri_lle*, and header
			- Added output index updates for sri_fovx,y & xcen, ycen
			- Add history update within function call
V1.4	 9-Feb-00 (RWN) - Add keyword tsum0 to correct llcx(y) for summing on-chip
			  for darks and for summing/binning for other image extractions
V1.5 	13-Mar-00 (RWN) - Correct tsum, index_out.sri_lle*, and verbose print out 
V1.6	 2-Jul-02 (RWN) - Correct keywords dark & verbose to always have values
			  and output program version number in verbose mode


TR_FLAT_SUB $SSW/trace/idl/util/tr_flat_sub.pro
[Previous] [Next]
 NAME:
	TR_FLAT_SUB

 PURPOSE:
	Calculate time and wavelength dependent flat field correction 
	using interpolated flat fields and synoptic-fit parameters 
	(multiplier C and power gamma) and then correct image by
	dividing by new flat field

 CATEGORY:
	FITS processing

 SAMPLE CALLING SEQUENCE:
	corrected_image = tr_flat_sub(index, image, version=version, /loud)

 INPUTS:
	index     - The index structure for each image, including /image
	image     - The data array (NX x NY)

 OPTIONAL INPUT KEYWORD PARAMETERS:
	nx        - The x axis dimension of the image, otherwise derived from
		    TRACE keyword 'naxis1'
	ny        - The y axis dimension of the image, otherwise derived from
		    TRACE keyword 'naxis2'
	flatdir   - Alternate directory for processed flat field fits images,
		    default = 'concat_dir('$tdb','tff_flats')' for flat images 
		    at LMSAL & GSFC
	verbose   - Set for a few more messages: overrides /loud
	loud      - Not set to minimize the messages
	qstop     - Set to stop in this procedure for debugging purposes

 OUTPUT KEYWORD PARAMETERS;
       ff_1700_image - The 1700 flat field image before binning or extraction
       ff_1700_index - The flat field index for the 1700 flat field image
       ff_1600_image - The 1600 flat field image before binning or extraction
       ff_1600_index - The flat field index for the 1600 flat field image
       ff_1550_image - The 1550 flat field image before binning or extraction
       ff_1550_index - The flat field index for the 1550 flat field image
       ff_1216_image - The 1216 flat field image before binning or extraction
       ff_1216_index - The flat field index for the 1216 flat field image
       ff_wl_image   - The WL flat field image before binning or extraction
       ff_wl_index   - The flat field index for the WL flat field image
       ff_euv_image  - The euv flat field image before binning or extraction 
       ff_euv_index  - The flat field index for the euv flat field images    
			(The above image & index keywords store them for reuse)
       version   - The current version number of the program
       retrn     - Flag for branching on unusual return

 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2]
	MOMENT, TR_EXT_SUBIMG, concat_dir [4], file_exist [1], file_exist [3]
	gt_tagval [1], gt_tagval [2], int2secarr [1], int2secarr [2], read_trace
	sel_filetimes [1], sel_filetimes [2], update_history
 CALLED BY:
	TRACE_PREP
 PROCEDURE:

	1. First time thru for image find and read in the previous and following
	     flat field fits files by time from the flat field database
	2. Determine wavelength of image
	3. For white light image, use one white light flat field only
	4. Interpolate flat field and appropriate parameters to image time
	5. Calculate corrected flat field
	6. Extract a sub-image of the corrected flat field
	7. Rebin corrected flat field image, if necessary
	8. Divide image by corrected flat field

 MODIFICATION HISTORY:
V1.0   Completed on 14-May-02  by  R.W. Nightingale
V1.1	28-Jun-02 (RWN) - modify gamma to use an average
			- add reuse of processed flats
V1.2	 3-Jul-02 (RWN) - modify gamma for 1216
V1.3	20-Feb-03 (RWN) - add EUV wavelengths using 171 flatfields for all euvs
V1.4   12-Aug-03 (RWN) - add updated UV & EUV params by new ffest..saveset.dat
V1.41  14-Aug-03 (SLF) - use restore of $tdb/tff_flats/ffest...dat 
V1.5    4-Sep-03 (RWN) - add flat field pixel binning for summed images
V1.6	26-Sep-05 (RWN) - add updated UV & EUV params by new ffest..saveset.dat


TR_GET_DISP [1] $SSW/trace/idl/util/tr_get_disp.pro
[Previous] [Next]
 NAME:
    	TR_GET_DISP.PRO

 PURPOSE:
	Given a datacube of images, measure the rigid displacement
	between each image and the first in the cube and optionally
	shift each image to coalign the entire cube.  Uses a centered
	2^n x 2^n window for coalignment.  Finds the whole-pixel
	shift of maximum cross-correlation, then interpolates for
	fractional pixel part either on cross-correlation function or
	optionally on an array of squared mean absolute deviations (MAD).  
	Shifts may be accurate to a few tenths of a pixel but don't
	expect much better than that.

 CALLING SEQUENCE:
	disp = tr_get_disp(data [,/shift][,mad=mad][,/debug])

 INPUTS:
	data -- data cube of images, size (NX,NY,NT); 
	        data(*,*,0)= reference image to which others are aligned

 KEYWORD PARAMETERS:
	shift -- if set, data(*,*,1:*) are shifted to match the reference
	mad -- if non-zero, use mad x mad array of MAD residuals to
	        find final displacement; if 0 < mad < 5, uses 5x5 array
	        USE ONLY IF IMAGES ARE SAME WAVELENGTHS AND EXPOSURE LEVELS
	debug  -- prints out parts of cross-correlation & MAD arrays

 OUTPUTS:
	Returns array of displacements disp = fltarr(2,NT)
	The sense is that data(i,j,0) <==> data(i-disp(0,k),j-disp(1,k),k)

	You can shift the images afterwards using data = shift_img(data, disp)

 TO DO:
	Needs better 2-D interpolation of sub-pixel displacement 
	Needs better handling when mad x mad doesn't include the minimum

 CALLS: ***
	HANNING, IS_IN_RANGE, SHIFT_IMG
 CALLED BY:
	CIV_SUBTRACT, LYA_SUBTRACT
 MODIFICATION HISTORY:
	29-Jan-98 (TDT) - adapted get_disp from H. Lin's flat fielding package ccdcal5.pro
	 1-Jul-98 (TDT) - added shift keyword, shift_img using poly_2d
	11-Sep-98 (TDT) - variable MAD search area, fixed bug in subarea size 
	22-Sep-98 (TDT) - added cross-correlation only feature
	 1-Oct-98 (TDT) - renamed tr_get_disp and put on-line


TR_GET_DISP [2] $SSW/trace/idl/util/tr_get_disp_2d.pro
[Previous] [Next]
 NAME:
    	TR_GET_DISP.PRO

 PURPOSE:
	Given a datacube of images, measure the rigid displacement
	between each image and the first in the cube and optionally
	shift each image to coalign the entire cube.  Uses a centered
	square window for coalignment, side=2^n or 3*2^n.  Finds the whole-pixel
	shift of maximum cross-correlation, then interpolates for
	fractional pixel part either on cross-correlation function or
	optionally on an array of squared mean absolute deviations (MAD).  
	With MAD option, shifts are accurate to better than 0.1 pixel for 
	test images which are truly identical except for displacement, as long
 	as displacements are ~< 25 % of the square window

 CALLING SEQUENCE:
	disp = tr_get_disp(data [,/shift][,mad=mad][,/debug])

 INPUTS:
	data -- data cube of images, size (NX,NY,NT); 
	        data(*,*,0)= reference image to which others are aligned

 KEYWORD PARAMETERS:
	shift -- if set, data(*,*,1:*) are shifted to match the reference
	mad -- if non-zero, use mad x mad array of mean absolute difference (MAD) residuals to
	        find final displacement; if 1 < mad < 5, uses 5x5 array
	        USE ONLY IF IMAGES ARE SAME WAVELENGTHS AND EXPOSURE LEVELS
	debug  -- prints out parts of cross-correlation & MAD arrays

 OUTPUTS:
	Returns array of displacements disp = fltarr(2,NT)
	The sense is that data(i,j,0) <==> data(i-disp(0,k),j-disp(1,k),k)

	You can shift the images afterwards using data = shift_img(data, disp)

 TO DO:
	Needs better handling when mad x mad doesn't include the minimum

 CALLED BY:
	CIV_SUBTRACT, LYA_SUBTRACT
 MODIFICATION HISTORY:
	29-Jan-98 (TDT) - adapted get_disp from H. Lin's flat fielding package ccdcal5.pro
	 1-Jul-98 (TDT) - added shift keyword, shift_img using poly_2d
	11-Sep-98 (TDT) - variable MAD search area, fixed bug in subarea size 
	22-Sep-98 (TDT) - added cross-correlation only feature
	 1-Oct-98 (TDT) - renamed tr_get_disp and put on-line
	12-Mar-02 (TDT) - fixed bug so MAD now uses approx. same FOV as CC
	12-Mar-02 (TDT) - changed to 2-D least square fitting to find minimum of CC and MAD


tr_head_info $SSW/trace/idl/info/tr_head_info.pro
[Previous] [Next]
NAME:
	tr_head_info
PURPOSE:
	To display the information in the TRACE index header
METHOD:
	It uses the description portion of the keyword database
	to label the information.
SAMPLE CALLING SEQUENCE:
	out = tr_head_info(index)
	out = tr_head_info(index, tags)
INPUT:
       index   - The index structure to make a listing of.  It should 
		  be a SINGLE index (not an array).  If an array is 
		  sent in, then only the first one is listed
OPTIONAL INPUT:
	tags	- The list of tags to display.  Default is all tags
 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2]
	concat_dir [4], data_chk [1], data_chk [2], data_type [1], data_type [2]
	file_exist [1], file_exist [3], gt_tagval [1], gt_tagval [2], prstr [1], prstr [2]
	rd_ulin_col, strjustify
 CALLED BY:
	trace_get1www_image, xdisp_trace3
OPTIONAL KEYWORD INPUT:
       hc      - Make a hardcopy
       land    - Make the hardcopy in landscape mode
       quiet   - Don't display the listing to the screen
       outfil  - Write the listing to an output file
       prehead - Add this information before the header
	head_db	- The keyword database file.  The default is
			$TR_CAL_INFO/trace_keywords.tdb
	nodescription - If set, don't display the description
OPTIONAL KEYWORD OUTPUT:
	labels	- The label string array
HISTORY:
	Written 26-Feb-98 by M.Morrison
	21-Apr-98 (MDM) - Changed to use /nomore on prstr
			- Added /nodescription keyword
			- Enabled "tag_list_file" option


tr_hsm_fix $SSW/trace/idl/ops/tr_hsm_fix.pro
[Previous] [Next]
NAME:
	tr_hsm_fix
PURPOSE:
	Fix for the HSM system which does not allow proper reads on
	files which are not online
SAMPLE CALLING SEQUENCE:
	tr_hsm_fix, files
INPUT:
	files	- The list of files to insure which are online.
DETAILS:
	Only the first several 100 bytes of the file are online, and 
	when the file is read with direct access and I/O error occurs.
	This routine forces the file to be fully staged to the 
	magnetic disk before the read is attempted.
 CALLS: ***
	get_host [1], get_host [2], is_member [1], is_member [2]
 CALLED BY:
	tr_rd_inventory
HISTORY:
	Written 18-Aug-98 by M.Morrison
       28-Aug-1998 - S.L.Freeland - use get_host.pro / is_member.pro


tr_inventory_telem $SSW/trace/idl/ops/tr_inventory_telem.pro
[Previous] [Next]
NAME:
	 tr_inventory_telem
PURPOSE:
	To inventory a raw telemetry file, packet by packet,
       and produce a list of images contained therein
SAMPLE CALLING SEQUENCE:
       tr_inventory_telem, infil, outfilnam, sttim, entim, outdir=outdir, qdebug=qdebug, qstop=qstop
  on cheyenne:
   tr_inventory_telem, '971014_011616_01.sc3c'                ;test file
   tr_inventory_telem, '/disk6/people/dps/old_9709/TRACE_G060_QL_1998-01-12T22-51-10Z_V01.DAT1'  $
   tr_inventory_telem, '/disk6/people/dps/old_9709/TRACE_G060_QL_1998-01-11T07-24-31Z_V01.DAT1'  $ 
                                               , skipbytes=48
  on diapason:
       tr_inventory_telem, '/usr2/people/ngale/reformat/tinv/week19971012/971014_011616_01.sc3c' $
						,outdir='./tinv'
       tr_inventory_telem, '/usr2/people/ngale/reformat/tinv/week19971012/971014_164545_01.sc3c' $
 						,outdir='./tinv'
       tr_inventory_telem, '/usr2/people/ngale/reformat/tinv/week19971012/971007_221511_01.sc3c' $
						,outdir='./tinv'
INPUT/OUTPUT:
	infil	  - Input input-file name (including the path)
	outfilnam - Input output-file name (with or without the path)
       apid      - Input apid from file name
       sttim     - Input time from file name
                 - Output start time of first file sync
       entim     - Output end time = start time of last file sync
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], MASK, RSTRPOS
	TR_SEARCH_SYNC, anytim2ints [1], anytim2ints [2], concat_dir [4], file_exist [1]
	file_exist [3], file_size [1], file_size [2], fmt_tim [1], fmt_tim [2]
 CALLED BY:
	do_tr_inventory
OPTIONAL KEYWORD INPUT:
	outdir	  - The output directory
       dps       - Flag set if infil ext = DAT1 or dat1 for files from dps
       qdebug    - Debug flag 
       qstop     - Debug and stop flag
       skipbytes - skip header bytes (in ~dps, if needed)
HISTORY:
V1.0	Written Nov-97 by R. W. Nightingale
V1.1   18-Nov-97 (RWN) - Added capability to handle partial images by packets
V1.2    1-Dec-97 (RWN) - Fixed byte counter (new_start) for short packets ( <11 bytes)
V1.3	 1-Dec-97 (MDM) - Made entim variables always defined
			  (handles case of exit before any good data)
V1.4    2-Dec-97 (RWN) - Initialize sai to 0; used for type = 999 when 1st packet is partial packet 
                         Modify comments to ouput file to be formatted with # at beginning
V2.0    7-Jan-98 (RWN) - Add sequence number and data product length to inventory list
                         Add progver and prognam
V2.1   27-Jan-98 (RWN) - Fixed type=999 printouts with type = typp, added vals for type=999,
                         and moved start_byte update after type 999 time change check
V2.2	20-Feb-98 (RWN) - Added dps flag set if infil ext = 'dat1'
V2.3    8-Apr-98 (RWN) - Fix for missing partial dp_header packet, type=998
			  Removed line numbers
V2.4    9-Apr-98 (RWN) - Check for npkts>2400, if so, set npkts=2400 and add 100 to image type
V2.5	23-Feb-99 (RWN) - Count loops of bad, very small packet headers and error off after 25
			  Use lower 11 bits for APID, not full word
V2.6	 6-Jul-99 (RWN) - Fix for negative npkts, same as =0, type=998
V2.7	 7-Jul-00 (RWN) - Fix short pkt new_start logic for negative pkt0.len
			  Add checks for lun* existence before "afterloop" usage in case of io_errors
V2.8	15-Jan-04 (RWN) - Add ability to handle changed last bit of sync_pat (primarily for jitter data)


tr_list_frames $SSW/trace/idl/egse/tr_list_frames.pro
[Previous] [Next]
NAME:
	tr_list_frames
PURPOSE:
	List the TRACE frames in tabular format
SAMPLE CALLING SEQUENCE:
	tr_list_frames, file_list('/tsw/obs_dev/dpm/frame', '*.ufrm')
	tr_list_frames, file_list('/tsw/cfl/cdh_test/cc', '*.ufrm')
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], TR_FRAME_DECODE, break_file [4]
	prstr [1], prstr [2], rd_tfile [1], rd_tfile [2], str_replace [1], str_replace [2]
 CALLED BY:
	timeline, web_seq
HISTORY:
V1.0	Written Mar-97 by M.MOrrison
V2.0	 7-Jul-97 (MDM) - Added documentation header
			- Forced the title lines out every 35 frames


tr_lut_conv $SSW/trace/idl/info/tr_lut_conv.pro
[Previous] [Next]
NAME:
	tr_lut_conv
PURPOSE:
	TRACE routine to allow lookup table (lut) conversions of
	input values.
SAMPLE CALLING SEQUENCE:
	print, tr_lut_conv(in, basefil, times)
	print, tr_lut_conv(4, 'wave_table')
	prstr, tr_lut_conv(indgen(32), 'wave_table')
INPUT:
	in	- integer table entry numbers
	basefil	- The base filename.  A valid start date/time is
		  encoded in the filename to say when it started
		  being active
	times	- The times for each of the input values.  The
		  input is assumed to be time sorted.
OUTPUT:
	out	- The lookup table value.  If the value is not
		  in the table, then '????' is returned.  If it
		  can't find a lookup table file for the proper
		  time, then 'LUT_NFF' is returned.
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE2TIME, FILE_EXIST [2]
	FMT_TIMER [1], FMT_TIMER [2], GET_DELIM, anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], concat_dir [4], file_exist [1], file_exist [3]
	file_list [1], file_list [2], rd_ulin_col, ut_time [1], ut_time [2], wc_where [1]
	wc_where [2], where_arr [1], where_arr [2]
 CALLED BY:
	gtt_info
HISTORY:
	Written 29-Jan-98 by M.Morrison
	19-Feb-98 (MDM) - Modified to do the file listings once
			  to speed things up
        7-Apr-1998 S.L.Freeland - $SSW_TRACE environmental
       13-May-19 (FZ)  - Changed loop variable to long
       29-mar-2006 - S.L.Freeland - apply Windows tweak suggested by Y.P.Li


tr_mech_summary_img month $SSW/trace/idl/ops/tr_mech_summary_img.pro
[Previous] [Next]
NAME:
       tr_mech_summary_img, month
PURPOSE:
       To log times and count frames and transitions that a given mnemonic
       changes state on a monthly basis using image headers
SAMPLE CALLING SEQUENCE:
       tr_mech_summary_img,'199804'
 CALLS: ***
	TR_MECH_SUMMARY_IMG, UNIQ [1], UNIQ [2], UNIQ [3], gt_tagval [1], gt_tagval [2]
	int2secarr [1], int2secarr [2], pr_uniq_hk, prstr [1], prstr [2], trace_cat
	ut_time [1], ut_time [2]
HISTORY:
       Written 17-Nov-97 by M.Morrison
	02-Apr-98 (FZ)  - Modified start and end time calculations 
	06-May-98 (FZ)  - Changed name of routine from tr_mech_summary2 to tr_mech_summary_img
V1.2	26-Aug-98 (MDM) - Changed from using TR_RD_INDEX to TRACE_CAT
			- Also pass the LONG of the data value to handle the positive/negative
			  move summary right (byte types are unsigned)


tr_mk_seq_alph $SSW/trace/idl/site/tr_mk_seq_alph.pro
[Previous] [Next]
NAME:
	tr_mk_seq_alph
PURPOSE:
	Take the monthly sequence summary listings and combine them
	all together and sort alphabetically
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], TIME2FILE, concat_dir [4]
	file_list [1], file_list [2], prstr [1], prstr [2], rd_tfile [1], rd_tfile [2]
	strmids [1], strmids [2], strposarr [1], strposarr [2], ut_time [1], ut_time [2]
HISTORY:
	Written 4-Jun-98 by M.Morrison
       15-Feb-00 (FZ) - Eliminate listing of sequences of duration <= 0.1 min


tr_mon_health [1] $SSW/trace/idl/ops/tr_mon_health.pro
[Previous] [Next]
NAME:
	tr_mon_health
PURPOSE:
	TRACE Health monitor driver
SAMPLE CALLING SEQUENCE:
	tr_mon_health, item, dur, daytime
	tr_mon_health, 'HK_AMPS_MAIN'
	tr_mon_health, 'HK_VOLT_MAIN', 10, '10-Dec-97'
	tr_mon_health, 'TXT_SEQ_RUN_SUM', 1, '5-Dec-97'
	tr_mon_health, 'TXT_PER_IMAGE', 1, '5-Dec-97', offset=6558102D
INPUT:
	item	- The health item wanted.  Items are:
			HK_AMPS_MAIN	A 1x3 set of panels which provides the current for
					the DPU, the Operational Heaters, and the Mechanisms
			HK_AMPS_OTHER	A 2x2 set of panels providing the current for the
					CCD Decontamination bus, the Survival Heater bus, the Wax Actuator
					bus, and the Spacecraft Bus Voltage.
			HK_BATTERY	A 2x3 set of panels which provides the battery state of charge,
                                       battery curren, battery voltage, shunt current and battery temps 1 & 2
			HK_TEMP_6BASIC	A 2x3 set of panels giving the temperature of
					the Primary Mirror (S/C), the MgF Window (PRT), the CCD Electronics
					(S/C), the Operational Heaters Converter (PRT), the DPU Converter
					the CCD - where the latter plots both the S/C high and S/C low
			HK_TEMP_SC_ONLY	The 10 S/C packet temperatures
                       HK_SC_TEMPS     The spcacraft thermisters
                       HK_FLAGS        Fine Sunpoint, DSS Sunpresence and Sequence Status Flags
			HK_SEQ_FRMNUM	A single panel plotting the Frame Number in Sequence.
			HK_ISS_3ERRS	A 1x3 set of panels providing the average A, B, and C errors.
			HK_VOLT_MAIN	A 2x2 set of panels where
					     #1  has 3 curves    +15V for App & CCD & Mech 
					     #2  has 2 curves    -15V for App & CCD
					     #3  has 2 curves    +5V  for App & CCD
					     #4  has 2 curves    +72V for ISS and +30V for CCD
			HK_SW_CMD_ERR	At least a 1x2 panel where command count is in one
				        panel and DHC error count is in the other; perhaps DM/MxL will
				        decide on something additional.
			HK_WHL_A_TORQ   Wheel A torque - added to monitor the anomalous wheel A torque spikes
			TXT_IPERR_SEA	Listing of the events when the DHC (IP) error count incremented
			TXT_SEQ_RUN_SUM	Listing of when sequences were run
			TXT_PER_IMAGE	Listing per image
OPTIONAL INPUT:
	dur	- The duration in days.  Default is 1 day
	daytime	- The end date/time.  Default is up to current
		  GMT
OPTIONAL KEYWORD INPUT:
	start	- Make the "daytime" be the START date/time (not end)
	z	- Send the output to the z buffer and file
	offset	- The time correction for pre-launch real GMT not matching
		  the S/C time for the call to TR_RD_INDEX
METHOD:
	Display to the screen (or) to a z buffer and then saved to
	a GIF file.  Use similar calling sequences for 1 day, 10 day,
	and 60 day requests.
HISTORY:
	Written 10-Mar-98 by M.Morrison
	18-Mar-98 (MDM) - Changed to reset device back after /hc
	31-Mar-98 (MDM) - Added "HK_TEMP_SC_ONLY"
			- Changed HK_TEMP_6BASICS to do ccd hi/lo
	31-Mar-98 (MDM) - Made HK_TEMP_6BASICS only do hi
	 2-Apr-98 (MDM) - Make 6BASICS to ccd hi/lo
	 2-Apr-98 (MDM) - Pass "pm_filter=100" to quick_hkplot to 
			  filter the garbage
			- Made the window 750x600 (instead of 600x600)
	16-Apr-98 (MDM) - Changed to use /filter1d (instead of pm_filter)
			- Added HK_FRMNUM_CMD_ERR
			- Added /last_tim_lab param to quick_hkplots calls
	21-Apr-98 (MDM) - Fixed HK_FRMNUM_CMD_ERR to be 1x3 (not 1x2)
	26-May-98 (JFC) - changed HK_SW_CMD_ERR & HK_FRMNUM_CMD_ERR to have mass memory plotted (iksqrg1e)
			  instead of DHC error (ikipecnt) because it's now available as a list
	26-May-98 (JFC) - added !psym = 3 before calls to quick_hkplot in HK_SW_CMD_ERR and 
			   HK_FRMNUM_CMD_ERR so that dots are plotted instead of solid lines
	26-May-98 (JFC) - added !p.background = 255 and !p.color = 0 so that the plots have 
			   white background and blck foreground
       16-Oct-98 (CMH) - added battery trend parameters, HK_BATTERY; replaced wax actuator current
                         with spacecraft ops heater current in HK_AMPS_OTHER
       06-Nov-98 (CMH) - added spacecraft thermister plots; fine sunpoint, dss and sequence status flags
	17-Nov-98 (MDM) - Added a statement to delete the output file first
			  (to get around some funny protection problem)
	08-Mar-00 (TDT) - Added /every keyword for quick_hkplot to speed it up (default every = dur)
       14-aug-00 (CMH) - Changed GT errors to pzt errors in case of  'HK_ISS_3ERRS'
       22-Sep-00 (CMH) - Added HK_WHL_A_TORQ to monitor anomaluos wheel A torque spikes
       25-Sep-00 (CMH) - Added ISS plots to HK_WHL_A_TORQ
       19-Feb-01 (CMH) - Added wheel torque plots, HK_WHL_TORQUES


tr_mon_health [2] $SSW/trace/idl/ops/tr_mon_health_back.pro
[Previous] [Next]
NAME:
	tr_mon_health
PURPOSE:
	TRACE Health monitor driver
SAMPLE CALLING SEQUENCE:
	tr_mon_health, item, dur, daytime
	tr_mon_health, 'HK_AMPS_MAIN'
	tr_mon_health, 'HK_VOLT_MAIN', 10, '10-Dec-97'
	tr_mon_health, 'TXT_SEQ_RUN_SUM', 1, '5-Dec-97'
	tr_mon_health, 'TXT_PER_IMAGE', 1, '5-Dec-97', offset=6558102D
INPUT:
	item	- The health item wanted.  Items are:
			HK_AMPS_MAIN	A 1x3 set of panels which provides the current for
					the DPU, the Operational Heaters, and the Mechanisms
			HK_AMPS_OTHER	A 2x2 set of panels providing the current for the
					CCD Decontamination bus, the Survival Heater bus, the Wax Actuator
					bus, and the Spacecraft Bus Voltage.
			HK_BATTERY	A 2x3 set of panels which provides the battery state of charge,
                                       battery curren, battery voltage, shunt current and battery temps 1 & 2
			HK_TEMP_6BASIC	A 2x3 set of panels giving the temperature of
					the Primary Mirror (S/C), the MgF Window (PRT), the CCD Electronics
					(S/C), the Operational Heaters Converter (PRT), the DPU Converter
					the CCD - where the latter plots both the S/C high and S/C low
			HK_TEMP_SC_ONLY	The 10 S/C packet temperatures
                       HK_SC_TEMPS     The spcacraft thermisters
                       HK_FLAGS        Fine Sunpoint, DSS Sunpresence and Sequence Status Flags
			HK_SEQ_FRMNUM	A single panel plotting the Frame Number in Sequence.
			HK_ISS_3ERRS	A 1x3 set of panels providing the average A, B, and C errors.
			HK_VOLT_MAIN	A 2x2 set of panels where
					     #1  has 3 curves    +15V for App & CCD & Mech 
					     #2  has 2 curves    -15V for App & CCD
					     #3  has 2 curves    +5V  for App & CCD
					     #4  has 2 curves    +72V for ISS and +30V for CCD
			HK_SW_CMD_ERR	At least a 1x2 panel where command count is in one
				        panel and DHC error count is in the other; perhaps DM/MxL will
				        decide on something additional.
			HK_WHL_A_TORQ   Wheel A torque - added to monitor the anomalous wheel A torque spikes
			TXT_IPERR_SEA	Listing of the events when the DHC (IP) error count incremented
			TXT_SEQ_RUN_SUM	Listing of when sequences were run
			TXT_PER_IMAGE	Listing per image
OPTIONAL INPUT:
	dur	- The duration in days.  Default is 1 day
	daytime	- The end date/time.  Default is up to current
		  GMT
OPTIONAL KEYWORD INPUT:
	start	- Make the "daytime" be the START date/time (not end)
	z	- Send the output to the z buffer and file
	offset	- The time correction for pre-launch real GMT not matching
		  the S/C time for the call to TR_RD_INDEX
METHOD:
	Display to the screen (or) to a z buffer and then saved to
	a GIF file.  Use similar calling sequences for 1 day, 10 day,
	and 60 day requests.
HISTORY:
	Written 10-Mar-98 by M.Morrison
	18-Mar-98 (MDM) - Changed to reset device back after /hc
	31-Mar-98 (MDM) - Added "HK_TEMP_SC_ONLY"
			- Changed HK_TEMP_6BASICS to do ccd hi/lo
	31-Mar-98 (MDM) - Made HK_TEMP_6BASICS only do hi
	 2-Apr-98 (MDM) - Make 6BASICS to ccd hi/lo
	 2-Apr-98 (MDM) - Pass "pm_filter=100" to quick_hkplot to 
			  filter the garbage
			- Made the window 750x600 (instead of 600x600)
	16-Apr-98 (MDM) - Changed to use /filter1d (instead of pm_filter)
			- Added HK_FRMNUM_CMD_ERR
			- Added /last_tim_lab param to quick_hkplots calls
	21-Apr-98 (MDM) - Fixed HK_FRMNUM_CMD_ERR to be 1x3 (not 1x2)
	26-May-98 (JFC) - changed HK_SW_CMD_ERR & HK_FRMNUM_CMD_ERR to have mass memory plotted (iksqrg1e)
			  instead of DHC error (ikipecnt) because it's now available as a list
	26-May-98 (JFC) - added !psym = 3 before calls to quick_hkplot in HK_SW_CMD_ERR and 
			   HK_FRMNUM_CMD_ERR so that dots are plotted instead of solid lines
	26-May-98 (JFC) - added !p.background = 255 and !p.color = 0 so that the plots have 
			   white background and blck foreground
       16-Oct-98 (CMH) - added battery trend parameters, HK_BATTERY; replaced wax actuator current
                         with spacecraft ops heater current in HK_AMPS_OTHER
       06-Nov-98 (CMH) - added spacecraft thermister plots; fine sunpoint, dss and sequence status flags
	17-Nov-98 (MDM) - Added a statement to delete the output file first
			  (to get around some funny protection problem)
	08-Mar-00 (TDT) - Added /every keyword for quick_hkplot to speed it up (default every = dur)
       14-aug-00 (CMH) - Changed GT errors to pzt errors in case of  'HK_ISS_3ERRS'
       22-Sep-00 (CMH) - Added HK_WHL_A_TORQ to monitor anomaluos wheel A torque spikes
       25-Sep-00 (CMH) - Added ISS plots to HK_WHL_A_TORQ
       19-Feb-01 (CMH) - Added wheel torque plots, HK_WHL_TORQUES


tr_mon_health_lmsal $SSW/trace/idl/site/tr_mon_health_lmsal_pbs.pro
[Previous] [Next]
NAME:
	tr_mon_health_lmsal
PURPOSE:
	To generate the TRACE long duration health monitoring
	plots and listings
HISTORY:
	Written 25-Mar-98 by M.Morrison
	16-Apr-98 (MDM) - Added HK_FRMNUM_CMD_ERR
	21-Apr-98 (MDM) - Added HK_TEMP_SC_ONLY
       16-Oct-98 (CMH) - Added HK_BATTERY
       06-Nov-98 (CMH) - Added HK_SC_TEMPS, HK_FLAGS
       05-Oct-00 (CMH) - Added HK_WHL_A_TORQ


tr_qs_quality $SSW/trace/idl/info/tr_qs_quality.pro
[Previous] [Next]
NAME:
	tr_qs_quality
PURPOSE:
	Boolean return of equality between wavelength corresponding to the 
	allowed TRACE quad shutter positions (mquad) with the requested 
	EUV or UV wavelength (wave_len).
	
SAMPLE CALLING SEQUENCE:
	qsqual = tr_qs_quality(index)
INPUTS:
	index - The index structure of 1 or more images
	dph   - Optional binary "505" word header in byte 2-D form
	qstop - Optional STOP at end of function
OUTPUTS:
	function returns TRUE or FALSE byte array of good quad positions
	mquad - Optional output of quad position values
 CALLS: ***
	gtt_info
HISTORY:
	written 11-Apr-00 by R.W. Nightingale


tr_rd_index $SSW/trace/idl/ops/tr_rd_index.pro
[Previous] [Next]
NAME:
	tr_rd_index
PURPOSE:
	To read the TRACE Raw Image (tri) index (binary tables)
SAMPLE CALLING SEQUENCE:
	tr_rd_index, sttim, entim, index, files, map
	tr_rd_index, '18-Feb-98', '18-Feb-98 2:00', index
	tr_rd_index, '4-Dec-97', '4-Dec-97 6:00', index, offset=6558102D
INPUT:
	sttim	- Start date/time
	entim	- End date/time
OUTPUT:
	index	- Index header structure
	files	- Source files
	map	- Structure to allow quick access back into the files
 CALLS: ***
	EXIST, STR2ARR [1], STR2ARR [2], TAG_EXIST [1], TAG_EXIST [2], anytim [1]
	anytim [2], anytim [3], anytim [4], anytim [5], anytim2ints [1], anytim2ints [2]
	file_list [1], file_list [2], fmt_tim [1], fmt_tim [2], mxf_read_header, prstr [1]
	prstr [2], sel_filetimes [1], sel_filetimes [2], sel_timrange [1]
	sel_timrange [2], trace_dph2struct [1], trace_dph2struct [2]
 CALLED BY:
	xdisp_trace3
OPTIONAL KEYWORD INPUT:
	type	- Type of file (tri, trm, trj).  Default is tri
	offset_time-Offset to add to the input time to get from real
		GMT time to S/C time
			Test			Offset
			-----			------
			Aug-97 TV Tran#1	10755718
			Sep-97 TV Tran#2	10876652
			Sep-97 TV Tran#3	10681753
			Sep-97 TV 3Day Contam	10599526
			Oct-97 Sim		5883452
			Nov-97 Sim		8983857
			Dec-97 Sim		6558102
	notrim	- Don't do time selection after reading
HISTORY:
	Written 4-Dec-97 by M.Morrison
	11-Dec-97 (MDM) - Patch to avoid "tril" files (list files)
	30-Jan-98 (MDM) - Added /STRUCT option to convert the index
			  to tag names
	25-Mar-98 (MDM) - "Zero" out the index structure if no data
			  for the time span requested
	 9-Apr-98 (MDM) - Added /QDEBUG
	20-Apr-98 (RAS) - cleared inputs through ANYTIM for safety and removed 
			  null strings from all_dirs and all_ff after file_list().
	21-Apr-98 (DMZ) - added some input error checking
	 6-Jan-00 (MDM) - Corrected Y2K bug (not seeing 2000 data)


tr_rd_inventory $SSW/trace/idl/ops/tr_rd_inventory.pro
[Previous] [Next]
NAME:
	tr_rd_inventory
PURPOSE:
	Read the TRACE raw telemetry image inventory file(s)
SAMPLE CALLING SEQUENCE:
	tr_rd_inventory, sttim, entim, files, struct, sou_files
	tr_rd_inventory,'14-Oct 17:00', '15-Oct', files, out
INPUTS:
	sttim	- The starting date/time of interest
	entim	- The ending date/time of interest
OUTPUTS:
	files	- The inventory files found
	struct	- The inventory contents
	sou_files- The files where to get the raw data (source)
METHOD:
	If the inventory files are not in their default location
	in the week directory under the environment variable
	TRACE_RAW_VC2, then this variable needs to be set
	to the directory where the weekly directories of the 
	inventory files is located  
	(i.e.:  for inventory files in  /disk6/people/ngale/reformat/week*/inv  
	        setenv,'TRACE_RAW_VC2=/disk6/people/ngale/reformat').
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], STR2ARR [1], STR2ARR [2], anytim2ints [1], anytim2ints [2]
	break_file [4], concat_dir [4], deriv_arr [1], deriv_arr [2], file_list [1]
	file_list [2], fmt_tim [1], fmt_tim [2], rd_tfiles, sel_filetimes [1]
	sel_filetimes [2], str_replace [1], str_replace [2], tr_hsm_fix
 CALLED BY:
	do_tr_reformat, xdisp_trace2
HISTORY:
V1.0	Written 26-Nov-97 by M.Morrison
V1.1	26-Nov-97 (MDM) - Mod to work on both EGSE and DPS files
			- Added decoding and making the source
			  data files
V1.2	 1-Dec-97 (MDM) - Modified to use FILEMAP from RD_TFILES
V1.3	 8-Dec-97 (MDM) - Fixed up one element RD_TFILES result (IDL problem)
V1.4	18-Feb-98 (MDM) - Modified to point to the base directory
			  and assumes a directory per week
			- Added "seqnum" and "npkt" fields
			- Removed use of "TRACE_DPS_INV_DIR"
V1.5	19-Feb-98 (RWN) - Added version numbers
			  Updated Method text for removal of "TRACE_DPS_INV_DIR"
V1.6	19-Aug-98 (MDM) - Added call to TR_HSM_FIX


tr_reformat $SSW/trace/idl/ops/tr_reformat.pro
[Previous] [Next]
NAME:
	tr_reformat
PURPOSE:
       For reformatting, from all files in the inventory directory that are within
       -24 hours/+24 hours of the start/end times, find all data products within the 
       one hour time span, and time sort them, using the sai as the secondary sorting 
       parameter for each data product type: images, jitter and memory dumps
SAMPLE CALLING SEQUENCE:
	do_tr_reformat, 938473004, 938474479, getenv('TRACE_I1_DIR')
	do_tr_reformat, 938473004, 938474479, '/td35/raw_fits_test', offset_time=6558102
INPUT:
       sttimsec   - Input start time for reformatting into the one hour data file 
       type       - Input file type (string) for 1 hour output file
	base_outdir- The base directory for the output.  It will create a 
		     directory per day under that location
	files	   - The inventory files found
	struct	   - The inventory contents
	sou_files  - The source files from which to get the raw data
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], SSW_FILE_DELETE
	TIME2FILE, UNIQ [1], UNIQ [2], UNIQ [3], anytim2ex [1], anytim2ex [2]
	anytim2ints [1], anytim2ints [2], anytim2weekinfo, concat_dir [4], file_diff
	file_exist [1], file_exist [3], fmt_tim [1], fmt_tim [2], str_replace [1]
	str_replace [2], tr_build_img [1], tr_build_img [2], tr_wrt_fits_i1 [1]
	tr_wrt_fits_i1 [2]
 CALLED BY:
	do_tr_reformat
OPTIONAL KEYWORD INPUT:
       pdebug     - debug flag to print just selected and sorted file times, etc
       qdebug     - debug flag for all diagnostics 
	qstop      - debug stop
       offset_time- The number of seconds to subtract from pkt_time to get 
                    the "real" GMT Time (used during ground tests)
HISTORY:
V1.0   Written Nov-97 by R. W. Nightingale
V1.1   21-Nov-97 (RWN) - added capability to combine partial packets together (incomplete)
V1.2    3-Dec-97 (RWN) - replace TRACE raw telemetry inventory file read with TR_RD_INVENTORY
V1.21	 3-Dec-97 (MDM) - Added BASE_OUTDIR
			- Added calls to TR_BUILD_IMG and TR_WRT_FITS_I1
V1.22	 4-Dec-97 (MDM) - Added offset_time
V1.23	 9-Dec-97 (MDM) - Modified to make the output file in TEMP
			  dir and then move it
V2.0   28-Jan-98 (RWN) - Moved the call for TR_RD_INVENTORY to DO_TR_REFORMAT before loop
                       - Added partial data product (image) merging to TR_BUILD_IMG
V2.1	18-Feb-98 (MDM) - Changed to use an output directory per week and a directory
			  branch per data type
V2.2	19-Feb-98 (RWN) - Removed argument dup from call to TR_BUILD_IMG
			- Removed line numbers
V2.3    4-Apr-98 (RWN) - Changed partial image selection for type le 800
V2.4	13-Jul-98 (MDM) - Modified to use FILE_DIFF and to only copy online if there
			  are differences to the online routine
V2.41	13-Jul-98 (MDM) - Modified FILE_DIFF mask to mask out the comment portion
			  of the binary extension table (date/time made)
V2.42	15-Jul-98 (MDM) - Correct "qdiff" logic (qdiff = 10, does not result in
			  a "true" for "if (qdiff)"!!!
V2.50	19-Aug-98 (MDM) - Added call to TR_HSM_FIX in TR_BUILD_IMG


tr_run_sw_sim $SSW/trace/idl/ops/tr_run_sw_sim.pro
[Previous] [Next]
HISTORY:
	Written Sep-97 by M.Morrison
	 2-Dec-97 (MDM) - Made s/w simulator output to go into ~/sw_sim
			- Added user question for input file name


tr_scan_images $SSW/trace/idl/egse/tr_scan_images.pro
[Previous] [Next]
NAME: 
	tr_scan_images
PURPOSE:
	Read and display a list of files - display the images
	stretching +/- N sigma.  Useful for screening data for
	health checks or finding data which is "lost"
SAMPLE CALLING SEQUENCE:
	tr_scan_images
	tr_scan_images, sigma=3
	tr_scan_images, file_arr
	tr_scan_images, filter='*cmtest*.fits'
	tr_scan_images, /nopause, dir='/td10/log/rawimage/970418'
OPTIONAL INPUT:
	file_arr- The files to display.  Default is to put up
		  a widget with a list of input directories
		  (a directory per day)
 CALLS: ***
	CONGRID [1], CONGRID [2], CONGRID [3], GET_I0_DIRS, PAUSE [1], RFITS [1], RFITS [2]
	RFITS [3], STDEV, XMENU_SEL [1], XMENU_SEL [2], file_list [1], file_list [2]
	pause [2]
OPTIONAL KEYWORD INPUT:
	sigma 	- How to stretch the data for display. Default=1
	dir	- The directory where to grab all fits images.
	nopause	- If set, then do not pause between images.
	filter	- The filename filter to be used to select
		  files (Default = '*.fits')
METHOD:
	The file name is printed out, along with the avg and
	standard deviation.
HISTORY:
	Written 30-Apr-97 by M.Morrison


tr_summary_head $SSW/trace/idl/egse/tr_summary_head.pro
[Previous] [Next]
NAME:
	tr_summary_head
PURPOSE:
	To make a listing of the header information for a series of
	TRACE image files
SAMPLE CALLING SEQUENCE:
	tr_summary_head, files
	tr_summary_head, dir='/td21/log/rawimage/970403'
	tr_summary_head, ymd='970403'
	tr_summary_head, file_list('/td21/log/rawimage/970403', '*')
	tr_summary_head, ymd='970403', lstfil='mhead_tab_seqreg1.lst'
OPTIONAL INPUT:
	files	- The files to summarize
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FILE_EXIST [2], GET_I0_DIRS, break_file [4], concat_dir [4]
	data_type [1], data_type [2], file_exist [1], file_exist [3], file_list [1]
	file_list [2], prstr [1], prstr [2], rd_tfile [1], rd_tfile [2], rd_trace_i0 [1]
	rd_trace_i0 [2], str2cols [1], str2cols [2], tr_decode_head [1]
	tr_decode_head [2]
 CALLED BY:
	verify_gui
OPTIONAL KEYWORD INPUT:
	dir	- The directory to grab all FITS files and summaries
	ymd	- The year/month/day of the directory to grab and summarize
	lstfil	- The mnemonic list file to use to generate the table
	outfil	- If set, save to an output file.  If it is a non-string
		  variable, it saves to "tr_summary_head.txt"
	img	- If set, then read the image data (done if the lstfil
		  wants to summarize image information)
	hc	- If set, then send the output to a printer
	printer	- Optional printer name (lp printer queue)
	nofilename-If set, don't put the output file name
HISTORY:
	Written 2-Apr-97 by M.Morrison (using GO_SUMMARY_HEAD as start)
	27-Aug-97 (MDM) - Added out argument
	 4-Sep-97 (MDM) - Added /nofilename option
	16-Sep-97 (MDM) - Added "temporary(out)" on concatenation
	26-Sep-97 (MDM) - Added logic to figure out when it is necessary
			  to read the data portion.
	30-Sep-97 (MDM) - Changed default table file to "general2" (from 1)


tr_switch_dirs $SSW/trace/idl/site/tr_switch_dirs.pro
[Previous] [Next]
NAME:
	tr_switch_dirs
PURPOSE:
	To allow switching between what directories to use for
	TRACE HK and data files when running at LMSAL
 CALLS: ***
	XMENU_SEL [1], XMENU_SEL [2]
HISTORY:
	Written 27-Oct-97 by M.Morrison
	 2-Dec-97 (MDM) - Some additions
	11-Dec-97 (MDM) - Added selection of 1 hr/FITS files


tr_tab_head $SSW/trace/idl/info/tr_tab_head.pro
[Previous] [Next]
NAME:
	tr_tab_head
PURPOSE:
	To make a tabular listing of TRACE header information
SAMPLE CALLING SEQUENCE:
	tr_tab_head, index
	tr_tab_head, index, out, tabfil
	tr_tab_head, index, /hc, /land, outfil=outfil
	tr_tab_head, index, out, 'thead_tab_jake1.lst'
	tr_tab_head, index, out, 'thead_tab_jake2.lst', page1head='thead_top_jake2.lst
INPUT:
	index	- The index structure to make a tabular listing of
OUTPUT:
	out	- The string array with the tabular listing
OPTIONAL INPUT:
	tabfil	- The file with the list of keywords to list and the
		  format statements to use.  It will look in
		  $TR_CAL_INFO if the directory is not specified and
		  the input file is not in the default directory.
		  Default file is TR_CAL_INFO/thead_tab_general3.lst
OPTIONAL KEYWORD:
	hc	- Make a hardcopy
	land	- Make the hardcopy in landscape mode
	quiet	- Don't display the listing to the screen
	outfil	- Write the listing to an output file
	nohead	- Don't put the column headings in the output
	prehead	- Add this information before the header
	page1head- The ".lst" file name with the tags which should
		  be listed at the top of each page.
	nopage	- Don't format for page listing	
	keylab	- Passed to GET_INFOX to label each key on the same line
OPTIONAL KEYWORD OUTPUT:
	head	- The header line
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FILE_EXIST [2], break_file [4], concat_dir [4], file_exist [1]
	file_exist [3], get_infox, prstr [1], prstr [2], rd_ulin_col, str2pages
 CALLED BY:
	xdisp_trace3
HISTORY:
	Written 15-Jan-98 by M.Morrison
	19-Feb-98 (MDM) - Various modifications
	24-Feb-98 (MDM) - Changed to use STR2PAGES
			- Added PAGE1HEAD, NOPAGE, HEAD and KEYLAB


tr_wrt_fits $SSW/trace/idl/egse/tr_wrt_fits.pro
[Previous] [Next]
NAME:
	tr_wrt_fits
PURPOSE:
	To write a TRACE FITS file with a binary extension
SAMPLE CALLING SEQUENCE:
	tr_wrt_fits, outfil, shead, img, ehead
INPUT:
	outfil	- The name of the output file
	shead	- The simple FITS header (string array)
	img	- The data to be saved
	ehead	- The binary extended header in structure format
 CALLS: ***
	FXADDPAR [1], FXADDPAR [2], FXBADDCOL [1], FXBADDCOL [2], FXBCREATE [1]
	FXBCREATE [2], FXBFINISH [1], FXBFINISH [2], FXBHMAKE [1], FXBHMAKE [2]
	FXBWRITE [1], FXBWRITE [2], FXHMAKE [1], FXHMAKE [2], FXWRITE [1], FXWRITE [2]
	data_type [1], data_type [2]
 CALLED BY:
	xdisp_fits, xdisp_trace [1], xdisp_trace2, xdisp_trace3
HISTORY:
	Written 18-Dec-96 by M.Morrison


tr_wrt_fits_i1 [1] $SSW/trace/idl/egse/tr_wrt_fits_i1.pro
[Previous] [Next]
NAME:
	tr_wrt_fits_i1
PURPOSE:
	Write a single image to a FITS file per hour for TRACE
SAMPLE CALLING SEQUENCE:
	tr_wrt_fits_i1, outfil, dp_header, img0, img, iimg, nimg, $
		percentd, apid, pkt_time, $
		offset_time=offset_time
INPUT:
	outfil
	dp_header
	img0	- raw (compressed) image.  It is overwritten by
		  img if it is compressed
	img	- Decompressed image (0b if img0 is already 
		  decompressed
	iimg	- The image number in the file, starts at 0
	nimg	- The number of images to go into that file
	apid	- The APID where the image came from
	pkt_time- The packet time (seconds past 24-May-68)
	percentd- The amount of data present
 CALLS: ***
	FXADDPAR [1], FXADDPAR [2], FXBHMAKE [1], FXBHMAKE [2], FXHMAKE [1], FXHMAKE [2]
	FXWRITE [1], FXWRITE [2], GET_NBYTES, STDEV, anytim2ints [1], anytim2ints [2]
	data_type [1], data_type [2], gtt_mnem, wrt_fits_bin_exten [1]
	wrt_fits_bin_exten [2]
 CALLED BY:
	tr_reformat, write_trace_bin
OPTIONAL KEYWORD INPUT:
	offset_time-The number of seconds to subtract from pkt_time to
		  get the "real" GMT Time (used during ground
		  tests)
	norotation- If set, don't set the "rot_out" value based
		   on the rotation.
OPTIONAL KEYWORD OUTPUT:
	start_extend-The byte offset to the start of the extended header
HISTORY OF IMG_VER:
1.0	- "mk_trace_i0"
2.0	- "mk_trace_i1" initial value
2.01	- Added APID and PKT_TIME to the binary fits extension
	- Changed "n_words" to "n_bytes"
	- Changed "comp_style" to "comp_code"
2.10	- Changed to have "start_byte" be from the beginning of
	  the file (not the beginning of data section)
3.0	- First version of TR_WRT_FITS_I1
3.1	- Added rotation

HISTORY:
V1.00	Written 1-Dec-97 by M.Morrison (guts of MK_TRACE_I1)
V1.01	 3-Dec-97 (MDM) - Added MPROGNAM and MPROGVER
V1.02	 3-Dec-97 (MDM)	- STDEV protection
V1.03	 4-Dec-97 (MDM) - Adjusted QCOMP logic (handle memory dumps)
V1.04	 4-Dec-97 (MDM) - Corrected OFFSET_TIME usage
V1.05	28-Jan-98 (MDM) - Modified to make the .dp_header tag to NOT be
			  hardwired to 505 elements long.  It is defined
			  by the input.  This handles the non-image
			  data product types.
			- progver was still set to 1.03 (note)
V1.06	10-Feb-98 (MDM) - Modified to look at the data type when writing
			  it out (because jitter data is byte type)
V1.10	11-Mar-98 (MDM) - Added "rot_out" for rotation to put the image
			  up properly for solar north up
			- Reversed nx_out/ny_out because of the rotation
			- Added /NOROTATION
V1.11	17-Mar-98 (MDM) - Corrected V1.06 mod (didn't work for JPEG properly)
			- Made /NOROTATION not flip the NX/NY
V1.12	13-Jul-98 (MDM) - Added start_extend output


tr_wrt_fits_i1 [2] $SSW/trace/idl/info/tr_wrt_fits_i11.pro
[Previous] [Next]
NAME:
	tr_wrt_fits_i1
PURPOSE:
	Write a single image to a FITS file per hour for TRACE
SAMPLE CALLING SEQUENCE:
	tr_wrt_fits_i1, outfil, dp_header, img0, img, iimg, nimg, $
		percentd, apid, pkt_time, $
		offset_time=offset_time
INPUT:
	outfil
	dp_header
	img0	- raw (compressed) image.  It is overwritten by
		  img if it is compressed
	img	- Decompressed image (0b if img0 is already 
		  decompressed
	iimg	- The image number in the file, starts at 0
	nimg	- The number of images to go into that file
	apid	- The APID where the image came from
	pkt_time- The packet time (seconds past 24-May-68)
	percentd- The amount of data present
 CALLS: ***
	BOX_MESSAGE, FXADDPAR [1], FXADDPAR [2], FXBHMAKE [1], FXBHMAKE [2], FXHMAKE [1]
	FXHMAKE [2], FXWRITE [1], FXWRITE [2], GET_NBYTES, IS_LENDIAN, STDEV
	TR_WRT_FITS_I11, anytim [1], anytim [2], anytim [3], anytim [4], anytim [5]
	data_chk [1], data_chk [2], data_type [1], data_type [2], dec2sun [1], dec2sun [2]
	gt_tagval [1], gt_tagval [2], gtt_mnem, trace_bin_struct, wrt_fits_bin_exten [1]
	wrt_fits_bin_exten [2]
 CALLED BY:
	tr_reformat, write_trace_bin
OPTIONAL KEYWORD INPUT:
	offset_time-The number of seconds to subtract from pkt_time to
		  get the "real" GMT Time (used during ground
		  tests)
	norotation- If set, don't set the "rot_out" value based
		   on the rotation.
HISTORY OF IMG_VER:
1.0	- "mk_trace_i0"
2.0	- "mk_trace_i1" initial value
2.01	- Added APID and PKT_TIME to the binary fits extension
	- Changed "n_words" to "n_bytes"
	- Changed "comp_style" to "comp_code"
2.10	- Changed to have "start_byte" be from the beginning of
	  the file (not the beginning of data section)
3.0	- First version of TR_WRT_FITS_I1
3.1	- Added rotation

HISTORY:
V1.00	Written 1-Dec-97 by M.Morrison (guts of MK_TRACE_I1)
V1.01	 3-Dec-97 (MDM) - Added MPROGNAM and MPROGVER
V1.02	 3-Dec-97 (MDM)	- STDEV protection
V1.03	 4-Dec-97 (MDM) - Adjusted QCOMP logic (handle memory dumps)
V1.04	 4-Dec-97 (MDM) - Corrected OFFSET_TIME usage
V1.05	28-Jan-98 (MDM) - Modified to make the .dp_header tag to NOT be
			  hardwired to 505 elements long.  It is defined
			  by the input.  This handles the non-image
			  data product types.
			- progver was still set to 1.03 (note)
V1.06	10-Feb-98 (MDM) - Modified to look at the data type when writing
			  it out (because jitter data is byte type)
V1.10	11-Mar-98 (MDM) - Added "rot_out" for rotation to put the image
			  up properly for solar north up
			- Reversed nx_out/ny_out because of the rotation
			- Added /NOROTATION
V1.11	17-Mar-98 (MDM) - Corrected V1.06 mod (didn't work for JPEG properly)
			- Made /NOROTATION not flip the NX/NY
V1.12  19-Mar-98 (SLF) - use data_chk(xx,[/nx,/ny]) instead of n_el(xx(*,0))
                         for execution efficiency
V2.00  23-Mar-98 (SLF) - use input index, add FILE_TYPE info
V2.01  21-May-98 (SLF) - update .time/.day derivation
V3.00  24-Sep-98 (SLF) - assure dp_header is non-zero
V4.00  15-Mar-98 (SLF) - fix ancient L.Endian prob with image (header was ok)
                         [ Thanks to Thijs Krijger, Utrecht  for pointing out
                           this oversight, due to early TRACE team SGI bias....]


TRACE_AEC $SSW/trace/idl/ops/trace_aec.pro
[Previous] [Next]
 NAME:
	TRACE_AEC
 PURPOSE:
	This program mimics the execution of the TRACE automatic exposure
	control (AEC). The online document 
		http://icarus.physics.montana.edu/TRACE/AEC/aec_plan.html
	supplies details of TRACE AEC operation. Requires an AEC
	table to be supplied through the AEC_table common block.
 CALLING SEQUENCE:
	TRACE_AEC, image [,/default, /print, ichange=ichange]
 INPUTS:
	image = an integer array, representing a TRACE image in DN units.
		The image will be threshholded to ensure that it
		is only 12 bits deep.
 KEYWORDS:
	default: if set, then a default AEC table is used.
	print: if set, then a summary of results is printed.
	ichange: returns the change in exposure index.
	display: displays histogram of the image.
	nsat: returns the number of saturated pixels.
 OUTPUT:
	Changes the value of T.CUR in the AEC_table common block.
 CALLED BY:
	TRACE_AECSIM
 COMMON BLOCKS:
	AEC_table contains the following entries (all except PAL are bytes):
		CUR = current exposure index 
		DEF = default exposure index
		UP  = amount to increase CUR if underexposed
		DN  = amount to decrease CUR if overexposed
		PAH = % pixels overexposed for frame overexposed (float);
			precision is (I think) 1%
		PAL = 100-% pixels underexposed for frame underexposed (float);
			precision should be 1/8 %.
		INH = threshhold (histogram bin) for pixel overexposure
		INL = threshhold (histogram bin) for pixel underexposure
 LIMITATIONS:
	(1) This program may not be identical with the flight 
	software implementation. The numerics need a detailed
	check to be certain...
	(2)No provision has been made for multiple target classes.
 REVISION HISTORY:
	Written by C. Kankelborg, 5/97
	97-10-24 (CCK) fixed definition of PAL


TRACE_AECSIM $SSW/trace/idl/ops/trace_aecsim.pro
[Previous] [Next]
 NAME:
       TRACE_AECSIM
 PURPOSE:
       This program simulates response of the TRACE automatic exposure
       control (AEC) to a static image. The online document
               http://icarus.physics.montana.edu/TRACE/AEC/aec_plan.html
       supplies details of TRACE AEC operation. Requires an AEC
       table to be supplied through the AEC_table common block.
 CALLING SEQUENCE:
       result = TRACE_AECSIM(image, [,/display, /default, n=n])
 INPUTS:
       image = a float array, representing detector flux (DN/sec).
 KEYWORDS:
	n: number of iterations; defaults to 32 if not specified.
	default: if set, default values are entered into the AEC table.
       display: if set, AEC image histograms are displayed in real time
		and the final image is displayed in DN units (requires
		the XTV procedure).
 OUTPUT:
       The result is the sequence of exposure indeces (integer array)
	from the test.
 CALLS: ***
	AVERAGE, TRACE_AEC, XTV
 COMMON BLOCKS:
       AEC_table contains the following entries (all except PAL are bytes):
               CUR = current exposure index
               DEF = default exposure index
               UP  = amount to increase CUR if underexposed
               DN  = amount to decrease CUR if overexposed
               PAH = % pixels overexposed for frame overexposed (float);
			precision is (I think) 1%.
               PAL = 100-% pixels underexposed for frame underexposed,
			to a precision of 1/8% (float).
               INH = threshhold (histogram bin) for pixel overexposure
               INL = threshhold (histogram bin) for pixel underexposure
	Note that if /default is set, then a default built-in table is used.
 REVISION HISTORY:
       Written by C. Kankelborg, 5/97
	97-10-24 (CCK) fixed definition of PAL


TRACE_ALIGN_CUBE $SSW/trace/idl/util/trace_align_cube.pro
[Previous] [Next]

pro trace_align_cube, itrace, dtrace, index, data, $
                      ss_ref, ss_start, ss_end,  $
                      missing = missing, nodiffrot=nodiffrot, $
                      center=center, dimensions=dimensions,  $
                      scale=scale, date=date, $
                      verbose=verbose, quiet=quiet

NAME:
   TRACE_ALIGN_CUBE
PURPOSE:
   Dejitter/align a TRACE data cube and optionally correct for solar
   rotation. 
CATEGORY:
CALLING SEQUENCE:
   trace_align_cube, itrace, dtrace, index, data, ss_ref, ss_start, ss_end
INPUTS:
   itrace, dtrace = original TRACE index and data cube.  You must
                    correct the pointing (.xcen,.ycen) in itrace
                    before running trace_align_cube if you want to
                    remove jitter (see trace_mdi_align and
                    trace_cube_pointing).
OPTIONAL INPUT PARAMETERS:
   ss_ref = index of the reference image in itrace,dtrace.  All other
            images are aligned to this one.  Default = 0.
   ss_start, ss_end = If you like, you can operate on a subset of the
                      data cube.  These give the index of the start
                      and end images in itrace,dtrace.  Dafault =
                      align the full data cube.  
KEYWORD PARAMETERS:
   missing = set value of extrapolated pixels to this number.
   /nodiffrot = do not apply solar rotation to the shifts.
   center, dimensions, scale, date = Rather than aligning to a reference
                              image, align all images to center =
                              [x,y], dimension = [xsize,ysize], and
                              scale = [yscale,yscale] at date = date.
OUTPUTS:
   index, data = the new TRACE index and data cube.
 CALLS: ***
	DIFF_ROT [1], DIFF_ROT [2], LONLAT2XY, PROGRESS, SHIFT_IMG, anytim [1], anytim [2]
	anytim [3], anytim [4], anytim [5], update_history, xy2lonlat
COMMON BLOCKS:
SIDE EFFECTS:
RESTRICTIONS:
     The .xcen and .ycen fields of the index are assumed to be
     correct.  You should use trace_mdi_align and trace_cube_pointing
     to make sure this is true before using trace_align_cube.  If you
     don't do this, the jitter will *not* be removed.  This might still
     be useful, depending on your application, but beware.
PROCEDURE:
     Determines the image shifts from the pointing in the TRACE
     header (.xcen and .ycen) and then uses shift_img to do the
     alignments.

     If the images in the data cube are not all the same size or
     scale, the final data cube will have the size and scale of the
     reference image. 
MODIFICATION HISTORY:
     T. Metcalf  2003-Sep-24


trace_bin_struct $SSW/trace/idl/info/trace_bin_struct.pro
[Previous] [Next]
   Name: trace_bin_struct

   Purpose: generate binary 'index' array including required tags and input
            
   Input Parameters:
      dph - dpheader (either header or structure containing header)  

   Output:
      function returns vector of structures (minimal or minimal+index)
  
  Calling Sequence:
     binstructs=trace_bin_struct(dph)   ; minimal binary structure
     binstructs=trace_bin_struct(index) ; same + input structure contents

 CALLS: ***
	JOIN_STRUCT [1], JOIN_STRUCT [2], MAKE_STR [1], MAKE_STR [2], data_chk [1]
	data_chk [2], gt_tagval [1], gt_tagval [2]
 CALLED BY:
	tr_wrt_fits_i1 [2]
  History:
    24-mar-98 - S.L.Freeland - permit output files with preserved index
                in the binary extension.  add .FILE_TYPE field.
                (simplify logic in tr_wrt_fits_i1)
    25-Mar-98 - S. L. Freeland (remove file_type (move to primary header)


trace_build_mosaic3 $SSW/trace/idl/util/trace_build_mosaic3.pro
[Previous] [Next]
 NAME: trace_build_mosaic3

 PURPOSE: Assembles TRACE full disk mosaic

 CALLING SEQUENCE: trace_build_mosaic3, tmrfilename

 INPUT PARAMETERS:	tmrfilename - the tmr file contining the data
	index, data - from tmrfile
	xgrid, ygrid - grid parameters for rotation shift (default 8,8)	

 OUTPUTS:  tma_tmrfilename 
	mindex, mdata - mosaic 'index,data'
	
 CALLED BY:
	trace_make_tma
 EXAMPLE: trace_build_mosaic, tmrindex, tmrdata, mindex, mdata
	                           IN     IN       OUT     OUT
 HISTORY:
	Written		McMullen/Northup	June, 1998 for TRACE data
	(largely from DeLuca fs_mosaic.pro)
	Modified to do 4 rotation shifts/image July 6, 1998
       13-July-1998 - S.L.Freeland - made it a memory operation routine
	15-July-1998 - T.Northup - rotation shifts/image as variable
       23-Sep -1998 - S.L.Freeland - Boost output size to maximum for new (larger) mosaics
	25-Nov -1998 - T. Tarbell - Remove despiking from here and put in make_tma instead
       30-Nov-1998  - S.L.Freeland - add a history (update_history.pro)
                                     change 'boost it' logic to use
                                     index2fov.pro

 CALLS: ***
	ANYTIM2TAI, BOX_MESSAGE, ROT_XY, data_chk [1], data_chk [2], index2fov, read_trace
	update_history
 RESTRICTIONS:


trace_cat $SSW/trace/idl/info/trace_cat.pro
[Previous] [Next]
   Name: trace_cat

   Purpose: read TRACE catalog (via setup/call to 'read_genxcat')  

   Input Parameters:
      t0, t1 - timerange for read

   Keyword Parameters:
      short - if set, read/return catalog 'short form'
      status - success, 1=>1 or more records between t0 and t1 found
                        0=>no records between t0 and t1
      deltat - if no records between t0 and t1, deltaT of closest match
      count  - number of catalog entries returned
      engineering - if set, read engineering catalog
      cosmic - if set, read cosmic ray dbase
      prefix - optional prefix to use

   Output:
      catalog - catalog entries (idl strutures) between t0 and t1  

   Callling Sequence:
        trace_cat, t0 , t1, catalog [,/short] [,/engineering]
   -OR- trace_cat, catalog , /LASTXX (last XX hours)
 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2]
	concat_dir [4], data_chk [1], data_chk [2], file_exist [1], file_exist [3]
	get_logenv [1], get_logenv [2], is_number [1], is_number [2], read_genxcat
	timegrid, ut_time [1], ut_time [2]
 CALLED BY:
	TRACE_COPY, TRACE_GBO, plot_ssw_fov, tace_time2level1, tr_mech_summary_img month
	trace_cosmic2hist_accum, trace_last_movie [2], trace_make_vignette
   History:
      16-April-1998 - S.L.Freeland - provide TRACE front end to read_genxcat
      18-April-1998 - S.L.Freeland - add /LASTXX option
      25-June-1998  - S.L.Freeland - add STATUS and DELTAT (out from read_genx)
      29-June-1999  - S.L.Freeland - add /COSMIC keyword and function
      15-July-1999  - S.L.Freeland - add /QREV (use /cosmic and wave='xx' to get "opposite" quadrant...)
      12-May-2001   - Zarro (EITI/GSFC) - added TRACE_I1_DIR search dir 


trace_cat2cosmic $SSW/trace/idl/util/trace_cat2cosmic.pro
[Previous] [Next]
   Name: trace_cat2cosmic

   Purpose:  get trace cosmic ray counts, add some fdss info....

   Input Parameters:
      catalog - catalog structures (assume pre-filtered for wave/size, etc)

   Output Parameters:
      cosmic_struct - catalog + cosmic info + fdsss

   Keyword Parameters:
      /ULEFT,/URIGHT,/LLEFT,/LRIGHT  - quadrant of image to check
      subsize - nx (=ny)   ; used with quadrant keyword to define corner
      subfield - user explicit [x,y,nx,ny] 
      loud - if set, be verbose
  
 CALLS: ***
	BOX_MESSAGE, JOIN_STRUCT [1], JOIN_STRUCT [2], cosmic_stat, data_chk [1]
	data_chk [2], file_append [1], file_append [2], get_infox, gt_tagval [1]
	gt_tagval [2], gtt_orbit, trace_cat2data
   Restrictions:
      assume catalog is alread prefiltered


trace_cat2data $SSW/trace/idl/info/trace_cat2data.pro
[Previous] [Next]
   Name: trace_cat2data

   Purpose: use catalog entries to get the data (or filelist/dset)

   Input Parameters:
      catalog - catalog entries to check or extract

   Output Parameters:
      out1, out2 - output parameters - definition depends on /FILEDSET
                   switch - the two possibilities are:

      trace_cat2data, catalog, index [,data]        - return 'index,data'
 -OR- trace_cat2data, catalog, file, ss, /FILEDSET  - return 'file,dsetss' 
                                              
   Keyword Parameters:
      FILEDSET - switch - DETERMINES OUTPUT PARAMETER DEFINITION
                          --------------------------------------
                 Default: return 'index,data' via read_trace call

      check_files - switch - if set, just check (no read) online
                    (implied if no output parameters supplied)  
      /XXXX - all others passed to read_trace via keyword inheritance
      ex: /all - convert all trace tags
          /image - use image default tags, etc.

   Calling Examples:
       trace_cat2data, cat(ss), index, data, /image   ; read index/data
                                                      ; /IMAGE->read_trace  
  
 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2]
	UNIQ [1], UNIQ [2], UNIQ [3], anytim2weekinfo, concat_dir [4], file_exist [1]
	file_exist [3], gt_tagval [1], gt_tagval [2], mxf_read_header, read_trace
	required_tags, totvect, trace_struct2filename
 CALLED BY:
	TRACE_COPY, TRACE_GBO, tace_time2level1, trace_cat2cosmic, trace_last_movie [1]
	trace_last_movie [2], trace_last_movie [3], trace_make_vignette
	trace_movie_context, trace_special_movie [1], trace_special_movie [2]
	trace_special_movie [3], trace_special_movie2
   History:
      16-April-1998 - S.L.Freeland
      28-April-1998 - S.L.Freeland - dont try read if /FILEDSET is set
      26-Nov-1998   - S.L.Freeland - pass unknown keywords to read_trace
      28-May-1999   - S.L.Freeland - if /FILEDSET set, return absolute SS
      26-Jun-1999   - RDB - corrected type (call to box_message)


trace_cen2pix $SSW/trace/idl/util/trace_cen2pix.pro
[Previous] [Next]
   Name: trace_cen2pix

   Purpose: trace xcen/ycen->SSW standard pixel coord (crval1/crval2)  

   History:
      24-April-1998 - S.L.Freeland (simplify read_trace<->ssw)
      25-April-1998 - S.L.Freeland (adjust signs for wedge2solar update)
  
 CALLS: ***
	BOX_MESSAGE, gt_tagval [1], gt_tagval [2], required_tags
   Restrictions:
      needs revisiting after wedge2solar,etc are blessed  


trace_cleanjpg $SSW/trace/idl/util/trace_cleanjpg.pro
[Previous] [Next]
 NAME:
	trace_cleanjpg
 PUPROSE:
	To remove jpeg artifacts due to cosmic ray hits.
	The default parameters are optimized for prepared, compressed
	SXT images.
 CALLING SEQUENCE:
	result = trace_cleanjpg(image[, sens=sens, thresh=thresh])
 INPUTS:
	image = 2-dimensional image
 OPTIONAL KEYWORD INPUTS:
   thresh = threshold for bad pixels
   (thresh = 0.05 is default)
 CALLS: ***
	ck_smooth
 CALLED BY:
	TRACE_PREP, trace_unspike
 PROCEDURE:
	Undesired features are amplified and located by
	convolution and thresholding. This information is used to generate
	a map of good (undamaged) pixels. Bad pixels are replaced with a 
	weighted average of nearby good pixels. In a second pass, the
	result of this operation is subtracted from the original image.
	The good pixel map is revised based on the difference image,
	and pixel replacement is done again.
 SIDE-EFFECTS:
	image is converted to a float array, if it's not already.
 MODIFICATION HISTORY:
	Originally sxt_destreak by C. Kankelborg
	1998-Jun-18 CCK Adapted for TRACE SAA/HLZ cleanup


trace_comsmic_norm $SSW/trace/idl/util/trace_cosmic_norm.pro
[Previous] [Next]
   Name: trace_comsmic_norm

   Purpose: normalize trace cosmic hit dbase - default is cts/sec/pixel

   Input Parameters:
      structures - vector of structures - assume from trace cosmic dbase

   Keyword Parameters:
      nopixnorm - if set, dont apply the per pixel normalization
  
 CALLS: ***
	BOX_MESSAGE, TRACE_COSMIC_NORM, data_chk [1], data_chk [2], gt_tagval [1]
	gt_tagval [2], required_tags
   History:
      15-July-1999 - S.L.Freeland - simplify some cosmic dbase comparisons..  


trace_cosmic2filename $SSW/trace/idl/util/trace_cosmic2filename.pro
[Previous] [Next]
   Name: trace_cosmic2filename

   Purpose: generate "standard" filenames from cosmic catalog dbase input

   Input Parameters:
      
   History:
      21-July-1999 - S.L.Freeland - to simplifly data->WWW

   Calls: ***
	ARR2STR [1], Arr2Str [2], BOX_MESSAGE, MAP_PROJ_INFO, TIME2FILE, gt_tagval [1]
	gt_tagval [2], required_tags, ssw_deltat, str_replace [1], str_replace [2]
	time_window


trace_cosmic2hist_accum $SSW/trace/idl/util/trace_cosmic2hist_accum.pro
[Previous] [Next]
   Name: trace_cosmic2hist_accum

   Purpose: accumulate  cosmic radiation histograms for 3 orbital regions

   Input Parameters:
      t0,t1 - time range of interest (input to trace_cat,/cosmic

   Keyword Parameters:
      wave - wavelength (def=171)
      qrev/unshielded (synonyms) - consider UNSHIELDED dbase if set
      shielded (default) - consider shielded dbase  
      nsamp - limit number of histograms per region
      display - if set, show results summary
  
   Method:
      set up and call 'trace_cat', 'trace_cosmic2hist'
      differentiate by radiation zone region

 CALLS: ***
	ARR2STR [1], Arr2Str [2], BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], LEGEND [1], LEGEND [2], LEGEND [3], STR2ARR [1], STR2ARR [2]
	TIME2FILE, TRACE_COSMIC2HIST, WDEF [1], WDEF [2], anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], concat_dir [4], file_append [1], file_append [2]
	grid_data [1], grid_data [2], gtt_orbit, html_doc, linecolors [1], linecolors [2]
	str2number [1], str2number [2], strtab2html, time_window, trace_cat
	zbuff2file [1], zbuff2file [2]
   History:
      8-December-1999 - S.L.Freeland - AGU prep. (Cobey/Freeland/Rosenburg)


TRACE_CUBE_POINTING $SSW/trace/idl/util/trace_cube_pointing.pro
[Previous] [Next]

function trace_cube_pointing,tindex,tdata,itref,mask=mask,quiet=quiet, $
                             xytrace=xytrace,no_shift_guess=no_shift_guess, $
                             full=full, nolimbmask=nolimbmask, shifts=shifts, $
                             xscale = xscaleout, yscale = yscaleout, $
                             _EXTRA=extra

NAME:
     TRACE_CUBE_POINTING
PURPOSE:
     Fix the pointing in a TRACE dataset by aligning each image to
     a reference image within the data cube.  The pointing of the 
     reference image is assumed to be correct (see trace_mdi_align.pro for
     an example of how to get the pointing of this image correct).  The 
     pointing in the new index (.xcen and .ycen) is updated to reflect the 
     pointing in the reference image, but the images themselves are not 
     modified.
CATEGORY:
CALLING SEQUENCE:
     new_trace_index = trace_cube_pointing(tindex,tdata,iref)
INPUTS:
     tindex = trace index
     tdata = trace data cube
     itref = image number in the data cube which will be the reference
             image.  If not set, assumed to be the first image.
OPTIONAL INPUT PARAMETERS:
KEYWORD PARAMETERS
     xytrace = 4 element array giving the LL and UR corners of a subregion
               of the reference image to use in the alignment.  If
               this is not set, you will be asked to define the
               subregion with the mouse (but see /full below). [x0,x1,y0,y1]
     /full = Uses the full reference image, overriding xytrace.  You
             will not be asked to define the subregion.  Slow, but
             useful when automating the alignment process.
     /nolimbmask = Do not apply a limb mask.  By default, points in
                   the images which are over the limb are masked out.
     mask = same size as the tdata cube.  Pixels with mask=1 will NOT
            be included in the alignment calculation.  Use this to mask
            out blemishes, saturated areas, whatever.  If mask exists, it
            must exist for every image in the data cube.  It is
            important to mask out the limb and over the limb points
            for WL and UV images.  A limb mask is applied by default,
            but, since it uses the pointing to determine where the
            limb is, it may not be accurate except for the reference
            image (since the poinging of the reference image is
            presumed to be correct but others are not).
     /no_shift_guess = ignore the pointing shift between the images and the
                       reference image when computing the initial guess for
                       the transformation between them.  Useful if the images
                       have nearly the same pointing to start with, but the 
                       pointing error in the images is large so that the 
                       corrected pointing in the reference image is far from
                       the incorrect pointing in the images to be
                       fixed.  Setting this keyword will neglect this
                       artificial shift in the initial guess of the
                       alignment.  If the pointing is not in fact the
                       smae, this keyword will cause a rather
                       dramatic failure.
     shifts = On output contains the x and y shifts which would be
              required to align all the images to the reference
              image.  No shifts are actually made, but you could use
              shift_img.pro to do the alignment using these numbers.
              The shifts are returned in *pixel* units.  For example,
                 inew = trace_cube_pointing(i,d,shifts=shiftsxsc=xsc,ysc=ysc)
                 dnew = shift_img(d,shifts,xscale=xsc,yscale=ysc)
              computes the corrected poining of the data cube and
              then creates a new data cube with all the images
              aligned to the reference image (image 0 in this case).
              In this case, the index will not have the correct
              pointing for the *shifted* images, but a movie with dnew
              would have pointing errors and jitter removed.
     xscale,yscale = On output contains the x and y scales which would be
              required to align all the images to the reference
              image.  Pass to shift_img.pro to do the alignment using
              these numbers. 
     /quiet = quiet
     _extra = Extra keywords are passed to auto_align_image, e.g. /amoeba,
              scale, etc.
OUTPUTS:
     new_trace_index = new trace index with .xcen and .ycen updated to match
                       the pointing of the reference image.  The .crval and
                       .crpix tags are also updated with the new pointing.
 CALLS: ***
	AUTO_ALIGN_IMAGES, BILINEAR, DELVARX [1], DELVARX [2], DELVARX [3], DELVARX [4]
	DIFF_ROT [1], DIFF_ROT [2], GET_LATLON, LONLAT2XY, PQ2XY, RSS2PQ, anytim [1]
	anytim [2], anytim [3], anytim [4], anytim [5], delvarx [5], get_rb0p [1]
	get_rb0p [2], int2secarr [1], int2secarr [2], wdefroi [1], wdefroi [2]
	wdefroi [3], wdefroi [4], xy2lonlat
COMMON BLOCKS:
SIDE EFFECTS:
RESTRICTIONS:
     Very slow since a very general warping between the images is
     used.  If you olny want to correct a simple image shift, this is
     not the correct routine to be using.  It will work, but it will
     be much slower than necessary.  The general warping allows for
     some AR evolution, solar rotation, foreshortening, etc. so is
     applicable for datasets that are not very close in time.  For
     images that are just a few seconds or even minutes apart, a
     simple shift is likely sufficient (see tr_get_disp.pro for
     example). 

     The coordinates in the index must match the data cube.  Critical
     parameters are naxis1, naxis2, xcen, ycen, date_obs, cdelt1, and
     cdelt2.  Hence, you cannot pass in a spatial subarray of the
     data unless you also modify the pointing in the index.  The
     safest thing to do is to pass in the index and the full x-y
     extent of the datacube.  Then use the xytrace keyword to select a
     subarray for alignment. 

     This routine will not work well with coronal images since they
     change rapidly.  However, if you insist, you may need to use the
     /nolimbmask keyword.

     Solar rotation is accounted for but this will not give a correct
     change for coronal images.
PROCEDURE:
     Uses auto_align_images with a second order transformation to allow
     for a mask and for foreshortening, etc.  Only the .xcen, .ycen,
     .crpix1, .crpix2, .crval1, .crval2 fields in the index are
     updated.  The images are not in any way shifted, etc.  By
     default, points over the limb are masked out since the apparent
     shift in the limb due to solar rotation would ruin the alignment
     if the limbs were included.  There is little in this routine
     that is specific to TRACE (assumes that solar north is up in the
     images) so it should work for any dataset that has an index with
     the right tags (naxis1, naxis2, xcen, ycen, crpix1, crpix2,
     crval1, crval2, wave_len) and the north up.   
MODIFICATION HISTORY:
     T. Metcalf 2001-Oct-17
     T. Metcalf 2001-Nov-15 Also update crpix1,crpix2,crval1,crval2, wave_len so that
                            the new index with the new pointing will work
                            with index2map and plot_map which gets pointing
                            from crpix and crval rather than xcen and ycen.
     T. Metcalf 2001-Nov-19 Mask off-limb points.  Fixed bug in ROI selection.
     T. Metcalf 2003-Jul-21 Changed code so that it works correctly
                            when the images in the cube have
                            different sizes. Added /full keyword.
     T. Metcalf 2003-Jul-22 Fixed bug in mask indexing introduced
                            yesterday.  Added /nolimbmask keyword.
     T. Metcalf 2003-Jul-22 Changed code so that it works correctly
                            when the image plate scales in the data cube
                            vary.
     T. Metcalf 2003-Jul-29 Added shifts, xscale, and yscale keywords.  Fixed
                            a small bug in the way the initial guess
                            was computed when the image plate scales
                            vary. 


trace_data_filter $SSW/trace/idl/util/trace_data_filter.pro
[Previous] [Next]
   Name: trace_data_filter

   Purpose: return subscripts of 'good' or 'bad' trace data

   Input Parameters:
      index - tri index or catalog entry
      data  - optional (for detailed checks)

   Output:
      funtion returns subscripts of good or bad data

 CALLS: ***
	BOX_MESSAGE, gtt_orbit, required_tags
 CALLED BY:
	TRACE_SSWHERE [1], plot_fov [1], trace_last_movie [1], trace_last_movie [3]
	trace_special_movie [1], trace_special_movie [2], trace_special_movie [3]
	trace_special_movie2, trace_sswhere [2], trace_sswhere [3], trace_sswhere [4]
   History:
     ~1-Aug-1998 - S.L.Freeland - for auto-TRACE movies
     16-Sep-1998 - S.L.Freeland - add PERCENTD and QUALITY (synonyms) 
                                  (default set to 100%)
     03-Nov-1998 - RDB  Corrected logic error in bad vector; verbose keyword


trace_decode_idl PLEASE USE trace_jpeg_decomp $SSW/trace/idl/info/trace_decode_idl.pro
[Previous] [Next]
   Name: trace_decode_idl (PLEASE USE <trace_jpeg_decomp> )

   Purpose: decompress a 'TRACE' jpeg stream (call RShine C routine)

   Input Parameters:  
      index       - structure defining image/stream (w/tag = dp_header)
                    OR trace dp_header  
      jpeg_stream - stream 

   Keyword Parameters:
      huffman - huffman table to use (default derived from DP header)
      qt      - quant. talbe default derived from DP header)
      nx      - (output) NX size of decoded image  
      ny      - (output) NY size of decoded image  
      current - (switch) if set, use copy of Shared object in current direct.
      ssw     - (switch) if set, force use of SSW shared version (DEFAULT)
      debug   - (switch) if set, stop before and after call_external call
  
 CALLS: ***
	BOX_MESSAGE, CALL_EXTERNAL_INFO, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3]
	FILE_EXIST [2], TRACE_DECODE_IDL, concat_dir [4], curdir [1], curdir [2]
	file_exist [1], file_exist [3], get_logenv [1], get_logenv [2], trace_jpeg_dbase
   History:
      26-Nov-1997 - S.L.Freeland / Richard Shine
       2-dec-1997 - add NX, NY, made temporary copy , reform within IDL
                    made it SSW transportable - rename to 'trace_jpeg_decomp'
  
       4-dec-1997 - add /CURRENT (testing)
                    review after c change - nx/ny protect
                     eliminate old testing dir referces
      
   Method: 
      Set up and call R. Shine C routine 'trace_decode_idl' via 'call_external'

      TODO - optimize 


TRACE_DEM $SSW/trace/idl/util/trace_dem.pro
[Previous] [Next]
NAME:
	TRACE_DEM
PURPOSE:
	Calculate differential emission measure and EM weighted average
	temperature for a set of TRACE images in all three EUV wavelengths
	(171, 195, 284). By default, units of column emission measure are
	used (see TRACE_T_RESP).
CALLING SEQUENCE:
	trace_dem, index, data[, basis=basis, Tavg=Tavg, emtot=emtot, emc=emc, $
		A=A, K_inv=K_inv, /volume]
INPUTS:
	data - m x n x 3 array containing pixel values in DN for the 171, 195, 
		and 284 angstrom EUV passbands of TRACE
		(but not necessarily in that order). Readout pedestal (approx.
		83 DN for full resolution images, 95 DN for 2x2 summed images)
		must be subtracted prior to sending the data to TRACE_DEM.
	index - TRACE index structure containing, at minimum, the wavelength
		(index.wave_len) and exposure time (index.sht_mdur) associated
		with the three images contained in the data parameter. If not
		supplied, then it is assumed that the order of wavelengths is
		171, 195, 284 and that the pixel values are normalized to
		1.0 s exposure time (i.e., units of DN/s).
OPTIONAL INPUT KEYWORDS:
	basis - A string containing the name of a function that will supply
		the three basis elements necessary for constructing DEM curves.
		See TRACE_DEM_SETUP for more information.
		-----------------------------------------------------------
 CALLS: ***
	TRACE_DEM_SETUP
		NOTE: The default basis is NOT normalized to unit total EM.
			Use keyword A to recover the DEM curve from the 
			original basis functions. (example below under "em")
		-----------------------------------------------------------
	volume - if set, use units of volume emission measure instead of
		column emission measure. See TRACE_T_RESP.
OPTIONAL OUTPUT KEYWORDS:
	A - Contains renormalization coefficients for the three basis functions.
	K_inv - Inverse of the K-matrix, which specifies the linear mapping
		from the basis elements to the pixel values (normalized to DN/s).
		The inverse of K may then be used to find the coefficients for
		the three normalized basis functions, and thereby reconstruct a
		DEM curve from TRACE pixel values in three EUV wavelengths.
	emc - contains emission measure coefficients for the three
		normalized basis functions. Because of automatic renormalization,
		the elements of em ALWAYS have units of emission measure.
			In effect, this m x n x 3 data cube represents a 3-parameter 
		differential emission measure curve at every pixel. The total DEM
		function is then:

			dem = emc(0)*A(0)*sbasis(0,T) + $
				 emc(1)*A(1)*sbasis(1,T) + $
				 emc(2)*A(2)*sbasis(2,T)

		If the default basis is not used, then sbasis in the above
		expression would be replaced by a function returning the user's 
		chosen basis.
	Tavg - emission measure averaged temperature, i.e. an m x n temperature map.
	tau - 3-vector giving characteristic temperatures of the DEM basis functions. 
	emtot - Map of total emission measure along the line of sight, 
		integrated over the range of temperatures where the basis elements
		are nonzero. This is just the sum of the three components of em:
		emtot = total(emc, 3).
MODIFICATION HISTORY:
	C. Kankelborg, 25-Sept-1998


TRACE_DEM_SETUP $SSW/trace/idl/util/trace_dem_setup.pro
[Previous] [Next]
NAME:
	TRACE_DEM_SETUP
PURPOSE:
	Calculate and invert the temperature response matrix for a 3-component
	model of the differential emission measure. The resulting 3x3 matrix,
	K_inv, can be used to produce differential emission measure curves
	and temperature maps based on TRACE data in all three EUV wavelengths
	(171, 195, 284). If the dn input parameter is used, then a single
	DEM curve is calculated based on three EUV pixel values.
	
	NOTE-- By default, units of column emission measure are
	used (see TRACE_T_RESP).
CALLING SEQUENCE:
	trace_dem_setup, [index, dn, basis=basis, Tavg=Tavg, em=em, A=A, $
		K_inv=K_inv, /volume]
INPUTS (OPTIONAL):
	dn - 3-component array containing pixel values in DN for 171, 195, 284.
		The three values may be for a single co-aligned pixel, or averaged
		over many pixels. Pedestal (approx. must be already subtracted!
	index - TRACE index structure containing, at minimum, the wavelength
		(index.wave_len) and exposure time (index.sht_mdur) associated
		with the three values contained in the dn parameter. If not
		supplied, then it is assumed that the order of wavelengths is
		171, 195, 284 and that the pixel values are normalized to
		1.0 s exposure time.
OPTIONAL INPUT KEYWORDS:
	basis - A string containing the name of a function that will supply
		the three basis elements necessary for constructing DEM curves.
		The basis functions need not be normalized-- but be warned that
		the program will normalize them so that they integrate to unity,
		and all of the results will be expressed in terms of renormalized
		basis functions. Calculated renormalization coefficients are
		returned through the A keyword. If the basis keyword is not
		used, then the trace_sbasis function (below) will supply a default
		basis. The prototype of any supplied basis function should be
		similar to that of trace_sbasis (see below).
	volume - if set, use units of volume emission measure instead of
		column emission measure. See TRACE_T_RESP.
OPTIONAL OUTPUT KEYWORDS:
	A - Contains normalization coefficients for the three basis functions.
	K_inv - Inverse of the K-matrix, which specifies the linear mapping
		from the basis elements to the pixel values (normalized to DN/s).
		The inverse of K may then be used to find the coefficients for
		the three normalized basis functions, and thereby reconstruct a
		DEM curve from TRACE pixel values in three EUV wavelengths.
	em - If the dn input is supplied, em contains coefficients for the three
		normalized basis functions. Because of automatic renormalization, the
		elements of em ALWAYS have units of emission measure. The total DEM 
		function is then:

			dem = em(0)*A(0)*trace_sbasis(0,T) + $
				 em(1)*A(1)*trace_sbasis(1,T) + $
				 em(2)*A(2)*trace_sbasis(2,T)

		If the default basis is not used, then trace_sbasis in the above
		expression would be replaced by a function returning the user's 
		chosen basis.
	Tavg - If the dn input is supplied, Tavg contains the resulting emission
		measure averaged temperature.
	tau - 3-vector giving characteristic temperatures of the DEM basis functions. 
 CALLED BY:
	TRACE_DEM
MODIFICATION HISTORY:
	C. Kankelborg, 25-Sept-1998

===== Default basis set ======
NAME:
	trace_sbasis
PURPOSE:
	Implement three DEM basis functions, indexed 0, 1, 2.
	This basis has been tested extensively in comparison with
	CHIANTI emission measure curves. It works well for
	quiet sun and active regions.
		The functions are based on sinusoidal bell curves
	with maxima of 1.0 at log(T) = 5.95, 6.13, and 6.31. These
	are close to the peaks in the response curves for the
	TRACE 171, 195, and 284 angstrom passbands. Basis
	element 0 evaluates to 1.0 for temperatures between
	log(T) = 5.0 and 5.95, allowing better fits to DEM
	curves derived from spectroscopic data.
 CALLS: ***
	INT_TABULATED, SIGMOID, TRACE_SBASIS, trace_t_resp
	NOTE: This basis is NOT normalized to unit total EM.
CALLING SEQUENCE:
	result = trace_sbasis(index, T)
INPUTS:
	index - denotes which basis function is to be evaluated
		at temperature T. Valid values are 0, 1, or 2.
	T - A temperature or array of temperatures at which to
		evaluate the basis function.


trace_destreak $SSW/trace/idl/util/trace_destreak.pro
[Previous] [Next]
 NAME:
	trace_destreak
 PUPROSE:
	To remove bad pixels in streaks due to cosmic ray hits.
	The default parameters are optimized for TRACE EUV images.
 CALLING SEQUENCE:
	result = trace_destreak(image[, sens=sens, thresh=thresh])
 INPUTS:
	image = 2-dimensional image
 OPTIONAL KEYWORD INPUTS:
   sens = sensitivity to streaks and spots
   (sens = 5.0 is default)
   thresh = threshold for revised pixel map
   (not used by default)
 CALLS: ***
	CONVOL_ENHANCE, ck_smooth
 CALLED BY:
	TRACE_PREP
 PROCEDURE:
	Streaks at various angles are amplified and located by
	convolution and thresholding. This information is used to generate
	a map of good (undamaged) pixels. The pixel map is then revised
	to include nearest neighbors. Bad pixels are replaced with a 
	weighted average of nearby good pixels. 
 SIDE-EFFECTS:
	image is converted to a float array, if it's not already.
 MODIFICATION HISTORY:
	Originally sxt_destreak by C. Kankelborg
	1998-Jun-18 CCK Adapted for TRACE SAA/HLZ cleanup


TRACE_DIFFRACTION_PATTERN [3] $SSW/trace/idl/util/trace_diffraction_pattern.pro
[Previous] [Next]

function trace_diffraction_pattern, nxin, nyin, wavelengthin, pixel_size

NAME:
     TRACE_DIFFRACTION_PATTERN
PURPOSE:
     Calculates the TRACE diffraction pattern.  Useful for then removing
     the diffraction pattern.
CATEGORY:
CALLING SEQUENCE:
     patt = trace_diffraction_pattern(nx,ny,wavelength,pixel_size)
INPUTS:
     nx,ny = size of array
     wavelength = wavelength in A (string), e.g. '171', '195' or '284'.
     pixel_size = pixel size in arc sec
OPTIONAL INPUT PARAMETERS:
KEYWORD PARAMETERS
OUTPUTS:
     patt = array holding the diffraction pattern.  Normalized so that 
            total(patt) = 1.0.
 CALLED BY:
	TRACE_UNDIFFRACT
COMMON BLOCKS:
SIDE EFFECTS:
     For each order, 
     prints  "order intensityNWSE intensitySWNE distanceNWSE distanceSWNE"
RESTRICTIONS:
     This code is still experimental!  It was calibrated for 171 and 195 from 
     a single flare and assumes that the diffraction pattern does not change
     with time.  Also, it has not yet been calibrated for 284. 
PROCEDURE:
     Interference and diffraction formulae for multiple slits.  The
     parameters used in the model are the slope of the line connecting the
     principal maxima, the wire diameter in the filter mesh, and the wire
     spacing in the filter mesh.  These parameters were set from measurements 
     of a flare.
MODIFICATION HISTORY:
   T. Metcalf  2000-March-04


TRACE_DISP_TEM $SSW/trace/idl/util/trace_disp_tem.pro
[Previous] [Next]
NAME:
	TRACE_DISP_TEM
PURPOSE:
	Create a map of temperature and emission measure. Both parameters
	are displayed simultaneously by the use of color and brightness.
	The HLS color system is used, with temperature represented by the
	hue angle and emission measure encoded in the lightness. Saturation
	is kept at unity to maximize color contrasts.
CALLING SEQUENCE:
	trace_disp_tem, T, em [,/reverse, /legend]
INPUT PARAMETERS:
	T - an m x n array of temperatures, such as the Tavg output produced
		by TRACE_DEM.
	em - an m x n array of emission measures, such as the emtot output
		produced by TRACE_DEM.
OPTIONAL KEYWORD INPUTS:
	quantize - if set, then the T-EM map will be plotted using 8-bit
		color, taking into account the number of colors available on
		the display device. The result is not as pretty, but most users 
		will need this option since 24-bit displays are not common.
	reverse - Controls how emission measure maps to lightness.
		By default, the color goes from black to a bright,
		saturated hue as emission measure increases. If the reverse
		keyword is set, then the representation instead fades from white
		to saturated color with increasing emission measure. This gives
		an appearance similar to watercolor on white canvas. In terms
		of the HLS coordinate system:

			REVERSE         lightness of    lightness of
			set to           minimum EM      maximum EM
			--------------------------------------------
			0 (zero)            0.0             0.5
			1 (nonzero)         1.0             0.5

	legend - if set, then a legend is displayed showing the entire
		palette of colors as a function of T and EM. Optionally,
		legend may contain a 2-vector specifying the location of the
		lower left-hand corner of the legend graphic in device
		coordinates.
	gamma_T - power law for the transfer function mapping temperature
		to hue angle. The default is 1.
	gamma_em - power law for the transfer function mapping emission
		measure to lightness. The default is 1.
	hues - 2-vector indicating the range of hue angles to be used
		for temperature representation. The hue angle may increase
		or decrease with temperature. The default setting of [0,270]
		obtains maximum color contrast by employing hues all the way
		from red to violet. Some other nice choices are:
			[120, 0]     green-yellow-orange-red
			[120, 240]   green-cyan-blue
			[60, 180]    yellow-green-cyan
			[240, 360]   blue-magenta-violet-red
		For convenience, here is a list of colors and their corresponding
		hue angles:
			red        0 (same as 360)
			orange    30
			yellow    60
			green    120
			cyan     180
			blue     240
			violet   270
			magenta  300
			red      360 (same as 0)
	position - 2-vector specifying the position of the lower left-hand
		corner of the T/EM map in device coordinates.
	range - 4-vector specifying the minimum and maximum temperature and
		emission measure values as base-10 logarithms: 

		      range = [log_Tmin, log_Tmax, log_EMmin, log_EMmax]

 CALLS: ***
	CT_LUMINANCE
MODIFICATION HISTORY:
	Written 17-Oct-1998 by C. Kankelborg
	1999-Feb-26 CCK, Added /quantize and revised documentation.


trace_do_data_requests $SSW/trace/idl/wwwidl/trace_do_data_requests.pro
[Previous] [Next]
   Name: trace_do_data_requests

   Purpose: background driver to handle TRACE WWW data request queue

 CALLS: ***
	BOX_MESSAGE, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1]
	CONCAT_DIR [2], CONCAT_DIR [3], FILE2TIME, TRACE_ORDER_DATA
	TRACE_WWWORDERS_INDEX, break_file [4], concat_dir [4], configure_http
	file_append [1], file_append [2], file_list [1], file_list [2], file_size [1]
	file_size [2], get_logenv [1], get_logenv [2], mail [1], mail [2], rd_tfile [1]
	rd_tfile [2], str_replace [1], str_replace [2], trace_request_summary
   History:
     21-May-1998 - S.L.Freeland - LMSAL - driver for 'trace_order_data'
      2-Jun-1998 - S.L.Freeland - use subdirectory orders/requested
                                                         /current
                                                         /finished  
     12-Jun-1998 - S.L.Freeland - call trace_trace_wwworders_index
     18-Aug-1998 - S.L.Freeland - call index generator every loop
  
   Method:
     ----------------------------------------------------------------------
     1) check current job area - if any active jobs, then exit
     2) check incoming job area (via trace_submit_request)
        If new jobs exist, then 
            a) move jobs from ...orders -> ...orders_current
            b) for each new job, process [via trace_order_data,/background]
        Else (no new jobs) exit   
     ----------------------------------------------------------------------


trace_dph2struct [1] $SSW/trace/idl/info/trace_dph2struct.pro
[Previous] [Next]
   Name: trace_dph2struct

   Purpose: extract/convert info from trace dpheader -> IDL structure
  
   Input Parameters:
      ph - primary header from TRACE fits file
      be - binary extension header (includes dph field)
  
   Output:
      Function outputs vector of structures with specify tags filled
      -OR- if /KEYWORD, return vector of associated TAG/KEY (non-structure)  

   Keyword Parameters:
       taglist - optional taglist to include/convert (def=all in dbase)
                (array, comma delimited string or ascii file with tags)
       strtemplate - optional pre-made structure to use (implies TAGLIST)
       head_db - name of header dbase file to use 
      
      quiet/loud - switches to determine noise level of routine
      XXX - if  keyword passed as a switch - output non-structure
            (just specified tag contents)
      no_struct - (switch) - if set, return value, not structure
                             (first element in taglist only)
      nonone - If set, then don't do the ".NONE" database definition executions
      alphabetize - If set, alphabetize tags (default is dbase order)

   Calling Sequence:
      outstr=trace_dph2struct(ph, be [,taglist=taglist , $
                                     strtemplate=strtemplate  $
                                      , head_db=head_db , /loud]
      -OR-
      outval=trace_dph2struct(ph, be , /XXXX) ; extract only specified tag  

      outval=trace_dph2struct(ph, be, taglist='XXXX',/no_struct) ; equivilent

   Calling Examples:
      outstr=trace_dph2struct(ph, be) ; map all tags in tag dbase->structure
      outval=trace_dph2struct(ph, be, /date_obs) ; only DATE_OBS (strarr in this case)

   Notes:
	Speed test is:
		tr_rd_index, '18-Feb-98', '18-Feb-98 2:00', index0		;361 images
		idl_speed & for i=1,1 do index = trace_dph2struct(ph, index0, index0.dp_header) & idl_speed,1

		   Jan-98 	16-18 sec
		19-Feb-98 	7 sec	(pass time to LUT, not do .NONE on gtt_info calls to dph2struct)
 CALLS: ***
	ARR2STR [1], Arr2Str [2], BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FILE_EXIST [2], FMT_TAG [1], FMT_TAG [2], MAKE_STR [1]
	MAKE_STR [2], SCALARIZE, STR2ARR [1], STR2ARR [2], TAG_EXIST [1], TAG_EXIST [2]
	UNIQ [1], UNIQ [2], UNIQ [3], concat_dir [4], data_chk [1], data_chk [2]
	file_exist [1], file_exist [3], get_logenv [1], get_logenv [2], is_member [1]
	is_member [2], make_into_bytarr, rd_tfile [1], rd_tfile [2], rd_ulin_col
	str_replace [1], str_replace [2], strmids [1], strmids [2], strspecial [1]
	strspecial [2]
 CALLED BY:
	gtt_info, read_trace, tr_rd_index
   History:
      14-Jan-1998 - S.L.Freeland
      TODO - break out generic sections, how to scalarize properly?, $
             parameters ->p1 , p2 in call? p1='ph', p2='be'
      25-Jan-1998 - S.L.Freeland - add some error traps
      30-Jan-1998 - S.L.Freeland - permit non-structure output
                           via keyword inheritance ( /TAGNAME )
	30-Jan-1998- M.D.Morrison - Added "dph" input parameter
	19-Feb-1998- M.D.Morrison - Added common block to not re-read database
				    file more than once
				  - Added /NONONE option
	24-Feb-1998- M.D.Morrison - Corrected case where database had the key
				    in uppercase and we're asking for all keys
       25-Feb-1998 - S.L.Freeland - look for 'trace_loud'
	26-Feb-1998 - M.D.Morrison - Added debug statements
				   - Disabled passing a tag list filename by "taglist"
        2-Mar-1998 - S.L.Freeland - add TAGFILE (replace feature MDM removed)
        4-Mar-1998 - S.L.Freeland - add ALPHABETIZE, make default=dbase tag order
       19-Mar-1998 - S.L.Freeland - check for variable references in
                                    EXECUTIVE commands when /nostruct set
       23-Apr-1998 - S.L.Freeland - revisit 19-mar change
       17-Jun-1998 - S.L.Freeland - add /swap_lendian in make_into_bytarr call
       10-Sep-1998 - S.L.Freeland - use $trace_key_db for header if defined
       11-Jul-2000 - S.L.Freeland - avoid scalarizing dp_header
                                    (#images eq #words dp_header...)


trace_dph2struct [2] $SSW/trace/idl/util/trace_dph2struct2.pro
[Previous] [Next]
   Name: trace_dph2struct

   Purpose: extract/convert info from trace dpheader -> IDL structure
  
   Input Parameters:
      ph - primary header from TRACE fits file
      be - binary extension header (includes dph field)
  
   Output:
      Function outputs vector of structures with specify tags filled
      -OR- if /KEYWORD, return vector of associated TAG/KEY (non-structure)  

   Keyword Parameters:
       taglist - optional taglist to include/convert (def=all in dbase)
                (array, comma delimited string or ascii file with tags)
       strtemplate - optional pre-made structure to use (implies TAGLIST)
       head_db - name of header dbase file to use 
      
      quiet/loud - switches to determine noise level of routine
      XXX - if  keyword passed as a switch - output non-structure
            (just specified tag contents)
      no_struct - (switch) - if set, return value, not structure
                             (first element in taglist only)
      nonone - If set, then don't do the ".NONE" database definition executions
      alphabetize - If set, alphabetize tags (default is dbase order)

   Calling Sequence:
      outstr=trace_dph2struct(ph, be [,taglist=taglist , $
                                     strtemplate=strtemplate  $
                                      , head_db=head_db , /loud]
      -OR-
      outval=trace_dph2struct(ph, be , /XXXX) ; extract only specified tag  

      outval=trace_dph2struct(ph, be, taglist='XXXX',/no_struct) ; equivilent

   Calling Examples:
      outstr=trace_dph2struct(ph, be) ; map all tags in tag dbase->structure
      outval=trace_dph2struct(ph, be, /date_obs) ; only DATE_OBS (strarr in this case)

   Notes:
	Speed test is:
		tr_rd_index, '18-Feb-98', '18-Feb-98 2:00', index0		;361 images
		idl_speed & for i=1,1 do index = trace_dph2struct(ph, index0, index0.dp_header) & idl_speed,1

		   Jan-98 	16-18 sec
		19-Feb-98 	7 sec	(pass time to LUT, not do .NONE on gtt_info calls to dph2struct)
 CALLED BY:
	gtt_info, read_trace, tr_rd_index
   History:
      14-Jan-1998 - S.L.Freeland
      TODO - break out generic sections, how to scalarize properly?, $
             parameters ->p1 , p2 in call? p1='ph', p2='be'
      25-Jan-1998 - S.L.Freeland - add some error traps
      30-Jan-1998 - S.L.Freeland - permit non-structure output
                           via keyword inheritance ( /TAGNAME )
	30-Jan-1998- M.D.Morrison - Added "dph" input parameter
	19-Feb-1998- M.D.Morrison - Added common block to not re-read database
				    file more than once
				  - Added /NONONE option
	24-Feb-1998- M.D.Morrison - Corrected case where database had the key
				    in uppercase and we're asking for all keys
       25-Feb-1998 - S.L.Freeland - look for 'trace_loud'
	26-Feb-1998 - M.D.Morrison - Added debug statements
				   - Disabled passing a tag list filename by "taglist"
        2-Mar-1998 - S.L.Freeland - add TAGFILE (replace feature MDM removed)
        4-Mar-1998 - S.L.Freeland - add ALPHABETIZE, make default=dbase tag order
       19-Mar-1998 - S.L.Freeland - check for variable references in
                                    EXECUTIVE commands when /nostruct set
       23-Apr-1998 - S.L.Freeland - revisit 19-mar change
       17-Jun-1998 - S.L.Freeland - add /swap_lendian in make_into_bytarr call
       10-Sep-1998 - S.L.Freeland - use $trace_key_db for header if defined
       11-Jul-2000 - S.L.Freeland - avoid scalarizing dp_header
                                    (#images eq #words dp_header...)


trace_euv_resp [1] $SSW/trace/idl/info/trace_euv_resp.pro
[Previous] [Next]
 
             NAME : trace_euv_resp
 
          PURPOSE : Returns the TRACE response for the 171, 195, or
                    284 channels.

 CALLING SEQUENCE : eps = trace_euv_resp(band,filter,lambda=lambda)
 
           INPUTS : band   - 171, 195, or 284 (173 also works)
                    filter - OO, AO, OA, or AA - optional, default is AO
 
  OPTIONAL INPUTS : lambda - the wavelength scale. if this is not
                    input then the response function is interpolated
                    to the default wavelength scale.
 
         KEYWORDS : show_plot - displays the response in a new window.

                    silent - supress text output.

                    select - allow user to select response file.
 
                    amp_b  - If set, use amplifier 'b' (42 e/sec)
                           (Default is amp 'a', 11 e/sec)
 
          OUTPUTS : The TRACE response as a function of wavelength in
                    units of DN/s/pixel per ph/cm^2/s/sr. Thus
                    convolving the TRACE response function with a
                    solar spectrum will yield the expected TRACE
                    count rates.

 OPTIONAL OUTPUTS : the default wavelength scale

 CALLS: ***
	BOX_MESSAGE, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], DATATYPE [1]
	DATATYPE [2], DATATYPE [3], FILE_EXIST [2], INTERPOL, PAUSE [1], RD_GENX
	TRACE_EUV_RESP_OLD, TRIM, WDEF [1], WDEF [2], XDOC, break_file [4], file_exist [1]
	file_exist [3], file_list [1], file_list [2], last_nelem, pause [2]
 CALLED BY:
	moffat2d, trace_psf_isothermal
    COMMON BLOCKS : none
 
          EXAMPLE : IDL> eps = trace_euv_resp('171',lambda=lambda,/show)
                    IDL> cnts = int_tabulated(lambda,eps*spectrum)

    SPECIAL CALLS : none

          WRITTEN : HPW 21-JUL-1998 email to hwarren@cfa.harvard.edu
                    Based on earlier code by J. Newmark, E. DeLuca,
                    R. McMullen, and K. Shrivjer.

         MODIFIED : HPW 02-APR-1999 Modified to use updated filter
                    transmission and ccd quantum efficency data.

                  : HPW 09-APR-1999 Modified methods for selecting
                    input file.

                  : BNH 21-APR-1999 Added amplifier 'B'.
                    used WDEF in lieu of 'window' cmd.
 


trace_euv_resp [2] $SSW/trace/idl/info/trace_euv_resp_old.pro
[Previous] [Next]
 
             NAME : trace_euv_resp
 
          PURPOSE : Returns the TRACE response for the 171, 195, or
                    284 channels.

 CALLING SEQUENCE : eps = trace_euv_resp(band,filter,input_wave=wave)
 
           INPUTS : band   - 171, 195, or 284
                    filter - OO, AO, OA, or AA - optional, default is AO
 
  OPTIONAL INPUTS : input_wave - the wavelength scale. if this is not
                    input then the response function is interpolated
                    to a default wavelength scale.
 
         KEYWORDS : show_plot - displays the response in a new window.
 
          OUTPUTS : The TRACE response as a function of wavelength in
                    units of DN/s/pixel per ph/cm^2/s/sr. Thus
                    convolving the TRACE response function with a
                    solar spectrum will yeild the count rate.

 OPTIONAL OUTPUTS : the default wavelength scale

 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], INTERPOL, PAUSE [1]
	RD_GENX, TRACE_EUV_RESP_OLD, TRIM, concat_dir [4], pause [2]
 CALLED BY:
	moffat2d, trace_psf_isothermal
    COMMON BLOCKS : none
 
          EXAMPLE : eps = trace_euv_resp(171,input_wave=wave)

    SPECIAL CALLS : Reads the file "trace_euv_resp.genx"

          WRITTEN : HPW 21-JUL-1998 based on earlier code by
                    J. Newmark, E. DeLuca, R. McMullen, and
                    K.Shrivjer.

         MODIFIED : HPW 12-APR-1999 renamed trace_euv_resp_old, the
                    new version of this program reads files with a
                    different format.
 


trace_file2path $SSW/trace/idl/info/trace_file2path.pro
[Previous] [Next]

    Purpose: derive full pathname to trace file

    Output:
       function returns full path to input files
  
    Input Parameters:
      inputs - list of files, with or without paths

    Output Parameters:
      online - boolean, =1 if files actually online
  
    Calling Sequence:
       filenames=trace_file2path(filelist [,online] )
  
    Calling Examples:
       IDL> print,trace_file2path('tri19980515.0000',online)

       hosts/vestige/archive/sci/trace/tri/week19980510/tri19980515.0000  
       | -------- $TRACE_I1_DIR ---------|-- weekid ---|--- filename ---|
  
       IDL> print,online    ; actually online locally?
          1                 ; yes in this case
  
    Method:
       check current, if not found, construct standard path inc, 'week...'
    
 CALLED BY:
	READ_ANALIST, trace_success_file
    Restrictions:
      Unless files in current directory, assume $TRACE_I1_DIR is parent
      In a given call, cannot have mixed locations
      (for ex: PWD and $TRACE_I1_DIR/week.../xxx)

   History:
      21-May-1998 - S.L.Freeland  
       5-sep-1998 - S.L.Freeland - dont dupliate path...
       8-Sep-1998 - S.L.Freeland - handle not online case properly

   Calls: ***
	BOX_MESSAGE, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1]
	CONCAT_DIR [2], CONCAT_DIR [3], FILE2TIME, FILE_EXIST [2], anytim2weekinfo
	break_file [4], concat_dir [4], curdir [1], curdir [2], file_exist [1]
	file_exist [3], get_logenv [1], get_logenv [2]


trace_files $SSW/trace/idl/info/trace_files.pro
[Previous] [Next]
   Name: trace_files

   Purpose: return trace reformatted file names between t0 and t1

   Input Parameters:
      t0 , t1 - start and stop times 

   Calling Sequence:
      filelist=trace_files(t0, t1 [,weeks=weeks, prefix='txx'] )

   Keyword Parameters:
      weeks  - asscociated weekly directories
      prefix - prefix to check (default = 'tri')
               (others /tma, /tmr, /synop, /stra)
       
   Calling Examples:
      reffiles   =trace_files('1-jun','2-jun 12:30')
      mosaicfiles=trace_files('2-jul-1998','7-jul-1998',prefix='tmr')
      synop=trace_files('15-aug',wave=195,/synop)   ; assembled 1024x1024
  
 CALLED BY:
	TRACE_SSWHERE [1], VIEW_TRACE_MOSAIC, plot_fov [1], trace_make_tma
	trace_movie_context, trace_sswhere [2], trace_sswhere [3], trace_sswhere [4]
	trace_write_genxcat
   History:
      26-March-1998 - S.L.Freeland - (based on eit_files, cds_files, etc)
      16-April-1998 - S.L.Freeland - optimized time selection
       8-July-1998  - S.L.Freeland - add PREFIX keyword and function
      13-July-1998  - S.L.Freeland - allow PREFIX via keyword inherit
      22-July-1998  - S.L.Freeland - add WAVE_LENGTH and /QUICKLOOK
      23-July-1998  - S.L.Freeland - if only one time, get closest
      28-Aug-1998   - S.L.Freeland - allow comma list for TRACE_I1_DIR
       5-Oct-1998   - S.L.Freeland - add SYNOP/STRA  switches
      29-Jan-1999   - S.L.Freeland - look for $SYNOP_DATA/trace if
                                     $tdb/mosaics/fits not found
                                     Merge another offline change
       1-mar-1999   - S.L.Freeland - correct minor flaw in backup logic
       8-mar-1999   - S.L.Freeland - fixed bug introduced 1-march
      13-Jul-2000   - R.D.Bentley  - corrected format of message about week dirs.
  
 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE2TIME
	FILE_EXIST [2], STR2ARR [1], STR2ARR [2], TIME2FILE, UNIQ [1], UNIQ [2], UNIQ [3]
	anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], anytim2weekinfo
	concat_dir [4], data_chk [1], data_chk [2], extract_fid, file_exist [1]
	file_exist [3], file_list [1], file_list [2], get_logenv [1], get_logenv [2]
	str_perm, str_replace [1], str_replace [2], strmids [1], strmids [2], tim2dset [1]
	tim2dset [2], timegrid
   Restrictions:
      parent directory $TRACE_I1_DIR must be defined ('tri' parent)
      (and '$tdb' OR $SYNOP_DATA/trace for SYNOP/STR)


trace_get1www_image $SSW/trace/idl/wwwidl/trace_get1www_image.pro
[Previous] [Next]
   Name: trace_get1www_image

   Purpose: satisfy single image requests in 'near real time'  

   Input Parameters:
      file_dset - xxxxxYYYYMMDD.HHMM_NNNN   (YYYYMMDD.HHMM=>hourly file)
                                                      NNNN=>image# )
 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE2TIME
	FILE_EXIST [2], STR2ARR [1], STR2ARR [2], TRACE_COLORS, anytim2weekinfo
	concat_dir [4], file_append [1], file_append [2], file_exist [1], file_exist [3]
	file_size [1], file_size [2], get_logenv [1], get_logenv [2], gt_tagval [1]
	gt_tagval [2], html_doc, http_names, is_number [1], is_number [2], mkthumb
	read_trace, str2cols [1], str2cols [2], strsplit, strtab2html, tr_head_info
	write_trace
   Side Effects:
      Flat FITS file written to: $path_http/img_client  

   History:
	Written by S.L.Freeland Circa 5-May-1998 
	13-May-98 (FZ)  - Changed from color to black & white
       18-May-98  S.L.Freeland


trace_get_vignette $SSW/trace/idl/util/trace_get_vignette.pro
[Previous] [Next]
   Name: trace_get_vignette

   Purpose: get quadrant/wavelength dependent vignette data&mask

   Input Parameters:
      index - trace index or catalog structure(s) -OR- wavelength(s)

   Output Parameters:
      vmask - the vignette mask
      vdata - summed data used for mask determination

   Keyword Parameters:
      vindex - (output) - the index records included in summed image(vdata)
      normalization - (switch) - if set, vmask out is normalization mask
                                 *** normalization not yet implemented ***

   Calling Sequence:
      IDL> trace_get_vignette, input, vmask [,vdata] [,vindex=vindex]

   Calling Examples:
      IDL> trace_get_vignette, 171, v171mask               ; mask for 171
      IDL> trace_get_vignette, [195,284,1600],vmasks,vdata ; vect in, 3D out  
      IDL>

   History:
      13-October-2000 - S.L.Freeland 

 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], CONCAT_STRUCT
	DELVARX [1], DELVARX [2], DELVARX [3], DELVARX [4], FILE_EXIST [2], UNIQ [1]
	UNIQ [2], UNIQ [3], anytim [1], anytim [2], anytim [3], anytim [4], anytim [5]
	concat_dir [4], data_chk [1], data_chk [2], delvarx [5], file_exist [1]
	file_exist [3], file_list [1], file_list [2], gt_tagval [1], gt_tagval [2]
	required_tags, restgenx, str2number [1], str2number [2]
   Restrictions:
      vmask is currently boolean; TODO: optionally make it a normalization mask
      Currently only one mask per quadrant/wave available - index/structure
      input has advantage over wavelength only if/when time dependent 
      masks are online

      For vector input (index/waves), output VMASK and optional VDATA
      are 3D (1024,1024,#index) so beware of "too large" output 


trace_goodobs $SSW/trace/idl/info/trace_goodobs.pro
[Previous] [Next]
   Name: trace_goodobs

   Purpose: return time ranges of 'good' TRACE observing times

   Input Parameters:
      int0 [,int1] - desired time or time range (if only one time, assume 24 hours)

   Output Parameters:
      gt0 - start times of valid observing ranges
      gt1 - stop  times of valid observing ranges
      dtmin - number of minutes in each observing range

   Keyword Parameters:
      nosaa - if set, exclude TRACE SAA
      nohlz - if set, exclude TRACE HLZ
      noatm - if set, exclude TRACE atmospheric absoption times
      sxt_nosaa - if set, exclude SXT SAA times
      sxt_day -   if set, include only SXT day times
      sxt_visible - if set, only include visible orbit time range 
      badobs - if set, invert sense (return bad ranges)
      min_duration - minimum observing window in minutes (def=5 minutes)
      out_style - output time format for gt0 and gt1 vectors
                  (see antyim.pro for OUT_STYLE options, default='ECS')  
      nvalid (OUTPUT) - number of valid observing ranges returned
  
   Calling Sequence:
      IDL> trace_goodobs,startT,stopT [,obsstartT,obsstopT,dTmin,] $
              [,/loud,/nosaa,/nohlz,/noatm,/sxt_day,/sxt_nosaa] [,/badobs]  

   Calling Examples:
      Following example returns observing times within Yohkoh/SXT day
         excluding all Yohkoh and TRACE SAAs - only consider observing
         windows >= 30 minutes; print result to tty
  
      IDL> trace_goodobs,'27-oct-1999','28-oct-1999',/sxt_day,/sxt_nosaa,$
                         /nosaa,min_duration=30,/loud
                   
   History:
      27-October-1999 - S.L.Freeland - simplify inter-ssw fem conflicts checking
      28-October-1999 - few tweaks,  documentation
  
 CALLS: ***
	BOX_MESSAGE, STR2ARR [1], STR2ARR [2], anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], deriv_arr [1], deriv_arr [2], ssw_deltat, strjustify
	tim2orbit [1], tim2orbit [2], timegrid
   Restrictions:
      sxt_visible not yet implemented...
      must include at least 'sxt' and 'trace' in SSW inst. list ($SSW_INSTR)
      TRACE and SXT ephemeris online ($SSWDB: ../tdb/fdss  ..ydb/fem)


trace_idlcat $SSW/trace/idl/wwwidl/trace_idlcat.pro
[Previous] [Next]
   Name: trace_idlcat

   Purpose: WWW interface to trace catalog search utilities(IDL)

   Keyword Parameters:
      qfile - WWW Post Query filename  
  
   History:
      2-Feb-1998 - S.L.Freeland 
     21-Apr-1998 - S.L.Freeland - use the real TRACE catalog
     24-Apr-1998 - S.L.Freeland - add some pointing XCEN/YCEN
      8-May-1998 - (FZ)  Removed link from itable header
     17-May-1998 - S.L.Freeland - add MERGE_LIST and RANGE_LIST to
                   <form_qstr_valid> call   
     19-May-1998 - S.L.Freeland - added OLIMIT and cgi hook to order FORM
     26-May-1998 - S.L.Freeland - add some informational HTML
     11-Jun-1998 - S.L.Freeland - Flag bad JPEG decodes & inhibit hyperlinks
                                  (NX=NY=1)

     20-Jan-1999 - S.L.Freeland - add PERCENTD (data qual) to output list
     29-Jan-1999 - S.L.Freeland - expanded jpeg size
     29-Feb-2000 - S.L.Freeland - disable common, limit time range


trace_index2macrofov $SSW/trace/idl/util/trace_index2macrofov.pro
[Previous] [Next]
   Name: trace_index2macrofov

   Purpose: return 'macropixel' location  from xcen/ycen

 CALLS: ***
	BOX_MESSAGE, FSTRING, RETVAL, data_chk [1], data_chk [2], required_tags
 CALLED BY:
	trace_uniq_movies
   History:
      6-May-1998 - S.L.Freeland - help automate related image/movie set ID

   Input Parameters:
        index - index or catalog records (assume contain XCEN/YCEN in ")

   Output:
      Function returns string of form [N/S]XX_[E/W]XX
        where: XX in arcmin  
  
   Keyword Parameters:
      macroamin - size of 'macro pixel' in arcminutes  (default=2')
      macroasec - size of 'marco pixel' in arcseconds  (default=120")
      stringx   - output is string of form NSXX_EWXX , XX in arcmin
                  (positive NORTH and WEST)


TRACE_INVERT_DIFFPATT $SSW/trace/idl/util/trace_invert_diffpatt.pro
[Previous] [Next]

function trace_invert_diffpatt,image,psfin,iindex, quiet=quiet, sigma=sigma, satpattern=dpss

NAME:
     TRACE_INVERT_DIFFPATT
PURPOSE:
     Make a crude estimate of the TRACE intensities from the diffraction
     pattern to correct areas of saturation. 
CATEGORY:
CALLING SEQUENCE:
     newimage = trace_invert_diffpatt(image,psf,ss)
INPUTS:
     image = image to be corrected
     psf = PSF for the diffraction pattern centered on floor(nx/2),floor(ny/2)
     ss = indices in image to be corrected (usually indices of saturated
          pixels) 
OPTIONAL INPUT PARAMETERS:
KEYWORD PARAMETERS
     /quiet = no output
     sigma = outputs with a crude error estimate at the corrected locations
     satpattern = returns with indices of the pixels affected by the
                  saturated diffraction pattern.
OUTPUTS:
     newimage = corrected image
 CALLS: ***
	FFTCONVOL, STDDEV
 CALLED BY:
	TRACE_UNDIFFRACT
COMMON BLOCKS:
SIDE EFFECTS:
RESTRICTIONS:
PROCEDURE:
MODIFICATION HISTORY:
     2000-March-04  T. Metcalf
     2000-March-31  T. Metcalf  Changed the way the background pixels are
                                determined.  Pixels expected to contain the
                                diffraction pattern are specifically not
                                included in the background average.
     2002-Oct-25    T. Metcalf  Added satpattern keyword


trace_isorbevt $SSW/trace/idl/info/trace_isorbevt.pro
[Previous] [Next]
   Name: trace_isorbevt

   Purpose: return boolean map or SS which match desired event

   Input Parameters:
      structures - vector of trace header or catalog structures to check

   Ouptut:
      function returns boolean map -OR- SS vector of sucesses if /SSWHERE set

   Output Paramters:
      count - number of matches

   Calling Sequence:
      boolmap=trace_isorbevt(index, /ascending, /perigee, /midpoint)

 CALLS: ***
	BOX_MESSAGE, TRACE_GETORBEVT, TRACE_ORBEVT2TIME, tim2dset [1], tim2dset [2]
	time_window
   Restrictions: (due to first limited use project)
      prototype - /ascend currently implies midpoint(ascend/perigee)  +/- minutes
                  /descend currently implies midpoint(descend/apogee) +/- minutes
      let me know if you are using this and I will rationalize the keywords...
  


TRACE_ISOTHERMAL $SSW/trace/idl/util/trace_isothermal.pro
[Previous] [Next]
NAME:
	TRACE_ISOTHERMAL
PURPOSE:
	Create temperature and emission measure maps from TRACE EUV images,
	assuming an isothermal plasma along the line of sight for each pixel.
CALLING SEQUENCE:
	trace_isothermal, index, data [, Tmap=Tmap, em=em, chisq=chisq]
 CALLS: ***
	TRACE_T2EM
MODIFICATION HISTORY:
	C. Kankelborg, Sept-24-1998


trace_jpeg_dbase $SSW/trace/idl/info/trace_jpeg_dbase.pro
[Previous] [Next]
NAME:
	trace_jpeg_dbase

PURPOSE:
	Return TRACE jpeg dbase info required by Shine executable

SAMPLE CALLING SEQUENCE:
	trace_jpeg_dbase, bin_header , hfile, qfile

INPUT:
	bin_header - trace binary image header structure (inc/ dp_header tag)
                    OR dp_header (assumed 505 elements)

OUTPUT:
       hfile, qfile - jpeg data base files (huffman code, quality code)  

 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], concat_dir [4]
	data_chk [1], data_chk [2], gt_tagval [1], gt_tagval [2]
 CALLED BY:
	trace_decode_idl PLEASE USE trace_jpeg_decomp, trace_jpeg_decomp
HISTORY:
	Written 4-Nov-1997 - S.L.Freeland (info from MDM rd_trace_jpeg.pro)
              26-nov-1997 - S.L.Freeland (permit dp_header directly)


trace_jpeg_decomp $SSW/trace/idl/info/trace_jpeg_decomp.pro
[Previous] [Next]
   Name: trace_jpeg_decomp

   Purpose: decompress a 'TRACE' jpeg stream (call RShine C routine)

   Input Parameters:  
      index       - structure defining image/stream (w/tag = dp_header)
                    OR trace dp_header  
      jpeg_stream - stream 

   Keyword Parameters:
      huffman - huffman table to use (default derived from DP header)
      qt      - quant. talbe default derived from DP header)
      nx      - (output) NX size of decoded image  
      ny      - (output) NY size of decoded image  
      current - (switch) if set, use copy of Shared object in current direct.
      ssw     - (switch) if set, force use of SSW shared version (DEFAULT)
      debug   - (switch) if set, stop before and after call_external call
      temp    - (switch) if set, work on temporary copy of jpeg stream
  
 CALLS: ***
	BOX_MESSAGE, CALL_EXTERNAL_INFO, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3]
	DELVARX [1], DELVARX [2], DELVARX [3], DELVARX [4], FILE_EXIST [2], concat_dir [4]
	curdir [1], curdir [2], delvarx [5], file_exist [1], file_exist [3]
	get_logenv [1], get_logenv [2], gt_tagval [1], gt_tagval [2], str_replace [1]
	str_replace [2], trace_jpeg_dbase
 CALLED BY:
	mxf_decomp_data, tr_build_img [1]
   History:
      26-Nov-1997 -  S.L.Freeland / Richard Shine
       2-dec-1997 -  S.L.Freeland - add NX, NY, made temporary copy , reform within IDL
                     made it SSW transportable - rename to 'trace_jpeg_decomp'
  
       4-dec-1997 -  S.L.Freeland -  add /CURRENT (testing)
                     review after c change - nx/ny protect
                     eliminate old testing dir referces
	15-dec-1997 - S.L.Freeland - remove some diagnostics, add /TEMP switch
                     only use temporary copy on request
        7-May-1999 - S.L.Freeland - avoid addressing 'decoded stream' if
                     bad decode status is returned by shared object
	 5_Oct-1999 - R.W.Nightingale - double 'decoded_stream' array length 
        17-Jan-2000 - S.L  Freeland - Made default quieter
        10-Feb-2000 - S.L. Freeland - Added version dependent SO name
                      (sgi/idl V5.3 uses different compiler options     
        15-Mar-2003 - H.P.Warren - pass IDL Release to dcompressor
         8-Apr-2003 - S.L.Freeland - use $SSW_TRACE/binaries/.. for "new" 
                      decompressor (which accepts release) - attempt to make
                      this backwardly compatible and independent of $SSW_BINARIES
                      branch upgrade (which may occur asyncronously w/resp to trace)
        10-Nov-2003 - S.L.Freeland - try to rationalize the OS/ARCH -and-
                      RSI Release dependcies; goal is backward and forward
                      compatibility, but let me know.... 
                      (still many OS not represented yet, such as WinXX, MacOS
  
   Method: 
      Set up and call R. Shine C routine 'trace_decode_idl' via 'call_external'

      TODO - optimize 


trace_knoise $SSW/trace/idl/util/trace_knoise.pro
[Previous] [Next]
NAME:
	trace_knoise
PURPOSE:
	Remove readout noise from TRACE images by
	identifying and zeroing spikes in the FFT.
	Supersedes trace_rnoise. Although developed
	for TRACE, The algorithm is completely 
	generic. It runs fairly well with default
	parameters on a broad range of compressed
	and uncompressed images.
CALLING SEQUENCE:
	result = trace_knoise(image)
INPUTS:
	image = TRACE image array
OUTPUTS:
	result = image minus readout noise.
KEYWORDS:
	nsigma = number of standard deviations
		beyond which an FFT pixel is
		considered bad. Default is 6.
	mask_size = size of neighborhood around
		k=0 which is not filtered.
		Default is 40.
	edge_pix = width in pixels of a border around
		the FFT that is not to be modified. The
		rationale is that typically, there is
		considerable power in the edges of the 
		FFT of a rectangular image. Default = 3.
 CALLS: ***
	DIST, LOGSCALE, MOMENT, XTV
 CALLED BY:
	TRACE_PREP
		NOTE: Against convention, IDL orients the
		FFT with low frequencies in the corners.
		That's why highest power is along 'edges'!
	debug = if set, give verbose diagnostic output.
	Niterations = number of times to filter the FFT.
		It is MUCH faster and more precise to use
		Niterations than to run trace_knoise several 
		times.
PROCEDURE:
	The amplitude spectrum abs(fft(image)) is broken
	down into rings of nearly constant k. The
	population in each ring is analyzed, and pixels
	that are more than NSIGMA standard deviations
	above the mean are considered "bad". Corresponding
	pixels are zeroed in the FFT, and the reverse 
	transform is performed. For finer points, see 
	the list of keywords above.
MODIFICATION HISTORY:
	C. Kankelborg 11-Sep-1998
	CCK 2-Aug-2000 added Niterations feature


trace_last_movie [1] $SSW/trace/idl/util/trace_last_movie.pro
[Previous] [Next]
   Name: trace_last_movie

   Purpose: recent TRACE movies -> WWW  

   Keyword Parameters:
      minframes - ignore movies with fewer than this many frames
      maxframes - upper limit number of frames per movie
      outsize   - output size for each movie frame
      prepit  - switch, if set, run data through trace_prep
      _EXTRA  - special_movie / image2movie keywords via inheritance
      grid    - if set, than grid MAXFRAMES over interval
                (default is last MAXFRAMES images)
      last_nhours - most recent N hours to consider (default=24)
      percentd - frame quality threshold (default=100%) 
      queue_days - number of days saved (passed to trace_last_movie_queue)
   History:
      25-April-1998 - S.L.Freeland - apply some SSW movie techniques->TRACE  
      12-Jun-1998   - S.L.Freeland - call 'trace_data_filter' to remove
                      radiation contaminated/other bad data  
      17-Jul-1998   - S.L.Freeland - filter out movies < 512x512 (dosimiter)
      16-Sep-1998   - Add /GRID, change default outsize to 320 (mpeg compat)
                      Add LAST_NHOURS and PERCENTD keywords and function
      22-Sep-1998   - keep genx log of movie frame info, add /TESTING keyword
      27-Sep-1998   - pass MDIR to trace_movie_index
      14-Apr-1998   - S.L.Freeland - fix typo in OUTSIZE initialize

   Method:
      use trace_cat - loop through 'special_movie' for each
                      uniq movie dset - organize submovies by OBS_PROG

   Calls: ***
	ADD_TAG [1], ADD_TAG [2], AVERAGE, BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FMT_TIMER [1], FMT_TIMER [2], TRACESCALE, TRACE_COLORS, TRACE_PREP
	UNIQ [1], UNIQ [2], UNIQ [3], concat_dir [4], data_chk [1], data_chk [2]
	file_append [1], file_append [2], get_logenv [1], get_logenv [2], grid_data [1]
	grid_data [2], gt_tagval [1], gt_tagval [2], html_doc, is_number [1]
	is_number [2], last_nelem, read_trace, savegen [1], savegen [2], set_logenv [1]
	set_logenv [2], special_movie, str_replace [1], str_replace [2], trace_cat2data
	trace_data_filter, trace_last_movie_queue, trace_movie_index [1]
	trace_movie_index [2], trace_uniq_movies


trace_last_movie [2] $SSW/trace/idl/util/trace_last_umovie.pro
[Previous] [Next]
   Name: trace_last_movie

   Purpose: recent TRACE movies -> WWW  

   Keyword Parameters:
      minframes - ignore movies with fewer than this many frames
      maxframes - upper limit number of frames per movie
      outsize   - output size for each movie frame
      prepit  - switch, if set, run data through trace_prep
      _EXTRA  - special_movie / image2movie keywords via inheritance

   History:
      25-April-1998 - S.L.Freeland - apply some SSW movie techniques->TRACE  

   Method:
      use trace_cat - loop through 'special_movie' for each
                      uniq movie dset - organize submovies by OBS_PROG

   Calls:
	TODO:, add the FOV discrimiator (via trace_uniq_movies.pro mod)
	file_append [1], file_append [2], get_logenv [1], get_logenv [2], html_doc
	read_trace, set_logenv [1], set_logenv [2], special_movie (image2movie)
	ssw_ct2rgb, the usual suspects, trace_cat, trace_cat2data, trace_uniq_movies


trace_last_movie [3] $SSW/trace/idl/wwwidl/trace_last_movie.pro
[Previous] [Next]
   Name: trace_last_movie

   Purpose: recent TRACE movies -> WWW  

   Keyword Parameters:
      minframes - ignore movies with fewer than this many frames
      maxframes - upper limit number of frames per movie
      outsize   - output size for each movie frame
      prepit  - switch, if set, run data through trace_prep
      _EXTRA  - special_movie / image2movie keywords via inheritance

   History:
      25-April-1998 - S.L.Freeland - apply some SSW movie techniques->TRACE  

   Method:
      use trace_cat - loop through 'special_movie' for each
                      uniq movie dset - organize submovies by OBS_PROG

   Calls: ***
	ADD_TAG [1], ADD_TAG [2], AVERAGE, BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], FMT_TIMER [1], FMT_TIMER [2], TRACESCALE, TRACE_COLORS, TRACE_PREP
	UNIQ [1], UNIQ [2], UNIQ [3], concat_dir [4], data_chk [1], data_chk [2]
	file_append [1], file_append [2], get_logenv [1], get_logenv [2], grid_data [1]
	grid_data [2], gt_tagval [1], gt_tagval [2], html_doc, is_number [1]
	is_number [2], last_nelem, read_trace, savegen [1], savegen [2], set_logenv [1]
	set_logenv [2], special_movie, str_replace [1], str_replace [2], trace_cat2data
	trace_data_filter, trace_last_movie_queue, trace_movie_index [1]
	trace_movie_index [2], trace_uniq_movies


trace_last_movie_queue $SSW/trace/idl/wwwidl/trace_last_movie_queue.pro
[Previous] [Next]
   Name: trace_last_movie_queue

   Purpose: maintain queue of TRACE NRT movie directories

 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2]
	TIME2FILE, TRACE_MOVIE_QKL_QUEUE, concat_dir [4], data_chk [1], data_chk [2]
	file_exist [1], file_exist [3], file_list [1], file_list [2], get_logenv [1]
	get_logenv [2], reltime [1], reltime [2]
 CALLED BY:
	trace_last_movie [1], trace_last_movie [3], trace_special_movie [1]
	trace_special_movie [2], trace_special_movie [3], trace_special_movie2
   History:
      Circa June 8, 1998 - S.L.Freeland -
      1-June-1999 - S.L.Freeland - allow mult dir/day , "offline"->"online"
          move last_movies  -> last_movies_yyyymmdd_hhmm
          move last_moviesx -> last_movies
      8-June-1999 - S.L.Freeland - add call to trace_movie_qkl_queue


TRACE_LIST_INDEX $SSW/trace/idl/info/trace_list_index.pro
[Previous] [Next]
 NAME:
       TRACE_LIST_INDEX
 PURPOSE:
       produces listing of TRACE index structure
 CATEGORY:
 CALLING SEQUENCE:
       more, trace_list_index(index)

 CALLED BY:
	TRACE_SSWHERE [1], plot_fov [1], trace_special_movie [1]
	trace_special_movie [2], trace_special_movie [3], trace_special_movie2
	trace_sswhere [2], trace_sswhere [3], trace_sswhere [4]
	Note: called from TRACE_SSWHERE and TRACE_SSWHERE_EVENT
 INPUTS:
	index	TRACE index, or catalog structure
 OPTIONAL INPUT PARAMETERS:
 KEYWORD PARAMETERS:
 OUTPUTS:
 OPTIONAL OUTPUT PARAMETERS:
 CALLS: ***
	fmt_tim [1], fmt_tim [2], gt_tagval [1], gt_tagval [2]
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
          Sep-98  RDB	Written
	30-Sep-98  RDB	Changed gt of /cdelt2 - no longer in catalog
	03-Nov-98  rdb	Also list value of tag .img_dev -> image deviation
	04-Dec-99  rdb  Added check for tags exptime and wavelnth if not found
                       (allows routine to work for SSW complient SXT index)


trace_make_tma $SSW/trace/idl/util/trace_make_tma.pro
[Previous] [Next]
   Name: trace_make_tma

   Purpose: generate the primary TRACE assembled mosaic data base ('tma' files)

   Input Parameters:
        
   Keyword Parameters:
      outdir - (input) if specified, write 'tma's there (default is->archive)
      force_overwrite - if set, update even if it already exists
      tmas_written (output) - list of new or updated tmrs 
      noprep - (switch) - if set, dont trace_prep the tmr data
      ss - optional subscripts of TMR to include (default is all)  
  
   History:
      13-Jul-1998 - S.L.Freeland (from trace_make_tmr.pro)
      25-Nov-1998 - T. Tarbell - use trace_prep to read tmr file
                               - traceunspike if EUV
      30-Nov-1998 - S.L.Freelad - add a history record (update_history.pro)
                                  made this Version 1.0
       1-Dec-1998 - S.L.Freeland - version 1.1 - correct tmr < 1.0
                    add /NOPREP and SS keywords

    Calls: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FILE_EXIST [2], REVERSE, TRACE_PREP
	anytim2weekinfo, concat_dir [4], data_chk [1], data_chk [2], delvarx [5]
	file_exist [1], file_exist [3], get_history, get_logenv [1], get_logenv [2]
	read_trace, str_replace [1], str_replace [2], trace_build_mosaic3, trace_files
	trace_unspike, update_history, write_trace


trace_make_tmr [1] $SSW/trace/idl/util/trace_make_tmr.pro
[Previous] [Next]
   Name: trace_make_tmr

   Purpose: generate the TRACE raw mosaic data base ('tmr' files)

   Input Parameters:
        
   Keyword Parameters:
      outdir - (input) if specified, write 'tmrs' there (default is->archive)
      force_overwrite - if set, update even if it already exists
      tmrs_written (output) - list of new or updated tmrs 
     
   History:
      7-Jul-1998 - S.L.Freeland
      1-Dec-1998 - S.L.Freeland - add history record, make this 1.0
  
    Calls: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], DELVARX [1]
	DELVARX [2], DELVARX [3], DELVARX [4], FILE_EXIST [2], LAST_TRACE2, STR2ARR [1]
	STR2ARR [2], anytim2weekinfo, concat_dir [4], delvarx [5], file_exist [1]
	file_exist [3], get_logenv [1], get_logenv [2], str_concat [1], str_concat [2]
	str_replace [1], str_replace [2], trace_struct2filename, update_history
	write_trace


trace_make_tmr [2] $SSW/trace/idl/util/trace_make_tsmr.pro
[Previous] [Next]
   Name: trace_make_tmr

   Purpose: generate the TRACE raw mosaic data base ('tmr' files)

   Input Parameters:
        
   Keyword Parameters:
      outdir - (input) if specified, write 'tmrs' there (default is->archive)
      force_overwrite - if set, update even if it already exists
      tmrs_written (output) - list of new or updated tmrs 
     
   History:
      7-Jul-1998 - S.L.Freeland
      1-Dec-1998 - S.L.Freeland - add history record, make this 1.0
     19-May-1998 - S.L.Freeland - added 1216 to default wave list
  
    Calls: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2]
	STR2ARR [1], STR2ARR [2], TRACE_FIND_MOSAIC, TRACE_MAKE_TSMR, anytim2weekinfo
	concat_dir [4], data_chk [1], data_chk [2], file_exist [1], file_exist [3]
	get_logenv [1], get_logenv [2], str_replace [1], str_replace [2]
	trace_struct2filename, update_history, write_trace


trace_make_tsma $SSW/trace/idl/util/trace_make_tsma.pro
[Previous] [Next]
   Name: trace_make_tsma

   Purpose: assemble small mosaics (whatever's in tsmr (mxf) file

   Input Parameters:
      tsmr - list of one or more component files
             (generated via trace_find_mosaic & trace_make_tsmr)

   Keyword Parameters:
      deripple, unspike - passed to 'trace_prep' (see header for description)
  
   History:
      10-November-1999 - S.L.Freeland - more generic version of make_tma

   Calls: ***
	BOX_MESSAGE, FILE2TIME, SSW_BUILD_MOSAIC, TRACE_PREP, get_infox, read_trace
	str_replace [1], str_replace [2], update_history, write_trace


trace_make_vignette $SSW/trace/idl/util/trace_make_vignette.pro
[Previous] [Next]
   Name:  trace_make_vignette

   Purpose: generate wave dependent vignette mask, optionaly save->dbase

   Input Parameters:
      time0/time1 - times to include     (required)
      wavelen - wave(s) to make          (default=171)

   Output Parameters:
      vdata - summed data
      vmask - boolean mask

   Keyword Parameters:
      index  - index records of 
      minimages - minimum #images to "accept"    (default=10)
      maximages - maximum #images to sum         (default=50)
      despike - optional despike - number of iterations (default=3)
      savedbase - if set, save data to database file 
      overwrite - if set, overwrite existing dbase file, if any
      outdir - optional output directory (def=$tdb/vignette)

  History:
   11-Oct-2000 - S.L.Freeland

 CALLS: ***
	AVERAGE, BOX_MESSAGE, CIR_MASK, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3]
	EXTRACT_ARR, FIND_LIMB, concat_dir [4], curdir [1], curdir [2], data_chk [1]
	data_chk [2], get_infox, grid_data [1], grid_data [2], gtt_orbit, last_nelem
	savegenx, struct_where, trace_cat, trace_cat2data, update_history
	write_access [1], write_access [2]
 Restrictions:
   currently mask is only a boolean mask
   TODO - make it a normalization mask


TRACE_MDI_ALIGN $SSW/trace/idl/util/trace_mdi_align.pro
[Previous] [Next]

function trace_mdi_align,tindex,tdata,mindex,mdata, $
                         trace_mask=rmaskin,mdi_mask=tmaskin, $
                         tmdi2traceguess=tmdi2traceguess, $
                         xvr=xvr,yvr=yvr,xvi=xvi,yvi=yvi, $
                         quiet=quiet,mdi2trace=mdi2trace, $
                         new_mdata=inew,new_tdata=rimage, $
                         blindguess=blindguess, xytrace=xytrace, $
                         eit=eit,noparallax=noparallax, debug=debug, $
                        _EXTRA=extra

NAME:
     TRACE_MDI_ALIGN
PURPOSE:
     Use an MDI white light image to fix the pointing in a TRACE
     white light image by assuming that the MDI pointing is correct.
CATEGORY:
CALLING SEQUENCE:
     new_trace_index = trace_mdi_align(tindex,tdata,mindex,mdata)
INPUTS:
     tindex  = TRACE index (a structure)
     tdata   = TRACE image
     mindex  = MDI index (a structure)
     mdata   = MDI image
OPTIONAL INPUT PARAMETERS:
KEYWORD PARAMETERS:
     trace_mask = Index giving points in the TRACE image to neglect in the
                  alignment.
     mdi_mask = Index giving points in the MDI image to neglect in the
                alignment.
     mdi2trace = the final transformation from the MDI image to the TRACE
                 image (output).  You probably don't really want this.
     new_tdata = the piece of the TRACE image used to do the alignment
                 (output).
     new_mdata = the piece of the MDI images transformed onto new_tdata
                 (output).
     /quiet = work quietly
     /eit = The data is from EIT not MDI.  This is not really a good
            idea since the EUV images change rapidly and since the
            parallax correction assumes the emission is
            photospheric.  But, if that's all you've got, use this
            keyword and be very careful with the result.  Pass the
            EIT data in as mindex and mdata.
     /noparallax = Do not include the parallax correction.  This is
                   only for debugging purposes, do not use this keyword.
     _extra = Any extra kewords are passed to auto_align_image.  E.g. scale,
             /amoeba, etc.

     INPUT PARAMETERS FOR THE INITIAL GUESS (NOT REQUIRED):

     These keywords allow you to avoid clicking on points in the two images
     which may be useful for automated alignments etc. 

     /blindguess = If set, use the alignment in the MDI and TRACE headers
                   to set the initial guess: do not ask the user to click
                   on points in the two images.  If this works, fine, but if
                   the guess is too far off, it is possible that
                   auto_align_images will fail.  If /blindguess is set, the
                   tmdi2trace and xvr, xvi etc. keywords are ignored (but
                   will be set on output).
     xytrace = 4 element array giving the LL and UR corners of a subregion
               to use in the alignment.  If this is not set, you will be
               asked to define the subregion with the mouse. [x0,x1,y0,y1]
               Ignored if /blindguess is not set.

     If the following are passed as input, they must all be passed in and they must
     all be consistent.  I.e., the transformation must apply to the subimages
     defined by xvr,yvr,xvi,yvi.  If they are not consistent, the answer you 
     get will be incorrect.  Garbage in, garbage out.  Be careful with these,
     getting them right can be a bit tricky!  If these are not set on input,
     they will be set on output so that they can be used for a subsequent call.

     tmdi2traceguess = Tranform vector (from caltrans.pro) giving the initial
                       guess for the alignment.  If this is not specified,
                       the user will be prompted to click on corresponding
                       points in the TRACE and MDI images in order to get
                       the initial guess.  If this is passed, xvr,yvr,xvi,yvi
                       must also be passed in.  If undefined, it will be
                       set on output to the guess from setpts_roi.
     xvr,yvr = 2 element arrays giving LL a UR corners of the TRACE subimage
               to use.  Ignored unless tmdi2traceguess is also passed.
               If undefined, it will be set on output to the guess from 
               setpts_roi.
     xvi,yvi = 2 element arrays giving LL a UR corners of the MDI subimage
               to use.  Ignored unless tmdi2traceguess is also passed.
               If undefined, it will be set on output to the guess from 
               setpts_roi.
OUTPUTS:
     new_trace_index = trace index with the pointing (i.e. .xcen and .ycen)
                       corrected.  .xcen,.ycen,.crval and .crpix  are the
                       only things changed in the new index.
 CALLS: ***
	AUTO_ALIGN_IMAGES, BILINEAR, CALTRANS, DELVARX [1], DELVARX [2], DELVARX [3]
	DELVARX [4], DIFF_ROT [1], DIFF_ROT [2], GET_FITS_PAR, GET_LATLON, GET_ORBIT [1]
	GET_ORBIT [2], LONLAT2XY, OCONTOUR2, PQ2RSS, PQ2XY, RSS2PQ, anytim [1], anytim [2]
	anytim [3], anytim [4], anytim [5], anytim2ints [1], anytim2ints [2], delvarx [5]
	get_rb0p [1], get_rb0p [2], int2secarr [1], int2secarr [2], setpts_roi, soho_fac
	wdefroi [1], wdefroi [2], wdefroi [3], wdefroi [4], xy2lonlat
COMMON BLOCKS:
SIDE EFFECTS:
RESTRICTIONS:
     VERY SLOW

     Obviously the TRACE and MDI images should be close in time to avoid
     evolution in the AR (but solar rotation and foreshortening are 
     accounted for).

     MDI pointing is assumed to be correct.
PROCEDURE:
     The user first gives an initial guess for the transformation between
     TRACE and MDI using setpts_roi and then the guess is refined using 
     auto_align_image.   The transformation is then used to set the pointing
     of TRACE assuming that the MDI pointing is correct.
EXAMPLE:
     ; First get the MDI data
     mdata  = readfits('Some_MDI_FITS_File',smdihead)
     mindex = fitshead2struct(smdihead)
     ; Second get the TRACE data
     trace_cat,some_start_time,some_end_time,cat
     ss = where(cat.wave_len EQ 'WL')
     trace_cat2data,cat[ss[0]],i,d
     trace_prep,i,d,tindex,tdata,/wave2point
     ; Third align the MDI and TRACE data
     tindex_new = trace_mdi_align(tindex,tdata,mindex,mdata)
MODIFICATION HISTORY:
     T. Metcalf 2001-Oct-17
     T. Metcalf 2001-Nov-14 Added a warning for a large coordinate shift.
     T. Metcalf 2001-Nov-15 Also update crpix1,crpix2,crval1,crval2 so that
                            the new index with the new pointing will work
                            with index2map and plot_map which gets pointing
                            from crpix and crval rather than xcen and ycen.
     T. Metcalf 2001-Nov-19 Added the /blindguess keyword.  Also mask
                            off-limb points.
     T. Metcalf 2002-Apr-04 Added correction for parallax in longitude
                            between the earth and SOHO points of view
                            (a small correction).  Parallax in latitude
                            was already accounted for.
     T. Metcalf 2002-Apr-23 Cleaned up code a bit.
     T. Metcalf 2002-Oct-22 Added /eit keyword and call to get_orbit
     T. Metcalf 2005-Jan-21 Account for SOHO roll angle.  I could
                            only test this with 0 and 180 degrees, so
                            I'm not entirely sure that I have the
                            sign of the angle right.
     T. Metcalf 2005-Jun-30 Changed sign of xsshift and syshift when
                            blindguess set.
     T. Metcalf 2006-Jul-28 If get_orbit fails to return the SOHO
                            orbital parameters, use the values from
                            the MDI header. 
     T. Metcalf 2006-Dec-07 Pass /synodic to diff_rot.pro.    


trace_movie_context $SSW/trace/idl/util/trace_movie_context.pro
[Previous] [Next]
   Name: trace_movie_context

   Purpose: generate a 'context' image for a movie sequence

   Input Parameters:
      structure - either catalog vector or index (of index,data pairings)
      data  - the data cube (if index,data input) - not if catalog passed

   Output:
      Function returns the context image (overlay, GOES LC...)

   Calling Sequence:
       IDL> img=trace_movie_context(catalog)
        -OR-
       IDL> img=trace_movie_context(index,data)
  
   Method:
      Use mapping SW for FOV overlay on FD image, optionally GOES/event

 CALLS:


trace_movie_index [1] $SSW/trace/idl/util/trace_movie_index.pro
[Previous] [Next]
  
   Name: trace_movie_index

   Purpose: generate an index page for trace movies from genx catalog

 CALLS: ***
	BOX_MESSAGE, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1]
	CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], FIND_IX, REVERSE, STR2ARR [1]
	STR2ARR [2], UNIQ [1], UNIQ [2], UNIQ [3], anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], break_file [4], concat_dir [4], data_chk [1], data_chk [2]
	file_append [1], file_append [2], file_exist [1], file_exist [3], file_list [1]
	file_list [2], get_infox, get_logenv [1], get_logenv [2], html_doc, restgenx
	set_logenv [1], set_logenv [2], ssw_deltat, str2html [1], str2html [2]
	str2html [3], strtab2html, time_window
 CALLED BY:
	trace_last_movie [1], trace_last_movie [3], trace_special_movie [1]
	trace_special_movie [2], trace_special_movie [3], trace_special_movie2
   History:
      Circa 1-jan-1999 - S.L.Freeland
            4-Jun-1999 - S.L.Freeland - major upgrade using genx catalogs


trace_movie_index [2] $SSW/trace/idl/wwwidl/trace_movie_index.pro
[Previous] [Next]
  
   Name: trace_movie_index

   Purpose: generate an index page for trace movies from genx catalog

 CALLS: ***
	BOX_MESSAGE, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1]
	CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], FIND_IX, REVERSE, STR2ARR [1]
	STR2ARR [2], UNIQ [1], UNIQ [2], UNIQ [3], anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], break_file [4], concat_dir [4], data_chk [1], data_chk [2]
	file_append [1], file_append [2], file_exist [1], file_exist [3], file_list [1]
	file_list [2], get_infox, get_logenv [1], get_logenv [2], html_doc, restgenx
	set_logenv [1], set_logenv [2], ssw_deltat, str2html [1], str2html [2]
	str2html [3], strtab2html, time_window
 CALLED BY:
	trace_last_movie [1], trace_last_movie [3], trace_special_movie [1]
	trace_special_movie [2], trace_special_movie [3], trace_special_movie2
   History:
      Circa 1-jan-1999 - S.L.Freeland
            4-Jun-1999 - S.L.Freeland - major upgrade using genx catalogs


trace_movies_prioritize [2] $SSW/trace/idl/wwwidl/trace_movies_prioritize.pro
[Previous] [Next]
   Name: trace_movies_prioritize
  
   Purpose: return priortized movie URLs 
  
   Input Parameters:
      NONE:

   Output:
      Function returns movie URLS, most->least priority

   Output Paramteres:
      mordered - movie info structures, most->least priority
  
   Keyword Parameters:

      wave_len  - one or more wavelenths (returns 1st matching)
      recent    -if set, timeliness is most important for given WAVE_LEN
      frequency - if set, frequency is most important param for WAVE_LEN  
      mcount (output) - number of movies matching criteria (zero if no match)
      javascript/gif_animate/mpeg - type of URL to return
      anchors (output) - corresponding top level html anchor point
                         associated with output urls

   Calling Sequence:
      urls=trace_movies_prioritize(wave_len='xxx' [,/frequency]  [,/recent] $
                                   [mcount=mcount],  $
                                   [,/javascript] [,/mpeg] [,/gif_animate]  

 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2]
	MATCH [1], MATCH [2], MATCH [3], REVERSE, STR2ARR [1], STR2ARR [2], concat_dir [4]
	data_chk [1], data_chk [2], file_exist [1], file_exist [3], get_logenv [1]
	get_logenv [2], gt_tagval [1], gt_tagval [2], restgenx, time_window
   History:
      10-May-2000 - S.L.Freeland - for auto WWW->display
      18-May-2000 - S.L.Freeland - add ANCHORS output 
      11-Oct-2005 - Zarro (L-3Com/GSFC) - expanded wavelength search


trace_newmoviedata $SSW/trace/idl/wwwidl/trace_newmoviedata.pro
[Previous] [Next]
   Name: trace_newmoviedata

   Purpose: boolean function - true if new data to proces

   Method:
      look at $TRACE_I1_DIR and $path_http/last_movies/*genx
      and call 'files_newer.pro' ($SSW/gen) 

   29-April-2000 - S.L.Freeland

 CALLS:


trace_orbevt $SSW/trace/idl/info/trace_getorbevt.pro
[Previous] [Next]
   Name: trace_orbevt

   Purpose:   return fdss/orbevt information

   Input Parameters:
      input0 - start time of range OR vector of structures to match
      input1 - (optional) - stop time of range
 CALLS:


trace_plate_scale $SSW/trace/idl/info/trace_plate_scale.pro
[Previous] [Next]
   Name: trace_plate_scale

   Purpose: return trace plate scale 

   History:
      24-November-1998 - S.L.Freeland - single point - permit future
                         tweaks for wave/focus, etc.  
  


TRACE_PREP $SSW/trace/idl/util/trace_prep.pro
[Previous] [Next]
 NAME:
	TRACE_PREP

 PURPOSE:
	Process  TRACE image(s).

	A preliminary version of a processing routine for preparing the
	TRACE image data for analysis.  The steps performed are:
		1. Read in raw FITS image(s) from a filelist and  
                    decompress the data and structure; 
		     or read in a datacube and structure
		2. Fill pixels of value = 0 with mean pixel value of entire 
	       	     image
		3. Replace near saturated pixels with values > 4095
		4. Subtract the dark pedestal (ADC offset) & current from each 
 		     image
	        5. Perform ccd gain calibration and lumogen degradation 
                    correction by dividing by time and wavelength dependent 
                    flat field 
		6. Options to remove radiation-belt/cosmic-ray spikes and 
 		     streaks
		7. Option to remove background diffraction pattern (ripple)
		8. Option to normalize each image for exposure
		9. Option to extract a subimage from each image
	       10. Output the corrected image(s) in an updated structure
		     and data cube, and optionally output a FITS file
		     with 1 or more images plus a binary extension or as
		     2D flat FITS files (1 per image)
	In the future this routine may also:
	       11. Instrument response normalization to physical units

 CATEGORY:
	FITS processing

 SAMPLE CALLING SEQUENCE:
       TRACE_PREP, input1, input2, [index_out, image_out] [,/outtrfits]
		    [,outdir=outdir] [,/normalize] [,darkdir=darkdir] 
		    [,/user_dark] [,user_dark=user_dark] [,/no_darksub] 
		    [,flatdir=flatdir] [,/no_flatfield] [,unspike=unspike]
		    [,/destreak] [,/deripple] [,/wave2point_correct] [,/float]
		    [,/new_avg] [,/subimgx=subimgx] [,subimgy=subimgy] 
		    [,sllex=sllex] [,slley=slley] [,/nodata] [,/no_calib] 
		    [,/original] [,/outminsiz] [,/outflatfits] [,/qstop] 
		    [,/quiet] [,/verbose] [,n_pixel=n_pixel] 
		    [,run_time=run_time]

       trace_prep, filename, image_no of hourly file, index_out, image_out
       trace_prep, infile, dset_arr, index_out, image_out
       trace_prep, index, data, index_out, image_out
	trace_prep, file_list(indir,infile), ss(0:8), index, image  
		    (with ss=lindgen(total))

   Example for the beginner:
	trace_prep, file_list(indir,infile), [0,2,4,6,8], index, image ,/unspike ,/outtrfits ,outdir=outdir

 INPUTS:
		 ** There are 2 methods for calling TRACE_PREP **
  Case	1. input1 - The input TRACE FITS filelist name(s)
	   input2 - The dataset number(s) to extract and process

  Case	2. input1 - The index structure for each of the input images
		       (e.g., index from output of read_trace with
			      option /image)
	   input2 - The input data array (cube)

 
 OUTPUTS (OPTIONAL):
	index_out - The updated index structure of the input images
	image_out - Processed output TRACE images (data cube).  
			Default data type is I*2

 OPTIONAL INPUT KEYWORD PARAMETERS: 
	normalize - Set to normalize output image to DN per sec	
 (TBD) response_norm - Set if want to include response normalization 
	 		    to physical units				(TBD)
	darkdir   - Directory for ~monthly dark current processed fits images,
			default =  "concat_dir('$tdb','tdc_darks')",  which 
			should work at most sites (including vestige and EOF)
	user_dark - If set, read in a user supplied dark current fits image from
			darkdir as the first image with filename given by 
			'user_dark'.  This image is assumed to be sized, binned, 
			and pixel aligned already.
	no_darksub - Set to not perform dark subtraction; [default: perform it]
 	no_flatfield - Set to not perform flat fielding correction (as done 
			 prior to V3.0); [default: perform it]
	flatdir   - Directory for ~quarterly flat field processed fits images,
			default =  "concat_dir('$tdb','tdc_darks')",  which 
			should work at most sites (including vestige and EOF)
	unspike   - Set if 1 pass of unspike wanted to remove radiation-belt/
			cosmic-ray spikes, or set to 1-3 passes of unspike. This
			method uses convolution and thresholding to remove 
		        spikes 
			and may remove small real features.
			[This calls CCK trace_unspike.pro & trace_cleanjpg.pro] 
 (TBD)	despike   - Set if 1 pass of despike, an alternate unspike, wanted to 
  (NOT TURNED ON YET!)	remove radiation-belt/cosmic-ray spikes, or set to 1-3 
			passes of despike.  This method uses a median filter or
			a statistical correction to remove spikes and may remove 
			small real features.   				(TBD)
			[This calls CJS tracedespike.pro & CCK 
			trace_cleanjpg.pro] 
	destreak  - Set if 1 pass of destreak wanted to remove radiation belt/
			cosmic-ray streaks (particle hits skimming the 
			detector). This method uses convolution and thresholding 
			for removal and may remove small real features.   
			[This calls CCK trace_destreak.pro] 
	deripple  - Set if 1 pass of readout noise (ripple) remover is wanted. 
			This method identifies and zeroes spikes in FFT.
			[This calls CCK trace_knoise.pro] 
       wave2point_correct - set to change the pointing tags (xcen,ycen) ONLY,
                       based on the wavelength dependent alignment corrections 
                       contained in trace_wave2point.pro for subsequent use with 
			Dominic Zarro's SSW mapping software, e.g., plot_map.
                       ***NOTE that these shifts, which are focus dependent,  
                       are only good at the wavelength focusing positions. In 
                       recent years the latter have sometimes not been used to
                       conserve the focus mechanism. Therefore the researcher  
                       should separately check image alignments until this 
                       procedure has been updated.  (RWN Nov. 2005)***  		
	float     - Set if you want to return floating point.  [Default is I*2]
	new_avg   - Set to recalculate img_avg, img_dev, img_min, img_max for 
			image, this is also done upon a call to write_trace to 
			save TRACE data cube
	subimgx   - Set to x size of subimage for extraction and image_out size;
			to extract a subimage set this and subimgy, sllex, slley
	subimgy   - Set to y size of subimage for extraction and image_out size
	sllex     - Set to lower left x position of subimage to be extracted
	slley     - Set to lower left y position of subimage to be extracted
       nodata    - Set if don't want output array (auto set if lt 3 params)
	no_calib  - Set to skip calibration but not various output options
	original  - Set if input files need more keywords for dark subtraction
	outminsiz - Set if output datacube size to be minimum input image size, 
			larger sized images are rebinned to this size after 
			being processed;   [default is maximum input image size
			with no rebinning] 
       outdir    - Destination directory for prepped FITS files
       outtrfits - Set if want to output a TRACE binary extension FITS file
			with 1 or more images 
       outflatfits - Set if want to output a 2D flat FITS file (1 per image)
	qstop	  - Set to stop in this procedure for debuging purposes
	quiet     - Set for fewer messages, default is loud
	verbose   - Set for lots of messages and intermediate data listings;
			suppresses quiet

 OPTIONAL OUTPUT KEYWORD PARAMETERS:
	n_pixel   - Number of pixels repaired
	run_time  - The run time in seconds for TRACE_PREP

 CALLS: ***
	BOX_MESSAGE, DATATYPE [1], DATATYPE [2], DATATYPE [3], MOMENT, TR_DARK_SUB
	TR_EXT_SUBIMG, TR_FLAT_SUB, curdir [1], curdir [2], data_chk [1], data_chk [2]
	get_history, gt_tagval [1], gt_tagval [2], mxf_dset_map, mxf_read_header
	read_trace, required_tags, str_copy_tags [1], str_copy_tags [2]
	str_copy_tags [3], str_copy_tags [4], trace_cleanjpg, trace_destreak
	trace_knoise, trace_unspike, trace_wave2point, tracedespike, update_history
	write_trace
 CALLED BY:
	TRACE_COPY, TRACE_GBO, focus_trace_flt, tace_time2level1, trace_last_movie [1]
	trace_last_movie [3], trace_make_tma, trace_make_tsma, trace_special_movie [1]
	trace_special_movie [2], trace_special_movie [3], trace_special_movie2
 COMMON BLOCKS: none.

 RESTRICTIONS:
       If the input consists of more than one image, there is no  
       check to make sure that all the images are the same size. 
       *** The user must be careful to check this. ***
	In fact each image is processed separately with background
	subtractions adjusted for the image size.  The output datacube
	is by default sized for the largest image and zero-filled, with 
	the images inserted into the cube afterword.  There is an 
	option to size to the minimum image size.  The output datacube
	will be resized to subimage if the subimage extraction option is used.

	Note that the usage of the routines called by the keywords unspike, 
	despike, destreak, and/or deripple may remove small real features 
	in the image.

	If the input is an index structure plus a data cube, the index
	is assumed to contain more than the default set of the keywords 
	(use '/image' in READ_TRACE; '/all_tags' may result in more then 
	127 keywords, which may cause problems in IDL versions below 5.0)

 PROCEDURE:
       Each raw image of the FITS filelist, or of the index and data array, 
	are read in one at a time for processing.   Missing pixels are
	replaced with the total image average value.  Near saturated pixels
	are replaced with values > 4095, such that after dark subtraction they 
	are still > 4100, even for the 4x4 summed values.  Then the appropriate 
	dark pedestal (ADC offset) and the nominally small dark current are 
	subtracted from each entire image.  Negative data values are left as 
	they are. Next the images are flat field corrected. Options are provided
	to call an unspike routine to remove particle and cosmic ray hits of the
	ccd for EUV images only; call an alternate despike program; call a 
	destreak procedure to clean, in EUV images only, streaks resulting from 
	a cosmic ray traveling through several pixels as it skims through the 
	ccd; and call a herringbone readout noise (~few dn ripple) remover for 
	cleaning EUV only image backgrounds that have low intensities.  Another 
	option is to normalize the image for the actual shutter exposure value. 
	A subimage can be extracted from each image as an option also.  An 
	option for updating some of the index parameters for each modified 
	image, e.g., 'img_avg', can be selected.

	In the future, corrections to the image may also be made for response
	normalization to physical units.  Note that no pinhole leakage of foils
	has been observed, so no corrections are needed at the present time. 
	The images are returned as an index structure and a datacube, and 
	optionally as a TRACE binary extension FITS file with an updated header,
	1 or more images per file, and a filename of "tfiyyyymmdd_hhmmss", or as
	a 2D flat FITS file (1 image per file) with a filename of 
	"tsiyyyymmdd_hhmmss_a#.fits", where # = sai integer (0, 1, or 2).


 MODIFICATION HISTORY:
V1.0	Completed on 15-Apr-98  by  R. W. Nightingale  based on
           eit_prep.pro and sxt_prep.pro
V1.1	16-Apr-98 (RWN) - Modified so darkdir can be input, if needed 	    
V1.2   19-Jun-98 (RWN) - Implemented verbose and retrn for TR_DARK_SUB
			- Modified so user_dark file can be supplied to 
			  TR_DARK_SUB and dark_raw_image & _index get saved
			- Updated procedure description and in-line comments
			- Added image normalization capability
			- Added counting of saturated pixels
V1.3    6-Jul-98 (RWN) - Modified keyword info. for default 'darkdir'
V1.4	22-Sep-98 (RWN) - In call to read_trace use /image keyword inplace of
			  /all_tags for shorter index list
V1.5   26-Sep-98 (RWN) - Added option for extraction of a subimage
			- Made the updating of 'img_avg', etc an option
			- Added pointer to dark images at EOF
V1.6 	12-Oct-98 (RWN) - Modify default darkdir keyword documentation
V1.7	14-Jan-99 (RWN) - Added keyword original to allow more keywords
			- Modify "wave_num" to keyword "wave_len"
V1.8    6-Mar-99 (SLF) - Add /WAVE2POINT_CORRECT keyword and logic
V1.9   13-Sep-99 (RWN) - Added more calls to and used UPDATE_HISTORY and 
			  GET_HISTORY instead of add_tag 
			- Added unspike, destreak, despike, deripple, and quiet
			- Updated header and procedure keyword calling sequence
			- Updated /float option and saturated pixel handling
			- Updated to utilize a file/ss map in reading images
V2.0	11-Feb-00 (RWN) - Updated call to tr_ext_subimg for summed/binned images
V2.1   14-Mar-00 (RWN) - Correct call to tr_ext_subimg for index2.tbin_ccd
			- Add /quiet pass through to read_trace
V3.0   23-Aug-02 (RWN) - Add TR_FLAT_SUB interface and UV flat field correction
			- Update library call for mean and standard deviation
V3.1	17-Sep-02 (RWN) - Include double as possible image type for data_chk
V3.2	20-Feb-03 (RWN) - Add EUV flat field correction
V3.2a   4-Nov-05 (RWN) - Header updates, including wave2point note


trace_prioritize_um $SSW/trace/idl/util/trace_prioritize_um.pro
[Previous] [Next]
   Name: trace_prioritize_um

   Purpose: order image sequence structures by paramter "importance"

   Input Parameters:
      umstructs - sequence structures output from trace_uniq_movies.pro

   Output Parameters:
      function returns subscripts of input structures in order from 
      most to least important; 

   Keyword Parameters:
      wave_import - optional desired wave importance (most->least)
                    authors current default looks like: 
                     waves=strtrim([171,195,284,1600,1216,1550],2)
 
      importance (output) - weighted importance of output subscripts

   Calling Sequence:
      um=trace_uniq_movies(catalog)           ; generate uniq sequence 
      priority=trace_prioritize_um(um)        ; prioritize
      Then , "best movie" is um(priority(0))  ; most->least 

 CALLED BY:
	trace_special_movie [2], trace_special_movie [3]
   History:
      6-Dec-2001 - S.L.Freeland - for data summary -> WWW prioritization
   
 CALLS: ***
	BOX_MESSAGE, REVERSE, STR2ARR [1], STR2ARR [2], data_chk [1], data_chk [2]
	required_tags
   Restrictions:
     fairly arbitrary parameter weightings during beta-testing
     ( and beta-testing may continue till the end of MO&DA funding)


trace_psf_isothermal $SSW/trace/idl/util/trace_psf_isothermal.pro
[Previous] [Next]

         NAME : trace_psf_isothermal

         PURPOSE : Returns the TRACE PSF function for the 171 and 195 channel


         CALLING SEQUENCE : psf = trace_psf_isothermal(input_band, temp, max_order)

 CALLED BY:
	moffat2d
         EXAMPLE : trace_psf=trace_psf_isothermal('171', 3.2*1e6, 6)
         INPUTS : input_band   - '171', '195' 
                    temp   - temperature in Kelvins
                    max_ord - maximum diffraction order in the output PSF

         OPTIONAL INPUTS :none

         KEYWORDS :

                           (Default is amp 'a', 11 e/sec).
                    xcen and ycen - shifts of the PSF core relative to the peak pixel center.
                    input_filter - OO, AO, OA, or AA - optional, default is AO.
                    amp_b  - If present, use amplifier 'b' (42 e/sec)
                    div - super-resolution factor
                    noblur - if set then only diffraction pattern is returned (no core blur is applied) 

		     lambda - wavelength array for which the output PSF is calculated (in Angstroms)
                    spectrum - spectrum fluxes for which the output PSF is calculated (in ph/s/cm^2/kev)
	             WARNING - keywords lambda and spectrum have to be used together
                    user_a - a parameter of the nickel wire mesh that supports the TRACE entrance EUV filters and 
                             causes diffraction effects in TRACE images.


          OUTPUTS : the TRACE psf function for selected filter setup

          OPTIONAL OUTPUTS :
          psf_info_struct - an DL structure with description of the TRACE PSF properties.

          CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], ISOTHERMAL, concat_dir [4]
	moffat2d, trace_euv_resp [1], trace_euv_resp [2]
         COMMON BLOCKS : none

         SPECIAL CALLS : none

         WRITTEN : S. Gburek 09-March-2006, email to sg@cbk.pan.wroc.pl

         MODIFIED : SJG 12-March-2006 added xcen and ycen keywords to allow for sub-pixel PSF shifts


trace_rd_jpeg $SSW/trace/idl/egse/trace_rd_jpeg.pro
[Previous] [Next]
NAME:
	trace_rd_jpeg
PURPOSE:
	Convert the JPEG data stream into a 2-D image
SAMPLE CALLING SEQUENCE:
	trace_rd_jpeg, bhead, img, infil
INPUT:
	bhead	- The binary FITS header (optionally does not
		  exist and the input file is read)
	img	- The image array (optionally read file)
	infil	- The input file
METHOD:
	The input image is modified and sent out as 2-D
	if needed.  If the data is not JPEGed, it just
	returns.

	Currently spawns a call to Shine executable which
	takes a file as input and has a file as output.
	In the future, it will use a pipe and will not
	require the data to be re-read
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], DELVARX [1], DELVARX [2]
	DELVARX [3], DELVARX [4], FILE_EXIST [2], RFITS [1], RFITS [2], RFITS [3]
	TAG_EXIST [1], TAG_EXIST [2], concat_dir [4], data_type [1], data_type [2]
	delvarx [5], file_exist [1], file_exist [3], prstr [1], prstr [2], rd_trace_i0 [1]
	rd_trace_i0 [2]
 CALLED BY:
	rd_trace_i0 [1], rd_trace_i0 [2]
HISTORY:
	Written 23-Jul-97 by M.Morrison
	 1-Aug-97 (MDM) - Small adjustments, added header
	24-Sep-97 (MDM) - Corrected the quality table selection
	15-Oct-97 (MDM) - Modified to use "START_BYTE" information


trace_recent_movie_summary $SSW/trace/idl/wwwidl/trace_movie_qkl_queue.pro
[Previous] [Next]
   Name: trace_recent_movie_summary  

   Purpose: return info/html summary re: recent only movie directories
 CALLS:


trace_request_summary $SSW/trace/idl/wwwidl/trace_request_summary.pro
[Previous] [Next]
   Name: trace_request_summary

   Purpose:
      provide html summary of a completed TRACE data request job 

 CALLS: ***
	BOX_MESSAGE, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], FILE_EXIST [2]
	break_file [4], configure_http, data_chk [1], data_chk [2], file_append [1]
	file_append [2], file_exist [1], file_exist [3], file_size [1], file_size [2]
	html_doc, http_names, rd_tfile [1], rd_tfile [2], read_trace, str_replace [1]
	str_replace [2], strmids [1], strmids [2], strsplit, strtab2html
 CALLED BY:
	trace_do_data_requests
   History:
      25-May-1998 - S.L.Freeland - TRACE WWW request interface
      27-May-1998 - S.L.Freeland - add version/extension to link text  


trace_rnoise $SSW/trace/idl/util/trace_rnoise.pro
[Previous] [Next]
 NAME:
	trace_rnoise
 PUPROSE:
	To suppress electronic readout noise in TRACE images.
	Image despiking is recommended prior to use:
		image = trace_unspike(image_raw,/cleanjpg)
 CALLING SEQUENCE:
	result = trace_rnoise(image)
  Increase sensitivity by increasing n_modes:
	result = trace_rnoise(image,n_modes=4)
 INPUTS:
	image = 2-dimensional image
 OPTIONAL KEYWORD INPUTS:
	thresh = threshold for bad pixels (0.1 is default). In
		/AUTO mode (the default), THRESH is just the
		starting value for the threshold, which may
		range from some small number to 10*THRESH.
	n_modes = number of noise modes to suppress when in
		/AUTO mode. This is half the number of spikes 
		found in the FFT. By default, N_MODES=2. Some
		images will benefit from the removal of up to
		16 modes.
	mask_size = size of low-frequency region in the FFT that
		will not be despiked. The default is 50.
 KEYWORD SWITCHES:
	auto - This is set by default; say auto=0 to disable. In
		AUTO mode, threshold is updated iteratively until
		exactly n_modes modes have been identified for
		suppression. The overhead for this is miniscule,
		and it allows the algorithm to do fairly well
		without human intervention.
	debug - if set, gives some interactive information
 PROCEDURE:
	The objective is to remove spikes from the power spectrum of
	the image. Spikes in the absolute value of the FFT are amplified
	by convolution. A map of bad pixels is made by thresholding this
	amplified image. 

	The bad pixel map is masked to exclude a window around the low
	frequencies, where there is enough power in the image to make
	despiking impractical. The size of this neighborhood can be
	adjusted with the MASK_SIZE keyword.

	In /AUTO mode (the default), the threshold is updated
	iteratively until a desired number of "modes" in the
	Fourier spectrum have been identified in the bad pixel
	map.

	The FFT is then repaired by replacing bad pixels with an average
	of nearby good pixels. The result is obtained by an inverse transform 
	on the repaired FFT image.

 CALLS: ***
	DIST, ck_smooth
	NOTE: trace_rnoise may work best on images that have been treated
	with trace_unspike() because the FFT is then smoother. This, in turn,
	allows the THRESH parameter to be set lower for higher fidelity.
 SIDE-EFFECTS:
	image is converted to a float array, if it's not already.
 MODIFICATION HISTORY:
	1998-Aug-25  C. C. Kankelborg


trace_scale $SSW/trace/idl/util/trace_scale.pro
[Previous] [Next]
   Name: trace_scale

   Purpose: scale TRACE images (SSW wrapper for Karel Schryver routines)

   Input Parameters:
      index  - TRACE 'index' from read_trace or mreadfits
      data   - data array
     
 CALLS: ***
	ADD_TAG [1], ADD_TAG [2], ARR2STR [1], Arr2Str [2], BOOST_TAG, BOX_MESSAGE
	SIGRANGE [1], SIGRANGE [2], TRACESCALE, Time2Dset, data_chk [1], data_chk [2]
	gt_tagval [1], gt_tagval [2], is_number [1], is_number [2], tag_index [1]
	tag_index [2]
 CALLED BY:
	READ_TRACE_FOV, trace_movie_context, trace_special_movie [1]
	trace_special_movie [2], trace_special_movie [3], trace_special_movie2
	write_trace
    History:
      30-Apr-1998 - tracescale by C.J. Schryver Written
      21-May-1998 - tracescale C.J. Schryver modified, 'submitted'
      28-May-1998 - S.L.Freeland - made trace_scale wrapper, online->SSW
                    remove file reading code, made default quiet , $
                    added /LOUD and /FULLRANGE switches permit 3D input and 
       9-Sep-1998 - use a histogram equal for WL
  
    Output:
         image_scaled      despiked&scaled image - bytarr
         image_corrected   despiked image - intarr (optional)

    Method:
       (see header for 'tracescale.pro' 

    Calling Examples:
       ; derived scaling ...
          IDL> simg=trace_scale(index,data,/despike,/byte,contrast=3)
       ; prescribed scaling
          IDL> simg=trace_scale(index, data,/despike,scaling=[p,s,g])
               (p=pedestal/minimum, s=saturation/maximum, g=gamma)

      Scaling adjusts to available colors (use Zbuffer for full 256->GIF)
      By default, the two highest cells are not used and are available
           for magnetic contours - use /FULLRANGE to override


trace_special_movie [1] $SSW/trace/idl/wwwidl/trace_special_movie.pro
[Previous] [Next]
   Name: trace_special_movie

   Purpose: TRACE movies -> WWW  

   Keyword Parameters:
      minframes - ignore movies with fewer than this many frames
      maxframes - upper limit number of frames per movie
      outsize   - output size for each movie frame
      prepit  - switch, if set, run data through trace_prep
      _EXTRA  - special_movie / image2movie keywords via inheritance
      grid    - if set, than grid MAXFRAMES over interval
                (default is last MAXFRAMES images)
      last_nhours - most recent N hours to consider (default=24)
      percentd - frame quality threshold (default=100%) 
      queue_days - number of days saved (passed to trace_last_movie_queue)
      mdir  - output directory (movies, gifs, etc)
      movie_dir - synonym for mdir
      noprep - if set, inhibit trace_prep
      interactive - if set, sequence selection is interactive
      context - include EIT/GOES context
                if 1 element array - size of full size context image
                if 2 element array - size of [thumbnail,fullsize]
                if switch (=1) - default [thumb,full] = [ 140,512]
  
   History:
      25-April-1998 - S.L.Freeland - apply some SSW movie techniques->TRACE  
      12-Jun-1998   - S.L.Freeland - call 'trace_data_filter' to remove
                      radiation contaminated/other bad data  
      17-Jul-1998   - S.L.Freeland - filter out movies < 512x512 (dosimiter)
      16-Sep-1998   - Add /GRID, change default outsize to 320 (mpeg compat)
                      Add LAST_NHOURS and PERCENTD keywords and function
      22-Sep-1998   - keep genx log of movie frame info, add /TESTING keyword
      27-Sep-1998   - pass MDIR to trace_movie_index
      13-Oct-1998   - derive from 'trace_last_movie' - permit user time range
                      enable context images
      26-May-1999   - make 'prep' and 'derotate' defaults, additional mods
                      unify (single point maint) recent and 'special' movies
       1-Jun-1999   - S.L.Freeland - make recent movies in 'offline'
                      subdirectory - only transfer->default WWW when complete
      15-Jun-1999   - S.L.Freeland - add /INTERACTIVE, MINNX, EXCLUDE
                      ( pass through to 'trace_uniq_movies' )  
      8-Dec-1999    - add FDROLL ( -> ssw_fov_context during soho roll times)
      8-May-2000    - permit CONTEXT specification of context image size
     18-Jun-2000    - S.L.Freeland add FD_TYPE ( -> ssw_fov_context )   

   Method:
      use trace_cat - loop through 'special_movie' for each
                      uniq movie dset - organize submovies by OBS_PROG

   Calls: ***
	ADD_TAG [1], ADD_TAG [2], BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], CT2RGB, FILE_EXIST [2], FMT_TIMER [1], FMT_TIMER [2], REVERSE
	STR2ARR [1], STR2ARR [2], TIME2FILE, TRACE_COLORS, TRACE_LIST_INDEX
	TRACE_MOVIE_QKL_QUEUE, TRACE_PREP, UNIQ [1], UNIQ [2], UNIQ [3], WRITE_GIF
	concat_dir [4], cube_edit, data_chk [1], data_chk [2], file_append [1]
	file_append [2], file_exist [1], file_exist [3], get_logenv [1], get_logenv [2]
	grid_data [1], grid_data [2], gt_tagval [1], gt_tagval [2], html_doc
	is_member [1], is_member [2], last_nelem, read_trace, savegen [1], savegen [2]
	set_logenv [1], set_logenv [2], special_movie, ssw_fov_context, ssw_track_fov
	str_replace [1], str_replace [2], trace_cat2data, trace_data_filter
	trace_last_movie_queue, trace_movie_index [1], trace_movie_index [2]
	trace_scale, trace_sub2point, trace_uniq_movies, trace_unspike


trace_special_movie [2] $SSW/trace/idl/wwwidl/trace_special_movie3.pro
[Previous] [Next]
   Name: trace_special_movie

   Purpose: TRACE movies -> WWW  

   Keyword Parameters:
      minframes - ignore movies with fewer than this many frames
      maxframes - upper limit number of frames per movie
      outsize   - output size for each movie frame
      prepit  - switch, if set, run data through trace_prep
      _EXTRA  - special_movie / image2movie keywords via inheritance
      grid    - if set, than grid MAXFRAMES over interval
                (default is last MAXFRAMES images)
      last_nhours - most recent N hours to consider (default=24)
      percentd - frame quality threshold (default=100%) 
      queue_days - number of days saved (passed to trace_last_movie_queue)
      mdir  - output directory (movies, gifs, etc)
      movie_dir - synonym for mdir
      noprep - if set, inhibit trace_prep
      interactive - if set, sequence selection is interactive
      context - include EIT/GOES context
                if 1 element array - size of full size context image
                if 2 element array - size of [thumbnail,fullsize]
                if switch (=1) - default [thumb,full] = [ 140,512]
      cube_unspike - if set, call 'ssw_unspike_cube' (EUV only)
      goes_movie - if set, append GOES XRay movie plot
      outurl - top level url output
      priority_limit - limit number of seqeunces ("best" NN movies only)
      only_waves     - only consider these wavelengths

   History:
      25-April-1998 - S.L.Freeland - apply some SSW movie techniques->TRACE  
      12-Jun-1998   - S.L.Freeland - call 'trace_data_filter' to remove
                      radiation contaminated/other bad data  
      17-Jul-1998   - S.L.Freeland - filter out movies < 512x512 (dosimiter)
      16-Sep-1998   - Add /GRID, change default outsize to 320 (mpeg compat)
                      Add LAST_NHOURS and PERCENTD keywords and function
      22-Sep-1998   - keep genx log of movie frame info, add /TESTING keyword
      27-Sep-1998   - pass MDIR to trace_movie_index
      13-Oct-1998   - derive from 'trace_last_movie' - permit user time range
                      enable context images
      26-May-1999   - make 'prep' and 'derotate' defaults, additional mods
                      unify (single point maint) recent and 'special' movies
       1-Jun-1999   - S.L.Freeland - make recent movies in 'offline'
                      subdirectory - only transfer->default WWW when complete
      15-Jun-1999   - S.L.Freeland - add /INTERACTIVE, MINNX, EXCLUDE
                      ( pass through to 'trace_uniq_movies' )  
      8-Dec-1999    - add FDROLL ( -> ssw_fov_context during soho roll times)
      8-May-2000    - permit CONTEXT specification of context image size
     18-Jun-2000    - S.L.Freeland add FD_TYPE ( -> ssw_fov_context )   
     26-Jun-2000    - add /NORMALIZE to trace_prep call.
     25-July-2001   - add LL,LR,UL,UR,CENTER,PIXSUB (-> ssw_subimage)
     19-Sep-2001    - add rotate_movie (parameter -> rotate_3d)
      6-Dec-2001    - add ONLY_WAVES and PRIORITY_LIMIT

   Method:
      use trace_cat - loop through 'special_movie' for each
                      uniq movie dset - organize submovies by OBS_PROG

   Calls: ***
	ADD_TAG [1], ADD_TAG [2], BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], CT2RGB, FILE_EXIST [2], FMT_TIMER [1], FMT_TIMER [2], REVERSE
	STR2ARR [1], STR2ARR [2], TIME2FILE, TRACE_COLORS2, TRACE_LIST_INDEX
	TRACE_MOVIE_QKL_QUEUE, TRACE_PREP, TRACE_SPECIAL_MOVIE3, UNIQ [1], UNIQ [2]
	UNIQ [3], WRITE_GIF, concat_dir [4], cube_edit, data_chk [1], data_chk [2]
	event_movie [1], event_movie [2], file_append [1], file_append [2]
	file_exist [1], file_exist [3], get_logenv [1], get_logenv [2], get_user [1]
	get_user [2], grid_data [1], grid_data [2], gt_tagval [1], gt_tagval [2], html_doc
	http_names, is_member [1], is_member [2], last_nelem, mail [1], mail [2], read_trace
	rotate_3d, savegenx, set_logenv [1], set_logenv [2], special_movie
	ssw_fov_context, ssw_subimage, ssw_track_fov, ssw_unspike_cube, str_replace [1]
	str_replace [2], trace_cat2data, trace_data_filter, trace_last_movie_queue
	trace_movie_index [1], trace_movie_index [2], trace_prioritize_um, trace_scale
	trace_sub2point, trace_uniq_movies


trace_special_movie [3] $SSW/trace/idl/wwwidl/trace_special_movie4.pro
[Previous] [Next]
   Name: trace_special_movie

   Purpose: TRACE movies -> WWW  

   Keyword Parameters:
      minframes - ignore movies with fewer than this many frames
      maxframes - upper limit number of frames per movie
      outsize   - output size for each movie frame
      prepit  - switch, if set, run data through trace_prep
      _EXTRA  - special_movie / image2movie keywords via inheritance
      grid    - if set, than grid MAXFRAMES over interval
                (default is last MAXFRAMES images)
      last_nhours - most recent N hours to consider (default=24)
      percentd - frame quality threshold (default=100%) 
      queue_days - number of days saved (passed to trace_last_movie_queue)
      mdir  - output directory (movies, gifs, etc)
      movie_dir - synonym for mdir
      noprep - if set, inhibit trace_prep
      interactive - if set, sequence selection is interactive
      context - include EIT/GOES context
                if 1 element array - size of full size context image
                if 2 element array - size of [thumbnail,fullsize]
                if switch (=1) - default [thumb,full] = [ 140,512]
      cube_unspike - if set, call 'ssw_unspike_cube' (EUV only)
      goes_movie - if set, append GOES XRay movie plot
      outurl - top level url output
      priority_limit - limit number of seqeunces ("best" NN movies only)
      only_waves     - only consider these wavelengths

   History:
      25-April-1998 - S.L.Freeland - apply some SSW movie techniques->TRACE  
      12-Jun-1998   - S.L.Freeland - call 'trace_data_filter' to remove
                      radiation contaminated/other bad data  
      17-Jul-1998   - S.L.Freeland - filter out movies < 512x512 (dosimiter)
      16-Sep-1998   - Add /GRID, change default outsize to 320 (mpeg compat)
                      Add LAST_NHOURS and PERCENTD keywords and function
      22-Sep-1998   - keep genx log of movie frame info, add /TESTING keyword
      27-Sep-1998   - pass MDIR to trace_movie_index
      13-Oct-1998   - derive from 'trace_last_movie' - permit user time range
                      enable context images
      26-May-1999   - make 'prep' and 'derotate' defaults, additional mods
                      unify (single point maint) recent and 'special' movies
       1-Jun-1999   - S.L.Freeland - make recent movies in 'offline'
                      subdirectory - only transfer->default WWW when complete
      15-Jun-1999   - S.L.Freeland - add /INTERACTIVE, MINNX, EXCLUDE
                      ( pass through to 'trace_uniq_movies' )  
      8-Dec-1999    - add FDROLL ( -> ssw_fov_context during soho roll times)
      8-May-2000    - permit CONTEXT specification of context image size
     18-Jun-2000    - S.L.Freeland add FD_TYPE ( -> ssw_fov_context )   
     26-Jun-2000    - add /NORMALIZE to trace_prep call.
     25-July-2001   - add LL,LR,UL,UR,CENTER,PIXSUB (-> ssw_subimage)
     19-Sep-2001    - add rotate_movie (parameter -> rotate_3d)
      6-Dec-2001    - add ONLY_WAVES and PRIORITY_LIMIT

   Method:
      use trace_cat - loop through 'special_movie' for each
                      uniq movie dset - organize submovies by OBS_PROG

   Calls: ***
	ADD_TAG [1], ADD_TAG [2], AVERAGE, BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], CT2RGB, FILE_EXIST [2], FMT_TIMER [1], FMT_TIMER [2], REVERSE
	STR2ARR [1], STR2ARR [2], TIME2FILE, TRACE_COLORS2, TRACE_LIST_INDEX
	TRACE_MOVIE_QKL_QUEUE, TRACE_PREP, TRACE_SPECIAL_MOVIE4, UNIQ [1], UNIQ [2]
	UNIQ [3], WRITE_GIF, concat_dir [4], cube_edit, data_chk [1], data_chk [2]
	event_movie [1], event_movie [2], file_append [1], file_append [2]
	file_exist [1], file_exist [3], get_logenv [1], get_logenv [2], get_user [1]
	get_user [2], grid_data [1], grid_data [2], gt_tagval [1], gt_tagval [2], html_doc
	http_names, is_member [1], is_member [2], last_nelem, mail [1], mail [2], nospike
	read_trace, rotate_3d, savegenx, set_logenv [1], set_logenv [2], special_movie
	ssw_fov_context, ssw_subimage, ssw_unspike_cube, str_replace [1]
	str_replace [2], time_window, trace_cat2data, trace_data_filter
	trace_last_movie_queue, trace_movie_index [1], trace_movie_index [2]
	trace_prioritize_um, trace_scale, trace_sub2point, trace_uniq_movies
	write_trace


trace_special_movie2 $SSW/trace/idl/wwwidl/trace_special_movie2.pro
[Previous] [Next]
   Name: trace_special_movie2

   Purpose: TRACE movies -> WWW  

   Keyword Parameters:
      minframes - ignore movies with fewer than this many frames
      maxframes - upper limit number of frames per movie
      outsize   - output size for each movie frame
      prepit  - switch, if set, run data through trace_prep
      _EXTRA  - special_movie / image2movie keywords via inheritance
      grid    - if set, than grid MAXFRAMES over interval
                (default is last MAXFRAMES images)
      last_nhours - most recent N hours to consider (default=24)
      percentd - frame quality threshold (default=100%) 
      queue_days - number of days saved (passed to trace_last_movie_queue)
      mdir  - output directory (movies, gifs, etc)
      movie_dir - synonym for mdir
      noprep - if set, inhibit trace_prep
      interactive - if set, sequence selection is interactive
  
   History:
      25-April-1998 - S.L.Freeland - apply some SSW movie techniques->TRACE  
      12-Jun-1998   - S.L.Freeland - call 'trace_data_filter' to remove
                      radiation contaminated/other bad data  
      17-Jul-1998   - S.L.Freeland - filter out movies < 512x512 (dosimiter)
      16-Sep-1998   - Add /GRID, change default outsize to 320 (mpeg compat)
                      Add LAST_NHOURS and PERCENTD keywords and function
      22-Sep-1998   - keep genx log of movie frame info, add /TESTING keyword
      27-Sep-1998   - pass MDIR to trace_movie_index
      13-Oct-1998   - derive from 'trace_last_movie' - permit user time range
                      enable context images
      26-May-1999   - make 'prep' and 'derotate' defaults, additional mods
                      unify (single point maint) recent and 'special' movies
       1-Jun-1999   - S.L.Freeland - make recent movies in 'offline'
                      subdirectory - only transfer->default WWW when complete
      15-Jun-1999   - S.L.Freeland - add /INTERACTIVE, MINNX, EXCLUDE
                      ( pass through to 'trace_uniq_movies' )  
      8-Dec-1999    - add FDROLL ( -> ssw_fov_context during soho roll times)

   Method:
      use trace_cat - loop through 'special_movie' for each
                      uniq movie dset - organize submovies by OBS_PROG

   Calls: ***
	ADD_TAG [1], ADD_TAG [2], BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], CT2RGB, FILE_EXIST [2], FMT_TIMER [1], FMT_TIMER [2], REVERSE
	STR2ARR [1], STR2ARR [2], TIME2FILE, TRACE_COLORS, TRACE_LIST_INDEX
	TRACE_MOVIE_QKL_QUEUE, TRACE_PREP, UNIQ [1], UNIQ [2], UNIQ [3], WRITE_GIF
	concat_dir [4], cube_edit, data_chk [1], data_chk [2], file_append [1]
	file_append [2], file_exist [1], file_exist [3], get_logenv [1], get_logenv [2]
	grid_data [1], grid_data [2], gt_tagval [1], gt_tagval [2], html_doc
	is_member [1], is_member [2], last_nelem, read_trace, savegen [1], savegen [2]
	set_logenv [1], set_logenv [2], special_movie, ssw_fov_context, ssw_track_fov
	str_replace [1], str_replace [2], trace_cat2data, trace_data_filter
	trace_last_movie_queue, trace_movie_index [1], trace_movie_index [2]
	trace_scale, trace_sub2point, trace_uniq_movies, trace_unspike


TRACE_SSWHERE [1] $SSW/trace/idl/util/trace_sswhere.pro
[Previous] [Next]
 NAME:
	TRACE_SSWHERE
 PURPOSE:
	Select subset of TRACE images with widget interface
 CATEGORY:
 CALLING SEQUENCE:
	ss = trace_sswhere(struct)
 INPUTS:
	struct		TRACE index, or catalog structure
 OPTIONAL INPUT PARAMETERS:
 KEYWORD PARAMETERS:
	debug		prints additional information if set
 OUTPUTS:
	ss		vector of selected records within input structure
 OPTIONAL OUTPUT PARAMETERS:
 CALLS: ***
	ADDTIME [1], ADDTIME [2], ALL_VALS [1], ALL_VALS [2], ARR2STR [1], Arr2Str [2]
	BOX_CURSOR, BOX_MESSAGE, CONGRID [1], CONGRID [2], CONGRID [3], FILE2TIME
	FMT_TIMER [1], FMT_TIMER [2], FSTRING, READFITS [1], READFITS [2], READFITS [3]
	TIME2FILE, TRACE_LIST_INDEX, TRACE_SSWHERE_EVENT, TRACE_SSWHERE_FOV
	TRACE_SSWHERE_RESET, XMANAGER, XMENU [1], XMENU [2], anytim [1], anytim [2]
	anytim [3], anytim [4], anytim [5], anytim2ints [1], anytim2ints [2]
	draw_boxcensiz [1], draw_boxcensiz [2], draw_boxcorn [1], draw_boxcorn [2]
	fmt_tim [1], fmt_tim [2], get_rb0p [1], get_rb0p [2], grid_data [1], grid_data [2]
	gt2exe [1], gt2exe [2], gt_tagval [1], gt_tagval [2], tim2dset [1], tim2dset [2]
	trace_data_filter, trace_files
 CALLED BY:
	plot_fov [1]
 COMMON BLOCKS:
	obs_tbl, obs_cms, obs_btn, obs_btnx, obs_times, 
	obs_plot_msgs, obs_index, obs_image...
 SIDE EFFECTS:
	call routines trace_sswhere_event, trace_sswhere_reset, trace_plot_fov
 RESTRICTIONS:
	Only use the BAD data rejection for short time intervals. The method 
	used can give unexpected results if used on a long time interval with 
	a range of exposures. A range of image sizes can also confuse it!
 PROCEDURE:
	Select desired options and use "Show Selection" to see the result

	Currently the following can be selected in TRACE_SSWHERE:
          Start and stop time
          Image Cadence
          Min and/or max image exposure
          Wavelength
          Image Dimension
          Spacecraft Pointing
          Removal of "bad" data, using trace_data_filter - under development!
	  
	Enter carriage return <CR> after any value entered in an editable 
	widget window.

	Only channels and image dimensions present in the supplied structure 
	are available for selection
	Start and stop times cannot be changed to outside the limits of the 
	supplied "index" structure
	The selected cadence is applied after the other selection criteria 
	have been combined.

	Uses box_cursor when selecting pointing information
	Buttons are:
	  left:    drag box around
	  center:  change box size by dragging side in desired direction
	  right:   exit

 MODIFICATION HISTORY:
	   Sep-98  RDB	Written
	01-Oct-98  RDB	Added Pointing selection, time adjustment
			Concatonated all routines into one file
	03-Nov-98  rdb  Added selection of image cadence; few bug fixes
			Display nearest mosaic image if requested
	06-Nov-98  rdb	Use time2file for time limit comparison (Y2K) 
			Added removal of "bad" data (trace_data_filter)
	24-Mar-99  rdb	Corrected problem related to deleting windows under 5.2
	01-Jun-99  rdb  Image dims. now /nonexcl
       18-Jul-00  slf  update syntax for tighter 5.3 controls


trace_sswhere [2] $SSW/trace/idl/util/trace_sswhere.pro
[Previous] [Next]
	Event processor called by widget created by TRACE_SSWHERE
 CALLS:
 CALLED BY
	plot_fov [1]


trace_sswhere [3] $SSW/trace/idl/util/trace_sswhere.pro
[Previous] [Next]
       Resets values in widget in TRACE_SSWHERE
 CALLS:
 CALLED BY
	plot_fov [1]


trace_sswhere [4] $SSW/trace/idl/util/trace_sswhere.pro
[Previous] [Next]
	Select subset of TRACE images with widget interface
 CALLS:
 CALLED BY
	plot_fov [1]


trace_struct2filename $SSW/trace/idl/info/trace_struct2filename.pro
[Previous] [Next]
   Name: trace_struct2filename

   Purpose: derive filenames from trace structures

   Input Parameters:
      struct - vector of TRACE structures (ex, output from read_trace)  

   Output:
      function returns implied filenames, format determined by keywords

   Keyword Parameters:
      outdir -    if supplied, prepend this path to output filenames
      soho   -    if set, output in soho-standard format
      prefix -    if supplied, prepend this prefix to filenames
      extension - if supplied, append this to filenames
      incwave -   if set, append wave_nam to filenames 
      incsize -   if set, append NX to filename 
      hourly -    if set, name is implied hourly file name ('triyyyymmdd.hh00')
      seconds -   if set, name includes seconds

   Calls: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], STR2ARR [1]
	STR2ARR [2], TIME2FILE, concat_dir [4], data_chk [1], data_chk [2], gt_tagval [1]
	gt_tagval [2], strmids [1], strmids [2]
 CALLED BY:
	READ_TRACE_FOV, TRACE_COPY, TRACE_GBO, trace_cat2data, trace_make_tmr [1]
	trace_make_tmr [2], write_trace
   History:
      26-Feb-1998 - S.L.Freeland
      12-Mar-1998 - S.L.Freeland - change order of default naming logic
      11-Mar-2002 - D.M. Zarro - added /seconds


trace_sub2point $SSW/trace/idl/info/trace_sub2point.pro
[Previous] [Next]
   Name: trace_sub2point

   Purpose: apply CCD cutout dependent dependent adjustments to trace pointing tags

   Input Parameters:
      index - index structure vector (read_trace output) or catalog recs.

   Output:
      function returns wavelenth adjusted indices (xcen/ycen/.HISTORY)
  
   Keyword Parameters:
      version - (output) - version number of this routine
      noapply - (switch) - if set, do not apply or update history
      undo    - (switch) - if set and .HISTORY available, undo the correction
  
   Calling Sequence:
      newind=trace_sub2point(index [,/noapply] [,version=xx] )
      
   Calling Examples:
      newind=trace_sub2point(index)           ; adjust xcen/ycen/history
      newind=trace_sub2point(index,/quiet)    ; minimize tty chatter
      newind=trace_sub2point(index,/noapply,xyoff=xyoff) ; just return XYOFF

 CALLED BY:
	trace_special_movie [1], trace_special_movie [2], trace_special_movie [3]
	trace_special_movie2
   History:
      24-November-1998 - S.L.Freeland - Version 1.0 -
                         from trace_wave2point and trace_ccdpositions.ana

   Calls: ***
	BOX_MESSAGE, data_chk [1], data_chk [2], get_history, gt_tagval [1], gt_tagval [2]
	gtt_info, required_tags, trace_wave2point, update_history
   Restrictions:
      input structure vector must include XCEN,YCEN, and DP_HEADER.


trace_submit_request $SSW/trace/idl/wwwidl/trace_submit_request.pro
[Previous] [Next]
   Name: trace_submit_request

   Purpose: post processing of WWW data request - append options->success file

   Keyword Parameters:
      qfile - WWW Post Query filename  
  
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], break_file [4], concat_dir [4], configure_http, file_append [1]
	file_append [2], get_logenv [1], get_logenv [2], gt_tagval [1], gt_tagval [2]
	html_doc, rd_tfile [1], rd_tfile [2], str_replace [1], str_replace [2], url_decode
   History:
     19-May-1998 - S.L.Freeland


trace_success_file $SSW/trace/idl/wwwidl/trace_order_data.pro
[Previous] [Next]
   Name: trace_success_file

   Purpose: success file->data order FORM (fg) FORM order->data (background)  

   Input Parameters:
       success_file - ascii file list of successes from catalog search
                      (from trace_idlcat.pro)
 CALLS: ***
	BOX_MESSAGE, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1]
	CONCAT_DIR [2], CONCAT_DIR [3], DELVARX [1], DELVARX [2], DELVARX [3], DELVARX [4]
	FILE_EXIST [2], TRACE_DATA_REQUEST_MIRROR, TRACE_ORDER_DATA, UNIQ [1], UNIQ [2]
	UNIQ [3], break_file [4], concat_dir [4], data_chk [1], data_chk [2], delvarx [5]
	file_append [1], file_append [2], file_exist [1], file_exist [3], get_logenv [1]
	get_logenv [2], html_doc, rd_tfile [1], rd_tfile [2], read_trace, str2cols [1]
	str2cols [2], str_replace [1], str_replace [2], strnocomment, strsplit
	strtab2html, trace_file2path, write_trace
   Side Effects:
      if foreground, FORM echoed to user  (assumed at WWW browser)
      if background, Data -> dropoff/pickup

   History:
       18-May-98  S.L.Freeland
       19-May-98  S.L.Freeland - email , extend FORM 
       20-May-98  S.L.Freeland - background task (order->pickup)
       26-May-98  S.L.Freeland - add some additional tracking
       27-May-98  S.L.Freeland - add /EXTEN to write_fits call
       19-Feb-98  S.L.Freeland - email rationalize


TRACE_T2EM $SSW/trace/idl/util/trace_t2em.pro
[Previous] [Next]
NAME:
	TRACE_T2EM
PURPOSE:
	Given an array of possible temperatures and one,
	two, or three pixel values in DN for any of the
	TRACE EUV passbands, calculate the corresponding 
	emission measures and chi squared values.
CALLING SEQUENCE:
	trace_t2em, index, dn, noise, temperature, chisq=chisq, em=em
 CALLS: ***
	trace_t_resp
 CALLED BY:
	TRACE_ISOTHERMAL
EXAMPLE:
	;Suppose that data is a raw data cube containing
	;raw, co-aligned images in 171, 195, and 284. We
	;will use TRACE_T2EM to see how goodness of fit,
	;as measured by chi squared, varies with temperature
	;for a single pixel.
	dn = data(485,297,*) - 85 ;approx. subtract pedestal
	noise = 2 + sqrt(dn/12)   ;readout noise plus shot noise
	T = 1e5 + findgen(2000) * 5000 ;Temps ranging from 1e5 to 1e7
	trace_t2em, index, dn, noise, T, chisq=chisq, em=em
	plot_oo, T, chisq  ;look at how chi squared varies with temp
INPUT PARAMETERS:
	index - n-element array of TRACE index structures.
		The sht_mdur tag is required.
	dn - n-element array of pixel values (pedestal must
		already be subtracted).
	noise - n-element array giving estimated noise in DN.
	temperature - scalar or array of temperatures at 
		which to calculate the corresponding emission
		measure.
KEYWORD OUTPUTS:
	chisq - chi squared statistic indicating goodness of fit
		for the assumed temperature and calculated emission
		measure. Has the same number of elements as the
		temperature input parameter.
	em - emission measure. This is first calculated separately
		for each of the DN values. A weighted average is
		taken so as to minimize chi squared as a function
		of EM.
MODIFICATION HISTORY:
	C. Kankelborg, Sept-24-1998


trace_t_resp $SSW/trace/idl/util/trace_t_resp.pro
[Previous] [Next]
NAME:
       trace_t_resp
PURPOSE:
       Returns TRACE EUV response to a solar plasma at 
       temperature T. The default assumptions are the coronal 
       abundances of Feldman and the ionization balance of Arnaud
       & Raymond; see the rfile keyword, below. 

       Units:
               +-----------------------+
               |  DN s-1 pixel-1 cm+5  |
               +-----------------------+
       Note that this is per unit column emission measure.
       To get units of DN s-1 cm+3, i.e. DN per second per
       unit volume emission measure, just use the /volume
       keyword.
CALLING SEQUENCE:
       result=trace_t_resp(wavelength, T)       
 CALLED BY:
	TRACE_DEM_SETUP, TRACE_T2EM, TRACE_TBASIS, TRACE_TEEM
EXAMPLE:
       The following example illustrates the great discrepancy
       between the Arnaud & Raymond ionization balances and those
       of Arnaud & Rothenflug. Of the TRACE passbands, Fe IX (171)
       shows the difference most clearly:
       IDL> Te=2.0e5+1.0e4*findgen(200)
       IDL> response=trace_t_resp('171oa',Te)
       IDL> plot_oo, Te, response
       ;Compare the ionization balance of Arnaud & Rothenflug:
       IDL> r2=trace_t_resp('same',Te,rfile='FELDMAN_ROTHENFLUG_pe1E15.resp')
       IDL> oplot,Te, r2, linestyle=2
OUTPUTS:
	The result is a double precision floating point number
	representing the TRACE response to a plasma at temperature
	T. The units are DN s-1 pixel-1 cm+5 unless the /volume
	keyword is set.
INPUT PARAMETERS:
       wavelength - The TRACE EUV wavelength, represented
               as a string. Allowed values are: 'same', '171ao',
               '171oa', '171aa', '171oo', and similar for 173, 195
               and 284. 'same' means the same wavelength will
               be used as in the last call to trace_t_resp.
               173 is allowed because 173 is really more accurate 
               than 171. The oa, ao, aa, oo are filter combinations,
               e.g. ao = open, aluminum. Extra whitespace
               is ignored, so for example '171 a o' == '171ao'.
               The wavelength parameter is not case sensitive.
       T - Temperature of the plasma. If T is an array,
               then the result will be an array of the same
               dimensions.
OPTIONAL KEYWORD INPUTS:
       volume - if set, convert to response per unit volume emission
               measure, i.e.:
                       +---------------+
                       |  DN s-1 cm+3  |
                       +---------------+
       rfile - The path of a genx file containing TRACE response curves.
               The standard library of curves includes two alternatives
               for elemental abundances (GREVESSE photospheric 
               abundances or FELDMAN coronal abundances), three
               possible ionization equilibria (MAZZOTTA, Arnaud &
               RAYMOND, or Arnaud & ROTHENFLUG). Most of the response
               calculations have been done for a fixed pressure of
               n_e * T = 1e15, but there is one with fixed electron
               density. The assumptions are implicit in the filenames,
               which include:
				GREVESSE_MAZZOTTA_pe1E15.resp
				GREVESSE_RAYMOND_ne5E09.resp <--Constant density
				GREVESSE_RAYMOND_pe1E15.resp
				FELDMAN_RAYMOND_pe1E15.resp         <--DEFAULT
				FELDMAN_ROTHENFLUG_pe1E15.resp
				FELDMAN_MAZZOTTA_pe1E15.resp
				GREVESSE_ROTHENFLUG_pe1E15.resp
               If the system variable !TRACE_RESPONSE exists, then that
               will be pre-pended to rfile. If not, then !TRACE_RESPONSE
               is created and initialized to "$TRACE_RESPONSE", which
               is name of the Unix/SSW environmental variable that
               points to the standard set of TRACE calibration data.
               Regardless of operating system, the !TRACE_RESPONSE system 
               variable may be set to "", enabling the use of a fully 
               qualified path for RFILE.
               MacOS: Since the OS doesn't have environmental variables,
               ~~~~~~ initialize !TRACE_RESPONSE in your IDL startup file
                      using the defsysv procedure. Note that a leading
                      colon ":" always indicates a relative path,
                      whereas full pathnames have no leading delimiter.
                      This is exactly opposite the Unix slash "/".
       inter - if set, then an interactive widget is used to select
               the genx file; the rfile keyword, if set, overrides
               the inter keyword.
       nopath- if set, the concatenation of the response file name is not done.
               This allows users to input response files from their own working
               directory, or from a directory other than the trace response library. 
PROCEDURE:
    The responses are interpolated by cubic spline
    from tabulated values in an .genx file.
    The cubic spline uses Numerical Recipes (TM) 
    algorithms and is very fast.
    The first call to trace_t_resp will take some time because
    the .genx file must be loaded. This information is stored
    in a common block so that subsequent calls will be quick
    and efficient.
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], TRACE_INIT_T_RESP
	concat_dir [4], restgen [1], restgen [2]
COMMON BLOCKS:
	TRACE_T_ENVIRONMENT
HISTORY:
	C. Kankelborg, 1998-Jul-8 written
	C. Kankelborg, 1998-Aug-6 extensive rewrite:
		-Eliminated pointers for compatibility with IDL 4
		-Converted data to .genx format. This led to modifications
		 of some SSW IDL modules to make them compatible with MacOS:
				make_str.pro     concat_dir.pro
				more.pro         which.pro
	C. Kankelborg, 1999-Feb-26 made wavelength input insensitive to
		extra whitespace. Improves compatibility with other routines.
	C. Kankelborg, 1999-Apr-21 fixed the "same" wavelength feature.
		Replaced the original sensitivity curve with a suite
		of curves using varying assumptions about abundances and
		ionization balance. The new curves were derived by Harry P. 
		Warren using Chianti 2.0 along with the latest/best TRACE 
		mirror, filter, and detector data. See the rfile keyword.
	C. Kankelborg, 1999-Apr-26 Incorporated HPW's latest calculations,
		including aa and oo filter combinations. Added /inter option.
	C. Kankelborg, 1999-May-19 Modifications to RPATH variable behavior
	D. H. Brooks,  2005-May-09 Added keyword NOPATH to allow use of response 
               files from any directory. Changed default response file from 
               FELDMAN_RAYMOND_pe1E15.resp to 
               SUN_CORONAL_MAZZOTTA_ETAL_pe1.0E15_CHIANTI_v4.2.spec
               to use Mazzotta et al. data and latest version of CHIANTI.


TRACE_TBASIS $SSW/trace/idl/util/trace_tbasis.pro
[Previous] [Next]
NAME:
	TRACE_TBASIS
PURPOSE:
	Implement three DEM basis functions, indexed 0, 1, 2,
	for use with TRACE_DEM and TRACE_DEM_SETUP.
	This is the "telescope" basis -- the response kernels
	of the TRACE EUV telescopes are used as basis elements.
	This is a natural choice since it uses positive definite
	functions that yield small values in the off-diagonal
	elements of the K matrix. This in turn reduces the 
	likelihood that any emission measure coecient will be
	negative.
 CALLS: ***
	trace_t_resp
	NOTE: This basis is NOT normalized to unit total EM.
CALLING SEQUENCE:
	result = trace_tbasis(index, T)
INPUTS:
	index - denotes which basis function is to be evaluated
		at temperature T. Valid values are 0, 1, or 2.
	T - A temperature or array of temperatures at which to
		evaluate the basis function.
MODIFICATION HISTORY:
	C. Kankelborg 5-Oct-98


TRACE_TEEM $SSW/trace/idl/util/trace_teem.pro
[Previous] [Next]
 Project     : TRACE

 Name        : TRACE_TEEM

 Purpose     : calculates temperature and emission measure from a wavelength pair of 2 TRACE images
               (e.g. 171/195 or 195/284)

 Category    : Image processing and physical parameters

 Explanation : The filter-ratio method is based on the assumption that a structure seen in two
               wavelengths is (1) isothermal, and (2) the temperature lies between the peak
               temperatures of the response functions of the two wavelength filters, T1<T<T2.
               In principle, the filter-ratio yields a non-unique solution if a temperature (T3)
               lies outside the range [T1,T2]. However, multi-valued solutions (e.g. T3>T2)
               have a very low emission measure contribution in the opposite passband (e.g. EM[T1])
               so that structures with such temperatures (e.g. T3) are likely to be dominated by
               other structures with higher emission measures EM(T1) at T1. -
               A more general approach to obtain a unique solution of an isothermal temperature
               can be calculated by TRACE_ISOTHERMAL based on 3 wavelength images.
               TRACE_TEEM requires only two wavelength images and is fast because of its vectorization,
               while TRACE_ISOTHERMAL requires three wavelength images and is much slower because of
               chi-square fit computations that are performed independently in each image pixel.

 Syntax      : IDL> trace_teem,index1,data1,index2,data2,em,te

 Examples    : IDL> read_trace,files_171,-1,index1,data1
               IDL> read_trace,files_195,-1,index2,data2
               IDL> trace_teem,index1,data1(0:200,0:200,*),index2,data2(0:200,0:200,*),em,te
               IDL> tv,bytscl(em,min=1.e27,max=1.e30) ;display EM map within specified range of EM [cm-3]

 Inputs      : data1(*,*,n) - n images of first  wavelength (e.g. 171 A)
               index1(n)    - n index structures of first wavelength images
               data2(*,*,n) - n images of second wavelength (e.g. 195 A)
               index2(n)    - n index structures of second wavelength images

 Opt. Inputs :

 Outputs     : em(*,*,n)    - n emission measure maps, EM(x,y)=Int(n_e(x,y)^2 dh)  [cm^-5]
             : te(*,*,n)    - n temperature maps       Te(x,y)                     [K]

 Opt. Outputs: None

 Keywords    : None

 CALLS: ***
	trace_t_resp
 Common      : None

 Restrictions: Meaningful combinations of wavelengths require overlap in their response function
               e.g. 171+195, or 195+284
               indes1,data1 correspond to lower  wavelength
               index2,data2 correspond to higher wavelength

 Side effects: None

 History     : Version 1,  10-MAY-1999, Sam Krucker (UCB) and Markus J. Aschwanden (LMSAL),  Written

 Contact     : aschwanden@lmsal.com


trace_tmap $SSW/trace/idl/util/trace_tmap.pro
[Previous] [Next]
NAME:
	trace_tmap
PURPOSE:
	Compute temperature and emission measure maps
	based on an isothermal model. A single
	temperature and emission measure is derived
	for each pixel.
CALLING SEQUENCE:
	trace_tmap, index, data[, tmap=tmap, em=em, chisq=chisq, /debug]
 CALLS: ***
	MATT_20_16, TT_BADNESS
EXAMPLE:
	read_trace, filename, ss, data, index
	temperature = 1e6 ;initial guess
	trace_tmap, data-83, index, T_guess=temperature, tmap=tmap, em=em
		;In the example, readout pedestal is assumed to be 83 DN. 
		;An initial guess of 1 million K is passed in through the
		;T parameter, which is also used to output the resulting
		;temperature map.
INPUTS:
	data = TRACE data cube, presumed to be a set of co-aligned images
		taken at about the same time. Only EUV images (171, 195, 284) will
		influence the computation. Readout pedestal (approximately 83 DN) 
		must be subtracted from data prior to feeding it to trace_tmap.
	index = TRACE index data structure (see READ_TRACE). Some tags
		are required: sht_mdur, wave_len
KEYWORDS:
	tmap - Output temperature map.
	T_guess - a temperature map (if an array) or single temperature
		(if a scalar) as a first guess. Default = 1.5e6.
	em - Output emission measure map.
	chisq - Output chi squared, indicating the badness of fit for the
		isothermal model.
	dT - Initial size of simplex (Tguess, Tguess+dT). Default = 5e4.
PROCEDURE:
	Iterative least-squares fit using trace_t_resp().
MODIFICATION HISTORY:
	C. Kankelborg, 17-September-1998


TRACE_UNDIFFRACT $SSW/trace/idl/util/trace_undiffract.pro
[Previous] [Next]

function trace_undiffract, index, data, satlevel=satlevelin, $
                           pedestal=pedestalin, guess=guessin, $
                           guard=guard

NAME:
     TRACE_UNDIFFRACT
PURPOSE:
     Remove the diffraction pattern from TRACE images
CATEGORY:
CALLING SEQUENCE:
     newimage = trace_undiffract(index,data)
INPUTS:
     index = data index
     data = image(s).  To get enough orders in the diffraction pattern the
            image should be as large as possible given memory/time
            constraints.  fltarr(nx,ny,ni)
OPTIONAL INPUT PARAMETERS:
KEYWORD PARAMETERS
     satlevel = Saturation level.  Any values above this are considered
                saturated. Default = 4050.  This is a reasonable value for
                compressed images, but uncompressed images should have
                satlevel set to 4095.
     pedestal = Pedestal level.  Subtracted before the deconvolution and
                re-added at the end.  If the pedestal has already been
                subtracted, be sure to set this to zero!  Default = 86.
     guess = The guess is only important when there are saturated pixels in
             the image.  There are 3 possibilities for the initial guess:
             1. fltarr(nx,ny,ni).  User defined initial guess for deconvolved
                image(es).  Must be the same dimension as data.
             2. If guess is a nonzero scalar (i.e. /guess) then the initial
                guess is set to the deconvolution:
                      fimage = fft(image,+1)
                      fpsf=fft(shift(psf,-floor(nx/2),-floor(ny/2)),+1)
                      guess = float(fft(fimage/fpsf,-1))
                /guess is generally the best choice for speed but does not
                work well if there are saturated pixels.
             3. Otherwise (default), guess is set to the raw image.
                The default is slow, but generally more accurate when there
                are saturated pixels in the image.
     guard = Puts a guard ring of zeroes around the image as padding for the
             FFT.  For example, if guard=64, then a 64 pixel ring is put
             around the image and the size of the image is increased by
             64*2=128 in each dimension. The guard ring is removed before 
             the image is returned.  Since the TRACE diffraction pattern
             is quite broad, it is *very important* to include a sufficiently
             large guard band.  For speed, the final dimension, including the
             guard band, should be a power of 2, since FFT's are used 
             throughout.
OUTPUTS:
     newimage = image with diffraction pattern removed
 CALLS: ***
	IMAGE_DECONVOLVE, TRACE_DIFFRACTION_PATTERN [1]
	TRACE_DIFFRACTION_PATTERN [2], TRACE_DIFFRACTION_PATTERN [3]
	TRACE_INVERT_DIFFPATT
COMMON BLOCKS:
SIDE EFFECTS:
     Extremely slow.
RESTRICTIONS:
     Any pixels GE satlevel are considered saturated and treated differently
     that the rest of the image.  When there are saturated pixels, the 
     intensity at these pixels is estimated from the diffraction pattern, 
     but it is not known how good (or bad) this estimate is.

     The deconvolution is done with the FFT so the dimension of the
     data, including the guard band, should be a power of two for speed.

     When there are saturated pixels, the intensity at these pixels is
     estimated from the diffraction pattern, but it is at best a crude
     estimate.  Also,  the algorithm can't necessarily tell whether the
     diffraction pattern is in fact a real solar feature.  Hence the "other"
     solution is for the saturated areas to have a *low* intensity.  Watch
     out for this.  

     This code is still experimental!  In particular, the statistics of
     convergence are not consistent from one image to the next.  This needs
     to be understood.
PROCEDURE:
MODIFICATION HISTORY:
     T. Metcalf  2000-March-24
     T. Metcalf  2002-Oct-25   Changed the way sigma is calculated
                               for saturated pixels.  Increase sigm
                               of saturated pixels and all affected
                               pixels by sqrt(sigma).
     T. Metcalf  2003-Jan-30   Fixed bug which did not allow satlevel
                               to be passed in.


trace_uniq_movies $SSW/trace/idl/util/trace_uniq_movies.pro
[Previous] [Next]
   Name: trace_uniq_movies

   Purpose: identify uniq movies from input structures (index or catalog)

   Calling Sequence:
      (generally called from cron/movie/image maker routines)
      
      umovies=trace_uniq_movies(input)       ; return uniq movie records
      ss=trace_uniq_movies(input, umovrec)   ; subscripts of 'current' movie  

   Output:
      Function return depends on #params:
         1 input param - return sequence summary structures of uniq movies
         2 input params - return SS for specified summary structure
  
   Keyword Parameters:
      minnx - ignore sequences with NX < this number
      minny - ignore sequences with NY < this number
      nosht_mdur - if set, ignore exposure duration param (.SHT_MDUR)

 CALLS: ***
	BOX_MESSAGE, FSTRING, STR2ARR [1], STR2ARR [2], UNIQ [1], UNIQ [2], UNIQ [3]
	XMENU_SEL [1], XMENU_SEL [2], data_chk [1], data_chk [2], get_infox, required_tags
	str2cols [1], str2cols [2], str_replace [1], str_replace [2], strjustify
	trace_index2macrofov
 CALLED BY:
	trace_last_movie [1], trace_last_movie [2], trace_last_movie [3]
	trace_movie_context, trace_special_movie [1], trace_special_movie [2]
	trace_special_movie [3], trace_special_movie2
   History:
     24-Apr-1998 - S.L.Freeland - assist in auto-movie-making
      6-May-1998 - S.L.Freeland - include call to 'trace_index2macrofov'
     12-Jun-1998 - S.L.Freeland - add Exposure time (SHT_MDUR)
     15-sep-1998 - S.L.Freeland - fix sou_ara (catalog change int-ntnt->byte)sou_
     16-Jun-1999 - S.L.Freeland - add NX/NY to structure, minnx & minny input
     26-Jun-2000 - S.L.Freeland - add /NOSHT_MDUR keyword and function  

   Method:
      look at observing program, wavelenths, source area and FOV
      to determine 'uniq' data sets in input   


trace_unspike $SSW/trace/idl/util/trace_unspike.pro
[Previous] [Next]
 NAME:
	trace_unspike
 PUPROSE:
	To remove bad pixels due to cosmic ray hits. The default
	parameters are reasonable for most TRACE EUV images.
	Note that particle hits skimming the detector ("streaks")
	are best removed by trace_destreak.
 CALLING SEQUENCE:
	result = trace_unspike(image[, sens=sens])
 INPUTS:
	image = 2-dimensional image
 OPTIONAL KEYWORD INPUTS:
   SENS = sensitivity to spots
   (sens = 1.5 is default; for UV, 0.4 is better)
	CLEANJPG = if set, call trace_cleanjpg(). This cleans up
		the residue JPEG artifacts from the particle hits.
 CALLS: ***
	ck_smooth, trace_cleanjpg
 CALLED BY:
	TRACE_PREP, focus_trace_flt, trace_make_tma, trace_special_movie [1]
	trace_special_movie2
 PROCEDURE:
	Spikes, i.e. bright pixels, are amplified and located by
	convolution and thresholding. This information is used to
	generate a map of bad pixels. The bad pixel map is then
	revised to include nearest neighbors.
 SIDE-EFFECTS:
	image is converted to a float array, if it's not already.
 MODIFICATION HISTORY:
	1998-Jun-18 CCK


trace_unspike_time $SSW/trace/idl/util/trace_unspike_time.pro
[Previous] [Next]
 Project     : TRACE - CDS

 Name        : trace_unspike_time

 Purpose     : temporal despiking of TRACE images using neighbor images

 Category    : Image processing

 Explanation : This algorithm cleans up spiky pixel in TRACE images which are either
		high because of a cosmic ray hit or represent "hot pixels" that are 
		temporarily enhanced. Because this algorithm is based on spatial and
		temporal next neighbors (from the 3x3x3 cube around the spiky pixel) it 
		requires a 3D data cube with a sequence of images DATA(*,*,NTIMES), 
		NTIMES>3. It filters out noisy spikes that exceed a threshold factor THRES 
		above the average of 2x8 nearest spatial neighbors of the preceding and
		following image. The 8 nearest spatial neighbors in the simultaneous image
		are not used because of the ring-like sidelobes produced by the jpeg compression
		around a cosmic ray hit. The spiky pixel is replaced by the average of the
		nearest 2 temporal pixels if the spikly pixel is a cosmic ray hit but 
		not a "hot pixel". The noisy pixel is replaced by average of the 2x8 nearest 
		(non-simultaneous) spatial neighbors if it is a "hot pixel".
		This algorighm works similar to TRACE_DESPIKE and TRACE_DESTREAK, 
		but seems to produce cleaner images for long exposure times where 
		cosmic ray hit rate is high. Multiple iterations of this algorithm are 
		recommended for deep cleaning (e.g. THESH=1.15), while a single iteration
		if sufficient for coarse cleaning (e.g. THRESH=1.5).
		This IDL algorithm is a vectorized version. 


   Input Parameters: 
      index, data - standaard read_xxx 'index,data' output
 
   Output Paramters:
      outindex - optional, index with .HISTORY updated 

    Keyword Parameters:
      threshold - sensitivity threshold, default = 1.5
      verbose/loud (synonyms) - if set, be noiser to TTY
      display - if set, display to image device
      logfile - if string, name of logfile to write statistics too
                if set (/LOGFILE), log to $HOME/trace_unspkike_time.dat
      new - if set and logfile defined or set, force new logfile (def=append)
      update_hist - if set, update .HISTORY tag of input index vector
                    [optionally, can return same in 3rd parameter to avoid
                     clobbering input]
  
    Calling Sequence:
       cleaned=trace_unspike_time(index,data [theshold=threshold] , $
                   [ /verbose, /loud, /logfile, /display]
    History
      Version 1,  30-MAR-1990,  Markus J. Aschwanden, LMSAL,  Written
      Version 2,  19-July-1999, S.L.Freeland, LMSAL, rename ->function
                   sswify it, remove explicit LUN, make it quiet
                   by default, make logging statistics optional
      Version 2.1 20-July-1999, S.L.F. added UPDATE_HISTORY keyword and function
      Version 2.2 15-Sep-1999,  S.L.F. correct a call to 'concat_dir'

   
 Contact     : aschwanden@lmsal.com
 CALLS:


trace_uv_resp $SSW/trace/idl/util/trace_uv_resp.pro
[Previous] [Next]
 NAME:
    trace_uv_resp.pro

 PURPOSE:
    Return the TRACE response for the various UV channel bandpasses.

 CALLING SEQUENCE:
    result = trace_uv_resp(band, lambda=lambda)
 
 INPUTS:
    band   - Wavelength bandpass.  Options are:
             1216
             1216L
             1550
             1550L
             1600
             1700
             WL
             OPEN (No analysis filters.)
    lambda - Wavelengths to spline response over.  Default is 
             indgen(1300)+1200.  Response beyond 7000 A is just extrapolation
	
 KEYWORD PARAMETERS:
    amp_b - If set, use amplifier gain for Amplifier 'B', 42 e/sec.
            Default is Amplifier 'A', 11 e/sec.

    file  - Response GENX file to use.  Defaults to the most recent
            present in $SSW/trace/response.  Mostly for testing.

 OUTPUTS:
    result = TRACE response as a function of wavelength in 
             units of DN/s/pixel per ph/cm^2/s/sr.  Convolving this 
             function with a solar spectrum will yield expected TRACE
             count rates.

 CALLS: ***
	BOX_MESSAGE, DATATYPE [1], DATATYPE [2], DATATYPE [3], FILE_EXIST [2], INTERPOL
	file_exist [1], file_exist [3], file_list [1], file_list [2], last_nelem
	restgen [1], restgen [2], restgenx
 EXAMPLE:


 MODIFICATION HISTORY:
    01-Jun-1999 (BNH) - Written
    14-Mar-2002 (TDT) - Wavelength range extended, use restgenx and restgen


trace_wave2point $SSW/trace/idl/util/trace_wave2point.pro
[Previous] [Next]
   Name: trace_wave2point

   Purpose: apply wavelength dependent adjustments to trace pointing tags

   Input Parameters:
      index - index structure vector (read_trace output) or catalog recs.

   Output:
      function returns wavelenth adjusted indices (xcen/ycen/.HISTORY)
  
   Keyword Parameters:
      version - (output) - version number of this routine
      xyoff   - (output) - [2,N] - XY offsets 
      noapply - (switch) - if set, do not apply or update history
      undo    - (switch) - if set and .HISTORY available, undo the correction
  
   Calling Sequence:
      newind=trace_wave2point(index [,/noapply] [,version=xx] )
      
   Calling Examples:
      newind=trace_wave2point(index)           ; adjust xcen/ycen/history
      newind=trace_wave2point(index,/quiet)    ; minimize tty chatter
      newind=trace_wave2point(index,/noapply,xyoff=xyoff) ; just return XYOFF

 CALLED BY:
	TRACE_PREP, trace_sub2point
   History:
      3-November-1998 - S.L.Freeland - Version 1.0 - Offsets derived from 
                         R.Shine/T.Tarbell email: Tue, 03 Nov 1998 10:49:27

	9-Nov-98 - TDT - changed signs of all offsets 
       5-Jul-99 - S.L.Freeland - trim 'indwaves' string to assure match!
       8-Nov-2000 - S.L.Freeland - ajdust crpixN using adjusted xcen/ycen
  
   Calls: ***
	BOX_MESSAGE, COMP_FITS_CRPIX, STR2ARR [1], STR2ARR [2], anytim [1], anytim [2]
	anytim [3], anytim [4], anytim [5], data_chk [1], data_chk [2], get_history
	gt_tagval [1], gt_tagval [2], reltime [1], reltime [2], required_tags
	update_history
   Restrictions:
      input structure vector must include XCEN,YCEN,WAVE_LEN and time fields
      UNDO not yet implemented


trace_wavename2num $SSW/trace/idl/info/trace_wavename2num.pro
[Previous] [Next]
   Name: trace_wavename2num

   Purpose: map from string name ('171', '195' etc) -> index/catalog.wave_num

   Input Parameters:
      input - string of form 'xxx [,yyy, zzz']
     
   Output:
      function returns number equivilent (pass to trace_where, for example)

   Calling Example
      wnum=trace_wavename2num
  
 CALLS: ***
	BOX_MESSAGE, STR2ARR [1], STR2ARR [2], data_chk [1], data_chk [2], str_replace [1]
	str_replace [2]
   History:
      10-Sep-1998 - S.L.Freeland - for TRACE WWW/IDL catalog optimization


trace_where $SSW/trace/idl/util/trace_where.pro
[Previous] [Next]
   Name: trace_where

   Purpose: filter trace index/roadmaps - return indices of matches

   Input Parameters:
      index - TRACE input structures
 
   Output Parameters:
      count - number of matches

   Keyword Parameters:
      conf_file - name of SS configuration file 
      quite - if set, suppress messages
        
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], FILE_EXIST [2], concat_dir [4]
	file_exist [1], file_exist [3], get_logenv [1], get_logenv [2], gt2exe [1]
	gt2exe [2], rd_tfile [1], rd_tfile [2]
   History:
       2-Feb-1998 - S.L.Freeland - adapt sxt_where to TRACE


trace_write_genxcat $SSW/trace/idl/info/trace_write_genxcat.pro
[Previous] [Next]

    Purpose: write trace 'catlog' files in genx format (via write_genxcat)

 CALLS: ***
	BOX_MESSAGE, CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], concat_dir [4]
	data_chk [1], data_chk [2], get_logenv [1], get_logenv [2], gt_tagval [1]
	gt_tagval [2], gtt_info, mxf_read_header, read_trace, set_logenv [1]
	set_logenv [2], str_replace [1], str_replace [2], str_subset, timegrid
	trace_files, write_genxcat
    History:
      30-Mar-1998 - S.L.Freeland
       5-May-1998 - S.L.Freeland - extended keywords->SSW/pointing versoin  
      26-aug-1998 - S.L.Freeland - add /ENGINEERING keyword and function
       5-sep-1998 - S.L.Freeland - pass DAY_ROUND and HOUR_ROUND to 
                                   write_genxcat call (for uniq name/24 hour)
      10-sep-1998 - S.L.Freeland - add /NELEMENTS and /DAY_ROUND to 
                                   write_genxcat call, 
                                   reuced keywords dbase and keyword list

      28-Jan-1999 - S.L.Freeland - add jpeg quality to COMP_CODE
                                   [xxQQQQQC]
                                      -----|                                  
                                        |  C=COMP Code
                                        |Q=Quality (gtt_info(xx,'COMP_QT')


tracedespike $SSW/trace/idl/util/tracedespike.pro
[Previous] [Next]
NAME:    tracedespike.pro    
PURPOSE: despike an image using a median filter (default) that eliminates
         spikes exceeding `threshold' percent (detault = 15%), or using a
         statistical correction that corrects pixels diviating by more than
         `statistics' sigma from the expected noise given the photon
         statistics and electron-to-DN amplifiction.
SUBROUTINES: none
CALLING SEQUENCE: image=tracedespike(image)
OUTPUT: returns despiked image array
 CALLED BY:
	TRACE_PREP
EXAMPLE: 
  imout=tracedespike(readfits('file'))        simple correction
  imout=tracedespike(despike(image))          double correct. for faint fields
  imout=tracedespike(image,statistics=6)      correct > 6sigma outliers
  imout=tracedespike(image,minimum=100,ri=3)  low-quartile corr. above I=100
  imout=tracedespike(image,nspikes=nspikes,imap=imap) to return the number of
                                              spikes removed and a pixel map
OPTIONAL KEYWORD INPUT:
  nspikes	       number of spikes removed
  imap                map of corrected pixels
  ri                  replacement index: ri=7 or 8 for median filter
  threshold           fractional threshold for brightness
  minimum             do not correct pixels dimmer than minimum
  statistics          use statistical correction beyond stat.. sigma
  ampl                amplification of CCD signal
HISTORY:
 Karel Schrijver, 20 May 1998.
 Revised: CJS     27 May 1998: changed loop counter to long word
 Revised: CJS     09 Mar 1999: changed to return repair mask
          SLF     09 Mar 1999: added LOUD keyword (no function but interface
                               compatible with earlier version)

 CPU time scales roughly linearly with the size of the array

 Note that there are two mutually exlusive keyword sets:
  for criterion of relative intensity: threshold, minimum
  for statistical correction:          statistics, ampl