RADEC_FILL $SSW/cgro/batse/idl/radec_fill.pro
[Previous] [Next]
  Name:
       RADEC_FILL
 radec_fill looks for gaps in the  pointing data (value is 0 in gaps).
 (There are gaps in the pointing data when the data was sent using the
 omni directional antenna and a compressed data format was used.)
 If there was any good data passed into radec_fill, it will perform a
 linear fit to determine the values to insert into the arrays to fill the
 gaps.  It then saves the latest pointing data and time in radec_save
 in common radec_com.  The next time it is called, if there is no good 
 pointing data in the entire passed interval, it will insert the values
 that were stored in radec_save in the xra,xdec,zra,zdec arrays if the
 the current time is within 12 hours of the time of the saved pointing.
 CALLS: ***
	POLY_FIT
 CALLED BY:
	CONT_READ, DISCSP_READ, FDBREAD, FS_ACC, READ_DISCLA, WRITE_FDB
 NOTE:  the sec array passed into radec_fill contains only every other
        point from the original seconds array, so there is a one-to-one
        correspondence between elements in sec and xra,xdec,zra,zdec.

Similar to qlradec_fill which is used in qlarchive.  Difference is that 
 pointing arrays are passed in in separate arrays here (can't pass in 
 just the subarrays because then can't change the values), and here we look
 to see if radec_save pointing values were within 12 hours of current time
 before restoring (if current interval doesn't have any good data).

 K. Tolbert 3/93
 Mod. 6/2/93 by KT. One use elements that have real times.  Gaps in data
  will have times of .512 and zero for everything else.  Don't want to 
  use them.


RATESDUMPOC $SSW/cgro/batse/idl/ratesdumpoc.pro
[Previous] [Next]
  Name:
       RATESDUMPOC
 pro ratesdumpoc
 Operator communications for the task to dump BATSE rates data.

 Kim Tolbert   10/8/91

 Modified 4/5/95 by AES - usefdb had been left out of dumpcom declaration -
	   		   added it so it works with rawdump
 Version 2 		 - eva@kano.nascom.nasa.gov, 09-Feb-2000
			 - Increased default time-range from 10s to 15s
	   
********************************************************************
 CALLS:
 CALLED BY
	pro ratesdump


RATIO_PL $SSW/cgro/batse/idl/ratio_pl.pro
[Previous] [Next]

 NAME: 
       RATIO_PL

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


RAWDUMP $SSW/cgro/batse/idl/rawdump.pro
[Previous] [Next]

 NAME: 
	RAWDUMP

 PURPOSE:
 	Controls the dump of raw BATSE data between selected times for selected detectors.

 CATEGORY:
	BATSE

 CALLING SEQUENCE:
	RAWDUMP, X

 CALLS: ***
	ASCII_RAW, CHECKVAR [1], DD_CLOSE, FILELIST, FIND_DBFILE, LOC_FILE [1], LOC_FILE [2]
	LOC_FILE [3], MORE [1], MORE [2], Mailfile, PATH_DIR, RAWDUMPOC, READ_SEQFILE
	YOHKOH_FORMAT [1], YOHKOH_FORMAT [2], checkvar [2], curdir [1], curdir [2]
	hxrbs_format, yohkoh_format [3]
 INPUTS:
       X- dummy argument
	The rest of the arguments through DUMPCOM
	usefdb, dd_open, dd_type, sec_st, sec_to, sec_en, det_arr

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	batse_menu
 COMMON BLOCKS:
	DUMPCOM

 SIDE EFFECTS:
	!quiet is set

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
 Kim Tolbert   3/28/91

 Modified by Amy Skowronek 6/28/94 - detector array now goes from 0-7
 rather than 1-8
 Documented, ras, April, 1996
 VERSION 4, richard.schwartz@gsfc.nasa.gov, 26-aug-1997,
 used loc_file with path_dir('batse') to locate help files.


RAWDUMPOC $SSW/cgro/batse/idl/rawdumpoc.pro
[Previous] [Next]

 NAME: 
       RAWDUMPOC

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS: ***
	ALPHA_PAGE [1], ALPHA_PAGE [2], ATIME [1], ATIME [2], BATSE_TIME_INPUT, CH_SELECT
	FIND_DBFILE, GETUT [1], GETUT [2], SETUT [1], SETUT [2]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	RAWDUMP
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


RD_BATSE_511CAL $SSW/cgro/batse/idl/rd_batse_511cal.pro
[Previous] [Next]
 NAME:
	RD_BATSE_511CAL

 PURPOSE:
	Read the compressed calibration files from perm_data.
	Return the 511 channel number for the date and detector for
	the BATSE SPECs.

 CATEGORY:
	BATSE, SPEX, calibration

 CALLING SEQUENCE:
	Result = RD_BATSE_511CAL(tjd, detector_id)
	
 INPUTS:
	Tjd:	Time for calibration. Calibration returned will be for time
		just before TJD.  Units are Truncated Julian Day.
		1-Jan_1979 00:00:00.000 UT is 3874 in TJD.
	Detector_id:
		SPEC detector for calibration line.

 OPTIONAL INPUTS:
	None
 OPTIONAL OUTPUTS:
	None

 KEYWORD PARAMETERS:
	TJD_FOUND: time in tjd of calibration record used
	PAST_DATE: time requested is after last calibration measurement
		   Possible error!!!!!
	ALL: Returns the entire file for that detector as a structure
	with tags:
		UT  - Time in sec from 1 Jan 1979 (TJD= 3874 @ 1 Jan 1979)
		N511- The linear channel number of the 511 keV line.
		DET_ID-
 OUTPUTS:
	Result is the linear channel number of the position of the 511 keV line,
	typically ranging from around 40 (for a gain of 0.4X) to 1100 for a gain 
 	of 8X.

 CALLED BY:
	GET_DISCSP511
 PROCEDURE:
	Compressed calibration file is opened and searched for the time
	just before the requested time. 

 CALLS: ***
	CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], INTERPOL
	concat_dir [4]
 EXAMPLE:
	tjd  = 8900 ;5-oct-1992
	id   = 0    ;SPEC 0
	line = RD_BATSE_511CAL(tjd, id)
	print, line
	1108.42

 MODIFICATION HISTORY:
 	Written by:	ras, 1-dec-1995
			Version 2, RAS, 2-Dec-1996
               RAS, 7-Jul-1997, changed PERM_DATA to SSWDB_BATSE
	16-sep-1997, richard.schwartz@gsfc.nasa.gov, need only be within 100 days
		for final approach in search algorithm.  Changed from 10 days.


rd_spec $SSW/cgro/batse/idl/rd_spec.pro
[Previous] [Next]

 	Read in spectral accumulation files produced by the 
	BATSE Spectral Analysis Software (BSAS).
	Suitable for reading SHERB, SHER, HER, and HERB data produced
	by the routine COUNT in BSAS.
	Probably suitable for reading in any data accumulated by COUNT.

	RD_SPEC reads DMIN (minimum energy), DMAX (maximum energy), DATA
       (rate), and SIGMA (error in rate) from FILENAME (a binary .SPC file 
	created by BSAS for a particular time interval of a particular BATSE 
	burst) into a floating point array, SPEC.
	If spectrum is not read properly, error will be set to 1.

	Returns PHA and DISC - count rates in the PHA and Discriminator
	channels in a 4 x Number of Channels array where each row is:

	Emin (keV),  Emax,  Rate (cnts/(s keV cm^2)), Sigma_Rate
 CALLS:


READ_BATSE_DD $SSW/cgro/batse/idl/read_batse_dd.pro
[Previous] [Next]
 Project:
       SDAC
 Name:
       READ_BATSE_DD

 CATEGORY:
       BATSE

 Purpose:

	Read in BATSE data from Daily Dataset (DD) structures
	Suitable for DISCLA, CONT, and DISCSP data types
 Calling sequence:

	READ_BATSE_DD, filename, data_str, data, seconds, maxindex,
		fdr, audit_trail, error=error, new=new

 Inputs:	Filename - full file descriptor for DD BATSE file in native
		format.
		Data_str - data structure for reading and unpacking count data
			   data is packed in file as unsigned integer*2
		New - if set then DATA and SECONDS are created if if extant

 Outputs:	Data - Count data unpacked as whole numbers into 
			 fltarr( nch, ndet, nrep * npck)
				nch - number of energy bins
				ndet - number of detectors		
				nrep - cycles per packet
				npck - maximum number of packets allowed
			DATA is dimensioned by the calling program,
			if not, or insufficient then the dimensions are 
			set from DATA_STR and the number of packets 
			Seconds must be consistent with Data
			 
		Seconds - time in s from 79/1/1 for each time interval
			  dblarr( nrep, npck)

		Maxindex - nrep*npck -1

		FDR - header record

		AUDIT - Audit records

 CALLS: ***
	CONV_VAX_UNIX, SC_SECONDS_ED, SIZE_STRUCT
 Restrictions:  Must provide data structures.  File Definition Record
		 includes NUM_AUDIT_REC tag name specifying the
		 number of data records.  
		 Data Structures are found in these files.
		 CONT   - CONT_MSFC_STR.PRO and CONT_STR.PRO
		 DISCSP - DISCSP_MSFC_STR.PRO and DISCSP_STR.PRO
		 DISCLA - DISCLA_STR.PRO

 History:
 ras, 93/1/21
 modified, 9 aug 93, ras, reads into a single byte buffer, then extracts
	cont and seconds
 17-oct-93, ras, fixed findfile test problem.  Doesn't use output of
	findfile for file.
 Version 4, richard.schwartz@gsfc.nasa.gov, 2-sep-1997, cleaned documentation
	added conv_vax_unix if we're reading on a unix platform. 


READ_BDAS_DRM $SSW/cgro/batse/idl/read_bdas_drm.pro
[Previous] [Next]

  Name:
       READ_BDAS_DRM


 PURPOSE: input into IDL session the detector response matrix created from
	the response generator at MSFC on animaldsk2:[schwartz.lad_response]
	or animaldsk2:[schwartz.matrix].  The matrix is returned in the 
	same units as for the BSAS generator cnts/keV/cm2 output per 
	photon/bin/cm2 input.
	

 CATEGORY:  I/O for fitting
       BATSE

 CALLING SEQUENCE: Read_bdas_drm, file=file, drm=drm, head=head, $
	raw_drm= raw_drm, area=area


 INPUTS: file - complete name of data file
	  /rdhead - only read the header       

 OUTPUTS:
	drm - response matrix as found in file, (nobins_out,nobins_in)
	scaled a la BSAS
	raw_drm - matrix as output by generator, i.e. counts/bin for
	plane wave of flux 1 photon/bin/cm2, input to map_matrix.pro
	area - Detector area for elevation angle of 90 degrees
		127 cm2 for SPEC and 2025 cm 2for LAD

       head - structure containing info on drm creation
	head.file - filename (bytarr(80))
	head.position - source phi, theta, earth, phi, theta in GRO coord. (deg)
	head.det_type - SPEC or LAD , bytarr(4)
	head.drm_type - e.g. 'DIRECT  ', 'SCATTER ','TOTAL   ', bytarr(8)
	head.mat_vers - version of response generator program , bytarr(12)
	head.detid - detector id (0-7)
	head.nobins_in - number of input photon bins
	head.nobins_out - number of output energy loss bins
	head.e_in - input energy edges  (2,nobins_in)
	head.e_out - output energy edges (2,nobins_out)

 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONV_VAX_UNIX, break_file [4]
 CALLED BY:
	LAD_DRM, Load_sher, SETUP_DRM
 MODIFICATION HISTORY: ras, 22-June-1993
		        ras, 1-feb-1994, made it unix compatible by adding the
			pad for each readu


READ_CAL_SPEC $SSW/cgro/batse/idl/read_cal_spec.pro
[Previous] [Next]

  Name:
       READ_CAL_SPEC


 PURPOSE:  read calibration line data for BATSE SPEC detectors


 CATEGORY:  spectral analysis, SPEX, BATSE


 CALLING SEQUENCE:  read_cal_spec


 CALLED BY:


 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], MINMAX [1], MINMAX [2]
	concat_dir [4]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	flare - an array or single flare number

 OUTPUTS:
       out_rec - 1 or more cal_spec records determined by flare

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	CALIB_HIST
 COMMON BLOCKS:
	cal_catalog

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	must pass valid flare numbers, implemented only in vms

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 15-feb-95
               RAS, 7-Jul-1997, changed PERM_DATA to SSWDB_BATSE


read_cat $SSW/cgro/batse/idl/read_cat.pro
[Previous] [Next]
 Project:
	SDAC
 Name:
       read_cat
  

 PURPOSE:
 Procedure to read the BATSE flare catalog into common flare_catalog.
 If it has already been read (num_flares is already defined), it doesn't read
 it unless force_read equals one.
 Previously read catalog directory into an array of structures.  It was 
 reading each record singly and taking a long time.  If read this way (into
 an associated variable byte array that's big enough to hold the whole thing,
 only does one read - much faster.  But then need to extract the fields into
 the array of structures to use them later.  This is relatively fast.

 CATEGORY:
	 batse archive i/o

 CALLING SEQUENCE: 
	read_cat, [/force]

 CALLED BY:


 CALLS: ***
	CHKLOG [1], CHKLOG [2], CONV_VAX_UNIX, USE_VAX_FLOAT, printx [1], printx [2]
 INPUTS:
 	force - if set then (re)read the catalog

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 COMMON BLOCKS:
	flare_catalog

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:

 Kim Tolbert  7/91
 Mod 2/2/94 to be Unix compatible.
 Mod 2/7/94 to extract two new fields - sun_position and earth_position
 Mod 22-March-94, ras, to support installation on Unix machines, elim assoc read
 ras, 12 apr 95, switched to reading and writing byte arrays
 Version 6, richard.schwartz@gsfc.nasa.gov, 24-jun-1998, forced old VAX float format on write.


READ_COEF $SSW/cgro/batse/idl/read_coef.pro
[Previous] [Next]
  Name:
       READ_COEF
c****************************************************************************
c	      pro read_coef, spec_lld

c     This subroutine reads in some of the necessary coefficients stored in 
c     external data files. The coefficients are passed in common blocks 
c     to the main routine.  In addition, the subroutine calculates the
c     SLED correction appropriate to the detector's LLD setting.
c
c     The SLED correction is d* (1.-tanh(b*(x-c)) up to 'cut'.
c     I assume that 1./b and c increase linearly with the LLD, while
c     d should remain constant.
c
      The relevant data files are found on SSWDB_BATSE in ASCII
      and XDR format save sets
      
c     Input:
c        spec_lld--LLD setting of spectrum to be calibrated
c     Output:
c        sled_com--common block with sled correction coefficients
c        fiducial_com--common block with calibration equation parameters
c
;c     written 12/6/91 LAF; last modifed 4/7/92 DLB
c
c****************************************************************************
c
               RAS, 7-Jul-1997, changed PERM_DATA to SSWDB_BATSE
 CALLS:
 CALLED BY
	CALIBRATE [1], TEST_CAL


READ_COMPRESSED $SSW/cgro/batse/idl/read_compressed.pro
[Previous] [Next]

 NAME: 
       READ_COMPRESSED

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS: ***
	FXBCLOSE [1], FXBCLOSE [2], FXBOPEN [1], FXBOPEN [2], FXBOPEN [3], FXBREAD [1]
	FXBREAD [2], FXBREAD [3], HEADFITS [1], HEADFITS [2], HEADFITS [3], SXPAR [1]
	SXPAR [2], SXPAR [3]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	PLOT_DRM
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


READ_CONT $SSW/cgro/batse/idl/read_cont.pro
[Previous] [Next]

  Name:
       READ_CONT


 PURPOSE: read continuous data type from native format or fits files


 CATEGORY: data i/o
       BATSE

 CALLING SEQUENCE: read_cont, cont=cont, seconds=seconds, file=file, $
		fits=fits, start_time=startt, end_time=endt

 CALLS TO:
	read_fits, read_cont_fits, read_dd, cont_msfc_str,
	fdr_msfc_str, audit_trail_str

 INPUTS:
       file - data file
	fits - if set, assumes fits file
 OPTIONAL:
	start_time - start reading after this time (anytim readable)
	end_time   - end reading before this time

 OUTPUTS:
       cont - Continuous data, fltarr(16,8,npackets), signed but raw
	seconds - Center times for each packet, seconds since 79/1/1
	
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], DATATYPE [1], DATATYPE [2]
	DATATYPE [3], READ_CONT_FITS, SC_SECONDS_ED, anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], break_file [4], read_dd
 CALLED BY:
	PLOT_OCCS, read_batse_4_spex [1], read_batse_4_spex [2]
 RESTRICTIONS: 
	Fits files cannot be read across network.  Readfits uses
	the IDL EOF function.

 PROCEDURE:
	For native format record oriented, uses READ_DD
	For FITS uses READ_CONT_FITS


 MODIFICATION HISTORY: ras, 9 aug 93
			ras, 1 Sep 93, added 1.024 second to non-fits accum.
		        ras, 15-jul-93, added true binary table possibility in read_cont_fits
			if so, then structure not returned ,  seconds must be converted
			ras, 30 jul 95, fixed bug in test of data_str


READ_CONT_FITS $SSW/cgro/batse/idl/read_cont_fits.pro
[Previous] [Next]

  Name:
       READ_CONT_FITS


 PURPOSE: Read FITS files at GROSSC of CONTinuous data type for BATSE


 CATEGORY: I/O
       BATSE

 CALLING SEQUENCE: str = read_cont_fits( File[, ut_str, cont])

 CALLS TO:  cont_msfc_str, sc_seconds_ed, readfits, utime2str, mrdfits_spectra

 INPUTS: file- full file name
       none explicit, only through commons;

 OPTIONAL INPUTS:
	The following inputs only apply to mrdfits_spectra readable files
	start_time - extract data after this time, anytim.pro formats
	end_time   - extract data up to this time
 OUTPUTS:
	ut_str- time structure interpretable by anytim.pro, mid-point of integration interval
	cont  - cont data, counts, 16 channels x 8 detectors x n time bins, unsigned integers
	head1 - primary fits header
	head2 - header of first extension
 OPTIONAL OUTPUTS:
	none

 CALLS: ***
	FXPAR [1], FXPAR [2], HEADFITS [1], HEADFITS [2], HEADFITS [3], READFITS [1]
	READFITS [2], READFITS [3], SC_SECONDS_ED, Utime2str [1], Utime2str [2]
	load_struct, mrdfits_spectra
 CALLED BY:
	READ_CONT
 COMMON BLOCKS:
	none

 SIDE EFFECTS: SC_SECONDS_ED assumes time error early in mission as of
	93/06/29, this may cause errors in the times of these files.

 MODIFICATION HISTORY: ras, 93/06/29
	 		ras, 14-apr-94, mod to use load_struct
			ras, 15-jul-95, added start_time, end_time, mrdfits_spectra capability
			ras, 18-ju0-95, make sure data is 16x8xn


read_dd $SSW/cgro/batse/idl/read_dd.pro
[Previous] [Next]
 Project:
       SDAC
 NAME:
	read_dd
 PURPOSE:
	This procedure reads BATSE data files and extracts arrays containing fluxes, times,
	position/pointing, and housekeeping info.  Reads file in blocks of 1000 records.
	Constructs arrays big enough to hold the data requested.
	
	read_dd and fs_read_dd are similar.  The main difference is that
	fs_read_dd saves data into pre-defined arrays in common fs_saveaccum,
	while read_dd constructs the arrays and returns them in output args.

       Select input file either by calling fs_open before calling read_dd 
	and passing the dd_open structure that fs_open sets up to read_dd
	or
       pass a filename or dd_type and flare or startt keywords to read_dd.
		e.g.:
               fs_open,flare=12,dd_open=dd_open
               read_dd,dd_open=dd_open,yarray,times
                       or
               read_dd,flare=12     (type defaults to fdb)

 CATEGORY:
	BATSE
 CALLING SEQUENCE:
	read_dd, times, yarray, [hsk, file=infile, flare=flare,$
	   dd_open=dd_open, dd_type=dd_type, startt=startt, endt=endt, $
	   error=error, msfc=msfc]

 SAMPLE CALLS:  
	read_dd, dd_open=dd_open, yarray, times, hsk
	read_dd, times, yarray, startt='93/10/18,1230', $
	   endt='93/10/18,1235', error=error         
 
 OUTPUTS:
	times - r*8 seconds at middle of accumulation interval (relative to
		79/1/1,0) of data in yarray
	yarray - floating point array of fluxes dimensioned as
	   (nchannels, ndetectors, ntimes)
	hsk - (optional) integer array of housekeeping information:
               (Not available for MSFC data files)
		hsk(0,n), hsk(1,n), hsk(2,n) -   x,y,z coordinates of GRO 
		   position in Earth-centered inertial coordinates in 1/4 
		   km units 
		hsk(3,n), hsk(4,n) - z right ascension and declination of 
		   GRO pointing direction, units of .0001 radians 
		hsk(5,n), hsk(6,n) - x right ascension and declination of
		   GRO pointing direction, units of .0001 radians 

 OPTIONAL KEYWORD INPUTS:
       file -  string name of file. If no disk or directory is specified,
               BATSE_DATA is the default.
       flare - BATSE flare number.  FS_OPEN will find file containing FLARE.
       dd_open - structure set by fs_open containing information about input
           file (see dd_init for contents of structure)
       dd_type - Type of data as string or number:
               'BDB', 'FDB', CONT', 'DISCSP'  or 'HKG'
               0/1/2/3/4 = discla bdb, discla fdb, cont, discsp
               Unless the FILE or DD_OPEN keywords are passed, will find this
               type of file for the flare or time requested.  Default is FDB.;+

       startt - start time to read in r*8 seconds relative to 79/1/1,0 or
          	ASCII string in format yy/mm/dd,hhmm:ss.xxx.  If dd_open, 
		flare, and file keywords are NOT specified, then finds file 
		containing this time.
 	endt - end time of interval to read.  See startt description.
	msfc - forces use of msfc native format structures, default non-msfc
	noyarray - doesn't return yarray, count rate data.

 OPTIONAL KEYWORD OUTPUTS:
 	error - 0/1 indicates no error/error reading file
	hkgseq- hkgseq tag from hkg structure
	hkgmod- hkgmod tag from hkg structure
	hkgms1- hkg miscellaneous word 1
	hkgms2- hkg miscellaneous word 2
	hkgmtb- hkg module table
 CALLS: ***
	ATIME [1], ATIME [2], CHECKVAR [1], CONV_VAX_UNIX, DD_CLOSE, FIND_PACKET
	FS_OPEN [1], FS_OPEN [2], NEXTBDB, OS_FAMILY, SC_SECONDS_ED, SIZE_STRUCT, SYS2UT
	UTIME [1], UTIME [2], checkvar [2]
 CALLED BY:
	BATSE_SPEC_GAIN_FDB, EDGES_HVSPEC, GAP_FINDER, HKG_DBASE, READ_CONT, READ_DISCLA
	READ_DISCSP, READ_HKG_CAL, READ_OCC_DISCSP, xzchange
 MODIFICATION HISTORY:
	Written by Kim Tolbert  10/93
	ras, 18-apr-94, add msfc keyword
	ras, 23-jul-95, allowed number of records read to be longword
	RAS, 17-NOV 95, added hkgseq and hkgmod for fdb and bdb
	Version 4, richard.schwartz@gsfc.nasa.gov, 4-sep-1997,  check for pad_byte
	Add MSFC hkg extraction, too.
	richard.schwartz@gsfc.nasa.gov, 10-dec-1998, moved hsk conversion past "done:" statement!


READ_DISCLA $SSW/cgro/batse/idl/read_discla.pro
[Previous] [Next]
 PROJECT:
	SDAC
 NAME:
	READ_DISCLA
 PURPOSE:
 	Procedure to read BATSE FDB files and return time, DISCLA, and angle
 	information.  The DISCLA data has been corrected for overflow and 
	divided by livetime.

 	You must supply the file name explicitly, the time you want, or the 
	flare number in order for read_discla to find the correct input file.  
	If you specify a file name or flare number, you may also specify 
	time start and end to restrict the amount of data returned.  If 
	you don't specify any times, fdbread will return all data in the 
 	fdb, bdb, or the msfc discla file. 
 	UTPLOT package times are set as follows:  base time is set to start 
	of day of the current data, start and end times are set to 0 for 
	autoscaling.
	This procedure is based on FDBREAD but the data values aren't placed
	into the common blocks, but read directly.
 CALLS: ***
	CHECKVAR [1], CHECK_OVERFLOW, DET_POINT, FCHECK, FS_OPEN [1], FS_OPEN [2]
	GETUTBASE [1], GETUTBASE [2], GRO_POINT, JUMPER, LIVETIME [1], Livetime [2]
	RADEC_FILL, READ_DISCLA_FITS, RESTORE_OVERFLOW, SETUTBASE [1], SETUTBASE [2]
	SETUTEND [1], SETUTEND [2], SETUTSTART [1], SETUTSTART [2], SOLEPHUT, anytim [1]
	anytim [2], anytim [3], anytim [4], anytim [5], checkvar [2], read_dd
 CALLED BY:
	read_batse_4_spex [1], read_batse_4_spex [2]
 RESTRICTIONS:
	Doesn't fully support start and end times of all MSFC FITS formats.
 CALLING SEQUENCE:
	read_discla, seconds, discla, cosines	
 CATEGORY:
	BATSE
 OUTPUTS:
   seconds - (output)   array of times at middle of accumulation interval in 
                  seconds since start of day.  
                  Base time for UTPLOT routines will be set to 0h 0m
                  on day of data. (Function GETUTBASE(0) will return base 
                  time in seconds since 79/1/1.) 
   discla  - (output)   (i,j,n) floating point array of discla data where
                  i=6 - channels 1-4 (energy bins 25-50, 50-100, 100-300, and
                        >300 keV), $
			 NaI-(channels 1-4 +CPD, effectively 15-25 keV), and CPD
                  j=8 - LADs 1 through 8
                  n - number of data intervals 
   cosines - (output) floating point array of cosine of angles between 8 LADs
                  and Sun (cosines(j) corresponds to y(*,j,*)

 OPTIONAL KEYWORD INPUTS:
   filename -  string FDB, BDB, or DISCLA file name
   starttime - start time of data to accumulate in r*8 seconds 
               since 79/1/1,0 or as ASCII string 'YY/MM//DD,HHMM:SS'.
   endtime -   end time of data to accumulate. See starttime above for format.
   flare -     BATSE flare number to accumulate data for
   verbose -   0/1 means don't/do print accumulation times message

 OPTIONAL KEYWORD OUTPUTS:
   livetime -  (8,n) floating point array of live time in seconds for 
               each LAD for each data interval 
   error -     (keyword output) =0/1 means no error / error
   cos_spec -  (output) floating point array of cosine of angles between 8 SPECs
                  and Sun (cos_spec(j) corresponds to y(*,j,*)
		The cosines are selected from the start of the time interval
		which could be in error if there is a pointing change
		which comes about once every two weeks.
   USEBDB   -  If set, will use .bdb file if user has privilege
   REORDER  -  If set, put low energy channel (index 4) into index 0,
		channel indices 0-3 are moved to 1-3.  This properly
		orders the channel indices by energy response.  The original
		channel 4 is a residual channel just below the DISCLA1 (Msfc nomenclature)
		energy.
 MODIFICATION HISTORY:

	richard.schwartz@gsfc.nasa.gov, 26-sep-1997.
	Version 2, fixed overflow time selection, richard.schwartz@gsfc.nasa.gov, 24-feb-1998.


READ_DISCLA_FITS $SSW/cgro/batse/idl/read_discla_fits.pro
[Previous] [Next]

  Name:
       READ_DISCLA_FITS


 PURPOSE: Read FITS files at GROSSC of DISCLA data type for BATSE


 CATEGORY: I/O
       BATSE

 CALLING SEQUENCE: read_discla_fits,  File, ut, discla

 CALLS TO:  mrdfits, sc_seconds_ed,

 INPUTS: file- full file name, including path
       none explicit, only through commons;

 OPTIONAL INPUTS:
	The following inputs only apply to mrdfits_spectra readable files
	start_time - extract data after this time, anytim.pro formats
	end_time   - extract data up to this time
 OUTPUTS:
	ut- time  interpretable by anytim.pro, mid-point of integration interval
	discla  - discla data, counts, 6 channels x 8 detectors x n time bins, unsigned integers
	head1 - primary fits header
	head2 - header of first extension
 OPTIONAL OUTPUTS:
	none

 CALLS: ***
	FCHECK, MRDFITS [1], MRDFITS [2], SC_SECONDS_ED, SYS2UT
 CALLED BY:
	READ_DISCLA
 COMMON BLOCKS:
	none
 RESTRICTIONS:
	doesn't support bfits at this time.
 SIDE EFFECTS: SC_SECONDS_ED assumes time error early in mission as of
	93/06/29, this may cause errors in the times of these files.

 MODIFICATION HISTORY: 
	ras, 26-sep-1997


READ_DISCSC $SSW/cgro/batse/idl/read_discsc.pro
[Previous] [Next]
  Name:
       READ_DISCSC

	Read DISCSC data files from MOPS format and optionally write
	IDL save files in /xdr format with the data and time arrays and
	the bit mask for the detectors.  Times are written in seconds
	from 79/1/1.  

Call:	read_discsc, file=filename, DISCSC_TIME, DISCSC, DSELB, save=save

Input:	
	file		complete file name, fits or native format
	save=save	If set, then write a save file in /xdr
	
Outputs:	DSELB - A mask indicating the triggered detectors used for
			DISCSC
		DISCSC - 64 MS counter in 4 DISCLA channels
			saved as an unsigned value in intarr(4,numbins)
		DISCSC_TIME - Mid-point time dblarr(numbins) in sec fr. 79/1/1
		ltime - Live time correction.  Divide DISCSC output
				by ltime to obtain approximate rate
				corrected for dead time effects
Action:	File is opened and read into needed elements of burst_str
		If Save set then:
			IDL save file is written in /xdr format with the three 
			output variables. File name is
			SPEC_DATA:DISCSC_SAV.BURST_NO
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], HEADFITS [1], HEADFITS [2]
	HEADFITS [3], LIVETIME [1], Livetime [2], READFITS [1], READFITS [2], READFITS [3]
	SC_SECONDS_ED, bits [1], bits [2], break_file [4], load_struct, printx [1]
	printx [2]
Restrictions:	Native format files are assumed created with VAX architecture.
History:	ras, 31-jan-94


READ_DISCSP $SSW/cgro/batse/idl/read_discsp.pro
[Previous] [Next]

  Name:
       READ_DISCSP


 PURPOSE: read discspinuous data type from native format or fits files


 CATEGORY: data i/o
       BATSE

 CALLING SEQUENCE: read_discsp, discsp=discsp, seconds=seconds, file=file, $
		fits=fits, start_time=startt, end_time=endt

 CALLS TO:
	read_fits, read_discsp_fits, read_dd, discsp_msfc_str,
	fdr_msfc_str, audit_trail_str

 INPUTS:
       file - data file
	fits - if set, assumes fits file
 OPTIONAL:
	start_time - start reading after this time (anytim readable)
	end_time   - end reading before this time

 OUTPUTS:
       discsp - spectroscopy discriminator data, fltarr(4,8,npackets), signed but raw
	seconds - Center times for each packet, seconds since 79/1/1
	
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], READ_DISCSP_FITS, SC_SECONDS_ED
	break_file [4], read_dd
 CALLED BY:
	PLOTBATSE_QL, Shers_load [1], read_batse_4_spex [1], read_batse_4_spex [2]
 RESTRICTIONS: 
	Fits files cannot be read across network.  Readfits uses
	the IDL EOF function.

 PROCEDURE:
	For native format record oriented, uses READ_DD
	For FITS uses READ_DISCSP_FITS


 MODIFICATION HISTORY: ras, 9 aug 93
			ras, 1 Sep 93, added 1.024 second to non-fits accum.
			ras, 29 Jun 1995, if msfc is in filename then its that format
		        


READ_DISCSP_FITS $SSW/cgro/batse/idl/read_discsp_fits.pro
[Previous] [Next]

  Name:
       READ_DISCSP_FITS


 PURPOSE: Read FITS files at GROSSC of DISCSP data type for BATSE


 CATEGORY: I/O
       BATSE

 CALLING SEQUENCE: str = read_discsp_fits( File[, ut_str, discsp])

 CALLS TO:  discsp_msfc_str, sc_seconds_ed, readfits, utime2str

 INPUTS: file- full file name
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 CALLS: ***
	HEADFITS [1], HEADFITS [2], HEADFITS [3], READFITS [1], READFITS [2], READFITS [3]
	SC_SECONDS_ED, Utime2str [1], Utime2str [2]
 CALLED BY:
	READ_DISCSP
 COMMON BLOCKS:
	none

 SIDE EFFECTS: SC_SECONDS_ED assumes time error early in mission as of
	93/06/29, this may cause errors in the times of these files.

 MODIFICATION HISTORY: ras, 93/06/29
 	ras, 17-oct-94, changed fts to fits


READ_DISCSP_M $SSW/cgro/batse/idl/occults/read_discsp_m.pro
[Previous] [Next]
Name:
	READ_DISCSP_M
Purpose:
	Read DISCSCP data files from MOPS format into IDL 

Calling Sequence:	
	read_discscp_m, file=filename, DISCSCP_TIME, DISCSCP [, det_id=det_id]

Inputs:	
	file		complete file name, fits or native format
	det_id		extract the counters for just this detector
	
Outputs:	
		DISCSCP - intarr(4,nbins) raw unsigned integers for selected det_id
		DISCSC_TIME - intarr(3,nbins)

Action:	File is opened and read into needed elements of discsp_str

 CALLS: ***
	printx [1], printx [2]
 CALLED BY:
	MERGE_DISCSP_HKG_OCC
Restrictions:	Native format files are assumed created with VAX architecture.
		This procedure is designed to extract only essential DISCSP info
		from the J-Box at MSFC for return to the SDAC
History:	ras, 31-jan-94


READ_DNFILE $SSW/cgro/batse/idl/read_dnfile.pro
[Previous] [Next]

 NAME: 
	READ_DNFILE

 PURPOSE:
	Read CGRO orbital predicts files for day/night crossing times.
	Predicts only!
 CATEGORY:
	BATSE

 CALLING SEQUENCE:
	read_dnfile, latest=latest, goodtimes=goodtimes, quiet=quiet

 CALLED BY:


 CALLS: ***
	ATIME [1], ATIME [2], CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], CONV_VAX_UNIX, USE_VAX_FLOAT, concat_dir [4]
 INPUTS:
	/quiet - non-verbose mode
 OPTIONAL INPUTS:
	none

 OUTPUTS:
       latest: most recent crossing
       goodtimes: valid dn crossings
	NOREAD - Doesn't read whole file, only reports latest.

 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	BATSE_ON
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Written by AKT, 1991
	Documented, 31-mar-1996 ras,
	Mod 12/13/96 by RCJ. File dn_file.dat converted to stream. Apply
		conv_vax_unix to header and goodtimes.
	Mod 01/22/97 by RCJ. Open file as stream.
	Version 5, richard.schwartz@GSFC.nasa.gov, added noread, 13-mar-1998
 	Version 6, richard.schwartz@gsfc.nasa.gov, 24-jun-1998, forced old VAX float format on write.


READ_DRM_BIN $SSW/cgro/batse/idl/read_drm_bin.pro
[Previous] [Next]

  Name:
       READ_DRM_BIN


 PURPOSE:  read bsas produced binary drm files


 CATEGORY: i/o for SPEX
       BATSE

 CALLING SEQUENCE:
   read_drm_bin,filename=filename, energy=e, width=wrm, drm=drm, $
	effarea=effarea
   
 CALLED BY:


 CALLS:
	none
 INPUTS:
       filename
       energy - energy of input and outputs
       width
       drm    - response matrix
       edges  - 2 x n

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	vms only?

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 1992


READ_EPHEM $SSW/cgro/batse/idl/read_ephem.pro
[Previous] [Next]

 NAME: 
       READ_EPHEM

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:
	READ_EPHEM, FILENAME, DAYTIMES, NDAYS, NITETIMES, NNITES


 CALLS: ***
	RD_ASCII [1], RD_ASCII [2], UTIME [1], UTIME [2]
 INPUTS:
       Filename

 OPTIONAL INPUTS:
	none

 OUTPUTS:
	Daytimes - Times of entry into orbital days in seconds from 1-jan-1979.
	Ndays    - Number of day crossings.
	Nitetimes- Times of entry into orbital night.
	Nnites   - Number of night crossings.

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	DN_FILE
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
 	READ_EPHEM reads a GRO ephemeris file copied from the GROSSC and returns
 	arrays of day and night start times.
 	(The files are copied from grossc::public:[plan_dat.batse]*.*)
	
	On 12-March-1997 the default source of the ephemeris files is from MSFC
	here is a message on this subject from Anne Shaver:
	I spoke with Bill Henze about the ephemeris files.  They will be sending them 
	directly to us via email in the future.

	Anne

 MODIFICATION HISTORY:
 	Kim Tolbert  May 1992


READ_FLARE $SSW/cgro/batse/idl/read_flare.pro
[Previous] [Next]

 NAME: 
       READ_FLARE

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS: ***
	batse_read_cat
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	BATSE_POINTING, BATSE_SPEC_GAIN_FDB, DET_COSINES, DISCSP_BANDS, DO_FDBFILES
	EVAL_SHERB, FIND_DBFILE, FLARE_F_NAME, FS_AUTO_LOG, HKG_DBASE, MAP_DISCLA2CONT
	PLOT_FLARE, READ_HKG_CAL, RUN_BATSE, TYPE_FLARE, batse_file_search [1]
	batse_file_search [2], spex_batse_preview [1], spex_batse_preview [2]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
 Version 2, richard.schwartz@gsfc.nasa.gov, 13-jun-2000. Generate error if
	batse_flare_catalog not readable(available).


READ_GAPFILE $SSW/cgro/batse/idl/read_gapfile.pro
[Previous] [Next]

 NAME: 
       READ_GAPFILE

 PURPOSE:
	This procedure reports telemetry gaps for BATSE.

 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS: ***
	ATIME [1], ATIME [2], CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], CONV_VAX_UNIX, USE_VAX_FLOAT, concat_dir [4]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	NOREAD - Doesn't read whole file, only reports latest.
	LATEST - Time of most recent record.
 CALLED BY:
	BATSE_ON
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, 1991
	version 2, ras, 9-dec-1996, generalize to unix with conv_vax_unix
	Version 3, richard.schwartz@GSFC.nasa.gov, added noread, 13-mar-1998
 	Version 4, richard.schwartz@gsfc.nasa.gov, 24-jun-1998, forced old VAX float format on write.


READ_HKG_CAL $SSW/cgro/batse/idl/read_hkg_cal.pro
[Previous] [Next]
 Project: SDAC

  Name:   READ_HKG_CAL


 PURPOSE:  extract BATSE SPEC parameters from housekeeping data in batse f(b)db or msfc hkg files.


 CATEGORY: BATSE


 CALLING SEQUENCE:  out = read_hkg_cal( filename )


 CALLED BY:


 CALLS:
	READ_FLARE, SETUP_BATSE_ARRAYS, read_dd
 INPUTS:
       filename - name of BATSE fdb, bdb, or hkg file to be read by READ_DD.

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       Returns out, a structure with tags HV, BASETEMP, and SLLD.

 OPTIONAL OUTPUTS:
	none

 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	

 RESTRICTIONS:
	runs only on SDAC

 PROCEDURE:
	The data is extracted from each fdb file sequentially.

 MODIFICATION HISTORY:
	
       Version 1, richard.schwartz@gsfc.nasa.gov, 30-mar-1998.


READ_HVFILE $SSW/cgro/batse/idl/read_hvfile.pro
[Previous] [Next]
 PROJECT:
	SDAC
 NAME: 
       READ_HVFILE

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS: ***
	ATIME [1], ATIME [2], CHKLOG [1], CHKLOG [2], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], CONV_VAX_UNIX, USE_VAX_FLOAT, concat_dir [4]
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	NOREAD - Doesn't read whole file, only reports latest.
	LATEST - Time of most recent record.
	
 CALLED BY:
	BATSE_ON
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, 1991
	version 2, ras, 9-dec-1996, generalize to unix with conv_vax_unix
	Mod. 12/13/96 by RCJ. File hv_file.dat converted to stream.
	Version 4, richard.schwartz@GSFC.nasa.gov, added noread, 13-mar-1998
 	Version 5, richard.schwartz@gsfc.nasa.gov, 24-jun-1998, forced old VAX float format on write.


READ_MER $SSW/cgro/batse/idl/read_mer.pro
[Previous] [Next]
  Name:
       READ_MER

	Read MER data files from MOPS format. and write
	IDL save files in /xdr format with the data and time arrays and
	the bit mask for the detectors.  Times are written in seconds
	from 79/1/1.
 CATEGORY:
 	BATSE
Calling Sequence:
	read_mer, file=filename, mer_time, mer, DSELB, dstrct=dstrct

Input:	
	file		complete file name, fits or native format
	save=save	If set, then write a save file in /xdr

Outputs:	DSELB - A mask indicating the triggered detectors used for
			MER
                MER - Intarr(4096,16) - 16 energy channels from the selected
		LADs given by DSELB.  First 2048 bins accumulated over 16msec
		and the last 2048 bins over 64msec.
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], HEADFITS [1], HEADFITS [2]
	HEADFITS [3], READFITS [1], READFITS [2], READFITS [3], SC_SECONDS_ED
	break_file [4], load_struct, printx [1], printx [2]
 CALLED BY:
	MK_MER_CONT
Restrictions:
		Only works for MER data with no gaps

Procedure:
	File is opened and read into needed elements of burst_str
History:
Mod:		ras, 2-feb-94
 ras, 3-mar-94, corrected time conversion to include no packet offset 
		 and use burst load time not burst start time
 ras, 16-jun-94, revise documentation


READ_MONTH_CAT $SSW/cgro/batse/idl/read_month_cat.pro
[Previous] [Next]

  Name:
       READ_MONTH_CAT
  

 PURPOSE:
 	This procedure writes the BATSE flare catalog into monthly files.
 CATEGORY:
	 batse archive i/o

 CALLING SEQUENCE: 
	read_month_cat

 CALLED BY:


 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONCAT_DIR [1], CONCAT_DIR [2]
	CONCAT_DIR [3], IEEE_TO_HOST [1], IEEE_TO_HOST [2], IEEE_TO_HOST [3]
	IEEE_TO_HOST [4], TIME2FILE, anytim [1], anytim [2], anytim [3], anytim [4]
	anytim [5], break_file [4], concat_dir [4]
 INPUTS:
 	none

 OPTIONAL INPUTS:
	Month - a single date (anytim format), return the catalog
		only for this month which includes this date.

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	Fldata_month - the catalog structure for the month is
	the input Month is present.

 KEYWORD OUTPUTS:
	ERROR - returns (0/1) if the file indicated by Month is/not present.

 CALLED BY:
	WRITE_MONTH_CAT
 COMMON BLOCKS:
	flare_catalog

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	This procedure finds the batse flare catalog monthly files,
	opens them and reads them into the common catalog area.  This
 	procedure was written to support the modularization of the
	catalog to facilitate broadcast using SSW.  Written mainly
	as a test of the technique.

 MODIFICATION HISTORY:
	Version 1, richard.schwartz@gsfc.nasa.gov, 18-nov-1997


READ_OCC_DISCSP $SSW/cgro/batse/idl/occults/read_occ_discsp.pro
[Previous] [Next]

  Name:
       READ_OCC_DISCSP


 PURPOSE:  
	read compressed discsp files, full sdac-format discsp, full msfc-format discsp
	files including housekeeping, or msfc discsp and hkg files.  Looks for files based on
	date in all recorded places on SDAC and UMBRA including
	the current directory and subdirectories.  
	Looking first for files with name format:
	 occ_discsp_'yymmdd'.dat_'det_id', e.g. occ_discsp_910825.dat_5
	
	or with format:  yymmdd.discsp


 CATEGORY: 
	BATSE, OCCULTS

 CALLING SEQUENCE:
	read_occ_discsp, start_time, end_time, ut, discsp, xpos, ypos, zpos, $
		[det_id=det_id, zradecs=zradecs, xradecs=xradecs, utchange=utchange]

 CALLED BY:


 CALLS: ***
	ATIME [1], ATIME [2], CHECKVAR [1], CONV_VAX_UNIX, FIND_PACKET, HKG_STR, OCC_DBASE
	OCC_FILETYPE, SC_SECONDS_ED, SIZE_STRUCT, anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], checkvar [2], read_dd, xzchange
 INPUTS:
	start_time - time to begin extraction, anytim formats
	end_time   - time to end extraction
 OPTIONAL INPUTS:

 OUTPUTS:
       ut - midpoint of each sample, secs from 1979/1/1
	discsp - two channels of pre-selected discsp data from 1 detector
		or discla data at packet resolution (2.048 sec)
	xpos,ypos,zpos,
		 x,y,z coordinates of GRO position in Earth-
                centered inertial coordinates in 1/4 km units (exactly 
		 as in housekeeping data in bdb file) unsigned integers
		 these will be zeroes in data gaps
	
 OPTIONAL OUTPUTS:

 KEYWORDS:
   INPUTS:
	FILPATH- an array of directories to search for the file.
		  if undefined or '', returns data path used.
	HKG
	NOHKG
	PRIORITY check types of files in this order
	     default:   ['occ_discsp','.discsp','.discsp_msfc']
	REQUEST_ID - Used with OCC_DISCSP to specify file.
   OUTPUTS:
	ZRADECS
	XRADECS
	UTCHANGE: time of change in spacecraft attitude
 	DET_ID - the detector ID returned, either an array
	or the single ID

 CALLED BY:
	FIND_GOOD_OCCS, GET_OCCS, GET_OCC_ONDAY, PLOT_OCCS, PLOT_OCC_ONDAY, xzchange
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY: 
	ras, 29-jun-1995
	Version 2, ras, 7 June 1996, adding database search for files
	Version 3, ras 10 June 1996, use occ_dbase
	Version 4, ras 20 Sept 1996 support all discsp data files, 
	occ_discsp, yymmdd.discsp, and discsp_msfc.dat_


READ_RESULTS $SSW/cgro/batse/idl/occults/read_results.pro
[Previous] [Next]

 NAME: 
       READ_RESULTS

 PURPOSE:
	This procedure collects the daily results file into a single
	large file containing all of the occultation results structures.

 CATEGORY:
	BATSE, OCCULTS

 CALLING SEQUENCE:
	read_results, crab_discsp, data_dir=data_dir, infile=infile

 CALLS: ***
	CHECKVAR [1], CRAB_OCC_STR, EXIST, checkvar [2]
 INPUTS:
	infile: file name for merged results       

 OPTIONAL INPUT:
	data_dir: directory with .rslts files, defaults to '/umbra/schwartz/occults/data2'
	

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


READ_RESULTS2 $SSW/cgro/batse/idl/occults/read_results2.pro
[Previous] [Next]
 Project : SDAC    

 NAME: 
       READ_RESULTS2

 PURPOSE:
	This procedure collects the daily results file into a single
	large file containing all of the occultation results structures.

 CATEGORY:
	BATSE, OCCULTATION

 CALLING SEQUENCE:
	read_results2, crab_discsp, data_dir=data_dir, infile=infile

 CALLS: ***
	CHECKVAR [1], CRAB_OCC_STR, DATATYPE [1], DATATYPE [2], DATATYPE [3]
	IEEE_TO_HOST [1], IEEE_TO_HOST [2], IEEE_TO_HOST [3], IEEE_TO_HOST [4]
	OCC_DBASE, checkvar [2]
 INPUTS:
	item- either a date or '*' to  be used with occ_dbase.pro  
	or
	    - a list of files to read into the structure occout

 OPTIONAL INPUT:
	data_dir: directory with .rslts files, defaults to OCC_DBASE.PRO to find date
	

 OUTPUTS:
       occout - structure with occultation results on an orbit by orbit basis

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	date - dates for each file read, an output
	ftype - '.bdb', '.cont', or '.discsp'
	ofiles - data files used for occultations
	filpath- filepath to pass on to occ_dbase
 CALLED BY:
	OCC_AVG
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	ras, 8-sep-1996
	Version 2, ras, 9-oct-1996
	Version 2, ras, 2-jan-1997, added FILPATH


READ_SHER $SSW/cgro/batse/idl/read_sher.pro
[Previous] [Next]
  Name:
       READ_SHER
************************************************************************ 
 Pro	READ_SHER, filename, data, start_time, end_time, width64
	fdr, audit_trail, error=error, file_type=file_type,
	fits=fits
       
	Read Sher, Sher_cor, Her, Her_cor BATSE data 

 Inputs:	Filename - full file descriptor for file in native
		format.  Corrected data may be used.  If the extension
		is ".fits", then fits readers are used.
		Must contain the substrings 'her' or 'sher' and may
		contain 'cor'.  Otherwise, these strings may be input
		through FILE_TYPE.

 Optional Keywords
		file_type - string containing the substrings which specify
		the data structure to be read.
		fits - if set, then fits reader used.

 Outputs:	Data - Count data unpacked as whole numbers into 
			 fltarr( nch, ndet, npck)
				nch - number of energy bins
				ndet - number of detectors		
				npck - maximum number of packets allowed
			 
		Start_time - time in s from 79/1/1 for each time interval
			  dblarr( nrep, npck)
		End_time - time in s from 79/1/1 for each time interval
			  dblarr( nrep, npck)
		width64 - reported width of linear channel 64
		FDR - header record

		AUDIT - Audit records

 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONV_VAX_UNIX, HEADFITS [1]
	HEADFITS [2], HEADFITS [3], READFITS [1], READFITS [2], READFITS [3]
	SC_SECONDS_ED, SIZE_STRUCT, break_file [4], load_struct
 CALLED BY:
	Shers_load [1], spex_batse_preview [1], spex_batse_preview [2]
 Restrictions:  File name must contain the words Her or Sher and 
		 the word Cor for corrected data.  Otherwise the
		 correct data structure must be provided.
		 File Definition Record
		 includes NUM_AUDIT_REC tag name specifying the
		 number of data records.  

 ras, 93/10/14
 ras, 31-jan-94, used load_struct and conv_vax_unix to make
	machine independent
 ras, 3-mar-94, corrected time conversion to include no packet offset
 ras, 19-oct-95, revised record length calculation
************************************************************************


READ_SHERB $SSW/cgro/batse/idl/read_sherb.pro
[Previous] [Next]
************************************************************************ 
 Name:
	READ_SHERB
 Call:
	READ_SHERB, filename, det_id, data, start_time, end_time, 
	dselected=dselected, error=error, file_type=file_type, head=head,
	fits=fits, burst_str=burst_str, sched=sched, dstrct_in=dstrct_in,
	burst_time=base_time
       
 Category:
	BATSE, SPEX
 Inputs:	
		Filename - full file descriptor for file in native
		format.  Corrected data may be used.  If the extension
		is ".fits", then fits readers are used.
		Must contain the substrings 'herb' or 'sherb'. 
		Otherwise, these strings may be input
		through FILE_TYPE.  String may contain wildcards.
		Det_id - id (0-7) of the detector to select. Defaults to
		DSELECTED(0), the id of the brightest LAD

 Optional Keywords
		FILE_TYPE - string containing the substrings which specify
		the data structure to be read.
		FITS - if set, then fits reader used.
		HEAD - only read the first data record to return the 
			burst selected detector ids, dselected and base_time
 Outputs:	Data - Count data unpacked as whole numbers into 
			 fltarr( nch, nspec)
				nch - number of energy bins
				nspec - number os spectra in memory for
					dselected
			 
		Start_time - time in s from 79/1/1 for each time interval
			  dblarr( nrep, nspec)
		End_time - time in s from 79/1/1 for each time interval
			  dblarr( nrep, nspec)

 Optional Outputs:
		DSELECTED - The ids (0-7) of the four detectors selected
		BURST_STR - data structure from the first record read.
               SCHED     - schedule of readouts in data file and data
			    if det_id is not one of dselected.  To
			    return all of the spectra for all of the
			    detetectors, select det_id > 7.
		DSTRCT_IN - raw packets read in
		BURST_TIME - burst time in seconds from 79/1/1
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CHECKVAR [1], HEADFITS [1]
	HEADFITS [2], HEADFITS [3], READFITS [1], READFITS [2], READFITS [3]
	SC_SECONDS_ED, break_file [4], checkvar [2], load_struct, printx [1], printx [2]
 CALLED BY:
	EVAL_SHERB, Shers_load [1], spex_batse_preview [1], spex_batse_preview [2]
 Restrictions:  File name must contain the words Her or Sher and 
		 the word Cor for corrected data.  Otherwise the
		 correct data structure must be provided.
		 File Definition Record
		 includes NUM_AUDIT_REC tag name specifying the
		 number of data records.  

 ras, 93/10/17
 ras, 21-dec-93, only valid for sherb
 ras, 31-jan-94, used load_struct and conv_vax_unix to make
	machine independent
 ras, 18-feb-94, head option
 ras, 3-mar-94, corrected time conversion to include no packet offset 
		 and use burst load time not burst start time
 Version 1	ras, 25-Mar-96 
************************************************************************


READ_SPLINE $SSW/cgro/batse/idl/read_spline.pro
[Previous] [Next]
  Name:
       READ_SPLINE

  Category:
	BATSE
  Call:
	read_coef, spec_lld

  Purpose:

     This subroutine reads in all necessary coefficients stored in 
     external data files for the light/energy calibration

      Input:
	spec_lld: LLD channel for SPEC detector
       
     Output:
        spline_com--common block with spline coefficients for L/E curve

    
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], concat_dir [4]
  Common Blocks:
	spline_com

  History:
	RAS, copied from BSAS, 1991

               RAS, 7-Jul-1997, changed PERM_DATA to SSWDB_BATSE


READ_STTE $SSW/cgro/batse/idl/read_stte.pro
[Previous] [Next]
 Name:
	READ_STTE
 Purpose:
	Read STTE data files from MOPS format. and write
	IDL save files in /xdr format with the data and time arrays and
	the bit mask for the detectors.  Times are written in seconds
	from 79/1/1.

 Call:	
	read_stte, Filename, Stte, Dselb

 Input:	
	Filename - complete file name, fits or native format

 Outputs:	
	Dselb - A mask indicating the triggered detectors used for
		STTE after the trigger
	Stte - A structure with pha channel, time in ut format, and det_id

 Keywords:
	DSTRCT- The original data structure
	DET_ID- Return the structure for only this detector.
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], EXIST, FCHECK, HEADFITS [1]
	HEADFITS [2], HEADFITS [3], READFITS [1], READFITS [2], READFITS [3]
	SC_SECONDS_ED, UNIQ [1], UNIQ [2], UNIQ [3], break_file [4], load_struct, printx [1]
	printx [2]
 CALLED BY:
	Shers_load [1], spex_batse_preview [1], spex_batse_preview [2]
 Restrictions:
	Only works for STTE data with no gaps and no period of 4.096 msec without an
	event (count rates usually over 10-100/4.096 sec)
 Action:
	File is opened and read into needed elements of burst_str
 Mod:		
 ras, 22-mar-96, written from BATSE Flight Software Manual description
 ras, 22-Apr-96, call sc_seconds_ed with /no_offset


READ_TTS_FITS $SSW/cgro/batse/idl/read_tts_fits.pro
[Previous] [Next]

 NAME: 
       READ_TTS_FITS

 PURPOSE:
       This function reads the BATSE TTS FITS files
	found on the COSSC ftp site.

 CATEGORY:
       BATSE

 CALLING SEQUENCE:
   read_tts_fits, File, TTS, tts_struct=tts_struct

 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], DELVARX [1], DELVARX [2]
	DELVARX [3], DELVARX [4], FXPAR [1], FXPAR [2], HEADFITS [1], HEADFITS [2]
	HEADFITS [3], READFITS [1], READFITS [2], READFITS [3], T_TTS, break_file [4]
	delvarx [5], load_struct
 INPUTS:
      filename - BATSE TTS filename, FITS format.

 OPTIONAL INPUTS:
       none

 OUTPUTS:

	TTS- a structure with 4 elements for the four channels,each with 3 tags 
		UT - center time of each interval, in sec from 1-jan-1979
		COUNTS - inferred TTS counts in each interval
		DT - TTS time interval

 OPTIONAL OUTPUTS:
       none

 KEYWORDS:
       TTS_STRUCT - The raw tts structure

 COMMON BLOCKS:
       none

 SIDE EFFECTS:
       none

 RESTRICTIONS:
       Only reads the TTS files in GROSSC FITS format

 PROCEDURE:
       none

 MODIFICATION HISTORY:
       ras, 16-Jun-1996


READQUAL $SSW/cgro/batse/idl/readqual.pro
[Previous] [Next]
 PROJECT:
	SDAC
 NAME: 
       READQUAL

 PURPOSE:
       Read BATSE quality file.

 CATEGORY:
       BATSE, I/O

 CALLING SEQUENCE:
       READQUAL, intime, qual

 CALLS: ***
	BATSE_FILE2TIME, FCHECK, LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], PARSE_ATIME [1]
	anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], curdir [1], curdir [2]
	parse_atime [2]
 INPUTS:
       Intime:	Starting time. String compatible with anytim.

 OUTPUTS:
       Qual:	Quality file in string format (no header). 

 KEYWORDS:
	Error: 0/1 if no_error/error reading quality file.
 KEYWORD OUTPUTS:
	BUFF: raw data buffer read. Used for debugging.
	FILENAME: Read this instead of date default.  Used for debugging.
 CALLED BY:
	CHECK_OVERFLOW, HV_FINDER, LISTQUAL
 PROCEDURE:
	Given a date, readqual reads respective BATSE quality file header
	to get last record number used and subtract wrong lines,
	and reads quality file (no header) into string variable qual.
	About 16-oct-1997 the method of file copying was changed and
	the characteristics of the fixed-length binary file are changed
	by the copy/ftp/bin such that the fortran carriage return was
	included.  Two techniques are used to block the file and
	both are tried.  The old technique is tried first for files
	before 97/10/12 and the new first for data files after
	that date in the filename. 

 MODIFICATION HISTORY:
	Mod. by ras, 17-apr-95, unix/vms stream files
       Mod. by RCJ, 12/26/96, revised documentation.
	Version 3, richard.schwartz@gsfc.nasa.gov, 15-oct-1997, revamped read.  This is 
	just reading a bytarr grouped into 80 characters per line.  Also, rejected
	overflow intervals greater than 70 minutes.
	Version 4, richard.schwartz@gsfc.nasa.gov, 24-jun-1998, read first line using string function
	on byte buffer.  Didn't need it on earlier versions of idl prior to 5.1.
       Version 5, amy@aloha.nascom.nasa.gov, 10-Sep-1998, use the filename
	keyword to determine method if no intime is given.


RECORD_LATEST_NUMBER $SSW/cgro/batse/idl/record_latest_number.pro
[Previous] [Next]

 NAME: 
       RECORD_LATEST_NUMBER

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLED BY:
	DO_ARCHIVEPLOTS, DO_PSPLOTS
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


REDO_EDGES $SSW/cgro/batse/idl/occults/redo_edges.pro
[Previous] [Next]

 NAME: 
       REDO_EDGES

 PURPOSE:
       A main program to reprocess the discsp edges from the current
       database for SLLD and conversion of SLLD into keV.  Also, the
       current pointing database is used to generate the spacecraft
       attitude info (ZXRADEC) in the occultation structure.

 CATEGORY:
       BATSE, OCCULTS

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       looks for discsp_crab.sav unless infile is specified

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	latest_edges_cosines.sav is written to the current directory

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, ras, 7-June-1996


REFORMAT_RESULTS $SSW/cgro/batse/idl/occults/reformat_results.pro
[Previous] [Next]

 NAME: 
       REFORMAT_RESULTS

 PURPOSE:
       This is an obsolete main program to compress the results database
        for the BATSE CRAB DISCSP observations.

 CATEGORY:
       BATSE, OCCULTS

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, Aug 1995


REMOTECOM $SSW/cgro/batse/idl/remotecom.pro
[Previous] [Next]

 NAME: 
       REMOTECOM

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


RESET [1] $SSW/cgro/batse/idl/reset_old.pro
[Previous] [Next]
  Name:
       RESET
Given data(or any) rates with possible overflow, use jumper to reconstruct rates.
This code assumes that data have not been modified by livet 
 RAS
 CALLS:
 CALLED BY
	DSPEXP, Data Display, fig_tsmean [1], fig_tsmean [2]


RESOLVE_NEW_OBS $SSW/cgro/batse/idl/occults/resolve_new_obs.pro
[Previous] [Next]

 NAME: 
       RESOLVE_NEW_OBS

 PURPOSE:
        A routine for checking the observations against the database.

 CATEGORY:
        BATSE, OCCULTS

 CALLING SEQUENCE:
	resolve_new_obs, discsp_in, results_out, inradec=inradec

 CALLS: ***
	ATIME [1], ATIME [2], AVERAGE_STEPS, BUILD_DRM, CHECKVAR [1], CRAB_OCC_STR
	DISCSP_EDGES, FCHECK, GET_SPEC_GAIN, GRO_POINT, MINMAX [1], MINMAX [2], REVERSE
	UNIQ [1], UNIQ [2], UNIQ [3], checkvar [2], edge_products
 INPUTS:
       discsp_in: a crab_occ_discsp structure
       inradec: Crab ra and dec (default: [83.516, 22.0197]) in degrees

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	To be run on HXRBS only!!!!!!!
	NEEDS: 
 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, Aug 1995


RESOLVE_RESULTS $SSW/cgro/batse/idl/occults/resolve_results.pro
[Previous] [Next]

 NAME: 
       RESOLVE_RESULTS

 PURPOSE:


 CATEGORY:
       BATSE, OCCULTS

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


RESTORE_FLARE $SSW/cgro/batse/idl/restore_flare.pro
[Previous] [Next]
 PROJECT: 
	SDAC
  Name:
       RESTORE_FLARE

 CATEGORY:  
	BATSE


 PURPOSE:
 	This procedure recovers a BATSE archive flare plot file from compressed format.  
	The file is an IDL save file containing the time and data in compressed format, and all
 	information needed to construct the standard BATSE flare plot, most
 	important of which are:
 	  utb - base time in dbl sec since 79/1/1. time array is relative to utb
	   archive_sec - time array in seconds rel to utb
	   archive_data - data in Chan 1 and 2 for sum of 2 most sunward dets.
	   flare_datacom - structure containing parameters of flare (peak time,
 	     duration, peak rate, etc)
	   title, ytitle, subtitle1, subtitle2 - titles that would be drawn on
	      archive plot from which you can extract ascii start time, channel ranges,
	      time resolution, effective areas.
 	Everything in the save file is listed in common restorecom. 
	 Assumes the files are called flare_x.sav where x is the
	 flare number.

 	Returns in keyword parameters the time and data arrays, and utbase.

 KEYWORDS:
   flare - (input) flare number of file to restore
   sec - (output) float array of seconds relative to utbase
   data - (output) float array of fluxes in Channels 1 and 2 for the sum of
     the two most sunward detectors
   utbase - (output) base time of sec array in double precision seconds
     since 79/1/1,0
   error - (output) = 0 if no error occurred.  1 otherwise

 CALLS: ***
	FIND_IX, LOC_FILE [1], LOC_FILE [2], LOC_FILE [3]
 NOTE:  on Ultrix machines, even in Version 3.0, double precision variables
        are not restored correctly.  utbase is the only double precision
        variable used.  To correct the value, type mipseb_dblfixup,utbase.
 MODIFICATION HISTORY:

 Kim Tolbert 3/12/93

 Mod 5/14/93.  The save files are now XDR files.  Because XDR files save
 2-byte integers in 4 bytes, taking twice the space, 2-byte integer arrays 
 were converted to byte arrays (by location, not value) before writing.  
 So after restoring, need to convert back to 2-byte integer arrays, then 
 scale back to the true value.  Also we rewrote all the archive flare plot 
 files, so they now have the correct time (at least concerning the
 2.042142 clock fix that occurred on 92/6/25) so this routine no longer makes
 a time correction.
 Version 3, richard.schwartz@gsfc.nasa.gov, 28-aug-1997, fixed a bug
	in the creation of the time array.  Added documentation.
	Cleaned up the file naming using SSW routines.
	Made the time array exact, with 1.024 sec differences on reading.


RESTORE_QLOOK $SSW/cgro/batse/idl/restore_qlook.pro
[Previous] [Next]
 PROJECT: 
	SDAC

 NAME: 
	RESTORE_QLOOK


 PURPOSE: This procedure recovers BATSE orbital quick-look data to useable form from save file
	data have been log-byte-scaled and need reverse transformations.


 CATEGORY:  BATSE


 CALLING SEQUENCE:
	restore_qlook, time=time, orbit=orbit, utout=utout, cos_det=cos_det,  $
	  youts=youts, daymarks=daymarks, nightmarks=nightmarks,ylabels=ylabels,  $
	  error=error

 CALLED BY:


 CALLS: ***
	CHECKVAR [1], LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], PARSE_ATIME [1]
	anytim [1], anytim [2], anytim [3], anytim [4], anytim [5], checkvar [2]
	parse_atime [2]
 INPUTS:
       time - time of orbit for data
	
 OPTIONAL INPUTS:
	orbit- orbit number, supercedes time to use orbit n on date given by time

 OUTPUTS:
       utout - time of data, seconds from 1-jan-1979
	youts - count rate data, 8 arrays, fltarr(8, npoints)
		1st Sunward Chan 0
		2nd Sunward Chan 0
		3rd Sunward Chan 0
		4th Sunward Chan 0
		Sum Sunward Chan 0
		Sum Sunward Chan 1
		Sum Sunward CPDs
		Sum Anti-Sunward Chan 0
	cos_det - detector cosines
	daymark - time of sunrise for orbit	
	nightmark - time of sunset for orbit	
	ylabels - description of each of youts
	error   - set if there was a problem
 OPTIONAL OUTPUTS:
	none

 CALLED BY:
	PLOTBATSE_QL, Pointing_Change
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
 	restore_qlook restores the quicklook save file for the day requested, 


 MODIFICATION HISTORY:
  Mod. 9/24/92 Starting ~9/24/92 qlarchive saves an array of periods,
  one for each orbit, rather than a scalar for the entire day).  After 
  restoring save file, if period is a scalar, create an array from it
  so the rest of the code will look the same for either kind of file.
  Changed all references to period to include (element #) when appropriate.
  ras, 13-sep-95, compiled from quick-look plot procedures

 Version 3, richard.schwartz@gsfc.nasa.gov,  fixed a bug
	in the creation of the time array.  Added documentation.
	Cleaned up the file naming using SSW routines.
 	time and data arrays were stored scaled down as i*2.  
 	Old style compressed with digitization error.  The new restore (2-sep-1997) maps the
 	times onto packet times (multiples of 2.048 sec from xrange(0)) with the
 	only error being daily clock drift.
 Version 4, richard.schwartz@gsfc.nasa.gov, 31-oct-1997,
	checked available orbits before using orbit as index
	on cosines.


REWRITE_FDB $SSW/cgro/batse/idl/rewrite_fdb.pro
[Previous] [Next]
  Name:
       REWRITE_FDB
 Procedure to rewrite an FDB file, skipping over a packet with a counter
 known to be bad.  Must edit this file for the flare number and bad_counter
 you want to skip.
 Kim Tolbert 3/94
 CALLS:


ROTXYZ $SSW/cgro/batse/idl/rotxyz.pro
[Previous] [Next]

 NAME: 
	ROTXYZ

 PURPOSE:
	This function create a 3x3 rotation matrix about an arbitrary axis.

 CATEGORY:
       	MATH, BATSE

 CALLING SEQUENCE:
	Rotation_matrix = ROTXYZ( Phi, Axis_id )

 INPUTS:
       Phi - rotation angle in degrees.
	Axis_id - 0,1,or 2 for rotation about X, Y, or Z axis
 OPTIONAL INPUTS:
	none

 OUTPUTS:
       The result is Rotation_matrix, a 3x3 float array.

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 CALLS: ***
	DATATYPE [1], DATATYPE [2], DATATYPE [3]
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 EXAMPLE:

IDL> print,x
      1.00000     0.000000     0.000000
IDL> print, ROTXYZ( 45.0, 2)
     0.707107     0.707107     0.000000
    -0.707107     0.707107     0.000000
     0.000000     0.000000      1.00000
IDL> print, ROTXYZ( 45.0, 2) # x
     0.707107     0.707107     0.000000; CALLS:

 PROCEDURE:
	This procedure takes the rotation angles and puts them in the correct 
	positions in the matrix depending on the Matrix_id.

 MODIFICATION HISTORY:
	RAS, written ~1987, Documented April 1996


RSHER_STR $SSW/cgro/batse/idl/rsher_str.pro
[Previous] [Next]

 NAME: 
       RSHER_STR

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


RUN_BATSE $SSW/cgro/batse/idl/run_batse.pro
[Previous] [Next]
 Project     : SDAC
                   
 Name        : RUN_BATSE
               
 Purpose     : This procedure fits an interval around the peak of a BATSE
	flare and extracts the fit parameters and the raw rates.
               
 Category    : BATSE
               
 Explanation : Using the BATSE catalog, SPEX is used to read, extract, and 
	fit the observation of CONT data.
               
 Use         : Run_batse, flare, obs
    
 Inputs      : Flare - BATSE archive flare number
               
 Opt. Inputs : None
               
 Outputs     :	OBS   - Structure with these tags
		Flare -
		Det_id- ID of most fitted detector.
		Cosine- cosine of fitted detector
		Aspect- sorting order for aspect starting with 1 for most sunward.
		Edges - Channel edges in keV.
		Ch_mask - 1 for channel used in fit, 0 unused.
		Apar  - Single Power-law fit values.
		Utbase- Basetime in seconds from 1-jan-1979.
		Xselect- Interval times relative to Utbase.
		Obsi- Interval count rate (/s/keV/cm2) for each channel.
		Eobsi- Uncertainty on obsi.
		Backi- Background for interval.
		Ebacki
		
		

 Opt. Outputs: None
               
 Keywords    : ASPECT_ID - If used, set det_id to this aspect value. 1 is most sunward
		8 is least sunward.

 Calls	      : ***
	AVG [1], AVG [2], CHECKVAR [1], DET_COSINES, GETUTBASE [1], GETUTBASE [2]
	LOC_FILE [1], LOC_FILE [2], LOC_FILE [3], MINMAX [1], MINMAX [2], READ_FLARE
	SPEX_PROC [1], SPEX_PROC [2], checkvar [2], spex_current [1], spex_current [2]
 Common      : None
               
 Restrictions: 
               
 Side effects: None.
               
 Prev. Hist  : Version 1, RAS, 29-apr-1997.

 Modified    : 


RUN_EXTRACT_SLLD $SSW/cgro/batse/idl/run_extract_slld.pro
[Previous] [Next]

 NAME: 
       RUN_EXTRACT_SLLD

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:


RUN_MERGE_DISCSP_HKG_OCC $SSW/cgro/batse/idl/occults/run_merge_discsp_hkg_occ.pro
[Previous] [Next]

 NAME: 
       RUN_MERGE_DISCSP_HKG_OCC

 PURPOSE:
       This main program examines the available native format discsp 
        compressed hkg files 

 CATEGORY:
       BATSE, OCCULTS

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
      none

 OPTIONAL INPUTS:
	OUTDIR: write occ_discsp* to this directory.

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	only run on sdac

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	august 1995
	Version 2, ras, June 7, 1996


RUN_OCC $SSW/cgro/batse/idl/occults/run_occ.pro
[Previous] [Next]

 NAME: 
       RUN_OCC

 PURPOSE:
       This main program tests the software, software tree, and data paths
        at MSFC

 CATEGORY:
       BATSE, OCCULTS

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	Run at MSFC only

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, ras, March 1996


RUN_PLOT_OCCS $SSW/cgro/batse/idl/occults/run_plot_occs.pro
[Previous] [Next]

 NAME: 
       RUN_PLOT_OCCS

 PURPOSE:
       This main program provides an example of extracting the occultation
       step fit from cont data.  OBSOLETE       

 CATEGORY:
       BATSE, OCCULTS

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	OBSOLETE

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	RAS, july 1995


RUNBATSE_MENU $SSW/cgro/batse/idl/runbatse_menu.pro
[Previous] [Next]

 NAME: 
       RUNBATSE_MENU

 PURPOSE:
        This is a few lines of code meant to be used,
         @runbatse_menu
         runbatse_menu allows batse_menu to be run by typing IDL RUNBATSE_MENU

 CATEGORY:
       BATSE

 CALLING SEQUENCE:
         @runbatse_menu


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	1991
	Version 2, ras June 1996, documentation header added


RUNIT $SSW/cgro/batse/idl/occults/runit.pro
[Previous] [Next]

 NAME: 
       RUNIT

 PURPOSE:
       This is a block of code to facilitate  processing occultation data on umbra
        Used with ~schwartz/occults/do_runit

 CATEGORY:
       BATSE, OCCULTS

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	RAS, aug 1995


RUNMENU $SSW/cgro/batse/idl/runmenu.pro
[Previous] [Next]

 NAME: 
       RUNMENU

 PURPOSE:


 CATEGORY:
       BATSE

 CALLING SEQUENCE:


 CALLS:
	none
 INPUTS:
       none explicit, only through commons;

 OPTIONAL INPUTS:
	none

 OUTPUTS:
       none explicit, only through commons;

 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
	none
 COMMON BLOCKS:
	none

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
  	richard.schwartz, 20-nov-1997
	richard.schwartz@gsfc.nasa.gov, 1-feb-1998, eliminate main execute and
	run guts of idl_startup directly.