This page is a listing of the entire contents of this library for IDL. This listing is the long version. Viewing the much more compact listing may be handier.
NAME:
ACNVRT
PURPOSE:
This function converts the HEAO A-1 quasi-logarithmic numbers
to HEAO A-1 Science Data and vice versa.
HEAO A-1 quasi-logarithmic number format:
(8 BITS) - CCCMMMMM (C=CHARACTERISTIC, M=MANTISSA)
These quasi-logarithmic numbers are the result of the onboard
HEAO A-1 quasi-logarithmic scalars and are present in the raw
2.1 kbps A-1 portion of the NRZ data.
CATEGORY:
HEAO.
CALLING SEQUENCE:
Result = ACNVRT( Data )
INPUTS:
Data: Array of any dimensions containing either the HEAO A-1
quasi-logarithmic numbers OR the HEAO A-1 Science
Data.
OPTIONAL INPUT KEYWORD PARAMETERS:
INVERSE: Set this keyword to convert A-1 Science Data to
HEAO A-1 quasi-logarithmic numbers, (0=Default).
OUTPUTS:
This function returns A-1 Science Data converted from the input
Data array or A-1 quasi-logarithmic numbers, if the INVERSE keyword
is set.
MODIFICATION HISTORY:
Written by: Daryl J. Yentis, Naval Research laboratory, SSD 1980.
13-JUN-1994 H.C. Wen - Adapted to IDL; added INVERSE keyword.
(See /host/bluemoon/usr2/idllib/contrib/groupk/acnvrt.pro)
NAME:
ARR2STR
PURPOSE:
Converts an array of numbers to a string of numbers separated
by commas.
CATEGORY:
STRLIB.
CALLING SEQUENCE:
Result = ARR2STR( Array [, Nsig ] )
INPUTS:
Array: Array of numbers to convert.
OPTIONAL INPUTS:
Nsig: Number of significant figures to keep when converting
each number to a string.
OUTPUTS:
Returns a string containing the elements of the Array parameter
separated by commas.
MODIFICATION HISTORY:
Written by: Han Wen, October 1994.
23-APR-1995 Convert byte arrays to integers before applying the STRING
function.
31-OCT-1995 Added ON_ERROR,2
19-NOV-1995 Remove leading/trailing blank spaces.
(See /host/bluemoon/usr2/idllib/contrib/groupk/arr2str.pro)
NAME:
AVG_LC
PURPOSE:
Plots the average light curves for a source, customized to
the HEAO A-1 data.
CATEGORY:
HEAO A-1.
INPUTS:
Time: Array of times in SECONDS since 1/1/77, [dblarr( npts )].
Flux: Array of corresponding intensities for the source,
[fltarr( npts )] in units specified by the FLUX_UNITS keyword.
Err: Array of corresponding uncertainties for each intensity
[fltarr( npts )] in units specified by the FLUX_UNITS keyword.
SrcName: The name of the source, [string].
OPTIONAL INPUT PARAMETERS:
FLUX_UNITS: The units of the given intensities, [string], (''=Default).
BINSIZE: Time binsize of the average light curve in DAYS.
OUTPUTS:
This routine makes light curves of the HEAO A-1 data and sends
them to the graphic device if the USER selects it from the widget
menu.
MODIFICATION HISTORY:
September, 1994 H.C. Wen
12-JAN-1995 Added the BINSIZE keyword
01-FEB-1995 Implemented XPLOT, XOPLOT
08-FEB-1995 Eliminated the HALF keyword for simplicity.
(See /host/bluemoon/usr2/idllib/contrib/groupk/avg_lc.pro)
FUNCTIONAL DESCRIPTION:
Function calculates the satellite's position in barycentric
coordinates, then calculates a time correction based no the
projection of the satellite's position vector into the source
direction (from the Earth). Thus the time is corrected to a
fixed point on the Earth-source line, such that the line joining
that point to the barycenter is pependicular to the Earth-source
line.
INPUT PARAMETERS:
SRCVEC floating-point array giving the unit 3-vector to from the
Earth to the source object, in celestial coordinates.
SATVEC floating-point array giving the satellite's position
3-vector relative to Earth-center, in kilometers.
JTIME double-precision modified Julian date for which the
correction is to be calculated (JD1950) in days.
OUTPUT PARAMETERS:
None.
RETURNS:
BARY_CORR = (double-precision) delta-time (seconds) which, when
added to JTIME, gives the time at the correction point
discussed above.
NOTES:
This code based on SUBROUTINE BARYTIME written by Lynn Cominsky.
AUTHOR/DATE: K.H. Fairfield, 04-DEC-1992
(See /host/bluemoon/usr2/idllib/contrib/groupk/barycorr.pro)
NAME:
CAPTURE
PURPOSE:
Captures the current graphics screen and saves it to an image file.
CATEGORY:
I/O.
CALLING SEQUENCE:
CAPTURE
OPTIONAL INPUT KEYWORD PARAMETERS:
BMP: Set this keyword to send a BMP image to the printer, (1=Default).
GIF: Set this keyword to send a GIF image to the printer, (0=Default).
JPEG: Set this keyword to send a JPEG image to the printer, (0=Default).
FILENAME: Filename of the image file (picnnn.bmp,gif,jpg=Default).
PROCEDURE:
The current graphics screen is saved to an image file.
EXAMPLE:
plot,indgen(100),xtitle='This is the x-axis',ytitle='Y-Axis'
xyouts, 0.3, 0.94, 'Title.. So What.. Big Deal', CHARSIZE=1.4, /NORMAL
CAPTURE
MODIFICATION HISTORY:
Written by: Han Wen, July 1995.
(See /host/bluemoon/usr2/idllib/contrib/groupk/capture.pro)
NAME:
CK_VER
PURPOSE:
This function checks the validity of the Version number of a DATA
structure created by the FIDUCIAL routine.
CATEGORY:
HEAO A-1.
CALLING SEQUENCE:
Result = CK_VER( Data )
INPUTS:
Data: Structure created by the FIDUCIAL routine and saved to
an IDL SAVE session file (*.sav).
OPTINOAL INPUT KEYWORD PARAMETERS:
VERSION: The version number of the Data structure must be greater
than or equal to this value (3=Default).
OUTPUTS:
Returns a 1 if the structure is a valid DATA structure created by
FIDUCIAL version=VERSION or later, or a 0 otherwise.
MODIFICATION HISTORY:
Written by: Han Wen, February 1995.
(See /host/bluemoon/usr2/idllib/contrib/groupk/ck_ver.pro)
NAME:
CLEAN_UP
PURPOSE:
Cleans up "garbage" log files created by the
NEW_JOURNAL routine.
CATEGORY:
I/O.
CALLING SEQUENCE:
CLEAN_UP, LogPath
INPUTS:
LogPath: Path to your existing NEW_JOURNAL log files,
(e.g. 'd:\rsi\idl40\bob\log\')
OPTIONAL INPUT KEYWORD PARAMETERS:
TODAY: Mark all log files created today for possible deletion, (0=Default).
If this keyword is set then the CUTOFF keyword is ignored.
CUTOFF: The largest NEW_JOURNAL log file in BYTES to potentially
delete, (1000=Default).
ALL: Set this keyword to mark ALL log files found, (0=Default).
NOCONFIRM: Set this keyword to AUTOMATICALLY delete any
NEW_JOURNAL log files smaller than CUTOFF. The USER
will NOT be notified, (0=Default).
PROCEDURE:
A list of NEW_JOURNAL files that are smaller than CUTOFF is displayed
to the USER. The USER may then select any of these files to view
their contents and either keep or delete the log files.
RESTRICTIONS:
Currently the only OS platforms supported by this routine
are: Windows/DOS and Unix.
MODIFICATION HISTORY:
Written by: Han Wen, August 1995.
21-AUG-1995 Keep string lengths < 80 characters, added TODAY keyword,
delete log files together.
27-SEP-1995 Eliminated text-wrap for efficiency. Read in text more
efficiently into arrays; concatenation is VERY inefficient.
Added ALL keyword.
29-SEP-1995 Only display first 900 lines of text for efficiency. A
More ... line will appear if the log file is > 900 lines.
Check for 0-length files.
06-DEC-1995 Forgot to close any 0-length files before attempting to
delete them.
07-AUG-1996 Eliminate call to VERSION().
(See /host/bluemoon/usr2/idllib/contrib/groupk/cleanup.pro)
NAME:
CLEAR_SCAN
PURPOSE:
Resets all the common block structure to 0.
CATEGORY:
I/O
CALLING SEQUENCE:
CLEAR_SCAN
RESTRICTIONS:
Remember, when you exit an IDL routine or program, any common
block variables are still defined!
MODIFICATION HISTORY:
Written by: H.C. Wen, May, 1994.
15-MAY-1994 Added an end-of-file flag for each file buffer, eofb.
26-JUN-1994 Reduced the multi-common, multi-variables to ONE common
and ONE structure, buf.
01-AUG-1994 Formerly called CLEAR_BUF
(See /host/bluemoon/usr2/idllib/contrib/groupk/init_scan.pro)
NAME:
COLLDIRS
PURPOSE:
This procedure determines the viewing direction(s) of one
of the HEAO A-1 collimators.
CATEGORY:
HEAO A-1 Geometry.
CALLING SEQUENCE:
COLLDIRS, Module,RAY,DEY,RAZ,DEZ [,RAc,DECC]
INPUTS:
Module: Module number of the collimator (1-7), [integer].
RAY,DEC: The RA,DEC of the satellite's Y-axis in RADIANS, [float(nbin)].
OPTIONAL OUTPUTS:
RAc,DECc: The RA,DEC of the collimator viewing direction, [float(nbin)].
OPTIONAL KEYWORD OUTPUTS:
RC: The unit direction vector in spherical coordinates of the
collimator viewing direction, [float(3,nbin)].
RESTRICTIONS:
NOTE: you can also call this routine with scalar input arguments.
EXAMPLE:
let's choose a RA,DEC near the poles and determine the
viewing direction for collimator 3.
RA = 75.5*!dtor
DEC= 89.8*!dtor
COLLDIRS, 3, RA, DEC, RA_M3, DEC_M3, RC=Vec_M3
MODIFICATION HISTORY:
Written by: Han Wen, June 1994.
(See /host/bluemoon/usr2/idllib/contrib/groupk/colldirs.pro)
NAME:
COLLF
PURPOSE:
Function to return the HEAO A-1 collimator response function,
that is, transmission or efficiency, for a given detector module.
CATEGORY:
Collimator.
CALLING SEQUENCE:
Result = COLLF( Module,Ras,Des,Ray,Dey,Raz,Dez [,Theta,Phi])
INPUTS:
Module: Module number, in range 1-7, [integer].
Ras,Des: The RA, DEC of the source in RADIANS, [float].
Ray,Dey: The RA, DEC of the +Y axis in RADIANS, [float] or [float(nbin)].
Raz,Dez: The RA, DEC of +Z axis in RADIANS, [float] or [float(nbin)].
OUTPUTS:
This function returns the collimator response function (transmission)
for the given direction(s) specified by the aspect information,
[float] or [float(nbin)].
OPTIONAL OUTPUTS:
Theta,Phi: The collimator position angles defined in COLLMATR
in RADIANS, [float] or [float(nbin)].
MODIFICATION HISTORY:
Written by: Daryl J. Yentis, Naval Research Laboratory, SSD 1980.
12-NOV-1992 K.H. Fairfield, change to IMPLICIT NONE; use
Fortran 77 block structure.
22-JUN-1994 H.C. Wen, converted into an IDL routine, vectorized
routine to accept vector inputs.
(See /host/bluemoon/usr2/idllib/contrib/groupk/collf.pro)
NAME:
COLLINIT
PURPOSE:
To convert this into IDL code, the COMMON CLLMTR is needed to store
these coefficients as static variables.
H.C. Wen, 22-JUN-1994
NRLDIR:COLLMAT.INC
==================
Include file which declares the coefficient arrays, A,B,C,D,E,F,G,H,
and WT,WP, TF, and PF, used in the function COLLMATR to calculate
the collimator transmission function. Comments below from the
original NRL code. The orignal was a SUBROUTINE with DATA initiali-
zation statements for the arrays in COMMON /CLLMTR/. This INCLUDE
file obviates the need for a COMMON, which has been removed.
K.H. Fairfield, 12-NOV-1992
Original Comments:
06/29/77 KINZER-MEEKINS
03/29/78 JALAL SAMIMI----MODIFIED USING CRAB OBSERVATIONS.
08/29/78 SNYDER
10/25/78 MEEKINS
For more information than is contained herein see the paper,
Kinzer, HEAO Collimators Monte-Carlo Simulation. This routine (sic)
is used to both act as a single repository of collimator data and
to supply this data to the user if desired. Note that this routine
should be called before any data in the COMMON BLOCK, CLLMTR, is
used. The collimator number, I, identifies the collimator:
I=1(4x1), =2(2x8), =3(1/2x1), =4(1/2x1), =5(SUM 4x1s). Values given
are for one keV, values for energies up to 20 keV are identical.
THETA is the angle to coll zenith in the plane of the coll zenith
and the s/c spin axis.
PHI is the angle to collimator zenith in the plane orthogonal to
the spin axis. Offsets in both THETA and PHI have been included
(TF and PF) in order that intentional or unintentional
misalignments with the s/c look direction (Y-axis) be treated.
THETA is positive when toward the spin axis, PHI is positive in
direction of spin. The collimator response has been fit to cubic
polynomials. An algorithm for calculating the collimator response,
CR, for a look angle (TH,PH, measured wrt the Y-axis) might be as
follows (T is equiv. to THETA and P is equiv. to PHI):
T=ABS(THETA-TF)
P=ABS(PHI-PF)
CRT=A+T*(B+T*(C+T*D))
CRP=E+P*(F+P*(G+P*H))
CR=CRT*CRP
IF((P.GT.WP).OR.(T.GT.WT)) CR=0.
Note that THETA and PHI must be in radians and that WT,TF,WP, and
PF are in radians.
CATEGORY:
Collimator.
CALLING SEQUENCE:
COLLINIT
INPUTS: None.
OUTPUTS:
This routine initializes the CLLMTR common so that the routines,
COLLMATR and COLLF may be subsequently used.
COMMON BLOCKS:
CLLMTR: Coefficient arrays which hold information needed to
calculate the collimator transmission function.
RESTRICTIONS:
You must call this routine before using COLLMATR or COLLF. Currently,
COLLMATR automatically calls COLLINIT if the WT variable has not
been initialized.
MODIFICATION HISTORY:
Written by: See Above.
22-JUN-1994 H.C. Wen, converted include file into an IDL routine.
15-AUG-1995 Comment bugfix: removed extraneous ;+ and ;-.
(See /host/bluemoon/usr2/idllib/contrib/groupk/collinit.pro)
NAME:
COLLMATR
PURPOSE:
For a given collimator (module) index, and given angle with
respect to the collimator axis, calculates the transmission
function. See original comments below.
CATEGORY:
Collimator.
CALLING SEQUENCE:
Result = COLLMATR( I,TH,PH )
INPUTS:
I: An integer giving the collimator index, in the range 1-5.
TH: A real value giving the angle THETA in RADIANS (see below).
PH: A real value giving the angle PHI in RADIANS (see below).
OUTPUTS:
This function returns the value(s) of the transmission function
for the provided angles relative to the collimator axis
in the range 0.0 to 1.0.
COMMON BLOCKS:
CLLMTR: Coefficient arrays which hold information needed to
calculate the collimator transmission function.
MODIFICATION HISTORY:
NOTES:
The original comments refer to "ENTRY XXXX", while,
in fact, there were NO entry points. Instead, there is a computed
GOTO which jumps (supposedly) to particular labels ("entry points").
However, the GOTO variable, IENT, was LOCAL and defined to be zero
on entry to this procedure, so ONLY the Collimator function was
returned. The other functions in the package were unavailable.
See revision of 11/12/92 below.
AUTHOR/DATE: Meekins, 25-JUL-1979
REVISIONS:
H.C. Wen, 22-JUN-1994:
Converted into an IDL routine, restored COMMON CLLMTR
15-AUG-1995 Comment bugfix: removed extraneous ;+ and ;-.
K.H. Fairfield, 12-NOV-1992:
Changed to IMPLICIT NONE. Removed COMMON /CLLMTR/ in favor of
INCLUDE file data initailization of coefficient arrays. Edited
original comments.
Separated each "entry" into its own function, each includes the
coefficient-array data initialization file. Makes the image
smaller after linking; makes the "entry" points available to
callers again.
ORIGINAL COMMENTS:
=================
INSTRUMENT, HEAO-A1, COLLIMATOR. CODED FOR CDC3800.
This routine is used to find the following:
Collimator function (entry COLLMATR)
First Derivative of the collimator function wrt THETA (entry DCOLLDTH)
First Derivative of the collimator function wrt PHI (entry DCOLLDPH)
Integral of the collimator function over THETA, from
-Infinity to THETA (entry COLLITH)
Integral of the collimator function over PHI, from
-Infinity to PHI (entry COLLIPH)
Integral of the collimator function over THETA and PHI from
-Infinity to THETA and PHI (entry COLLINT)
All functions are evaluated at the angles THETA=TH and PHI=PH.
Note that TH and PH must be in radians and that all functions are
determined in radians. The collimator number, I, corresponds to
the collimators as follows:
I=1(4x1), =2(2x8), =3(1/2x1), =4(1/2x1), =5(ave of 4x1s)
TH is the angle wrt the s/c Y-axis in the X-Y plane,
PH is the angle wrt the s/c Y-axis in the Y-Z plane.
Y-axis is the nominal detector look direction.
X-axis is the roll axis.
THETA is positive when toward the X-axis,
PHI is positive in the direction of spin.
Note that the COMMON BLOCK, CLLMTR, is used. The data in this
COMMON BLOCK are provided by the SUBROUTINE COLLMAT, which must
be called before using this routine.
WT (WP) and TF (PF) are the width and offset of the collimator in
the THETA (PHI) directions.
15-AUG-1995 Comment bugfix: removed extraneous ;+ and ;-.
(See /host/bluemoon/usr2/idllib/contrib/groupk/collmatr.pro)
NAME:
CTIFMT
PURPOSE:
This routine concatenates and corrects all the data contained
in a PTI file (created by HBRFMT). All Adjacent Photon Events (APE)
and any photons in BAD minor frames are removed. A BAD minor frame
occurs when there are one or more HBRSYNC errors (e.g. missing MNFs,
Clock TicTok errors, sync loss, etc). This concatenated and corrected
data is then written to a binary file in the Concatenated Time
Interval (CTI) format.
CATEGORY:
HEAO HBR.
CALLING SEQUENCE:
CTIFMT, FILES=Files, PTIPATH=PTIPath, CTIPATH=CTIpath
INPUT KEYWORD PARAMETERS:
FILES: A array of filenames for each raw HBR digitized file.
PTIPATH: Path to the specified input PTI files, (''=Default).
CTIPATH: Path to the output CTI files, (''=Default).
OPTIONAL INPUT KEYWORD PARAMETERS:
QUIET: Suppress all print messages to the display, (0=Default).
OUTPUTS:
The Concatenated Time Interval (CTI) format consists of 19 variable
length records. The first record contains a sequence of numbers:
[0,1,2...511] that may be used to determine the byte order of the
binary file relative to your current platform. Each subsequent
record contains a 4-byte record header followed by data. The record
header should be read into a long integer and it contains the length
of the data in BYTES. The 19 records are defined as follows:
Record Variable/ Description
Number Array
______ ______________ ______________________________________________
0 intarr(512) Numbered sequence: [0,1,2...511]. This record
may be used to determine the byte order of the
CTI binary file. Namely, if it is Big Endian
or Little Endian.
1 bytarr(nb)* Name associated with this HBR data file,
SSS_TT_FF. SSS=NRL sequence number,
TT=NRL tape number, FF=NRL file number on the
tape.
2 bytarr(nb) Name of the celestial target that the HBR
data is taken from.
3 bytarr(nb) Name of IDL procedure that created the CTI
file, 'CTIFMT.PRO'.
4 bytarr(nb) Date/time of CTI creation, SYSTIME().
5 bytarr(nb) Filename of the PTI file, including path.
6 bytarr(nb) IDL platform used to create CTI file, !VERSION.
7 bytarr(nb) Date/time of the HBR data acquisition.
8 integer Revolution number of the HEAO satellite during
HBR data acquisition.
9 intarr(3) Various HEAO A-1 electronics modes:
intarr(0): Which modules selected for the
random encoder -> HBR data:
3 - modules 1-4
7 - module 7
intarr(1): Mode of the NRZ data:
5 - 5 msec
320- 320 msec
intarr(2): Mode of the HEAO satellite:
0 - scanning/spinning
1 - pointing
10 lonarr(nb/4) Major frame numbers.
11 intarr(512,nm) Major frame headers** created by HBRFMT,
nm = nb/(512*2).
12 intarr(16,nn) Minor frame headers** created by HBRFMT,
nn = nb/(16*2).
13 integer Overall Global Data Validity flag (0=Ok, NO
HBRSYNC errors detected in entire data file).
14 intarr(128,nr) Normal 6.4 kbps telemetry data (NRZ),
nr = nb/(128*2).
15 lonarr(nb/4) Corrected photon time intervals.
16 lonarr(nb/4) Corresponding photon times relative to the
beginning of the minor frame containing the
first photon.
17 lonarr(2,na) The beginning and end of time regions where
one or more HBRSYNC error were detected.
The times are relative to the beginning of the
MNF containing the 1st photon, na = nb/(2*4).
18 intarr(nb/2) Number of Adjacent Photon Events (APE) found
in each MJF.
*nb = the length of the data in BYTES, i.e. 4-byte record header.
*All of the byte arrays are strings converted to their ASCII numbers
equivalent. To extract the string corresponding to a byte array,
apply the string function, (e.g. str = string(b) where b=bytarr(nb))
**For a complete description of the headers, see DEF_HBRH.PRO.
RESTRICTIONS:
The def_hbrh.pro routine must be previously compiled.
COMMON BLOCKS:
DEF_HBRH: Holds all the MJF and MNF PTI pointers, (see def_hbrh.pro).
PROCEDURE:
The PTI file is read in one MJF block of data at a time. Adjacent
Photon Events (APE) are removed using KILLAPE.PRO and any photons
falling within BAD minor frame regions are also excluded. The
corrected PTIs are subsequently concatenated with the overall PTI
array. The MJF and MNF headers as well as the NRZ blocks are similarly
concatenated. Once all the MJF blocks have been read in and processed,
the concatenated arrays are then written to binary file in the CTI
format described above.
MODIFICATION HISTORY:
Written by: Han Wen, September 1995.
18-SEP-1995 Bugfix: Eliminate non-existing NRZ data associated with
each MNF header containing missing MNFs.
26-SEP-1995 Added the DBS tag.
27-SEP-1995 Moved Date & File tags into Origin; expanded Origin tag;
added Name and GDV tag.
29-SEP-1995 Take care of possible 16-bit overflows in DELBEG and DELEND.
30-SEP-1995 Transferred to task of removing non-existing NRZ data to
READPTI; take care of missing MJF possibility; changed
version tag from named (!version) to anonymous structure
to avoid incompatibilities across different versions of IDL.
09-OCT-1995 Formerly, CATPTI. Write out binary file in CTI format
instead of saving a structure variable to an IDL save
session.
(See /host/bluemoon/usr2/idllib/contrib/groupk/ctifmt.pro)
NAME:
CUBIC
PURPOSE:
Solve for the roots of a cubic polynomial OR
find the value(s) of a cubic polynomial (INVERSE)
CATEGORY:
Math.
CALLING SEQUENCE:
Result = CUBIC( X, Coeff )
INPUTS:
X: For the forward transform, it is the VALUE of the cubic
polynomial. If the INVERSE keyword is set then it is
the ARGUMENT of the cubic polynomial.
Coeff: Array of coefficients of the cubic polynomial, fltarr(4).
KEYWORD PARAMETERS:
INVERSE: Set this keyword to determine the value of the cubic
polynomial, (0=Default).
OUTPUTS:
Returns the ARGUMENT of a cubic polynomial for the forward
transform or the VALUE of a cubic polynomial for the inverse
transform (if the INVERSE keyword is set).
MODIFICATION HISTORY:
Written by: Han Wen, October 1994.
(See /host/bluemoon/usr2/idllib/contrib/groupk/cubic.pro)
NAME:
CUSPOLYN
PURPOSE:
This function returns a "cusp" polynomial determined by a given set of
coefficients.
CATEGORY:
Curve and surface fitting.
CALLING SEQUENCE:
Result = CUSPOLYN( Degree, X, Y, Coeff [,/MATRIX])
INPUTS:
Degree: The degree (in one dimension) of the 2D polynomial, [integer].
X,Y: The x- and y-vectors [double(npt)].
Coeff: The vector of coefficients for the cusp-polynomial,
which is dimensioned as [double( (Degree+1)^2 )]. (See SFITCUSP)
INPUT KEYWORDS:
MATRIX: Treat X as a "row" vector and Y as a "column" vector and find
the cusp-polynomial matrix associated with this XY-matrix.
OUTPUT:
This function returns the values of the cusp-polynomial at the values
set by the X and Y vectors, [double(npt)] OR [double(nx,ny)] if MATRIX
keyword is set.
PROCEDURE:
The cusp-polynomial is defined as:
F(x,y) = Sum over i and j of coeff(i*(degree+1)+j) * abs( x^i * y^j )
MODIFICATION HISTORY:
July, 1994 H.C. Wen
24-AUG-1994 Added MATRIX keyword to return a fit "matrix"
Return a fit "matrix" whose x-component is
defined by the x array and y-component is defined
by the y array. (i.e. fit_matrix( x, y ))
(See /host/bluemoon/usr2/idllib/contrib/groupk/cuspolyn.pro)
NAME:
DEADCORR
PURPOSE:
This function corrects for dead time in the HEAO A-1 detector.
The dead time and collimator response function were fitted for
using the data on the Crab from module 3 ONLY.
CATEGORY:
HEAO A-1 Scanning.
CALLING SEQUENCE:
Result = DEADCORR( Mode, Cts )
INPUTS:
Mode: Scanning timing mode in MILLISECONDS (320 ms or 5 ms).
Cts: Array of HEAO A-1 counts, UNCORRECTED for dead time.
OPTIONAL INPUT KEYWORD PARAMETERS:
EXTENDED: Set this keyword to specify extended or paralyzable
dead time corrections. Otherwise, NON-extended or
NON-paralyzable dead time corrections will be made, namely,
(0=Default).
OUTPUTS:
An array of counts, CORRECTED for dead time is returned.
OPTIONAL INPUT KEYWORD PARAMETERS:
OTAU: Dead time used to correct the data in MICROSECONDS.
ONC: Charged particle rate assumed in COUNTS/mode.
COMMON BLOCKS:
DEADCORR: Dead times and charged particle rates used by this
routine. See DEADINIT.
RESTRICTIONS:
The dead time used in this routine (14.4 microsec, NON-extended)
has been determined by studying ONLY collimator module 3 data on
the Crab.
MODIFICATION HISTORY:
Written by: Han Wen, 10-3-94.
(See /host/bluemoon/usr2/idllib/contrib/groupk/deadcorr.pro)
NAME:
DEADINIT
PURPOSE:
This procedures defines the dead times and charged particle rates
used to correct HEAO A-1 scanning counts for dead time.
CATEGORY:
HEAO A-1 Scanning.
CALLING SEQUENCE:
DEADINIT
COMMON BLOCKS:
DEADCORR: Dead times and charged particle rates defined here.
RESTRICTIONS:
The dead time used in this routine (14.4 microsec, NON-extended)
has been determined by studying ONLY collimator module 3 data on
the Crab.
PROCEDURE:
This routine is automatically called by DEADCORR. The USER does
not have to call this routine.
MODIFICATION HISTORY:
Written by: Han Wen, 10-3-94.
(See /host/bluemoon/usr2/idllib/contrib/groupk/deadinit.pro)
NAME:
DEF_HBRDBS
PURPOSE:
This routine defines the HEAO HBR database containing info on each
HEAO HBR data file.
CATEGORY:
HEAO HBR.
CALLING SEQUENCE:
DEF_HBRDBS
OPTIONAL INPUT KEYWORD PARAMETERS:
VERBOSE: Set this keyword to output a detailed listing of the
HBR database structure.
OUTPUTS:
A common block structure variable, HBRDBS_ gets defined. HBRDBS_ is
an array of structures, one element for each HBR data file. The tags
of each structure are defined as follows:
SLAC: Structure describing the location of the file in
the SLAC silos. The tags of this structure are:
volser: Volume serial number
seq: Sequence number
NRL: Structure describing the location of the file at NRL.
The tags of this structure are:
seq: Sequence number of the ANALOG tape ..
tape: Tape number of the DIGITIZED tape ..
file: File number on the DIGITIZED tape ..
.. containing this HBR data file.
chron: Structure describing when the HBR data was downlinked
to the ground station. The tags of this structure are:
dd: Day of the month (1-31)
mn: Month (1-12)
yy: Year (1977-1978)
hh: Hour (0:23)
mm: Minute (0:59)
ss: Seconds (0:59)
doy: Day of the year (1:365)
JD: Julian day number, long
mode: Structure describing the current modes of the HEAO
electronics and satellite. The tags of this structure are:
config: String describing K. Woods configuration notes
HBR: Mode of HEAO Random Decommutator,
{'bit','frame' or 'word')
PM: Describes which modules have been selected for
HBR data,(3 = Scan modules, 1-4; 7 = Module 7).
NRZ: Mode of the NRZ data, (5 = 5ms; 320 = 320ms).
sat: Describes the state of the satellite,
('S' = spinning/scanning; 'P' = pointing)
rev: HEAO satellite revolution number, integer.
pass: Ground station pass abbreviation, ('H' = Hawaii;
'G' = 'Guam';...).
length: Length of the data in MINUTES, float.
target: Description of the celestial target, string.
comments: Miscellaneous comments, string.
COMMON BLOCKS:
DEF_HBRDBS: This common block holds all the info on each HEAO HBR
data file in its structure array, HBRDBS_.
PROCEDURE:
The HBRDBS.SAV file, which contains the HBRDBS_ structure is restored.
MODIFICATION HISTORY:
Written by: Han Wen, September 1995.
06-AUG-1996 Simplified directory structure, added VERBOSE keyword.
(See /host/bluemoon/usr2/idllib/contrib/groupk/def_hbrdbs.pro)
NAME:
DEF_HBRH
PURPOSE:
This routine defines all the pointers and bits to the Major Frame
and Minor Frame headers for the Photon Time Interval (PTI) format.
CATEGORY:
HEAO HBR.
CALLING SEQUENCE:
DEF_HBRH
OUTPUTS:
A common block gets filled with pointer and bit values. See below
for definition of the common block.
COMMON BLOCKS:
DEF_HBRH: This common block holds all the pointers and bits to the
MJF and MNF headers.
NWMJFH: Length of a MJF header in WORDS
MJFptr_: A structure containing the index values and their
associated names of all the pointers to the MJF
header.
MJFbit_: A structure containing the bit values and their
associated names of the MJF Flags variable.
MJFmark: Value of the MJF marker.
NWMNFH: Length of a MNF header in WORDS
MNFptr_: A structure containing the index values and their
associated names of all the pointers to the MNF
header.
MNFbit_: A structure containing the bit values and their
associated names of the MNF Flags variable.
MNFmark: Value of the MNF marker.
(*Note: For a description of each pointer or bit, see DEF_HBRH.pro)
MODIFICATION HISTORY:
Written by: Han Wen, July 1995.
(See /host/bluemoon/usr2/idllib/contrib/groupk/def_hbrh.pro)
NAME:
DEF_MJF
PURPOSE:
Defines the anonymous major frame data structure appropriate
for the given data file.
CATEGORY:
I/O
CALLING SEQUENCE:
Result = DEF_MJF( Unit [, FORMAT=Format] )
INPUTS:
Unit: Logical unit associated with the data file.
INPUT KEYWORD PARAMETERS:
FORMAT: String describing the format of the data file.
The following formats are defined:
================================================================
ASPECTS : This is the "current" data format (11/14/94)
used by FMT_IDL. The resulting structure tags
or members are defined as follows:
----------------------------------------------------------------
Format : Name of the file format = 'ASPECTS'
Mjf : Major frame number, [long integer].
Mode : Timing mode of the scan in milliseconds (320 or 5).
Module : Module number (3, 4, 5, 6 or 7).
T77i,T77f: Integer,fraction of time at the start of major frame in seconds
since 1977, [long integer, double].
T77c : Barycentric time correction for the primary source
at the beginning and end of the major frame in
seconds, [ double(2,nsrc) ].
Raz,Dez : The RA,DEC of the satellite's Z-axis at the start of
this major frame in DEGREES, [double].
Sat : Structure holding information about the satellite's
position with the following tags defined:
xyz : Satellite 3-vector from the earth at
the beginning and end of the major frame,
[ float( 3,2 )].
aspects : Structure holding the aspects of the
satellite at each bin with the following
tags defined:
y : The RA and DEC of the y-axis
in RADIANS, [ float( 2, nbin )]
z : The RA and DEC of the z-axis
in RADIANS, [ float( 2, nbin )]
Ray,Dey : The RA of the satellite's Y-axis at the start of
this major frame in DEGREES, [double].
Nsrc : Number of sources = 1 (Kept to maintain backward
compatibility with the STANDARD format).
Srcnam : Name of the primary source, [string].
SrcRA : RA of the primary source in DEGREES, [ double ].
SrcDEC : DEC of the primary source in DEGREES, [ double ].
Nbin : Number of bins in each major frame.
Cts : An array holding the counts for this major frame,
[ float(nbin) ].
Trns : A 1 x nbin array holding the transmission
functions of the primary source for this major frame,
[float( 1, nbin )].
================================================================
STANDARD : This is the "standard" data format most
commonly used by FMT_SRCDATA. This format contains
information for multiple sources specified by
the user in FMT_SRCDATA. It is identical to the
ASPECTS format with the omission of the tags:
( sat, format )
and modifications to the following tags:
----------------------------------------------------------------
T77c : Barycentric time correction for each source at the
beginning and end of the major frame in seconds,
[ double(2,nsrc) ].
Nsrc : The number of sources for which transmission
functions are given in the data, (1-20).
Srcnam : A string array of the names of the sources,
[string( Nsrc)].
SrcRA : An array of the source RA's in DEGREES, [ double( Nsrc ) ].
SrcDEC : An array of the source DEC's in DEGREES, [ double( Nsrc ) ].
Trns : A (Nsrc) x nbin array holding the transmission
functions of each source for this major frame,
[float( nsrc, nbin )].
================================================================
NOBARY : This is an older data format whose structure is
identical to the STANDARD format except for the
omission of the T77c member.
================================================================
DIRS : This format is identical to the NOBARY format
except for the addition of two new members:
----------------------------------------------------------------
Phis : The scan longitude in RADIANS for each bin in the
major frame [double(nbin)].
Thts : The scan latitude in RADIANS for each bin in the
major frame [double(nbin)].
OUTPUTS:
Returns the anonymous major frame data structure as described
above under the FORMAT keyword specification.
COMMON BLOCKS:
MJF_COM: Holds a copy of the data structure in the MJFstruc variable
so that other routines can copy this anonymous structure. This
method was chosen over a NAMED data structure because the
dimension of some of the members or tags may change depending
on different data files.
RESTRICTIONS:
This routine must be called before any calls to READ_MJF.
EXAMPLE:
EXAMPLE:
Let's create some arrays and read in the first major frame of
a data file with data from the Crab pulsar at 320 ms mode.
openr,unit,'crab.idl',/GET_LUN
MJFstrucvar = DEF_MJF( Unit )
ISS = READ_MJF( Unit, DATA=Data )
MODIFICATION HISTORY:
Written by: Han Wen, August, 1994.
25-AUG-1994 Added the DIRS format for response function
calibration.
(See /host/bluemoon/usr2/idllib/contrib/groupk/def_mjf.pro)
NAME:
DEVICE_MGR
PURPOSE:
Manages the graphics device for two "standard" orientations,
LANDSCAPE (default) and PORTRAIT.
CATEGORY:
I/O.
CALLING SEQUENCE:
DEVICE_MGR [, Dev]
OPTIONAL INPUTS:
Dev: Name of the graphics device,[string]. If this argument
is not provided then the graphics device defaults to
'WIN' or 'X' depending on the OS. Devices currently
supported are: 'WIN','X','PS','PCL'
OPTIONAL INPUT KEYWORD PARAMETERS:
ORIENTATION: Orientation of the graphics device output, either
'LANDSCAPE' (default) or 'PORTRAIT', [string].
WINDOW: If the graphics device is 'WIN' or 'X', this
keyword specifies the window number, 0=Default.
CLOSE: Set this keyword to close the current graphics
device. If the curent graphics device is non-display,
then setting this keyword = 2 will additionally delete
the output file.
PRINT: Set this keyword to close the current output file and
send it to the printer as defined by the environment
variable, PRINTER. Setting this keyword to 2 will
additionally delete the output file.
QUERY: If the graphics device is 'WIN' or 'X' and
the CLOSE keyword is set, then setting this keyword
will cause the USER to be queried for the deletion
of each open window.
FILENAME: Filename and path of the output file for non-display
graphics devices. If this keyword is not specified then
a TMP file is created in the appropriate tmp directory,
idl##### where ##### is a random number between 00000-99999.
APPEND: Appends the graphics device output to the current
output file. The graphics device cannot be 'X' nor 'WIN'.
SILENT: Set this keyword if you do not want any informational
messages printed to the display. (0=Default)
QUEUE: String defining the printer device name, (e.g. 'ek_ps').
[Default=GETENV('PRINTER')]
OTHER_KEYWORDS: Any other additional keywords are passed via
the _EXTRA keyword to either the WINDOW or the DEVICE
routine depending upon the graphics device.
OUTPUTS:
Output of the graphics device is either sent to the screen
in a LANDSCAPE or PORTRAIT window, or to an output file depending
upon the graphics device.
OPTIONAL OUTPUT KEYWORD PARAMETERS:
OFILENAME: Filename and path of the output file for non-display
graphics devices. This is useful if you did not specify
the FILENAME keyword and would like to know the name of the
TMP file created.
COMMON BLOCKS:
DEVMGR_COM: This common block holds the filename of the
graphics output, dvmgr_fn.
RESTRICTIONS:
Currently the only OS platforms supported by this routine
are: Windows/DOS and Unix.
EXAMPLE:
Create a simple plot and output it to both a window and an
output file.
x = findgen(100)
y = 100.*exp(-((x-50.)/20.)^2. )
DEVICE_MGR,'WIN'
plot,x,y
DEVICE_MGR,'PS'
plot,x,y
DEVICE_MGR,'PS',/close
DEVICE_MGR,'WIN',/close
MODIFICATION HISTORY:
Written by: Han Wen, November 1994.
03-JAN-1995 Replaced INQUIRE with XQUERY.
21-JAN-1995 Replaced XQUERY with YNCANCEL. (Added WSHOW before
and after YNCANCEL).
23-JAN-1995 Added the RESET keyword
25-JAN-1995 Renamed the common block variable names to more
obscure names (i.e. unlikely to be used by the USER).
28-JAN-1995 Fixed a few minor bugs when closing multiple Windows.
30-JAN-1995 Added the SILENT keyword, and CLOSE=2 option.
08-FEB-1995 Changed default output filename from idltmpnn.ps to
idlnnnnn.ps
29-APR-1995 Added the OFILENAME keyword. I could have passed this
value to the FILENAME keyword, but I did not want to
overload its functionality.
03-MAY-1995 >Added the ANONYMOUS_ keyword to avoid a very subtle/
rare bug with _EXTRA keyword. (Has no functionality
for the USER -> Internal user only.)
>Moved spawn print command to PRINT_FILE
02-JUN-1995 Implemented VERSION routine.
14-JUN-1995 Use WINDOW_STATE keyword to keep track of open
windows instead of devmgr_com.
21-JUN-1995 Do NOT use SET_PLOT,dev if dev is the current device.
19-OCT-1995 Added the PRINTER keyword.
29-JUL-1996 Changed PRINTER keyword name to QUEUE. Added the PRINT
keyword. HARDCOPY keyword now obsolete; although it
will still work to maintain backward compatibility.
07-AUG-1996 Remove calls to VERSION(). Check OS platform.
(See /host/bluemoon/usr2/idllib/contrib/groupk/device_mgr.pro)
NAME:
DIR_EXIST
PURPOSE:
This function tests for the presence of a directory.
CATEGORY:
I/O.
CALLING SEQUENCE:
Result = DIR_EXIST( Dir )
INPUTS:
Dir String holding the name of the directory you want to
test the existence of.
OUTPUTS:
This function returns 1 if the specified directory exists or
0 if the specified directory does NOT exist.
EXAMPLE:
To check the existence of a '\TMP' directory type:
iss = DIR_EXIST('\TMP')
if (iss eq 1) then print,'TMP directory EXISTs.' $
else print,'TMP directory does NOT exist.'
MODIFICATION HISTORY:
Written by: Han Wen, June 1995.
Copied from !News TECH TIPS.
(See /host/bluemoon/usr2/idllib/contrib/groupk/dir_exist.pro)
NAME:
DTPOIDEV
PURPOSE:
Return an integer random deviate drawn from a dead-time-distorted
Poisson distribution with a specified mean. Adapted from POIDEV
procedure in "Numerical Recipes" by Press et al. (1986), Section 7.3
and IDL Astronomy User's library routine of the same name by
Wayne Landsman.
CALLING SEQUENCE:
result = DTPOIDEV( Xm, Npts, Tinterval, Deadtime, [ SEED = ] )
INPUTS:
Xm: Mean of the ORIGINAL (undistorted) Poisson distribution.
Npts: Number of deviates to generate.
Tinterval:The length of the measuring time bin.
Deadtime: The length of the NON-EXTENDED dead time in the SAME units
as Tinterval.
OUTPUT:
An array of deviates, [LONARR(Npts)].
OPTIONAL KEYWORD INPUT-OUTPUT:
SEED - Scalar to be used as the seed for the random distribution.
For best results, SEED should be a large (>100) integer.
If SEED is undefined, then its value is taken from the system
clock (see RANDOMU). The value of SEED is always updated
upon output. This keyword can be used to have POIDEV give
identical results on consecutive runs.
EXAMPLE:
(1) Add dead-time-distorted Poisson noise to an integral image array, im
IDL> imnoise = POIDEV( im, 100, tbin, tau)
(2) Verify the expected mean and sigma for an input value of 81
IDL> p = POIDEV( 81, 10000,1,1e-3) ;Test for 10,000 points
IDL> print,avg(p),sigma(p)
Average and sigma of the 10000 points should be close to
81/(1+81*1e-3)=75 and (1+81*1e-3)^(-3/2)*9=8.
RESTRICTIONS:
Negative values in the input array will be returned as zeros.
Note: there are very subtle correlations between sequential time bins
in the presence of dead time. The time interval between the beginning
of a bin and the first count is correlated to the interval between
the last count of the previous bin. This correlation occurs when
the time interval between the last count of the previous bin and the
end of the time bin is less than the dead time.
PROCEDURE:
For small values (observed counts < 20) independent exponential
deviates offset by a dead time are generated until their sum exceeds
the specfied mean, the number of events required is returned as the
Poisson deviate. For large (observed counts > 20) values, uniform
random variates are compared with a Lorentzian distribution function.
REVISION HISTORY:
Adapted from Landsman, POIDEV: Han Wen, July 1996.
26-JUL-1996 Bugfix: Lorentzian distribution function falls below
d-t-d Poisson distribution at low observed counts and
low means. Reapplied technique of independent exponential
deviates (with a dead time offset) for cases when the
observed counts falls below 20.
(See /host/bluemoon/usr2/idllib/contrib/groupk/dtpoidev.pro)
NAME:
EATOM
PURPOSE:
Generate rotation matrix given 3 euler angles
CATEGORY:
Analytic geometry.
CALLING SEQUENCE:
EATOM, A, B, C, D
INPUTS:
A: First euler angle in radians, [float] or [float(nbin)].
B: Second euler angle in radians, [float] or [float(nbin)].
C: Third euler angle in radians, [float] or [float(nbin)].
THE EULER ROTATION IS DEFINED AS FOLLOWS:
1) ROTATE CCW BY ANGLE A ABOUT Z-AXIS GIVING X', Y', Z'-AXES
2) ROTATE CCW BY ANGLE B ABOUT X'-AXIS GIVING X", Y", Z"-AXES
3) ROTATE CCW BY ANGLE C ABOUT Z"-AXIS
OUTPUTS:
D: Returned 3x3 rotation matrix as a 1-D array, [float(3,3)]
or [float(3,3,nbin)].
REFERENCE:
CLASSICAL MECHANICS, H. GOLDSTEIN, ADDISON WESLEY, 1950, P 107 FF
The three euler angles define a coordinate system rotation
from the original axes to a new set of axes. The rotation
matrix returned by EATOM rotates the coordinates of a vector
in the original axes to the coordinates in the new set.
x' = Dx
MODIFICATION HISTORY:
Written by: K.H. Fairfield, 1993.
06-JUN-94: Modified into an IDL routine, H.C. Wen.
22-JUN-94: Vectorized routine to accept vector inputs
(See /host/bluemoon/usr2/idllib/contrib/groupk/eatom.pro)
NAME:
END_SCAN
PURPOSE:
Closes the data file used by GET_SCAN to extract
HEAO A-1 data.
CATEGORY:
I/O
CALLING SEQUENCE:
END_SCAN
INPUT KEYWORD PARAMETERS:
NOWARN: Suppress printing of warning messages to screen.
LOG: Output warning messages to log file.
OUTPUTS:
Closes the current data file associated with the buffer.
MODIFICATION HISTORY:
Written by: H.C. Wen, May, 1994.
15-MAY-1994 Changed logical unit to file pointer.
26-JUN-1994 Eliminated multiple file option. Change file pointer
back to logical unit.
01-AUG-1994 Formerly named CLOSE_BUF
09-AUG-1994 Added the close statement
(See /host/bluemoon/usr2/idllib/contrib/groupk/init_scan.pro)
NAME:
EQUIV
PURPOSE:
This procedure equates arrays of different integer types, similar to
Fortran's Equivalence function.
CATEGORY:
I/O.
CALLING SEQUENCE:
EQUIV, Target, Source [, iTar, iSrc]
INPUTS:
Target: Target array.
Source: Source array.
OPTIONAL INPUTS:
iTar: Starting index of the target array. If this parameter is
not provided, 0 is the default.
iSrc: Starting index of the source array. If this parameter is
not provided, 0 is the default.
OUTPUTS:
Starting from index, iTar, the Target array gets filled with "equivalent"
elements from the Source array starting from the Source index, iSrc up
until the end of the Source or Target array depending upon which one ends
first.
PROCEDURE:
Assuming iTar and iSrc = 0, if the Target is an integer array and the Source
is a longword integer array, then the least significant 16-bits of Source are
put into the "even" elements of Target, while the most signficant 16 bits of
Source are put into the "odd" elements of Target. If the situation is reversed,
then the "even" elements of Source are put into the least significant 16-bits
of Target, while the "odd" elements are put into the most significant 16-bits
of Target.
EXAMPLE:
a = 1234567890L
b = intarr(2)
EQUIV,b,a
MODIFICATION HISTORY:
Written by: Han Wen, July 1995.
(See /host/bluemoon/usr2/idllib/contrib/groupk/equiv.pro)
NAME:
EULER2
PURPOSE:
Transform between galactic, celestial, and ecliptic coordinates.
Use the procedure ASTRO to use this routine interactively
CALLING SEQUENCE:
EULER, AI, BI, AO, BO, [ SELECT ]
INPUTS:
AI - Input Longitude in RADIANS, scalar or vector. If only two
parameters are supplied, then AI and BI will be modified to
contain the output longitude and latitude.
BI - Input Latitude in RADIANS
OPTIONAL INPUT:
SELECT - Integer (1-6) specifying type of coordinate transformation.
SELECT From To | SELECT From To
1 RA-DEC(1950) GAL.(ii) | 5 ECLIPTIC GAL.(ii)
2 GAL.(ii) RA-DEC | 6 GAL.(ii) ECLIPTIC
3 RA-DEC ECLIPTIC | 7 System A System B
4 ECLIPTIC RA-DEC | 8 System B System A
If omitted, program will prompt for the value of SELECT
OUTPUTS:
AO - Output Longitude in RADIANS
BO - Output Latitude in RADIANS
REVISION HISTORY:
Written W. Landsman, February 1987
Adapted from Fortran by Daryl Yentis NRL
22-JUN-1994: H.C. Wen, change angle units from degrees to radians.
Added SETSYB keyword, and 2 more conversion options:
System A to System B
======== ========
System B: z-axis = alongz,alatz
x-axis = alongx,alatx = zero azimuth (longitude)
PSI,THETA,PHI = F(alongz,alatz,alongx,alatx)
initialized at ENTRY SETSYB.
----- ------
SYASYB, alongz,alatz,alongx,alatx
EULER2, along,alat,blong,blat, 7
System B to System A
======== ========
PSI,THETA,PHI = F(alongz,alatz,alongx,alatx)
initialized at ENTRY SETSYB.
----- ------
EULER2, blong,blat,along,alat, 8
15-AUG-1995 Comment bugfix: removed extraneous ;+ and ;-.
(See /host/bluemoon/usr2/idllib/contrib/groupk/euler2.pro)
NAME:
EXPDEV
PURPOSE:
Returns an exponentially distributed, positive, random deviate
using RAN2( seed ) as the source of uniform deviates. The
default unit mean and zero offset of the deviates may be modified
by setting the appropriate keywords.
CATEGORY:
Math.
CALLING SEQUENCE:
Result = EXPDEV( Seed [,N] )
INPUTS:
Seed: Seed for the random number generator. (It can be undefined)
OPTIONAL INPUTS:
N: Number of deviates to return, (1=Default).
OPTIONAL INPUT KEYWORD PARAMETERS:
MEAN: Mean of the deviates, (1=Default).
OFFSET: Offset of the deviates, (0=Default). The resulting
exponential distribution and its mean is offset by
this amount.
SUM: Open upper limit to the sum of all the deviates,
(i.e. TOTAL(EXPDEV(Seed,..)) < SUM), (0=Default).
Deviates will be generated until their sum is equal to
or greater than this cutoff. If this keyword is specified,
then the number of deviates generated is returned in the
optional argument, N.
CUTOFF: Minimum possible value of the deviates, (1e-37=Default).
If set, this value MUST be > 0.
MODIFICATION HISTORY:
Written by: Han Wen, October 1995.
02-NOV-1995 Formerly, EXPDT, changed keywords TAU -> OFFSET,
AVG -> MEAN, added CUTOFF keyword.
24-NOV-1995 Return a scalar when called with 1 argument,
(i.e. EXPDEV(Seed)).
03-JAN-1996 Bugfixes: TOTAL(dts)->TOTAL(dts,/DOUBLE),
N = round(N) -> round(N) > 1
28-MAR-1996 This SPECIAL version for the AIX utilized RAN2
instead of RANDOMU.
(See /host/bluemoon/usr2/idllib/contrib/groupk/expdev.pro)
NAME:
EXPDEV
PURPOSE:
Returns an exponentially distributed, positive, random deviate
using RANDOMU( seed ) as the source of uniform deviates. The
default unit mean and zero offset of the deviates may be modified
by setting the appropriate keywords.
CATEGORY:
Math.
CALLING SEQUENCE:
Result = EXPDEV( Seed [,N] )
INPUTS:
Seed: Seed for the random number generator. (It can be undefined)
OPTIONAL INPUTS:
N: Number of deviates to return, (1=Default).
OPTIONAL INPUT KEYWORD PARAMETERS:
MEAN: Mean of the deviates, (1=Default).
OFFSET: Offset of the deviates, (0=Default). The resulting
exponential distribution and its mean is offset by
this amount.
SUM: Open upper limit to the sum of all the deviates,
(i.e. TOTAL(EXPDEV(Seed,..)) < SUM), (0=Default).
Deviates will be generated until their sum is equal to
or greater than this cutoff. If this keyword is specified,
then the number of deviates generated is returned in the
optional argument, N.
CUTOFF: Minimum possible value of the deviates, (1e-37=Default).
If set, this value MUST be > 0.
MODIFICATION HISTORY:
Written by: Han Wen, October 1995.
02-NOV-1995 Formerly, EXPDT, changed keywords TAU -> OFFSET,
AVG -> MEAN, added CUTOFF keyword.
24-NOV-1995 Return a scalar when called with 1 argument,
(i.e. EXPDEV(Seed)).
03-JAN-1996 Bugfixes: TOTAL(dts)->TOTAL(dts,/DOUBLE),
N = round(N) -> round(N) > 1
(See /host/bluemoon/usr2/idllib/contrib/groupk/expdev_PC.pro)
NAME:
FACPRIME
PURPOSE:
Factor a number into its prime numbers.
CATEGORY:
Math.
CALLING SEQUENCE:
Result = FACPRIME( N, SUM=Sum )
INPUTS:
N: Number to factor into primes.
OUTPUTS:
Returns a two dimensional array, LONARR(2,nprime) where nprime
is the number of unique prime numbers. The first dimension holds
the value of each unique prime, Result(0,*) and the second
dimension holds the frequency or number of times that prime
occurs, Result(1,*).
COMMON BLOCKS:
FACPRIME: Holds an array containing the first 100000 prime numbers.
RESTRICTIONS:
The number to be factored must be < 1299709.
EXAMPLE:
pnums = FACPRIME( 63500 ) ; Factor 63500 into it pnums
help, pnums ; pnums LONG = Array(2,3)
print,REFORM(pnums(0,*) ; 2 5 127
print,REFORM(pnums(1,*) ; 2 3 1
ck = 1L ; (2^2)(5^3)(127) = 63500
for i=0,2 do $
ck=ck*long(pnums(0,i))^pnums(1,*)
MODIFICATION HISTORY:
Written by: Han Wen, August 1996.
11-Aug-1996 Missing prime number, 2 in factoring, eliminate
prime number, 1 from result.
(See /host/bluemoon/usr2/idllib/contrib/groupk/facprime.pro)
NAME:
FASPER
PURPOSE:
Given abscissas x (which need not be equally spaced) and ordinates
y, and given a desired oversampling factor ofac (a typical value
being 4 or larger). this routine creates an array wk1 with a
sequence of nout increasing frequencies (not angular frequencies)
up to hifac times the "average" Nyquist frequency, and creates
an array wk2 with the values of the Lomb normalized periodogram at
those frequencies. The arrays x and y are not altered. This
routine also returns jmax such that wk2(jmax) is the maximum
element in wk2, and prob, an estimate of the significance of that
maximum against the hypothesis of random noise. A small value of prob
indicates that a significant periodic signal is present.
CATEGORY:
Numerical Recipes routines.
CALLING SEQUENCE:
FASPER, X, Y, Ofac, Hifac, Wk1, Wk2 [, Nout, Jmax, Prob]
INPUTS:
X: Abscissas array, (e.g. an array of times).
Y: Ordinates array, (e.g. an array of corresponding counts).
Ofac: Oversampling factor.
Hifac: Hifac * "average" Nyquist frequency = highest frequency
for which values of the Lomb normalized periodogram will
be calculated.
OUTPUTS:
Wk1: An array of Lomb periodogram frequencies.
Wk2: An array of corresponding values of the Lomb periodogram.
OPTIONAL OUTPUTS:
Nout: The dimension of Wk1 and Wk2, i.e. the number of frequencies
calculated.
Jmax: The array index corresponding to the MAX( Wk2 ).
Prob: The False Alarm Probability (FAP) of the largest value of
of Lomb normalized periodogram.
MODIFICATION HISTORY:
Written by: Han Wen, December 1994. (Adapted from a Numerical
Recipes routine with the same name).
15-AUG-1996 Andrew Lee, Modified spread and fasper to use arrays
starting at 0 instead of 1, and fixed some bugs where
int was used instead of long.
(See /host/bluemoon/usr2/idllib/contrib/groupk/fasper.pro)
NAME:
FFINDSRC
PURPOSE:
Interactively finds all x-ray sources around a primary source
within the field of view of any HEAO A-1 scan in an IDL data
FILE. (FF abbreviation for FILE FIND)
CATEGORY:
Database.
CALLING SEQUENCE:
FFINDSRC [, Srclist]
OUTPUTS:
This function first finds all the sources around a primary source
and within the field of view of any scan in the IDL data file
by searching the XXX database. Only those sources the USER interactively
specifies will be written out to a file containing information
about the Name, RA in DEGREES and DEC in DEGREES for each source
selected.
OPTIONAL OUTPUT:
Srclist: The same information written out to the file but
packaged into an ARRAY of structures with tags
defined as:
Name: The name of the source, string.
RA: The RA of the source in DEGREES.
DEC: The DEC of the source in DEGREES.
If no sources are accepted by the USER then -1 is returned.
PROCEDURE:
(See description in FINDSRC).
MODIFICATION HISTORY:
Written by: Han Wen, November, 1994.
30-DEC-1994 Widgitized this routine, FFINDSRC -> FFINDSRC;
also added the Additional Source(s) file output option
used the XFIDUCIAL.
22-JAN-1995 Moved FFINDSRC->OBSOLETE directory. Renamed
XFFINDSRC->FFINDSRC
06-AUG-1996 Check if !DATA_PATH system variable is defined.
(See /host/bluemoon/usr2/idllib/contrib/groupk/ffindsrc.pro)
NAME:
FIDCUTS1
PURPOSE:
Applies various fiducial or "quality" cuts on an IDL HEAO A-1 data
file, extracts relevant scan characteristics into a data structure
and saves this structure to an IDL session file. The USER is able
to interactively select which scans to accept or reject, respective
or irrespective of the fiducial cuts.
CATEGORY:
HEAO A-1 scanning.
OPTIONAL INPUTS:
Former "command line" options such as the input IDL data filename
are now handled interactively within FIDCUTS1. You may select the
appropriate IDL data file by selecting the File pulldown submenu
on the Fiducial Main Menu.
OPTIONAL INPUT KEYWORDS:
All of the former optional input keywords may now be configured
interactively in FIDCUTS1 by selecting the Options pulldown submenu
on the Fiducial Main Menu.
CALLING SEQUENCE:
FIDCUTS1
OPTIONAL OUTPUTS:
The USER may interactively select to save the results of the
data analysis to an IDL session file (*.sav). The contents of this
saved file is one structure variable, named "data". The tags of this
data structure are defined as follows: (NOTE: Only signal region
data is saved!)
structure: data
tags:
Data file
Name Description Type(Size) formats
--------- ------------------------------ ------------------ ----------
mode Timing mode (320 ms or 5 ms). integer All
module Module number (1-7). integer All
npass Number of scans that passed integer All
the fiducial or quality cuts
nfail Number of scans that failed integer All
the fiducial or quality cuts.
nscan Total number of scans in data file integer All
nbin Total number of data points. integer All
nsig The number of bins in each scan intarr(npass) All
where the total transmission from
summing all sources is > 0.
nsig_src The number of bins in each scan intarr(npass,nsrc) All
where the transmission from each
source is > 0.
nsrc Number of sources in data. integer All
(for each scan if number of intarr(npass) All
sources vary)
name Name of each source in the data. strarr(nsrc) All
degree Degree of polynomial used to integer All
fit the background
mjfs First major frame number in lonarr(npass) All
each scan.
nmjfs Number of major frames in each intarr(npass) All
scan.
sig The signal = cts - background fltarr(nbin) All
at each bin where the trans. > 0
for each scan.
cts The detector counts, cts in the fltarr(nbin) All
signal region for each scan.
bkd The fitted background in the fltarr(nbin) All
signal region for each scan.
bkd_coeff The coefficients of the fitted fltarr(npass, All
background degree)
trns The transmissions of each source fltarr(nbin,nsrc) All
in the signal region for each scan.
phis The scan longitude in the signal dblarr(nbin) DIRS
region for each scan in RADIANS.
thts The scan latitude in the signal dblarr(nbin) DIRS
region for each scan in RADIANS.
intensity The fitted intensity, assuming fltarr(npass,nsrc) ASPECTS,
constant sources, for each source. STANDARD,
NOBARY
sigma The sigma uncertainties associated fltarr(npass,nsrc) ASPECTS,
with each fitted intensity. STANDARD,
NOBARY
pk_bins The bins where the transmission intarr(npass,nsrc) All
is a max. for each source and each
scan.
pk_trns The tranmission max. for each fltarr(npass,nsrc) All
and each scan.
overlap The fraction of each sourc trans. fltarr(npass,nsrc) All
overlapped by the sum of all the
other sources' trans.
t77i The integer time in seconds since lonarr(npass,nsrc) All
1977 at the peak trans. bin for
for each scan and each source.
t77f The fraction of a second since dblarr(npass,nsrc) All
1977 at the peak trans. bin for
for each scan and each source.
tcorr The barycentric time correction dblarr(2,npass, ASPECTS,
at the beginning and end of the nsrc) STANDARD
transmission function for each
scan and for each source.
aspects A structure containing the ASPECTS
satellite's aspects at the beginning
of each scan. This structure
contains two tags defined as:
y : The RA and DEC of the Y-axis dblarr(2,npass)
in DEGREES for each scan.
z : The RA and DEC of the Z-axis dblarr(2,npass)
in DEGREES for each scan.
MJF_RNG range of major frames selected by lonarr(2) All
USER, 0 if none.
BAD_MJFS list of bad major frames selected lonarr(nbad) All
by the USER, 0 if none.
FORMAT format of the IDL data file string All
NOTRNS flag to exclude transmission integer All
regions in fit of the scan, 1=yes
DEADTIME type of dead time correction integer All
applied to the cts data:
= 0, No dead time corrections
= 1, NON-Extended or NON-Paralyzable
dead time corrections made
= 2, Extended or Paralyzable
dead time corrections made
VERSION version number of the FIDCUTS1 float ASPECTS
routine that created the save file
Another output option is for Fiducial to write out the first major
frame number of every scan that was EXCLUDED; FAILED the fiducial
cuts; or optionally, REJECTED by the USER (*.bad). The USER
interactively chooses the name of this output file.
COMMON BLOCKS:
These common block are for INTERNAL USE ONLY.
DATA_COM: Common block holding the structure, data. This structure
contains all relevant scan characteristics for those scans
that pass the fiducial cuts.
INIT_COM: This common block holds all the settings configurable
by the USER. The variables within this common block
used to be optional keyword inputs to the Fiducial routine.
LC_COM: This common block holds the scan data for the current
scan for use of displaying or printing its light curve.
XF_CUT_COM: Keeps track of the Widget Identifier for the Main Menu.
MODIFICATION HISTORY:
August, 1994 H.C. Wen
06-SEP-1994 Changed PK_BINS to give bins relative to the
SAVED signal region, NOT relative to the 128 or
8192 bins! Eliminated PK_TRNS, PK_CTS and PK_THTS.
09-SEP-1994 Added the DEADTIME keyword to make deadtime corrections
to the data.
15-NOV-1994 Added the ASPECTS format.
20-NOV-1994 Additional sources may be added INTERACTIVELY.
21-NOV-1994 Mark bad MJFs for ALL failed scans, not just
those rejected interactively under FINAL CUT.
23-DEC-1994 Converted FIDCUTS1 into a widget routine
=> FIDCUTS1.
05-JAN-1995 Removed glitch cuts for 5ms data, added FILE
keyword to PICKFILE calls.
07-JAN-1995 Read in .dbs file (if available) to determine
MAX_NSCAN and MAX_NBIN.
11-JAN-1995 Bugfix: fixed warning messages when buffer full
and at end of data file.
17-JAN-1995 Bugfix: t77i = fltarr() => lonarr(). Also changed
t77f, tcorr = fltarr() => dblarr().
18-JAN-1995 Changed t77i,t77f from time at beginning of signal
region to time at peak trns. of each source.
Transposed all structure tags from ( nsrc,npass )
-> (npass, nsrc) (i.e. pk_bins, intensity, sigma,
tcorr and trns). Also added the version tag to
indicate which version of FIDCUTS1 created the
save file. (version 3.0)
19-JAN-1995 Bugfix: idl.max_nbin = nscan*nbin => nmjf*nbin
Added the YNCANCEL widget when quitting back to
the Fiducial Main Menu. (version 3.1)
22-JAN-1995 Moved FIDCUTS1 to the OBSOLETE directory and
renamed XFIDCUTS1 -> FIDCUTS1. (still version 3.1)
22-JAN-1995 Bugfix: made data.name = strarr(1) if nsrc=1,
previously=scalar string. (version 3.2)
27-JAN-1995 Bugfix: small bug if data only contains one scan,
cannot transpose a scalar => 1-D array = [scalar]
08-FEB-1995 Bugfix: data.name was incorrectly filled with
extra blank array elements between the primary
sources in the .idl data file and the sources
from the .add file. (version 3.4)
11-FEB-1995 Utilized CREATE_STRUCT when saving data structure,
added the PK_TRNS and ASPECTS tags, (version 4.0)
14-FEB-1995 Added the NSIG_SRC and OVERLAP tags, (version 5.0)
15-FEB-1995 Added the Passed after MJF cutoff option in the
light curves option menu, (version 5.1)
16-FEB-1995 Added the BKD_COEFF, FIDCUTS1 tags, (version 6.0)
Rename this routine FIDUCIAL -> FIDCUTS1, free
up memory when I can.
06-AUG-1996 Check if !SAVE_PATH, !DATA_PATH system variables
are defined.
(See /host/bluemoon/usr2/idllib/contrib/groupk/fidcuts1.pro)
NAME:
FIDCUTS2
PURPOSE:
Apply second round of fiducial cuts to the HEAO A-1 Scanning data.
CATEGORY:
HEAO A-1 Scanning.
CALLING SEQUENCE:
FIDCUTS2 [,Cuts]
OPTIONAL INPUTS:
Cuts: A 4-element array of cuts to be applied to the data, with
the following definitions:
Cuts(0) = Cut on the |background slope|
Cuts(1) = Cut on the number of signal bins
Cuts(2) = Cut on the overlap fraction
Cuts(3) = Cut on the transmission peak minimum
OUTPUTS:
This procedure writes out a new IDL SAVE session file containing the
scans which have passed the second round of fiducial cuts. The USER
is prompted for the filename of this IDL SAVE session file.
MODIFICATION HISTORY:
Written by: Han Wen, February 1995.
06-AUG-1996 Check if !SAVE_PATH system variable is defined.
(See /host/bluemoon/usr2/idllib/contrib/groupk/fidcuts2.pro)
NAME:
FIDUCIAL
PURPOSE:
Applies various fiducial or "quality" cuts on an IDL HEAO A-1 data
file, extracts relevant scan characteristics into a data structure
and saves this structure to an IDL session file. The USER is able
to interactively select which scans to accept or reject, respective
or irrespective of the fiducial cuts.
CATEGORY:
HEAO A-1 scanning.
OPTIONAL INPUTS:
Former "command line" options such as the input IDL data filename
are now handled interactively within FIDUCIAL. You may select the
appropriate IDL data file by selecting the File pulldown submenu
on the Fiducial Main Menu.
OPTIONAL INPUT KEYWORDS:
All of the former optional input keywords may now be configured
interactively in FIDUCIAL by selecting the Options pulldown submenu
on the Fiducial Main Menu.
CALLING SEQUENCE:
FIDUCIAL
OPTIONAL OUTPUTS:
The USER may interactively select to save the results of the
data analysis to an IDL session file (*.sav). The contents of this
saved file is one structure variable, named "data". The tags of this
data structure are defined as follows: (NOTE: Only signal region
data is saved!)
structure: data
tags:
Data file
Name Description Type(Size) formats
--------- ------------------------------ ------------------ ----------
mode Timing mode (320 ms or 5 ms). integer All
module Module number (1-7). integer All
npass Number of scans that passed integer All
the fiducial or quality cuts
nfail Number of scans that failed integer All
the fiducial or quality cuts.
nscan Total number of scans in data file integer All
nbin Total number of data points. integer All
nsig The number of bins in each scan intarr(npass) All
where the total transmission from
summing all sources is > 0.
nsig_src The number of bins in each scan intarr(npass,nsrc) All
where the transmission from each
source is > 0.
nsrc Number of sources in data. integer All
(for each scan if number of intarr(npass) All
sources vary)
name Name of each source in the data. strarr(nsrc) All
degree Degree of polynomial used to integer All
fit the background
mjfs First major frame number in lonarr(npass) All
each scan.
nmjfs Number of major frames in each intarr(npass) All
scan.
sig The signal = cts - background fltarr(nbin) All
at each bin where the trans. > 0
for each scan.
cts The detector counts, cts in the fltarr(nbin) All
signal region for each scan.
bkd The fitted background in the fltarr(nbin) All
signal region for each scan.
bkd_coeff The coefficients of the fitted fltarr(npass, All
background degree)
trns The transmissions of each source fltarr(nbin,nsrc) All
in the signal region for each scan.
phis The scan longitude in the signal dblarr(nbin) DIRS
region for each scan in RADIANS.
thts The scan latitude in the signal dblarr(nbin) DIRS
region for each scan in RADIANS.
intensity The fitted intensity, assuming fltarr(npass,nsrc) ASPECTS,
constant sources, for each source. STANDARD,
NOBARY
sigma The sigma uncertainties associated fltarr(npass,nsrc) ASPECTS,
with each fitted intensity. STANDARD,
NOBARY
pk_bins The bins where the transmission intarr(npass,nsrc) All
is a max. for each source and each
scan.
pk_trns The tranmission max. for each fltarr(npass,nsrc) All
and each scan.
overlap The fraction of each sourc trans. fltarr(npass,nsrc) All
overlapped by the sum of all the
other sources' trans.
t77i The integer time in seconds since lonarr(npass,nsrc) All
1977 at the peak trans. bin for
for each scan and each source.
t77f The fraction of a second since dblarr(npass,nsrc) All
1977 at the peak trans. bin for
for each scan and each source.
tcorr The barycentric time correction dblarr(2,npass, ASPECTS,
at the beginning and end of the nsrc) STANDARD
transmission function for each
scan and for each source.
aspects A structure containing the ASPECTS
satellite's aspects at the beginning
of each scan. This structure
contains two tags defined as:
y : The RA and DEC of the Y-axis dblarr(2,npass)
in DEGREES for each scan.
z : The RA and DEC of the Z-axis dblarr(2,npass)
in DEGREES for each scan.
MJF_RNG range of major frames selected by lonarr(2) All
USER, 0 if none.
BAD_MJFS list of bad major frames selected lonarr(nbad) All
by the USER, 0 if none.
FORMAT format of the IDL data file string All
NOTRNS flag to exclude transmission integer All
regions in fit of the scan, 1=yes
DEADTIME type of dead time correction integer All
applied to the cts data:
= 0, No dead time corrections
= 1, NON-Extended or NON-Paralyzable
dead time corrections made
= 2, Extended or Paralyzable
dead time corrections made
VERSION version number of the FIDUCIAL float ASPECTS
routine that created the save file
Another output option is for Fiducial to write out the first major
frame number of every scan that was EXCLUDED; FAILED the fiducial
cuts; or optionally, REJECTED by the USER (*.bad). The USER
interactively chooses the name of this output file.
COMMON BLOCKS:
These common block are for INTERNAL USE ONLY.
DATA_COM: Common block holding the structure, data. This structure
contains all relevant scan characteristics for those scans
that pass the fiducial cuts.
INIT_COM: This common block holds all the settings configurable
by the USER. The variables within this common block
used to be optional keyword inputs to the Fiducial routine.
LC_COM: This common block holds the scan data for the current
scan for use of displaying or printing its light curve.
XF_CUT_COM: Keeps track of the Widget Identifier for the Main Menu.
MODIFICATION HISTORY:
August, 1994 H.C. Wen
06-SEP-1994 Changed PK_BINS to give bins relative to the
SAVED signal region, NOT relative to the 128 or
8192 bins! Eliminated PK_TRNS, PK_CTS and PK_THTS.
09-SEP-1994 Added the DEADTIME keyword to make deadtime corrections
to the data.
15-NOV-1994 Added the ASPECTS format.
20-NOV-1994 Additional sources may be added INTERACTIVELY.
21-NOV-1994 Mark bad MJFs for ALL failed scans, not just
those rejected interactively under FINAL CUT.
23-DEC-1994 Converted FIDUCIAL into a widget routine
=> FIDUCIAL.
05-JAN-1995 Removed glitch cuts for 5ms data, added FILE
keyword to PICKFILE calls.
07-JAN-1995 Read in .dbs file (if available) to determine
MAX_NSCAN and MAX_NBIN.
11-JAN-1995 Bugfix: fixed warning messages when buffer full
and at end of data file.
17-JAN-1995 Bugfix: t77i = fltarr() => lonarr(). Also changed
t77f, tcorr = fltarr() => dblarr().
18-JAN-1995 Changed t77i,t77f from time at beginning of signal
region to time at peak trns. of each source.
Transposed all structure tags from ( nsrc,npass )
-> (npass, nsrc) (i.e. pk_bins, intensity, sigma,
tcorr and trns). Also added the version tag to
indicate which version of FIDUCIAL created the
save file. (version 3.0)
19-JAN-1995 Bugfix: idl.max_nbin = nscan*nbin => nmjf*nbin
Added the YNCANCEL widget when quitting back to
the Fiducial Main Menu. (version 3.1)
22-JAN-1995 Moved FIDUCIAL to the OBSOLETE directory and
renamed XFIDUCIAL -> FIDUCIAL. (still version 3.1)
22-JAN-1995 Bugfix: made data.name = strarr(1) if nsrc=1,
previously=scalar string. (version 3.2)
27-JAN-1995 Bugfix: small bug if data only contains one scan,
cannot transpose a scalar => 1-D array = [scalar]
08-FEB-1995 Bugfix: data.name was incorrectly filled with
extra blank array elements between the primary
sources in the .idl data file and the sources
from the .add file. (version 3.4)
11-FEB-1995 Utilized CREATE_STRUCT when saving data structure,
added the PK_TRNS and ASPECTS tags, (version 4.0)
14-FEB-1995 Added the NSIG_SRC and OVERLAP tags, (version 5.0)
15-FEB-1995 Added the Passed after MJF cutoff option in the
light curves option menu, (version 5.1)
16-FEB-1995 Added the BKD_COEFF tag, (version 6.0)
06-AUG-1996 Check if !SAVE_PATH, !DATA_PATH system variables
are defined.
(See /host/bluemoon/usr2/idllib/contrib/groupk/fiducial.pro)
NAME:
FINDSRC
PURPOSE:
Interactively finds all x-ray sources around a primary source
within the field of view of a HEAO A-1 scan. Uses the XXX database.
CATEGORY:
Database.
CALLING SEQUENCE:
Result = FINDSRC( Module, Cts, Src, Sat )
INPUTS:
Module: Collimator module number.
Cts: Counts of the scan, fltarr(nbin).
Src: Structure containing information about the primary source.
Its must have the following tags defined:
RA: The RA of the primary source in DEGREES.
DEC: The DEC of the primary source in DEGREES.
trn: The collimator transmissions of the primary source
across the scan, fltarr(nbin).
Sat: Structure containing information about the satellite's
position. It must have the following tags defined:
RAY,DEY: The RA,DEC of the Y-axis of the satellite
in RADIANS at either the beginning of each
major frame, fltarr( nmjfs ) or at each
bin, fltarr( nbin ).
RAZ,DEZ: The RA,DEC of the Z-axis of the satellite
in RADIANS at either the beginning of each
major frame, fltarr( nmjfs ) or at each
bin, fltarr( nbin ).
OPTIONAL INPUT KEYWORD PARAMETERS:
DEGREES: Set this keyword to interactively input the RA and
DEC of any additional USER-defined sources not
found in the database in DEGREES. ((hh mm ss) and
(dd mm ss)] = Default).
FLUX_CUTOFF: Minimum flux requirement in MICROJY for any
source found in the database, (i.e. you want to find
all sources with its max. flux > FLUX_CUTOFF). (0=Default)
MJFS: List of major frame numbers for this scan, lonarr( nmjf ).
USERSRC: ARRAY of structures holding information about each
USER-defined source to be plotted and returned
in addition to those found by the database. It must
have the following tags defined for each structure.
Name: The name of the source, string.
RA: The RA of the source in DEGREES.
DEC: The DEC of the source in DEGREES.
(See example below for implementation).
OUTPUTS:
This function first finds all the sources around a primary source
and within the field of view of a scan by searching a database.
Only those sources the USER interactively specifies will be
returned in an ARRAY of structures with tags defined as:
Name: The name of the source, string.
RA: The RA of the source in DEGREES.
DEC: The DEC of the source in DEGREES.
If no sources are accepted by the USER then -1 is returned.
RESTRICTIONS:
There are TWO PRECONDITIONS that must be satisfied before calling
this routine, 1) That the XXX database is currently opened using
the Astronomy Library routine DBOPEN; and 2) The light curve
color table has already been loaded by calling the LCLOADCT routine.
(See example below).
PROCEDURE:
When you call this routine, a database is first searched for all
sources within a cone about the primary source, defined by the
Src structure. The (1/2) separation or polar angle defining this
cone is the larger of the two angles between the source position
on the scan and the bin edges of the scan added in quadrature with
8 degrees to account for the collimator's acceptance.
For each source found, its corresponding transmissions are
calculated across the scan. The transmissions for this source
as well as for the primary source are then plotted over the
light curve for this scan. The USER is then prompted about
whether to add this source to the list that will eventually be
returned.
EXAMPLE:
Let's say we want to find all the sources around 1H1741-32
that will actually show up in the scan because they're within
the acceptance of the collimator module.
name = '1H1741-32'
src = { RA:265.4, DEC:-32.2, Trn:trn }
sat = { RAY:RAY, DEY:DEY, RAZ:RAZ, DEZ:DEZ }
Let's additionally say we already know two sources, 1H1715-321
and 1H1728-334.A that will show up; so we want them plotted
immediately:
othersrc = { name:'', RA:0.0, DEC:0.0 }
othersrc = REPLICATE( othersrc, 2)
othersrc( 0).name =
othersrc( 0).RA = 258.885
othersrc( 0).DEC = -32.1261
othersrc( 1).name = '
othersrc( 1).RA = 262.165
othersrc( 1).DEC = -33.7969
We must first open the XXX database, and load the light curve
color table:
DBOPEN,'xxx'
LCLOADCT
Now, we can go ahead and interactively get the list:
list = FINDSRC( Module, Cts, Src, Sat, USERSRC=othersrc )
You will find, in addition to those you accept:
list(0).name = 1H1715-321
list(1).name = 1H1728-334.A
..etc
MODIFICATION HISTORY:
Written by: Han Wen, November, 1994.
30-DEC-1994 Widgetized this routine FINDSRC->FINDSRC.
10-JAN-1995 Fixed small typo bug.
22-JAN-1995 Moved FINDSRC -> OBSOLETE directory. Renamed
XFINDSRC->FINDSRC
(See /host/bluemoon/usr2/idllib/contrib/groupk/findsrc.pro)
NAME:
FITSCAN
PURPOSE:
Fits for the source intensities and background in a scan assuming
constant intensities and a polynomial background. The method of
multiple linear regression is employed.
CATEGORY:
Curve fitting.
CALLING SEQUENCE:
FITSCAN, Cts, Trns, Ndegree
INPUTS:
Cts: Counts or "data" in each bin of the scan, [float(nbin)]
Trns: A nsrc x nbin array of transmission functions, [float( nsrc, nbin )].
Ndegree: The degree of the polynomial to be fitted to the background.
OPTIONAL INPUT KEYWORD PARAMETERS:
NOTRNS: If this keyword is set, then the transmissions are ignored,
and ONLY the background regions are fitted. All variables
associated with the transmissions are either set to 0 or -1.
( Note: if all sources fit for negative intensities then this
mode is automatically set! )
MIN_TRN: Sets the minimum transmission peak allowed for all
sources. Sources which fall below this minimum have their
intensities set to 0 and are excluded from the fitting.
The default value is 0, and must be GE 0 and LE 1.
MAX_FDER: The fractional derivative cut used in the routine GLITCH for
removing glitches from the background data, [float].
NOWARN: Suppress printing of warning messages.
LOG: Write warning messages to log file.
OUTPUT KEYWORD PARAMETERS:
OCOEFF: Structure holding all the coefficients of the fit. Its tags
are defined as follows:
intensity : fitted intensities for each source, [float( nbin )].
bkd : coefficients of the polynomial background fit,
starting from the constant term, ending at the
Cn * bin^ndegree term, [float( ndegree+1 )].
(NOTE:if source fits for a negative intensity, the intensity is
set to 0, but its corresponding uncertainty, OSIGMA.intensity
is kept)
OSIGMA: Structure holding the sigmas associated with each of the
fitted coefficients defined in OCOEFF. Its tags are defined as
follows:
intensity : sigmas of OCOEFF.intensity, [float( nbin )].
bkd : sigmas of OCOEFF.bkd, [float( ndegree+1 )].
OFIT: Structure holding the fit of the scan at each bin. Its tags
are defined as follows:
data : overall fit to the data at each bin, [float( nbin )].
bkd : polynomial fit to the background, [float( nbin )].
sig : sum of Intensity * Transmission over all the
sources at each bin, [float( nbin )].
OREGRESS: Structure holding some of the "tests of fit" results from
the multiple linear regression. Its tags are defined as follows:
Ftest : value of F for test of fit.
R : vector of linear correlation coefficient.
Rmul : multiple linear correlation coefficient.
CL : confidence level of the overall reduced chi-squared
per degree of freedom.
ORCHISQ: Structure holding the reduced chi-squared per degree of
freedom for the various regions of fitting. All bins with
glitches are excluded. Its tags are defined as follows:
data : overall reduced chi-squared over all the bins.
bkd : reduced chi-squared for the background region.
sig : reduced chi-squared for the signal region where
transmissions > 0.
OGLITCH: Structure holding all glitches found in the data for the
various regions of fitting. Its tags are defined as follows:
nglitch : number of glitches found in the data.
nbkd : number of glitches found in the background region.
nsig : number of glitches found in the signal region.
here_bkd : array of indices pointing to glitch bins in the
background region. (Set to -1 if there are no glitches.)
here_sig : array of indices pointing to glitch bins in the
signal region. (Set to -1 if there are no glitches.)
EXAMPLE:
Let's create some fake data...
Define our fake sources
nsrc = 5
nbin = 512
nglitch = 10
here_bin = indgen(nbin)
ctrs = [50, 100, 110, 250, 300]
sigs = [10, 20, 30, 15, 10]
Amps = [0.8, 0.6, 0.4, 0.9, 0.2]
Ins = [100., 450., 210., 230., 120.]
Create gaussain transmission sources
trns = fltarr( nsrc, nbin )
for i=0,nsrc-1 do begin
trns( i,* ) = Amps(i) * exp( -( here_bin - ctrs(i) )^2./sigs(i)^2. )
here_ltcut = WHERE( trns( i,* ) lt 0.01, nltcut )
if nltcut gt 0 then trns( i,here_ltcut ) = 0.0
endfor
Put in montonically increasing background with normally distributed noise
A0 = 50.
slope= 0.05
bkd = A0 + slope * here_bin + 5. * randomn( seed, nbin )
Add the background and the signal
cts = bkd + TRANSPOSE(Ins # trns)
Put in zero and overflow glitches
here_glitch = intarr( nglitch )
for i=0,nglitch/2 -1 do begin
j = fix( randomu( seed ) * (nbin-1) )
cts(j) = cts(j) + 1000.
here_glitch(i) = j
endfor
for i=nglitch/2,nglitch-1 do begin
j = fix( randomu( seed ) * (nbin-1) )
cts(j) = 0.0
here_glitch(i) = j
endfor
plot,bkd,/xstyle & wshow & pause
for i=0,nsrc-1 do begin
plot,trns(i,*),/xstyle
pause
endfor
plot,cts,psym=10,/xstyle & pause
Fit the data!
FITSCAN, cts, trns, 1, OCOEFF=Ocoeff, OSIGMA=Osigma, OFIT=Ofit, $
ORCHISQ=Orchisq, OGLITCH = Oglitch
oplot,ofit.bkd & pause
oplot,ofit.sig & pause
oplot,Ofit.data & pause
wdelete,0
print,'Real Intensities:',Ins
print,'Fit Intensities:',ocoeff.intensity
print,'Fit sigmas :',osigma.intensity
pause
print,'Real background:',A0,' + ',slope,' * bins'
print,'Fit background:',ocoeff.bkd
print,'Fit sigmas :',osigma.bkd
pause
print,'Real glitches:', here_glitch
print,'Fit glitches: number:',oglitch.nglitch
print,' bkd: number:',oglitch.nbkd
print,' bins:',oglitch.here_bkd
print,' sig: number:',oglitch.nsig
print,' bins:',oglitch.here_sig
MODIFICATION HISTORY:
Written by: Han Wen, May 1994.
10-MAY-1994: Removes glitches from underneath non-zero transmission
regions and excludes these data points from the fitting.
19-MAY-1994: Adapted from CT_RATE, restricting to regression analysis;
Fit signal and background simultaneously; If fitted
intensities are negative, set to 0, exclude from analysis
and refit the data.
09-JUN-1994: Minor bug fixes for improbable cases, added BADFIT label.
20-JUL-1994: Bug fix: the ZERO_ONLY/CUT keywords were switched between
background/peak GLITCH calls!
28-AUG-1994: Formerly named, INTENSITY. Changed optional outputs
to output KEYWORD structures. Made code more intelligible
and readable. Added the NOTRNS keyword.
19-SEP-1994: Added the Confidence level for the overall fit, CL.
19-NOV-1994: Bug fix: problem with properly zeroing transmissions
corresponding to negative fitted intensities.
15-DEC-1994: Added the BADFIT label for the case of NO good bkd bins.
10-JAN-1995: Bug fix: include case when nsig=0.
(See /host/bluemoon/usr2/idllib/contrib/groupk/fitscan.pro)
NAME:
FIT_BKD
PURPOSE:
Perform a least-square polynomial fit to the background of a major
frame with optional error estimates.
This routine uses matrix inversion. A newer version of this routine,
SVDFIT, uses Singular Value Decomposition. The SVD technique is more
flexible, but slower.
Another version of this routine, POLYFITW, performs a weighted
least square fit.
CATEGORY:
Curve fitting.
CALLING SEQUENCE:
Result = FIT_BKD(Cts, Trns [, NDegree ,Yfit, Yband, Sigma, A, Chisq] )
INPUTS:
Cts: An array holding the counts for this major frame, [float( nbin )].
Trns: A nsrc x nbin array holding all the transmission functions
for this major frame.
OPTIONAL INPUT KEYWORDS:
NDegree: The degree of the polynomial to fit. If the USER does not
specify this, NDegree defaults to 1.
NOTE: if the USER sets NDegree= 0 then the background
is simply the weighted average, assuming Poisson statistics,
(i.e. sigma2 = Counts )
CUT: The fractional derivative cut used in the routine GLITCH for
removing glitches from the background data, [float].
OUTPUTS:
FIT_BKD returns a vector of coefficients with a length of NDegree+1.
OPTIONAL OUTPUT PARAMETERS:
Yfit: The vector of calculated Y's. These values have an error
of + or - Yband.
Yband: Error estimate for each point = 1 sigma
Sigma: The standard deviation in Y units.
A: Correlation matrix of the coefficients.
Chisq: The Chi-squared for this fit, assuming poisson statistics.
OPTIONAL OUTPUT KEYWORDS:
GLITCHES: A list of bins where glitches were found in the background.
Returns a -1 if no glitches were found, [integer( nbad )]
BIN_PK: A list of bins where the transmissions are a maximum, [integer( nsrc )].
BKD_PK: The fitted background values at the bins where the transmissions
are a maximum, [float( nsrc )].
EXAMPLE:
Let's find the background for some major frame in 320ms mode with 2 sources
in the field of view:
let's generate random background and data:
cts = randomn( seed, 128 )
trns = fltarr( 2, 128 )
for i=20,80 do trns( 0,i ) = randomn( seed )
for i=50,100 do trns( 1,i ) = randomn( seed )
coeff = FIT_BKD( Cts, Trns, 1, Bkd, ErrBars )
MODIFICATION HISTORY:
Written by: H. C. Wen, April, 1994.
27-APR-1994 Changed the name from GET_BKD and added the option to fit the
background to a polynomial.
04-MAY-1994 For Ndegree=0, changed the average background to a
weighted average, where sigma2 = counts.
05-MAY-1994 Added Chisq as an optional output. Converted the
for/do loops into matrix algebra.
08-MAY-1994 Removed glitches from the background data with GLITCH routine.
(See /host/bluemoon/usr2/idllib/contrib/groupk/fit_bkd.pro)
NAME:
FOLD_LC
PURPOSE:
Folds the light curves for a source using a USER provided
period and plots the resulting folded light curves.
CATEGORY:
Plotting.
INPUTS:
Time: Array of times in SECONDS since 1/1/77, [dblarr( npts )].
Flux: Array of corresponding intensities for the source,
[fltarr( npts )] in units specified by the FLUX_UNITS keyword.
Err: Array of corresponding uncertainties for each intensity
[fltarr( npts )] in units specified by the FLUX_UNITS keyword.
Period: Folding period in HOURS.
SrcName: The name of the source, [string].
OPTIONAL INPUT PARAMETERS:
FLUX_UNITS: The units of the given intensities, [string], (''=Default).
OUTPUTS:
This routine makes light curves of the HEAO A-1 data and sends
them to the graphic device if the USER selects it from the widget
menu.
MODIFICATION HISTORY:
September, 1994 H.C. Wen
02-FEB-1995 Implemented XPLOT, XOPLOT
08-FEB-1995 Eliminated the HALF keyword for simplicity.
(See /host/bluemoon/usr2/idllib/contrib/groupk/fold_lc.pro)
NAME:
GET_ASPECTS
PURPOSE:
Subroutine interpolates, or extrapolates, the aspect angles, right
ascension and declination (alpha, delta), for the Y- and Z-axes
given the initial and final value for these angles. The Z-axis is
assumed to be the spin axis.
The interpolation (or extrapolation) is done by first converting
alpha,delta to celestial cartesian coordinates, then cartesian
coordinates to Euler angles. The Euler angles are interpolated to
the desired number of intermediate points, then converted back to
cartesian coordinates, and finally to alphas and deltas.
Note that the aspects are interpolated, or extrapolated, to the
middle of each bin, and that the initial and final aspects
supplied in the input arguments bound the beginning of the first
bin and the end of the last bin, respectively.
CATEGORY:
Interpolation
CALLING SEQUENCE:
GET_ASPECTS, Mode, Bins, Ry,Dy, Rz,Dz, Y_asp, Z_asp
INPUTS:
Mode: The interpolation "mode", [integer].
If MODE=0, aspects are INTERPOLATED for values between
the initial and final aspects.
If MODE=1, aspects are EXTRAPOLATED beyond the final
aspects given.
Bins: The number of intermediate or extrapolated bins
between the initial and final aspects, [integer].
Ry: The initial and final values of the Y-axis
right ascension, [float(2)].
Dy: The initial and final values of the Y-axis
declination, [float(2)].
Rz: The initial and final values of the Z-axis
right ascension, [float(2)].
Dz: The initial and final values of the Z-axis
declination, [float(2)].
OPTIONAL INPUT KEYWORDS:
OFFSET: The number of bins from the bin edge where the aspects
are calculated. The default is 0.5 bin, namely, the center
of each bin, [float].
OUTPUTS:
Y_asp: The interpolated (or extrapolated) Y-axis right
ascension and declination for each of BINS points, [float(2,Bins)].
Z_asp: The interpolated (or extrapolated) Z-axis right
ascension and declination for each of BINS points, [float(2,Bins)].
MODIFICATION HISTORY:
Written by: K.H. Fairfield, 02-DEC-1992.
09-FEB-93: Changed the meaning of the BINS input argument to be
the actual number of bins between the bounding aspects,
rather than the number of intermediate points, so as to
calculate the returned aspects at the center of each bin
rather than the bin edge.
N.B. Because of these changes, calling programs must be
modified accordingly.
06-JUN-1994: Adapted routine into an IDL procedure, H.C. Wen.
22-JUN-1994: Vectorized routine to eliminate for loops.
Added the OFFSET keyword.
15-AUG-1995 Comment bugfix: removed extraneous ;+ and ;-.
(See /host/bluemoon/usr2/idllib/contrib/groupk/get_aspects.pro)
NAME:
GET_DATA
PURPOSE:
This function restores an IDL SAVE Session file created by the
FIDUCIAL routine and returns the saved DATA structure.
CATEGORY:
I/O
CALLING SEQUENCE:
Result = GET_DATA( [Filename] )
OPTIONAL INPUTS:
Filename: The filename (including path) of the IDL save session file.
If this parameter is not provided by the USER, then the
USER will be prompted to select the desired file from a
widget menu.
OPTIONAL INPUT KEYWORD PARAMETERS:
TITLE: The title of the widget window that displays information
to the USER ('Get_DATA'=Default)
VERSION: The Version number that the DATA structure must be greater
than or equal to. (3=Default)
OUTPUTS:
The DATA structure saved in the IDL SAVE session file is returned.
If the DATA structure is invalid or the USER aborts selecting a
file by pressing the Cancel button, then a 'NULL' structure is
returned {NULL:0}
OPTIONAL OUTPUT KEYWORD PARAMETERS:
OFILE: The filename (including path) of the IDL save session file
restored.
RESTRICTIONS:
The IDL SAVE session file must have been created by the FIDUCIAL
routine.
MODIFICATION HISTORY:
Written by: Han Wen, February 1995.
08-FEB-1995 Added the OFILE keyword.
06-AUG-1996 Check if !SAVE_PATH system variable is defined.
(See /host/bluemoon/usr2/idllib/contrib/groupk/get_data.pro)
NAME:
GET_FMT
PURPOSE:
This function extracts the name of the format of an IDL data file.
CATEGORY:
I/O.
CALLING SEQUENCE:
Result = GET_FMT( File )
INPUTS:
File: Name of the IDL data file. If none is provided, the
USER will be prompted for it via PICKFILE().
OUTPUTS:
The format name is returned. If the format of the IDL data file
is not among the currently recognized data formats, then a
null string, '' is returned. The list of currently recognized
data format is a follows:
'ASPECTS'
'STANDARD'
'NOBARY'
EXAMPLE:
;Let's say we have the IDL data file, 1755-33.IDL and we would
;like to determine the format of this file:
fmt = GET_FMT( !DATA_PATH+'1755-33.IDL' )
;The value of fmt will be: 'ASPECTS'
MODIFICATION HISTORY:
Written by: Han Wen, December 1994.
06-AUG-1996 Make File a required input parameter.
(See /host/bluemoon/usr2/idllib/contrib/groupk/get_fmt.pro)
NAME:
GET_NSRC
PURPOSE:
This function extracts the number of sources in an IDL data file.
CATEGORY:
I/O.
CALLING SEQUENCE:
Result = GET_NSRC( File )
INPUTS:
File: Name of the IDL data file.
OUTPUTS:
The number of sources in the IDL data file is returned.
MODIFICATION HISTORY:
Written by: Han Wen, December 1994.
06-AUG-1996 Make File a required input parameter.
(See /host/bluemoon/usr2/idllib/contrib/groupk/get_nsrc.pro)
NAME:
GET_PEAK
PURPOSE:
Finds the bin(s) where the transmission curves are a maximum.
CATEGORY:
Curve fitting.
CALLING SEQUENCE:
Result = GET_PEAK( Trns )
INPUTS:
Trns: A nsrc x nbin array of transmission functions, [float( nsrc, nbin )].
OUTPUTS:
This functions returns the bin numbers where the transmission
curves are a maximum, [integer(nsrc)].
MODIFICATION HISTORY:
Written by: Han Wen, May, 1994.
17-MAY-1994: Restricted the functionality of this routine to ONLY
returning the bins; moved other characteristics, like
the fitted background @ peak to the routine(s) which
calculate these values.
(See /host/bluemoon/usr2/idllib/contrib/groupk/get_peak.pro)
NAME:
GET_SCAN
PURPOSE:
This function reads in major frame(s) of the HEAO A-1 data from a
data file into buffers. Each buffer contains a set of sequential
major frames and may be referred to as a "scan". The number of
sequential major frames may vary according to the number of
sequential major frames found in the data file.
CATEGORY:
I/O
CALLING SEQUENCE:
Result = GET_SCAN( Move [, PICKMJF=Pickmjf, DATA=Data, NOWARN=Nowarn, LOG=Log] )
INPUTS:
Move: Buffer command to tell which buffer to retreive:
1 -> Get the next buffer.
0 -> Get the current buffer.
-1 -> Get the previous buffer.
If the buffer pointer is at the top of the buffer stack and
Move = 1, then the next major frame buffer is read from the data file.
INPUT KEYWORD PARAMETERS:
PICKMJF: Get the major frame buffer with the major frame number
specified by PICKMJF by searching forward. NOTE: Move must
be set to 1 if the PICKMJF keyword is set, [long].
NOWARN: Suppress printing of warning messages to screen.
LOG: Output warning messages to log file.
OUTPUTS: